babylon.module.d.ts 7.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765159766159767159768159769159770159771159772159773159774159775159776159777159778159779159780159781159782159783159784159785159786159787159788159789159790159791159792159793159794159795159796159797159798159799159800159801159802159803159804159805159806159807159808159809159810159811159812159813159814159815159816159817159818159819159820159821159822159823159824159825159826159827159828159829159830159831159832159833159834159835159836159837159838159839159840159841159842159843159844159845159846159847159848159849159850159851159852159853159854159855159856159857159858159859159860159861159862159863159864159865159866159867159868159869159870159871159872159873159874159875159876159877159878159879159880159881159882159883159884159885159886159887159888159889159890159891159892159893159894159895159896159897159898159899159900159901159902159903159904159905159906159907159908159909159910159911159912159913159914159915159916159917159918159919159920159921159922159923159924159925159926159927159928159929159930159931159932159933159934159935159936159937159938159939159940159941159942159943159944159945159946159947159948159949159950159951159952159953159954159955159956159957159958159959159960159961159962159963159964159965159966159967159968159969159970159971159972159973159974159975159976159977159978159979159980159981159982159983159984159985159986159987159988159989159990159991159992159993159994159995159996159997159998159999160000160001160002160003160004160005160006160007160008160009160010160011160012160013160014160015160016160017160018160019160020160021160022160023160024160025160026160027160028160029160030160031160032160033160034160035160036160037160038160039160040160041160042160043160044160045160046160047160048160049160050160051160052160053160054160055160056160057160058160059160060160061160062160063160064160065160066160067160068160069160070160071160072160073160074160075160076160077160078160079160080160081160082160083160084160085160086160087160088160089160090160091160092160093160094160095160096160097160098160099160100160101160102160103160104160105160106160107160108160109160110160111160112160113160114160115160116160117160118160119160120160121160122160123160124160125160126160127160128160129160130160131160132160133160134160135160136160137160138160139160140160141160142160143160144160145160146160147160148160149160150160151160152160153160154160155160156160157160158160159160160160161160162160163160164160165160166160167160168160169160170160171160172160173160174160175160176160177160178160179160180160181160182160183160184160185160186160187160188160189160190160191160192160193160194160195160196160197160198160199160200160201160202160203160204160205160206160207160208160209160210160211160212160213160214160215160216160217160218160219160220160221160222160223160224160225160226160227160228160229160230160231160232160233160234160235160236160237160238160239160240160241160242160243160244160245160246160247160248160249160250160251160252160253160254160255160256160257160258160259160260160261160262160263160264160265160266160267160268160269160270160271160272160273160274160275160276160277160278160279160280160281160282160283160284160285160286160287160288160289160290160291160292160293160294160295160296160297160298160299160300160301160302160303160304160305160306160307160308160309160310160311160312160313160314160315160316160317160318160319160320160321160322160323160324160325160326160327160328160329160330160331160332160333160334160335160336160337160338160339160340160341160342160343160344160345160346160347160348160349160350160351160352160353160354160355160356160357160358160359160360160361160362160363160364160365160366160367160368160369160370160371160372160373160374160375160376160377160378160379160380160381160382160383160384160385160386160387160388160389160390160391160392160393160394160395160396160397160398160399160400160401160402160403160404160405160406160407160408160409160410160411160412160413160414160415160416160417160418160419160420160421160422160423160424160425160426160427160428160429160430160431160432160433160434160435160436160437160438160439160440160441160442160443160444160445160446160447160448160449160450160451160452160453160454160455160456160457160458160459160460160461160462160463160464160465160466160467160468160469160470160471160472160473160474160475160476160477160478160479160480160481160482160483160484160485160486160487160488160489160490160491160492160493160494160495160496160497160498160499160500160501160502160503160504160505160506160507160508160509160510160511160512160513160514160515160516160517160518160519160520160521160522160523160524160525160526160527160528160529160530160531160532160533160534160535160536160537160538160539160540160541160542160543160544160545160546160547160548160549160550160551160552160553160554160555160556160557160558160559160560160561160562160563160564160565160566160567160568160569160570160571160572160573160574160575160576160577160578160579160580160581160582160583160584160585160586160587160588160589160590160591160592160593160594160595160596160597160598160599160600160601160602160603160604160605160606160607160608160609160610160611160612160613160614160615160616160617160618160619160620160621160622160623160624160625160626160627160628160629160630160631160632160633160634160635160636160637160638160639160640160641160642160643160644160645160646160647160648160649160650160651160652160653160654160655160656160657160658160659160660160661160662160663160664160665160666160667160668160669160670160671160672160673160674160675160676160677160678160679160680160681160682160683160684160685160686160687160688160689160690160691160692160693160694160695160696160697160698160699160700160701160702160703160704160705160706160707160708160709160710160711160712160713160714160715160716160717160718160719160720160721160722160723160724160725160726160727160728160729160730160731160732160733160734160735160736160737160738160739160740160741160742160743160744160745160746160747160748160749160750160751160752160753160754160755160756160757160758160759160760160761160762160763160764160765160766160767160768160769160770160771160772160773160774160775160776160777160778160779160780160781160782160783160784160785160786160787160788160789160790160791160792160793160794160795160796160797160798160799160800160801160802160803160804160805160806160807160808160809160810160811160812160813160814160815160816160817160818160819160820160821160822160823160824160825160826160827160828160829160830160831160832160833160834160835160836160837160838160839160840160841160842160843160844160845160846160847160848160849160850160851160852160853160854160855160856160857160858160859160860160861160862160863160864160865160866160867160868160869160870160871160872160873160874160875160876160877160878160879160880160881160882160883160884160885160886160887160888160889160890160891160892160893160894160895160896160897160898160899160900160901160902160903160904160905160906160907160908160909160910160911160912160913160914160915160916160917160918160919160920160921160922160923160924160925160926160927160928160929160930160931160932160933160934160935160936160937160938160939160940160941160942160943160944160945160946160947160948160949160950160951160952160953160954160955160956160957160958160959160960160961160962160963160964160965160966160967160968160969160970160971160972160973160974160975160976160977160978160979160980160981160982160983160984160985160986160987160988160989160990160991160992160993160994160995160996160997160998160999161000161001161002161003161004161005161006161007161008161009161010161011161012161013161014161015161016161017161018161019161020161021161022161023161024161025161026161027161028161029161030161031161032161033161034161035161036161037161038161039161040161041161042161043161044161045161046161047161048161049161050161051161052161053161054161055161056161057161058161059161060161061161062161063161064161065161066161067161068161069161070161071161072161073161074161075161076161077161078161079161080161081161082161083161084161085161086161087161088161089161090161091161092161093161094161095161096161097161098161099161100161101161102161103161104161105161106161107161108161109161110161111161112161113161114161115161116161117161118161119161120161121161122161123161124161125161126161127161128161129161130161131161132161133161134161135161136161137161138161139161140161141161142161143161144161145161146161147161148161149161150161151161152161153161154161155161156161157161158161159161160161161161162161163161164161165161166161167161168161169161170161171161172161173161174161175161176161177161178161179161180161181161182161183161184161185161186161187161188161189161190161191161192161193161194161195161196161197161198161199161200161201161202161203161204161205161206161207161208161209161210161211161212161213161214161215161216161217161218161219161220161221161222161223161224161225161226161227161228161229161230161231161232161233161234161235161236161237161238161239161240161241161242161243161244161245161246161247161248161249161250161251161252161253161254161255161256161257161258161259161260161261161262161263161264161265161266161267161268161269161270161271161272161273161274161275161276161277161278161279161280161281161282161283161284161285161286161287161288161289161290161291161292161293161294161295161296161297161298161299161300161301161302161303161304161305161306161307161308161309161310161311161312161313161314161315161316161317161318161319161320161321161322161323161324161325161326161327161328161329161330161331161332161333161334161335161336161337161338161339161340161341161342161343161344161345161346161347161348161349161350161351161352161353161354161355161356161357161358161359161360161361161362161363161364161365161366161367161368161369161370161371161372161373161374161375161376161377161378161379161380161381161382161383161384161385161386161387161388161389161390161391161392161393161394161395161396161397161398161399161400161401161402161403161404161405161406161407161408161409161410161411161412161413161414161415161416161417161418161419161420161421161422161423161424161425161426161427161428161429161430161431161432161433161434161435161436161437161438161439161440161441161442161443161444161445161446161447161448161449161450161451161452161453161454161455161456161457161458161459161460161461161462161463161464161465161466161467161468161469161470161471161472161473161474161475161476161477161478161479161480161481161482161483161484161485161486161487161488161489161490161491161492161493161494161495161496161497161498161499161500161501161502161503161504161505161506161507161508161509161510161511161512161513161514161515161516161517161518161519161520161521161522161523161524161525161526161527161528161529161530161531161532161533161534161535161536161537161538161539161540161541161542161543161544161545161546161547161548161549161550161551161552161553161554161555161556161557161558161559161560161561161562161563161564161565161566161567161568161569161570161571161572161573161574161575161576161577161578161579161580161581161582161583161584161585161586161587161588161589161590161591161592161593161594161595161596161597161598161599161600161601161602161603161604161605161606161607161608161609161610161611161612161613161614161615161616161617161618161619161620161621161622161623161624161625161626161627161628161629161630161631161632161633161634161635161636161637161638161639161640161641161642161643161644161645161646161647161648161649161650161651161652161653161654161655161656161657161658161659161660161661161662161663161664161665161666161667161668161669161670161671161672161673161674161675161676161677161678161679161680161681161682161683161684161685161686161687161688161689161690161691161692161693161694161695161696161697161698161699161700161701161702161703161704161705161706161707161708161709161710161711161712161713161714161715161716161717161718161719161720161721161722161723161724161725161726161727161728161729161730161731161732161733161734161735161736161737161738161739161740161741161742161743161744161745161746161747161748161749161750161751161752161753161754161755161756161757161758161759161760161761161762161763161764161765161766161767161768161769161770161771161772161773161774161775161776161777161778161779161780161781161782161783161784161785161786161787161788161789161790161791161792161793161794161795161796161797161798161799161800161801161802161803161804161805161806161807161808161809161810161811161812161813161814161815161816161817161818161819161820161821161822161823161824161825161826161827161828161829161830161831161832161833161834161835161836161837161838161839161840161841161842161843161844161845161846161847161848161849161850161851161852161853161854161855161856161857161858161859161860161861161862161863161864161865161866161867161868161869161870161871161872161873161874161875161876161877161878161879161880161881161882161883161884161885161886161887161888161889161890161891161892161893161894161895161896161897161898161899161900161901161902161903161904161905161906161907161908161909161910161911161912161913161914161915161916161917161918161919161920161921161922161923161924161925161926161927161928161929161930161931161932161933161934161935161936161937161938161939161940161941161942161943161944161945161946161947161948161949161950161951161952161953161954161955161956161957161958161959161960161961161962161963161964161965161966161967161968161969161970161971161972161973161974161975161976161977161978161979161980161981161982161983161984161985161986161987161988161989161990161991161992161993161994161995161996161997161998161999162000162001162002162003162004162005162006162007162008162009162010162011162012162013162014162015162016162017162018162019162020162021162022162023162024162025162026162027162028162029162030162031162032162033162034162035162036162037162038162039162040162041162042162043162044162045162046162047162048162049162050162051162052162053162054162055162056162057162058162059162060162061162062162063162064162065162066162067162068162069162070162071162072162073162074162075162076162077162078162079162080162081162082162083162084162085162086162087162088162089162090162091162092162093162094162095162096162097162098162099162100162101162102162103162104162105162106162107162108162109162110162111162112162113162114162115162116162117162118162119162120162121162122162123162124162125162126162127162128162129162130162131162132162133162134162135162136162137162138162139162140162141162142162143162144162145162146162147162148162149162150162151162152162153162154162155162156162157162158162159162160162161162162162163162164162165162166162167162168162169162170162171162172162173162174162175162176162177162178162179162180162181162182162183162184162185162186162187162188162189162190162191162192162193162194162195162196162197162198162199162200162201162202162203162204162205162206162207162208162209162210162211162212162213162214162215162216162217162218162219162220162221162222162223162224162225162226162227162228162229162230162231162232162233162234162235162236162237162238162239162240162241162242162243162244162245162246162247162248162249162250162251162252162253162254162255162256162257162258162259162260162261162262162263162264162265162266162267162268162269162270162271162272162273162274162275162276162277162278162279162280162281162282162283162284162285162286162287162288162289162290162291162292162293162294162295162296162297162298162299162300162301162302162303162304162305162306162307162308162309162310162311162312162313162314162315162316162317162318162319162320162321162322162323162324162325162326162327162328162329162330162331162332162333162334162335162336162337162338162339162340162341162342162343162344162345162346162347162348162349162350162351162352162353162354162355162356162357162358162359162360162361162362162363162364162365162366162367162368162369162370162371162372162373162374162375162376162377162378162379162380162381162382162383162384162385162386162387162388162389162390162391162392162393162394162395162396162397162398162399162400162401162402162403162404162405162406162407162408162409162410162411162412162413162414162415162416162417162418162419162420162421162422162423162424162425162426162427162428162429162430162431162432162433162434162435162436162437162438162439162440162441162442162443162444162445162446162447162448162449162450162451162452162453162454162455162456162457162458162459162460162461162462162463162464162465162466162467162468162469162470162471162472162473162474162475162476162477162478162479162480162481162482162483162484162485162486162487162488162489162490162491162492162493162494162495162496162497162498162499162500162501162502162503162504162505162506162507162508162509162510162511162512162513162514162515162516162517162518162519162520162521162522162523162524162525162526162527162528162529162530162531162532162533162534162535162536162537162538162539162540162541162542162543162544162545162546162547162548162549162550162551162552162553162554162555162556162557162558162559162560162561162562162563162564162565162566162567162568162569162570162571162572162573162574162575162576162577162578162579162580162581162582162583162584162585162586162587162588162589162590162591162592162593162594162595162596162597162598162599162600162601162602162603162604162605162606162607162608162609162610162611162612162613162614162615162616162617162618162619162620162621162622162623162624162625162626162627162628162629162630162631162632162633162634162635162636162637162638162639162640162641162642162643162644162645162646162647162648162649162650162651162652162653162654162655162656162657162658162659162660162661162662162663162664162665162666162667162668162669162670162671162672162673162674162675162676162677162678162679162680162681162682162683162684162685162686162687162688162689162690162691162692162693162694162695162696162697162698162699162700162701162702162703162704162705162706162707162708162709162710162711162712162713162714162715162716162717162718162719162720162721162722162723162724162725162726162727162728162729162730162731162732162733162734162735162736162737162738162739162740162741162742162743162744162745162746162747162748162749162750162751162752162753162754162755162756162757162758162759162760162761162762162763162764162765162766162767162768162769162770162771162772162773162774162775162776162777162778162779162780162781162782162783162784162785162786162787162788162789162790162791162792162793162794162795162796162797162798162799162800162801162802162803162804162805162806162807162808162809162810162811162812162813162814162815162816162817162818162819162820162821162822162823162824162825162826162827162828162829162830162831162832162833162834162835162836162837162838162839162840162841162842162843162844162845162846162847162848162849162850162851162852162853162854162855162856162857162858162859162860162861162862162863162864162865162866162867162868162869162870162871162872162873162874162875162876162877162878162879162880162881162882162883162884162885162886162887162888162889162890162891162892162893162894162895162896162897162898162899162900162901162902162903162904162905162906162907162908162909162910162911162912162913162914162915162916162917162918162919162920162921162922162923162924162925162926162927162928162929162930162931162932162933162934162935162936162937162938162939162940162941162942162943162944162945162946162947162948162949162950162951162952162953162954162955162956162957162958162959162960162961162962162963162964162965162966162967162968162969162970162971162972162973162974162975162976162977162978162979162980162981162982162983162984162985162986162987162988162989162990162991162992162993162994162995162996162997162998162999163000163001163002163003163004163005163006163007163008163009163010163011163012163013163014163015163016163017163018163019163020163021163022163023163024163025163026163027163028163029163030163031163032163033163034163035163036163037163038163039163040163041163042163043163044163045163046163047163048163049163050163051163052163053163054163055163056163057163058163059163060163061163062163063163064163065163066163067163068163069163070163071163072163073163074163075163076163077163078163079163080163081163082163083163084163085163086163087163088163089163090163091163092163093163094163095163096163097163098163099163100163101163102163103163104163105163106163107163108163109163110163111163112163113163114163115163116163117163118163119163120163121163122163123163124163125163126163127163128163129163130163131163132163133163134163135163136163137163138163139163140163141163142163143163144163145163146163147163148163149163150163151163152163153163154163155163156163157163158163159163160163161163162163163163164163165163166163167163168163169163170163171163172163173163174163175163176163177163178163179163180163181163182163183163184163185163186163187163188163189163190163191163192163193163194163195163196163197163198163199163200163201163202163203163204163205163206163207163208163209163210163211163212163213163214163215163216163217163218163219163220163221163222163223163224163225163226163227163228163229163230163231163232163233163234163235163236163237163238163239163240163241163242163243163244163245163246163247163248163249163250163251163252163253163254163255163256163257163258163259163260163261163262163263163264163265163266163267163268163269163270163271163272163273163274163275163276163277163278163279163280163281163282163283163284163285163286163287163288163289163290163291163292163293163294163295163296163297163298163299163300163301163302163303163304163305163306163307163308163309163310163311163312163313163314163315163316163317163318163319163320163321163322163323163324163325163326163327163328163329163330163331163332163333163334163335163336163337163338163339163340163341163342163343163344163345163346163347163348163349163350163351163352163353163354163355163356163357163358163359163360163361163362163363163364163365163366163367163368163369163370163371163372163373163374163375163376163377163378163379163380163381163382163383163384163385163386163387163388163389163390163391163392163393163394163395163396163397163398163399163400163401163402163403163404163405163406163407163408163409163410163411163412163413163414163415163416163417163418163419163420163421163422163423163424163425163426163427163428163429163430163431163432163433163434163435163436163437163438163439163440163441163442163443163444163445163446163447163448163449163450163451163452163453163454163455163456163457163458163459163460163461163462163463163464163465163466163467163468163469163470163471163472163473163474163475163476163477163478163479163480163481163482163483163484163485163486163487163488163489163490163491163492163493163494163495163496163497163498163499163500163501163502163503163504163505163506163507163508163509163510163511163512163513163514163515163516163517163518163519163520163521163522163523163524163525163526163527163528163529163530163531163532163533163534163535163536163537163538163539163540163541163542163543163544163545163546163547163548163549163550163551163552163553163554163555163556163557163558163559163560163561163562163563163564163565163566163567163568163569163570163571163572163573163574163575163576163577163578163579163580163581163582163583163584163585163586163587163588163589163590163591163592163593163594163595163596163597163598163599163600163601163602163603163604163605163606163607163608163609163610163611163612163613163614163615163616163617163618163619163620163621163622163623163624163625163626163627163628163629163630163631163632163633163634163635163636163637163638163639163640163641163642163643163644163645163646163647163648163649163650163651163652163653163654163655163656163657163658163659163660163661163662163663163664163665163666163667163668163669163670163671163672163673163674163675163676163677163678163679163680163681163682163683163684163685163686163687163688163689163690163691163692163693163694163695163696163697163698163699163700163701163702163703163704163705163706163707163708163709163710163711163712163713163714163715163716163717163718163719163720163721163722163723163724163725163726163727163728163729163730163731163732163733163734163735163736163737163738163739163740163741163742163743163744163745163746163747163748163749163750163751163752163753163754163755163756163757163758163759163760163761163762163763163764163765163766163767163768163769163770163771163772163773163774163775163776163777163778163779163780163781163782163783163784163785163786163787163788163789163790163791163792163793163794163795163796163797163798163799163800163801163802163803163804163805163806163807163808163809163810163811163812163813163814163815163816163817163818163819163820163821163822163823163824163825163826163827163828163829163830163831163832163833163834163835163836163837163838163839163840163841163842163843163844163845163846163847163848163849163850163851163852163853163854163855163856163857163858163859163860163861163862163863163864163865163866163867163868163869163870163871163872163873163874163875163876163877163878163879163880163881163882163883163884163885163886163887163888163889163890163891163892163893163894163895163896163897163898163899163900163901163902163903163904163905163906163907163908163909163910163911163912163913163914163915163916163917163918163919163920163921163922163923163924163925163926163927163928163929163930163931163932163933163934163935163936163937163938163939163940163941163942163943163944163945163946163947163948163949163950163951163952163953163954163955163956163957163958163959163960163961163962163963163964163965163966163967163968163969163970163971163972163973163974163975163976163977163978163979163980163981163982163983163984163985163986163987163988163989163990163991163992163993163994163995163996163997163998163999164000164001164002164003164004164005164006164007164008164009164010164011164012164013164014164015164016164017164018164019164020164021164022164023164024164025164026164027164028164029164030164031164032164033164034164035164036164037164038164039164040164041164042164043164044164045164046164047164048164049164050164051164052164053164054164055164056164057164058164059164060164061164062164063164064164065164066164067164068164069164070164071164072164073164074164075164076164077164078164079164080164081164082164083164084164085164086164087164088164089164090164091164092164093164094164095164096164097164098164099164100164101164102164103164104164105164106164107164108164109164110164111164112164113164114164115164116164117164118164119164120164121164122164123164124164125164126164127164128164129164130164131164132164133164134164135164136164137164138164139164140164141164142164143164144164145164146164147164148164149164150164151164152164153164154164155164156164157164158164159164160164161164162164163164164164165164166164167164168164169164170164171164172164173164174164175164176164177164178164179164180164181164182164183164184164185164186164187164188164189164190164191164192164193164194164195164196164197164198164199164200164201164202164203164204164205164206164207164208164209164210164211164212164213164214164215164216164217164218164219164220164221164222164223164224164225164226164227164228164229164230164231164232164233164234164235164236164237164238164239164240164241164242164243164244164245164246164247164248164249164250164251164252164253164254164255164256164257164258164259164260164261164262164263164264164265164266164267164268164269164270164271164272164273164274164275164276164277164278164279164280164281164282164283164284164285164286164287164288164289164290164291164292164293164294164295164296164297164298164299164300164301164302164303164304164305164306164307164308164309164310164311164312164313164314164315164316164317164318164319164320164321164322164323164324164325164326164327164328164329164330164331164332164333164334164335164336164337164338164339164340164341164342164343164344164345164346164347164348164349164350164351164352164353164354164355164356164357164358164359164360164361164362164363164364164365164366164367164368164369164370164371164372164373164374164375164376164377164378164379164380164381164382164383164384164385164386164387164388164389164390164391164392164393164394164395164396164397164398164399164400164401164402164403164404164405164406164407164408164409164410164411164412164413164414164415164416164417164418164419164420164421164422164423164424164425164426164427164428164429164430164431164432164433164434164435164436164437164438164439164440164441164442164443164444164445164446164447164448164449164450164451164452164453164454164455164456164457164458164459164460164461164462164463164464164465164466164467164468164469164470164471164472164473164474164475164476164477164478164479164480164481164482164483164484164485164486164487164488164489164490164491164492164493164494164495164496164497164498164499164500164501164502164503164504164505164506164507164508164509164510164511164512164513164514164515164516164517164518164519164520164521164522164523164524164525164526164527164528164529164530164531164532164533164534164535164536164537164538164539164540164541164542164543164544164545164546164547164548164549164550164551164552164553164554164555164556164557164558164559164560164561164562164563164564164565164566164567164568164569164570164571164572164573164574164575164576164577164578164579164580164581164582164583164584164585164586164587164588164589164590164591164592164593164594164595164596164597164598164599164600164601164602164603164604164605164606164607164608164609164610164611164612164613164614164615164616164617164618164619164620164621164622164623164624164625164626164627164628164629164630164631164632164633164634164635164636164637164638164639164640164641164642164643164644164645164646164647164648164649164650164651164652164653164654164655164656164657164658164659164660164661164662164663164664164665164666164667164668164669164670164671164672164673164674164675164676164677164678164679164680164681164682164683164684164685164686164687164688164689164690164691164692164693164694164695164696164697164698164699164700164701164702164703164704164705164706164707164708164709164710164711164712164713164714164715164716164717164718164719164720164721164722164723164724164725164726164727164728164729164730164731164732164733164734164735164736164737164738164739164740164741164742164743164744164745164746164747164748164749164750164751164752164753164754164755164756164757164758164759164760164761164762164763164764164765164766164767164768164769164770164771164772164773164774164775164776164777164778164779164780164781164782164783164784164785164786164787164788164789164790164791164792164793164794164795164796164797164798164799164800164801164802164803164804164805164806164807164808164809164810164811164812164813164814164815164816164817164818164819164820164821164822164823164824164825164826164827164828164829164830164831164832164833164834164835164836164837164838164839164840164841164842164843164844164845164846164847164848164849164850164851164852164853164854164855164856164857164858164859164860164861164862164863164864164865164866164867164868164869164870164871164872164873164874164875164876164877164878164879164880164881164882164883164884164885164886164887164888164889164890164891164892164893164894164895164896164897164898164899164900164901164902164903164904164905164906164907164908164909164910164911164912164913164914164915164916164917164918164919164920164921164922164923164924164925164926164927164928164929164930164931164932164933164934164935164936164937164938164939164940164941164942164943164944164945164946164947164948164949164950164951164952164953164954164955164956164957164958164959164960164961164962164963164964164965164966164967164968164969164970164971164972164973164974164975164976164977164978164979164980164981164982164983164984164985164986164987164988164989164990164991164992164993164994164995164996164997164998164999165000165001165002165003165004165005165006165007165008165009165010165011165012165013165014165015165016165017165018165019165020165021165022165023165024165025165026165027165028165029165030165031165032165033165034165035165036165037165038165039165040165041165042165043165044165045165046165047165048165049165050165051165052165053165054165055165056165057165058165059165060165061165062165063165064165065165066165067165068165069165070165071165072165073165074165075165076165077165078165079165080165081165082165083165084165085165086165087165088165089165090165091165092165093165094165095165096165097165098165099165100165101165102165103165104165105165106165107165108165109165110165111165112165113165114165115165116165117165118165119165120165121165122165123165124165125165126165127165128165129165130165131165132165133165134165135165136165137165138165139165140165141165142165143165144165145165146165147165148165149165150165151165152165153165154165155165156165157165158165159165160165161165162165163165164165165165166165167165168165169165170165171165172165173165174165175165176165177165178165179165180165181165182165183165184165185165186165187165188165189165190165191165192165193165194165195165196165197165198165199165200165201165202165203165204165205165206165207165208165209165210165211165212165213165214165215165216165217165218165219165220165221165222165223165224165225165226165227165228165229165230165231165232165233165234165235165236165237165238165239165240165241165242165243165244165245165246165247165248165249165250165251165252165253165254165255165256165257165258165259165260165261165262165263165264165265165266165267165268165269165270165271165272165273165274165275165276165277165278165279165280165281165282165283165284165285165286165287165288165289165290165291165292165293165294165295165296165297165298165299165300165301165302165303165304165305165306165307165308165309165310165311165312165313165314165315165316165317165318165319165320165321165322165323165324165325165326165327165328165329165330165331165332165333165334165335165336165337165338165339165340165341165342165343165344165345165346165347165348165349165350165351165352165353165354165355165356165357165358165359165360165361165362165363165364165365165366165367165368165369165370165371165372165373165374165375165376165377165378165379165380165381165382165383165384165385165386165387165388165389165390165391165392165393165394165395165396165397165398165399165400165401165402165403165404165405165406165407165408165409165410165411165412165413165414165415165416165417165418165419165420165421165422165423165424165425165426165427165428165429165430165431165432165433165434165435165436165437165438165439165440165441165442165443165444165445165446165447165448165449165450165451165452165453165454165455165456165457165458165459165460165461165462165463165464165465165466165467165468165469165470165471165472165473165474165475165476165477165478165479165480165481165482165483165484165485165486165487165488165489165490165491165492165493165494165495165496165497165498165499165500165501165502165503165504165505165506165507165508165509165510165511165512165513165514165515165516165517165518165519165520165521165522165523165524165525165526165527165528165529165530165531165532165533165534165535165536165537165538165539165540165541165542165543165544165545165546165547165548165549165550165551165552165553165554165555165556165557165558165559165560165561165562165563165564165565165566165567165568165569165570165571165572165573165574165575165576165577165578165579165580165581165582165583165584165585165586165587165588165589165590165591165592165593165594165595165596165597165598165599165600165601165602165603165604165605165606165607165608165609165610165611165612165613165614165615165616165617165618165619165620165621165622165623165624165625165626165627165628165629165630165631165632165633165634165635165636165637165638165639165640165641165642165643165644165645165646165647165648165649165650165651165652165653165654165655165656165657165658165659165660165661165662165663165664165665165666165667165668165669165670165671165672165673165674165675165676165677165678165679165680165681165682165683165684165685165686165687165688165689165690165691165692165693165694165695165696165697165698165699165700165701165702165703165704165705165706165707165708165709165710165711165712165713165714165715165716165717165718165719165720165721165722165723165724165725165726165727165728165729165730165731165732165733165734165735165736165737165738165739165740165741165742165743165744165745165746165747165748165749165750165751165752165753165754165755165756165757165758165759165760165761165762165763165764165765165766165767165768165769165770165771165772165773165774165775165776165777165778165779165780165781165782165783165784165785165786165787165788165789165790165791165792165793165794165795165796165797165798165799165800165801165802165803165804165805165806165807165808165809165810165811165812165813165814165815165816165817165818165819165820165821165822165823165824165825165826165827165828165829165830165831165832165833165834165835165836165837165838165839165840165841165842165843165844165845165846165847165848165849165850165851165852165853165854165855165856165857165858165859165860165861165862165863165864165865165866165867165868165869165870165871165872165873165874165875165876165877165878165879165880165881165882165883165884165885165886165887165888165889165890165891165892165893165894165895165896165897165898165899165900165901165902165903165904165905165906165907165908165909165910165911165912165913165914165915165916165917165918165919165920165921165922165923165924165925165926165927165928165929165930165931165932165933165934165935165936165937165938165939165940165941165942165943165944165945165946165947165948165949165950165951165952165953165954165955165956165957165958165959165960165961165962165963165964165965165966165967165968165969165970165971165972165973165974165975165976165977165978165979165980165981165982165983165984165985165986165987165988165989165990165991165992165993165994165995165996165997165998165999166000166001166002166003166004166005166006166007166008166009166010166011166012166013166014166015166016166017166018166019166020166021166022166023166024166025166026166027166028166029166030166031166032166033166034166035166036166037166038166039166040166041166042166043166044166045166046166047166048166049166050166051166052166053166054166055166056166057166058166059166060166061166062166063166064166065166066166067166068166069166070166071166072166073166074166075166076166077166078166079166080166081166082166083166084166085166086166087166088166089166090166091166092166093166094166095166096166097166098166099166100166101166102166103166104166105166106166107166108166109166110166111166112166113166114166115166116166117166118166119166120166121166122166123166124166125166126166127166128166129166130166131166132166133166134166135166136166137166138166139166140166141166142166143166144166145166146166147166148166149166150166151166152166153166154166155166156166157166158166159166160166161166162166163166164166165166166166167166168166169166170166171166172166173166174166175166176166177166178166179166180166181166182166183166184166185166186166187166188166189166190166191166192166193166194166195166196166197166198166199166200166201166202166203166204166205166206166207166208166209166210166211166212166213166214166215166216166217166218166219166220166221166222166223166224166225166226166227166228166229166230166231166232166233166234166235166236166237166238166239166240166241166242166243166244166245166246166247166248166249166250166251166252166253166254166255166256166257166258166259166260166261166262166263166264166265166266166267166268166269166270166271166272166273166274166275166276166277166278166279166280166281166282166283166284166285166286166287166288166289166290166291166292166293166294166295166296166297166298166299166300166301166302166303166304166305166306166307166308166309166310166311166312166313166314166315166316166317166318166319166320166321166322166323166324166325166326166327166328166329166330166331166332166333166334166335166336166337166338166339166340166341166342166343166344166345166346166347166348166349166350166351166352166353166354166355166356166357166358166359166360166361166362166363166364166365166366166367166368166369166370166371166372166373166374166375166376166377166378166379166380166381166382166383166384166385166386166387166388166389166390166391166392166393166394166395166396166397166398166399166400166401166402166403166404166405166406166407166408166409166410166411166412166413166414166415166416166417166418166419166420166421166422166423166424166425166426166427166428166429166430166431166432166433166434166435166436166437166438166439166440166441166442166443166444166445166446166447166448166449166450166451166452166453166454166455166456166457166458166459166460166461166462166463166464166465166466166467166468166469166470166471166472166473166474166475166476166477166478166479166480166481166482166483166484166485166486166487166488166489166490166491166492166493166494166495166496166497166498166499166500166501166502166503166504166505166506166507166508166509166510166511166512166513166514166515166516166517166518166519166520166521166522166523166524166525166526166527166528166529166530166531166532166533166534166535166536166537166538166539166540166541166542166543166544166545166546166547166548166549166550166551166552166553166554166555166556166557166558166559166560166561166562166563166564166565166566166567166568166569166570166571166572166573166574166575166576166577166578166579166580166581166582166583166584166585166586166587166588166589166590166591166592166593166594166595166596166597166598166599166600166601166602166603166604166605166606166607166608166609166610166611166612166613166614166615166616166617166618166619166620166621166622166623166624166625166626166627166628166629166630166631166632166633166634166635166636166637166638166639166640166641166642166643166644166645166646166647166648166649166650166651166652166653166654166655166656166657166658166659166660166661166662166663166664166665166666166667166668166669166670166671166672166673166674166675166676166677166678166679166680166681166682166683166684166685166686166687166688166689166690166691166692166693166694166695166696166697166698166699166700166701166702166703166704166705166706166707166708166709166710166711166712166713166714166715166716166717166718166719166720166721166722166723166724166725166726166727166728166729166730166731166732166733166734166735166736166737166738166739166740166741166742166743166744166745166746166747166748166749166750166751166752166753166754166755166756166757166758166759166760166761166762166763166764166765166766166767166768166769166770166771166772166773166774166775166776166777166778166779166780166781166782166783166784166785166786166787166788166789166790166791166792166793166794166795166796166797166798166799166800166801166802166803166804166805166806166807166808166809166810166811166812166813166814166815166816166817166818166819166820166821166822166823166824166825166826166827166828166829166830166831166832166833166834166835166836166837166838166839166840166841166842166843166844166845166846166847166848166849166850166851166852166853166854166855166856166857166858166859166860166861166862166863166864166865166866166867166868166869166870166871166872166873166874166875166876166877166878166879166880166881166882166883166884166885166886166887166888166889166890166891166892166893166894166895166896166897166898166899166900166901166902166903166904166905166906166907166908166909166910166911166912166913166914166915166916166917166918166919166920166921166922166923166924166925166926166927166928166929166930166931166932166933166934166935166936166937166938166939166940166941166942166943166944166945166946166947166948166949166950166951166952166953166954166955166956166957166958166959166960166961166962166963166964166965166966166967166968166969166970166971166972166973166974166975166976166977166978166979166980166981166982166983166984166985166986166987166988166989166990166991166992166993166994166995166996166997166998166999167000167001167002167003167004167005167006167007167008167009167010167011167012167013167014167015167016167017167018167019167020167021167022167023167024167025167026167027167028167029167030167031167032167033167034167035167036167037167038167039167040167041167042167043167044167045167046167047167048167049167050167051167052167053167054167055167056167057167058167059167060167061167062167063167064167065167066167067167068167069167070167071167072167073167074167075167076167077167078167079167080167081167082167083167084167085167086167087167088167089167090167091167092167093167094167095167096167097167098167099167100167101167102167103167104167105167106167107167108167109167110167111167112167113167114167115167116167117167118167119167120167121167122167123167124167125167126167127167128167129167130167131167132167133167134167135167136167137167138167139167140167141167142167143167144167145167146167147167148167149167150167151167152167153167154167155167156167157167158167159167160167161167162167163167164167165167166167167167168167169167170167171167172167173167174167175167176167177167178167179167180167181167182167183167184167185167186167187167188167189167190167191167192167193167194167195167196167197167198167199167200167201167202167203167204167205167206167207167208167209167210167211167212167213167214167215167216167217167218167219167220167221167222167223167224167225167226167227167228167229167230167231167232167233167234167235167236167237167238167239167240167241167242167243167244167245167246167247167248167249167250167251167252167253167254167255167256167257167258167259167260167261167262167263167264167265167266167267167268167269167270167271167272167273167274167275167276167277167278167279167280167281167282167283167284167285167286167287167288167289167290167291167292167293167294167295167296167297167298167299167300167301167302167303167304167305167306167307167308167309167310167311167312167313167314167315167316167317167318167319167320167321167322167323167324167325167326167327167328167329167330167331167332167333167334167335167336167337167338167339167340167341167342167343167344167345167346167347167348167349167350167351167352167353167354167355167356167357167358167359167360167361167362167363167364167365167366167367167368167369167370167371167372167373167374167375167376167377167378167379167380167381167382167383167384167385167386167387167388167389167390167391167392167393167394167395167396167397167398167399167400167401167402167403167404167405167406167407167408167409167410167411167412167413167414167415167416167417167418167419167420167421167422167423167424167425167426167427167428167429167430167431167432167433167434167435167436167437167438167439167440167441167442167443167444167445167446167447167448167449167450167451167452167453167454167455167456167457167458167459167460167461167462167463167464167465167466167467167468167469167470167471167472167473167474167475167476167477167478167479167480167481167482167483167484167485167486167487167488167489167490167491167492167493167494167495167496167497167498167499167500167501167502167503167504167505167506167507167508167509167510167511167512167513167514167515167516167517167518167519167520167521167522167523167524167525167526167527167528167529167530167531167532167533167534167535167536167537167538167539167540167541167542167543167544167545167546167547167548167549167550167551167552167553167554167555167556167557167558167559167560167561167562167563167564167565167566167567167568167569167570167571167572167573167574167575167576167577167578167579167580167581167582167583167584167585167586167587167588167589167590167591167592167593167594167595167596167597167598167599167600167601167602167603167604167605167606167607167608167609167610167611167612167613167614167615167616167617167618167619167620167621167622167623167624167625167626167627167628167629167630167631167632167633167634167635167636167637167638167639167640167641167642167643167644167645167646167647167648167649167650167651167652167653167654167655167656167657167658167659167660167661167662167663167664167665167666167667167668167669167670167671167672167673167674167675167676167677167678167679167680167681167682167683167684167685167686167687167688167689167690167691167692167693167694167695167696167697167698167699167700167701167702167703167704167705167706167707167708167709167710167711167712167713167714167715167716167717167718167719167720167721167722167723167724167725167726167727167728167729167730167731167732167733167734167735167736167737167738167739167740167741167742167743167744167745167746167747167748167749167750167751167752167753167754167755167756167757167758167759167760167761167762167763167764167765167766167767167768167769167770167771167772167773167774167775167776167777167778167779167780167781167782167783167784167785167786167787167788167789167790167791167792167793167794167795167796167797167798167799167800167801167802167803167804167805167806167807167808167809167810167811167812167813167814167815167816167817167818167819167820167821167822167823167824167825167826167827167828167829167830167831167832167833167834167835167836167837167838167839167840167841167842167843167844167845167846167847167848167849167850167851167852167853167854167855167856167857167858167859167860167861167862167863167864167865167866167867167868167869167870167871167872167873167874167875167876167877167878167879167880167881167882167883167884167885167886167887167888167889167890167891167892167893167894167895167896167897167898167899167900167901167902167903167904167905167906167907167908167909167910167911167912167913167914167915167916167917167918167919167920167921167922167923167924167925167926167927167928167929167930167931167932167933167934167935167936167937167938167939167940167941167942167943167944167945167946167947167948167949167950167951167952167953167954167955167956167957167958167959167960167961167962167963167964167965167966167967167968167969167970167971167972167973167974167975167976167977167978167979167980167981167982167983167984167985167986167987167988167989167990167991167992167993167994167995167996167997167998167999168000168001168002168003168004168005168006168007168008168009168010168011168012168013168014168015168016168017168018168019168020168021168022168023168024168025168026168027168028168029168030168031168032168033168034168035168036168037168038168039168040168041168042168043168044168045168046168047168048168049168050168051168052168053168054168055168056168057168058168059168060168061168062168063168064168065168066168067168068168069168070168071168072168073168074168075168076168077168078168079168080168081168082168083168084168085168086168087168088168089168090168091168092168093168094168095168096168097168098168099168100168101168102168103168104168105168106168107168108168109168110168111168112168113168114168115168116168117168118168119168120168121168122168123168124168125168126168127168128168129168130168131168132168133168134168135168136168137168138168139168140168141168142168143168144168145168146168147168148168149168150168151168152168153168154168155168156168157168158168159168160168161168162168163168164168165168166168167168168168169168170168171168172168173168174168175168176168177168178168179168180168181168182168183168184168185168186168187168188168189168190168191168192168193168194168195168196168197168198168199168200168201168202168203168204168205168206168207168208168209168210168211168212168213168214168215168216168217168218168219168220168221168222168223168224168225168226168227168228168229168230168231168232168233168234168235168236168237168238168239168240168241168242168243168244
  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 handled
  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 throughout the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. /**
  334. * Message to display when a message has been logged too many times
  335. */
  336. static MessageLimitReached: string;
  337. private static _LogCache;
  338. private static _LogLimitOutputs;
  339. /**
  340. * Gets a value indicating the number of loading errors
  341. * @ignorenaming
  342. */
  343. static errorsCount: number;
  344. /**
  345. * Callback called when a new log is added
  346. */
  347. static OnNewCacheEntry: (entry: string) => void;
  348. private static _CheckLimit;
  349. private static _GenerateLimitMessage;
  350. private static _AddLogEntry;
  351. private static _FormatMessage;
  352. private static _LogDisabled;
  353. private static _LogEnabled;
  354. private static _WarnDisabled;
  355. private static _WarnEnabled;
  356. private static _ErrorDisabled;
  357. private static _ErrorEnabled;
  358. /**
  359. * Log a message to the console
  360. */
  361. static Log: (message: string, limit?: number) => void;
  362. /**
  363. * Write a warning message to the console
  364. */
  365. static Warn: (message: string, limit?: number) => void;
  366. /**
  367. * Write an error message to the console
  368. */
  369. static Error: (message: string, limit?: number) => void;
  370. /**
  371. * Gets current log cache (list of logs)
  372. */
  373. static get LogCache(): string;
  374. /**
  375. * Clears the log cache
  376. */
  377. static ClearLogCache(): void;
  378. /**
  379. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  380. */
  381. static set LogLevels(level: number);
  382. }
  383. }
  384. declare module "babylonjs/Misc/typeStore" {
  385. /** @hidden */
  386. export class _TypeStore {
  387. /** @hidden */
  388. static RegisteredTypes: {
  389. [key: string]: Object;
  390. };
  391. /** @hidden */
  392. static GetClass(fqdn: string): any;
  393. }
  394. }
  395. declare module "babylonjs/Misc/stringTools" {
  396. /**
  397. * Helper to manipulate strings
  398. */
  399. export class StringTools {
  400. /**
  401. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static EndsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  409. * @param str Source string
  410. * @param suffix Suffix to search for in the source string
  411. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  412. */
  413. static StartsWith(str: string, suffix: string): boolean;
  414. /**
  415. * Decodes a buffer into a string
  416. * @param buffer The buffer to decode
  417. * @returns The decoded string
  418. */
  419. static Decode(buffer: Uint8Array | Uint16Array): string;
  420. /**
  421. * Encode a buffer to a base64 string
  422. * @param buffer defines the buffer to encode
  423. * @returns the encoded string
  424. */
  425. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  426. /**
  427. * Converts a number to string and pads with preceding zeroes until it is of specified length.
  428. * @param num the number to convert and pad
  429. * @param length the expected length of the string
  430. * @returns the padded string
  431. */
  432. static PadNumber(num: number, length: number): string;
  433. }
  434. }
  435. declare module "babylonjs/Misc/deepCopier" {
  436. /**
  437. * Class containing a set of static utilities functions for deep copy.
  438. */
  439. export class DeepCopier {
  440. /**
  441. * Tries to copy an object by duplicating every property
  442. * @param source defines the source object
  443. * @param destination defines the target object
  444. * @param doNotCopyList defines a list of properties to avoid
  445. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  446. */
  447. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  448. }
  449. }
  450. declare module "babylonjs/Misc/precisionDate" {
  451. /**
  452. * Class containing a set of static utilities functions for precision date
  453. */
  454. export class PrecisionDate {
  455. /**
  456. * Gets either window.performance.now() if supported or Date.now() else
  457. */
  458. static get Now(): number;
  459. }
  460. }
  461. declare module "babylonjs/Misc/devTools" {
  462. /** @hidden */
  463. export class _DevTools {
  464. static WarnImport(name: string): string;
  465. }
  466. }
  467. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  468. /**
  469. * Interface used to define the mechanism to get data from the network
  470. */
  471. export interface IWebRequest {
  472. /**
  473. * Returns client's response url
  474. */
  475. responseURL: string;
  476. /**
  477. * Returns client's status
  478. */
  479. status: number;
  480. /**
  481. * Returns client's status as a text
  482. */
  483. statusText: string;
  484. }
  485. }
  486. declare module "babylonjs/Misc/webRequest" {
  487. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  488. import { Nullable } from "babylonjs/types";
  489. /**
  490. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  491. */
  492. export class WebRequest implements IWebRequest {
  493. private readonly _xhr;
  494. /**
  495. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  496. * i.e. when loading files, where the server/service expects an Authorization header
  497. */
  498. static CustomRequestHeaders: {
  499. [key: string]: string;
  500. };
  501. /**
  502. * Add callback functions in this array to update all the requests before they get sent to the network
  503. */
  504. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  505. private _injectCustomRequestHeaders;
  506. /**
  507. * Gets or sets a function to be called when loading progress changes
  508. */
  509. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  510. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  511. /**
  512. * Returns client's state
  513. */
  514. get readyState(): number;
  515. /**
  516. * Returns client's status
  517. */
  518. get status(): number;
  519. /**
  520. * Returns client's status as a text
  521. */
  522. get statusText(): string;
  523. /**
  524. * Returns client's response
  525. */
  526. get response(): any;
  527. /**
  528. * Returns client's response url
  529. */
  530. get responseURL(): string;
  531. /**
  532. * Returns client's response as text
  533. */
  534. get responseText(): string;
  535. /**
  536. * Gets or sets the expected response type
  537. */
  538. get responseType(): XMLHttpRequestResponseType;
  539. set responseType(value: XMLHttpRequestResponseType);
  540. /** @hidden */
  541. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  542. /** @hidden */
  543. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  544. /**
  545. * Cancels any network activity
  546. */
  547. abort(): void;
  548. /**
  549. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  550. * @param body defines an optional request body
  551. */
  552. send(body?: Document | BodyInit | null): void;
  553. /**
  554. * Sets the request method, request URL
  555. * @param method defines the method to use (GET, POST, etc..)
  556. * @param url defines the url to connect with
  557. */
  558. open(method: string, url: string): void;
  559. /**
  560. * Sets the value of a request header.
  561. * @param name The name of the header whose value is to be set
  562. * @param value The value to set as the body of the header
  563. */
  564. setRequestHeader(name: string, value: string): void;
  565. /**
  566. * Get the string containing the text of a particular header's value.
  567. * @param name The name of the header
  568. * @returns The string containing the text of the given header name
  569. */
  570. getResponseHeader(name: string): Nullable<string>;
  571. }
  572. }
  573. declare module "babylonjs/Misc/fileRequest" {
  574. import { Observable } from "babylonjs/Misc/observable";
  575. /**
  576. * File request interface
  577. */
  578. export interface IFileRequest {
  579. /**
  580. * Raised when the request is complete (success or error).
  581. */
  582. onCompleteObservable: Observable<IFileRequest>;
  583. /**
  584. * Aborts the request for a file.
  585. */
  586. abort: () => void;
  587. }
  588. }
  589. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  590. /**
  591. * Define options used to create a render target texture
  592. */
  593. export class RenderTargetCreationOptions {
  594. /**
  595. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  596. */
  597. createMipMaps?: boolean;
  598. /**
  599. * Specifies if mipmaps must be generated
  600. */
  601. generateMipMaps?: boolean;
  602. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  603. generateDepthBuffer?: boolean;
  604. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  605. generateStencilBuffer?: boolean;
  606. /** Defines texture type (int by default) */
  607. type?: number;
  608. /** Defines sampling mode (trilinear by default) */
  609. samplingMode?: number;
  610. /** Defines format (RGBA by default) */
  611. format?: number;
  612. /** Defines sample count (1 by default) */
  613. samples?: number;
  614. }
  615. }
  616. declare module "babylonjs/Engines/constants" {
  617. /** Defines the cross module used constants to avoid circular dependencies */
  618. export class Constants {
  619. /** Defines that alpha blending is disabled */
  620. static readonly ALPHA_DISABLE: number;
  621. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  622. static readonly ALPHA_ADD: number;
  623. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  624. static readonly ALPHA_COMBINE: number;
  625. /** Defines that alpha blending is DEST - SRC * DEST */
  626. static readonly ALPHA_SUBTRACT: number;
  627. /** Defines that alpha blending is SRC * DEST */
  628. static readonly ALPHA_MULTIPLY: number;
  629. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  630. static readonly ALPHA_MAXIMIZED: number;
  631. /** Defines that alpha blending is SRC + DEST */
  632. static readonly ALPHA_ONEONE: number;
  633. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  634. static readonly ALPHA_PREMULTIPLIED: number;
  635. /**
  636. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  637. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  638. */
  639. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  640. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  641. static readonly ALPHA_INTERPOLATE: number;
  642. /**
  643. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  644. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  645. */
  646. static readonly ALPHA_SCREENMODE: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA + DST ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEONE: number;
  652. /**
  653. * Defines that alpha blending is SRC * DST ALPHA + DST
  654. * Alpha will be set to 0
  655. */
  656. static readonly ALPHA_ALPHATOCOLOR: number;
  657. /**
  658. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  659. */
  660. static readonly ALPHA_REVERSEONEMINUS: number;
  661. /**
  662. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  663. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  664. */
  665. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  666. /**
  667. * Defines that alpha blending is SRC + DST
  668. * Alpha will be set to SRC ALPHA
  669. */
  670. static readonly ALPHA_ONEONE_ONEZERO: number;
  671. /**
  672. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  673. * Alpha will be set to DST ALPHA
  674. */
  675. static readonly ALPHA_EXCLUSION: number;
  676. /** Defines that alpha blending equation a SUM */
  677. static readonly ALPHA_EQUATION_ADD: number;
  678. /** Defines that alpha blending equation a SUBSTRACTION */
  679. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  680. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  681. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  682. /** Defines that alpha blending equation a MAX operation */
  683. static readonly ALPHA_EQUATION_MAX: number;
  684. /** Defines that alpha blending equation a MIN operation */
  685. static readonly ALPHA_EQUATION_MIN: number;
  686. /**
  687. * Defines that alpha blending equation a DARKEN operation:
  688. * It takes the min of the src and sums the alpha channels.
  689. */
  690. static readonly ALPHA_EQUATION_DARKEN: number;
  691. /** Defines that the resource is not delayed*/
  692. static readonly DELAYLOADSTATE_NONE: number;
  693. /** Defines that the resource was successfully delay loaded */
  694. static readonly DELAYLOADSTATE_LOADED: number;
  695. /** Defines that the resource is currently delay loading */
  696. static readonly DELAYLOADSTATE_LOADING: number;
  697. /** Defines that the resource is delayed and has not started loading */
  698. static readonly DELAYLOADSTATE_NOTLOADED: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  700. static readonly NEVER: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  702. static readonly ALWAYS: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  704. static readonly LESS: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  706. static readonly EQUAL: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  708. static readonly LEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  710. static readonly GREATER: number;
  711. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  712. static readonly GEQUAL: number;
  713. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  714. static readonly NOTEQUAL: number;
  715. /** Passed to stencilOperation to specify that stencil value must be kept */
  716. static readonly KEEP: number;
  717. /** Passed to stencilOperation to specify that stencil value must be zero */
  718. static readonly ZERO: number;
  719. /** Passed to stencilOperation to specify that stencil value must be replaced */
  720. static readonly REPLACE: number;
  721. /** Passed to stencilOperation to specify that stencil value must be incremented */
  722. static readonly INCR: number;
  723. /** Passed to stencilOperation to specify that stencil value must be decremented */
  724. static readonly DECR: number;
  725. /** Passed to stencilOperation to specify that stencil value must be inverted */
  726. static readonly INVERT: number;
  727. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  728. static readonly INCR_WRAP: number;
  729. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  730. static readonly DECR_WRAP: number;
  731. /** Texture is not repeating outside of 0..1 UVs */
  732. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  733. /** Texture is repeating outside of 0..1 UVs */
  734. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  735. /** Texture is repeating and mirrored */
  736. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  737. /** ALPHA */
  738. static readonly TEXTUREFORMAT_ALPHA: number;
  739. /** LUMINANCE */
  740. static readonly TEXTUREFORMAT_LUMINANCE: number;
  741. /** LUMINANCE_ALPHA */
  742. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  743. /** RGB */
  744. static readonly TEXTUREFORMAT_RGB: number;
  745. /** RGBA */
  746. static readonly TEXTUREFORMAT_RGBA: number;
  747. /** RED */
  748. static readonly TEXTUREFORMAT_RED: number;
  749. /** RED (2nd reference) */
  750. static readonly TEXTUREFORMAT_R: number;
  751. /** RG */
  752. static readonly TEXTUREFORMAT_RG: number;
  753. /** RED_INTEGER */
  754. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  755. /** RED_INTEGER (2nd reference) */
  756. static readonly TEXTUREFORMAT_R_INTEGER: number;
  757. /** RG_INTEGER */
  758. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  759. /** RGB_INTEGER */
  760. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  761. /** RGBA_INTEGER */
  762. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  763. /** BGRA */
  764. static readonly TEXTUREFORMAT_BGRA: number;
  765. /** Depth 24 bits + Stencil 8 bits */
  766. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  767. /** Depth 32 bits float */
  768. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  769. /** Compressed BC7 */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  771. /** Compressed BC6 unsigned float */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  773. /** Compressed BC6 signed float */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  775. /** Compressed BC3 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  777. /** Compressed BC2 */
  778. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  779. /** Compressed BC1 */
  780. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  781. /** UNSIGNED_BYTE */
  782. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  783. /** UNSIGNED_BYTE (2nd reference) */
  784. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  785. /** FLOAT */
  786. static readonly TEXTURETYPE_FLOAT: number;
  787. /** HALF_FLOAT */
  788. static readonly TEXTURETYPE_HALF_FLOAT: number;
  789. /** BYTE */
  790. static readonly TEXTURETYPE_BYTE: number;
  791. /** SHORT */
  792. static readonly TEXTURETYPE_SHORT: number;
  793. /** UNSIGNED_SHORT */
  794. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  795. /** INT */
  796. static readonly TEXTURETYPE_INT: number;
  797. /** UNSIGNED_INT */
  798. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  799. /** UNSIGNED_SHORT_4_4_4_4 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  801. /** UNSIGNED_SHORT_5_5_5_1 */
  802. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  803. /** UNSIGNED_SHORT_5_6_5 */
  804. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  805. /** UNSIGNED_INT_2_10_10_10_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  807. /** UNSIGNED_INT_24_8 */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  809. /** UNSIGNED_INT_10F_11F_11F_REV */
  810. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  811. /** UNSIGNED_INT_5_9_9_9_REV */
  812. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  813. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  814. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  815. /** nearest is mag = nearest and min = nearest and no mip */
  816. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  817. /** mag = nearest and min = nearest and mip = none */
  818. static readonly TEXTURE_NEAREST_NEAREST: number;
  819. /** Bilinear is mag = linear and min = linear and no mip */
  820. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  821. /** mag = linear and min = linear and mip = none */
  822. static readonly TEXTURE_LINEAR_LINEAR: number;
  823. /** Trilinear is mag = linear and min = linear and mip = linear */
  824. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  825. /** Trilinear is mag = linear and min = linear and mip = linear */
  826. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  827. /** mag = nearest and min = nearest and mip = nearest */
  828. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  829. /** mag = nearest and min = linear and mip = nearest */
  830. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  831. /** mag = nearest and min = linear and mip = linear */
  832. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  833. /** mag = nearest and min = linear and mip = none */
  834. static readonly TEXTURE_NEAREST_LINEAR: number;
  835. /** nearest is mag = nearest and min = nearest and mip = linear */
  836. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  837. /** mag = linear and min = nearest and mip = nearest */
  838. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = linear */
  840. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  841. /** Bilinear is mag = linear and min = linear and mip = nearest */
  842. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  843. /** mag = linear and min = nearest and mip = none */
  844. static readonly TEXTURE_LINEAR_NEAREST: number;
  845. /** Explicit coordinates mode */
  846. static readonly TEXTURE_EXPLICIT_MODE: number;
  847. /** Spherical coordinates mode */
  848. static readonly TEXTURE_SPHERICAL_MODE: number;
  849. /** Planar coordinates mode */
  850. static readonly TEXTURE_PLANAR_MODE: number;
  851. /** Cubic coordinates mode */
  852. static readonly TEXTURE_CUBIC_MODE: number;
  853. /** Projection coordinates mode */
  854. static readonly TEXTURE_PROJECTION_MODE: number;
  855. /** Skybox coordinates mode */
  856. static readonly TEXTURE_SKYBOX_MODE: number;
  857. /** Inverse Cubic coordinates mode */
  858. static readonly TEXTURE_INVCUBIC_MODE: number;
  859. /** Equirectangular coordinates mode */
  860. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  861. /** Equirectangular Fixed coordinates mode */
  862. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  863. /** Equirectangular Fixed Mirrored coordinates mode */
  864. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  865. /** Offline (baking) quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  867. /** High quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  869. /** Medium quality for texture filtering */
  870. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  871. /** Low quality for texture filtering */
  872. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  873. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  874. static readonly SCALEMODE_FLOOR: number;
  875. /** Defines that texture rescaling will look for the nearest power of 2 size */
  876. static readonly SCALEMODE_NEAREST: number;
  877. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  878. static readonly SCALEMODE_CEILING: number;
  879. /**
  880. * The dirty texture flag value
  881. */
  882. static readonly MATERIAL_TextureDirtyFlag: number;
  883. /**
  884. * The dirty light flag value
  885. */
  886. static readonly MATERIAL_LightDirtyFlag: number;
  887. /**
  888. * The dirty fresnel flag value
  889. */
  890. static readonly MATERIAL_FresnelDirtyFlag: number;
  891. /**
  892. * The dirty attribute flag value
  893. */
  894. static readonly MATERIAL_AttributesDirtyFlag: number;
  895. /**
  896. * The dirty misc flag value
  897. */
  898. static readonly MATERIAL_MiscDirtyFlag: number;
  899. /**
  900. * The dirty prepass flag value
  901. */
  902. static readonly MATERIAL_PrePassDirtyFlag: number;
  903. /**
  904. * The all dirty flag value
  905. */
  906. static readonly MATERIAL_AllDirtyFlag: number;
  907. /**
  908. * Returns the triangle fill mode
  909. */
  910. static readonly MATERIAL_TriangleFillMode: number;
  911. /**
  912. * Returns the wireframe mode
  913. */
  914. static readonly MATERIAL_WireFrameFillMode: number;
  915. /**
  916. * Returns the point fill mode
  917. */
  918. static readonly MATERIAL_PointFillMode: number;
  919. /**
  920. * Returns the point list draw mode
  921. */
  922. static readonly MATERIAL_PointListDrawMode: number;
  923. /**
  924. * Returns the line list draw mode
  925. */
  926. static readonly MATERIAL_LineListDrawMode: number;
  927. /**
  928. * Returns the line loop draw mode
  929. */
  930. static readonly MATERIAL_LineLoopDrawMode: number;
  931. /**
  932. * Returns the line strip draw mode
  933. */
  934. static readonly MATERIAL_LineStripDrawMode: number;
  935. /**
  936. * Returns the triangle strip draw mode
  937. */
  938. static readonly MATERIAL_TriangleStripDrawMode: number;
  939. /**
  940. * Returns the triangle fan draw mode
  941. */
  942. static readonly MATERIAL_TriangleFanDrawMode: number;
  943. /**
  944. * Stores the clock-wise side orientation
  945. */
  946. static readonly MATERIAL_ClockWiseSideOrientation: number;
  947. /**
  948. * Stores the counter clock-wise side orientation
  949. */
  950. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  951. /**
  952. * Nothing
  953. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_NothingTrigger: number;
  956. /**
  957. * On pick
  958. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPickTrigger: number;
  961. /**
  962. * On left pick
  963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnLeftPickTrigger: number;
  966. /**
  967. * On right pick
  968. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnRightPickTrigger: number;
  971. /**
  972. * On center pick
  973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnCenterPickTrigger: number;
  976. /**
  977. * On pick down
  978. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnPickDownTrigger: number;
  981. /**
  982. * On double pick
  983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnDoublePickTrigger: number;
  986. /**
  987. * On pick up
  988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  989. */
  990. static readonly ACTION_OnPickUpTrigger: number;
  991. /**
  992. * On pick out.
  993. * This trigger will only be raised if you also declared a OnPickDown
  994. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  995. */
  996. static readonly ACTION_OnPickOutTrigger: number;
  997. /**
  998. * On long press
  999. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1000. */
  1001. static readonly ACTION_OnLongPressTrigger: number;
  1002. /**
  1003. * On pointer over
  1004. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1005. */
  1006. static readonly ACTION_OnPointerOverTrigger: number;
  1007. /**
  1008. * On pointer out
  1009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1010. */
  1011. static readonly ACTION_OnPointerOutTrigger: number;
  1012. /**
  1013. * On every frame
  1014. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1015. */
  1016. static readonly ACTION_OnEveryFrameTrigger: number;
  1017. /**
  1018. * On intersection enter
  1019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1020. */
  1021. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1022. /**
  1023. * On intersection exit
  1024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1025. */
  1026. static readonly ACTION_OnIntersectionExitTrigger: number;
  1027. /**
  1028. * On key down
  1029. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1030. */
  1031. static readonly ACTION_OnKeyDownTrigger: number;
  1032. /**
  1033. * On key up
  1034. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1035. */
  1036. static readonly ACTION_OnKeyUpTrigger: number;
  1037. /**
  1038. * Billboard mode will only apply to Y axis
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1041. /**
  1042. * Billboard mode will apply to all axes
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1045. /**
  1046. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1047. */
  1048. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1049. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1050. * Test order :
  1051. * Is the bounding sphere outside the frustum ?
  1052. * If not, are the bounding box vertices outside the frustum ?
  1053. * It not, then the cullable object is in the frustum.
  1054. */
  1055. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1056. /** Culling strategy : Bounding Sphere Only.
  1057. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1058. * It's also less accurate than the standard because some not visible objects can still be selected.
  1059. * Test : is the bounding sphere outside the frustum ?
  1060. * If not, then the cullable object is in the frustum.
  1061. */
  1062. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1063. /** Culling strategy : Optimistic Inclusion.
  1064. * This in an inclusion test first, then the standard exclusion test.
  1065. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1066. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1067. * Anyway, it's as accurate as the standard strategy.
  1068. * Test :
  1069. * Is the cullable object bounding sphere center in the frustum ?
  1070. * If not, apply the default culling strategy.
  1071. */
  1072. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1073. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1074. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1075. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1076. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1077. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1078. * Test :
  1079. * Is the cullable object bounding sphere center in the frustum ?
  1080. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1081. */
  1082. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1083. /**
  1084. * No logging while loading
  1085. */
  1086. static readonly SCENELOADER_NO_LOGGING: number;
  1087. /**
  1088. * Minimal logging while loading
  1089. */
  1090. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1091. /**
  1092. * Summary logging while loading
  1093. */
  1094. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1095. /**
  1096. * Detailed logging while loading
  1097. */
  1098. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1099. /**
  1100. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1101. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1102. */
  1103. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1104. /**
  1105. * Constant used to retrieve the position texture index in the textures array in the prepass
  1106. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1107. */
  1108. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1109. /**
  1110. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1111. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1112. */
  1113. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1114. /**
  1115. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1116. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1117. */
  1118. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1119. /**
  1120. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1121. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1122. */
  1123. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1124. /**
  1125. * Constant used to retrieve depth index in the textures array in the prepass
  1126. * using the getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE)
  1127. */
  1128. static readonly PREPASS_DEPTH_TEXTURE_TYPE: number;
  1129. /**
  1130. * Constant used to retrieve normal index in the textures array in the prepass
  1131. * using the getIndex(Constants.PREPASS_NORMAL_TEXTURE_TYPE)
  1132. */
  1133. static readonly PREPASS_NORMAL_TEXTURE_TYPE: number;
  1134. /**
  1135. * Constant used to retrieve albedo index in the textures array in the prepass
  1136. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1137. */
  1138. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1139. /**
  1140. * Prefixes used by the engine for custom effects
  1141. */
  1142. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1143. }
  1144. }
  1145. declare module "babylonjs/Materials/Textures/hardwareTextureWrapper" {
  1146. /** @hidden */
  1147. export interface HardwareTextureWrapper {
  1148. underlyingResource: any;
  1149. set(hardwareTexture: any): void;
  1150. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1151. reset(): void;
  1152. release(): void;
  1153. }
  1154. }
  1155. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1156. import { Nullable } from "babylonjs/types";
  1157. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1158. /**
  1159. * This represents the required contract to create a new type of texture loader.
  1160. */
  1161. export interface IInternalTextureLoader {
  1162. /**
  1163. * Defines whether the loader supports cascade loading the different faces.
  1164. */
  1165. supportCascades: boolean;
  1166. /**
  1167. * This returns if the loader support the current file information.
  1168. * @param extension defines the file extension of the file being loaded
  1169. * @param mimeType defines the optional mime type of the file being loaded
  1170. * @returns true if the loader can load the specified file
  1171. */
  1172. canLoad(extension: string, mimeType?: string): boolean;
  1173. /**
  1174. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1175. * @param data contains the texture data
  1176. * @param texture defines the BabylonJS internal texture
  1177. * @param createPolynomials will be true if polynomials have been requested
  1178. * @param onLoad defines the callback to trigger once the texture is ready
  1179. * @param onError defines the callback to trigger in case of error
  1180. * @param options options to be passed to the loader
  1181. */
  1182. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1183. /**
  1184. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1185. * @param data contains the texture data
  1186. * @param texture defines the BabylonJS internal texture
  1187. * @param callback defines the method to call once ready to upload
  1188. * @param options options to be passed to the loader
  1189. */
  1190. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1191. }
  1192. }
  1193. declare module "babylonjs/Maths/math.like" {
  1194. import { float, int, DeepImmutable } from "babylonjs/types";
  1195. /**
  1196. * @hidden
  1197. */
  1198. export interface IColor4Like {
  1199. r: float;
  1200. g: float;
  1201. b: float;
  1202. a: float;
  1203. }
  1204. /**
  1205. * @hidden
  1206. */
  1207. export interface IColor3Like {
  1208. r: float;
  1209. g: float;
  1210. b: float;
  1211. }
  1212. /**
  1213. * @hidden
  1214. */
  1215. export interface IVector4Like {
  1216. x: float;
  1217. y: float;
  1218. z: float;
  1219. w: float;
  1220. }
  1221. /**
  1222. * @hidden
  1223. */
  1224. export interface IVector3Like {
  1225. x: float;
  1226. y: float;
  1227. z: float;
  1228. }
  1229. /**
  1230. * @hidden
  1231. */
  1232. export interface IVector2Like {
  1233. x: float;
  1234. y: float;
  1235. }
  1236. /**
  1237. * @hidden
  1238. */
  1239. export interface IMatrixLike {
  1240. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1241. updateFlag: int;
  1242. }
  1243. /**
  1244. * @hidden
  1245. */
  1246. export interface IViewportLike {
  1247. x: float;
  1248. y: float;
  1249. width: float;
  1250. height: float;
  1251. }
  1252. /**
  1253. * @hidden
  1254. */
  1255. export interface IPlaneLike {
  1256. normal: IVector3Like;
  1257. d: float;
  1258. normalize(): void;
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/IPipelineContext" {
  1262. import { Nullable } from "babylonjs/types";
  1263. import { Effect } from "babylonjs/Materials/effect";
  1264. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  1265. /**
  1266. * Class used to store and describe the pipeline context associated with an effect
  1267. */
  1268. export interface IPipelineContext {
  1269. /**
  1270. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1271. */
  1272. isAsync: boolean;
  1273. /**
  1274. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1275. */
  1276. isReady: boolean;
  1277. /** @hidden */
  1278. _name?: string;
  1279. /** @hidden */
  1280. _getVertexShaderCode(): string | null;
  1281. /** @hidden */
  1282. _getFragmentShaderCode(): string | null;
  1283. /** @hidden */
  1284. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1285. /** @hidden */
  1286. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1287. [key: string]: number;
  1288. }, uniformsNames: string[], uniforms: {
  1289. [key: string]: Nullable<WebGLUniformLocation>;
  1290. }, samplerList: string[], samplers: {
  1291. [key: string]: number;
  1292. }, attributesNames: string[], attributes: number[]): void;
  1293. /** Releases the resources associated with the pipeline. */
  1294. dispose(): void;
  1295. /**
  1296. * Sets an integer value on a uniform variable.
  1297. * @param uniformName Name of the variable.
  1298. * @param value Value to be set.
  1299. */
  1300. setInt(uniformName: string, value: number): void;
  1301. /**
  1302. * Sets an int2 value on a uniform variable.
  1303. * @param uniformName Name of the variable.
  1304. * @param x First int in int2.
  1305. * @param y Second int in int2.
  1306. */
  1307. setInt2(uniformName: string, x: number, y: number): void;
  1308. /**
  1309. * Sets an int3 value on a uniform variable.
  1310. * @param uniformName Name of the variable.
  1311. * @param x First int in int3.
  1312. * @param y Second int in int3.
  1313. * @param z Third int in int3.
  1314. */
  1315. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1316. /**
  1317. * Sets an int4 value on a uniform variable.
  1318. * @param uniformName Name of the variable.
  1319. * @param x First int in int4.
  1320. * @param y Second int in int4.
  1321. * @param z Third int in int4.
  1322. * @param w Fourth int in int4.
  1323. */
  1324. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1325. /**
  1326. * Sets an int array on a uniform variable.
  1327. * @param uniformName Name of the variable.
  1328. * @param array array to be set.
  1329. */
  1330. setIntArray(uniformName: string, array: Int32Array): void;
  1331. /**
  1332. * 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)
  1333. * @param uniformName Name of the variable.
  1334. * @param array array to be set.
  1335. */
  1336. setIntArray2(uniformName: string, array: Int32Array): void;
  1337. /**
  1338. * 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)
  1339. * @param uniformName Name of the variable.
  1340. * @param array array to be set.
  1341. */
  1342. setIntArray3(uniformName: string, array: Int32Array): void;
  1343. /**
  1344. * 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)
  1345. * @param uniformName Name of the variable.
  1346. * @param array array to be set.
  1347. */
  1348. setIntArray4(uniformName: string, array: Int32Array): void;
  1349. /**
  1350. * Sets an array on a uniform variable.
  1351. * @param uniformName Name of the variable.
  1352. * @param array array to be set.
  1353. */
  1354. setArray(uniformName: string, array: number[] | Float32Array): void;
  1355. /**
  1356. * 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)
  1357. * @param uniformName Name of the variable.
  1358. * @param array array to be set.
  1359. */
  1360. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1361. /**
  1362. * 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)
  1363. * @param uniformName Name of the variable.
  1364. * @param array array to be set.
  1365. */
  1366. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1367. /**
  1368. * 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)
  1369. * @param uniformName Name of the variable.
  1370. * @param array array to be set.
  1371. */
  1372. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1373. /**
  1374. * Sets matrices on a uniform variable.
  1375. * @param uniformName Name of the variable.
  1376. * @param matrices matrices to be set.
  1377. */
  1378. setMatrices(uniformName: string, matrices: Float32Array): void;
  1379. /**
  1380. * Sets matrix on a uniform variable.
  1381. * @param uniformName Name of the variable.
  1382. * @param matrix matrix to be set.
  1383. */
  1384. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1385. /**
  1386. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1387. * @param uniformName Name of the variable.
  1388. * @param matrix matrix to be set.
  1389. */
  1390. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1391. /**
  1392. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1393. * @param uniformName Name of the variable.
  1394. * @param matrix matrix to be set.
  1395. */
  1396. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1397. /**
  1398. * Sets a float on a uniform variable.
  1399. * @param uniformName Name of the variable.
  1400. * @param value value to be set.
  1401. */
  1402. setFloat(uniformName: string, value: number): void;
  1403. /**
  1404. * Sets a Vector2 on a uniform variable.
  1405. * @param uniformName Name of the variable.
  1406. * @param vector2 vector2 to be set.
  1407. */
  1408. setVector2(uniformName: string, vector2: IVector2Like): void;
  1409. /**
  1410. * Sets a float2 on a uniform variable.
  1411. * @param uniformName Name of the variable.
  1412. * @param x First float in float2.
  1413. * @param y Second float in float2.
  1414. */
  1415. setFloat2(uniformName: string, x: number, y: number): void;
  1416. /**
  1417. * Sets a Vector3 on a uniform variable.
  1418. * @param uniformName Name of the variable.
  1419. * @param vector3 Value to be set.
  1420. */
  1421. setVector3(uniformName: string, vector3: IVector3Like): void;
  1422. /**
  1423. * Sets a float3 on a uniform variable.
  1424. * @param uniformName Name of the variable.
  1425. * @param x First float in float3.
  1426. * @param y Second float in float3.
  1427. * @param z Third float in float3.
  1428. */
  1429. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1430. /**
  1431. * Sets a Vector4 on a uniform variable.
  1432. * @param uniformName Name of the variable.
  1433. * @param vector4 Value to be set.
  1434. */
  1435. setVector4(uniformName: string, vector4: IVector4Like): void;
  1436. /**
  1437. * Sets a float4 on a uniform variable.
  1438. * @param uniformName Name of the variable.
  1439. * @param x First float in float4.
  1440. * @param y Second float in float4.
  1441. * @param z Third float in float4.
  1442. * @param w Fourth float in float4.
  1443. */
  1444. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1445. /**
  1446. * Sets a Color3 on a uniform variable.
  1447. * @param uniformName Name of the variable.
  1448. * @param color3 Value to be set.
  1449. */
  1450. setColor3(uniformName: string, color3: IColor3Like): void;
  1451. /**
  1452. * Sets a Color4 on a uniform variable.
  1453. * @param uniformName Name of the variable.
  1454. * @param color3 Value to be set.
  1455. * @param alpha Alpha value to be set.
  1456. */
  1457. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1458. /**
  1459. * Sets a Color4 on a uniform variable
  1460. * @param uniformName defines the name of the variable
  1461. * @param color4 defines the value to be set
  1462. */
  1463. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1464. }
  1465. }
  1466. declare module "babylonjs/Meshes/dataBuffer" {
  1467. /**
  1468. * Class used to store gfx data (like WebGLBuffer)
  1469. */
  1470. export class DataBuffer {
  1471. private static _Counter;
  1472. /**
  1473. * Gets or sets the number of objects referencing this buffer
  1474. */
  1475. references: number;
  1476. /** Gets or sets the size of the underlying buffer */
  1477. capacity: number;
  1478. /**
  1479. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1480. */
  1481. is32Bits: boolean;
  1482. /**
  1483. * Gets the underlying buffer
  1484. */
  1485. get underlyingResource(): any;
  1486. /**
  1487. * Gets the unique id of this buffer
  1488. */
  1489. readonly uniqueId: number;
  1490. /**
  1491. * Constructs the buffer
  1492. */
  1493. constructor();
  1494. }
  1495. }
  1496. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1497. import { Nullable } from "babylonjs/types";
  1498. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1499. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1500. /** @hidden */
  1501. export interface IShaderProcessor {
  1502. attributeProcessor?: (attribute: string, preProcessors: {
  1503. [key: string]: string;
  1504. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1505. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1506. [key: string]: string;
  1507. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1508. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1509. [key: string]: string;
  1510. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1511. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1512. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1513. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1514. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1515. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1516. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1517. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1518. vertexCode: string;
  1519. fragmentCode: string;
  1520. };
  1521. }
  1522. }
  1523. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1524. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1525. import { Nullable } from "babylonjs/types";
  1526. /** @hidden */
  1527. export interface ShaderProcessingContext {
  1528. }
  1529. /** @hidden */
  1530. export interface ProcessingOptions {
  1531. defines: string[];
  1532. indexParameters: any;
  1533. isFragment: boolean;
  1534. shouldUseHighPrecisionShader: boolean;
  1535. supportsUniformBuffers: boolean;
  1536. shadersRepository: string;
  1537. includesShadersStore: {
  1538. [key: string]: string;
  1539. };
  1540. processor: Nullable<IShaderProcessor>;
  1541. version: string;
  1542. platformName: string;
  1543. lookForClosingBracketForUniformBuffer?: boolean;
  1544. processingContext: Nullable<ShaderProcessingContext>;
  1545. }
  1546. }
  1547. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1548. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1549. /** @hidden */
  1550. export class ShaderCodeNode {
  1551. line: string;
  1552. children: ShaderCodeNode[];
  1553. additionalDefineKey?: string;
  1554. additionalDefineValue?: string;
  1555. isValid(preprocessors: {
  1556. [key: string]: string;
  1557. }): boolean;
  1558. process(preprocessors: {
  1559. [key: string]: string;
  1560. }, options: ProcessingOptions): string;
  1561. }
  1562. }
  1563. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1564. /** @hidden */
  1565. export class ShaderCodeCursor {
  1566. private _lines;
  1567. lineIndex: number;
  1568. get currentLine(): string;
  1569. get canRead(): boolean;
  1570. set lines(value: string[]);
  1571. }
  1572. }
  1573. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1574. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1575. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1576. /** @hidden */
  1577. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1578. process(preprocessors: {
  1579. [key: string]: string;
  1580. }, options: ProcessingOptions): string;
  1581. }
  1582. }
  1583. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1584. /** @hidden */
  1585. export class ShaderDefineExpression {
  1586. isTrue(preprocessors: {
  1587. [key: string]: string;
  1588. }): boolean;
  1589. private static _OperatorPriority;
  1590. private static _Stack;
  1591. static postfixToInfix(postfix: string[]): string;
  1592. static infixToPostfix(infix: string): string[];
  1593. }
  1594. }
  1595. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1596. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1597. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1598. /** @hidden */
  1599. export class ShaderCodeTestNode extends ShaderCodeNode {
  1600. testExpression: ShaderDefineExpression;
  1601. isValid(preprocessors: {
  1602. [key: string]: string;
  1603. }): boolean;
  1604. }
  1605. }
  1606. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1607. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1608. /** @hidden */
  1609. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1610. define: string;
  1611. not: boolean;
  1612. constructor(define: string, not?: boolean);
  1613. isTrue(preprocessors: {
  1614. [key: string]: string;
  1615. }): boolean;
  1616. }
  1617. }
  1618. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1619. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1620. /** @hidden */
  1621. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1622. leftOperand: ShaderDefineExpression;
  1623. rightOperand: ShaderDefineExpression;
  1624. isTrue(preprocessors: {
  1625. [key: string]: string;
  1626. }): boolean;
  1627. }
  1628. }
  1629. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1630. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1631. /** @hidden */
  1632. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1633. leftOperand: ShaderDefineExpression;
  1634. rightOperand: ShaderDefineExpression;
  1635. isTrue(preprocessors: {
  1636. [key: string]: string;
  1637. }): boolean;
  1638. }
  1639. }
  1640. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1641. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1642. /** @hidden */
  1643. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1644. define: string;
  1645. operand: string;
  1646. testValue: string;
  1647. constructor(define: string, operand: string, testValue: string);
  1648. isTrue(preprocessors: {
  1649. [key: string]: string;
  1650. }): boolean;
  1651. }
  1652. }
  1653. declare module "babylonjs/Offline/IOfflineProvider" {
  1654. /**
  1655. * Class used to enable access to offline support
  1656. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1657. */
  1658. export interface IOfflineProvider {
  1659. /**
  1660. * Gets a boolean indicating if scene must be saved in the database
  1661. */
  1662. enableSceneOffline: boolean;
  1663. /**
  1664. * Gets a boolean indicating if textures must be saved in the database
  1665. */
  1666. enableTexturesOffline: boolean;
  1667. /**
  1668. * Open the offline support and make it available
  1669. * @param successCallback defines the callback to call on success
  1670. * @param errorCallback defines the callback to call on error
  1671. */
  1672. open(successCallback: () => void, errorCallback: () => void): void;
  1673. /**
  1674. * Loads an image from the offline support
  1675. * @param url defines the url to load from
  1676. * @param image defines the target DOM image
  1677. */
  1678. loadImage(url: string, image: HTMLImageElement): void;
  1679. /**
  1680. * Loads a file from offline support
  1681. * @param url defines the URL to load from
  1682. * @param sceneLoaded defines a callback to call on success
  1683. * @param progressCallBack defines a callback to call when progress changed
  1684. * @param errorCallback defines a callback to call on error
  1685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1686. */
  1687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1688. }
  1689. }
  1690. declare module "babylonjs/Misc/filesInputStore" {
  1691. /**
  1692. * Class used to help managing file picking and drag'n'drop
  1693. * File Storage
  1694. */
  1695. export class FilesInputStore {
  1696. /**
  1697. * List of files ready to be loaded
  1698. */
  1699. static FilesToLoad: {
  1700. [key: string]: File;
  1701. };
  1702. }
  1703. }
  1704. declare module "babylonjs/Misc/retryStrategy" {
  1705. import { WebRequest } from "babylonjs/Misc/webRequest";
  1706. /**
  1707. * Class used to define a retry strategy when error happens while loading assets
  1708. */
  1709. export class RetryStrategy {
  1710. /**
  1711. * Function used to defines an exponential back off strategy
  1712. * @param maxRetries defines the maximum number of retries (3 by default)
  1713. * @param baseInterval defines the interval between retries
  1714. * @returns the strategy function to use
  1715. */
  1716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1717. }
  1718. }
  1719. declare module "babylonjs/Misc/baseError" {
  1720. /**
  1721. * @ignore
  1722. * Application error to support additional information when loading a file
  1723. */
  1724. export abstract class BaseError extends Error {
  1725. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1726. }
  1727. }
  1728. declare module "babylonjs/Misc/fileTools" {
  1729. import { WebRequest } from "babylonjs/Misc/webRequest";
  1730. import { Nullable } from "babylonjs/types";
  1731. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1732. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1733. import { BaseError } from "babylonjs/Misc/baseError";
  1734. /** @ignore */
  1735. export class LoadFileError extends BaseError {
  1736. request?: WebRequest;
  1737. file?: File;
  1738. /**
  1739. * Creates a new LoadFileError
  1740. * @param message defines the message of the error
  1741. * @param request defines the optional web request
  1742. * @param file defines the optional file
  1743. */
  1744. constructor(message: string, object?: WebRequest | File);
  1745. }
  1746. /** @ignore */
  1747. export class RequestFileError extends BaseError {
  1748. request: WebRequest;
  1749. /**
  1750. * Creates a new LoadFileError
  1751. * @param message defines the message of the error
  1752. * @param request defines the optional web request
  1753. */
  1754. constructor(message: string, request: WebRequest);
  1755. }
  1756. /** @ignore */
  1757. export class ReadFileError extends BaseError {
  1758. file: File;
  1759. /**
  1760. * Creates a new ReadFileError
  1761. * @param message defines the message of the error
  1762. * @param file defines the optional file
  1763. */
  1764. constructor(message: string, file: File);
  1765. }
  1766. /**
  1767. * @hidden
  1768. */
  1769. export class FileTools {
  1770. /**
  1771. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1772. */
  1773. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1774. /**
  1775. * Gets or sets the base URL to use to load assets
  1776. */
  1777. static BaseUrl: string;
  1778. /**
  1779. * Default behaviour for cors in the application.
  1780. * It can be a string if the expected behavior is identical in the entire app.
  1781. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1782. */
  1783. static CorsBehavior: string | ((url: string | string[]) => string);
  1784. /**
  1785. * Gets or sets a function used to pre-process url before using them to load assets
  1786. */
  1787. static PreprocessUrl: (url: string) => string;
  1788. /**
  1789. * Removes unwanted characters from an url
  1790. * @param url defines the url to clean
  1791. * @returns the cleaned url
  1792. */
  1793. private static _CleanUrl;
  1794. /**
  1795. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1796. * @param url define the url we are trying
  1797. * @param element define the dom element where to configure the cors policy
  1798. */
  1799. static SetCorsBehavior(url: string | string[], element: {
  1800. crossOrigin: string | null;
  1801. }): void;
  1802. /**
  1803. * Loads an image as an HTMLImageElement.
  1804. * @param input url string, ArrayBuffer, or Blob to load
  1805. * @param onLoad callback called when the image successfully loads
  1806. * @param onError callback called when the image fails to load
  1807. * @param offlineProvider offline provider for caching
  1808. * @param mimeType optional mime type
  1809. * @returns the HTMLImageElement of the loaded image
  1810. */
  1811. 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>;
  1812. /**
  1813. * Reads a file from a File object
  1814. * @param file defines the file to load
  1815. * @param onSuccess defines the callback to call when data is loaded
  1816. * @param onProgress defines the callback to call during loading process
  1817. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1818. * @param onError defines the callback to call when an error occurs
  1819. * @returns a file request object
  1820. */
  1821. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1822. /**
  1823. * Loads a file from a url
  1824. * @param url url to load
  1825. * @param onSuccess callback called when the file successfully loads
  1826. * @param onProgress callback called while file is loading (if the server supports this mode)
  1827. * @param offlineProvider defines the offline provider for caching
  1828. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1829. * @param onError callback called when the file fails to load
  1830. * @returns a file request object
  1831. */
  1832. 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;
  1833. /**
  1834. * Loads a file
  1835. * @param url url to load
  1836. * @param onSuccess callback called when the file successfully loads
  1837. * @param onProgress callback called while file is loading (if the server supports this mode)
  1838. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1839. * @param onError callback called when the file fails to load
  1840. * @param onOpened callback called when the web request is opened
  1841. * @returns a file request object
  1842. */
  1843. 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;
  1844. /**
  1845. * Checks if the loaded document was accessed via `file:`-Protocol.
  1846. * @returns boolean
  1847. */
  1848. static IsFileURL(): boolean;
  1849. }
  1850. }
  1851. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1852. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1853. import { WebRequest } from "babylonjs/Misc/webRequest";
  1854. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1855. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1856. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1857. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1858. /** @hidden */
  1859. export class ShaderProcessor {
  1860. static Initialize(options: ProcessingOptions): void;
  1861. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1862. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1863. vertexCode: string;
  1864. fragmentCode: string;
  1865. };
  1866. private static _ProcessPrecision;
  1867. private static _ExtractOperation;
  1868. private static _BuildSubExpression;
  1869. private static _BuildExpression;
  1870. private static _MoveCursorWithinIf;
  1871. private static _MoveCursor;
  1872. private static _EvaluatePreProcessors;
  1873. private static _PreparePreProcessors;
  1874. private static _ProcessShaderConversion;
  1875. private static _ProcessIncludes;
  1876. /**
  1877. * Loads a file from a url
  1878. * @param url url to load
  1879. * @param onSuccess callback called when the file successfully loads
  1880. * @param onProgress callback called while file is loading (if the server supports this mode)
  1881. * @param offlineProvider defines the offline provider for caching
  1882. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1883. * @param onError callback called when the file fails to load
  1884. * @returns a file request object
  1885. * @hidden
  1886. */
  1887. 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;
  1888. }
  1889. }
  1890. declare module "babylonjs/Materials/iEffectFallbacks" {
  1891. import { Effect } from "babylonjs/Materials/effect";
  1892. /**
  1893. * Interface used to define common properties for effect fallbacks
  1894. */
  1895. export interface IEffectFallbacks {
  1896. /**
  1897. * Removes the defines that should be removed when falling back.
  1898. * @param currentDefines defines the current define statements for the shader.
  1899. * @param effect defines the current effect we try to compile
  1900. * @returns The resulting defines with defines of the current rank removed.
  1901. */
  1902. reduce(currentDefines: string, effect: Effect): string;
  1903. /**
  1904. * Removes the fallback from the bound mesh.
  1905. */
  1906. unBindMesh(): void;
  1907. /**
  1908. * Checks to see if more fallbacks are still available.
  1909. */
  1910. hasMoreFallbacks: boolean;
  1911. }
  1912. }
  1913. declare module "babylonjs/Maths/math.size" {
  1914. /**
  1915. * Interface for the size containing width and height
  1916. */
  1917. export interface ISize {
  1918. /**
  1919. * Width
  1920. */
  1921. width: number;
  1922. /**
  1923. * Heighht
  1924. */
  1925. height: number;
  1926. }
  1927. /**
  1928. * Size containing widht and height
  1929. */
  1930. export class Size implements ISize {
  1931. /**
  1932. * Width
  1933. */
  1934. width: number;
  1935. /**
  1936. * Height
  1937. */
  1938. height: number;
  1939. /**
  1940. * Creates a Size object from the given width and height (floats).
  1941. * @param width width of the new size
  1942. * @param height height of the new size
  1943. */
  1944. constructor(width: number, height: number);
  1945. /**
  1946. * Returns a string with the Size width and height
  1947. * @returns a string with the Size width and height
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * "Size"
  1952. * @returns the string "Size"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Returns the Size hash code.
  1957. * @returns a hash code for a unique width and height
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Updates the current size from the given one.
  1962. * @param src the given size
  1963. */
  1964. copyFrom(src: Size): void;
  1965. /**
  1966. * Updates in place the current Size from the given floats.
  1967. * @param width width of the new size
  1968. * @param height height of the new size
  1969. * @returns the updated Size.
  1970. */
  1971. copyFromFloats(width: number, height: number): Size;
  1972. /**
  1973. * Updates in place the current Size from the given floats.
  1974. * @param width width to set
  1975. * @param height height to set
  1976. * @returns the updated Size.
  1977. */
  1978. set(width: number, height: number): Size;
  1979. /**
  1980. * Multiplies the width and height by numbers
  1981. * @param w factor to multiple the width by
  1982. * @param h factor to multiple the height by
  1983. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1984. */
  1985. multiplyByFloats(w: number, h: number): Size;
  1986. /**
  1987. * Clones the size
  1988. * @returns a new Size copied from the given one.
  1989. */
  1990. clone(): Size;
  1991. /**
  1992. * True if the current Size and the given one width and height are strictly equal.
  1993. * @param other the other size to compare against
  1994. * @returns True if the current Size and the given one width and height are strictly equal.
  1995. */
  1996. equals(other: Size): boolean;
  1997. /**
  1998. * The surface of the Size : width * height (float).
  1999. */
  2000. get surface(): number;
  2001. /**
  2002. * Create a new size of zero
  2003. * @returns a new Size set to (0.0, 0.0)
  2004. */
  2005. static Zero(): Size;
  2006. /**
  2007. * Sums the width and height of two sizes
  2008. * @param otherSize size to add to this size
  2009. * @returns a new Size set as the addition result of the current Size and the given one.
  2010. */
  2011. add(otherSize: Size): Size;
  2012. /**
  2013. * Subtracts the width and height of two
  2014. * @param otherSize size to subtract to this size
  2015. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2016. */
  2017. subtract(otherSize: Size): Size;
  2018. /**
  2019. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2020. * @param start starting size to lerp between
  2021. * @param end end size to lerp between
  2022. * @param amount amount to lerp between the start and end values
  2023. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2024. */
  2025. static Lerp(start: Size, end: Size, amount: number): Size;
  2026. }
  2027. }
  2028. declare module "babylonjs/Materials/Textures/thinTexture" {
  2029. import { Nullable } from "babylonjs/types";
  2030. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  2031. import { ISize } from "babylonjs/Maths/math.size";
  2032. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  2033. /**
  2034. * Base class of all the textures in babylon.
  2035. * It groups all the common properties required to work with Thin Engine.
  2036. */
  2037. export class ThinTexture {
  2038. protected _wrapU: number;
  2039. /**
  2040. * | Value | Type | Description |
  2041. * | ----- | ------------------ | ----------- |
  2042. * | 0 | CLAMP_ADDRESSMODE | |
  2043. * | 1 | WRAP_ADDRESSMODE | |
  2044. * | 2 | MIRROR_ADDRESSMODE | |
  2045. */
  2046. get wrapU(): number;
  2047. set wrapU(value: number);
  2048. protected _wrapV: number;
  2049. /**
  2050. * | Value | Type | Description |
  2051. * | ----- | ------------------ | ----------- |
  2052. * | 0 | CLAMP_ADDRESSMODE | |
  2053. * | 1 | WRAP_ADDRESSMODE | |
  2054. * | 2 | MIRROR_ADDRESSMODE | |
  2055. */
  2056. get wrapV(): number;
  2057. set wrapV(value: number);
  2058. /**
  2059. * | Value | Type | Description |
  2060. * | ----- | ------------------ | ----------- |
  2061. * | 0 | CLAMP_ADDRESSMODE | |
  2062. * | 1 | WRAP_ADDRESSMODE | |
  2063. * | 2 | MIRROR_ADDRESSMODE | |
  2064. */
  2065. wrapR: number;
  2066. /**
  2067. * With compliant hardware and browser (supporting anisotropic filtering)
  2068. * this defines the level of anisotropic filtering in the texture.
  2069. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2070. */
  2071. anisotropicFilteringLevel: number;
  2072. /**
  2073. * Define the current state of the loading sequence when in delayed load mode.
  2074. */
  2075. delayLoadState: number;
  2076. /**
  2077. * How a texture is mapped.
  2078. * Unused in thin texture mode.
  2079. */
  2080. get coordinatesMode(): number;
  2081. /**
  2082. * Define if the texture is a cube texture or if false a 2d texture.
  2083. */
  2084. get isCube(): boolean;
  2085. set isCube(value: boolean);
  2086. /**
  2087. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2088. */
  2089. get is3D(): boolean;
  2090. set is3D(value: boolean);
  2091. /**
  2092. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2093. */
  2094. get is2DArray(): boolean;
  2095. set is2DArray(value: boolean);
  2096. /**
  2097. * Get the class name of the texture.
  2098. * @returns "ThinTexture"
  2099. */
  2100. getClassName(): string;
  2101. /** @hidden */
  2102. _texture: Nullable<InternalTexture>;
  2103. protected _engine: Nullable<ThinEngine>;
  2104. private _cachedSize;
  2105. private _cachedBaseSize;
  2106. /**
  2107. * Instantiates a new ThinTexture.
  2108. * Base class of all the textures in babylon.
  2109. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2110. * @param internalTexture Define the internalTexture to wrap
  2111. */
  2112. constructor(internalTexture: Nullable<InternalTexture>);
  2113. /**
  2114. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2115. * @returns true if fully ready
  2116. */
  2117. isReady(): boolean;
  2118. /**
  2119. * Triggers the load sequence in delayed load mode.
  2120. */
  2121. delayLoad(): void;
  2122. /**
  2123. * Get the underlying lower level texture from Babylon.
  2124. * @returns the internal texture
  2125. */
  2126. getInternalTexture(): Nullable<InternalTexture>;
  2127. /**
  2128. * Get the size of the texture.
  2129. * @returns the texture size.
  2130. */
  2131. getSize(): ISize;
  2132. /**
  2133. * Get the base size of the texture.
  2134. * It can be different from the size if the texture has been resized for POT for instance
  2135. * @returns the base size
  2136. */
  2137. getBaseSize(): ISize;
  2138. /**
  2139. * Update the sampling mode of the texture.
  2140. * Default is Trilinear mode.
  2141. *
  2142. * | Value | Type | Description |
  2143. * | ----- | ------------------ | ----------- |
  2144. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2145. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2146. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2147. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2148. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2149. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2150. * | 7 | NEAREST_LINEAR | |
  2151. * | 8 | NEAREST_NEAREST | |
  2152. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2153. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2154. * | 11 | LINEAR_LINEAR | |
  2155. * | 12 | LINEAR_NEAREST | |
  2156. *
  2157. * > _mag_: magnification filter (close to the viewer)
  2158. * > _min_: minification filter (far from the viewer)
  2159. * > _mip_: filter used between mip map levels
  2160. *@param samplingMode Define the new sampling mode of the texture
  2161. */
  2162. updateSamplingMode(samplingMode: number): void;
  2163. /**
  2164. * Release and destroy the underlying lower level texture aka internalTexture.
  2165. */
  2166. releaseInternalTexture(): void;
  2167. /**
  2168. * Dispose the texture and release its associated resources.
  2169. */
  2170. dispose(): void;
  2171. }
  2172. }
  2173. declare module "babylonjs/Misc/smartArray" {
  2174. /**
  2175. * Defines an array and its length.
  2176. * It can be helpful to group result from both Arrays and smart arrays in one structure.
  2177. */
  2178. export interface ISmartArrayLike<T> {
  2179. /**
  2180. * The data of the array.
  2181. */
  2182. data: Array<T>;
  2183. /**
  2184. * The active length of the array.
  2185. */
  2186. length: number;
  2187. }
  2188. /**
  2189. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2190. */
  2191. export class SmartArray<T> implements ISmartArrayLike<T> {
  2192. /**
  2193. * The full set of data from the array.
  2194. */
  2195. data: Array<T>;
  2196. /**
  2197. * The active length of the array.
  2198. */
  2199. length: number;
  2200. protected _id: number;
  2201. /**
  2202. * Instantiates a Smart Array.
  2203. * @param capacity defines the default capacity of the array.
  2204. */
  2205. constructor(capacity: number);
  2206. /**
  2207. * Pushes a value at the end of the active data.
  2208. * @param value defines the object to push in the array.
  2209. */
  2210. push(value: T): void;
  2211. /**
  2212. * Iterates over the active data and apply the lambda to them.
  2213. * @param func defines the action to apply on each value.
  2214. */
  2215. forEach(func: (content: T) => void): void;
  2216. /**
  2217. * Sorts the full sets of data.
  2218. * @param compareFn defines the comparison function to apply.
  2219. */
  2220. sort(compareFn: (a: T, b: T) => number): void;
  2221. /**
  2222. * Resets the active data to an empty array.
  2223. */
  2224. reset(): void;
  2225. /**
  2226. * Releases all the data from the array as well as the array.
  2227. */
  2228. dispose(): void;
  2229. /**
  2230. * Concats the active data with a given array.
  2231. * @param array defines the data to concatenate with.
  2232. */
  2233. concat(array: any): void;
  2234. /**
  2235. * Returns the position of a value in the active data.
  2236. * @param value defines the value to find the index for
  2237. * @returns the index if found in the active data otherwise -1
  2238. */
  2239. indexOf(value: T): number;
  2240. /**
  2241. * Returns whether an element is part of the active data.
  2242. * @param value defines the value to look for
  2243. * @returns true if found in the active data otherwise false
  2244. */
  2245. contains(value: T): boolean;
  2246. private static _GlobalId;
  2247. }
  2248. /**
  2249. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2250. * The data in this array can only be present once
  2251. */
  2252. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2253. private _duplicateId;
  2254. /**
  2255. * Pushes a value at the end of the active data.
  2256. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2257. * @param value defines the object to push in the array.
  2258. */
  2259. push(value: T): void;
  2260. /**
  2261. * Pushes a value at the end of the active data.
  2262. * If the data is already present, it won t be added again
  2263. * @param value defines the object to push in the array.
  2264. * @returns true if added false if it was already present
  2265. */
  2266. pushNoDuplicate(value: T): boolean;
  2267. /**
  2268. * Resets the active data to an empty array.
  2269. */
  2270. reset(): void;
  2271. /**
  2272. * Concats the active data with a given array.
  2273. * This ensures no duplicate will be present in the result.
  2274. * @param array defines the data to concatenate with.
  2275. */
  2276. concatWithNoDuplicate(array: any): void;
  2277. }
  2278. }
  2279. declare module "babylonjs/Misc/andOrNotEvaluator" {
  2280. /**
  2281. * Class used to evaluate queries containing `and` and `or` operators
  2282. */
  2283. export class AndOrNotEvaluator {
  2284. /**
  2285. * Evaluate a query
  2286. * @param query defines the query to evaluate
  2287. * @param evaluateCallback defines the callback used to filter result
  2288. * @returns true if the query matches
  2289. */
  2290. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2291. private static _HandleParenthesisContent;
  2292. private static _SimplifyNegation;
  2293. }
  2294. }
  2295. declare module "babylonjs/Misc/tags" {
  2296. /**
  2297. * Class used to store custom tags
  2298. */
  2299. export class Tags {
  2300. /**
  2301. * Adds support for tags on the given object
  2302. * @param obj defines the object to use
  2303. */
  2304. static EnableFor(obj: any): void;
  2305. /**
  2306. * Removes tags support
  2307. * @param obj defines the object to use
  2308. */
  2309. static DisableFor(obj: any): void;
  2310. /**
  2311. * Gets a boolean indicating if the given object has tags
  2312. * @param obj defines the object to use
  2313. * @returns a boolean
  2314. */
  2315. static HasTags(obj: any): boolean;
  2316. /**
  2317. * Gets the tags available on a given object
  2318. * @param obj defines the object to use
  2319. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2320. * @returns the tags
  2321. */
  2322. static GetTags(obj: any, asString?: boolean): any;
  2323. /**
  2324. * Adds tags to an object
  2325. * @param obj defines the object to use
  2326. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2327. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2328. */
  2329. static AddTagsTo(obj: any, tagsString: string): void;
  2330. /**
  2331. * @hidden
  2332. */
  2333. static _AddTagTo(obj: any, tag: string): void;
  2334. /**
  2335. * Removes specific tags from a specific object
  2336. * @param obj defines the object to use
  2337. * @param tagsString defines the tags to remove
  2338. */
  2339. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2340. /**
  2341. * @hidden
  2342. */
  2343. static _RemoveTagFrom(obj: any, tag: string): void;
  2344. /**
  2345. * Defines if tags hosted on an object match a given query
  2346. * @param obj defines the object to use
  2347. * @param tagsQuery defines the tag query
  2348. * @returns a boolean
  2349. */
  2350. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2351. }
  2352. }
  2353. declare module "babylonjs/Maths/math.scalar" {
  2354. /**
  2355. * Scalar computation library
  2356. */
  2357. export class Scalar {
  2358. /**
  2359. * Two pi constants convenient for computation.
  2360. */
  2361. static TwoPi: number;
  2362. /**
  2363. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2364. * @param a number
  2365. * @param b number
  2366. * @param epsilon (default = 1.401298E-45)
  2367. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2368. */
  2369. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2370. /**
  2371. * Returns a string : the upper case translation of the number i to hexadecimal.
  2372. * @param i number
  2373. * @returns the upper case translation of the number i to hexadecimal.
  2374. */
  2375. static ToHex(i: number): string;
  2376. /**
  2377. * Returns -1 if value is negative and +1 is value is positive.
  2378. * @param value the value
  2379. * @returns the value itself if it's equal to zero.
  2380. */
  2381. static Sign(value: number): number;
  2382. /**
  2383. * Returns the value itself if it's between min and max.
  2384. * Returns min if the value is lower than min.
  2385. * Returns max if the value is greater than max.
  2386. * @param value the value to clmap
  2387. * @param min the min value to clamp to (default: 0)
  2388. * @param max the max value to clamp to (default: 1)
  2389. * @returns the clamped value
  2390. */
  2391. static Clamp(value: number, min?: number, max?: number): number;
  2392. /**
  2393. * the log2 of value.
  2394. * @param value the value to compute log2 of
  2395. * @returns the log2 of value.
  2396. */
  2397. static Log2(value: number): number;
  2398. /**
  2399. * the floor part of a log2 value.
  2400. * @param value the value to compute log2 of
  2401. * @returns the log2 of value.
  2402. */
  2403. static ILog2(value: number): number;
  2404. /**
  2405. * Loops the value, so that it is never larger than length and never smaller than 0.
  2406. *
  2407. * This is similar to the modulo operator but it works with floating point numbers.
  2408. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2409. * With t = 5 and length = 2.5, the result would be 0.0.
  2410. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2411. * @param value the value
  2412. * @param length the length
  2413. * @returns the looped value
  2414. */
  2415. static Repeat(value: number, length: number): number;
  2416. /**
  2417. * Normalize the value between 0.0 and 1.0 using min and max values
  2418. * @param value value to normalize
  2419. * @param min max to normalize between
  2420. * @param max min to normalize between
  2421. * @returns the normalized value
  2422. */
  2423. static Normalize(value: number, min: number, max: number): number;
  2424. /**
  2425. * Denormalize the value from 0.0 and 1.0 using min and max values
  2426. * @param normalized value to denormalize
  2427. * @param min max to denormalize between
  2428. * @param max min to denormalize between
  2429. * @returns the denormalized value
  2430. */
  2431. static Denormalize(normalized: number, min: number, max: number): number;
  2432. /**
  2433. * Calculates the shortest difference between two given angles given in degrees.
  2434. * @param current current angle in degrees
  2435. * @param target target angle in degrees
  2436. * @returns the delta
  2437. */
  2438. static DeltaAngle(current: number, target: number): number;
  2439. /**
  2440. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2441. * @param tx value
  2442. * @param length length
  2443. * @returns The returned value will move back and forth between 0 and length
  2444. */
  2445. static PingPong(tx: number, length: number): number;
  2446. /**
  2447. * Interpolates between min and max with smoothing at the limits.
  2448. *
  2449. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2450. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2451. * @param from from
  2452. * @param to to
  2453. * @param tx value
  2454. * @returns the smooth stepped value
  2455. */
  2456. static SmoothStep(from: number, to: number, tx: number): number;
  2457. /**
  2458. * Moves a value current towards target.
  2459. *
  2460. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2461. * Negative values of maxDelta pushes the value away from target.
  2462. * @param current current value
  2463. * @param target target value
  2464. * @param maxDelta max distance to move
  2465. * @returns resulting value
  2466. */
  2467. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2468. /**
  2469. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2470. *
  2471. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2472. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2473. * @param current current value
  2474. * @param target target value
  2475. * @param maxDelta max distance to move
  2476. * @returns resulting angle
  2477. */
  2478. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2479. /**
  2480. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2481. * @param start start value
  2482. * @param end target value
  2483. * @param amount amount to lerp between
  2484. * @returns the lerped value
  2485. */
  2486. static Lerp(start: number, end: number, amount: number): number;
  2487. /**
  2488. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2489. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2490. * @param start start value
  2491. * @param end target value
  2492. * @param amount amount to lerp between
  2493. * @returns the lerped value
  2494. */
  2495. static LerpAngle(start: number, end: number, amount: number): number;
  2496. /**
  2497. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2498. * @param a start value
  2499. * @param b target value
  2500. * @param value value between a and b
  2501. * @returns the inverseLerp value
  2502. */
  2503. static InverseLerp(a: number, b: number, value: number): number;
  2504. /**
  2505. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2506. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2507. * @param value1 spline value
  2508. * @param tangent1 spline value
  2509. * @param value2 spline value
  2510. * @param tangent2 spline value
  2511. * @param amount input value
  2512. * @returns hermite result
  2513. */
  2514. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2515. /**
  2516. * Returns a random float number between and min and max values
  2517. * @param min min value of random
  2518. * @param max max value of random
  2519. * @returns random value
  2520. */
  2521. static RandomRange(min: number, max: number): number;
  2522. /**
  2523. * This function returns percentage of a number in a given range.
  2524. *
  2525. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2526. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2527. * @param number to convert to percentage
  2528. * @param min min range
  2529. * @param max max range
  2530. * @returns the percentage
  2531. */
  2532. static RangeToPercent(number: number, min: number, max: number): number;
  2533. /**
  2534. * This function returns number that corresponds to the percentage in a given range.
  2535. *
  2536. * PercentToRange(0.34,0,100) will return 34.
  2537. * @param percent to convert to number
  2538. * @param min min range
  2539. * @param max max range
  2540. * @returns the number
  2541. */
  2542. static PercentToRange(percent: number, min: number, max: number): number;
  2543. /**
  2544. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2545. * @param angle The angle to normalize in radian.
  2546. * @return The converted angle.
  2547. */
  2548. static NormalizeRadians(angle: number): number;
  2549. }
  2550. }
  2551. declare module "babylonjs/Maths/math.constants" {
  2552. /**
  2553. * Constant used to convert a value to gamma space
  2554. * @ignorenaming
  2555. */
  2556. export const ToGammaSpace: number;
  2557. /**
  2558. * Constant used to convert a value to linear space
  2559. * @ignorenaming
  2560. */
  2561. export const ToLinearSpace = 2.2;
  2562. /**
  2563. * Constant used to define the minimal number value in Babylon.js
  2564. * @ignorenaming
  2565. */
  2566. let Epsilon: number;
  2567. export { Epsilon };
  2568. }
  2569. declare module "babylonjs/Maths/math.viewport" {
  2570. /**
  2571. * Class used to represent a viewport on screen
  2572. */
  2573. export class Viewport {
  2574. /** viewport left coordinate */
  2575. x: number;
  2576. /** viewport top coordinate */
  2577. y: number;
  2578. /**viewport width */
  2579. width: number;
  2580. /** viewport height */
  2581. height: number;
  2582. /**
  2583. * Creates a Viewport object located at (x, y) and sized (width, height)
  2584. * @param x defines viewport left coordinate
  2585. * @param y defines viewport top coordinate
  2586. * @param width defines the viewport width
  2587. * @param height defines the viewport height
  2588. */
  2589. constructor(
  2590. /** viewport left coordinate */
  2591. x: number,
  2592. /** viewport top coordinate */
  2593. y: number,
  2594. /**viewport width */
  2595. width: number,
  2596. /** viewport height */
  2597. height: number);
  2598. /**
  2599. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2600. * @param renderWidth defines the rendering width
  2601. * @param renderHeight defines the rendering height
  2602. * @returns a new Viewport
  2603. */
  2604. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2605. /**
  2606. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2607. * @param renderWidth defines the rendering width
  2608. * @param renderHeight defines the rendering height
  2609. * @param ref defines the target viewport
  2610. * @returns the current viewport
  2611. */
  2612. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2613. /**
  2614. * Returns a new Viewport copied from the current one
  2615. * @returns a new Viewport
  2616. */
  2617. clone(): Viewport;
  2618. }
  2619. }
  2620. declare module "babylonjs/Misc/arrayTools" {
  2621. /**
  2622. * Class containing a set of static utilities functions for arrays.
  2623. */
  2624. export class ArrayTools {
  2625. /**
  2626. * Returns an array of the given size filled with element built from the given constructor and the parameters
  2627. * @param size the number of element to construct and put in the array
  2628. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2629. * @returns a new array filled with new objects
  2630. */
  2631. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2632. }
  2633. }
  2634. declare module "babylonjs/Maths/math.plane" {
  2635. import { DeepImmutable } from "babylonjs/types";
  2636. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  2637. /**
  2638. * Represents a plane by the equation ax + by + cz + d = 0
  2639. */
  2640. export class Plane {
  2641. private static _TmpMatrix;
  2642. /**
  2643. * Normal of the plane (a,b,c)
  2644. */
  2645. normal: Vector3;
  2646. /**
  2647. * d component of the plane
  2648. */
  2649. d: number;
  2650. /**
  2651. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2652. * @param a a component of the plane
  2653. * @param b b component of the plane
  2654. * @param c c component of the plane
  2655. * @param d d component of the plane
  2656. */
  2657. constructor(a: number, b: number, c: number, d: number);
  2658. /**
  2659. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2660. */
  2661. asArray(): number[];
  2662. /**
  2663. * @returns a new plane copied from the current Plane.
  2664. */
  2665. clone(): Plane;
  2666. /**
  2667. * @returns the string "Plane".
  2668. */
  2669. getClassName(): string;
  2670. /**
  2671. * @returns the Plane hash code.
  2672. */
  2673. getHashCode(): number;
  2674. /**
  2675. * Normalize the current Plane in place.
  2676. * @returns the updated Plane.
  2677. */
  2678. normalize(): Plane;
  2679. /**
  2680. * Applies a transformation the plane and returns the result
  2681. * @param transformation the transformation matrix to be applied to the plane
  2682. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2683. */
  2684. transform(transformation: DeepImmutable<Matrix>): Plane;
  2685. /**
  2686. * Compute the dot product between the point and the plane normal
  2687. * @param point point to calculate the dot product with
  2688. * @returns the dot product (float) of the point coordinates and the plane normal.
  2689. */
  2690. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Updates the current Plane from the plane defined by the three given points.
  2693. * @param point1 one of the points used to contruct the plane
  2694. * @param point2 one of the points used to contruct the plane
  2695. * @param point3 one of the points used to contruct the plane
  2696. * @returns the updated Plane.
  2697. */
  2698. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2699. /**
  2700. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2701. * Note that for this function to work as expected you should make sure that:
  2702. * - direction and the plane normal are normalized
  2703. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2704. * @param direction the direction to check if the plane is facing
  2705. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2706. * @returns True if the plane is facing the given direction
  2707. */
  2708. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2709. /**
  2710. * Calculates the distance to a point
  2711. * @param point point to calculate distance to
  2712. * @returns the signed distance (float) from the given point to the Plane.
  2713. */
  2714. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2715. /**
  2716. * Creates a plane from an array
  2717. * @param array the array to create a plane from
  2718. * @returns a new Plane from the given array.
  2719. */
  2720. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2721. /**
  2722. * Creates a plane from three points
  2723. * @param point1 point used to create the plane
  2724. * @param point2 point used to create the plane
  2725. * @param point3 point used to create the plane
  2726. * @returns a new Plane defined by the three given points.
  2727. */
  2728. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2729. /**
  2730. * Creates a plane from an origin point and a normal
  2731. * @param origin origin of the plane to be constructed
  2732. * @param normal normal of the plane to be constructed
  2733. * @returns a new Plane the normal vector to this plane at the given origin point.
  2734. * Note : the vector "normal" is updated because normalized.
  2735. */
  2736. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2737. /**
  2738. * Calculates the distance from a plane and a point
  2739. * @param origin origin of the plane to be constructed
  2740. * @param normal normal of the plane to be constructed
  2741. * @param point point to calculate distance to
  2742. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2743. */
  2744. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2745. }
  2746. }
  2747. declare module "babylonjs/Engines/performanceConfigurator" {
  2748. /** @hidden */
  2749. export class PerformanceConfigurator {
  2750. /** @hidden */
  2751. static MatrixUse64Bits: boolean;
  2752. /** @hidden */
  2753. static MatrixTrackPrecisionChange: boolean;
  2754. /** @hidden */
  2755. static MatrixCurrentType: any;
  2756. /** @hidden */
  2757. static MatrixTrackedMatrices: Array<any> | null;
  2758. /** @hidden */
  2759. static SetMatrixPrecision(use64bits: boolean): void;
  2760. }
  2761. }
  2762. declare module "babylonjs/Maths/math.vector" {
  2763. import { Viewport } from "babylonjs/Maths/math.viewport";
  2764. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2765. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2766. import { Plane } from "babylonjs/Maths/math.plane";
  2767. /**
  2768. * Class representing a vector containing 2 coordinates
  2769. */
  2770. export class Vector2 {
  2771. /** defines the first coordinate */
  2772. x: number;
  2773. /** defines the second coordinate */
  2774. y: number;
  2775. /**
  2776. * Creates a new Vector2 from the given x and y coordinates
  2777. * @param x defines the first coordinate
  2778. * @param y defines the second coordinate
  2779. */
  2780. constructor(
  2781. /** defines the first coordinate */
  2782. x?: number,
  2783. /** defines the second coordinate */
  2784. y?: number);
  2785. /**
  2786. * Gets a string with the Vector2 coordinates
  2787. * @returns a string with the Vector2 coordinates
  2788. */
  2789. toString(): string;
  2790. /**
  2791. * Gets class name
  2792. * @returns the string "Vector2"
  2793. */
  2794. getClassName(): string;
  2795. /**
  2796. * Gets current vector hash code
  2797. * @returns the Vector2 hash code as a number
  2798. */
  2799. getHashCode(): number;
  2800. /**
  2801. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2802. * @param array defines the source array
  2803. * @param index defines the offset in source array
  2804. * @returns the current Vector2
  2805. */
  2806. toArray(array: FloatArray, index?: number): Vector2;
  2807. /**
  2808. * Update the current vector from an array
  2809. * @param array defines the destination array
  2810. * @param index defines the offset in the destination array
  2811. * @returns the current Vector3
  2812. */
  2813. fromArray(array: FloatArray, index?: number): Vector2;
  2814. /**
  2815. * Copy the current vector to an array
  2816. * @returns a new array with 2 elements: the Vector2 coordinates.
  2817. */
  2818. asArray(): number[];
  2819. /**
  2820. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2821. * @param source defines the source Vector2
  2822. * @returns the current updated Vector2
  2823. */
  2824. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2825. /**
  2826. * Sets the Vector2 coordinates with the given floats
  2827. * @param x defines the first coordinate
  2828. * @param y defines the second coordinate
  2829. * @returns the current updated Vector2
  2830. */
  2831. copyFromFloats(x: number, y: number): Vector2;
  2832. /**
  2833. * Sets the Vector2 coordinates with the given floats
  2834. * @param x defines the first coordinate
  2835. * @param y defines the second coordinate
  2836. * @returns the current updated Vector2
  2837. */
  2838. set(x: number, y: number): Vector2;
  2839. /**
  2840. * Add another vector with the current one
  2841. * @param otherVector defines the other vector
  2842. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2843. */
  2844. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2845. /**
  2846. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2847. * @param otherVector defines the other vector
  2848. * @param result defines the target vector
  2849. * @returns the unmodified current Vector2
  2850. */
  2851. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2852. /**
  2853. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2854. * @param otherVector defines the other vector
  2855. * @returns the current updated Vector2
  2856. */
  2857. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2858. /**
  2859. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2860. * @param otherVector defines the other vector
  2861. * @returns a new Vector2
  2862. */
  2863. addVector3(otherVector: Vector3): Vector2;
  2864. /**
  2865. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2866. * @param otherVector defines the other vector
  2867. * @returns a new Vector2
  2868. */
  2869. subtract(otherVector: Vector2): Vector2;
  2870. /**
  2871. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2872. * @param otherVector defines the other vector
  2873. * @param result defines the target vector
  2874. * @returns the unmodified current Vector2
  2875. */
  2876. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2877. /**
  2878. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2879. * @param otherVector defines the other vector
  2880. * @returns the current updated Vector2
  2881. */
  2882. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2883. /**
  2884. * Multiplies in place the current Vector2 coordinates by the given ones
  2885. * @param otherVector defines the other vector
  2886. * @returns the current updated Vector2
  2887. */
  2888. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2889. /**
  2890. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2891. * @param otherVector defines the other vector
  2892. * @returns a new Vector2
  2893. */
  2894. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2895. /**
  2896. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2897. * @param otherVector defines the other vector
  2898. * @param result defines the target vector
  2899. * @returns the unmodified current Vector2
  2900. */
  2901. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2902. /**
  2903. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2904. * @param x defines the first coordinate
  2905. * @param y defines the second coordinate
  2906. * @returns a new Vector2
  2907. */
  2908. multiplyByFloats(x: number, y: number): Vector2;
  2909. /**
  2910. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2911. * @param otherVector defines the other vector
  2912. * @returns a new Vector2
  2913. */
  2914. divide(otherVector: Vector2): Vector2;
  2915. /**
  2916. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2917. * @param otherVector defines the other vector
  2918. * @param result defines the target vector
  2919. * @returns the unmodified current Vector2
  2920. */
  2921. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2922. /**
  2923. * Divides the current Vector2 coordinates by the given ones
  2924. * @param otherVector defines the other vector
  2925. * @returns the current updated Vector2
  2926. */
  2927. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2928. /**
  2929. * Gets a new Vector2 with current Vector2 negated coordinates
  2930. * @returns a new Vector2
  2931. */
  2932. negate(): Vector2;
  2933. /**
  2934. * Negate this vector in place
  2935. * @returns this
  2936. */
  2937. negateInPlace(): Vector2;
  2938. /**
  2939. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2940. * @param result defines the Vector3 object where to store the result
  2941. * @returns the current Vector2
  2942. */
  2943. negateToRef(result: Vector2): Vector2;
  2944. /**
  2945. * Multiply the Vector2 coordinates by scale
  2946. * @param scale defines the scaling factor
  2947. * @returns the current updated Vector2
  2948. */
  2949. scaleInPlace(scale: number): Vector2;
  2950. /**
  2951. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2952. * @param scale defines the scaling factor
  2953. * @returns a new Vector2
  2954. */
  2955. scale(scale: number): Vector2;
  2956. /**
  2957. * Scale the current Vector2 values by a factor to a given Vector2
  2958. * @param scale defines the scale factor
  2959. * @param result defines the Vector2 object where to store the result
  2960. * @returns the unmodified current Vector2
  2961. */
  2962. scaleToRef(scale: number, result: Vector2): Vector2;
  2963. /**
  2964. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2965. * @param scale defines the scale factor
  2966. * @param result defines the Vector2 object where to store the result
  2967. * @returns the unmodified current Vector2
  2968. */
  2969. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2970. /**
  2971. * Gets a boolean if two vectors are equals
  2972. * @param otherVector defines the other vector
  2973. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2974. */
  2975. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2976. /**
  2977. * Gets a boolean if two vectors are equals (using an epsilon value)
  2978. * @param otherVector defines the other vector
  2979. * @param epsilon defines the minimal distance to consider equality
  2980. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2981. */
  2982. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2983. /**
  2984. * Gets a new Vector2 from current Vector2 floored values
  2985. * @returns a new Vector2
  2986. */
  2987. floor(): Vector2;
  2988. /**
  2989. * Gets a new Vector2 from current Vector2 floored values
  2990. * @returns a new Vector2
  2991. */
  2992. fract(): Vector2;
  2993. /**
  2994. * Gets the length of the vector
  2995. * @returns the vector length (float)
  2996. */
  2997. length(): number;
  2998. /**
  2999. * Gets the vector squared length
  3000. * @returns the vector squared length (float)
  3001. */
  3002. lengthSquared(): number;
  3003. /**
  3004. * Normalize the vector
  3005. * @returns the current updated Vector2
  3006. */
  3007. normalize(): Vector2;
  3008. /**
  3009. * Gets a new Vector2 copied from the Vector2
  3010. * @returns a new Vector2
  3011. */
  3012. clone(): Vector2;
  3013. /**
  3014. * Gets a new Vector2(0, 0)
  3015. * @returns a new Vector2
  3016. */
  3017. static Zero(): Vector2;
  3018. /**
  3019. * Gets a new Vector2(1, 1)
  3020. * @returns a new Vector2
  3021. */
  3022. static One(): Vector2;
  3023. /**
  3024. * Gets a new Vector2 set from the given index element of the given array
  3025. * @param array defines the data source
  3026. * @param offset defines the offset in the data source
  3027. * @returns a new Vector2
  3028. */
  3029. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  3030. /**
  3031. * Sets "result" from the given index element of the given array
  3032. * @param array defines the data source
  3033. * @param offset defines the offset in the data source
  3034. * @param result defines the target vector
  3035. */
  3036. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  3037. /**
  3038. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  3039. * @param value1 defines 1st point of control
  3040. * @param value2 defines 2nd point of control
  3041. * @param value3 defines 3rd point of control
  3042. * @param value4 defines 4th point of control
  3043. * @param amount defines the interpolation factor
  3044. * @returns a new Vector2
  3045. */
  3046. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  3047. /**
  3048. * 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".
  3049. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3050. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3051. * @param value defines the value to clamp
  3052. * @param min defines the lower limit
  3053. * @param max defines the upper limit
  3054. * @returns a new Vector2
  3055. */
  3056. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3057. /**
  3058. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3059. * @param value1 defines the 1st control point
  3060. * @param tangent1 defines the outgoing tangent
  3061. * @param value2 defines the 2nd control point
  3062. * @param tangent2 defines the incoming tangent
  3063. * @param amount defines the interpolation factor
  3064. * @returns a new Vector2
  3065. */
  3066. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3067. /**
  3068. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3069. * @param start defines the start vector
  3070. * @param end defines the end vector
  3071. * @param amount defines the interpolation factor
  3072. * @returns a new Vector2
  3073. */
  3074. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3075. /**
  3076. * Gets the dot product of the vector "left" and the vector "right"
  3077. * @param left defines first vector
  3078. * @param right defines second vector
  3079. * @returns the dot product (float)
  3080. */
  3081. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3082. /**
  3083. * Returns a new Vector2 equal to the normalized given vector
  3084. * @param vector defines the vector to normalize
  3085. * @returns a new Vector2
  3086. */
  3087. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3088. /**
  3089. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3090. * @param left defines 1st vector
  3091. * @param right defines 2nd vector
  3092. * @returns a new Vector2
  3093. */
  3094. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3095. /**
  3096. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3097. * @param left defines 1st vector
  3098. * @param right defines 2nd vector
  3099. * @returns a new Vector2
  3100. */
  3101. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3102. /**
  3103. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3104. * @param vector defines the vector to transform
  3105. * @param transformation defines the matrix to apply
  3106. * @returns a new Vector2
  3107. */
  3108. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3109. /**
  3110. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3111. * @param vector defines the vector to transform
  3112. * @param transformation defines the matrix to apply
  3113. * @param result defines the target vector
  3114. */
  3115. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3116. /**
  3117. * Determines if a given vector is included in a triangle
  3118. * @param p defines the vector to test
  3119. * @param p0 defines 1st triangle point
  3120. * @param p1 defines 2nd triangle point
  3121. * @param p2 defines 3rd triangle point
  3122. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3123. */
  3124. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3125. /**
  3126. * Gets the distance between the vectors "value1" and "value2"
  3127. * @param value1 defines first vector
  3128. * @param value2 defines second vector
  3129. * @returns the distance between vectors
  3130. */
  3131. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3132. /**
  3133. * Returns the squared distance between the vectors "value1" and "value2"
  3134. * @param value1 defines first vector
  3135. * @param value2 defines second vector
  3136. * @returns the squared distance between vectors
  3137. */
  3138. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3139. /**
  3140. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3141. * @param value1 defines first vector
  3142. * @param value2 defines second vector
  3143. * @returns a new Vector2
  3144. */
  3145. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3146. /**
  3147. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3148. * @param value1 defines first vector
  3149. * @param value2 defines second vector
  3150. * @param ref defines third vector
  3151. * @returns ref
  3152. */
  3153. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3154. /**
  3155. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3156. * @param p defines the middle point
  3157. * @param segA defines one point of the segment
  3158. * @param segB defines the other point of the segment
  3159. * @returns the shortest distance
  3160. */
  3161. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3162. }
  3163. /**
  3164. * Class used to store (x,y,z) vector representation
  3165. * A Vector3 is the main object used in 3D geometry
  3166. * It can represent etiher the coordinates of a point the space, either a direction
  3167. * Reminder: js uses a left handed forward facing system
  3168. */
  3169. export class Vector3 {
  3170. private static _UpReadOnly;
  3171. private static _ZeroReadOnly;
  3172. /** @hidden */
  3173. _x: number;
  3174. /** @hidden */
  3175. _y: number;
  3176. /** @hidden */
  3177. _z: number;
  3178. /** @hidden */
  3179. _isDirty: boolean;
  3180. /** Gets or sets the x coordinate */
  3181. get x(): number;
  3182. set x(value: number);
  3183. /** Gets or sets the y coordinate */
  3184. get y(): number;
  3185. set y(value: number);
  3186. /** Gets or sets the z coordinate */
  3187. get z(): number;
  3188. set z(value: number);
  3189. /**
  3190. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3191. * @param x defines the first coordinates (on X axis)
  3192. * @param y defines the second coordinates (on Y axis)
  3193. * @param z defines the third coordinates (on Z axis)
  3194. */
  3195. constructor(x?: number, y?: number, z?: number);
  3196. /**
  3197. * Creates a string representation of the Vector3
  3198. * @returns a string with the Vector3 coordinates.
  3199. */
  3200. toString(): string;
  3201. /**
  3202. * Gets the class name
  3203. * @returns the string "Vector3"
  3204. */
  3205. getClassName(): string;
  3206. /**
  3207. * Creates the Vector3 hash code
  3208. * @returns a number which tends to be unique between Vector3 instances
  3209. */
  3210. getHashCode(): number;
  3211. /**
  3212. * Creates an array containing three elements : the coordinates of the Vector3
  3213. * @returns a new array of numbers
  3214. */
  3215. asArray(): number[];
  3216. /**
  3217. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3218. * @param array defines the destination array
  3219. * @param index defines the offset in the destination array
  3220. * @returns the current Vector3
  3221. */
  3222. toArray(array: FloatArray, index?: number): Vector3;
  3223. /**
  3224. * Update the current vector from an array
  3225. * @param array defines the destination array
  3226. * @param index defines the offset in the destination array
  3227. * @returns the current Vector3
  3228. */
  3229. fromArray(array: FloatArray, index?: number): Vector3;
  3230. /**
  3231. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3232. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3233. */
  3234. toQuaternion(): Quaternion;
  3235. /**
  3236. * Adds the given vector to the current Vector3
  3237. * @param otherVector defines the second operand
  3238. * @returns the current updated Vector3
  3239. */
  3240. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3241. /**
  3242. * Adds the given coordinates to the current Vector3
  3243. * @param x defines the x coordinate of the operand
  3244. * @param y defines the y coordinate of the operand
  3245. * @param z defines the z coordinate of the operand
  3246. * @returns the current updated Vector3
  3247. */
  3248. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3249. /**
  3250. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3251. * @param otherVector defines the second operand
  3252. * @returns the resulting Vector3
  3253. */
  3254. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3255. /**
  3256. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3257. * @param otherVector defines the second operand
  3258. * @param result defines the Vector3 object where to store the result
  3259. * @returns the current Vector3
  3260. */
  3261. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3262. /**
  3263. * Subtract the given vector from the current Vector3
  3264. * @param otherVector defines the second operand
  3265. * @returns the current updated Vector3
  3266. */
  3267. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3268. /**
  3269. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3270. * @param otherVector defines the second operand
  3271. * @returns the resulting Vector3
  3272. */
  3273. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3274. /**
  3275. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3276. * @param otherVector defines the second operand
  3277. * @param result defines the Vector3 object where to store the result
  3278. * @returns the current Vector3
  3279. */
  3280. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3281. /**
  3282. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3283. * @param x defines the x coordinate of the operand
  3284. * @param y defines the y coordinate of the operand
  3285. * @param z defines the z coordinate of the operand
  3286. * @returns the resulting Vector3
  3287. */
  3288. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3289. /**
  3290. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3291. * @param x defines the x coordinate of the operand
  3292. * @param y defines the y coordinate of the operand
  3293. * @param z defines the z coordinate of the operand
  3294. * @param result defines the Vector3 object where to store the result
  3295. * @returns the current Vector3
  3296. */
  3297. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3298. /**
  3299. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3300. * @returns a new Vector3
  3301. */
  3302. negate(): Vector3;
  3303. /**
  3304. * Negate this vector in place
  3305. * @returns this
  3306. */
  3307. negateInPlace(): Vector3;
  3308. /**
  3309. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3310. * @param result defines the Vector3 object where to store the result
  3311. * @returns the current Vector3
  3312. */
  3313. negateToRef(result: Vector3): Vector3;
  3314. /**
  3315. * Multiplies the Vector3 coordinates by the float "scale"
  3316. * @param scale defines the multiplier factor
  3317. * @returns the current updated Vector3
  3318. */
  3319. scaleInPlace(scale: number): Vector3;
  3320. /**
  3321. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3322. * @param scale defines the multiplier factor
  3323. * @returns a new Vector3
  3324. */
  3325. scale(scale: number): Vector3;
  3326. /**
  3327. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3328. * @param scale defines the multiplier factor
  3329. * @param result defines the Vector3 object where to store the result
  3330. * @returns the current Vector3
  3331. */
  3332. scaleToRef(scale: number, result: Vector3): Vector3;
  3333. /**
  3334. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3335. * @param scale defines the scale factor
  3336. * @param result defines the Vector3 object where to store the result
  3337. * @returns the unmodified current Vector3
  3338. */
  3339. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3340. /**
  3341. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3342. * @param origin defines the origin of the projection ray
  3343. * @param plane defines the plane to project to
  3344. * @returns the projected vector3
  3345. */
  3346. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3347. /**
  3348. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3349. * @param origin defines the origin of the projection ray
  3350. * @param plane defines the plane to project to
  3351. * @param result defines the Vector3 where to store the result
  3352. */
  3353. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3354. /**
  3355. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3356. * @param otherVector defines the second operand
  3357. * @returns true if both vectors are equals
  3358. */
  3359. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3360. /**
  3361. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3362. * @param otherVector defines the second operand
  3363. * @param epsilon defines the minimal distance to define values as equals
  3364. * @returns true if both vectors are distant less than epsilon
  3365. */
  3366. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3367. /**
  3368. * Returns true if the current Vector3 coordinates equals the given floats
  3369. * @param x defines the x coordinate of the operand
  3370. * @param y defines the y coordinate of the operand
  3371. * @param z defines the z coordinate of the operand
  3372. * @returns true if both vectors are equals
  3373. */
  3374. equalsToFloats(x: number, y: number, z: number): boolean;
  3375. /**
  3376. * Multiplies the current Vector3 coordinates by the given ones
  3377. * @param otherVector defines the second operand
  3378. * @returns the current updated Vector3
  3379. */
  3380. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3381. /**
  3382. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3383. * @param otherVector defines the second operand
  3384. * @returns the new Vector3
  3385. */
  3386. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3387. /**
  3388. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3389. * @param otherVector defines the second operand
  3390. * @param result defines the Vector3 object where to store the result
  3391. * @returns the current Vector3
  3392. */
  3393. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3394. /**
  3395. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3396. * @param x defines the x coordinate of the operand
  3397. * @param y defines the y coordinate of the operand
  3398. * @param z defines the z coordinate of the operand
  3399. * @returns the new Vector3
  3400. */
  3401. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3402. /**
  3403. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3404. * @param otherVector defines the second operand
  3405. * @returns the new Vector3
  3406. */
  3407. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3408. /**
  3409. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3410. * @param otherVector defines the second operand
  3411. * @param result defines the Vector3 object where to store the result
  3412. * @returns the current Vector3
  3413. */
  3414. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3415. /**
  3416. * Divides the current Vector3 coordinates by the given ones.
  3417. * @param otherVector defines the second operand
  3418. * @returns the current updated Vector3
  3419. */
  3420. divideInPlace(otherVector: Vector3): Vector3;
  3421. /**
  3422. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3423. * @param other defines the second operand
  3424. * @returns the current updated Vector3
  3425. */
  3426. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3427. /**
  3428. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3429. * @param other defines the second operand
  3430. * @returns the current updated Vector3
  3431. */
  3432. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3433. /**
  3434. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3435. * @param x defines the x coordinate of the operand
  3436. * @param y defines the y coordinate of the operand
  3437. * @param z defines the z coordinate of the operand
  3438. * @returns the current updated Vector3
  3439. */
  3440. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3441. /**
  3442. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3443. * @param x defines the x coordinate of the operand
  3444. * @param y defines the y coordinate of the operand
  3445. * @param z defines the z coordinate of the operand
  3446. * @returns the current updated Vector3
  3447. */
  3448. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3449. /**
  3450. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3451. * Check if is non uniform within a certain amount of decimal places to account for this
  3452. * @param epsilon the amount the values can differ
  3453. * @returns if the the vector is non uniform to a certain number of decimal places
  3454. */
  3455. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3456. /**
  3457. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3458. */
  3459. get isNonUniform(): boolean;
  3460. /**
  3461. * Gets a new Vector3 from current Vector3 floored values
  3462. * @returns a new Vector3
  3463. */
  3464. floor(): Vector3;
  3465. /**
  3466. * Gets a new Vector3 from current Vector3 floored values
  3467. * @returns a new Vector3
  3468. */
  3469. fract(): Vector3;
  3470. /**
  3471. * Gets the length of the Vector3
  3472. * @returns the length of the Vector3
  3473. */
  3474. length(): number;
  3475. /**
  3476. * Gets the squared length of the Vector3
  3477. * @returns squared length of the Vector3
  3478. */
  3479. lengthSquared(): number;
  3480. /**
  3481. * Normalize the current Vector3.
  3482. * Please note that this is an in place operation.
  3483. * @returns the current updated Vector3
  3484. */
  3485. normalize(): Vector3;
  3486. /**
  3487. * Reorders the x y z properties of the vector in place
  3488. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3489. * @returns the current updated vector
  3490. */
  3491. reorderInPlace(order: string): this;
  3492. /**
  3493. * Rotates the vector around 0,0,0 by a quaternion
  3494. * @param quaternion the rotation quaternion
  3495. * @param result vector to store the result
  3496. * @returns the resulting vector
  3497. */
  3498. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3499. /**
  3500. * Rotates a vector around a given point
  3501. * @param quaternion the rotation quaternion
  3502. * @param point the point to rotate around
  3503. * @param result vector to store the result
  3504. * @returns the resulting vector
  3505. */
  3506. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3507. /**
  3508. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3509. * The cross product is then orthogonal to both current and "other"
  3510. * @param other defines the right operand
  3511. * @returns the cross product
  3512. */
  3513. cross(other: Vector3): Vector3;
  3514. /**
  3515. * Normalize the current Vector3 with the given input length.
  3516. * Please note that this is an in place operation.
  3517. * @param len the length of the vector
  3518. * @returns the current updated Vector3
  3519. */
  3520. normalizeFromLength(len: number): Vector3;
  3521. /**
  3522. * Normalize the current Vector3 to a new vector
  3523. * @returns the new Vector3
  3524. */
  3525. normalizeToNew(): Vector3;
  3526. /**
  3527. * Normalize the current Vector3 to the reference
  3528. * @param reference define the Vector3 to update
  3529. * @returns the updated Vector3
  3530. */
  3531. normalizeToRef(reference: Vector3): Vector3;
  3532. /**
  3533. * Creates a new Vector3 copied from the current Vector3
  3534. * @returns the new Vector3
  3535. */
  3536. clone(): Vector3;
  3537. /**
  3538. * Copies the given vector coordinates to the current Vector3 ones
  3539. * @param source defines the source Vector3
  3540. * @returns the current updated Vector3
  3541. */
  3542. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3543. /**
  3544. * Copies the given floats to the current Vector3 coordinates
  3545. * @param x defines the x coordinate of the operand
  3546. * @param y defines the y coordinate of the operand
  3547. * @param z defines the z coordinate of the operand
  3548. * @returns the current updated Vector3
  3549. */
  3550. copyFromFloats(x: number, y: number, z: number): Vector3;
  3551. /**
  3552. * Copies the given floats to the current Vector3 coordinates
  3553. * @param x defines the x coordinate of the operand
  3554. * @param y defines the y coordinate of the operand
  3555. * @param z defines the z coordinate of the operand
  3556. * @returns the current updated Vector3
  3557. */
  3558. set(x: number, y: number, z: number): Vector3;
  3559. /**
  3560. * Copies the given float to the current Vector3 coordinates
  3561. * @param v defines the x, y and z coordinates of the operand
  3562. * @returns the current updated Vector3
  3563. */
  3564. setAll(v: number): Vector3;
  3565. /**
  3566. * Get the clip factor between two vectors
  3567. * @param vector0 defines the first operand
  3568. * @param vector1 defines the second operand
  3569. * @param axis defines the axis to use
  3570. * @param size defines the size along the axis
  3571. * @returns the clip factor
  3572. */
  3573. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3574. /**
  3575. * Get angle between two vectors
  3576. * @param vector0 angle between vector0 and vector1
  3577. * @param vector1 angle between vector0 and vector1
  3578. * @param normal direction of the normal
  3579. * @return the angle between vector0 and vector1
  3580. */
  3581. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3582. /**
  3583. * Returns a new Vector3 set from the index "offset" of the given array
  3584. * @param array defines the source array
  3585. * @param offset defines the offset in the source array
  3586. * @returns the new Vector3
  3587. */
  3588. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3589. /**
  3590. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3591. * @param array defines the source array
  3592. * @param offset defines the offset in the source array
  3593. * @returns the new Vector3
  3594. * @deprecated Please use FromArray instead.
  3595. */
  3596. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3597. /**
  3598. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3599. * @param array defines the source array
  3600. * @param offset defines the offset in the source array
  3601. * @param result defines the Vector3 where to store the result
  3602. */
  3603. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3604. /**
  3605. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3606. * @param array defines the source array
  3607. * @param offset defines the offset in the source array
  3608. * @param result defines the Vector3 where to store the result
  3609. * @deprecated Please use FromArrayToRef instead.
  3610. */
  3611. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3612. /**
  3613. * Sets the given vector "result" with the given floats.
  3614. * @param x defines the x coordinate of the source
  3615. * @param y defines the y coordinate of the source
  3616. * @param z defines the z coordinate of the source
  3617. * @param result defines the Vector3 where to store the result
  3618. */
  3619. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3620. /**
  3621. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3622. * @returns a new empty Vector3
  3623. */
  3624. static Zero(): Vector3;
  3625. /**
  3626. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3627. * @returns a new unit Vector3
  3628. */
  3629. static One(): Vector3;
  3630. /**
  3631. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3632. * @returns a new up Vector3
  3633. */
  3634. static Up(): Vector3;
  3635. /**
  3636. * Gets a up Vector3 that must not be updated
  3637. */
  3638. static get UpReadOnly(): DeepImmutable<Vector3>;
  3639. /**
  3640. * Gets a zero Vector3 that must not be updated
  3641. */
  3642. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3643. /**
  3644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3645. * @returns a new down Vector3
  3646. */
  3647. static Down(): Vector3;
  3648. /**
  3649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3650. * @param rightHandedSystem is the scene right-handed (negative z)
  3651. * @returns a new forward Vector3
  3652. */
  3653. static Forward(rightHandedSystem?: boolean): Vector3;
  3654. /**
  3655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3656. * @param rightHandedSystem is the scene right-handed (negative-z)
  3657. * @returns a new forward Vector3
  3658. */
  3659. static Backward(rightHandedSystem?: boolean): Vector3;
  3660. /**
  3661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3662. * @returns a new right Vector3
  3663. */
  3664. static Right(): Vector3;
  3665. /**
  3666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3667. * @returns a new left Vector3
  3668. */
  3669. static Left(): Vector3;
  3670. /**
  3671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3673. * @param vector defines the Vector3 to transform
  3674. * @param transformation defines the transformation matrix
  3675. * @returns the transformed Vector3
  3676. */
  3677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3678. /**
  3679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3681. * @param vector defines the Vector3 to transform
  3682. * @param transformation defines the transformation matrix
  3683. * @param result defines the Vector3 where to store the result
  3684. */
  3685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3686. /**
  3687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3688. * This method computes tranformed coordinates only, not transformed direction vectors
  3689. * @param x define the x coordinate of the source vector
  3690. * @param y define the y coordinate of the source vector
  3691. * @param z define the z coordinate of the source vector
  3692. * @param transformation defines the transformation matrix
  3693. * @param result defines the Vector3 where to store the result
  3694. */
  3695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3696. /**
  3697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3699. * @param vector defines the Vector3 to transform
  3700. * @param transformation defines the transformation matrix
  3701. * @returns the new Vector3
  3702. */
  3703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3704. /**
  3705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3707. * @param vector defines the Vector3 to transform
  3708. * @param transformation defines the transformation matrix
  3709. * @param result defines the Vector3 where to store the result
  3710. */
  3711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3712. /**
  3713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3715. * @param x define the x coordinate of the source vector
  3716. * @param y define the y coordinate of the source vector
  3717. * @param z define the z coordinate of the source vector
  3718. * @param transformation defines the transformation matrix
  3719. * @param result defines the Vector3 where to store the result
  3720. */
  3721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3722. /**
  3723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3724. * @param value1 defines the first control point
  3725. * @param value2 defines the second control point
  3726. * @param value3 defines the third control point
  3727. * @param value4 defines the fourth control point
  3728. * @param amount defines the amount on the spline to use
  3729. * @returns the new Vector3
  3730. */
  3731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3732. /**
  3733. * 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"
  3734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3736. * @param value defines the current value
  3737. * @param min defines the lower range value
  3738. * @param max defines the upper range value
  3739. * @returns the new Vector3
  3740. */
  3741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3742. /**
  3743. * 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"
  3744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3746. * @param value defines the current value
  3747. * @param min defines the lower range value
  3748. * @param max defines the upper range value
  3749. * @param result defines the Vector3 where to store the result
  3750. */
  3751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3752. /**
  3753. * Checks if a given vector is inside a specific range
  3754. * @param v defines the vector to test
  3755. * @param min defines the minimum range
  3756. * @param max defines the maximum range
  3757. */
  3758. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3759. /**
  3760. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3761. * @param value1 defines the first control point
  3762. * @param tangent1 defines the first tangent vector
  3763. * @param value2 defines the second control point
  3764. * @param tangent2 defines the second tangent vector
  3765. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3766. * @returns the new Vector3
  3767. */
  3768. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3769. /**
  3770. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3771. * @param start defines the start value
  3772. * @param end defines the end value
  3773. * @param amount max defines amount between both (between 0 and 1)
  3774. * @returns the new Vector3
  3775. */
  3776. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3777. /**
  3778. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3779. * @param start defines the start value
  3780. * @param end defines the end value
  3781. * @param amount max defines amount between both (between 0 and 1)
  3782. * @param result defines the Vector3 where to store the result
  3783. */
  3784. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3785. /**
  3786. * Returns the dot product (float) between the vectors "left" and "right"
  3787. * @param left defines the left operand
  3788. * @param right defines the right operand
  3789. * @returns the dot product
  3790. */
  3791. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3792. /**
  3793. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3794. * The cross product is then orthogonal to both "left" and "right"
  3795. * @param left defines the left operand
  3796. * @param right defines the right operand
  3797. * @returns the cross product
  3798. */
  3799. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3800. /**
  3801. * Sets the given vector "result" with the cross product of "left" and "right"
  3802. * The cross product is then orthogonal to both "left" and "right"
  3803. * @param left defines the left operand
  3804. * @param right defines the right operand
  3805. * @param result defines the Vector3 where to store the result
  3806. */
  3807. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3808. /**
  3809. * Returns a new Vector3 as the normalization of the given vector
  3810. * @param vector defines the Vector3 to normalize
  3811. * @returns the new Vector3
  3812. */
  3813. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3814. /**
  3815. * Sets the given vector "result" with the normalization of the given first vector
  3816. * @param vector defines the Vector3 to normalize
  3817. * @param result defines the Vector3 where to store the result
  3818. */
  3819. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3820. /**
  3821. * Project a Vector3 onto screen space
  3822. * @param vector defines the Vector3 to project
  3823. * @param world defines the world matrix to use
  3824. * @param transform defines the transform (view x projection) matrix to use
  3825. * @param viewport defines the screen viewport to use
  3826. * @returns the new Vector3
  3827. */
  3828. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3829. /**
  3830. * Project a Vector3 onto screen space to reference
  3831. * @param vector defines the Vector3 to project
  3832. * @param world defines the world matrix to use
  3833. * @param transform defines the transform (view x projection) matrix to use
  3834. * @param viewport defines the screen viewport to use
  3835. * @param result the vector in which the screen space will be stored
  3836. * @returns the new Vector3
  3837. */
  3838. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3839. /** @hidden */
  3840. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3841. /**
  3842. * Unproject from screen space to object space
  3843. * @param source defines the screen space Vector3 to use
  3844. * @param viewportWidth defines the current width of the viewport
  3845. * @param viewportHeight defines the current height of the viewport
  3846. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3847. * @param transform defines the transform (view x projection) matrix to use
  3848. * @returns the new Vector3
  3849. */
  3850. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3851. /**
  3852. * Unproject from screen space to object space
  3853. * @param source defines the screen space Vector3 to use
  3854. * @param viewportWidth defines the current width of the viewport
  3855. * @param viewportHeight defines the current height of the viewport
  3856. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3857. * @param view defines the view matrix to use
  3858. * @param projection defines the projection matrix to use
  3859. * @returns the new Vector3
  3860. */
  3861. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3862. /**
  3863. * Unproject from screen space to object space
  3864. * @param source defines the screen space Vector3 to use
  3865. * @param viewportWidth defines the current width of the viewport
  3866. * @param viewportHeight defines the current height of the viewport
  3867. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3868. * @param view defines the view matrix to use
  3869. * @param projection defines the projection matrix to use
  3870. * @param result defines the Vector3 where to store the result
  3871. */
  3872. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3873. /**
  3874. * Unproject from screen space to object space
  3875. * @param sourceX defines the screen space x coordinate to use
  3876. * @param sourceY defines the screen space y coordinate to use
  3877. * @param sourceZ defines the screen space z coordinate to use
  3878. * @param viewportWidth defines the current width of the viewport
  3879. * @param viewportHeight defines the current height of the viewport
  3880. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3881. * @param view defines the view matrix to use
  3882. * @param projection defines the projection matrix to use
  3883. * @param result defines the Vector3 where to store the result
  3884. */
  3885. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3886. /**
  3887. * Gets the minimal coordinate values between two Vector3
  3888. * @param left defines the first operand
  3889. * @param right defines the second operand
  3890. * @returns the new Vector3
  3891. */
  3892. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3893. /**
  3894. * Gets the maximal coordinate values between two Vector3
  3895. * @param left defines the first operand
  3896. * @param right defines the second operand
  3897. * @returns the new Vector3
  3898. */
  3899. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3900. /**
  3901. * Returns the distance between the vectors "value1" and "value2"
  3902. * @param value1 defines the first operand
  3903. * @param value2 defines the second operand
  3904. * @returns the distance
  3905. */
  3906. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3907. /**
  3908. * Returns the squared distance between the vectors "value1" and "value2"
  3909. * @param value1 defines the first operand
  3910. * @param value2 defines the second operand
  3911. * @returns the squared distance
  3912. */
  3913. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3914. /**
  3915. * Returns a new Vector3 located at the center between "value1" and "value2"
  3916. * @param value1 defines the first operand
  3917. * @param value2 defines the second operand
  3918. * @returns the new Vector3
  3919. */
  3920. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3921. /**
  3922. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3923. * @param value1 defines first vector
  3924. * @param value2 defines second vector
  3925. * @param ref defines third vector
  3926. * @returns ref
  3927. */
  3928. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3929. /**
  3930. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3931. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3932. * to something in order to rotate it from its local system to the given target system
  3933. * Note: axis1, axis2 and axis3 are normalized during this operation
  3934. * @param axis1 defines the first axis
  3935. * @param axis2 defines the second axis
  3936. * @param axis3 defines the third axis
  3937. * @returns a new Vector3
  3938. */
  3939. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3940. /**
  3941. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3942. * @param axis1 defines the first axis
  3943. * @param axis2 defines the second axis
  3944. * @param axis3 defines the third axis
  3945. * @param ref defines the Vector3 where to store the result
  3946. */
  3947. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3948. }
  3949. /**
  3950. * Vector4 class created for EulerAngle class conversion to Quaternion
  3951. */
  3952. export class Vector4 {
  3953. /** x value of the vector */
  3954. x: number;
  3955. /** y value of the vector */
  3956. y: number;
  3957. /** z value of the vector */
  3958. z: number;
  3959. /** w value of the vector */
  3960. w: number;
  3961. /**
  3962. * Creates a Vector4 object from the given floats.
  3963. * @param x x value of the vector
  3964. * @param y y value of the vector
  3965. * @param z z value of the vector
  3966. * @param w w value of the vector
  3967. */
  3968. constructor(
  3969. /** x value of the vector */
  3970. x: number,
  3971. /** y value of the vector */
  3972. y: number,
  3973. /** z value of the vector */
  3974. z: number,
  3975. /** w value of the vector */
  3976. w: number);
  3977. /**
  3978. * Returns the string with the Vector4 coordinates.
  3979. * @returns a string containing all the vector values
  3980. */
  3981. toString(): string;
  3982. /**
  3983. * Returns the string "Vector4".
  3984. * @returns "Vector4"
  3985. */
  3986. getClassName(): string;
  3987. /**
  3988. * Returns the Vector4 hash code.
  3989. * @returns a unique hash code
  3990. */
  3991. getHashCode(): number;
  3992. /**
  3993. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3994. * @returns the resulting array
  3995. */
  3996. asArray(): number[];
  3997. /**
  3998. * Populates the given array from the given index with the Vector4 coordinates.
  3999. * @param array array to populate
  4000. * @param index index of the array to start at (default: 0)
  4001. * @returns the Vector4.
  4002. */
  4003. toArray(array: FloatArray, index?: number): Vector4;
  4004. /**
  4005. * Update the current vector from an array
  4006. * @param array defines the destination array
  4007. * @param index defines the offset in the destination array
  4008. * @returns the current Vector3
  4009. */
  4010. fromArray(array: FloatArray, index?: number): Vector4;
  4011. /**
  4012. * Adds the given vector to the current Vector4.
  4013. * @param otherVector the vector to add
  4014. * @returns the updated Vector4.
  4015. */
  4016. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4017. /**
  4018. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  4019. * @param otherVector the vector to add
  4020. * @returns the resulting vector
  4021. */
  4022. add(otherVector: DeepImmutable<Vector4>): Vector4;
  4023. /**
  4024. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  4025. * @param otherVector the vector to add
  4026. * @param result the vector to store the result
  4027. * @returns the current Vector4.
  4028. */
  4029. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4030. /**
  4031. * Subtract in place the given vector from the current Vector4.
  4032. * @param otherVector the vector to subtract
  4033. * @returns the updated Vector4.
  4034. */
  4035. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4036. /**
  4037. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  4038. * @param otherVector the vector to add
  4039. * @returns the new vector with the result
  4040. */
  4041. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  4042. /**
  4043. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  4044. * @param otherVector the vector to subtract
  4045. * @param result the vector to store the result
  4046. * @returns the current Vector4.
  4047. */
  4048. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4049. /**
  4050. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4051. */
  4052. /**
  4053. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4054. * @param x value to subtract
  4055. * @param y value to subtract
  4056. * @param z value to subtract
  4057. * @param w value to subtract
  4058. * @returns new vector containing the result
  4059. */
  4060. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4061. /**
  4062. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4063. * @param x value to subtract
  4064. * @param y value to subtract
  4065. * @param z value to subtract
  4066. * @param w value to subtract
  4067. * @param result the vector to store the result in
  4068. * @returns the current Vector4.
  4069. */
  4070. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4071. /**
  4072. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4073. * @returns a new vector with the negated values
  4074. */
  4075. negate(): Vector4;
  4076. /**
  4077. * Negate this vector in place
  4078. * @returns this
  4079. */
  4080. negateInPlace(): Vector4;
  4081. /**
  4082. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4083. * @param result defines the Vector3 object where to store the result
  4084. * @returns the current Vector4
  4085. */
  4086. negateToRef(result: Vector4): Vector4;
  4087. /**
  4088. * Multiplies the current Vector4 coordinates by scale (float).
  4089. * @param scale the number to scale with
  4090. * @returns the updated Vector4.
  4091. */
  4092. scaleInPlace(scale: number): Vector4;
  4093. /**
  4094. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4095. * @param scale the number to scale with
  4096. * @returns a new vector with the result
  4097. */
  4098. scale(scale: number): Vector4;
  4099. /**
  4100. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4101. * @param scale the number to scale with
  4102. * @param result a vector to store the result in
  4103. * @returns the current Vector4.
  4104. */
  4105. scaleToRef(scale: number, result: Vector4): Vector4;
  4106. /**
  4107. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4108. * @param scale defines the scale factor
  4109. * @param result defines the Vector4 object where to store the result
  4110. * @returns the unmodified current Vector4
  4111. */
  4112. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4113. /**
  4114. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4115. * @param otherVector the vector to compare against
  4116. * @returns true if they are equal
  4117. */
  4118. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4119. /**
  4120. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4121. * @param otherVector vector to compare against
  4122. * @param epsilon (Default: very small number)
  4123. * @returns true if they are equal
  4124. */
  4125. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4126. /**
  4127. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4128. * @param x x value to compare against
  4129. * @param y y value to compare against
  4130. * @param z z value to compare against
  4131. * @param w w value to compare against
  4132. * @returns true if equal
  4133. */
  4134. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4135. /**
  4136. * Multiplies in place the current Vector4 by the given one.
  4137. * @param otherVector vector to multiple with
  4138. * @returns the updated Vector4.
  4139. */
  4140. multiplyInPlace(otherVector: Vector4): Vector4;
  4141. /**
  4142. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4143. * @param otherVector vector to multiple with
  4144. * @returns resulting new vector
  4145. */
  4146. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4147. /**
  4148. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4149. * @param otherVector vector to multiple with
  4150. * @param result vector to store the result
  4151. * @returns the current Vector4.
  4152. */
  4153. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4154. /**
  4155. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4156. * @param x x value multiply with
  4157. * @param y y value multiply with
  4158. * @param z z value multiply with
  4159. * @param w w value multiply with
  4160. * @returns resulting new vector
  4161. */
  4162. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4163. /**
  4164. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4165. * @param otherVector vector to devide with
  4166. * @returns resulting new vector
  4167. */
  4168. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4169. /**
  4170. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4171. * @param otherVector vector to devide with
  4172. * @param result vector to store the result
  4173. * @returns the current Vector4.
  4174. */
  4175. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4176. /**
  4177. * Divides the current Vector3 coordinates by the given ones.
  4178. * @param otherVector vector to devide with
  4179. * @returns the updated Vector3.
  4180. */
  4181. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4182. /**
  4183. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4184. * @param other defines the second operand
  4185. * @returns the current updated Vector4
  4186. */
  4187. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4188. /**
  4189. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4190. * @param other defines the second operand
  4191. * @returns the current updated Vector4
  4192. */
  4193. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4194. /**
  4195. * Gets a new Vector4 from current Vector4 floored values
  4196. * @returns a new Vector4
  4197. */
  4198. floor(): Vector4;
  4199. /**
  4200. * Gets a new Vector4 from current Vector3 floored values
  4201. * @returns a new Vector4
  4202. */
  4203. fract(): Vector4;
  4204. /**
  4205. * Returns the Vector4 length (float).
  4206. * @returns the length
  4207. */
  4208. length(): number;
  4209. /**
  4210. * Returns the Vector4 squared length (float).
  4211. * @returns the length squared
  4212. */
  4213. lengthSquared(): number;
  4214. /**
  4215. * Normalizes in place the Vector4.
  4216. * @returns the updated Vector4.
  4217. */
  4218. normalize(): Vector4;
  4219. /**
  4220. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4221. * @returns this converted to a new vector3
  4222. */
  4223. toVector3(): Vector3;
  4224. /**
  4225. * Returns a new Vector4 copied from the current one.
  4226. * @returns the new cloned vector
  4227. */
  4228. clone(): Vector4;
  4229. /**
  4230. * Updates the current Vector4 with the given one coordinates.
  4231. * @param source the source vector to copy from
  4232. * @returns the updated Vector4.
  4233. */
  4234. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4235. /**
  4236. * Updates the current Vector4 coordinates with the given floats.
  4237. * @param x float to copy from
  4238. * @param y float to copy from
  4239. * @param z float to copy from
  4240. * @param w float to copy from
  4241. * @returns the updated Vector4.
  4242. */
  4243. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4244. /**
  4245. * Updates the current Vector4 coordinates with the given floats.
  4246. * @param x float to set from
  4247. * @param y float to set from
  4248. * @param z float to set from
  4249. * @param w float to set from
  4250. * @returns the updated Vector4.
  4251. */
  4252. set(x: number, y: number, z: number, w: number): Vector4;
  4253. /**
  4254. * Copies the given float to the current Vector3 coordinates
  4255. * @param v defines the x, y, z and w coordinates of the operand
  4256. * @returns the current updated Vector3
  4257. */
  4258. setAll(v: number): Vector4;
  4259. /**
  4260. * Returns a new Vector4 set from the starting index of the given array.
  4261. * @param array the array to pull values from
  4262. * @param offset the offset into the array to start at
  4263. * @returns the new vector
  4264. */
  4265. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4266. /**
  4267. * Updates the given vector "result" from the starting index of the given array.
  4268. * @param array the array to pull values from
  4269. * @param offset the offset into the array to start at
  4270. * @param result the vector to store the result in
  4271. */
  4272. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4273. /**
  4274. * Updates the given vector "result" from the starting index of the given Float32Array.
  4275. * @param array the array to pull values from
  4276. * @param offset the offset into the array to start at
  4277. * @param result the vector to store the result in
  4278. */
  4279. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4280. /**
  4281. * Updates the given vector "result" coordinates from the given floats.
  4282. * @param x float to set from
  4283. * @param y float to set from
  4284. * @param z float to set from
  4285. * @param w float to set from
  4286. * @param result the vector to the floats in
  4287. */
  4288. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4289. /**
  4290. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4291. * @returns the new vector
  4292. */
  4293. static Zero(): Vector4;
  4294. /**
  4295. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4296. * @returns the new vector
  4297. */
  4298. static One(): Vector4;
  4299. /**
  4300. * Returns a new normalized Vector4 from the given one.
  4301. * @param vector the vector to normalize
  4302. * @returns the vector
  4303. */
  4304. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4305. /**
  4306. * Updates the given vector "result" from the normalization of the given one.
  4307. * @param vector the vector to normalize
  4308. * @param result the vector to store the result in
  4309. */
  4310. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4311. /**
  4312. * Returns a vector with the minimum values from the left and right vectors
  4313. * @param left left vector to minimize
  4314. * @param right right vector to minimize
  4315. * @returns a new vector with the minimum of the left and right vector values
  4316. */
  4317. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4318. /**
  4319. * Returns a vector with the maximum values from the left and right vectors
  4320. * @param left left vector to maximize
  4321. * @param right right vector to maximize
  4322. * @returns a new vector with the maximum of the left and right vector values
  4323. */
  4324. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4325. /**
  4326. * Returns the distance (float) between the vectors "value1" and "value2".
  4327. * @param value1 value to calulate the distance between
  4328. * @param value2 value to calulate the distance between
  4329. * @return the distance between the two vectors
  4330. */
  4331. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4332. /**
  4333. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4334. * @param value1 value to calulate the distance between
  4335. * @param value2 value to calulate the distance between
  4336. * @return the distance between the two vectors squared
  4337. */
  4338. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4339. /**
  4340. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4341. * @param value1 value to calulate the center between
  4342. * @param value2 value to calulate the center between
  4343. * @return the center between the two vectors
  4344. */
  4345. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4346. /**
  4347. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4348. * @param value1 defines first vector
  4349. * @param value2 defines second vector
  4350. * @param ref defines third vector
  4351. * @returns ref
  4352. */
  4353. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4354. /**
  4355. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4356. * This methods computes transformed normalized direction vectors only.
  4357. * @param vector the vector to transform
  4358. * @param transformation the transformation matrix to apply
  4359. * @returns the new vector
  4360. */
  4361. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4362. /**
  4363. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4364. * This methods computes transformed normalized direction vectors only.
  4365. * @param vector the vector to transform
  4366. * @param transformation the transformation matrix to apply
  4367. * @param result the vector to store the result in
  4368. */
  4369. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4370. /**
  4371. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4372. * This methods computes transformed normalized direction vectors only.
  4373. * @param x value to transform
  4374. * @param y value to transform
  4375. * @param z value to transform
  4376. * @param w value to transform
  4377. * @param transformation the transformation matrix to apply
  4378. * @param result the vector to store the results in
  4379. */
  4380. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4381. /**
  4382. * Creates a new Vector4 from a Vector3
  4383. * @param source defines the source data
  4384. * @param w defines the 4th component (default is 0)
  4385. * @returns a new Vector4
  4386. */
  4387. static FromVector3(source: Vector3, w?: number): Vector4;
  4388. }
  4389. /**
  4390. * Class used to store quaternion data
  4391. * @see https://en.wikipedia.org/wiki/Quaternion
  4392. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4393. */
  4394. export class Quaternion {
  4395. /** @hidden */
  4396. _x: number;
  4397. /** @hidden */
  4398. _y: number;
  4399. /** @hidden */
  4400. _z: number;
  4401. /** @hidden */
  4402. _w: number;
  4403. /** @hidden */
  4404. _isDirty: boolean;
  4405. /** Gets or sets the x coordinate */
  4406. get x(): number;
  4407. set x(value: number);
  4408. /** Gets or sets the y coordinate */
  4409. get y(): number;
  4410. set y(value: number);
  4411. /** Gets or sets the z coordinate */
  4412. get z(): number;
  4413. set z(value: number);
  4414. /** Gets or sets the w coordinate */
  4415. get w(): number;
  4416. set w(value: number);
  4417. /**
  4418. * Creates a new Quaternion from the given floats
  4419. * @param x defines the first component (0 by default)
  4420. * @param y defines the second component (0 by default)
  4421. * @param z defines the third component (0 by default)
  4422. * @param w defines the fourth component (1.0 by default)
  4423. */
  4424. constructor(x?: number, y?: number, z?: number, w?: number);
  4425. /**
  4426. * Gets a string representation for the current quaternion
  4427. * @returns a string with the Quaternion coordinates
  4428. */
  4429. toString(): string;
  4430. /**
  4431. * Gets the class name of the quaternion
  4432. * @returns the string "Quaternion"
  4433. */
  4434. getClassName(): string;
  4435. /**
  4436. * Gets a hash code for this quaternion
  4437. * @returns the quaternion hash code
  4438. */
  4439. getHashCode(): number;
  4440. /**
  4441. * Copy the quaternion to an array
  4442. * @returns a new array populated with 4 elements from the quaternion coordinates
  4443. */
  4444. asArray(): number[];
  4445. /**
  4446. * Check if two quaternions are equals
  4447. * @param otherQuaternion defines the second operand
  4448. * @return true if the current quaternion and the given one coordinates are strictly equals
  4449. */
  4450. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4451. /**
  4452. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4453. * @param otherQuaternion defines the other quaternion
  4454. * @param epsilon defines the minimal distance to consider equality
  4455. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4456. */
  4457. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4458. /**
  4459. * Clone the current quaternion
  4460. * @returns a new quaternion copied from the current one
  4461. */
  4462. clone(): Quaternion;
  4463. /**
  4464. * Copy a quaternion to the current one
  4465. * @param other defines the other quaternion
  4466. * @returns the updated current quaternion
  4467. */
  4468. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4469. /**
  4470. * Updates the current quaternion with the given float coordinates
  4471. * @param x defines the x coordinate
  4472. * @param y defines the y coordinate
  4473. * @param z defines the z coordinate
  4474. * @param w defines the w coordinate
  4475. * @returns the updated current quaternion
  4476. */
  4477. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4478. /**
  4479. * Updates the current quaternion from the given float coordinates
  4480. * @param x defines the x coordinate
  4481. * @param y defines the y coordinate
  4482. * @param z defines the z coordinate
  4483. * @param w defines the w coordinate
  4484. * @returns the updated current quaternion
  4485. */
  4486. set(x: number, y: number, z: number, w: number): Quaternion;
  4487. /**
  4488. * Adds two quaternions
  4489. * @param other defines the second operand
  4490. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4491. */
  4492. add(other: DeepImmutable<Quaternion>): Quaternion;
  4493. /**
  4494. * Add a quaternion to the current one
  4495. * @param other defines the quaternion to add
  4496. * @returns the current quaternion
  4497. */
  4498. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4499. /**
  4500. * Subtract two quaternions
  4501. * @param other defines the second operand
  4502. * @returns a new quaternion as the subtraction result of the given one from the current one
  4503. */
  4504. subtract(other: Quaternion): Quaternion;
  4505. /**
  4506. * Multiplies the current quaternion by a scale factor
  4507. * @param value defines the scale factor
  4508. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4509. */
  4510. scale(value: number): Quaternion;
  4511. /**
  4512. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4513. * @param scale defines the scale factor
  4514. * @param result defines the Quaternion object where to store the result
  4515. * @returns the unmodified current quaternion
  4516. */
  4517. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4518. /**
  4519. * Multiplies in place the current quaternion by a scale factor
  4520. * @param value defines the scale factor
  4521. * @returns the current modified quaternion
  4522. */
  4523. scaleInPlace(value: number): Quaternion;
  4524. /**
  4525. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4526. * @param scale defines the scale factor
  4527. * @param result defines the Quaternion object where to store the result
  4528. * @returns the unmodified current quaternion
  4529. */
  4530. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4531. /**
  4532. * Multiplies two quaternions
  4533. * @param q1 defines the second operand
  4534. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4535. */
  4536. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4537. /**
  4538. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4539. * @param q1 defines the second operand
  4540. * @param result defines the target quaternion
  4541. * @returns the current quaternion
  4542. */
  4543. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4544. /**
  4545. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4546. * @param q1 defines the second operand
  4547. * @returns the currentupdated quaternion
  4548. */
  4549. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4550. /**
  4551. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4552. * @param ref defines the target quaternion
  4553. * @returns the current quaternion
  4554. */
  4555. conjugateToRef(ref: Quaternion): Quaternion;
  4556. /**
  4557. * Conjugates in place (1-q) the current quaternion
  4558. * @returns the current updated quaternion
  4559. */
  4560. conjugateInPlace(): Quaternion;
  4561. /**
  4562. * Conjugates in place (1-q) the current quaternion
  4563. * @returns a new quaternion
  4564. */
  4565. conjugate(): Quaternion;
  4566. /**
  4567. * Gets length of current quaternion
  4568. * @returns the quaternion length (float)
  4569. */
  4570. length(): number;
  4571. /**
  4572. * Normalize in place the current quaternion
  4573. * @returns the current updated quaternion
  4574. */
  4575. normalize(): Quaternion;
  4576. /**
  4577. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4578. * @param order is a reserved parameter and is ignored for now
  4579. * @returns a new Vector3 containing the Euler angles
  4580. */
  4581. toEulerAngles(order?: string): Vector3;
  4582. /**
  4583. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4584. * @param result defines the vector which will be filled with the Euler angles
  4585. * @returns the current unchanged quaternion
  4586. */
  4587. toEulerAnglesToRef(result: Vector3): Quaternion;
  4588. /**
  4589. * Updates the given rotation matrix with the current quaternion values
  4590. * @param result defines the target matrix
  4591. * @returns the current unchanged quaternion
  4592. */
  4593. toRotationMatrix(result: Matrix): Quaternion;
  4594. /**
  4595. * Updates the current quaternion from the given rotation matrix values
  4596. * @param matrix defines the source matrix
  4597. * @returns the current updated quaternion
  4598. */
  4599. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4600. /**
  4601. * Creates a new quaternion from a rotation matrix
  4602. * @param matrix defines the source matrix
  4603. * @returns a new quaternion created from the given rotation matrix values
  4604. */
  4605. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4606. /**
  4607. * Updates the given quaternion with the given rotation matrix values
  4608. * @param matrix defines the source matrix
  4609. * @param result defines the target quaternion
  4610. */
  4611. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4612. /**
  4613. * Returns the dot product (float) between the quaternions "left" and "right"
  4614. * @param left defines the left operand
  4615. * @param right defines the right operand
  4616. * @returns the dot product
  4617. */
  4618. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4619. /**
  4620. * Checks if the two quaternions are close to each other
  4621. * @param quat0 defines the first quaternion to check
  4622. * @param quat1 defines the second quaternion to check
  4623. * @returns true if the two quaternions are close to each other
  4624. */
  4625. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4626. /**
  4627. * Creates an empty quaternion
  4628. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4629. */
  4630. static Zero(): Quaternion;
  4631. /**
  4632. * Inverse a given quaternion
  4633. * @param q defines the source quaternion
  4634. * @returns a new quaternion as the inverted current quaternion
  4635. */
  4636. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4637. /**
  4638. * Inverse a given quaternion
  4639. * @param q defines the source quaternion
  4640. * @param result the quaternion the result will be stored in
  4641. * @returns the result quaternion
  4642. */
  4643. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4644. /**
  4645. * Creates an identity quaternion
  4646. * @returns the identity quaternion
  4647. */
  4648. static Identity(): Quaternion;
  4649. /**
  4650. * Gets a boolean indicating if the given quaternion is identity
  4651. * @param quaternion defines the quaternion to check
  4652. * @returns true if the quaternion is identity
  4653. */
  4654. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4655. /**
  4656. * Creates a quaternion from a rotation around an axis
  4657. * @param axis defines the axis to use
  4658. * @param angle defines the angle to use
  4659. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4660. */
  4661. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4662. /**
  4663. * Creates a rotation around an axis and stores it into the given quaternion
  4664. * @param axis defines the axis to use
  4665. * @param angle defines the angle to use
  4666. * @param result defines the target quaternion
  4667. * @returns the target quaternion
  4668. */
  4669. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4670. /**
  4671. * Creates a new quaternion from data stored into an array
  4672. * @param array defines the data source
  4673. * @param offset defines the offset in the source array where the data starts
  4674. * @returns a new quaternion
  4675. */
  4676. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4677. /**
  4678. * Updates the given quaternion "result" from the starting index of the given array.
  4679. * @param array the array to pull values from
  4680. * @param offset the offset into the array to start at
  4681. * @param result the quaternion to store the result in
  4682. */
  4683. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4684. /**
  4685. * Create a quaternion from Euler rotation angles
  4686. * @param x Pitch
  4687. * @param y Yaw
  4688. * @param z Roll
  4689. * @returns the new Quaternion
  4690. */
  4691. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4692. /**
  4693. * Updates a quaternion from Euler rotation angles
  4694. * @param x Pitch
  4695. * @param y Yaw
  4696. * @param z Roll
  4697. * @param result the quaternion to store the result
  4698. * @returns the updated quaternion
  4699. */
  4700. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4701. /**
  4702. * Create a quaternion from Euler rotation vector
  4703. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4704. * @returns the new Quaternion
  4705. */
  4706. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4707. /**
  4708. * Updates a quaternion from Euler rotation vector
  4709. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4710. * @param result the quaternion to store the result
  4711. * @returns the updated quaternion
  4712. */
  4713. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4714. /**
  4715. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4716. * @param vecFrom defines the direction vector from which to rotate
  4717. * @param vecTo defines the direction vector to which to rotate
  4718. * @param result the quaternion to store the result
  4719. * @returns the updated quaternion
  4720. */
  4721. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4722. /**
  4723. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4724. * @param yaw defines the rotation around Y axis
  4725. * @param pitch defines the rotation around X axis
  4726. * @param roll defines the rotation around Z axis
  4727. * @returns the new quaternion
  4728. */
  4729. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4730. /**
  4731. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4732. * @param yaw defines the rotation around Y axis
  4733. * @param pitch defines the rotation around X axis
  4734. * @param roll defines the rotation around Z axis
  4735. * @param result defines the target quaternion
  4736. */
  4737. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4738. /**
  4739. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4740. * @param alpha defines the rotation around first axis
  4741. * @param beta defines the rotation around second axis
  4742. * @param gamma defines the rotation around third axis
  4743. * @returns the new quaternion
  4744. */
  4745. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4746. /**
  4747. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4748. * @param alpha defines the rotation around first axis
  4749. * @param beta defines the rotation around second axis
  4750. * @param gamma defines the rotation around third axis
  4751. * @param result defines the target quaternion
  4752. */
  4753. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4754. /**
  4755. * 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)
  4756. * @param axis1 defines the first axis
  4757. * @param axis2 defines the second axis
  4758. * @param axis3 defines the third axis
  4759. * @returns the new quaternion
  4760. */
  4761. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4762. /**
  4763. * 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
  4764. * @param axis1 defines the first axis
  4765. * @param axis2 defines the second axis
  4766. * @param axis3 defines the third axis
  4767. * @param ref defines the target quaternion
  4768. */
  4769. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4770. /**
  4771. * Interpolates between two quaternions
  4772. * @param left defines first quaternion
  4773. * @param right defines second quaternion
  4774. * @param amount defines the gradient to use
  4775. * @returns the new interpolated quaternion
  4776. */
  4777. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4778. /**
  4779. * Interpolates between two quaternions and stores it into a target quaternion
  4780. * @param left defines first quaternion
  4781. * @param right defines second quaternion
  4782. * @param amount defines the gradient to use
  4783. * @param result defines the target quaternion
  4784. */
  4785. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4786. /**
  4787. * Interpolate between two quaternions using Hermite interpolation
  4788. * @param value1 defines first quaternion
  4789. * @param tangent1 defines the incoming tangent
  4790. * @param value2 defines second quaternion
  4791. * @param tangent2 defines the outgoing tangent
  4792. * @param amount defines the target quaternion
  4793. * @returns the new interpolated quaternion
  4794. */
  4795. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4796. }
  4797. /**
  4798. * Class used to store matrix data (4x4)
  4799. */
  4800. export class Matrix {
  4801. /**
  4802. * Gets the precision of matrix computations
  4803. */
  4804. static get Use64Bits(): boolean;
  4805. private static _updateFlagSeed;
  4806. private static _identityReadOnly;
  4807. private _isIdentity;
  4808. private _isIdentityDirty;
  4809. private _isIdentity3x2;
  4810. private _isIdentity3x2Dirty;
  4811. /**
  4812. * Gets the update flag of the matrix which is an unique number for the matrix.
  4813. * It will be incremented every time the matrix data change.
  4814. * You can use it to speed the comparison between two versions of the same matrix.
  4815. */
  4816. updateFlag: number;
  4817. private readonly _m;
  4818. /**
  4819. * Gets the internal data of the matrix
  4820. */
  4821. get m(): DeepImmutable<Float32Array | Array<number>>;
  4822. /** @hidden */
  4823. _markAsUpdated(): void;
  4824. /** @hidden */
  4825. private _updateIdentityStatus;
  4826. /**
  4827. * Creates an empty matrix (filled with zeros)
  4828. */
  4829. constructor();
  4830. /**
  4831. * Check if the current matrix is identity
  4832. * @returns true is the matrix is the identity matrix
  4833. */
  4834. isIdentity(): boolean;
  4835. /**
  4836. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4837. * @returns true is the matrix is the identity matrix
  4838. */
  4839. isIdentityAs3x2(): boolean;
  4840. /**
  4841. * Gets the determinant of the matrix
  4842. * @returns the matrix determinant
  4843. */
  4844. determinant(): number;
  4845. /**
  4846. * Returns the matrix as a Float32Array or Array<number>
  4847. * @returns the matrix underlying array
  4848. */
  4849. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4850. /**
  4851. * Returns the matrix as a Float32Array or Array<number>
  4852. * @returns the matrix underlying array.
  4853. */
  4854. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4855. /**
  4856. * Inverts the current matrix in place
  4857. * @returns the current inverted matrix
  4858. */
  4859. invert(): Matrix;
  4860. /**
  4861. * Sets all the matrix elements to zero
  4862. * @returns the current matrix
  4863. */
  4864. reset(): Matrix;
  4865. /**
  4866. * Adds the current matrix with a second one
  4867. * @param other defines the matrix to add
  4868. * @returns a new matrix as the addition of the current matrix and the given one
  4869. */
  4870. add(other: DeepImmutable<Matrix>): Matrix;
  4871. /**
  4872. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4873. * @param other defines the matrix to add
  4874. * @param result defines the target matrix
  4875. * @returns the current matrix
  4876. */
  4877. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4878. /**
  4879. * Adds in place the given matrix to the current matrix
  4880. * @param other defines the second operand
  4881. * @returns the current updated matrix
  4882. */
  4883. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4884. /**
  4885. * Sets the given matrix to the current inverted Matrix
  4886. * @param other defines the target matrix
  4887. * @returns the unmodified current matrix
  4888. */
  4889. invertToRef(other: Matrix): Matrix;
  4890. /**
  4891. * add a value at the specified position in the current Matrix
  4892. * @param index the index of the value within the matrix. between 0 and 15.
  4893. * @param value the value to be added
  4894. * @returns the current updated matrix
  4895. */
  4896. addAtIndex(index: number, value: number): Matrix;
  4897. /**
  4898. * mutiply the specified position in the current Matrix by a value
  4899. * @param index the index of the value within the matrix. between 0 and 15.
  4900. * @param value the value to be added
  4901. * @returns the current updated matrix
  4902. */
  4903. multiplyAtIndex(index: number, value: number): Matrix;
  4904. /**
  4905. * Inserts the translation vector (using 3 floats) in the current matrix
  4906. * @param x defines the 1st component of the translation
  4907. * @param y defines the 2nd component of the translation
  4908. * @param z defines the 3rd component of the translation
  4909. * @returns the current updated matrix
  4910. */
  4911. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4912. /**
  4913. * Adds the translation vector (using 3 floats) in the current matrix
  4914. * @param x defines the 1st component of the translation
  4915. * @param y defines the 2nd component of the translation
  4916. * @param z defines the 3rd component of the translation
  4917. * @returns the current updated matrix
  4918. */
  4919. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4920. /**
  4921. * Inserts the translation vector in the current matrix
  4922. * @param vector3 defines the translation to insert
  4923. * @returns the current updated matrix
  4924. */
  4925. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4926. /**
  4927. * Gets the translation value of the current matrix
  4928. * @returns a new Vector3 as the extracted translation from the matrix
  4929. */
  4930. getTranslation(): Vector3;
  4931. /**
  4932. * Fill a Vector3 with the extracted translation from the matrix
  4933. * @param result defines the Vector3 where to store the translation
  4934. * @returns the current matrix
  4935. */
  4936. getTranslationToRef(result: Vector3): Matrix;
  4937. /**
  4938. * Remove rotation and scaling part from the matrix
  4939. * @returns the updated matrix
  4940. */
  4941. removeRotationAndScaling(): Matrix;
  4942. /**
  4943. * Multiply two matrices
  4944. * @param other defines the second operand
  4945. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4946. */
  4947. multiply(other: DeepImmutable<Matrix>): Matrix;
  4948. /**
  4949. * Copy the current matrix from the given one
  4950. * @param other defines the source matrix
  4951. * @returns the current updated matrix
  4952. */
  4953. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4954. /**
  4955. * Populates the given array from the starting index with the current matrix values
  4956. * @param array defines the target array
  4957. * @param offset defines the offset in the target array where to start storing values
  4958. * @returns the current matrix
  4959. */
  4960. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4961. /**
  4962. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4963. * @param other defines the second operand
  4964. * @param result defines the matrix where to store the multiplication
  4965. * @returns the current matrix
  4966. */
  4967. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4968. /**
  4969. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4970. * @param other defines the second operand
  4971. * @param result defines the array where to store the multiplication
  4972. * @param offset defines the offset in the target array where to start storing values
  4973. * @returns the current matrix
  4974. */
  4975. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4976. /**
  4977. * Check equality between this matrix and a second one
  4978. * @param value defines the second matrix to compare
  4979. * @returns true is the current matrix and the given one values are strictly equal
  4980. */
  4981. equals(value: DeepImmutable<Matrix>): boolean;
  4982. /**
  4983. * Clone the current matrix
  4984. * @returns a new matrix from the current matrix
  4985. */
  4986. clone(): Matrix;
  4987. /**
  4988. * Returns the name of the current matrix class
  4989. * @returns the string "Matrix"
  4990. */
  4991. getClassName(): string;
  4992. /**
  4993. * Gets the hash code of the current matrix
  4994. * @returns the hash code
  4995. */
  4996. getHashCode(): number;
  4997. /**
  4998. * Decomposes the current Matrix into a translation, rotation and scaling components
  4999. * @param scale defines the scale vector3 given as a reference to update
  5000. * @param rotation defines the rotation quaternion given as a reference to update
  5001. * @param translation defines the translation vector3 given as a reference to update
  5002. * @returns true if operation was successful
  5003. */
  5004. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  5005. /**
  5006. * Gets specific row of the matrix
  5007. * @param index defines the number of the row to get
  5008. * @returns the index-th row of the current matrix as a new Vector4
  5009. */
  5010. getRow(index: number): Nullable<Vector4>;
  5011. /**
  5012. * Sets the index-th row of the current matrix to the vector4 values
  5013. * @param index defines the number of the row to set
  5014. * @param row defines the target vector4
  5015. * @returns the updated current matrix
  5016. */
  5017. setRow(index: number, row: Vector4): Matrix;
  5018. /**
  5019. * Compute the transpose of the matrix
  5020. * @returns the new transposed matrix
  5021. */
  5022. transpose(): Matrix;
  5023. /**
  5024. * Compute the transpose of the matrix and store it in a given matrix
  5025. * @param result defines the target matrix
  5026. * @returns the current matrix
  5027. */
  5028. transposeToRef(result: Matrix): Matrix;
  5029. /**
  5030. * Sets the index-th row of the current matrix with the given 4 x float values
  5031. * @param index defines the row index
  5032. * @param x defines the x component to set
  5033. * @param y defines the y component to set
  5034. * @param z defines the z component to set
  5035. * @param w defines the w component to set
  5036. * @returns the updated current matrix
  5037. */
  5038. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  5039. /**
  5040. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  5041. * @param scale defines the scale factor
  5042. * @returns a new matrix
  5043. */
  5044. scale(scale: number): Matrix;
  5045. /**
  5046. * Scale the current matrix values by a factor to a given result matrix
  5047. * @param scale defines the scale factor
  5048. * @param result defines the matrix to store the result
  5049. * @returns the current matrix
  5050. */
  5051. scaleToRef(scale: number, result: Matrix): Matrix;
  5052. /**
  5053. * Scale the current matrix values by a factor and add the result to a given matrix
  5054. * @param scale defines the scale factor
  5055. * @param result defines the Matrix to store the result
  5056. * @returns the current matrix
  5057. */
  5058. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5059. /**
  5060. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5061. * @param ref matrix to store the result
  5062. */
  5063. toNormalMatrix(ref: Matrix): void;
  5064. /**
  5065. * Gets only rotation part of the current matrix
  5066. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5067. */
  5068. getRotationMatrix(): Matrix;
  5069. /**
  5070. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5071. * @param result defines the target matrix to store data to
  5072. * @returns the current matrix
  5073. */
  5074. getRotationMatrixToRef(result: Matrix): Matrix;
  5075. /**
  5076. * Toggles model matrix from being right handed to left handed in place and vice versa
  5077. */
  5078. toggleModelMatrixHandInPlace(): void;
  5079. /**
  5080. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5081. */
  5082. toggleProjectionMatrixHandInPlace(): void;
  5083. /**
  5084. * Creates a matrix from an array
  5085. * @param array defines the source array
  5086. * @param offset defines an offset in the source array
  5087. * @returns a new Matrix set from the starting index of the given array
  5088. */
  5089. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5090. /**
  5091. * Copy the content of an array into a given matrix
  5092. * @param array defines the source array
  5093. * @param offset defines an offset in the source array
  5094. * @param result defines the target matrix
  5095. */
  5096. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5097. /**
  5098. * Stores an array into a matrix after having multiplied each component by a given factor
  5099. * @param array defines the source array
  5100. * @param offset defines the offset in the source array
  5101. * @param scale defines the scaling factor
  5102. * @param result defines the target matrix
  5103. */
  5104. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5105. /**
  5106. * Gets an identity matrix that must not be updated
  5107. */
  5108. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5109. /**
  5110. * Stores a list of values (16) inside a given matrix
  5111. * @param initialM11 defines 1st value of 1st row
  5112. * @param initialM12 defines 2nd value of 1st row
  5113. * @param initialM13 defines 3rd value of 1st row
  5114. * @param initialM14 defines 4th value of 1st row
  5115. * @param initialM21 defines 1st value of 2nd row
  5116. * @param initialM22 defines 2nd value of 2nd row
  5117. * @param initialM23 defines 3rd value of 2nd row
  5118. * @param initialM24 defines 4th value of 2nd row
  5119. * @param initialM31 defines 1st value of 3rd row
  5120. * @param initialM32 defines 2nd value of 3rd row
  5121. * @param initialM33 defines 3rd value of 3rd row
  5122. * @param initialM34 defines 4th value of 3rd row
  5123. * @param initialM41 defines 1st value of 4th row
  5124. * @param initialM42 defines 2nd value of 4th row
  5125. * @param initialM43 defines 3rd value of 4th row
  5126. * @param initialM44 defines 4th value of 4th row
  5127. * @param result defines the target matrix
  5128. */
  5129. 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;
  5130. /**
  5131. * Creates new matrix from a list of values (16)
  5132. * @param initialM11 defines 1st value of 1st row
  5133. * @param initialM12 defines 2nd value of 1st row
  5134. * @param initialM13 defines 3rd value of 1st row
  5135. * @param initialM14 defines 4th value of 1st row
  5136. * @param initialM21 defines 1st value of 2nd row
  5137. * @param initialM22 defines 2nd value of 2nd row
  5138. * @param initialM23 defines 3rd value of 2nd row
  5139. * @param initialM24 defines 4th value of 2nd row
  5140. * @param initialM31 defines 1st value of 3rd row
  5141. * @param initialM32 defines 2nd value of 3rd row
  5142. * @param initialM33 defines 3rd value of 3rd row
  5143. * @param initialM34 defines 4th value of 3rd row
  5144. * @param initialM41 defines 1st value of 4th row
  5145. * @param initialM42 defines 2nd value of 4th row
  5146. * @param initialM43 defines 3rd value of 4th row
  5147. * @param initialM44 defines 4th value of 4th row
  5148. * @returns the new matrix
  5149. */
  5150. 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;
  5151. /**
  5152. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5153. * @param scale defines the scale vector3
  5154. * @param rotation defines the rotation quaternion
  5155. * @param translation defines the translation vector3
  5156. * @returns a new matrix
  5157. */
  5158. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5159. /**
  5160. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5161. * @param scale defines the scale vector3
  5162. * @param rotation defines the rotation quaternion
  5163. * @param translation defines the translation vector3
  5164. * @param result defines the target matrix
  5165. */
  5166. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5167. /**
  5168. * Creates a new identity matrix
  5169. * @returns a new identity matrix
  5170. */
  5171. static Identity(): Matrix;
  5172. /**
  5173. * Creates a new identity matrix and stores the result in a given matrix
  5174. * @param result defines the target matrix
  5175. */
  5176. static IdentityToRef(result: Matrix): void;
  5177. /**
  5178. * Creates a new zero matrix
  5179. * @returns a new zero matrix
  5180. */
  5181. static Zero(): Matrix;
  5182. /**
  5183. * Creates a new rotation matrix for "angle" radians around the X axis
  5184. * @param angle defines the angle (in radians) to use
  5185. * @return the new matrix
  5186. */
  5187. static RotationX(angle: number): Matrix;
  5188. /**
  5189. * Creates a new matrix as the invert of a given matrix
  5190. * @param source defines the source matrix
  5191. * @returns the new matrix
  5192. */
  5193. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5194. /**
  5195. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5196. * @param angle defines the angle (in radians) to use
  5197. * @param result defines the target matrix
  5198. */
  5199. static RotationXToRef(angle: number, result: Matrix): void;
  5200. /**
  5201. * Creates a new rotation matrix for "angle" radians around the Y axis
  5202. * @param angle defines the angle (in radians) to use
  5203. * @return the new matrix
  5204. */
  5205. static RotationY(angle: number): Matrix;
  5206. /**
  5207. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5208. * @param angle defines the angle (in radians) to use
  5209. * @param result defines the target matrix
  5210. */
  5211. static RotationYToRef(angle: number, result: Matrix): void;
  5212. /**
  5213. * Creates a new rotation matrix for "angle" radians around the Z axis
  5214. * @param angle defines the angle (in radians) to use
  5215. * @return the new matrix
  5216. */
  5217. static RotationZ(angle: number): Matrix;
  5218. /**
  5219. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5220. * @param angle defines the angle (in radians) to use
  5221. * @param result defines the target matrix
  5222. */
  5223. static RotationZToRef(angle: number, result: Matrix): void;
  5224. /**
  5225. * Creates a new rotation matrix for "angle" radians around the given axis
  5226. * @param axis defines the axis to use
  5227. * @param angle defines the angle (in radians) to use
  5228. * @return the new matrix
  5229. */
  5230. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5231. /**
  5232. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5233. * @param axis defines the axis to use
  5234. * @param angle defines the angle (in radians) to use
  5235. * @param result defines the target matrix
  5236. */
  5237. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5238. /**
  5239. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5240. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5241. * @param from defines the vector to align
  5242. * @param to defines the vector to align to
  5243. * @param result defines the target matrix
  5244. */
  5245. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5246. /**
  5247. * Creates a rotation matrix
  5248. * @param yaw defines the yaw angle in radians (Y axis)
  5249. * @param pitch defines the pitch angle in radians (X axis)
  5250. * @param roll defines the roll angle in radians (Z axis)
  5251. * @returns the new rotation matrix
  5252. */
  5253. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5254. /**
  5255. * Creates a rotation matrix and stores it in a given matrix
  5256. * @param yaw defines the yaw angle in radians (Y axis)
  5257. * @param pitch defines the pitch angle in radians (X axis)
  5258. * @param roll defines the roll angle in radians (Z axis)
  5259. * @param result defines the target matrix
  5260. */
  5261. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5262. /**
  5263. * Creates a scaling matrix
  5264. * @param x defines the scale factor on X axis
  5265. * @param y defines the scale factor on Y axis
  5266. * @param z defines the scale factor on Z axis
  5267. * @returns the new matrix
  5268. */
  5269. static Scaling(x: number, y: number, z: number): Matrix;
  5270. /**
  5271. * Creates a scaling matrix and stores it in a given matrix
  5272. * @param x defines the scale factor on X axis
  5273. * @param y defines the scale factor on Y axis
  5274. * @param z defines the scale factor on Z axis
  5275. * @param result defines the target matrix
  5276. */
  5277. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5278. /**
  5279. * Creates a translation matrix
  5280. * @param x defines the translation on X axis
  5281. * @param y defines the translation on Y axis
  5282. * @param z defines the translationon Z axis
  5283. * @returns the new matrix
  5284. */
  5285. static Translation(x: number, y: number, z: number): Matrix;
  5286. /**
  5287. * Creates a translation matrix and stores it in a given matrix
  5288. * @param x defines the translation on X axis
  5289. * @param y defines the translation on Y axis
  5290. * @param z defines the translationon Z axis
  5291. * @param result defines the target matrix
  5292. */
  5293. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5294. /**
  5295. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5296. * @param startValue defines the start value
  5297. * @param endValue defines the end value
  5298. * @param gradient defines the gradient factor
  5299. * @returns the new matrix
  5300. */
  5301. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5302. /**
  5303. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5304. * @param startValue defines the start value
  5305. * @param endValue defines the end value
  5306. * @param gradient defines the gradient factor
  5307. * @param result defines the Matrix object where to store data
  5308. */
  5309. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5310. /**
  5311. * Builds a new matrix whose values are computed by:
  5312. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5313. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5314. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5315. * @param startValue defines the first matrix
  5316. * @param endValue defines the second matrix
  5317. * @param gradient defines the gradient between the two matrices
  5318. * @returns the new matrix
  5319. */
  5320. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5321. /**
  5322. * Update a matrix to values which are computed by:
  5323. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5324. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5325. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5326. * @param startValue defines the first matrix
  5327. * @param endValue defines the second matrix
  5328. * @param gradient defines the gradient between the two matrices
  5329. * @param result defines the target matrix
  5330. */
  5331. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5332. /**
  5333. * 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"
  5334. * This function works in left handed mode
  5335. * @param eye defines the final position of the entity
  5336. * @param target defines where the entity should look at
  5337. * @param up defines the up vector for the entity
  5338. * @returns the new matrix
  5339. */
  5340. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5341. /**
  5342. * 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".
  5343. * This function works in left handed mode
  5344. * @param eye defines the final position of the entity
  5345. * @param target defines where the entity should look at
  5346. * @param up defines the up vector for the entity
  5347. * @param result defines the target matrix
  5348. */
  5349. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5350. /**
  5351. * 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"
  5352. * This function works in right handed mode
  5353. * @param eye defines the final position of the entity
  5354. * @param target defines where the entity should look at
  5355. * @param up defines the up vector for the entity
  5356. * @returns the new matrix
  5357. */
  5358. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5359. /**
  5360. * 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".
  5361. * This function works in right handed mode
  5362. * @param eye defines the final position of the entity
  5363. * @param target defines where the entity should look at
  5364. * @param up defines the up vector for the entity
  5365. * @param result defines the target matrix
  5366. */
  5367. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5368. /**
  5369. * Create a left-handed orthographic projection matrix
  5370. * @param width defines the viewport width
  5371. * @param height defines the viewport height
  5372. * @param znear defines the near clip plane
  5373. * @param zfar defines the far clip plane
  5374. * @returns a new matrix as a left-handed orthographic projection matrix
  5375. */
  5376. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5377. /**
  5378. * Store a left-handed orthographic projection to a given matrix
  5379. * @param width defines the viewport width
  5380. * @param height defines the viewport height
  5381. * @param znear defines the near clip plane
  5382. * @param zfar defines the far clip plane
  5383. * @param result defines the target matrix
  5384. */
  5385. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5386. /**
  5387. * Create a left-handed orthographic projection matrix
  5388. * @param left defines the viewport left coordinate
  5389. * @param right defines the viewport right coordinate
  5390. * @param bottom defines the viewport bottom coordinate
  5391. * @param top defines the viewport top coordinate
  5392. * @param znear defines the near clip plane
  5393. * @param zfar defines the far clip plane
  5394. * @returns a new matrix as a left-handed orthographic projection matrix
  5395. */
  5396. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5397. /**
  5398. * Stores a left-handed orthographic projection into a given matrix
  5399. * @param left defines the viewport left coordinate
  5400. * @param right defines the viewport right coordinate
  5401. * @param bottom defines the viewport bottom coordinate
  5402. * @param top defines the viewport top coordinate
  5403. * @param znear defines the near clip plane
  5404. * @param zfar defines the far clip plane
  5405. * @param result defines the target matrix
  5406. */
  5407. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5408. /**
  5409. * Creates a right-handed orthographic projection matrix
  5410. * @param left defines the viewport left coordinate
  5411. * @param right defines the viewport right coordinate
  5412. * @param bottom defines the viewport bottom coordinate
  5413. * @param top defines the viewport top coordinate
  5414. * @param znear defines the near clip plane
  5415. * @param zfar defines the far clip plane
  5416. * @returns a new matrix as a right-handed orthographic projection matrix
  5417. */
  5418. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5419. /**
  5420. * Stores a right-handed orthographic projection into a given matrix
  5421. * @param left defines the viewport left coordinate
  5422. * @param right defines the viewport right coordinate
  5423. * @param bottom defines the viewport bottom coordinate
  5424. * @param top defines the viewport top coordinate
  5425. * @param znear defines the near clip plane
  5426. * @param zfar defines the far clip plane
  5427. * @param result defines the target matrix
  5428. */
  5429. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5430. /**
  5431. * Creates a left-handed perspective projection matrix
  5432. * @param width defines the viewport width
  5433. * @param height defines the viewport height
  5434. * @param znear defines the near clip plane
  5435. * @param zfar defines the far clip plane
  5436. * @returns a new matrix as a left-handed perspective projection matrix
  5437. */
  5438. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5439. /**
  5440. * Creates a left-handed perspective projection matrix
  5441. * @param fov defines the horizontal field of view
  5442. * @param aspect defines the aspect ratio
  5443. * @param znear defines the near clip plane
  5444. * @param zfar defines the far clip plane
  5445. * @returns a new matrix as a left-handed perspective projection matrix
  5446. */
  5447. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5448. /**
  5449. * Stores a left-handed perspective projection into a given matrix
  5450. * @param fov defines the horizontal field of view
  5451. * @param aspect defines the aspect ratio
  5452. * @param znear defines the near clip plane
  5453. * @param zfar defines the far clip plane
  5454. * @param result defines the target matrix
  5455. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5456. */
  5457. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5458. /**
  5459. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5460. * @param fov defines the horizontal field of view
  5461. * @param aspect defines the aspect ratio
  5462. * @param znear defines the near clip plane
  5463. * @param zfar not used as infinity is used as far clip
  5464. * @param result defines the target matrix
  5465. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5466. */
  5467. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5468. /**
  5469. * Creates a right-handed perspective projection matrix
  5470. * @param fov defines the horizontal field of view
  5471. * @param aspect defines the aspect ratio
  5472. * @param znear defines the near clip plane
  5473. * @param zfar defines the far clip plane
  5474. * @returns a new matrix as a right-handed perspective projection matrix
  5475. */
  5476. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5477. /**
  5478. * Stores a right-handed perspective projection into a given matrix
  5479. * @param fov defines the horizontal field of view
  5480. * @param aspect defines the aspect ratio
  5481. * @param znear defines the near clip plane
  5482. * @param zfar defines the far clip plane
  5483. * @param result defines the target matrix
  5484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5485. */
  5486. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5487. /**
  5488. * Stores a right-handed perspective projection into a given matrix
  5489. * @param fov defines the horizontal field of view
  5490. * @param aspect defines the aspect ratio
  5491. * @param znear defines the near clip plane
  5492. * @param zfar not used as infinity is used as far clip
  5493. * @param result defines the target matrix
  5494. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5495. */
  5496. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5497. /**
  5498. * Stores a perspective projection for WebVR info a given matrix
  5499. * @param fov defines the field of view
  5500. * @param znear defines the near clip plane
  5501. * @param zfar defines the far clip plane
  5502. * @param result defines the target matrix
  5503. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5504. */
  5505. static PerspectiveFovWebVRToRef(fov: {
  5506. upDegrees: number;
  5507. downDegrees: number;
  5508. leftDegrees: number;
  5509. rightDegrees: number;
  5510. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5511. /**
  5512. * Computes a complete transformation matrix
  5513. * @param viewport defines the viewport to use
  5514. * @param world defines the world matrix
  5515. * @param view defines the view matrix
  5516. * @param projection defines the projection matrix
  5517. * @param zmin defines the near clip plane
  5518. * @param zmax defines the far clip plane
  5519. * @returns the transformation matrix
  5520. */
  5521. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5522. /**
  5523. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5524. * @param matrix defines the matrix to use
  5525. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5526. */
  5527. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5528. /**
  5529. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5530. * @param matrix defines the matrix to use
  5531. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5532. */
  5533. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5534. /**
  5535. * Compute the transpose of a given matrix
  5536. * @param matrix defines the matrix to transpose
  5537. * @returns the new matrix
  5538. */
  5539. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5540. /**
  5541. * Compute the transpose of a matrix and store it in a target matrix
  5542. * @param matrix defines the matrix to transpose
  5543. * @param result defines the target matrix
  5544. */
  5545. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5546. /**
  5547. * Computes a reflection matrix from a plane
  5548. * @param plane defines the reflection plane
  5549. * @returns a new matrix
  5550. */
  5551. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5552. /**
  5553. * Computes a reflection matrix from a plane
  5554. * @param plane defines the reflection plane
  5555. * @param result defines the target matrix
  5556. */
  5557. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5558. /**
  5559. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5560. * @param xaxis defines the value of the 1st axis
  5561. * @param yaxis defines the value of the 2nd axis
  5562. * @param zaxis defines the value of the 3rd axis
  5563. * @param result defines the target matrix
  5564. */
  5565. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5566. /**
  5567. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5568. * @param quat defines the quaternion to use
  5569. * @param result defines the target matrix
  5570. */
  5571. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5572. }
  5573. /**
  5574. * @hidden
  5575. */
  5576. export class TmpVectors {
  5577. static Vector2: Vector2[];
  5578. static Vector3: Vector3[];
  5579. static Vector4: Vector4[];
  5580. static Quaternion: Quaternion[];
  5581. static Matrix: Matrix[];
  5582. }
  5583. }
  5584. declare module "babylonjs/Maths/math.path" {
  5585. import { DeepImmutable, Nullable } from "babylonjs/types";
  5586. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5587. /**
  5588. * Defines potential orientation for back face culling
  5589. */
  5590. export enum Orientation {
  5591. /**
  5592. * Clockwise
  5593. */
  5594. CW = 0,
  5595. /** Counter clockwise */
  5596. CCW = 1
  5597. }
  5598. /** Class used to represent a Bezier curve */
  5599. export class BezierCurve {
  5600. /**
  5601. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5602. * @param t defines the time
  5603. * @param x1 defines the left coordinate on X axis
  5604. * @param y1 defines the left coordinate on Y axis
  5605. * @param x2 defines the right coordinate on X axis
  5606. * @param y2 defines the right coordinate on Y axis
  5607. * @returns the interpolated value
  5608. */
  5609. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5610. }
  5611. /**
  5612. * Defines angle representation
  5613. */
  5614. export class Angle {
  5615. private _radians;
  5616. /**
  5617. * Creates an Angle object of "radians" radians (float).
  5618. * @param radians the angle in radians
  5619. */
  5620. constructor(radians: number);
  5621. /**
  5622. * Get value in degrees
  5623. * @returns the Angle value in degrees (float)
  5624. */
  5625. degrees(): number;
  5626. /**
  5627. * Get value in radians
  5628. * @returns the Angle value in radians (float)
  5629. */
  5630. radians(): number;
  5631. /**
  5632. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5633. * @param a defines first point as the origin
  5634. * @param b defines point
  5635. * @returns a new Angle
  5636. */
  5637. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5638. /**
  5639. * Gets a new Angle object from the given float in radians
  5640. * @param radians defines the angle value in radians
  5641. * @returns a new Angle
  5642. */
  5643. static FromRadians(radians: number): Angle;
  5644. /**
  5645. * Gets a new Angle object from the given float in degrees
  5646. * @param degrees defines the angle value in degrees
  5647. * @returns a new Angle
  5648. */
  5649. static FromDegrees(degrees: number): Angle;
  5650. }
  5651. /**
  5652. * This represents an arc in a 2d space.
  5653. */
  5654. export class Arc2 {
  5655. /** Defines the start point of the arc */
  5656. startPoint: Vector2;
  5657. /** Defines the mid point of the arc */
  5658. midPoint: Vector2;
  5659. /** Defines the end point of the arc */
  5660. endPoint: Vector2;
  5661. /**
  5662. * Defines the center point of the arc.
  5663. */
  5664. centerPoint: Vector2;
  5665. /**
  5666. * Defines the radius of the arc.
  5667. */
  5668. radius: number;
  5669. /**
  5670. * Defines the angle of the arc (from mid point to end point).
  5671. */
  5672. angle: Angle;
  5673. /**
  5674. * Defines the start angle of the arc (from start point to middle point).
  5675. */
  5676. startAngle: Angle;
  5677. /**
  5678. * Defines the orientation of the arc (clock wise/counter clock wise).
  5679. */
  5680. orientation: Orientation;
  5681. /**
  5682. * Creates an Arc object from the three given points : start, middle and end.
  5683. * @param startPoint Defines the start point of the arc
  5684. * @param midPoint Defines the midlle point of the arc
  5685. * @param endPoint Defines the end point of the arc
  5686. */
  5687. constructor(
  5688. /** Defines the start point of the arc */
  5689. startPoint: Vector2,
  5690. /** Defines the mid point of the arc */
  5691. midPoint: Vector2,
  5692. /** Defines the end point of the arc */
  5693. endPoint: Vector2);
  5694. }
  5695. /**
  5696. * Represents a 2D path made up of multiple 2D points
  5697. */
  5698. export class Path2 {
  5699. private _points;
  5700. private _length;
  5701. /**
  5702. * If the path start and end point are the same
  5703. */
  5704. closed: boolean;
  5705. /**
  5706. * Creates a Path2 object from the starting 2D coordinates x and y.
  5707. * @param x the starting points x value
  5708. * @param y the starting points y value
  5709. */
  5710. constructor(x: number, y: number);
  5711. /**
  5712. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5713. * @param x the added points x value
  5714. * @param y the added points y value
  5715. * @returns the updated Path2.
  5716. */
  5717. addLineTo(x: number, y: number): Path2;
  5718. /**
  5719. * 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.
  5720. * @param midX middle point x value
  5721. * @param midY middle point y value
  5722. * @param endX end point x value
  5723. * @param endY end point y value
  5724. * @param numberOfSegments (default: 36)
  5725. * @returns the updated Path2.
  5726. */
  5727. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5728. /**
  5729. * Closes the Path2.
  5730. * @returns the Path2.
  5731. */
  5732. close(): Path2;
  5733. /**
  5734. * Gets the sum of the distance between each sequential point in the path
  5735. * @returns the Path2 total length (float).
  5736. */
  5737. length(): number;
  5738. /**
  5739. * Gets the points which construct the path
  5740. * @returns the Path2 internal array of points.
  5741. */
  5742. getPoints(): Vector2[];
  5743. /**
  5744. * Retreives the point at the distance aways from the starting point
  5745. * @param normalizedLengthPosition the length along the path to retreive the point from
  5746. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5747. */
  5748. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5749. /**
  5750. * Creates a new path starting from an x and y position
  5751. * @param x starting x value
  5752. * @param y starting y value
  5753. * @returns a new Path2 starting at the coordinates (x, y).
  5754. */
  5755. static StartingAt(x: number, y: number): Path2;
  5756. }
  5757. /**
  5758. * Represents a 3D path made up of multiple 3D points
  5759. */
  5760. export class Path3D {
  5761. /**
  5762. * an array of Vector3, the curve axis of the Path3D
  5763. */
  5764. path: Vector3[];
  5765. private _curve;
  5766. private _distances;
  5767. private _tangents;
  5768. private _normals;
  5769. private _binormals;
  5770. private _raw;
  5771. private _alignTangentsWithPath;
  5772. private readonly _pointAtData;
  5773. /**
  5774. * new Path3D(path, normal, raw)
  5775. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5776. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5777. * @param path an array of Vector3, the curve axis of the Path3D
  5778. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5779. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5780. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5781. */
  5782. constructor(
  5783. /**
  5784. * an array of Vector3, the curve axis of the Path3D
  5785. */
  5786. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5787. /**
  5788. * Returns the Path3D array of successive Vector3 designing its curve.
  5789. * @returns the Path3D array of successive Vector3 designing its curve.
  5790. */
  5791. getCurve(): Vector3[];
  5792. /**
  5793. * Returns the Path3D array of successive Vector3 designing its curve.
  5794. * @returns the Path3D array of successive Vector3 designing its curve.
  5795. */
  5796. getPoints(): Vector3[];
  5797. /**
  5798. * @returns the computed length (float) of the path.
  5799. */
  5800. length(): number;
  5801. /**
  5802. * Returns an array populated with tangent vectors on each Path3D curve point.
  5803. * @returns an array populated with tangent vectors on each Path3D curve point.
  5804. */
  5805. getTangents(): Vector3[];
  5806. /**
  5807. * Returns an array populated with normal vectors on each Path3D curve point.
  5808. * @returns an array populated with normal vectors on each Path3D curve point.
  5809. */
  5810. getNormals(): Vector3[];
  5811. /**
  5812. * Returns an array populated with binormal vectors on each Path3D curve point.
  5813. * @returns an array populated with binormal vectors on each Path3D curve point.
  5814. */
  5815. getBinormals(): Vector3[];
  5816. /**
  5817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5819. */
  5820. getDistances(): number[];
  5821. /**
  5822. * Returns an interpolated point along this path
  5823. * @param position the position of the point along this path, from 0.0 to 1.0
  5824. * @returns a new Vector3 as the point
  5825. */
  5826. getPointAt(position: number): Vector3;
  5827. /**
  5828. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5829. * @param position the position of the point along this path, from 0.0 to 1.0
  5830. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5831. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5832. */
  5833. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5834. /**
  5835. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5836. * @param position the position of the point along this path, from 0.0 to 1.0
  5837. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5838. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5839. */
  5840. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5841. /**
  5842. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5843. * @param position the position of the point along this path, from 0.0 to 1.0
  5844. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5845. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5846. */
  5847. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5848. /**
  5849. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5850. * @param position the position of the point along this path, from 0.0 to 1.0
  5851. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5852. */
  5853. getDistanceAt(position: number): number;
  5854. /**
  5855. * Returns the array index of the previous point of an interpolated point along this path
  5856. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5857. * @returns the array index
  5858. */
  5859. getPreviousPointIndexAt(position: number): number;
  5860. /**
  5861. * 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)
  5862. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5863. * @returns the sub position
  5864. */
  5865. getSubPositionAt(position: number): number;
  5866. /**
  5867. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5868. * @param target the vector of which to get the closest position to
  5869. * @returns the position of the closest virtual point on this path to the target vector
  5870. */
  5871. getClosestPositionTo(target: Vector3): number;
  5872. /**
  5873. * Returns a sub path (slice) of this path
  5874. * @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
  5875. * @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
  5876. * @returns a sub path (slice) of this path
  5877. */
  5878. slice(start?: number, end?: number): Path3D;
  5879. /**
  5880. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5881. * @param path path which all values are copied into the curves points
  5882. * @param firstNormal which should be projected onto the curve
  5883. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5884. * @returns the same object updated.
  5885. */
  5886. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5887. private _compute;
  5888. private _getFirstNonNullVector;
  5889. private _getLastNonNullVector;
  5890. private _normalVector;
  5891. /**
  5892. * Updates the point at data for an interpolated point along this curve
  5893. * @param position the position of the point along this curve, from 0.0 to 1.0
  5894. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5895. * @returns the (updated) point at data
  5896. */
  5897. private _updatePointAtData;
  5898. /**
  5899. * Updates the point at data from the specified parameters
  5900. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5901. * @param point the interpolated point
  5902. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5903. */
  5904. private _setPointAtData;
  5905. /**
  5906. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5907. */
  5908. private _updateInterpolationMatrix;
  5909. }
  5910. /**
  5911. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5912. * A Curve3 is designed from a series of successive Vector3.
  5913. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5914. */
  5915. export class Curve3 {
  5916. private _points;
  5917. private _length;
  5918. /**
  5919. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5920. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5921. * @param v1 (Vector3) the control point
  5922. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5923. * @param nbPoints (integer) the wanted number of points in the curve
  5924. * @returns the created Curve3
  5925. */
  5926. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5927. /**
  5928. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5929. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5930. * @param v1 (Vector3) the first control point
  5931. * @param v2 (Vector3) the second control point
  5932. * @param v3 (Vector3) the end point of the Cubic Bezier
  5933. * @param nbPoints (integer) the wanted number of points in the curve
  5934. * @returns the created Curve3
  5935. */
  5936. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5937. /**
  5938. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5939. * @param p1 (Vector3) the origin point of the Hermite Spline
  5940. * @param t1 (Vector3) the tangent vector at the origin point
  5941. * @param p2 (Vector3) the end point of the Hermite Spline
  5942. * @param t2 (Vector3) the tangent vector at the end point
  5943. * @param nbPoints (integer) the wanted number of points in the curve
  5944. * @returns the created Curve3
  5945. */
  5946. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5947. /**
  5948. * Returns a Curve3 object along a CatmullRom Spline curve :
  5949. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5950. * @param nbPoints (integer) the wanted number of points between each curve control points
  5951. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5952. * @returns the created Curve3
  5953. */
  5954. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5955. /**
  5956. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5957. * A Curve3 is designed from a series of successive Vector3.
  5958. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5959. * @param points points which make up the curve
  5960. */
  5961. constructor(points: Vector3[]);
  5962. /**
  5963. * @returns the Curve3 stored array of successive Vector3
  5964. */
  5965. getPoints(): Vector3[];
  5966. /**
  5967. * @returns the computed length (float) of the curve.
  5968. */
  5969. length(): number;
  5970. /**
  5971. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5972. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5973. * curveA and curveB keep unchanged.
  5974. * @param curve the curve to continue from this curve
  5975. * @returns the newly constructed curve
  5976. */
  5977. continue(curve: DeepImmutable<Curve3>): Curve3;
  5978. private _computeLength;
  5979. }
  5980. }
  5981. declare module "babylonjs/Animations/easing" {
  5982. /**
  5983. * This represents the main contract an easing function should follow.
  5984. * Easing functions are used throughout the animation system.
  5985. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5986. */
  5987. export interface IEasingFunction {
  5988. /**
  5989. * Given an input gradient between 0 and 1, this returns the corresponding value
  5990. * of the easing function.
  5991. * The link below provides some of the most common examples of easing functions.
  5992. * @see https://easings.net/
  5993. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5994. * @returns the corresponding value on the curve defined by the easing function
  5995. */
  5996. ease(gradient: number): number;
  5997. }
  5998. /**
  5999. * Base class used for every default easing function.
  6000. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6001. */
  6002. export class EasingFunction implements IEasingFunction {
  6003. /**
  6004. * Interpolation follows the mathematical formula associated with the easing function.
  6005. */
  6006. static readonly EASINGMODE_EASEIN: number;
  6007. /**
  6008. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6009. */
  6010. static readonly EASINGMODE_EASEOUT: number;
  6011. /**
  6012. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6013. */
  6014. static readonly EASINGMODE_EASEINOUT: number;
  6015. private _easingMode;
  6016. /**
  6017. * Sets the easing mode of the current function.
  6018. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6019. */
  6020. setEasingMode(easingMode: number): void;
  6021. /**
  6022. * Gets the current easing mode.
  6023. * @returns the easing mode
  6024. */
  6025. getEasingMode(): number;
  6026. /**
  6027. * @hidden
  6028. */
  6029. easeInCore(gradient: number): number;
  6030. /**
  6031. * Given an input gradient between 0 and 1, this returns the corresponding value
  6032. * of the easing function.
  6033. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6034. * @returns the corresponding value on the curve defined by the easing function
  6035. */
  6036. ease(gradient: number): number;
  6037. }
  6038. /**
  6039. * Easing function with a circle shape (see link below).
  6040. * @see https://easings.net/#easeInCirc
  6041. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6042. */
  6043. export class CircleEase extends EasingFunction implements IEasingFunction {
  6044. /** @hidden */
  6045. easeInCore(gradient: number): number;
  6046. }
  6047. /**
  6048. * Easing function with a ease back shape (see link below).
  6049. * @see https://easings.net/#easeInBack
  6050. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6051. */
  6052. export class BackEase extends EasingFunction implements IEasingFunction {
  6053. /** Defines the amplitude of the function */
  6054. amplitude: number;
  6055. /**
  6056. * Instantiates a back ease easing
  6057. * @see https://easings.net/#easeInBack
  6058. * @param amplitude Defines the amplitude of the function
  6059. */
  6060. constructor(
  6061. /** Defines the amplitude of the function */
  6062. amplitude?: number);
  6063. /** @hidden */
  6064. easeInCore(gradient: number): number;
  6065. }
  6066. /**
  6067. * Easing function with a bouncing shape (see link below).
  6068. * @see https://easings.net/#easeInBounce
  6069. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6070. */
  6071. export class BounceEase extends EasingFunction implements IEasingFunction {
  6072. /** Defines the number of bounces */
  6073. bounces: number;
  6074. /** Defines the amplitude of the bounce */
  6075. bounciness: number;
  6076. /**
  6077. * Instantiates a bounce easing
  6078. * @see https://easings.net/#easeInBounce
  6079. * @param bounces Defines the number of bounces
  6080. * @param bounciness Defines the amplitude of the bounce
  6081. */
  6082. constructor(
  6083. /** Defines the number of bounces */
  6084. bounces?: number,
  6085. /** Defines the amplitude of the bounce */
  6086. bounciness?: number);
  6087. /** @hidden */
  6088. easeInCore(gradient: number): number;
  6089. }
  6090. /**
  6091. * Easing function with a power of 3 shape (see link below).
  6092. * @see https://easings.net/#easeInCubic
  6093. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6094. */
  6095. export class CubicEase extends EasingFunction implements IEasingFunction {
  6096. /** @hidden */
  6097. easeInCore(gradient: number): number;
  6098. }
  6099. /**
  6100. * Easing function with an elastic shape (see link below).
  6101. * @see https://easings.net/#easeInElastic
  6102. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6103. */
  6104. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6105. /** Defines the number of oscillations*/
  6106. oscillations: number;
  6107. /** Defines the amplitude of the oscillations*/
  6108. springiness: number;
  6109. /**
  6110. * Instantiates an elastic easing function
  6111. * @see https://easings.net/#easeInElastic
  6112. * @param oscillations Defines the number of oscillations
  6113. * @param springiness Defines the amplitude of the oscillations
  6114. */
  6115. constructor(
  6116. /** Defines the number of oscillations*/
  6117. oscillations?: number,
  6118. /** Defines the amplitude of the oscillations*/
  6119. springiness?: number);
  6120. /** @hidden */
  6121. easeInCore(gradient: number): number;
  6122. }
  6123. /**
  6124. * Easing function with an exponential shape (see link below).
  6125. * @see https://easings.net/#easeInExpo
  6126. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6127. */
  6128. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6129. /** Defines the exponent of the function */
  6130. exponent: number;
  6131. /**
  6132. * Instantiates an exponential easing function
  6133. * @see https://easings.net/#easeInExpo
  6134. * @param exponent Defines the exponent of the function
  6135. */
  6136. constructor(
  6137. /** Defines the exponent of the function */
  6138. exponent?: number);
  6139. /** @hidden */
  6140. easeInCore(gradient: number): number;
  6141. }
  6142. /**
  6143. * Easing function with a power shape (see link below).
  6144. * @see https://easings.net/#easeInQuad
  6145. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6146. */
  6147. export class PowerEase extends EasingFunction implements IEasingFunction {
  6148. /** Defines the power of the function */
  6149. power: number;
  6150. /**
  6151. * Instantiates an power base easing function
  6152. * @see https://easings.net/#easeInQuad
  6153. * @param power Defines the power of the function
  6154. */
  6155. constructor(
  6156. /** Defines the power of the function */
  6157. power?: number);
  6158. /** @hidden */
  6159. easeInCore(gradient: number): number;
  6160. }
  6161. /**
  6162. * Easing function with a power of 2 shape (see link below).
  6163. * @see https://easings.net/#easeInQuad
  6164. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6165. */
  6166. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6167. /** @hidden */
  6168. easeInCore(gradient: number): number;
  6169. }
  6170. /**
  6171. * Easing function with a power of 4 shape (see link below).
  6172. * @see https://easings.net/#easeInQuart
  6173. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6174. */
  6175. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6176. /** @hidden */
  6177. easeInCore(gradient: number): number;
  6178. }
  6179. /**
  6180. * Easing function with a power of 5 shape (see link below).
  6181. * @see https://easings.net/#easeInQuint
  6182. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6183. */
  6184. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6185. /** @hidden */
  6186. easeInCore(gradient: number): number;
  6187. }
  6188. /**
  6189. * Easing function with a sin shape (see link below).
  6190. * @see https://easings.net/#easeInSine
  6191. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6192. */
  6193. export class SineEase extends EasingFunction implements IEasingFunction {
  6194. /** @hidden */
  6195. easeInCore(gradient: number): number;
  6196. }
  6197. /**
  6198. * Easing function with a bezier shape (see link below).
  6199. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6200. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6201. */
  6202. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6203. /** Defines the x component of the start tangent in the bezier curve */
  6204. x1: number;
  6205. /** Defines the y component of the start tangent in the bezier curve */
  6206. y1: number;
  6207. /** Defines the x component of the end tangent in the bezier curve */
  6208. x2: number;
  6209. /** Defines the y component of the end tangent in the bezier curve */
  6210. y2: number;
  6211. /**
  6212. * Instantiates a bezier function
  6213. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6214. * @param x1 Defines the x component of the start tangent in the bezier curve
  6215. * @param y1 Defines the y component of the start tangent in the bezier curve
  6216. * @param x2 Defines the x component of the end tangent in the bezier curve
  6217. * @param y2 Defines the y component of the end tangent in the bezier curve
  6218. */
  6219. constructor(
  6220. /** Defines the x component of the start tangent in the bezier curve */
  6221. x1?: number,
  6222. /** Defines the y component of the start tangent in the bezier curve */
  6223. y1?: number,
  6224. /** Defines the x component of the end tangent in the bezier curve */
  6225. x2?: number,
  6226. /** Defines the y component of the end tangent in the bezier curve */
  6227. y2?: number);
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. }
  6232. declare module "babylonjs/Maths/math.color" {
  6233. import { DeepImmutable, FloatArray } from "babylonjs/types";
  6234. /**
  6235. * Class used to hold a RGB color
  6236. */
  6237. export class Color3 {
  6238. /**
  6239. * Defines the red component (between 0 and 1, default is 0)
  6240. */
  6241. r: number;
  6242. /**
  6243. * Defines the green component (between 0 and 1, default is 0)
  6244. */
  6245. g: number;
  6246. /**
  6247. * Defines the blue component (between 0 and 1, default is 0)
  6248. */
  6249. b: number;
  6250. /**
  6251. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6252. * @param r defines the red component (between 0 and 1, default is 0)
  6253. * @param g defines the green component (between 0 and 1, default is 0)
  6254. * @param b defines the blue component (between 0 and 1, default is 0)
  6255. */
  6256. constructor(
  6257. /**
  6258. * Defines the red component (between 0 and 1, default is 0)
  6259. */
  6260. r?: number,
  6261. /**
  6262. * Defines the green component (between 0 and 1, default is 0)
  6263. */
  6264. g?: number,
  6265. /**
  6266. * Defines the blue component (between 0 and 1, default is 0)
  6267. */
  6268. b?: number);
  6269. /**
  6270. * Creates a string with the Color3 current values
  6271. * @returns the string representation of the Color3 object
  6272. */
  6273. toString(): string;
  6274. /**
  6275. * Returns the string "Color3"
  6276. * @returns "Color3"
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Compute the Color3 hash code
  6281. * @returns an unique number that can be used to hash Color3 objects
  6282. */
  6283. getHashCode(): number;
  6284. /**
  6285. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6286. * @param array defines the array where to store the r,g,b components
  6287. * @param index defines an optional index in the target array to define where to start storing values
  6288. * @returns the current Color3 object
  6289. */
  6290. toArray(array: FloatArray, index?: number): Color3;
  6291. /**
  6292. * Update the current color with values stored in an array from the starting index of the given array
  6293. * @param array defines the source array
  6294. * @param offset defines an offset in the source array
  6295. * @returns the current Color3 object
  6296. */
  6297. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6298. /**
  6299. * Returns a new Color4 object from the current Color3 and the given alpha
  6300. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6301. * @returns a new Color4 object
  6302. */
  6303. toColor4(alpha?: number): Color4;
  6304. /**
  6305. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6306. * @returns the new array
  6307. */
  6308. asArray(): number[];
  6309. /**
  6310. * Returns the luminance value
  6311. * @returns a float value
  6312. */
  6313. toLuminance(): number;
  6314. /**
  6315. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6316. * @param otherColor defines the second operand
  6317. * @returns the new Color3 object
  6318. */
  6319. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6320. /**
  6321. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6322. * @param otherColor defines the second operand
  6323. * @param result defines the Color3 object where to store the result
  6324. * @returns the current Color3
  6325. */
  6326. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6327. /**
  6328. * Determines equality between Color3 objects
  6329. * @param otherColor defines the second operand
  6330. * @returns true if the rgb values are equal to the given ones
  6331. */
  6332. equals(otherColor: DeepImmutable<Color3>): boolean;
  6333. /**
  6334. * Determines equality between the current Color3 object and a set of r,b,g values
  6335. * @param r defines the red component to check
  6336. * @param g defines the green component to check
  6337. * @param b defines the blue component to check
  6338. * @returns true if the rgb values are equal to the given ones
  6339. */
  6340. equalsFloats(r: number, g: number, b: number): boolean;
  6341. /**
  6342. * Multiplies in place each rgb value by scale
  6343. * @param scale defines the scaling factor
  6344. * @returns the updated Color3
  6345. */
  6346. scale(scale: number): Color3;
  6347. /**
  6348. * Multiplies the rgb values by scale and stores the result into "result"
  6349. * @param scale defines the scaling factor
  6350. * @param result defines the Color3 object where to store the result
  6351. * @returns the unmodified current Color3
  6352. */
  6353. scaleToRef(scale: number, result: Color3): Color3;
  6354. /**
  6355. * Scale the current Color3 values by a factor and add the result to a given Color3
  6356. * @param scale defines the scale factor
  6357. * @param result defines color to store the result into
  6358. * @returns the unmodified current Color3
  6359. */
  6360. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6361. /**
  6362. * Clamps the rgb values by the min and max values and stores the result into "result"
  6363. * @param min defines minimum clamping value (default is 0)
  6364. * @param max defines maximum clamping value (default is 1)
  6365. * @param result defines color to store the result into
  6366. * @returns the original Color3
  6367. */
  6368. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6369. /**
  6370. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6371. * @param otherColor defines the second operand
  6372. * @returns the new Color3
  6373. */
  6374. add(otherColor: DeepImmutable<Color3>): Color3;
  6375. /**
  6376. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6377. * @param otherColor defines the second operand
  6378. * @param result defines Color3 object to store the result into
  6379. * @returns the unmodified current Color3
  6380. */
  6381. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6382. /**
  6383. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6384. * @param otherColor defines the second operand
  6385. * @returns the new Color3
  6386. */
  6387. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6388. /**
  6389. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6390. * @param otherColor defines the second operand
  6391. * @param result defines Color3 object to store the result into
  6392. * @returns the unmodified current Color3
  6393. */
  6394. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6395. /**
  6396. * Copy the current object
  6397. * @returns a new Color3 copied the current one
  6398. */
  6399. clone(): Color3;
  6400. /**
  6401. * Copies the rgb values from the source in the current Color3
  6402. * @param source defines the source Color3 object
  6403. * @returns the updated Color3 object
  6404. */
  6405. copyFrom(source: DeepImmutable<Color3>): Color3;
  6406. /**
  6407. * Updates the Color3 rgb values from the given floats
  6408. * @param r defines the red component to read from
  6409. * @param g defines the green component to read from
  6410. * @param b defines the blue component to read from
  6411. * @returns the current Color3 object
  6412. */
  6413. copyFromFloats(r: number, g: number, b: number): Color3;
  6414. /**
  6415. * Updates the Color3 rgb values from the given floats
  6416. * @param r defines the red component to read from
  6417. * @param g defines the green component to read from
  6418. * @param b defines the blue component to read from
  6419. * @returns the current Color3 object
  6420. */
  6421. set(r: number, g: number, b: number): Color3;
  6422. /**
  6423. * Compute the Color3 hexadecimal code as a string
  6424. * @returns a string containing the hexadecimal representation of the Color3 object
  6425. */
  6426. toHexString(): string;
  6427. /**
  6428. * Computes a new Color3 converted from the current one to linear space
  6429. * @returns a new Color3 object
  6430. */
  6431. toLinearSpace(): Color3;
  6432. /**
  6433. * Converts current color in rgb space to HSV values
  6434. * @returns a new color3 representing the HSV values
  6435. */
  6436. toHSV(): Color3;
  6437. /**
  6438. * Converts current color in rgb space to HSV values
  6439. * @param result defines the Color3 where to store the HSV values
  6440. */
  6441. toHSVToRef(result: Color3): void;
  6442. /**
  6443. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6444. * @param convertedColor defines the Color3 object where to store the linear space version
  6445. * @returns the unmodified Color3
  6446. */
  6447. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6448. /**
  6449. * Computes a new Color3 converted from the current one to gamma space
  6450. * @returns a new Color3 object
  6451. */
  6452. toGammaSpace(): Color3;
  6453. /**
  6454. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6455. * @param convertedColor defines the Color3 object where to store the gamma space version
  6456. * @returns the unmodified Color3
  6457. */
  6458. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6459. private static _BlackReadOnly;
  6460. /**
  6461. * Convert Hue, saturation and value to a Color3 (RGB)
  6462. * @param hue defines the hue
  6463. * @param saturation defines the saturation
  6464. * @param value defines the value
  6465. * @param result defines the Color3 where to store the RGB values
  6466. */
  6467. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6468. /**
  6469. * Creates a new Color3 from the string containing valid hexadecimal values
  6470. * @param hex defines a string containing valid hexadecimal values
  6471. * @returns a new Color3 object
  6472. */
  6473. static FromHexString(hex: string): Color3;
  6474. /**
  6475. * Creates a new Color3 from the starting index of the given array
  6476. * @param array defines the source array
  6477. * @param offset defines an offset in the source array
  6478. * @returns a new Color3 object
  6479. */
  6480. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6481. /**
  6482. * Creates a new Color3 from the starting index element of the given array
  6483. * @param array defines the source array to read from
  6484. * @param offset defines the offset in the source array
  6485. * @param result defines the target Color3 object
  6486. */
  6487. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6488. /**
  6489. * Creates a new Color3 from integer values (< 256)
  6490. * @param r defines the red component to read from (value between 0 and 255)
  6491. * @param g defines the green component to read from (value between 0 and 255)
  6492. * @param b defines the blue component to read from (value between 0 and 255)
  6493. * @returns a new Color3 object
  6494. */
  6495. static FromInts(r: number, g: number, b: number): Color3;
  6496. /**
  6497. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6498. * @param start defines the start Color3 value
  6499. * @param end defines the end Color3 value
  6500. * @param amount defines the gradient value between start and end
  6501. * @returns a new Color3 object
  6502. */
  6503. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6504. /**
  6505. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6506. * @param left defines the start value
  6507. * @param right defines the end value
  6508. * @param amount defines the gradient factor
  6509. * @param result defines the Color3 object where to store the result
  6510. */
  6511. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6512. /**
  6513. * Returns a Color3 value containing a red color
  6514. * @returns a new Color3 object
  6515. */
  6516. static Red(): Color3;
  6517. /**
  6518. * Returns a Color3 value containing a green color
  6519. * @returns a new Color3 object
  6520. */
  6521. static Green(): Color3;
  6522. /**
  6523. * Returns a Color3 value containing a blue color
  6524. * @returns a new Color3 object
  6525. */
  6526. static Blue(): Color3;
  6527. /**
  6528. * Returns a Color3 value containing a black color
  6529. * @returns a new Color3 object
  6530. */
  6531. static Black(): Color3;
  6532. /**
  6533. * Gets a Color3 value containing a black color that must not be updated
  6534. */
  6535. static get BlackReadOnly(): DeepImmutable<Color3>;
  6536. /**
  6537. * Returns a Color3 value containing a white color
  6538. * @returns a new Color3 object
  6539. */
  6540. static White(): Color3;
  6541. /**
  6542. * Returns a Color3 value containing a purple color
  6543. * @returns a new Color3 object
  6544. */
  6545. static Purple(): Color3;
  6546. /**
  6547. * Returns a Color3 value containing a magenta color
  6548. * @returns a new Color3 object
  6549. */
  6550. static Magenta(): Color3;
  6551. /**
  6552. * Returns a Color3 value containing a yellow color
  6553. * @returns a new Color3 object
  6554. */
  6555. static Yellow(): Color3;
  6556. /**
  6557. * Returns a Color3 value containing a gray color
  6558. * @returns a new Color3 object
  6559. */
  6560. static Gray(): Color3;
  6561. /**
  6562. * Returns a Color3 value containing a teal color
  6563. * @returns a new Color3 object
  6564. */
  6565. static Teal(): Color3;
  6566. /**
  6567. * Returns a Color3 value containing a random color
  6568. * @returns a new Color3 object
  6569. */
  6570. static Random(): Color3;
  6571. }
  6572. /**
  6573. * Class used to hold a RBGA color
  6574. */
  6575. export class Color4 {
  6576. /**
  6577. * Defines the red component (between 0 and 1, default is 0)
  6578. */
  6579. r: number;
  6580. /**
  6581. * Defines the green component (between 0 and 1, default is 0)
  6582. */
  6583. g: number;
  6584. /**
  6585. * Defines the blue component (between 0 and 1, default is 0)
  6586. */
  6587. b: number;
  6588. /**
  6589. * Defines the alpha component (between 0 and 1, default is 1)
  6590. */
  6591. a: number;
  6592. /**
  6593. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6594. * @param r defines the red component (between 0 and 1, default is 0)
  6595. * @param g defines the green component (between 0 and 1, default is 0)
  6596. * @param b defines the blue component (between 0 and 1, default is 0)
  6597. * @param a defines the alpha component (between 0 and 1, default is 1)
  6598. */
  6599. constructor(
  6600. /**
  6601. * Defines the red component (between 0 and 1, default is 0)
  6602. */
  6603. r?: number,
  6604. /**
  6605. * Defines the green component (between 0 and 1, default is 0)
  6606. */
  6607. g?: number,
  6608. /**
  6609. * Defines the blue component (between 0 and 1, default is 0)
  6610. */
  6611. b?: number,
  6612. /**
  6613. * Defines the alpha component (between 0 and 1, default is 1)
  6614. */
  6615. a?: number);
  6616. /**
  6617. * Adds in place the given Color4 values to the current Color4 object
  6618. * @param right defines the second operand
  6619. * @returns the current updated Color4 object
  6620. */
  6621. addInPlace(right: DeepImmutable<Color4>): Color4;
  6622. /**
  6623. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6624. * @returns the new array
  6625. */
  6626. asArray(): number[];
  6627. /**
  6628. * Stores from the starting index in the given array the Color4 successive values
  6629. * @param array defines the array where to store the r,g,b components
  6630. * @param index defines an optional index in the target array to define where to start storing values
  6631. * @returns the current Color4 object
  6632. */
  6633. toArray(array: number[], index?: number): Color4;
  6634. /**
  6635. * Update the current color with values stored in an array from the starting index of the given array
  6636. * @param array defines the source array
  6637. * @param offset defines an offset in the source array
  6638. * @returns the current Color4 object
  6639. */
  6640. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6641. /**
  6642. * Determines equality between Color4 objects
  6643. * @param otherColor defines the second operand
  6644. * @returns true if the rgba values are equal to the given ones
  6645. */
  6646. equals(otherColor: DeepImmutable<Color4>): boolean;
  6647. /**
  6648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6649. * @param right defines the second operand
  6650. * @returns a new Color4 object
  6651. */
  6652. add(right: DeepImmutable<Color4>): Color4;
  6653. /**
  6654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6655. * @param right defines the second operand
  6656. * @returns a new Color4 object
  6657. */
  6658. subtract(right: DeepImmutable<Color4>): Color4;
  6659. /**
  6660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6661. * @param right defines the second operand
  6662. * @param result defines the Color4 object where to store the result
  6663. * @returns the current Color4 object
  6664. */
  6665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6666. /**
  6667. * Creates a new Color4 with the current Color4 values multiplied by scale
  6668. * @param scale defines the scaling factor to apply
  6669. * @returns a new Color4 object
  6670. */
  6671. scale(scale: number): Color4;
  6672. /**
  6673. * Multiplies the current Color4 values by scale and stores the result in "result"
  6674. * @param scale defines the scaling factor to apply
  6675. * @param result defines the Color4 object where to store the result
  6676. * @returns the current unmodified Color4
  6677. */
  6678. scaleToRef(scale: number, result: Color4): Color4;
  6679. /**
  6680. * Scale the current Color4 values by a factor and add the result to a given Color4
  6681. * @param scale defines the scale factor
  6682. * @param result defines the Color4 object where to store the result
  6683. * @returns the unmodified current Color4
  6684. */
  6685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6686. /**
  6687. * Clamps the rgb values by the min and max values and stores the result into "result"
  6688. * @param min defines minimum clamping value (default is 0)
  6689. * @param max defines maximum clamping value (default is 1)
  6690. * @param result defines color to store the result into.
  6691. * @returns the cuurent Color4
  6692. */
  6693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6694. /**
  6695. * Multipy an Color4 value by another and return a new Color4 object
  6696. * @param color defines the Color4 value to multiply by
  6697. * @returns a new Color4 object
  6698. */
  6699. multiply(color: Color4): Color4;
  6700. /**
  6701. * Multipy a Color4 value by another and push the result in a reference value
  6702. * @param color defines the Color4 value to multiply by
  6703. * @param result defines the Color4 to fill the result in
  6704. * @returns the result Color4
  6705. */
  6706. multiplyToRef(color: Color4, result: Color4): Color4;
  6707. /**
  6708. * Creates a string with the Color4 current values
  6709. * @returns the string representation of the Color4 object
  6710. */
  6711. toString(): string;
  6712. /**
  6713. * Returns the string "Color4"
  6714. * @returns "Color4"
  6715. */
  6716. getClassName(): string;
  6717. /**
  6718. * Compute the Color4 hash code
  6719. * @returns an unique number that can be used to hash Color4 objects
  6720. */
  6721. getHashCode(): number;
  6722. /**
  6723. * Creates a new Color4 copied from the current one
  6724. * @returns a new Color4 object
  6725. */
  6726. clone(): Color4;
  6727. /**
  6728. * Copies the given Color4 values into the current one
  6729. * @param source defines the source Color4 object
  6730. * @returns the current updated Color4 object
  6731. */
  6732. copyFrom(source: Color4): Color4;
  6733. /**
  6734. * Copies the given float values into the current one
  6735. * @param r defines the red component to read from
  6736. * @param g defines the green component to read from
  6737. * @param b defines the blue component to read from
  6738. * @param a defines the alpha component to read from
  6739. * @returns the current updated Color4 object
  6740. */
  6741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6742. /**
  6743. * Copies the given float values into the current one
  6744. * @param r defines the red component to read from
  6745. * @param g defines the green component to read from
  6746. * @param b defines the blue component to read from
  6747. * @param a defines the alpha component to read from
  6748. * @returns the current updated Color4 object
  6749. */
  6750. set(r: number, g: number, b: number, a: number): Color4;
  6751. /**
  6752. * Compute the Color4 hexadecimal code as a string
  6753. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6754. * @returns a string containing the hexadecimal representation of the Color4 object
  6755. */
  6756. toHexString(returnAsColor3?: boolean): string;
  6757. /**
  6758. * Computes a new Color4 converted from the current one to linear space
  6759. * @returns a new Color4 object
  6760. */
  6761. toLinearSpace(): Color4;
  6762. /**
  6763. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6764. * @param convertedColor defines the Color4 object where to store the linear space version
  6765. * @returns the unmodified Color4
  6766. */
  6767. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6768. /**
  6769. * Computes a new Color4 converted from the current one to gamma space
  6770. * @returns a new Color4 object
  6771. */
  6772. toGammaSpace(): Color4;
  6773. /**
  6774. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6775. * @param convertedColor defines the Color4 object where to store the gamma space version
  6776. * @returns the unmodified Color4
  6777. */
  6778. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6779. /**
  6780. * Creates a new Color4 from the string containing valid hexadecimal values
  6781. * @param hex defines a string containing valid hexadecimal values
  6782. * @returns a new Color4 object
  6783. */
  6784. static FromHexString(hex: string): Color4;
  6785. /**
  6786. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6787. * @param left defines the start value
  6788. * @param right defines the end value
  6789. * @param amount defines the gradient factor
  6790. * @returns a new Color4 object
  6791. */
  6792. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6793. /**
  6794. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6795. * @param left defines the start value
  6796. * @param right defines the end value
  6797. * @param amount defines the gradient factor
  6798. * @param result defines the Color4 object where to store data
  6799. */
  6800. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6801. /**
  6802. * Creates a new Color4 from a Color3 and an alpha value
  6803. * @param color3 defines the source Color3 to read from
  6804. * @param alpha defines the alpha component (1.0 by default)
  6805. * @returns a new Color4 object
  6806. */
  6807. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6808. /**
  6809. * Creates a new Color4 from the starting index element of the given array
  6810. * @param array defines the source array to read from
  6811. * @param offset defines the offset in the source array
  6812. * @returns a new Color4 object
  6813. */
  6814. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6815. /**
  6816. * Creates a new Color4 from the starting index element of the given array
  6817. * @param array defines the source array to read from
  6818. * @param offset defines the offset in the source array
  6819. * @param result defines the target Color4 object
  6820. */
  6821. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6822. /**
  6823. * Creates a new Color3 from integer values (< 256)
  6824. * @param r defines the red component to read from (value between 0 and 255)
  6825. * @param g defines the green component to read from (value between 0 and 255)
  6826. * @param b defines the blue component to read from (value between 0 and 255)
  6827. * @param a defines the alpha component to read from (value between 0 and 255)
  6828. * @returns a new Color3 object
  6829. */
  6830. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6831. /**
  6832. * Check the content of a given array and convert it to an array containing RGBA data
  6833. * If the original array was already containing count * 4 values then it is returned directly
  6834. * @param colors defines the array to check
  6835. * @param count defines the number of RGBA data to expect
  6836. * @returns an array containing count * 4 values (RGBA)
  6837. */
  6838. static CheckColors4(colors: number[], count: number): number[];
  6839. }
  6840. /**
  6841. * @hidden
  6842. */
  6843. export class TmpColors {
  6844. static Color3: Color3[];
  6845. static Color4: Color4[];
  6846. }
  6847. }
  6848. declare module "babylonjs/Animations/animationKey" {
  6849. /**
  6850. * Defines an interface which represents an animation key frame
  6851. */
  6852. export interface IAnimationKey {
  6853. /**
  6854. * Frame of the key frame
  6855. */
  6856. frame: number;
  6857. /**
  6858. * Value at the specifies key frame
  6859. */
  6860. value: any;
  6861. /**
  6862. * The input tangent for the cubic hermite spline
  6863. */
  6864. inTangent?: any;
  6865. /**
  6866. * The output tangent for the cubic hermite spline
  6867. */
  6868. outTangent?: any;
  6869. /**
  6870. * The animation interpolation type
  6871. */
  6872. interpolation?: AnimationKeyInterpolation;
  6873. }
  6874. /**
  6875. * Enum for the animation key frame interpolation type
  6876. */
  6877. export enum AnimationKeyInterpolation {
  6878. /**
  6879. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6880. */
  6881. STEP = 1
  6882. }
  6883. }
  6884. declare module "babylonjs/Animations/animationRange" {
  6885. /**
  6886. * Represents the range of an animation
  6887. */
  6888. export class AnimationRange {
  6889. /**The name of the animation range**/
  6890. name: string;
  6891. /**The starting frame of the animation */
  6892. from: number;
  6893. /**The ending frame of the animation*/
  6894. to: number;
  6895. /**
  6896. * Initializes the range of an animation
  6897. * @param name The name of the animation range
  6898. * @param from The starting frame of the animation
  6899. * @param to The ending frame of the animation
  6900. */
  6901. constructor(
  6902. /**The name of the animation range**/
  6903. name: string,
  6904. /**The starting frame of the animation */
  6905. from: number,
  6906. /**The ending frame of the animation*/
  6907. to: number);
  6908. /**
  6909. * Makes a copy of the animation range
  6910. * @returns A copy of the animation range
  6911. */
  6912. clone(): AnimationRange;
  6913. }
  6914. }
  6915. declare module "babylonjs/Animations/animationEvent" {
  6916. /**
  6917. * Composed of a frame, and an action function
  6918. */
  6919. export class AnimationEvent {
  6920. /** The frame for which the event is triggered **/
  6921. frame: number;
  6922. /** The event to perform when triggered **/
  6923. action: (currentFrame: number) => void;
  6924. /** Specifies if the event should be triggered only once**/
  6925. onlyOnce?: boolean | undefined;
  6926. /**
  6927. * Specifies if the animation event is done
  6928. */
  6929. isDone: boolean;
  6930. /**
  6931. * Initializes the animation event
  6932. * @param frame The frame for which the event is triggered
  6933. * @param action The event to perform when triggered
  6934. * @param onlyOnce Specifies if the event should be triggered only once
  6935. */
  6936. constructor(
  6937. /** The frame for which the event is triggered **/
  6938. frame: number,
  6939. /** The event to perform when triggered **/
  6940. action: (currentFrame: number) => void,
  6941. /** Specifies if the event should be triggered only once**/
  6942. onlyOnce?: boolean | undefined);
  6943. /** @hidden */
  6944. _clone(): AnimationEvent;
  6945. }
  6946. }
  6947. declare module "babylonjs/Behaviors/behavior" {
  6948. import { Nullable } from "babylonjs/types";
  6949. /**
  6950. * Interface used to define a behavior
  6951. */
  6952. export interface Behavior<T> {
  6953. /** gets or sets behavior's name */
  6954. name: string;
  6955. /**
  6956. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6957. */
  6958. init(): void;
  6959. /**
  6960. * Called when the behavior is attached to a target
  6961. * @param target defines the target where the behavior is attached to
  6962. */
  6963. attach(target: T): void;
  6964. /**
  6965. * Called when the behavior is detached from its target
  6966. */
  6967. detach(): void;
  6968. }
  6969. /**
  6970. * Interface implemented by classes supporting behaviors
  6971. */
  6972. export interface IBehaviorAware<T> {
  6973. /**
  6974. * Attach a behavior
  6975. * @param behavior defines the behavior to attach
  6976. * @returns the current host
  6977. */
  6978. addBehavior(behavior: Behavior<T>): T;
  6979. /**
  6980. * Remove a behavior from the current object
  6981. * @param behavior defines the behavior to detach
  6982. * @returns the current host
  6983. */
  6984. removeBehavior(behavior: Behavior<T>): T;
  6985. /**
  6986. * Gets a behavior using its name to search
  6987. * @param name defines the name to search
  6988. * @returns the behavior or null if not found
  6989. */
  6990. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6991. }
  6992. }
  6993. declare module "babylonjs/Misc/sliceTools" {
  6994. /**
  6995. * Class used to provide helpers for slicing
  6996. */
  6997. export class SliceTools {
  6998. /**
  6999. * Provides a slice function that will work even on IE
  7000. * @param data defines the array to slice
  7001. * @param start defines the start of the data (optional)
  7002. * @param end defines the end of the data (optional)
  7003. * @returns the new sliced array
  7004. */
  7005. static Slice<T>(data: T, start?: number, end?: number): T;
  7006. /**
  7007. * Provides a slice function that will work even on IE
  7008. * The difference between this and Slice is that this will force-convert to array
  7009. * @param data defines the array to slice
  7010. * @param start defines the start of the data (optional)
  7011. * @param end defines the end of the data (optional)
  7012. * @returns the new sliced array
  7013. */
  7014. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  7015. }
  7016. }
  7017. declare module "babylonjs/Meshes/buffer" {
  7018. import { Nullable, DataArray, FloatArray } from "babylonjs/types";
  7019. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7020. /**
  7021. * Class used to store data that will be store in GPU memory
  7022. */
  7023. export class Buffer {
  7024. private _engine;
  7025. private _buffer;
  7026. /** @hidden */
  7027. _data: Nullable<DataArray>;
  7028. private _updatable;
  7029. private _instanced;
  7030. private _divisor;
  7031. private _isAlreadyOwned;
  7032. /**
  7033. * Gets the byte stride.
  7034. */
  7035. readonly byteStride: number;
  7036. /**
  7037. * Constructor
  7038. * @param engine the engine
  7039. * @param data the data to use for this buffer
  7040. * @param updatable whether the data is updatable
  7041. * @param stride the stride (optional)
  7042. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7043. * @param instanced whether the buffer is instanced (optional)
  7044. * @param useBytes set to true if the stride in in bytes (optional)
  7045. * @param divisor sets an optional divisor for instances (1 by default)
  7046. */
  7047. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  7048. /**
  7049. * Create a new VertexBuffer based on the current buffer
  7050. * @param kind defines the vertex buffer kind (position, normal, etc.)
  7051. * @param offset defines offset in the buffer (0 by default)
  7052. * @param size defines the size in floats of attributes (position is 3 for instance)
  7053. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7054. * @param instanced defines if the vertex buffer contains indexed data
  7055. * @param useBytes defines if the offset and stride are in bytes *
  7056. * @param divisor sets an optional divisor for instances (1 by default)
  7057. * @returns the new vertex buffer
  7058. */
  7059. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7060. /**
  7061. * Gets a boolean indicating if the Buffer is updatable?
  7062. * @returns true if the buffer is updatable
  7063. */
  7064. isUpdatable(): boolean;
  7065. /**
  7066. * Gets current buffer's data
  7067. * @returns a DataArray or null
  7068. */
  7069. getData(): Nullable<DataArray>;
  7070. /**
  7071. * Gets underlying native buffer
  7072. * @returns underlying native buffer
  7073. */
  7074. getBuffer(): Nullable<DataBuffer>;
  7075. /**
  7076. * Gets the stride in float32 units (i.e. byte stride / 4).
  7077. * May not be an integer if the byte stride is not divisible by 4.
  7078. * @returns the stride in float32 units
  7079. * @deprecated Please use byteStride instead.
  7080. */
  7081. getStrideSize(): number;
  7082. /**
  7083. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7084. * @param data defines the data to store
  7085. */
  7086. create(data?: Nullable<DataArray>): void;
  7087. /** @hidden */
  7088. _rebuild(): void;
  7089. /**
  7090. * Update current buffer data
  7091. * @param data defines the data to store
  7092. */
  7093. update(data: DataArray): void;
  7094. /**
  7095. * Updates the data directly.
  7096. * @param data the new data
  7097. * @param offset the new offset
  7098. * @param vertexCount the vertex count (optional)
  7099. * @param useBytes set to true if the offset is in bytes
  7100. */
  7101. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7102. /** @hidden */
  7103. _increaseReferences(): void;
  7104. /**
  7105. * Release all resources
  7106. */
  7107. dispose(): void;
  7108. }
  7109. /**
  7110. * Specialized buffer used to store vertex data
  7111. */
  7112. export class VertexBuffer {
  7113. private static _Counter;
  7114. /** @hidden */
  7115. _buffer: Buffer;
  7116. private _kind;
  7117. private _size;
  7118. private _ownsBuffer;
  7119. private _instanced;
  7120. private _instanceDivisor;
  7121. /**
  7122. * The byte type.
  7123. */
  7124. static readonly BYTE: number;
  7125. /**
  7126. * The unsigned byte type.
  7127. */
  7128. static readonly UNSIGNED_BYTE: number;
  7129. /**
  7130. * The short type.
  7131. */
  7132. static readonly SHORT: number;
  7133. /**
  7134. * The unsigned short type.
  7135. */
  7136. static readonly UNSIGNED_SHORT: number;
  7137. /**
  7138. * The integer type.
  7139. */
  7140. static readonly INT: number;
  7141. /**
  7142. * The unsigned integer type.
  7143. */
  7144. static readonly UNSIGNED_INT: number;
  7145. /**
  7146. * The float type.
  7147. */
  7148. static readonly FLOAT: number;
  7149. /**
  7150. * Gets or sets the instance divisor when in instanced mode
  7151. */
  7152. get instanceDivisor(): number;
  7153. set instanceDivisor(value: number);
  7154. /**
  7155. * Gets the byte stride.
  7156. */
  7157. readonly byteStride: number;
  7158. /**
  7159. * Gets the byte offset.
  7160. */
  7161. readonly byteOffset: number;
  7162. /**
  7163. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7164. */
  7165. readonly normalized: boolean;
  7166. /**
  7167. * Gets the data type of each component in the array.
  7168. */
  7169. readonly type: number;
  7170. /**
  7171. * Gets the unique id of this vertex buffer
  7172. */
  7173. readonly uniqueId: number;
  7174. /**
  7175. * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer
  7176. * All buffers with the same format will have the same hash code
  7177. */
  7178. readonly hashCode: number;
  7179. /**
  7180. * Constructor
  7181. * @param engine the engine
  7182. * @param data the data to use for this vertex buffer
  7183. * @param kind the vertex buffer kind
  7184. * @param updatable whether the data is updatable
  7185. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7186. * @param stride the stride (optional)
  7187. * @param instanced whether the buffer is instanced (optional)
  7188. * @param offset the offset of the data (optional)
  7189. * @param size the number of components (optional)
  7190. * @param type the type of the component (optional)
  7191. * @param normalized whether the data contains normalized data (optional)
  7192. * @param useBytes set to true if stride and offset are in bytes (optional)
  7193. * @param divisor defines the instance divisor to use (1 by default)
  7194. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7195. */
  7196. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  7197. private _computeHashCode;
  7198. /** @hidden */
  7199. _rebuild(): void;
  7200. /**
  7201. * Returns the kind of the VertexBuffer (string)
  7202. * @returns a string
  7203. */
  7204. getKind(): string;
  7205. /**
  7206. * Gets a boolean indicating if the VertexBuffer is updatable?
  7207. * @returns true if the buffer is updatable
  7208. */
  7209. isUpdatable(): boolean;
  7210. /**
  7211. * Gets current buffer's data
  7212. * @returns a DataArray or null
  7213. */
  7214. getData(): Nullable<DataArray>;
  7215. /**
  7216. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7217. * @param totalVertices number of vertices in the buffer to take into account
  7218. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7219. * @returns a float array containing vertex data
  7220. */
  7221. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7222. /**
  7223. * Gets underlying native buffer
  7224. * @returns underlying native buffer
  7225. */
  7226. getBuffer(): Nullable<DataBuffer>;
  7227. /**
  7228. * Gets the stride in float32 units (i.e. byte stride / 4).
  7229. * May not be an integer if the byte stride is not divisible by 4.
  7230. * @returns the stride in float32 units
  7231. * @deprecated Please use byteStride instead.
  7232. */
  7233. getStrideSize(): number;
  7234. /**
  7235. * Returns the offset as a multiple of the type byte length.
  7236. * @returns the offset in bytes
  7237. * @deprecated Please use byteOffset instead.
  7238. */
  7239. getOffset(): number;
  7240. /**
  7241. * Returns the number of components per vertex attribute (integer)
  7242. * @returns the size in float
  7243. */
  7244. getSize(): number;
  7245. /**
  7246. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7247. * @returns true if this buffer is instanced
  7248. */
  7249. getIsInstanced(): boolean;
  7250. /**
  7251. * Returns the instancing divisor, zero for non-instanced (integer).
  7252. * @returns a number
  7253. */
  7254. getInstanceDivisor(): number;
  7255. /**
  7256. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7257. * @param data defines the data to store
  7258. */
  7259. create(data?: DataArray): void;
  7260. /**
  7261. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7262. * This function will create a new buffer if the current one is not updatable
  7263. * @param data defines the data to store
  7264. */
  7265. update(data: DataArray): void;
  7266. /**
  7267. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7268. * Returns the directly updated WebGLBuffer.
  7269. * @param data the new data
  7270. * @param offset the new offset
  7271. * @param useBytes set to true if the offset is in bytes
  7272. */
  7273. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7274. /**
  7275. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7276. */
  7277. dispose(): void;
  7278. /**
  7279. * Enumerates each value of this vertex buffer as numbers.
  7280. * @param count the number of values to enumerate
  7281. * @param callback the callback function called for each value
  7282. */
  7283. forEach(count: number, callback: (value: number, index: number) => void): void;
  7284. /**
  7285. * Positions
  7286. */
  7287. static readonly PositionKind: string;
  7288. /**
  7289. * Normals
  7290. */
  7291. static readonly NormalKind: string;
  7292. /**
  7293. * Tangents
  7294. */
  7295. static readonly TangentKind: string;
  7296. /**
  7297. * Texture coordinates
  7298. */
  7299. static readonly UVKind: string;
  7300. /**
  7301. * Texture coordinates 2
  7302. */
  7303. static readonly UV2Kind: string;
  7304. /**
  7305. * Texture coordinates 3
  7306. */
  7307. static readonly UV3Kind: string;
  7308. /**
  7309. * Texture coordinates 4
  7310. */
  7311. static readonly UV4Kind: string;
  7312. /**
  7313. * Texture coordinates 5
  7314. */
  7315. static readonly UV5Kind: string;
  7316. /**
  7317. * Texture coordinates 6
  7318. */
  7319. static readonly UV6Kind: string;
  7320. /**
  7321. * Colors
  7322. */
  7323. static readonly ColorKind: string;
  7324. /**
  7325. * Matrix indices (for bones)
  7326. */
  7327. static readonly MatricesIndicesKind: string;
  7328. /**
  7329. * Matrix weights (for bones)
  7330. */
  7331. static readonly MatricesWeightsKind: string;
  7332. /**
  7333. * Additional matrix indices (for bones)
  7334. */
  7335. static readonly MatricesIndicesExtraKind: string;
  7336. /**
  7337. * Additional matrix weights (for bones)
  7338. */
  7339. static readonly MatricesWeightsExtraKind: string;
  7340. /**
  7341. * Deduces the stride given a kind.
  7342. * @param kind The kind string to deduce
  7343. * @returns The deduced stride
  7344. */
  7345. static DeduceStride(kind: string): number;
  7346. /**
  7347. * Gets the byte length of the given type.
  7348. * @param type the type
  7349. * @returns the number of bytes
  7350. */
  7351. static GetTypeByteLength(type: number): number;
  7352. /**
  7353. * Enumerates each value of the given parameters as numbers.
  7354. * @param data the data to enumerate
  7355. * @param byteOffset the byte offset of the data
  7356. * @param byteStride the byte stride of the data
  7357. * @param componentCount the number of components per element
  7358. * @param componentType the type of the component
  7359. * @param count the number of values to enumerate
  7360. * @param normalized whether the data is normalized
  7361. * @param callback the callback function called for each value
  7362. */
  7363. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7364. private static _GetFloatValue;
  7365. }
  7366. }
  7367. declare module "babylonjs/Collisions/intersectionInfo" {
  7368. import { Nullable } from "babylonjs/types";
  7369. /**
  7370. * @hidden
  7371. */
  7372. export class IntersectionInfo {
  7373. bu: Nullable<number>;
  7374. bv: Nullable<number>;
  7375. distance: number;
  7376. faceId: number;
  7377. subMeshId: number;
  7378. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7379. }
  7380. }
  7381. declare module "babylonjs/Culling/boundingSphere" {
  7382. import { DeepImmutable } from "babylonjs/types";
  7383. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7384. import { Plane } from "babylonjs/Maths/math.plane";
  7385. /**
  7386. * Class used to store bounding sphere information
  7387. */
  7388. export class BoundingSphere {
  7389. /**
  7390. * Gets the center of the bounding sphere in local space
  7391. */
  7392. readonly center: Vector3;
  7393. /**
  7394. * Radius of the bounding sphere in local space
  7395. */
  7396. radius: number;
  7397. /**
  7398. * Gets the center of the bounding sphere in world space
  7399. */
  7400. readonly centerWorld: Vector3;
  7401. /**
  7402. * Radius of the bounding sphere in world space
  7403. */
  7404. radiusWorld: number;
  7405. /**
  7406. * Gets the minimum vector in local space
  7407. */
  7408. readonly minimum: Vector3;
  7409. /**
  7410. * Gets the maximum vector in local space
  7411. */
  7412. readonly maximum: Vector3;
  7413. private _worldMatrix;
  7414. private static readonly TmpVector3;
  7415. /**
  7416. * Creates a new bounding sphere
  7417. * @param min defines the minimum vector (in local space)
  7418. * @param max defines the maximum vector (in local space)
  7419. * @param worldMatrix defines the new world matrix
  7420. */
  7421. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7422. /**
  7423. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7424. * @param min defines the new minimum vector (in local space)
  7425. * @param max defines the new maximum vector (in local space)
  7426. * @param worldMatrix defines the new world matrix
  7427. */
  7428. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7429. /**
  7430. * Scale the current bounding sphere by applying a scale factor
  7431. * @param factor defines the scale factor to apply
  7432. * @returns the current bounding box
  7433. */
  7434. scale(factor: number): BoundingSphere;
  7435. /**
  7436. * Gets the world matrix of the bounding box
  7437. * @returns a matrix
  7438. */
  7439. getWorldMatrix(): DeepImmutable<Matrix>;
  7440. /** @hidden */
  7441. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7442. /**
  7443. * Tests if the bounding sphere is intersecting the frustum planes
  7444. * @param frustumPlanes defines the frustum planes to test
  7445. * @returns true if there is an intersection
  7446. */
  7447. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7448. /**
  7449. * Tests if the bounding sphere center is in between the frustum planes.
  7450. * Used for optimistic fast inclusion.
  7451. * @param frustumPlanes defines the frustum planes to test
  7452. * @returns true if the sphere center is in between the frustum planes
  7453. */
  7454. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7455. /**
  7456. * Tests if a point is inside the bounding sphere
  7457. * @param point defines the point to test
  7458. * @returns true if the point is inside the bounding sphere
  7459. */
  7460. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7461. /**
  7462. * Checks if two sphere intersect
  7463. * @param sphere0 sphere 0
  7464. * @param sphere1 sphere 1
  7465. * @returns true if the spheres intersect
  7466. */
  7467. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7468. }
  7469. }
  7470. declare module "babylonjs/Culling/boundingBox" {
  7471. import { DeepImmutable } from "babylonjs/types";
  7472. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7473. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7474. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7475. import { Plane } from "babylonjs/Maths/math.plane";
  7476. /**
  7477. * Class used to store bounding box information
  7478. */
  7479. export class BoundingBox implements ICullable {
  7480. /**
  7481. * Gets the 8 vectors representing the bounding box in local space
  7482. */
  7483. readonly vectors: Vector3[];
  7484. /**
  7485. * Gets the center of the bounding box in local space
  7486. */
  7487. readonly center: Vector3;
  7488. /**
  7489. * Gets the center of the bounding box in world space
  7490. */
  7491. readonly centerWorld: Vector3;
  7492. /**
  7493. * Gets the extend size in local space
  7494. */
  7495. readonly extendSize: Vector3;
  7496. /**
  7497. * Gets the extend size in world space
  7498. */
  7499. readonly extendSizeWorld: Vector3;
  7500. /**
  7501. * Gets the OBB (object bounding box) directions
  7502. */
  7503. readonly directions: Vector3[];
  7504. /**
  7505. * Gets the 8 vectors representing the bounding box in world space
  7506. */
  7507. readonly vectorsWorld: Vector3[];
  7508. /**
  7509. * Gets the minimum vector in world space
  7510. */
  7511. readonly minimumWorld: Vector3;
  7512. /**
  7513. * Gets the maximum vector in world space
  7514. */
  7515. readonly maximumWorld: Vector3;
  7516. /**
  7517. * Gets the minimum vector in local space
  7518. */
  7519. readonly minimum: Vector3;
  7520. /**
  7521. * Gets the maximum vector in local space
  7522. */
  7523. readonly maximum: Vector3;
  7524. private _worldMatrix;
  7525. private static readonly TmpVector3;
  7526. /**
  7527. * @hidden
  7528. */
  7529. _tag: number;
  7530. /**
  7531. * Creates a new bounding box
  7532. * @param min defines the minimum vector (in local space)
  7533. * @param max defines the maximum vector (in local space)
  7534. * @param worldMatrix defines the new world matrix
  7535. */
  7536. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7537. /**
  7538. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7539. * @param min defines the new minimum vector (in local space)
  7540. * @param max defines the new maximum vector (in local space)
  7541. * @param worldMatrix defines the new world matrix
  7542. */
  7543. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7544. /**
  7545. * Scale the current bounding box by applying a scale factor
  7546. * @param factor defines the scale factor to apply
  7547. * @returns the current bounding box
  7548. */
  7549. scale(factor: number): BoundingBox;
  7550. /**
  7551. * Gets the world matrix of the bounding box
  7552. * @returns a matrix
  7553. */
  7554. getWorldMatrix(): DeepImmutable<Matrix>;
  7555. /** @hidden */
  7556. _update(world: DeepImmutable<Matrix>): void;
  7557. /**
  7558. * Tests if the bounding box is intersecting the frustum planes
  7559. * @param frustumPlanes defines the frustum planes to test
  7560. * @returns true if there is an intersection
  7561. */
  7562. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7563. /**
  7564. * Tests if the bounding box is entirely inside the frustum planes
  7565. * @param frustumPlanes defines the frustum planes to test
  7566. * @returns true if there is an inclusion
  7567. */
  7568. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7569. /**
  7570. * Tests if a point is inside the bounding box
  7571. * @param point defines the point to test
  7572. * @returns true if the point is inside the bounding box
  7573. */
  7574. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7575. /**
  7576. * Tests if the bounding box intersects with a bounding sphere
  7577. * @param sphere defines the sphere to test
  7578. * @returns true if there is an intersection
  7579. */
  7580. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7581. /**
  7582. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7583. * @param min defines the min vector to use
  7584. * @param max defines the max vector to use
  7585. * @returns true if there is an intersection
  7586. */
  7587. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7588. /**
  7589. * Tests if two bounding boxes are intersections
  7590. * @param box0 defines the first box to test
  7591. * @param box1 defines the second box to test
  7592. * @returns true if there is an intersection
  7593. */
  7594. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7595. /**
  7596. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7597. * @param minPoint defines the minimum vector of the bounding box
  7598. * @param maxPoint defines the maximum vector of the bounding box
  7599. * @param sphereCenter defines the sphere center
  7600. * @param sphereRadius defines the sphere radius
  7601. * @returns true if there is an intersection
  7602. */
  7603. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7604. /**
  7605. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7606. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7607. * @param frustumPlanes defines the frustum planes to test
  7608. * @return true if there is an inclusion
  7609. */
  7610. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7611. /**
  7612. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7613. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7614. * @param frustumPlanes defines the frustum planes to test
  7615. * @return true if there is an intersection
  7616. */
  7617. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Collisions/collider" {
  7621. import { Nullable, IndicesArray } from "babylonjs/types";
  7622. import { Vector3 } from "babylonjs/Maths/math.vector";
  7623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7624. import { Plane } from "babylonjs/Maths/math.plane";
  7625. /** @hidden */
  7626. export class Collider {
  7627. /** Define if a collision was found */
  7628. collisionFound: boolean;
  7629. /**
  7630. * Define last intersection point in local space
  7631. */
  7632. intersectionPoint: Vector3;
  7633. /**
  7634. * Define last collided mesh
  7635. */
  7636. collidedMesh: Nullable<AbstractMesh>;
  7637. private _collisionPoint;
  7638. private _planeIntersectionPoint;
  7639. private _tempVector;
  7640. private _tempVector2;
  7641. private _tempVector3;
  7642. private _tempVector4;
  7643. private _edge;
  7644. private _baseToVertex;
  7645. private _destinationPoint;
  7646. private _slidePlaneNormal;
  7647. private _displacementVector;
  7648. /** @hidden */
  7649. _radius: Vector3;
  7650. /** @hidden */
  7651. _retry: number;
  7652. private _velocity;
  7653. private _basePoint;
  7654. private _epsilon;
  7655. /** @hidden */
  7656. _velocityWorldLength: number;
  7657. /** @hidden */
  7658. _basePointWorld: Vector3;
  7659. private _velocityWorld;
  7660. private _normalizedVelocity;
  7661. /** @hidden */
  7662. _initialVelocity: Vector3;
  7663. /** @hidden */
  7664. _initialPosition: Vector3;
  7665. private _nearestDistance;
  7666. private _collisionMask;
  7667. get collisionMask(): number;
  7668. set collisionMask(mask: number);
  7669. /**
  7670. * Gets the plane normal used to compute the sliding response (in local space)
  7671. */
  7672. get slidePlaneNormal(): Vector3;
  7673. /** @hidden */
  7674. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7675. /** @hidden */
  7676. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7677. /** @hidden */
  7678. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7679. /** @hidden */
  7680. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7681. /** @hidden */
  7682. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7683. /** @hidden */
  7684. _getResponse(pos: Vector3, vel: Vector3): void;
  7685. }
  7686. }
  7687. declare module "babylonjs/Culling/boundingInfo" {
  7688. import { DeepImmutable } from "babylonjs/types";
  7689. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7690. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7691. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7692. import { Plane } from "babylonjs/Maths/math.plane";
  7693. import { Collider } from "babylonjs/Collisions/collider";
  7694. /**
  7695. * Interface for cullable objects
  7696. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7697. */
  7698. export interface ICullable {
  7699. /**
  7700. * Checks if the object or part of the object is in the frustum
  7701. * @param frustumPlanes Camera near/planes
  7702. * @returns true if the object is in frustum otherwise false
  7703. */
  7704. isInFrustum(frustumPlanes: Plane[]): boolean;
  7705. /**
  7706. * Checks if a cullable object (mesh...) is in the camera frustum
  7707. * Unlike isInFrustum this checks the full bounding box
  7708. * @param frustumPlanes Camera near/planes
  7709. * @returns true if the object is in frustum otherwise false
  7710. */
  7711. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7712. }
  7713. /**
  7714. * Info for a bounding data of a mesh
  7715. */
  7716. export class BoundingInfo implements ICullable {
  7717. /**
  7718. * Bounding box for the mesh
  7719. */
  7720. readonly boundingBox: BoundingBox;
  7721. /**
  7722. * Bounding sphere for the mesh
  7723. */
  7724. readonly boundingSphere: BoundingSphere;
  7725. private _isLocked;
  7726. private static readonly TmpVector3;
  7727. /**
  7728. * Constructs bounding info
  7729. * @param minimum min vector of the bounding box/sphere
  7730. * @param maximum max vector of the bounding box/sphere
  7731. * @param worldMatrix defines the new world matrix
  7732. */
  7733. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7734. /**
  7735. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7736. * @param min defines the new minimum vector (in local space)
  7737. * @param max defines the new maximum vector (in local space)
  7738. * @param worldMatrix defines the new world matrix
  7739. */
  7740. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7741. /**
  7742. * min vector of the bounding box/sphere
  7743. */
  7744. get minimum(): Vector3;
  7745. /**
  7746. * max vector of the bounding box/sphere
  7747. */
  7748. get maximum(): Vector3;
  7749. /**
  7750. * If the info is locked and won't be updated to avoid perf overhead
  7751. */
  7752. get isLocked(): boolean;
  7753. set isLocked(value: boolean);
  7754. /**
  7755. * Updates the bounding sphere and box
  7756. * @param world world matrix to be used to update
  7757. */
  7758. update(world: DeepImmutable<Matrix>): void;
  7759. /**
  7760. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7761. * @param center New center of the bounding info
  7762. * @param extend New extend of the bounding info
  7763. * @returns the current bounding info
  7764. */
  7765. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7766. /**
  7767. * Grows the bounding info to include the given point.
  7768. * @param point The point that will be included in the current bounding info
  7769. * @returns the current bounding info
  7770. */
  7771. encapsulate(point: Vector3): BoundingInfo;
  7772. /**
  7773. * Grows the bounding info to encapsulate the given bounding info.
  7774. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7775. * @returns the current bounding info
  7776. */
  7777. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7778. /**
  7779. * Scale the current bounding info by applying a scale factor
  7780. * @param factor defines the scale factor to apply
  7781. * @returns the current bounding info
  7782. */
  7783. scale(factor: number): BoundingInfo;
  7784. /**
  7785. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7786. * @param frustumPlanes defines the frustum to test
  7787. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7788. * @returns true if the bounding info is in the frustum planes
  7789. */
  7790. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7791. /**
  7792. * Gets the world distance between the min and max points of the bounding box
  7793. */
  7794. get diagonalLength(): number;
  7795. /**
  7796. * Checks if a cullable object (mesh...) is in the camera frustum
  7797. * Unlike isInFrustum this checks the full bounding box
  7798. * @param frustumPlanes Camera near/planes
  7799. * @returns true if the object is in frustum otherwise false
  7800. */
  7801. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7802. /** @hidden */
  7803. _checkCollision(collider: Collider): boolean;
  7804. /**
  7805. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7806. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7807. * @param point the point to check intersection with
  7808. * @returns if the point intersects
  7809. */
  7810. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7811. /**
  7812. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7813. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7814. * @param boundingInfo the bounding info to check intersection with
  7815. * @param precise if the intersection should be done using OBB
  7816. * @returns if the bounding info intersects
  7817. */
  7818. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7819. }
  7820. }
  7821. declare module "babylonjs/Maths/math.functions" {
  7822. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7823. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7824. /**
  7825. * Extracts minimum and maximum values from a list of indexed positions
  7826. * @param positions defines the positions to use
  7827. * @param indices defines the indices to the positions
  7828. * @param indexStart defines the start index
  7829. * @param indexCount defines the end index
  7830. * @param bias defines bias value to add to the result
  7831. * @return minimum and maximum values
  7832. */
  7833. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7834. minimum: Vector3;
  7835. maximum: Vector3;
  7836. };
  7837. /**
  7838. * Extracts minimum and maximum values from a list of positions
  7839. * @param positions defines the positions to use
  7840. * @param start defines the start index in the positions array
  7841. * @param count defines the number of positions to handle
  7842. * @param bias defines bias value to add to the result
  7843. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7844. * @return minimum and maximum values
  7845. */
  7846. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7847. minimum: Vector3;
  7848. maximum: Vector3;
  7849. };
  7850. }
  7851. declare module "babylonjs/Misc/guid" {
  7852. /**
  7853. * Class used to manipulate GUIDs
  7854. */
  7855. export class GUID {
  7856. /**
  7857. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7858. * Be aware Math.random() could cause collisions, but:
  7859. * "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"
  7860. * @returns a pseudo random id
  7861. */
  7862. static RandomId(): string;
  7863. }
  7864. }
  7865. declare module "babylonjs/Materials/Textures/baseTexture" {
  7866. import { Observable } from "babylonjs/Misc/observable";
  7867. import { Nullable } from "babylonjs/types";
  7868. import { Scene } from "babylonjs/scene";
  7869. import { Matrix } from "babylonjs/Maths/math.vector";
  7870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7871. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7872. import "babylonjs/Misc/fileTools";
  7873. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7874. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7875. /**
  7876. * Base class of all the textures in babylon.
  7877. * It groups all the common properties the materials, post process, lights... might need
  7878. * in order to make a correct use of the texture.
  7879. */
  7880. export class BaseTexture extends ThinTexture implements IAnimatable {
  7881. /**
  7882. * Default anisotropic filtering level for the application.
  7883. * It is set to 4 as a good tradeoff between perf and quality.
  7884. */
  7885. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7886. /**
  7887. * Gets or sets the unique id of the texture
  7888. */
  7889. uniqueId: number;
  7890. /**
  7891. * Define the name of the texture.
  7892. */
  7893. name: string;
  7894. /**
  7895. * Gets or sets an object used to store user defined information.
  7896. */
  7897. metadata: any;
  7898. /**
  7899. * For internal use only. Please do not use.
  7900. */
  7901. reservedDataStore: any;
  7902. private _hasAlpha;
  7903. /**
  7904. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7905. */
  7906. set hasAlpha(value: boolean);
  7907. get hasAlpha(): boolean;
  7908. /**
  7909. * Defines if the alpha value should be determined via the rgb values.
  7910. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7911. */
  7912. getAlphaFromRGB: boolean;
  7913. /**
  7914. * Intensity or strength of the texture.
  7915. * It is commonly used by materials to fine tune the intensity of the texture
  7916. */
  7917. level: number;
  7918. /**
  7919. * Define the UV channel to use starting from 0 and defaulting to 0.
  7920. * This is part of the texture as textures usually maps to one uv set.
  7921. */
  7922. coordinatesIndex: number;
  7923. protected _coordinatesMode: number;
  7924. /**
  7925. * How a texture is mapped.
  7926. *
  7927. * | Value | Type | Description |
  7928. * | ----- | ----------------------------------- | ----------- |
  7929. * | 0 | EXPLICIT_MODE | |
  7930. * | 1 | SPHERICAL_MODE | |
  7931. * | 2 | PLANAR_MODE | |
  7932. * | 3 | CUBIC_MODE | |
  7933. * | 4 | PROJECTION_MODE | |
  7934. * | 5 | SKYBOX_MODE | |
  7935. * | 6 | INVCUBIC_MODE | |
  7936. * | 7 | EQUIRECTANGULAR_MODE | |
  7937. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7938. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7939. */
  7940. set coordinatesMode(value: number);
  7941. get coordinatesMode(): number;
  7942. /**
  7943. * | Value | Type | Description |
  7944. * | ----- | ------------------ | ----------- |
  7945. * | 0 | CLAMP_ADDRESSMODE | |
  7946. * | 1 | WRAP_ADDRESSMODE | |
  7947. * | 2 | MIRROR_ADDRESSMODE | |
  7948. */
  7949. get wrapU(): number;
  7950. set wrapU(value: number);
  7951. /**
  7952. * | Value | Type | Description |
  7953. * | ----- | ------------------ | ----------- |
  7954. * | 0 | CLAMP_ADDRESSMODE | |
  7955. * | 1 | WRAP_ADDRESSMODE | |
  7956. * | 2 | MIRROR_ADDRESSMODE | |
  7957. */
  7958. get wrapV(): number;
  7959. set wrapV(value: number);
  7960. /**
  7961. * | Value | Type | Description |
  7962. * | ----- | ------------------ | ----------- |
  7963. * | 0 | CLAMP_ADDRESSMODE | |
  7964. * | 1 | WRAP_ADDRESSMODE | |
  7965. * | 2 | MIRROR_ADDRESSMODE | |
  7966. */
  7967. wrapR: number;
  7968. /**
  7969. * With compliant hardware and browser (supporting anisotropic filtering)
  7970. * this defines the level of anisotropic filtering in the texture.
  7971. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7972. */
  7973. anisotropicFilteringLevel: number;
  7974. private _isCube;
  7975. /**
  7976. * Define if the texture is a cube texture or if false a 2d texture.
  7977. */
  7978. get isCube(): boolean;
  7979. set isCube(value: boolean);
  7980. /**
  7981. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7982. */
  7983. get is3D(): boolean;
  7984. set is3D(value: boolean);
  7985. /**
  7986. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7987. */
  7988. get is2DArray(): boolean;
  7989. set is2DArray(value: boolean);
  7990. private _gammaSpace;
  7991. /**
  7992. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7993. * HDR texture are usually stored in linear space.
  7994. * This only impacts the PBR and Background materials
  7995. */
  7996. get gammaSpace(): boolean;
  7997. set gammaSpace(gamma: boolean);
  7998. /**
  7999. * Gets or sets whether or not the texture contains RGBD data.
  8000. */
  8001. get isRGBD(): boolean;
  8002. set isRGBD(value: boolean);
  8003. /**
  8004. * Is Z inverted in the texture (useful in a cube texture).
  8005. */
  8006. invertZ: boolean;
  8007. /**
  8008. * Are mip maps generated for this texture or not.
  8009. */
  8010. get noMipmap(): boolean;
  8011. /**
  8012. * @hidden
  8013. */
  8014. lodLevelInAlpha: boolean;
  8015. /**
  8016. * With prefiltered texture, defined the offset used during the prefiltering steps.
  8017. */
  8018. get lodGenerationOffset(): number;
  8019. set lodGenerationOffset(value: number);
  8020. /**
  8021. * With prefiltered texture, defined the scale used during the prefiltering steps.
  8022. */
  8023. get lodGenerationScale(): number;
  8024. set lodGenerationScale(value: number);
  8025. /**
  8026. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  8027. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  8028. * average roughness values.
  8029. */
  8030. get linearSpecularLOD(): boolean;
  8031. set linearSpecularLOD(value: boolean);
  8032. /**
  8033. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  8034. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  8035. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  8036. */
  8037. get irradianceTexture(): Nullable<BaseTexture>;
  8038. set irradianceTexture(value: Nullable<BaseTexture>);
  8039. /**
  8040. * Define if the texture is a render target.
  8041. */
  8042. isRenderTarget: boolean;
  8043. /**
  8044. * Define the unique id of the texture in the scene.
  8045. */
  8046. get uid(): string;
  8047. /** @hidden */
  8048. _prefiltered: boolean;
  8049. /**
  8050. * Return a string representation of the texture.
  8051. * @returns the texture as a string
  8052. */
  8053. toString(): string;
  8054. /**
  8055. * Get the class name of the texture.
  8056. * @returns "BaseTexture"
  8057. */
  8058. getClassName(): string;
  8059. /**
  8060. * Define the list of animation attached to the texture.
  8061. */
  8062. animations: import("babylonjs/Animations/animation").Animation[];
  8063. /**
  8064. * An event triggered when the texture is disposed.
  8065. */
  8066. onDisposeObservable: Observable<BaseTexture>;
  8067. private _onDisposeObserver;
  8068. /**
  8069. * Callback triggered when the texture has been disposed.
  8070. * Kept for back compatibility, you can use the onDisposeObservable instead.
  8071. */
  8072. set onDispose(callback: () => void);
  8073. protected _scene: Nullable<Scene>;
  8074. /** @hidden */
  8075. _texture: Nullable<InternalTexture>;
  8076. private _uid;
  8077. /**
  8078. * Define if the texture is preventing a material to render or not.
  8079. * If not and the texture is not ready, the engine will use a default black texture instead.
  8080. */
  8081. get isBlocking(): boolean;
  8082. /**
  8083. * Instantiates a new BaseTexture.
  8084. * Base class of all the textures in babylon.
  8085. * It groups all the common properties the materials, post process, lights... might need
  8086. * in order to make a correct use of the texture.
  8087. * @param sceneOrEngine Define the scene or engine the texture belongs to
  8088. */
  8089. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8090. /**
  8091. * Get the scene the texture belongs to.
  8092. * @returns the scene or null if undefined
  8093. */
  8094. getScene(): Nullable<Scene>;
  8095. /** @hidden */
  8096. protected _getEngine(): Nullable<ThinEngine>;
  8097. /**
  8098. * Checks if the texture has the same transform matrix than another texture
  8099. * @param texture texture to check against
  8100. * @returns true if the transforms are the same, else false
  8101. */
  8102. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8103. /**
  8104. * Get the texture transform matrix used to offset tile the texture for instance.
  8105. * @returns the transformation matrix
  8106. */
  8107. getTextureMatrix(): Matrix;
  8108. /**
  8109. * Get the texture reflection matrix used to rotate/transform the reflection.
  8110. * @returns the reflection matrix
  8111. */
  8112. getReflectionTextureMatrix(): Matrix;
  8113. /**
  8114. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8115. * @returns true if ready or not blocking
  8116. */
  8117. isReadyOrNotBlocking(): boolean;
  8118. /**
  8119. * Scales the texture if is `canRescale()`
  8120. * @param ratio the resize factor we want to use to rescale
  8121. */
  8122. scale(ratio: number): void;
  8123. /**
  8124. * Get if the texture can rescale.
  8125. */
  8126. get canRescale(): boolean;
  8127. /** @hidden */
  8128. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8129. /** @hidden */
  8130. _rebuild(): void;
  8131. /**
  8132. * Clones the texture.
  8133. * @returns the cloned texture
  8134. */
  8135. clone(): Nullable<BaseTexture>;
  8136. /**
  8137. * Get the texture underlying type (INT, FLOAT...)
  8138. */
  8139. get textureType(): number;
  8140. /**
  8141. * Get the texture underlying format (RGB, RGBA...)
  8142. */
  8143. get textureFormat(): number;
  8144. /**
  8145. * Indicates that textures need to be re-calculated for all materials
  8146. */
  8147. protected _markAllSubMeshesAsTexturesDirty(): void;
  8148. /**
  8149. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8150. * This will returns an RGBA array buffer containing either in values (0-255) or
  8151. * float values (0-1) depending of the underlying buffer type.
  8152. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8153. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8154. * @param buffer defines a user defined buffer to fill with data (can be null)
  8155. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8156. * @returns The Array buffer promise containing the pixels data.
  8157. */
  8158. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8159. /** @hidden */
  8160. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8161. /** @hidden */
  8162. get _lodTextureHigh(): Nullable<BaseTexture>;
  8163. /** @hidden */
  8164. get _lodTextureMid(): Nullable<BaseTexture>;
  8165. /** @hidden */
  8166. get _lodTextureLow(): Nullable<BaseTexture>;
  8167. /**
  8168. * Dispose the texture and release its associated resources.
  8169. */
  8170. dispose(): void;
  8171. /**
  8172. * Serialize the texture into a JSON representation that can be parsed later on.
  8173. * @returns the JSON representation of the texture
  8174. */
  8175. serialize(): any;
  8176. /**
  8177. * Helper function to be called back once a list of texture contains only ready textures.
  8178. * @param textures Define the list of textures to wait for
  8179. * @param callback Define the callback triggered once the entire list will be ready
  8180. */
  8181. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8182. private static _isScene;
  8183. }
  8184. }
  8185. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  8186. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8187. /** @hidden */
  8188. export class WebGLDataBuffer extends DataBuffer {
  8189. private _buffer;
  8190. constructor(resource: WebGLBuffer);
  8191. get underlyingResource(): any;
  8192. }
  8193. }
  8194. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  8195. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  8196. import { Nullable } from "babylonjs/types";
  8197. import { Effect } from "babylonjs/Materials/effect";
  8198. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  8199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  8200. /** @hidden */
  8201. export class WebGLPipelineContext implements IPipelineContext {
  8202. private _valueCache;
  8203. private _uniforms;
  8204. engine: ThinEngine;
  8205. program: Nullable<WebGLProgram>;
  8206. context?: WebGLRenderingContext;
  8207. vertexShader?: WebGLShader;
  8208. fragmentShader?: WebGLShader;
  8209. isParallelCompiled: boolean;
  8210. onCompiled?: () => void;
  8211. transformFeedback?: WebGLTransformFeedback | null;
  8212. vertexCompilationError: Nullable<string>;
  8213. fragmentCompilationError: Nullable<string>;
  8214. programLinkError: Nullable<string>;
  8215. programValidationError: Nullable<string>;
  8216. get isAsync(): boolean;
  8217. get isReady(): boolean;
  8218. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8219. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8220. [key: string]: number;
  8221. }, uniformsNames: string[], uniforms: {
  8222. [key: string]: Nullable<WebGLUniformLocation>;
  8223. }, samplerList: string[], samplers: {
  8224. [key: string]: number;
  8225. }, attributesNames: string[], attributes: number[]): void;
  8226. /**
  8227. * Release all associated resources.
  8228. **/
  8229. dispose(): void;
  8230. /** @hidden */
  8231. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8232. /** @hidden */
  8233. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8234. /** @hidden */
  8235. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8236. /** @hidden */
  8237. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8238. /**
  8239. * Sets an integer value on a uniform variable.
  8240. * @param uniformName Name of the variable.
  8241. * @param value Value to be set.
  8242. */
  8243. setInt(uniformName: string, value: number): void;
  8244. /**
  8245. * Sets a int2 on a uniform variable.
  8246. * @param uniformName Name of the variable.
  8247. * @param x First int in int2.
  8248. * @param y Second int in int2.
  8249. */
  8250. setInt2(uniformName: string, x: number, y: number): void;
  8251. /**
  8252. * Sets a int3 on a uniform variable.
  8253. * @param uniformName Name of the variable.
  8254. * @param x First int in int3.
  8255. * @param y Second int in int3.
  8256. * @param y Third int in int3.
  8257. */
  8258. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8259. /**
  8260. * Sets a int4 on a uniform variable.
  8261. * @param uniformName Name of the variable.
  8262. * @param x First int in int4.
  8263. * @param y Second int in int4.
  8264. * @param y Third int in int4.
  8265. * @param w Fourth int in int4.
  8266. */
  8267. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8268. /**
  8269. * Sets an int array on a uniform variable.
  8270. * @param uniformName Name of the variable.
  8271. * @param array array to be set.
  8272. */
  8273. setIntArray(uniformName: string, array: Int32Array): void;
  8274. /**
  8275. * 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)
  8276. * @param uniformName Name of the variable.
  8277. * @param array array to be set.
  8278. */
  8279. setIntArray2(uniformName: string, array: Int32Array): void;
  8280. /**
  8281. * 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)
  8282. * @param uniformName Name of the variable.
  8283. * @param array array to be set.
  8284. */
  8285. setIntArray3(uniformName: string, array: Int32Array): void;
  8286. /**
  8287. * 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)
  8288. * @param uniformName Name of the variable.
  8289. * @param array array to be set.
  8290. */
  8291. setIntArray4(uniformName: string, array: Int32Array): void;
  8292. /**
  8293. * Sets an array on a uniform variable.
  8294. * @param uniformName Name of the variable.
  8295. * @param array array to be set.
  8296. */
  8297. setArray(uniformName: string, array: number[]): void;
  8298. /**
  8299. * 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)
  8300. * @param uniformName Name of the variable.
  8301. * @param array array to be set.
  8302. */
  8303. setArray2(uniformName: string, array: number[]): void;
  8304. /**
  8305. * 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)
  8306. * @param uniformName Name of the variable.
  8307. * @param array array to be set.
  8308. * @returns this effect.
  8309. */
  8310. setArray3(uniformName: string, array: number[]): void;
  8311. /**
  8312. * 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)
  8313. * @param uniformName Name of the variable.
  8314. * @param array array to be set.
  8315. */
  8316. setArray4(uniformName: string, array: number[]): void;
  8317. /**
  8318. * Sets matrices on a uniform variable.
  8319. * @param uniformName Name of the variable.
  8320. * @param matrices matrices to be set.
  8321. */
  8322. setMatrices(uniformName: string, matrices: Float32Array): void;
  8323. /**
  8324. * Sets matrix on a uniform variable.
  8325. * @param uniformName Name of the variable.
  8326. * @param matrix matrix to be set.
  8327. */
  8328. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8329. /**
  8330. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8331. * @param uniformName Name of the variable.
  8332. * @param matrix matrix to be set.
  8333. */
  8334. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8335. /**
  8336. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8337. * @param uniformName Name of the variable.
  8338. * @param matrix matrix to be set.
  8339. */
  8340. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8341. /**
  8342. * Sets a float on a uniform variable.
  8343. * @param uniformName Name of the variable.
  8344. * @param value value to be set.
  8345. * @returns this effect.
  8346. */
  8347. setFloat(uniformName: string, value: number): void;
  8348. /**
  8349. * Sets a Vector2 on a uniform variable.
  8350. * @param uniformName Name of the variable.
  8351. * @param vector2 vector2 to be set.
  8352. */
  8353. setVector2(uniformName: string, vector2: IVector2Like): void;
  8354. /**
  8355. * Sets a float2 on a uniform variable.
  8356. * @param uniformName Name of the variable.
  8357. * @param x First float in float2.
  8358. * @param y Second float in float2.
  8359. */
  8360. setFloat2(uniformName: string, x: number, y: number): void;
  8361. /**
  8362. * Sets a Vector3 on a uniform variable.
  8363. * @param uniformName Name of the variable.
  8364. * @param vector3 Value to be set.
  8365. */
  8366. setVector3(uniformName: string, vector3: IVector3Like): void;
  8367. /**
  8368. * Sets a float3 on a uniform variable.
  8369. * @param uniformName Name of the variable.
  8370. * @param x First float in float3.
  8371. * @param y Second float in float3.
  8372. * @param z Third float in float3.
  8373. */
  8374. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8375. /**
  8376. * Sets a Vector4 on a uniform variable.
  8377. * @param uniformName Name of the variable.
  8378. * @param vector4 Value to be set.
  8379. */
  8380. setVector4(uniformName: string, vector4: IVector4Like): void;
  8381. /**
  8382. * Sets a float4 on a uniform variable.
  8383. * @param uniformName Name of the variable.
  8384. * @param x First float in float4.
  8385. * @param y Second float in float4.
  8386. * @param z Third float in float4.
  8387. * @param w Fourth float in float4.
  8388. * @returns this effect.
  8389. */
  8390. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8391. /**
  8392. * Sets a Color3 on a uniform variable.
  8393. * @param uniformName Name of the variable.
  8394. * @param color3 Value to be set.
  8395. */
  8396. setColor3(uniformName: string, color3: IColor3Like): void;
  8397. /**
  8398. * Sets a Color4 on a uniform variable.
  8399. * @param uniformName Name of the variable.
  8400. * @param color3 Value to be set.
  8401. * @param alpha Alpha value to be set.
  8402. */
  8403. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8404. /**
  8405. * Sets a Color4 on a uniform variable
  8406. * @param uniformName defines the name of the variable
  8407. * @param color4 defines the value to be set
  8408. */
  8409. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8410. _getVertexShaderCode(): string | null;
  8411. _getFragmentShaderCode(): string | null;
  8412. }
  8413. }
  8414. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  8415. import { FloatArray, Nullable } from "babylonjs/types";
  8416. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8417. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  8418. module "babylonjs/Engines/thinEngine" {
  8419. interface ThinEngine {
  8420. /**
  8421. * Create an uniform buffer
  8422. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8423. * @param elements defines the content of the uniform buffer
  8424. * @returns the webGL uniform buffer
  8425. */
  8426. createUniformBuffer(elements: FloatArray): DataBuffer;
  8427. /**
  8428. * Create a dynamic uniform buffer
  8429. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8430. * @param elements defines the content of the uniform buffer
  8431. * @returns the webGL uniform buffer
  8432. */
  8433. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8434. /**
  8435. * Update an existing uniform buffer
  8436. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8437. * @param uniformBuffer defines the target uniform buffer
  8438. * @param elements defines the content to update
  8439. * @param offset defines the offset in the uniform buffer where update should start
  8440. * @param count defines the size of the data to update
  8441. */
  8442. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8443. /**
  8444. * Bind an uniform buffer to the current webGL context
  8445. * @param buffer defines the buffer to bind
  8446. */
  8447. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8448. /**
  8449. * Bind a buffer to the current webGL context at a given location
  8450. * @param buffer defines the buffer to bind
  8451. * @param location defines the index where to bind the buffer
  8452. * @param name Name of the uniform variable to bind
  8453. */
  8454. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8455. /**
  8456. * Bind a specific block at a given index in a specific shader program
  8457. * @param pipelineContext defines the pipeline context to use
  8458. * @param blockName defines the block name
  8459. * @param index defines the index where to bind the block
  8460. */
  8461. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8462. }
  8463. }
  8464. }
  8465. declare module "babylonjs/Materials/uniformBuffer" {
  8466. import { Nullable, FloatArray } from "babylonjs/types";
  8467. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  8468. import { Engine } from "babylonjs/Engines/engine";
  8469. import { Effect } from "babylonjs/Materials/effect";
  8470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8471. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  8472. import { Color3 } from "babylonjs/Maths/math.color";
  8473. import { IMatrixLike } from "babylonjs/Maths/math.like";
  8474. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  8475. /**
  8476. * Uniform buffer objects.
  8477. *
  8478. * Handles blocks of uniform on the GPU.
  8479. *
  8480. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8481. *
  8482. * For more information, please refer to :
  8483. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8484. */
  8485. export class UniformBuffer {
  8486. /** @hidden */
  8487. static _updatedUbosInFrame: {
  8488. [name: string]: number;
  8489. };
  8490. private _engine;
  8491. private _buffer;
  8492. private _buffers;
  8493. private _bufferIndex;
  8494. private _createBufferOnWrite;
  8495. private _data;
  8496. private _bufferData;
  8497. private _dynamic?;
  8498. private _uniformLocations;
  8499. private _uniformSizes;
  8500. private _uniformArraySizes;
  8501. private _uniformLocationPointer;
  8502. private _needSync;
  8503. private _noUBO;
  8504. private _currentEffect;
  8505. private _currentEffectName;
  8506. private _name;
  8507. private _currentFrameId;
  8508. /** @hidden */
  8509. _alreadyBound: boolean;
  8510. private static _MAX_UNIFORM_SIZE;
  8511. private static _tempBuffer;
  8512. private static _tempBufferInt32View;
  8513. /**
  8514. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8515. * This is dynamic to allow compat with webgl 1 and 2.
  8516. * You will need to pass the name of the uniform as well as the value.
  8517. */
  8518. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8519. /**
  8520. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8521. * This is dynamic to allow compat with webgl 1 and 2.
  8522. * You will need to pass the name of the uniform as well as the value.
  8523. */
  8524. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8525. /**
  8526. * Lambda to Update a single float in a uniform buffer.
  8527. * This is dynamic to allow compat with webgl 1 and 2.
  8528. * You will need to pass the name of the uniform as well as the value.
  8529. */
  8530. updateFloat: (name: string, x: number) => void;
  8531. /**
  8532. * Lambda to Update a vec2 of float in a uniform buffer.
  8533. * This is dynamic to allow compat with webgl 1 and 2.
  8534. * You will need to pass the name of the uniform as well as the value.
  8535. */
  8536. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8537. /**
  8538. * Lambda to Update a vec3 of float in a uniform buffer.
  8539. * This is dynamic to allow compat with webgl 1 and 2.
  8540. * You will need to pass the name of the uniform as well as the value.
  8541. */
  8542. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8543. /**
  8544. * Lambda to Update a vec4 of float in a uniform buffer.
  8545. * This is dynamic to allow compat with webgl 1 and 2.
  8546. * You will need to pass the name of the uniform as well as the value.
  8547. */
  8548. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8549. /**
  8550. * Lambda to Update an array of float in a uniform buffer.
  8551. * This is dynamic to allow compat with webgl 1 and 2.
  8552. * You will need to pass the name of the uniform as well as the value.
  8553. */
  8554. updateFloatArray: (name: string, array: Float32Array) => void;
  8555. /**
  8556. * Lambda to Update an array of number in a uniform buffer.
  8557. * This is dynamic to allow compat with webgl 1 and 2.
  8558. * You will need to pass the name of the uniform as well as the value.
  8559. */
  8560. updateArray: (name: string, array: number[]) => void;
  8561. /**
  8562. * Lambda to Update an array of number in a uniform buffer.
  8563. * This is dynamic to allow compat with webgl 1 and 2.
  8564. * You will need to pass the name of the uniform as well as the value.
  8565. */
  8566. updateIntArray: (name: string, array: Int32Array) => void;
  8567. /**
  8568. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8569. * This is dynamic to allow compat with webgl 1 and 2.
  8570. * You will need to pass the name of the uniform as well as the value.
  8571. */
  8572. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8573. /**
  8574. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8575. * This is dynamic to allow compat with webgl 1 and 2.
  8576. * You will need to pass the name of the uniform as well as the value.
  8577. */
  8578. updateMatrices: (name: string, mat: Float32Array) => void;
  8579. /**
  8580. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8581. * This is dynamic to allow compat with webgl 1 and 2.
  8582. * You will need to pass the name of the uniform as well as the value.
  8583. */
  8584. updateVector3: (name: string, vector: Vector3) => void;
  8585. /**
  8586. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8587. * This is dynamic to allow compat with webgl 1 and 2.
  8588. * You will need to pass the name of the uniform as well as the value.
  8589. */
  8590. updateVector4: (name: string, vector: Vector4) => void;
  8591. /**
  8592. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8593. * This is dynamic to allow compat with webgl 1 and 2.
  8594. * You will need to pass the name of the uniform as well as the value.
  8595. */
  8596. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8597. /**
  8598. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8599. * This is dynamic to allow compat with webgl 1 and 2.
  8600. * You will need to pass the name of the uniform as well as the value.
  8601. */
  8602. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8603. /**
  8604. * Lambda to Update a int a uniform buffer.
  8605. * This is dynamic to allow compat with webgl 1 and 2.
  8606. * You will need to pass the name of the uniform as well as the value.
  8607. */
  8608. updateInt: (name: string, x: number, suffix?: string) => void;
  8609. /**
  8610. * Lambda to Update a vec2 of int in a uniform buffer.
  8611. * This is dynamic to allow compat with webgl 1 and 2.
  8612. * You will need to pass the name of the uniform as well as the value.
  8613. */
  8614. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8615. /**
  8616. * Lambda to Update a vec3 of int in a uniform buffer.
  8617. * This is dynamic to allow compat with webgl 1 and 2.
  8618. * You will need to pass the name of the uniform as well as the value.
  8619. */
  8620. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8621. /**
  8622. * Lambda to Update a vec4 of int in a uniform buffer.
  8623. * This is dynamic to allow compat with webgl 1 and 2.
  8624. * You will need to pass the name of the uniform as well as the value.
  8625. */
  8626. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8627. /**
  8628. * Instantiates a new Uniform buffer objects.
  8629. *
  8630. * Handles blocks of uniform on the GPU.
  8631. *
  8632. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8633. *
  8634. * For more information, please refer to :
  8635. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8636. * @param engine Define the engine the buffer is associated with
  8637. * @param data Define the data contained in the buffer
  8638. * @param dynamic Define if the buffer is updatable
  8639. * @param name to assign to the buffer (debugging purpose)
  8640. */
  8641. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8642. /**
  8643. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8644. * or just falling back on setUniformXXX calls.
  8645. */
  8646. get useUbo(): boolean;
  8647. /**
  8648. * Indicates if the WebGL underlying uniform buffer is in sync
  8649. * with the javascript cache data.
  8650. */
  8651. get isSync(): boolean;
  8652. /**
  8653. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8654. * Also, a dynamic UniformBuffer will disable cache verification and always
  8655. * update the underlying WebGL uniform buffer to the GPU.
  8656. * @returns if Dynamic, otherwise false
  8657. */
  8658. isDynamic(): boolean;
  8659. /**
  8660. * The data cache on JS side.
  8661. * @returns the underlying data as a float array
  8662. */
  8663. getData(): Float32Array;
  8664. /**
  8665. * The underlying WebGL Uniform buffer.
  8666. * @returns the webgl buffer
  8667. */
  8668. getBuffer(): Nullable<DataBuffer>;
  8669. /**
  8670. * std140 layout specifies how to align data within an UBO structure.
  8671. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8672. * for specs.
  8673. */
  8674. private _fillAlignment;
  8675. /**
  8676. * Adds an uniform in the buffer.
  8677. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8678. * for the layout to be correct !
  8679. * @param name Name of the uniform, as used in the uniform block in the shader.
  8680. * @param size Data size, or data directly.
  8681. * @param arraySize The number of elements in the array, 0 if not an array.
  8682. */
  8683. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8684. /**
  8685. * Adds a Matrix 4x4 to the uniform buffer.
  8686. * @param name Name of the uniform, as used in the uniform block in the shader.
  8687. * @param mat A 4x4 matrix.
  8688. */
  8689. addMatrix(name: string, mat: Matrix): void;
  8690. /**
  8691. * Adds a vec2 to the uniform buffer.
  8692. * @param name Name of the uniform, as used in the uniform block in the shader.
  8693. * @param x Define the x component value of the vec2
  8694. * @param y Define the y component value of the vec2
  8695. */
  8696. addFloat2(name: string, x: number, y: number): void;
  8697. /**
  8698. * Adds a vec3 to the uniform buffer.
  8699. * @param name Name of the uniform, as used in the uniform block in the shader.
  8700. * @param x Define the x component value of the vec3
  8701. * @param y Define the y component value of the vec3
  8702. * @param z Define the z component value of the vec3
  8703. */
  8704. addFloat3(name: string, x: number, y: number, z: number): void;
  8705. /**
  8706. * Adds a vec3 to the uniform buffer.
  8707. * @param name Name of the uniform, as used in the uniform block in the shader.
  8708. * @param color Define the vec3 from a Color
  8709. */
  8710. addColor3(name: string, color: Color3): void;
  8711. /**
  8712. * Adds a vec4 to the uniform buffer.
  8713. * @param name Name of the uniform, as used in the uniform block in the shader.
  8714. * @param color Define the rgb components from a Color
  8715. * @param alpha Define the a component of the vec4
  8716. */
  8717. addColor4(name: string, color: Color3, alpha: number): void;
  8718. /**
  8719. * Adds a vec3 to the uniform buffer.
  8720. * @param name Name of the uniform, as used in the uniform block in the shader.
  8721. * @param vector Define the vec3 components from a Vector
  8722. */
  8723. addVector3(name: string, vector: Vector3): void;
  8724. /**
  8725. * Adds a Matrix 3x3 to the uniform buffer.
  8726. * @param name Name of the uniform, as used in the uniform block in the shader.
  8727. */
  8728. addMatrix3x3(name: string): void;
  8729. /**
  8730. * Adds a Matrix 2x2 to the uniform buffer.
  8731. * @param name Name of the uniform, as used in the uniform block in the shader.
  8732. */
  8733. addMatrix2x2(name: string): void;
  8734. /**
  8735. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8736. */
  8737. create(): void;
  8738. /** @hidden */
  8739. _rebuild(): void;
  8740. /** @hidden */
  8741. get _numBuffers(): number;
  8742. /** @hidden */
  8743. get _indexBuffer(): number;
  8744. /** Gets the name of this buffer */
  8745. get name(): string;
  8746. /**
  8747. * Updates the WebGL Uniform Buffer on the GPU.
  8748. * If the `dynamic` flag is set to true, no cache comparison is done.
  8749. * Otherwise, the buffer will be updated only if the cache differs.
  8750. */
  8751. update(): void;
  8752. private _createNewBuffer;
  8753. private _checkNewFrame;
  8754. /**
  8755. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8756. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8757. * @param data Define the flattened data
  8758. * @param size Define the size of the data.
  8759. */
  8760. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8761. /**
  8762. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8763. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8764. * @param data Define the flattened data
  8765. * @param size Define the size of the data.
  8766. */
  8767. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8768. private _valueCache;
  8769. private _cacheMatrix;
  8770. private _updateMatrix3x3ForUniform;
  8771. private _updateMatrix3x3ForEffect;
  8772. private _updateMatrix2x2ForEffect;
  8773. private _updateMatrix2x2ForUniform;
  8774. private _updateFloatForEffect;
  8775. private _updateFloatForUniform;
  8776. private _updateFloat2ForEffect;
  8777. private _updateFloat2ForUniform;
  8778. private _updateFloat3ForEffect;
  8779. private _updateFloat3ForUniform;
  8780. private _updateFloat4ForEffect;
  8781. private _updateFloat4ForUniform;
  8782. private _updateFloatArrayForEffect;
  8783. private _updateFloatArrayForUniform;
  8784. private _updateArrayForEffect;
  8785. private _updateArrayForUniform;
  8786. private _updateIntArrayForEffect;
  8787. private _updateIntArrayForUniform;
  8788. private _updateMatrixForEffect;
  8789. private _updateMatrixForUniform;
  8790. private _updateMatricesForEffect;
  8791. private _updateMatricesForUniform;
  8792. private _updateVector3ForEffect;
  8793. private _updateVector3ForUniform;
  8794. private _updateVector4ForEffect;
  8795. private _updateVector4ForUniform;
  8796. private _updateColor3ForEffect;
  8797. private _updateColor3ForUniform;
  8798. private _updateColor4ForEffect;
  8799. private _updateColor4ForUniform;
  8800. private _updateIntForEffect;
  8801. private _updateIntForUniform;
  8802. private _updateInt2ForEffect;
  8803. private _updateInt2ForUniform;
  8804. private _updateInt3ForEffect;
  8805. private _updateInt3ForUniform;
  8806. private _updateInt4ForEffect;
  8807. private _updateInt4ForUniform;
  8808. /**
  8809. * Sets a sampler uniform on the effect.
  8810. * @param name Define the name of the sampler.
  8811. * @param texture Define the texture to set in the sampler
  8812. */
  8813. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8814. /**
  8815. * Directly updates the value of the uniform in the cache AND on the GPU.
  8816. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8817. * @param data Define the flattened data
  8818. */
  8819. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8820. /**
  8821. * Binds this uniform buffer to an effect.
  8822. * @param effect Define the effect to bind the buffer to
  8823. * @param name Name of the uniform block in the shader.
  8824. */
  8825. bindToEffect(effect: Effect, name: string): void;
  8826. /**
  8827. * Disposes the uniform buffer.
  8828. */
  8829. dispose(): void;
  8830. }
  8831. }
  8832. declare module "babylonjs/Materials/materialDefines" {
  8833. /**
  8834. * Manages the defines for the Material
  8835. */
  8836. export class MaterialDefines {
  8837. /** @hidden */
  8838. protected _keys: string[];
  8839. private _isDirty;
  8840. /** @hidden */
  8841. _renderId: number;
  8842. /** @hidden */
  8843. _areLightsDirty: boolean;
  8844. /** @hidden */
  8845. _areLightsDisposed: boolean;
  8846. /** @hidden */
  8847. _areAttributesDirty: boolean;
  8848. /** @hidden */
  8849. _areTexturesDirty: boolean;
  8850. /** @hidden */
  8851. _areFresnelDirty: boolean;
  8852. /** @hidden */
  8853. _areMiscDirty: boolean;
  8854. /** @hidden */
  8855. _arePrePassDirty: boolean;
  8856. /** @hidden */
  8857. _areImageProcessingDirty: boolean;
  8858. /** @hidden */
  8859. _normals: boolean;
  8860. /** @hidden */
  8861. _uvs: boolean;
  8862. /** @hidden */
  8863. _needNormals: boolean;
  8864. /** @hidden */
  8865. _needUVs: boolean;
  8866. [id: string]: any;
  8867. /**
  8868. * Specifies if the material needs to be re-calculated
  8869. */
  8870. get isDirty(): boolean;
  8871. /**
  8872. * Marks the material to indicate that it has been re-calculated
  8873. */
  8874. markAsProcessed(): void;
  8875. /**
  8876. * Marks the material to indicate that it needs to be re-calculated
  8877. */
  8878. markAsUnprocessed(): void;
  8879. /**
  8880. * Marks the material to indicate all of its defines need to be re-calculated
  8881. */
  8882. markAllAsDirty(): void;
  8883. /**
  8884. * Marks the material to indicate that image processing needs to be re-calculated
  8885. */
  8886. markAsImageProcessingDirty(): void;
  8887. /**
  8888. * Marks the material to indicate the lights need to be re-calculated
  8889. * @param disposed Defines whether the light is dirty due to dispose or not
  8890. */
  8891. markAsLightDirty(disposed?: boolean): void;
  8892. /**
  8893. * Marks the attribute state as changed
  8894. */
  8895. markAsAttributesDirty(): void;
  8896. /**
  8897. * Marks the texture state as changed
  8898. */
  8899. markAsTexturesDirty(): void;
  8900. /**
  8901. * Marks the fresnel state as changed
  8902. */
  8903. markAsFresnelDirty(): void;
  8904. /**
  8905. * Marks the misc state as changed
  8906. */
  8907. markAsMiscDirty(): void;
  8908. /**
  8909. * Marks the prepass state as changed
  8910. */
  8911. markAsPrePassDirty(): void;
  8912. /**
  8913. * Rebuilds the material defines
  8914. */
  8915. rebuild(): void;
  8916. /**
  8917. * Specifies if two material defines are equal
  8918. * @param other - A material define instance to compare to
  8919. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8920. */
  8921. isEqual(other: MaterialDefines): boolean;
  8922. /**
  8923. * Clones this instance's defines to another instance
  8924. * @param other - material defines to clone values to
  8925. */
  8926. cloneTo(other: MaterialDefines): void;
  8927. /**
  8928. * Resets the material define values
  8929. */
  8930. reset(): void;
  8931. /**
  8932. * Converts the material define values to a string
  8933. * @returns - String of material define information
  8934. */
  8935. toString(): string;
  8936. }
  8937. }
  8938. declare module "babylonjs/Misc/iInspectable" {
  8939. /**
  8940. * Enum that determines the text-wrapping mode to use.
  8941. */
  8942. export enum InspectableType {
  8943. /**
  8944. * Checkbox for booleans
  8945. */
  8946. Checkbox = 0,
  8947. /**
  8948. * Sliders for numbers
  8949. */
  8950. Slider = 1,
  8951. /**
  8952. * Vector3
  8953. */
  8954. Vector3 = 2,
  8955. /**
  8956. * Quaternions
  8957. */
  8958. Quaternion = 3,
  8959. /**
  8960. * Color3
  8961. */
  8962. Color3 = 4,
  8963. /**
  8964. * String
  8965. */
  8966. String = 5
  8967. }
  8968. /**
  8969. * Interface used to define custom inspectable properties.
  8970. * This interface is used by the inspector to display custom property grids
  8971. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8972. */
  8973. export interface IInspectable {
  8974. /**
  8975. * Gets the label to display
  8976. */
  8977. label: string;
  8978. /**
  8979. * Gets the name of the property to edit
  8980. */
  8981. propertyName: string;
  8982. /**
  8983. * Gets the type of the editor to use
  8984. */
  8985. type: InspectableType;
  8986. /**
  8987. * Gets the minimum value of the property when using in "slider" mode
  8988. */
  8989. min?: number;
  8990. /**
  8991. * Gets the maximum value of the property when using in "slider" mode
  8992. */
  8993. max?: number;
  8994. /**
  8995. * Gets the setp to use when using in "slider" mode
  8996. */
  8997. step?: number;
  8998. }
  8999. }
  9000. declare module "babylonjs/Lights/light" {
  9001. import { Nullable } from "babylonjs/types";
  9002. import { Scene } from "babylonjs/scene";
  9003. import { Vector3 } from "babylonjs/Maths/math.vector";
  9004. import { Color3 } from "babylonjs/Maths/math.color";
  9005. import { Node } from "babylonjs/node";
  9006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9007. import { Effect } from "babylonjs/Materials/effect";
  9008. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9009. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9010. /**
  9011. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9012. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9013. * 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.
  9014. */
  9015. export abstract class Light extends Node {
  9016. /**
  9017. * Falloff Default: light is falling off following the material specification:
  9018. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9019. */
  9020. static readonly FALLOFF_DEFAULT: number;
  9021. /**
  9022. * Falloff Physical: light is falling off following the inverse squared distance law.
  9023. */
  9024. static readonly FALLOFF_PHYSICAL: number;
  9025. /**
  9026. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9027. * to enhance interoperability with other engines.
  9028. */
  9029. static readonly FALLOFF_GLTF: number;
  9030. /**
  9031. * Falloff Standard: light is falling off like in the standard material
  9032. * to enhance interoperability with other materials.
  9033. */
  9034. static readonly FALLOFF_STANDARD: number;
  9035. /**
  9036. * If every light affecting the material is in this lightmapMode,
  9037. * material.lightmapTexture adds or multiplies
  9038. * (depends on material.useLightmapAsShadowmap)
  9039. * after every other light calculations.
  9040. */
  9041. static readonly LIGHTMAP_DEFAULT: number;
  9042. /**
  9043. * material.lightmapTexture as only diffuse lighting from this light
  9044. * adds only specular lighting from this light
  9045. * adds dynamic shadows
  9046. */
  9047. static readonly LIGHTMAP_SPECULAR: number;
  9048. /**
  9049. * material.lightmapTexture as only lighting
  9050. * no light calculation from this light
  9051. * only adds dynamic shadows from this light
  9052. */
  9053. static readonly LIGHTMAP_SHADOWSONLY: number;
  9054. /**
  9055. * Each light type uses the default quantity according to its type:
  9056. * point/spot lights use luminous intensity
  9057. * directional lights use illuminance
  9058. */
  9059. static readonly INTENSITYMODE_AUTOMATIC: number;
  9060. /**
  9061. * lumen (lm)
  9062. */
  9063. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9064. /**
  9065. * candela (lm/sr)
  9066. */
  9067. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9068. /**
  9069. * lux (lm/m^2)
  9070. */
  9071. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9072. /**
  9073. * nit (cd/m^2)
  9074. */
  9075. static readonly INTENSITYMODE_LUMINANCE: number;
  9076. /**
  9077. * Light type const id of the point light.
  9078. */
  9079. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9080. /**
  9081. * Light type const id of the directional light.
  9082. */
  9083. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9084. /**
  9085. * Light type const id of the spot light.
  9086. */
  9087. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9088. /**
  9089. * Light type const id of the hemispheric light.
  9090. */
  9091. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9092. /**
  9093. * Diffuse gives the basic color to an object.
  9094. */
  9095. diffuse: Color3;
  9096. /**
  9097. * Specular produces a highlight color on an object.
  9098. * Note: This is note affecting PBR materials.
  9099. */
  9100. specular: Color3;
  9101. /**
  9102. * Defines the falloff type for this light. This lets overriding how punctual light are
  9103. * falling off base on range or angle.
  9104. * This can be set to any values in Light.FALLOFF_x.
  9105. *
  9106. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9107. * other types of materials.
  9108. */
  9109. falloffType: number;
  9110. /**
  9111. * Strength of the light.
  9112. * Note: By default it is define in the framework own unit.
  9113. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9114. */
  9115. intensity: number;
  9116. private _range;
  9117. protected _inverseSquaredRange: number;
  9118. /**
  9119. * Defines how far from the source the light is impacting in scene units.
  9120. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9121. */
  9122. get range(): number;
  9123. /**
  9124. * Defines how far from the source the light is impacting in scene units.
  9125. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9126. */
  9127. set range(value: number);
  9128. /**
  9129. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9130. * of light.
  9131. */
  9132. private _photometricScale;
  9133. private _intensityMode;
  9134. /**
  9135. * Gets the photometric scale used to interpret the intensity.
  9136. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9137. */
  9138. get intensityMode(): number;
  9139. /**
  9140. * Sets the photometric scale used to interpret the intensity.
  9141. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9142. */
  9143. set intensityMode(value: number);
  9144. private _radius;
  9145. /**
  9146. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9147. */
  9148. get radius(): number;
  9149. /**
  9150. * sets the light radius used by PBR Materials to simulate soft area lights.
  9151. */
  9152. set radius(value: number);
  9153. private _renderPriority;
  9154. /**
  9155. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9156. * exceeding the number allowed of the materials.
  9157. */
  9158. renderPriority: number;
  9159. private _shadowEnabled;
  9160. /**
  9161. * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9162. * the current shadow generator.
  9163. */
  9164. get shadowEnabled(): boolean;
  9165. /**
  9166. * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9167. * the current shadow generator.
  9168. */
  9169. set shadowEnabled(value: boolean);
  9170. private _includedOnlyMeshes;
  9171. /**
  9172. * Gets the only meshes impacted by this light.
  9173. */
  9174. get includedOnlyMeshes(): AbstractMesh[];
  9175. /**
  9176. * Sets the only meshes impacted by this light.
  9177. */
  9178. set includedOnlyMeshes(value: AbstractMesh[]);
  9179. private _excludedMeshes;
  9180. /**
  9181. * Gets the meshes not impacted by this light.
  9182. */
  9183. get excludedMeshes(): AbstractMesh[];
  9184. /**
  9185. * Sets the meshes not impacted by this light.
  9186. */
  9187. set excludedMeshes(value: AbstractMesh[]);
  9188. private _excludeWithLayerMask;
  9189. /**
  9190. * Gets the layer id use to find what meshes are not impacted by the light.
  9191. * Inactive if 0
  9192. */
  9193. get excludeWithLayerMask(): number;
  9194. /**
  9195. * Sets the layer id use to find what meshes are not impacted by the light.
  9196. * Inactive if 0
  9197. */
  9198. set excludeWithLayerMask(value: number);
  9199. private _includeOnlyWithLayerMask;
  9200. /**
  9201. * Gets the layer id use to find what meshes are impacted by the light.
  9202. * Inactive if 0
  9203. */
  9204. get includeOnlyWithLayerMask(): number;
  9205. /**
  9206. * Sets the layer id use to find what meshes are impacted by the light.
  9207. * Inactive if 0
  9208. */
  9209. set includeOnlyWithLayerMask(value: number);
  9210. private _lightmapMode;
  9211. /**
  9212. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9213. */
  9214. get lightmapMode(): number;
  9215. /**
  9216. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9217. */
  9218. set lightmapMode(value: number);
  9219. /**
  9220. * Shadow generator associated to the light.
  9221. * @hidden Internal use only.
  9222. */
  9223. _shadowGenerator: Nullable<IShadowGenerator>;
  9224. /**
  9225. * @hidden Internal use only.
  9226. */
  9227. _excludedMeshesIds: string[];
  9228. /**
  9229. * @hidden Internal use only.
  9230. */
  9231. _includedOnlyMeshesIds: string[];
  9232. /**
  9233. * The current light uniform buffer.
  9234. * @hidden Internal use only.
  9235. */
  9236. _uniformBuffer: UniformBuffer;
  9237. /** @hidden */
  9238. _renderId: number;
  9239. /**
  9240. * Creates a Light object in the scene.
  9241. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9242. * @param name The friendly name of the light
  9243. * @param scene The scene the light belongs too
  9244. */
  9245. constructor(name: string, scene: Scene);
  9246. protected abstract _buildUniformLayout(): void;
  9247. /**
  9248. * Sets the passed Effect "effect" with the Light information.
  9249. * @param effect The effect to update
  9250. * @param lightIndex The index of the light in the effect to update
  9251. * @returns The light
  9252. */
  9253. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9254. /**
  9255. * Sets the passed Effect "effect" with the Light textures.
  9256. * @param effect The effect to update
  9257. * @param lightIndex The index of the light in the effect to update
  9258. * @returns The light
  9259. */
  9260. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9261. /**
  9262. * Binds the lights information from the scene to the effect for the given mesh.
  9263. * @param lightIndex Light index
  9264. * @param scene The scene where the light belongs to
  9265. * @param effect The effect we are binding the data to
  9266. * @param useSpecular Defines if specular is supported
  9267. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9268. */
  9269. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9270. /**
  9271. * Sets the passed Effect "effect" with the Light information.
  9272. * @param effect The effect to update
  9273. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9274. * @returns The light
  9275. */
  9276. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9277. /**
  9278. * Returns the string "Light".
  9279. * @returns the class name
  9280. */
  9281. getClassName(): string;
  9282. /** @hidden */
  9283. readonly _isLight: boolean;
  9284. /**
  9285. * Converts the light information to a readable string for debug purpose.
  9286. * @param fullDetails Supports for multiple levels of logging within scene loading
  9287. * @returns the human readable light info
  9288. */
  9289. toString(fullDetails?: boolean): string;
  9290. /** @hidden */
  9291. protected _syncParentEnabledState(): void;
  9292. /**
  9293. * Set the enabled state of this node.
  9294. * @param value - the new enabled state
  9295. */
  9296. setEnabled(value: boolean): void;
  9297. /**
  9298. * Returns the Light associated shadow generator if any.
  9299. * @return the associated shadow generator.
  9300. */
  9301. getShadowGenerator(): Nullable<IShadowGenerator>;
  9302. /**
  9303. * Returns a Vector3, the absolute light position in the World.
  9304. * @returns the world space position of the light
  9305. */
  9306. getAbsolutePosition(): Vector3;
  9307. /**
  9308. * Specifies if the light will affect the passed mesh.
  9309. * @param mesh The mesh to test against the light
  9310. * @return true the mesh is affected otherwise, false.
  9311. */
  9312. canAffectMesh(mesh: AbstractMesh): boolean;
  9313. /**
  9314. * Sort function to order lights for rendering.
  9315. * @param a First Light object to compare to second.
  9316. * @param b Second Light object to compare first.
  9317. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9318. */
  9319. static CompareLightsPriority(a: Light, b: Light): number;
  9320. /**
  9321. * Releases resources associated with this node.
  9322. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9323. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9324. */
  9325. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9326. /**
  9327. * Returns the light type ID (integer).
  9328. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9329. */
  9330. getTypeID(): number;
  9331. /**
  9332. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9333. * @returns the scaled intensity in intensity mode unit
  9334. */
  9335. getScaledIntensity(): number;
  9336. /**
  9337. * Returns a new Light object, named "name", from the current one.
  9338. * @param name The name of the cloned light
  9339. * @param newParent The parent of this light, if it has one
  9340. * @returns the new created light
  9341. */
  9342. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9343. /**
  9344. * Serializes the current light into a Serialization object.
  9345. * @returns the serialized object.
  9346. */
  9347. serialize(): any;
  9348. /**
  9349. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9350. * This new light is named "name" and added to the passed scene.
  9351. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9352. * @param name The friendly name of the light
  9353. * @param scene The scene the new light will belong to
  9354. * @returns the constructor function
  9355. */
  9356. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9357. /**
  9358. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9359. * @param parsedLight The JSON representation of the light
  9360. * @param scene The scene to create the parsed light in
  9361. * @returns the created light after parsing
  9362. */
  9363. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9364. private _hookArrayForExcluded;
  9365. private _hookArrayForIncludedOnly;
  9366. private _resyncMeshes;
  9367. /**
  9368. * Forces the meshes to update their light related information in their rendering used effects
  9369. * @hidden Internal Use Only
  9370. */
  9371. _markMeshesAsLightDirty(): void;
  9372. /**
  9373. * Recomputes the cached photometric scale if needed.
  9374. */
  9375. private _computePhotometricScale;
  9376. /**
  9377. * Returns the Photometric Scale according to the light type and intensity mode.
  9378. */
  9379. private _getPhotometricScale;
  9380. /**
  9381. * Reorder the light in the scene according to their defined priority.
  9382. * @hidden Internal Use Only
  9383. */
  9384. _reorderLightsInScene(): void;
  9385. /**
  9386. * Prepares the list of defines specific to the light type.
  9387. * @param defines the list of defines
  9388. * @param lightIndex defines the index of the light for the effect
  9389. */
  9390. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9391. }
  9392. }
  9393. declare module "babylonjs/Maths/math.axis" {
  9394. import { Vector3 } from "babylonjs/Maths/math.vector";
  9395. /** Defines supported spaces */
  9396. export enum Space {
  9397. /** Local (object) space */
  9398. LOCAL = 0,
  9399. /** World space */
  9400. WORLD = 1,
  9401. /** Bone space */
  9402. BONE = 2
  9403. }
  9404. /** Defines the 3 main axes */
  9405. export class Axis {
  9406. /** X axis */
  9407. static X: Vector3;
  9408. /** Y axis */
  9409. static Y: Vector3;
  9410. /** Z axis */
  9411. static Z: Vector3;
  9412. }
  9413. /**
  9414. * Defines cartesian components.
  9415. */
  9416. export enum Coordinate {
  9417. /** X axis */
  9418. X = 0,
  9419. /** Y axis */
  9420. Y = 1,
  9421. /** Z axis */
  9422. Z = 2
  9423. }
  9424. }
  9425. declare module "babylonjs/Lights/shadowLight" {
  9426. import { Camera } from "babylonjs/Cameras/camera";
  9427. import { Scene } from "babylonjs/scene";
  9428. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9430. import { Light } from "babylonjs/Lights/light";
  9431. /**
  9432. * Interface describing all the common properties and methods a shadow light needs to implement.
  9433. * This helps both the shadow generator and materials to generate the corresponding shadow maps
  9434. * as well as binding the different shadow properties to the effects.
  9435. */
  9436. export interface IShadowLight extends Light {
  9437. /**
  9438. * The light id in the scene (used in scene.findLightById for instance)
  9439. */
  9440. id: string;
  9441. /**
  9442. * The position the shadow will be casted from.
  9443. */
  9444. position: Vector3;
  9445. /**
  9446. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9447. */
  9448. direction: Vector3;
  9449. /**
  9450. * The transformed position. Position of the light in world space taking parenting in account.
  9451. */
  9452. transformedPosition: Vector3;
  9453. /**
  9454. * The transformed direction. Direction of the light in world space taking parenting in account.
  9455. */
  9456. transformedDirection: Vector3;
  9457. /**
  9458. * The friendly name of the light in the scene.
  9459. */
  9460. name: string;
  9461. /**
  9462. * Defines the shadow projection clipping minimum z value.
  9463. */
  9464. shadowMinZ: number;
  9465. /**
  9466. * Defines the shadow projection clipping maximum z value.
  9467. */
  9468. shadowMaxZ: number;
  9469. /**
  9470. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9471. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9472. */
  9473. computeTransformedInformation(): boolean;
  9474. /**
  9475. * Gets the scene the light belongs to.
  9476. * @returns The scene
  9477. */
  9478. getScene(): Scene;
  9479. /**
  9480. * Callback defining a custom Projection Matrix Builder.
  9481. * This can be used to override the default projection matrix computation.
  9482. */
  9483. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9484. /**
  9485. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9486. * @param matrix The matrix to updated with the projection information
  9487. * @param viewMatrix The transform matrix of the light
  9488. * @param renderList The list of mesh to render in the map
  9489. * @returns The current light
  9490. */
  9491. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9492. /**
  9493. * Gets the current depth scale used in ESM.
  9494. * @returns The scale
  9495. */
  9496. getDepthScale(): number;
  9497. /**
  9498. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9499. * @returns true if a cube texture needs to be use
  9500. */
  9501. needCube(): boolean;
  9502. /**
  9503. * Detects if the projection matrix requires to be recomputed this frame.
  9504. * @returns true if it requires to be recomputed otherwise, false.
  9505. */
  9506. needProjectionMatrixCompute(): boolean;
  9507. /**
  9508. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9509. */
  9510. forceProjectionMatrixCompute(): void;
  9511. /**
  9512. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9513. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9514. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9515. */
  9516. getShadowDirection(faceIndex?: number): Vector3;
  9517. /**
  9518. * Gets the minZ used for shadow according to both the scene and the light.
  9519. * @param activeCamera The camera we are returning the min for
  9520. * @returns the depth min z
  9521. */
  9522. getDepthMinZ(activeCamera: Camera): number;
  9523. /**
  9524. * Gets the maxZ used for shadow according to both the scene and the light.
  9525. * @param activeCamera The camera we are returning the max for
  9526. * @returns the depth max z
  9527. */
  9528. getDepthMaxZ(activeCamera: Camera): number;
  9529. }
  9530. /**
  9531. * Base implementation IShadowLight
  9532. * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.
  9533. */
  9534. export abstract class ShadowLight extends Light implements IShadowLight {
  9535. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9536. protected _position: Vector3;
  9537. protected _setPosition(value: Vector3): void;
  9538. /**
  9539. * Sets the position the shadow will be casted from. Also use as the light position for both
  9540. * point and spot lights.
  9541. */
  9542. get position(): Vector3;
  9543. /**
  9544. * Sets the position the shadow will be casted from. Also use as the light position for both
  9545. * point and spot lights.
  9546. */
  9547. set position(value: Vector3);
  9548. protected _direction: Vector3;
  9549. protected _setDirection(value: Vector3): void;
  9550. /**
  9551. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9552. * Also use as the light direction on spot and directional lights.
  9553. */
  9554. get direction(): Vector3;
  9555. /**
  9556. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9557. * Also use as the light direction on spot and directional lights.
  9558. */
  9559. set direction(value: Vector3);
  9560. protected _shadowMinZ: number;
  9561. /**
  9562. * Gets the shadow projection clipping minimum z value.
  9563. */
  9564. get shadowMinZ(): number;
  9565. /**
  9566. * Sets the shadow projection clipping minimum z value.
  9567. */
  9568. set shadowMinZ(value: number);
  9569. protected _shadowMaxZ: number;
  9570. /**
  9571. * Sets the shadow projection clipping maximum z value.
  9572. */
  9573. get shadowMaxZ(): number;
  9574. /**
  9575. * Gets the shadow projection clipping maximum z value.
  9576. */
  9577. set shadowMaxZ(value: number);
  9578. /**
  9579. * Callback defining a custom Projection Matrix Builder.
  9580. * This can be used to override the default projection matrix computation.
  9581. */
  9582. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9583. /**
  9584. * The transformed position. Position of the light in world space taking parenting in account.
  9585. */
  9586. transformedPosition: Vector3;
  9587. /**
  9588. * The transformed direction. Direction of the light in world space taking parenting in account.
  9589. */
  9590. transformedDirection: Vector3;
  9591. private _needProjectionMatrixCompute;
  9592. /**
  9593. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9594. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9595. */
  9596. computeTransformedInformation(): boolean;
  9597. /**
  9598. * Return the depth scale used for the shadow map.
  9599. * @returns the depth scale.
  9600. */
  9601. getDepthScale(): number;
  9602. /**
  9603. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9604. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9605. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9606. */
  9607. getShadowDirection(faceIndex?: number): Vector3;
  9608. /**
  9609. * Returns the ShadowLight absolute position in the World.
  9610. * @returns the position vector in world space
  9611. */
  9612. getAbsolutePosition(): Vector3;
  9613. /**
  9614. * Sets the ShadowLight direction toward the passed target.
  9615. * @param target The point to target in local space
  9616. * @returns the updated ShadowLight direction
  9617. */
  9618. setDirectionToTarget(target: Vector3): Vector3;
  9619. /**
  9620. * Returns the light rotation in euler definition.
  9621. * @returns the x y z rotation in local space.
  9622. */
  9623. getRotation(): Vector3;
  9624. /**
  9625. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9626. * @returns true if a cube texture needs to be use
  9627. */
  9628. needCube(): boolean;
  9629. /**
  9630. * Detects if the projection matrix requires to be recomputed this frame.
  9631. * @returns true if it requires to be recomputed otherwise, false.
  9632. */
  9633. needProjectionMatrixCompute(): boolean;
  9634. /**
  9635. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9636. */
  9637. forceProjectionMatrixCompute(): void;
  9638. /** @hidden */
  9639. _initCache(): void;
  9640. /** @hidden */
  9641. _isSynchronized(): boolean;
  9642. /**
  9643. * Computes the world matrix of the node
  9644. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9645. * @returns the world matrix
  9646. */
  9647. computeWorldMatrix(force?: boolean): Matrix;
  9648. /**
  9649. * Gets the minZ used for shadow according to both the scene and the light.
  9650. * @param activeCamera The camera we are returning the min for
  9651. * @returns the depth min z
  9652. */
  9653. getDepthMinZ(activeCamera: Camera): number;
  9654. /**
  9655. * Gets the maxZ used for shadow according to both the scene and the light.
  9656. * @param activeCamera The camera we are returning the max for
  9657. * @returns the depth max z
  9658. */
  9659. getDepthMaxZ(activeCamera: Camera): number;
  9660. /**
  9661. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9662. * @param matrix The matrix to updated with the projection information
  9663. * @param viewMatrix The transform matrix of the light
  9664. * @param renderList The list of mesh to render in the map
  9665. * @returns The current light
  9666. */
  9667. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9668. }
  9669. }
  9670. declare module "babylonjs/Materials/prePassConfiguration" {
  9671. import { Matrix } from "babylonjs/Maths/math.vector";
  9672. import { Mesh } from "babylonjs/Meshes/mesh";
  9673. import { Scene } from "babylonjs/scene";
  9674. import { Effect } from "babylonjs/Materials/effect";
  9675. /**
  9676. * Configuration needed for prepass-capable materials
  9677. */
  9678. export class PrePassConfiguration {
  9679. /**
  9680. * Previous world matrices of meshes carrying this material
  9681. * Used for computing velocity
  9682. */
  9683. previousWorldMatrices: {
  9684. [index: number]: Matrix;
  9685. };
  9686. /**
  9687. * Previous view project matrix
  9688. * Used for computing velocity
  9689. */
  9690. previousViewProjection: Matrix;
  9691. /**
  9692. * Previous bones of meshes carrying this material
  9693. * Used for computing velocity
  9694. */
  9695. previousBones: {
  9696. [index: number]: Float32Array;
  9697. };
  9698. /**
  9699. * Add the required uniforms to the current list.
  9700. * @param uniforms defines the current uniform list.
  9701. */
  9702. static AddUniforms(uniforms: string[]): void;
  9703. /**
  9704. * Add the required samplers to the current list.
  9705. * @param samplers defines the current sampler list.
  9706. */
  9707. static AddSamplers(samplers: string[]): void;
  9708. /**
  9709. * Binds the material data.
  9710. * @param effect defines the effect to update
  9711. * @param scene defines the scene the material belongs to.
  9712. * @param mesh The mesh
  9713. * @param world World matrix of this mesh
  9714. * @param isFrozen Is the material frozen
  9715. */
  9716. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9717. }
  9718. }
  9719. declare module "babylonjs/Cameras/targetCamera" {
  9720. import { Nullable } from "babylonjs/types";
  9721. import { Camera } from "babylonjs/Cameras/camera";
  9722. import { Scene } from "babylonjs/scene";
  9723. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9724. /**
  9725. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9726. * This is the base of the follow, arc rotate cameras and Free camera
  9727. * @see https://doc.babylonjs.com/features/cameras
  9728. */
  9729. export class TargetCamera extends Camera {
  9730. private static _RigCamTransformMatrix;
  9731. private static _TargetTransformMatrix;
  9732. private static _TargetFocalPoint;
  9733. private _tmpUpVector;
  9734. private _tmpTargetVector;
  9735. /**
  9736. * Define the current direction the camera is moving to
  9737. */
  9738. cameraDirection: Vector3;
  9739. /**
  9740. * Define the current rotation the camera is rotating to
  9741. */
  9742. cameraRotation: Vector2;
  9743. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9744. ignoreParentScaling: boolean;
  9745. /**
  9746. * When set, the up vector of the camera will be updated by the rotation of the camera
  9747. */
  9748. updateUpVectorFromRotation: boolean;
  9749. private _tmpQuaternion;
  9750. /**
  9751. * Define the current rotation of the camera
  9752. */
  9753. rotation: Vector3;
  9754. /**
  9755. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9756. */
  9757. rotationQuaternion: Quaternion;
  9758. /**
  9759. * Define the current speed of the camera
  9760. */
  9761. speed: number;
  9762. /**
  9763. * Add constraint to the camera to prevent it to move freely in all directions and
  9764. * around all axis.
  9765. */
  9766. noRotationConstraint: boolean;
  9767. /**
  9768. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9769. * panning
  9770. */
  9771. invertRotation: boolean;
  9772. /**
  9773. * Speed multiplier for inverse camera panning
  9774. */
  9775. inverseRotationSpeed: number;
  9776. /**
  9777. * Define the current target of the camera as an object or a position.
  9778. */
  9779. lockedTarget: any;
  9780. /** @hidden */
  9781. _currentTarget: Vector3;
  9782. /** @hidden */
  9783. _initialFocalDistance: number;
  9784. /** @hidden */
  9785. _viewMatrix: Matrix;
  9786. /** @hidden */
  9787. _camMatrix: Matrix;
  9788. /** @hidden */
  9789. _cameraTransformMatrix: Matrix;
  9790. /** @hidden */
  9791. _cameraRotationMatrix: Matrix;
  9792. /** @hidden */
  9793. _referencePoint: Vector3;
  9794. /** @hidden */
  9795. _transformedReferencePoint: Vector3;
  9796. /** @hidden */
  9797. _reset: () => void;
  9798. private _defaultUp;
  9799. /**
  9800. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9801. * This is the base of the follow, arc rotate cameras and Free camera
  9802. * @see https://doc.babylonjs.com/features/cameras
  9803. * @param name Defines the name of the camera in the scene
  9804. * @param position Defines the start position of the camera in the scene
  9805. * @param scene Defines the scene the camera belongs to
  9806. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  9807. */
  9808. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9809. /**
  9810. * Gets the position in front of the camera at a given distance.
  9811. * @param distance The distance from the camera we want the position to be
  9812. * @returns the position
  9813. */
  9814. getFrontPosition(distance: number): Vector3;
  9815. /** @hidden */
  9816. _getLockedTargetPosition(): Nullable<Vector3>;
  9817. private _storedPosition;
  9818. private _storedRotation;
  9819. private _storedRotationQuaternion;
  9820. /**
  9821. * Store current camera state of the camera (fov, position, rotation, etc..)
  9822. * @returns the camera
  9823. */
  9824. storeState(): Camera;
  9825. /**
  9826. * Restored camera state. You must call storeState() first
  9827. * @returns whether it was successful or not
  9828. * @hidden
  9829. */
  9830. _restoreStateValues(): boolean;
  9831. /** @hidden */
  9832. _initCache(): void;
  9833. /** @hidden */
  9834. _updateCache(ignoreParentClass?: boolean): void;
  9835. /** @hidden */
  9836. _isSynchronizedViewMatrix(): boolean;
  9837. /** @hidden */
  9838. _computeLocalCameraSpeed(): number;
  9839. /**
  9840. * Defines the target the camera should look at.
  9841. * @param target Defines the new target as a Vector or a mesh
  9842. */
  9843. setTarget(target: Vector3): void;
  9844. /**
  9845. * Defines the target point of the camera.
  9846. * The camera looks towards it form the radius distance.
  9847. */
  9848. get target(): Vector3;
  9849. set target(value: Vector3);
  9850. /**
  9851. * Return the current target position of the camera. This value is expressed in local space.
  9852. * @returns the target position
  9853. */
  9854. getTarget(): Vector3;
  9855. /** @hidden */
  9856. _decideIfNeedsToMove(): boolean;
  9857. /** @hidden */
  9858. _updatePosition(): void;
  9859. /** @hidden */
  9860. _checkInputs(): void;
  9861. protected _updateCameraRotationMatrix(): void;
  9862. /**
  9863. * 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)
  9864. * @returns the current camera
  9865. */
  9866. private _rotateUpVectorWithCameraRotationMatrix;
  9867. private _cachedRotationZ;
  9868. private _cachedQuaternionRotationZ;
  9869. /** @hidden */
  9870. _getViewMatrix(): Matrix;
  9871. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9872. /**
  9873. * @hidden
  9874. */
  9875. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9876. /**
  9877. * @hidden
  9878. */
  9879. _updateRigCameras(): void;
  9880. private _getRigCamPositionAndTarget;
  9881. /**
  9882. * Gets the current object class name.
  9883. * @return the class name
  9884. */
  9885. getClassName(): string;
  9886. }
  9887. }
  9888. declare module "babylonjs/Cameras/cameraInputsManager" {
  9889. import { Nullable } from "babylonjs/types";
  9890. import { Camera } from "babylonjs/Cameras/camera";
  9891. /**
  9892. * @ignore
  9893. * This is a list of all the different input types that are available in the application.
  9894. * Fo instance: ArcRotateCameraGamepadInput...
  9895. */
  9896. export var CameraInputTypes: {};
  9897. /**
  9898. * This is the contract to implement in order to create a new input class.
  9899. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9900. */
  9901. export interface ICameraInput<TCamera extends Camera> {
  9902. /**
  9903. * Defines the camera the input is attached to.
  9904. */
  9905. camera: Nullable<TCamera>;
  9906. /**
  9907. * Gets the class name of the current input.
  9908. * @returns the class name
  9909. */
  9910. getClassName(): string;
  9911. /**
  9912. * Get the friendly name associated with the input class.
  9913. * @returns the input friendly name
  9914. */
  9915. getSimpleName(): string;
  9916. /**
  9917. * Attach the input controls to a specific dom element to get the input from.
  9918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9919. */
  9920. attachControl(noPreventDefault?: boolean): void;
  9921. /**
  9922. * Detach the current controls from the specified dom element.
  9923. */
  9924. detachControl(): void;
  9925. /**
  9926. * Update the current camera state depending on the inputs that have been used this frame.
  9927. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9928. */
  9929. checkInputs?: () => void;
  9930. }
  9931. /**
  9932. * Represents a map of input types to input instance or input index to input instance.
  9933. */
  9934. export interface CameraInputsMap<TCamera extends Camera> {
  9935. /**
  9936. * Accessor to the input by input type.
  9937. */
  9938. [name: string]: ICameraInput<TCamera>;
  9939. /**
  9940. * Accessor to the input by input index.
  9941. */
  9942. [idx: number]: ICameraInput<TCamera>;
  9943. }
  9944. /**
  9945. * This represents the input manager used within a camera.
  9946. * It helps dealing with all the different kind of input attached to a camera.
  9947. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9948. */
  9949. export class CameraInputsManager<TCamera extends Camera> {
  9950. /**
  9951. * Defines the list of inputs attached to the camera.
  9952. */
  9953. attached: CameraInputsMap<TCamera>;
  9954. /**
  9955. * Defines the dom element the camera is collecting inputs from.
  9956. * This is null if the controls have not been attached.
  9957. */
  9958. attachedToElement: boolean;
  9959. /**
  9960. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9961. */
  9962. noPreventDefault: boolean;
  9963. /**
  9964. * Defined the camera the input manager belongs to.
  9965. */
  9966. camera: TCamera;
  9967. /**
  9968. * Update the current camera state depending on the inputs that have been used this frame.
  9969. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9970. */
  9971. checkInputs: () => void;
  9972. /**
  9973. * Instantiate a new Camera Input Manager.
  9974. * @param camera Defines the camera the input manager belongs to
  9975. */
  9976. constructor(camera: TCamera);
  9977. /**
  9978. * Add an input method to a camera
  9979. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9980. * @param input camera input method
  9981. */
  9982. add(input: ICameraInput<TCamera>): void;
  9983. /**
  9984. * Remove a specific input method from a camera
  9985. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9986. * @param inputToRemove camera input method
  9987. */
  9988. remove(inputToRemove: ICameraInput<TCamera>): void;
  9989. /**
  9990. * Remove a specific input type from a camera
  9991. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9992. * @param inputType the type of the input to remove
  9993. */
  9994. removeByType(inputType: string): void;
  9995. private _addCheckInputs;
  9996. /**
  9997. * Attach the input controls to the currently attached dom element to listen the events from.
  9998. * @param input Defines the input to attach
  9999. */
  10000. attachInput(input: ICameraInput<TCamera>): void;
  10001. /**
  10002. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  10003. * @param element Defines the dom element to collect the events from
  10004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10005. */
  10006. attachElement(noPreventDefault?: boolean): void;
  10007. /**
  10008. * Detach the current manager inputs controls from a specific dom element.
  10009. * @param element Defines the dom element to collect the events from
  10010. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  10011. */
  10012. detachElement(disconnect?: boolean): void;
  10013. /**
  10014. * Rebuild the dynamic inputCheck function from the current list of
  10015. * defined inputs in the manager.
  10016. */
  10017. rebuildInputCheck(): void;
  10018. /**
  10019. * Remove all attached input methods from a camera
  10020. */
  10021. clear(): void;
  10022. /**
  10023. * Serialize the current input manager attached to a camera.
  10024. * This ensures than once parsed,
  10025. * the input associated to the camera will be identical to the current ones
  10026. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  10027. */
  10028. serialize(serializedCamera: any): void;
  10029. /**
  10030. * Parses an input manager serialized JSON to restore the previous list of inputs
  10031. * and states associated to a camera.
  10032. * @param parsedCamera Defines the JSON to parse
  10033. */
  10034. parse(parsedCamera: any): void;
  10035. }
  10036. }
  10037. declare module "babylonjs/Events/keyboardEvents" {
  10038. /**
  10039. * Gather the list of keyboard event types as constants.
  10040. */
  10041. export class KeyboardEventTypes {
  10042. /**
  10043. * The keydown event is fired when a key becomes active (pressed).
  10044. */
  10045. static readonly KEYDOWN: number;
  10046. /**
  10047. * The keyup event is fired when a key has been released.
  10048. */
  10049. static readonly KEYUP: number;
  10050. }
  10051. /**
  10052. * This class is used to store keyboard related info for the onKeyboardObservable event.
  10053. */
  10054. export class KeyboardInfo {
  10055. /**
  10056. * Defines the type of event (KeyboardEventTypes)
  10057. */
  10058. type: number;
  10059. /**
  10060. * Defines the related dom event
  10061. */
  10062. event: KeyboardEvent;
  10063. /**
  10064. * Instantiates a new keyboard info.
  10065. * This class is used to store keyboard related info for the onKeyboardObservable event.
  10066. * @param type Defines the type of event (KeyboardEventTypes)
  10067. * @param event Defines the related dom event
  10068. */
  10069. constructor(
  10070. /**
  10071. * Defines the type of event (KeyboardEventTypes)
  10072. */
  10073. type: number,
  10074. /**
  10075. * Defines the related dom event
  10076. */
  10077. event: KeyboardEvent);
  10078. }
  10079. /**
  10080. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10081. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  10082. */
  10083. export class KeyboardInfoPre extends KeyboardInfo {
  10084. /**
  10085. * Defines the type of event (KeyboardEventTypes)
  10086. */
  10087. type: number;
  10088. /**
  10089. * Defines the related dom event
  10090. */
  10091. event: KeyboardEvent;
  10092. /**
  10093. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  10094. */
  10095. skipOnPointerObservable: boolean;
  10096. /**
  10097. * Instantiates a new keyboard pre info.
  10098. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  10099. * @param type Defines the type of event (KeyboardEventTypes)
  10100. * @param event Defines the related dom event
  10101. */
  10102. constructor(
  10103. /**
  10104. * Defines the type of event (KeyboardEventTypes)
  10105. */
  10106. type: number,
  10107. /**
  10108. * Defines the related dom event
  10109. */
  10110. event: KeyboardEvent);
  10111. }
  10112. }
  10113. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  10114. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  10115. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10116. /**
  10117. * Manage the keyboard inputs to control the movement of a free camera.
  10118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  10119. */
  10120. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  10121. /**
  10122. * Defines the camera the input is attached to.
  10123. */
  10124. camera: FreeCamera;
  10125. /**
  10126. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  10127. */
  10128. keysUp: number[];
  10129. /**
  10130. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  10131. */
  10132. keysUpward: number[];
  10133. /**
  10134. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  10135. */
  10136. keysDown: number[];
  10137. /**
  10138. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10139. */
  10140. keysDownward: number[];
  10141. /**
  10142. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10143. */
  10144. keysLeft: number[];
  10145. /**
  10146. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10147. */
  10148. keysRight: number[];
  10149. private _keys;
  10150. private _onCanvasBlurObserver;
  10151. private _onKeyboardObserver;
  10152. private _engine;
  10153. private _scene;
  10154. /**
  10155. * Attach the input controls to a specific dom element to get the input from.
  10156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10157. */
  10158. attachControl(noPreventDefault?: boolean): void;
  10159. /**
  10160. * Detach the current controls from the specified dom element.
  10161. */
  10162. detachControl(): void;
  10163. /**
  10164. * Update the current camera state depending on the inputs that have been used this frame.
  10165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10166. */
  10167. checkInputs(): void;
  10168. /**
  10169. * Gets the class name of the current input.
  10170. * @returns the class name
  10171. */
  10172. getClassName(): string;
  10173. /** @hidden */
  10174. _onLostFocus(): void;
  10175. /**
  10176. * Get the friendly name associated with the input class.
  10177. * @returns the input friendly name
  10178. */
  10179. getSimpleName(): string;
  10180. }
  10181. }
  10182. declare module "babylonjs/Actions/action" {
  10183. import { Observable } from "babylonjs/Misc/observable";
  10184. import { Condition } from "babylonjs/Actions/condition";
  10185. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10186. import { Nullable } from "babylonjs/types";
  10187. import { Scene } from "babylonjs/scene";
  10188. import { ActionManager } from "babylonjs/Actions/actionManager";
  10189. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10190. import { Node } from "babylonjs/node";
  10191. /**
  10192. * Interface used to define Action
  10193. */
  10194. export interface IAction {
  10195. /**
  10196. * Trigger for the action
  10197. */
  10198. trigger: number;
  10199. /** Options of the trigger */
  10200. triggerOptions: any;
  10201. /**
  10202. * Gets the trigger parameters
  10203. * @returns the trigger parameters
  10204. */
  10205. getTriggerParameter(): any;
  10206. /**
  10207. * Internal only - executes current action event
  10208. * @hidden
  10209. */
  10210. _executeCurrent(evt?: ActionEvent): void;
  10211. /**
  10212. * Serialize placeholder for child classes
  10213. * @param parent of child
  10214. * @returns the serialized object
  10215. */
  10216. serialize(parent: any): any;
  10217. /**
  10218. * Internal only
  10219. * @hidden
  10220. */
  10221. _prepare(): void;
  10222. /**
  10223. * Internal only - manager for action
  10224. * @hidden
  10225. */
  10226. _actionManager: Nullable<AbstractActionManager>;
  10227. /**
  10228. * Adds action to chain of actions, may be a DoNothingAction
  10229. * @param action defines the next action to execute
  10230. * @returns The action passed in
  10231. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10232. */
  10233. then(action: IAction): IAction;
  10234. }
  10235. /**
  10236. * The action to be carried out following a trigger
  10237. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10238. */
  10239. export class Action implements IAction {
  10240. /** the trigger, with or without parameters, for the action */
  10241. triggerOptions: any;
  10242. /**
  10243. * Trigger for the action
  10244. */
  10245. trigger: number;
  10246. /**
  10247. * Internal only - manager for action
  10248. * @hidden
  10249. */
  10250. _actionManager: ActionManager;
  10251. private _nextActiveAction;
  10252. private _child;
  10253. private _condition?;
  10254. private _triggerParameter;
  10255. /**
  10256. * An event triggered prior to action being executed.
  10257. */
  10258. onBeforeExecuteObservable: Observable<Action>;
  10259. /**
  10260. * Creates a new Action
  10261. * @param triggerOptions the trigger, with or without parameters, for the action
  10262. * @param condition an optional determinant of action
  10263. */
  10264. constructor(
  10265. /** the trigger, with or without parameters, for the action */
  10266. triggerOptions: any, condition?: Condition);
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. _prepare(): void;
  10272. /**
  10273. * Gets the trigger parameter
  10274. * @returns the trigger parameter
  10275. */
  10276. getTriggerParameter(): any;
  10277. /**
  10278. * Sets the trigger parameter
  10279. * @param value defines the new trigger parameter
  10280. */
  10281. setTriggerParameter(value: any): void;
  10282. /**
  10283. * Internal only - executes current action event
  10284. * @hidden
  10285. */
  10286. _executeCurrent(evt?: ActionEvent): void;
  10287. /**
  10288. * Execute placeholder for child classes
  10289. * @param evt optional action event
  10290. */
  10291. execute(evt?: ActionEvent): void;
  10292. /**
  10293. * Skips to next active action
  10294. */
  10295. skipToNextActiveAction(): void;
  10296. /**
  10297. * Adds action to chain of actions, may be a DoNothingAction
  10298. * @param action defines the next action to execute
  10299. * @returns The action passed in
  10300. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10301. */
  10302. then(action: Action): Action;
  10303. /**
  10304. * Internal only
  10305. * @hidden
  10306. */
  10307. _getProperty(propertyPath: string): string;
  10308. /**
  10309. * Internal only
  10310. * @hidden
  10311. */
  10312. _getEffectiveTarget(target: any, propertyPath: string): any;
  10313. /**
  10314. * Serialize placeholder for child classes
  10315. * @param parent of child
  10316. * @returns the serialized object
  10317. */
  10318. serialize(parent: any): any;
  10319. /**
  10320. * Internal only called by serialize
  10321. * @hidden
  10322. */
  10323. protected _serialize(serializedAction: any, parent?: any): any;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. static _SerializeValueAsString: (value: any) => string;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. static _GetTargetProperty: (target: Scene | Node) => {
  10334. name: string;
  10335. targetType: string;
  10336. value: string;
  10337. };
  10338. }
  10339. }
  10340. declare module "babylonjs/Actions/condition" {
  10341. import { ActionManager } from "babylonjs/Actions/actionManager";
  10342. /**
  10343. * A Condition applied to an Action
  10344. */
  10345. export class Condition {
  10346. /**
  10347. * Internal only - manager for action
  10348. * @hidden
  10349. */
  10350. _actionManager: ActionManager;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _evaluationId: number;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. _currentResult: boolean;
  10361. /**
  10362. * Creates a new Condition
  10363. * @param actionManager the manager of the action the condition is applied to
  10364. */
  10365. constructor(actionManager: ActionManager);
  10366. /**
  10367. * Check if the current condition is valid
  10368. * @returns a boolean
  10369. */
  10370. isValid(): boolean;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. _getProperty(propertyPath: string): string;
  10376. /**
  10377. * Internal only
  10378. * @hidden
  10379. */
  10380. _getEffectiveTarget(target: any, propertyPath: string): any;
  10381. /**
  10382. * Serialize placeholder for child classes
  10383. * @returns the serialized object
  10384. */
  10385. serialize(): any;
  10386. /**
  10387. * Internal only
  10388. * @hidden
  10389. */
  10390. protected _serialize(serializedCondition: any): any;
  10391. }
  10392. /**
  10393. * Defines specific conditional operators as extensions of Condition
  10394. */
  10395. export class ValueCondition extends Condition {
  10396. /** path to specify the property of the target the conditional operator uses */
  10397. propertyPath: string;
  10398. /** the value compared by the conditional operator against the current value of the property */
  10399. value: any;
  10400. /** the conditional operator, default ValueCondition.IsEqual */
  10401. operator: number;
  10402. /**
  10403. * Internal only
  10404. * @hidden
  10405. */
  10406. private static _IsEqual;
  10407. /**
  10408. * Internal only
  10409. * @hidden
  10410. */
  10411. private static _IsDifferent;
  10412. /**
  10413. * Internal only
  10414. * @hidden
  10415. */
  10416. private static _IsGreater;
  10417. /**
  10418. * Internal only
  10419. * @hidden
  10420. */
  10421. private static _IsLesser;
  10422. /**
  10423. * returns the number for IsEqual
  10424. */
  10425. static get IsEqual(): number;
  10426. /**
  10427. * Returns the number for IsDifferent
  10428. */
  10429. static get IsDifferent(): number;
  10430. /**
  10431. * Returns the number for IsGreater
  10432. */
  10433. static get IsGreater(): number;
  10434. /**
  10435. * Returns the number for IsLesser
  10436. */
  10437. static get IsLesser(): number;
  10438. /**
  10439. * Internal only The action manager for the condition
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Internal only
  10450. * @hidden
  10451. */
  10452. private _effectiveTarget;
  10453. /**
  10454. * Internal only
  10455. * @hidden
  10456. */
  10457. private _property;
  10458. /**
  10459. * Creates a new ValueCondition
  10460. * @param actionManager manager for the action the condition applies to
  10461. * @param target for the action
  10462. * @param propertyPath path to specify the property of the target the conditional operator uses
  10463. * @param value the value compared by the conditional operator against the current value of the property
  10464. * @param operator the conditional operator, default ValueCondition.IsEqual
  10465. */
  10466. constructor(actionManager: ActionManager, target: any,
  10467. /** path to specify the property of the target the conditional operator uses */
  10468. propertyPath: string,
  10469. /** the value compared by the conditional operator against the current value of the property */
  10470. value: any,
  10471. /** the conditional operator, default ValueCondition.IsEqual */
  10472. operator?: number);
  10473. /**
  10474. * Compares the given value with the property value for the specified conditional operator
  10475. * @returns the result of the comparison
  10476. */
  10477. isValid(): boolean;
  10478. /**
  10479. * Serialize the ValueCondition into a JSON compatible object
  10480. * @returns serialization object
  10481. */
  10482. serialize(): any;
  10483. /**
  10484. * Gets the name of the conditional operator for the ValueCondition
  10485. * @param operator the conditional operator
  10486. * @returns the name
  10487. */
  10488. static GetOperatorName(operator: number): string;
  10489. }
  10490. /**
  10491. * Defines a predicate condition as an extension of Condition
  10492. */
  10493. export class PredicateCondition extends Condition {
  10494. /** defines the predicate function used to validate the condition */
  10495. predicate: () => boolean;
  10496. /**
  10497. * Internal only - manager for action
  10498. * @hidden
  10499. */
  10500. _actionManager: ActionManager;
  10501. /**
  10502. * Creates a new PredicateCondition
  10503. * @param actionManager manager for the action the condition applies to
  10504. * @param predicate defines the predicate function used to validate the condition
  10505. */
  10506. constructor(actionManager: ActionManager,
  10507. /** defines the predicate function used to validate the condition */
  10508. predicate: () => boolean);
  10509. /**
  10510. * @returns the validity of the predicate condition
  10511. */
  10512. isValid(): boolean;
  10513. }
  10514. /**
  10515. * Defines a state condition as an extension of Condition
  10516. */
  10517. export class StateCondition extends Condition {
  10518. /** Value to compare with target state */
  10519. value: string;
  10520. /**
  10521. * Internal only - manager for action
  10522. * @hidden
  10523. */
  10524. _actionManager: ActionManager;
  10525. /**
  10526. * Internal only
  10527. * @hidden
  10528. */
  10529. private _target;
  10530. /**
  10531. * Creates a new StateCondition
  10532. * @param actionManager manager for the action the condition applies to
  10533. * @param target of the condition
  10534. * @param value to compare with target state
  10535. */
  10536. constructor(actionManager: ActionManager, target: any,
  10537. /** Value to compare with target state */
  10538. value: string);
  10539. /**
  10540. * Gets a boolean indicating if the current condition is met
  10541. * @returns the validity of the state
  10542. */
  10543. isValid(): boolean;
  10544. /**
  10545. * Serialize the StateCondition into a JSON compatible object
  10546. * @returns serialization object
  10547. */
  10548. serialize(): any;
  10549. }
  10550. }
  10551. declare module "babylonjs/Actions/directActions" {
  10552. import { Action } from "babylonjs/Actions/action";
  10553. import { Condition } from "babylonjs/Actions/condition";
  10554. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10555. /**
  10556. * This defines an action responsible to toggle a boolean once triggered.
  10557. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10558. */
  10559. export class SwitchBooleanAction extends Action {
  10560. /**
  10561. * The path to the boolean property in the target object
  10562. */
  10563. propertyPath: string;
  10564. private _target;
  10565. private _effectiveTarget;
  10566. private _property;
  10567. /**
  10568. * Instantiate the action
  10569. * @param triggerOptions defines the trigger options
  10570. * @param target defines the object containing the boolean
  10571. * @param propertyPath defines the path to the boolean property in the target object
  10572. * @param condition defines the trigger related conditions
  10573. */
  10574. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10575. /** @hidden */
  10576. _prepare(): void;
  10577. /**
  10578. * Execute the action toggle the boolean value.
  10579. */
  10580. execute(): void;
  10581. /**
  10582. * Serializes the actions and its related information.
  10583. * @param parent defines the object to serialize in
  10584. * @returns the serialized object
  10585. */
  10586. serialize(parent: any): any;
  10587. }
  10588. /**
  10589. * This defines an action responsible to set a the state field of the target
  10590. * to a desired value once triggered.
  10591. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10592. */
  10593. export class SetStateAction extends Action {
  10594. /**
  10595. * The value to store in the state field.
  10596. */
  10597. value: string;
  10598. private _target;
  10599. /**
  10600. * Instantiate the action
  10601. * @param triggerOptions defines the trigger options
  10602. * @param target defines the object containing the state property
  10603. * @param value defines the value to store in the state field
  10604. * @param condition defines the trigger related conditions
  10605. */
  10606. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10607. /**
  10608. * Execute the action and store the value on the target state property.
  10609. */
  10610. execute(): void;
  10611. /**
  10612. * Serializes the actions and its related information.
  10613. * @param parent defines the object to serialize in
  10614. * @returns the serialized object
  10615. */
  10616. serialize(parent: any): any;
  10617. }
  10618. /**
  10619. * This defines an action responsible to set a property of the target
  10620. * to a desired value once triggered.
  10621. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10622. */
  10623. export class SetValueAction extends Action {
  10624. /**
  10625. * The path of the property to set in the target.
  10626. */
  10627. propertyPath: string;
  10628. /**
  10629. * The value to set in the property
  10630. */
  10631. value: any;
  10632. private _target;
  10633. private _effectiveTarget;
  10634. private _property;
  10635. /**
  10636. * Instantiate the action
  10637. * @param triggerOptions defines the trigger options
  10638. * @param target defines the object containing the property
  10639. * @param propertyPath defines the path of the property to set in the target
  10640. * @param value defines the value to set in the property
  10641. * @param condition defines the trigger related conditions
  10642. */
  10643. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10644. /** @hidden */
  10645. _prepare(): void;
  10646. /**
  10647. * Execute the action and set the targeted property to the desired value.
  10648. */
  10649. execute(): void;
  10650. /**
  10651. * Serializes the actions and its related information.
  10652. * @param parent defines the object to serialize in
  10653. * @returns the serialized object
  10654. */
  10655. serialize(parent: any): any;
  10656. }
  10657. /**
  10658. * This defines an action responsible to increment the target value
  10659. * to a desired value once triggered.
  10660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10661. */
  10662. export class IncrementValueAction extends Action {
  10663. /**
  10664. * The path of the property to increment in the target.
  10665. */
  10666. propertyPath: string;
  10667. /**
  10668. * The value we should increment the property by.
  10669. */
  10670. value: any;
  10671. private _target;
  10672. private _effectiveTarget;
  10673. private _property;
  10674. /**
  10675. * Instantiate the action
  10676. * @param triggerOptions defines the trigger options
  10677. * @param target defines the object containing the property
  10678. * @param propertyPath defines the path of the property to increment in the target
  10679. * @param value defines the value value we should increment the property by
  10680. * @param condition defines the trigger related conditions
  10681. */
  10682. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10683. /** @hidden */
  10684. _prepare(): void;
  10685. /**
  10686. * Execute the action and increment the target of the value amount.
  10687. */
  10688. execute(): void;
  10689. /**
  10690. * Serializes the actions and its related information.
  10691. * @param parent defines the object to serialize in
  10692. * @returns the serialized object
  10693. */
  10694. serialize(parent: any): any;
  10695. }
  10696. /**
  10697. * This defines an action responsible to start an animation once triggered.
  10698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10699. */
  10700. export class PlayAnimationAction extends Action {
  10701. /**
  10702. * Where the animation should start (animation frame)
  10703. */
  10704. from: number;
  10705. /**
  10706. * Where the animation should stop (animation frame)
  10707. */
  10708. to: number;
  10709. /**
  10710. * Define if the animation should loop or stop after the first play.
  10711. */
  10712. loop?: boolean;
  10713. private _target;
  10714. /**
  10715. * Instantiate the action
  10716. * @param triggerOptions defines the trigger options
  10717. * @param target defines the target animation or animation name
  10718. * @param from defines from where the animation should start (animation frame)
  10719. * @param to defines where the animation should stop (animation frame)
  10720. * @param loop defines if the animation should loop or stop after the first play
  10721. * @param condition defines the trigger related conditions
  10722. */
  10723. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10724. /** @hidden */
  10725. _prepare(): void;
  10726. /**
  10727. * Execute the action and play the animation.
  10728. */
  10729. execute(): void;
  10730. /**
  10731. * Serializes the actions and its related information.
  10732. * @param parent defines the object to serialize in
  10733. * @returns the serialized object
  10734. */
  10735. serialize(parent: any): any;
  10736. }
  10737. /**
  10738. * This defines an action responsible to stop an animation once triggered.
  10739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10740. */
  10741. export class StopAnimationAction extends Action {
  10742. private _target;
  10743. /**
  10744. * Instantiate the action
  10745. * @param triggerOptions defines the trigger options
  10746. * @param target defines the target animation or animation name
  10747. * @param condition defines the trigger related conditions
  10748. */
  10749. constructor(triggerOptions: any, target: any, condition?: Condition);
  10750. /** @hidden */
  10751. _prepare(): void;
  10752. /**
  10753. * Execute the action and stop the animation.
  10754. */
  10755. execute(): void;
  10756. /**
  10757. * Serializes the actions and its related information.
  10758. * @param parent defines the object to serialize in
  10759. * @returns the serialized object
  10760. */
  10761. serialize(parent: any): any;
  10762. }
  10763. /**
  10764. * This defines an action responsible that does nothing once triggered.
  10765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10766. */
  10767. export class DoNothingAction extends Action {
  10768. /**
  10769. * Instantiate the action
  10770. * @param triggerOptions defines the trigger options
  10771. * @param condition defines the trigger related conditions
  10772. */
  10773. constructor(triggerOptions?: any, condition?: Condition);
  10774. /**
  10775. * Execute the action and do nothing.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to trigger several actions once triggered.
  10787. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class CombineAction extends Action {
  10790. /**
  10791. * The list of aggregated animations to run.
  10792. */
  10793. children: Action[];
  10794. /**
  10795. * Instantiate the action
  10796. * @param triggerOptions defines the trigger options
  10797. * @param children defines the list of aggregated animations to run
  10798. * @param condition defines the trigger related conditions
  10799. */
  10800. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10801. /** @hidden */
  10802. _prepare(): void;
  10803. /**
  10804. * Execute the action and executes all the aggregated actions.
  10805. */
  10806. execute(evt: ActionEvent): void;
  10807. /**
  10808. * Serializes the actions and its related information.
  10809. * @param parent defines the object to serialize in
  10810. * @returns the serialized object
  10811. */
  10812. serialize(parent: any): any;
  10813. }
  10814. /**
  10815. * This defines an action responsible to run code (external event) once triggered.
  10816. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class ExecuteCodeAction extends Action {
  10819. /**
  10820. * The callback function to run.
  10821. */
  10822. func: (evt: ActionEvent) => void;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param func defines the callback function to run
  10827. * @param condition defines the trigger related conditions
  10828. */
  10829. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10830. /**
  10831. * Execute the action and run the attached code.
  10832. */
  10833. execute(evt: ActionEvent): void;
  10834. }
  10835. /**
  10836. * This defines an action responsible to set the parent property of the target once triggered.
  10837. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10838. */
  10839. export class SetParentAction extends Action {
  10840. private _parent;
  10841. private _target;
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param target defines the target containing the parent property
  10846. * @param parent defines from where the animation should start (animation frame)
  10847. * @param condition defines the trigger related conditions
  10848. */
  10849. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10850. /** @hidden */
  10851. _prepare(): void;
  10852. /**
  10853. * Execute the action and set the parent property.
  10854. */
  10855. execute(): void;
  10856. /**
  10857. * Serializes the actions and its related information.
  10858. * @param parent defines the object to serialize in
  10859. * @returns the serialized object
  10860. */
  10861. serialize(parent: any): any;
  10862. }
  10863. }
  10864. declare module "babylonjs/Actions/actionManager" {
  10865. import { Nullable } from "babylonjs/types";
  10866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10867. import { Scene } from "babylonjs/scene";
  10868. import { IAction } from "babylonjs/Actions/action";
  10869. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10870. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10871. /**
  10872. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10873. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10874. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10875. */
  10876. export class ActionManager extends AbstractActionManager {
  10877. /**
  10878. * Nothing
  10879. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10880. */
  10881. static readonly NothingTrigger: number;
  10882. /**
  10883. * On pick
  10884. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10885. */
  10886. static readonly OnPickTrigger: number;
  10887. /**
  10888. * On left pick
  10889. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnLeftPickTrigger: number;
  10892. /**
  10893. * On right pick
  10894. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10895. */
  10896. static readonly OnRightPickTrigger: number;
  10897. /**
  10898. * On center pick
  10899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10900. */
  10901. static readonly OnCenterPickTrigger: number;
  10902. /**
  10903. * On pick down
  10904. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10905. */
  10906. static readonly OnPickDownTrigger: number;
  10907. /**
  10908. * On double pick
  10909. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10910. */
  10911. static readonly OnDoublePickTrigger: number;
  10912. /**
  10913. * On pick up
  10914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10915. */
  10916. static readonly OnPickUpTrigger: number;
  10917. /**
  10918. * On pick out.
  10919. * This trigger will only be raised if you also declared a OnPickDown
  10920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10921. */
  10922. static readonly OnPickOutTrigger: number;
  10923. /**
  10924. * On long press
  10925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10926. */
  10927. static readonly OnLongPressTrigger: number;
  10928. /**
  10929. * On pointer over
  10930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10931. */
  10932. static readonly OnPointerOverTrigger: number;
  10933. /**
  10934. * On pointer out
  10935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10936. */
  10937. static readonly OnPointerOutTrigger: number;
  10938. /**
  10939. * On every frame
  10940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10941. */
  10942. static readonly OnEveryFrameTrigger: number;
  10943. /**
  10944. * On intersection enter
  10945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10946. */
  10947. static readonly OnIntersectionEnterTrigger: number;
  10948. /**
  10949. * On intersection exit
  10950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10951. */
  10952. static readonly OnIntersectionExitTrigger: number;
  10953. /**
  10954. * On key down
  10955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10956. */
  10957. static readonly OnKeyDownTrigger: number;
  10958. /**
  10959. * On key up
  10960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10961. */
  10962. static readonly OnKeyUpTrigger: number;
  10963. private _scene;
  10964. /**
  10965. * Creates a new action manager
  10966. * @param scene defines the hosting scene
  10967. */
  10968. constructor(scene: Scene);
  10969. /**
  10970. * Releases all associated resources
  10971. */
  10972. dispose(): void;
  10973. /**
  10974. * Gets hosting scene
  10975. * @returns the hosting scene
  10976. */
  10977. getScene(): Scene;
  10978. /**
  10979. * Does this action manager handles actions of any of the given triggers
  10980. * @param triggers defines the triggers to be tested
  10981. * @return a boolean indicating whether one (or more) of the triggers is handled
  10982. */
  10983. hasSpecificTriggers(triggers: number[]): boolean;
  10984. /**
  10985. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10986. * speed.
  10987. * @param triggerA defines the trigger to be tested
  10988. * @param triggerB defines the trigger to be tested
  10989. * @return a boolean indicating whether one (or more) of the triggers is handled
  10990. */
  10991. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10992. /**
  10993. * Does this action manager handles actions of a given trigger
  10994. * @param trigger defines the trigger to be tested
  10995. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10996. * @return whether the trigger is handled
  10997. */
  10998. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10999. /**
  11000. * Does this action manager has pointer triggers
  11001. */
  11002. get hasPointerTriggers(): boolean;
  11003. /**
  11004. * Does this action manager has pick triggers
  11005. */
  11006. get hasPickTriggers(): boolean;
  11007. /**
  11008. * Registers an action to this action manager
  11009. * @param action defines the action to be registered
  11010. * @return the action amended (prepared) after registration
  11011. */
  11012. registerAction(action: IAction): Nullable<IAction>;
  11013. /**
  11014. * Unregisters an action to this action manager
  11015. * @param action defines the action to be unregistered
  11016. * @return a boolean indicating whether the action has been unregistered
  11017. */
  11018. unregisterAction(action: IAction): Boolean;
  11019. /**
  11020. * Process a specific trigger
  11021. * @param trigger defines the trigger to process
  11022. * @param evt defines the event details to be processed
  11023. */
  11024. processTrigger(trigger: number, evt?: IActionEvent): void;
  11025. /** @hidden */
  11026. _getEffectiveTarget(target: any, propertyPath: string): any;
  11027. /** @hidden */
  11028. _getProperty(propertyPath: string): string;
  11029. /**
  11030. * Serialize this manager to a JSON object
  11031. * @param name defines the property name to store this manager
  11032. * @returns a JSON representation of this manager
  11033. */
  11034. serialize(name: string): any;
  11035. /**
  11036. * Creates a new ActionManager from a JSON data
  11037. * @param parsedActions defines the JSON data to read from
  11038. * @param object defines the hosting mesh
  11039. * @param scene defines the hosting scene
  11040. */
  11041. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11042. /**
  11043. * Get a trigger name by index
  11044. * @param trigger defines the trigger index
  11045. * @returns a trigger name
  11046. */
  11047. static GetTriggerName(trigger: number): string;
  11048. }
  11049. }
  11050. declare module "babylonjs/Culling/ray" {
  11051. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11052. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11054. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11055. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11056. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11057. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11058. import { Plane } from "babylonjs/Maths/math.plane";
  11059. /**
  11060. * Class representing a ray with position and direction
  11061. */
  11062. export class Ray {
  11063. /** origin point */
  11064. origin: Vector3;
  11065. /** direction */
  11066. direction: Vector3;
  11067. /** length of the ray */
  11068. length: number;
  11069. private static readonly _TmpVector3;
  11070. private _tmpRay;
  11071. /**
  11072. * Creates a new ray
  11073. * @param origin origin point
  11074. * @param direction direction
  11075. * @param length length of the ray
  11076. */
  11077. constructor(
  11078. /** origin point */
  11079. origin: Vector3,
  11080. /** direction */
  11081. direction: Vector3,
  11082. /** length of the ray */
  11083. length?: number);
  11084. /**
  11085. * Checks if the ray intersects a box
  11086. * This does not account for the ray length by design to improve perfs.
  11087. * @param minimum bound of the box
  11088. * @param maximum bound of the box
  11089. * @param intersectionTreshold extra extend to be added to the box in all direction
  11090. * @returns if the box was hit
  11091. */
  11092. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11093. /**
  11094. * Checks if the ray intersects a box
  11095. * This does not account for the ray lenght by design to improve perfs.
  11096. * @param box the bounding box to check
  11097. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11098. * @returns if the box was hit
  11099. */
  11100. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11101. /**
  11102. * If the ray hits a sphere
  11103. * @param sphere the bounding sphere to check
  11104. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11105. * @returns true if it hits the sphere
  11106. */
  11107. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11108. /**
  11109. * If the ray hits a triange
  11110. * @param vertex0 triangle vertex
  11111. * @param vertex1 triangle vertex
  11112. * @param vertex2 triangle vertex
  11113. * @returns intersection information if hit
  11114. */
  11115. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11116. /**
  11117. * Checks if ray intersects a plane
  11118. * @param plane the plane to check
  11119. * @returns the distance away it was hit
  11120. */
  11121. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11122. /**
  11123. * Calculate the intercept of a ray on a given axis
  11124. * @param axis to check 'x' | 'y' | 'z'
  11125. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11126. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11127. */
  11128. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11129. /**
  11130. * Checks if ray intersects a mesh
  11131. * @param mesh the mesh to check
  11132. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11133. * @returns picking info of the intersection
  11134. */
  11135. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11136. /**
  11137. * Checks if ray intersects a mesh
  11138. * @param meshes the meshes to check
  11139. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11140. * @param results array to store result in
  11141. * @returns Array of picking infos
  11142. */
  11143. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11144. private _comparePickingInfo;
  11145. private static smallnum;
  11146. private static rayl;
  11147. /**
  11148. * Intersection test between the ray and a given segment within a given tolerance (threshold)
  11149. * @param sega the first point of the segment to test the intersection against
  11150. * @param segb the second point of the segment to test the intersection against
  11151. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11152. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11153. */
  11154. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11155. /**
  11156. * Update the ray from viewport position
  11157. * @param x position
  11158. * @param y y position
  11159. * @param viewportWidth viewport width
  11160. * @param viewportHeight viewport height
  11161. * @param world world matrix
  11162. * @param view view matrix
  11163. * @param projection projection matrix
  11164. * @returns this ray updated
  11165. */
  11166. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11167. /**
  11168. * Creates a ray with origin and direction of 0,0,0
  11169. * @returns the new ray
  11170. */
  11171. static Zero(): Ray;
  11172. /**
  11173. * Creates a new ray from screen space and viewport
  11174. * @param x position
  11175. * @param y y position
  11176. * @param viewportWidth viewport width
  11177. * @param viewportHeight viewport height
  11178. * @param world world matrix
  11179. * @param view view matrix
  11180. * @param projection projection matrix
  11181. * @returns new ray
  11182. */
  11183. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11184. /**
  11185. * 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
  11186. * transformed to the given world matrix.
  11187. * @param origin The origin point
  11188. * @param end The end point
  11189. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11190. * @returns the new ray
  11191. */
  11192. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11193. /**
  11194. * Transforms a ray by a matrix
  11195. * @param ray ray to transform
  11196. * @param matrix matrix to apply
  11197. * @returns the resulting new ray
  11198. */
  11199. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11200. /**
  11201. * Transforms a ray by a matrix
  11202. * @param ray ray to transform
  11203. * @param matrix matrix to apply
  11204. * @param result ray to store result in
  11205. */
  11206. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11207. /**
  11208. * Unproject a ray from screen space to object space
  11209. * @param sourceX defines the screen space x coordinate to use
  11210. * @param sourceY defines the screen space y coordinate to use
  11211. * @param viewportWidth defines the current width of the viewport
  11212. * @param viewportHeight defines the current height of the viewport
  11213. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11214. * @param view defines the view matrix to use
  11215. * @param projection defines the projection matrix to use
  11216. */
  11217. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11218. }
  11219. /**
  11220. * Type used to define predicate used to select faces when a mesh intersection is detected
  11221. */
  11222. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11223. module "babylonjs/scene" {
  11224. interface Scene {
  11225. /** @hidden */
  11226. _tempPickingRay: Nullable<Ray>;
  11227. /** @hidden */
  11228. _cachedRayForTransform: Ray;
  11229. /** @hidden */
  11230. _pickWithRayInverseMatrix: Matrix;
  11231. /** @hidden */
  11232. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11233. /** @hidden */
  11234. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11235. /** @hidden */
  11236. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11237. }
  11238. }
  11239. }
  11240. declare module "babylonjs/sceneComponent" {
  11241. import { Scene } from "babylonjs/scene";
  11242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11244. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11245. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11246. import { Nullable } from "babylonjs/types";
  11247. import { Camera } from "babylonjs/Cameras/camera";
  11248. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11249. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11250. import { AbstractScene } from "babylonjs/abstractScene";
  11251. import { Mesh } from "babylonjs/Meshes/mesh";
  11252. import { Effect } from "babylonjs/Materials/effect";
  11253. /**
  11254. * Groups all the scene component constants in one place to ease maintenance.
  11255. * @hidden
  11256. */
  11257. export class SceneComponentConstants {
  11258. static readonly NAME_EFFECTLAYER: string;
  11259. static readonly NAME_LAYER: string;
  11260. static readonly NAME_LENSFLARESYSTEM: string;
  11261. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11262. static readonly NAME_PARTICLESYSTEM: string;
  11263. static readonly NAME_GAMEPAD: string;
  11264. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11265. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11266. static readonly NAME_PREPASSRENDERER: string;
  11267. static readonly NAME_DEPTHRENDERER: string;
  11268. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11269. static readonly NAME_SPRITE: string;
  11270. static readonly NAME_SUBSURFACE: string;
  11271. static readonly NAME_OUTLINERENDERER: string;
  11272. static readonly NAME_PROCEDURALTEXTURE: string;
  11273. static readonly NAME_SHADOWGENERATOR: string;
  11274. static readonly NAME_OCTREE: string;
  11275. static readonly NAME_PHYSICSENGINE: string;
  11276. static readonly NAME_AUDIO: string;
  11277. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11278. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11279. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11280. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11281. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11282. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11283. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11284. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11285. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS: number;
  11286. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11287. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11288. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11289. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11290. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11291. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11292. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11293. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11294. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11295. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11296. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS: number;
  11297. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11298. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11299. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11300. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11301. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11302. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11303. static readonly STEP_AFTERRENDER_AUDIO: number;
  11304. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11305. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11306. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11307. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11308. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11309. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11310. static readonly STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS: number;
  11311. static readonly STEP_POINTERMOVE_SPRITE: number;
  11312. static readonly STEP_POINTERDOWN_SPRITE: number;
  11313. static readonly STEP_POINTERUP_SPRITE: number;
  11314. }
  11315. /**
  11316. * This represents a scene component.
  11317. *
  11318. * This is used to decouple the dependency the scene is having on the different workloads like
  11319. * layers, post processes...
  11320. */
  11321. export interface ISceneComponent {
  11322. /**
  11323. * The name of the component. Each component must have a unique name.
  11324. */
  11325. name: string;
  11326. /**
  11327. * The scene the component belongs to.
  11328. */
  11329. scene: Scene;
  11330. /**
  11331. * Register the component to one instance of a scene.
  11332. */
  11333. register(): void;
  11334. /**
  11335. * Rebuilds the elements related to this component in case of
  11336. * context lost for instance.
  11337. */
  11338. rebuild(): void;
  11339. /**
  11340. * Disposes the component and the associated ressources.
  11341. */
  11342. dispose(): void;
  11343. }
  11344. /**
  11345. * This represents a SERIALIZABLE scene component.
  11346. *
  11347. * This extends Scene Component to add Serialization methods on top.
  11348. */
  11349. export interface ISceneSerializableComponent extends ISceneComponent {
  11350. /**
  11351. * Adds all the elements from the container to the scene
  11352. * @param container the container holding the elements
  11353. */
  11354. addFromContainer(container: AbstractScene): void;
  11355. /**
  11356. * Removes all the elements in the container from the scene
  11357. * @param container contains the elements to remove
  11358. * @param dispose if the removed element should be disposed (default: false)
  11359. */
  11360. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11361. /**
  11362. * Serializes the component data to the specified json object
  11363. * @param serializationObject The object to serialize to
  11364. */
  11365. serialize(serializationObject: any): void;
  11366. }
  11367. /**
  11368. * Strong typing of a Mesh related stage step action
  11369. */
  11370. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11371. /**
  11372. * Strong typing of a Evaluate Sub Mesh related stage step action
  11373. */
  11374. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11375. /**
  11376. * Strong typing of a pre active Mesh related stage step action
  11377. */
  11378. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11379. /**
  11380. * Strong typing of a Camera related stage step action
  11381. */
  11382. export type CameraStageAction = (camera: Camera) => void;
  11383. /**
  11384. * Strong typing of a Camera Frame buffer related stage step action
  11385. */
  11386. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11387. /**
  11388. * Strong typing of a Render Target related stage step action
  11389. */
  11390. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  11391. /**
  11392. * Strong typing of a RenderingGroup related stage step action
  11393. */
  11394. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11395. /**
  11396. * Strong typing of a Mesh Render related stage step action
  11397. */
  11398. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11399. /**
  11400. * Strong typing of a simple stage step action
  11401. */
  11402. export type SimpleStageAction = () => void;
  11403. /**
  11404. * Strong typing of a render target action.
  11405. */
  11406. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11407. /**
  11408. * Strong typing of a pointer move action.
  11409. */
  11410. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11411. /**
  11412. * Strong typing of a pointer up/down action.
  11413. */
  11414. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11415. /**
  11416. * Representation of a stage in the scene (Basically a list of ordered steps)
  11417. * @hidden
  11418. */
  11419. export class Stage<T extends Function> extends Array<{
  11420. index: number;
  11421. component: ISceneComponent;
  11422. action: T;
  11423. }> {
  11424. /**
  11425. * Hide ctor from the rest of the world.
  11426. * @param items The items to add.
  11427. */
  11428. private constructor();
  11429. /**
  11430. * Creates a new Stage.
  11431. * @returns A new instance of a Stage
  11432. */
  11433. static Create<T extends Function>(): Stage<T>;
  11434. /**
  11435. * Registers a step in an ordered way in the targeted stage.
  11436. * @param index Defines the position to register the step in
  11437. * @param component Defines the component attached to the step
  11438. * @param action Defines the action to launch during the step
  11439. */
  11440. registerStep(index: number, component: ISceneComponent, action: T): void;
  11441. /**
  11442. * Clears all the steps from the stage.
  11443. */
  11444. clear(): void;
  11445. }
  11446. }
  11447. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11448. import { Nullable } from "babylonjs/types";
  11449. import { Observable } from "babylonjs/Misc/observable";
  11450. import { Scene } from "babylonjs/scene";
  11451. import { Sprite } from "babylonjs/Sprites/sprite";
  11452. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11453. import { Ray } from "babylonjs/Culling/ray";
  11454. import { Camera } from "babylonjs/Cameras/camera";
  11455. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11456. import { ISceneComponent } from "babylonjs/sceneComponent";
  11457. module "babylonjs/scene" {
  11458. interface Scene {
  11459. /** @hidden */
  11460. _pointerOverSprite: Nullable<Sprite>;
  11461. /** @hidden */
  11462. _pickedDownSprite: Nullable<Sprite>;
  11463. /** @hidden */
  11464. _tempSpritePickingRay: Nullable<Ray>;
  11465. /**
  11466. * All of the sprite managers added to this scene
  11467. * @see https://doc.babylonjs.com/babylon101/sprites
  11468. */
  11469. spriteManagers: Array<ISpriteManager>;
  11470. /**
  11471. * An event triggered when sprites rendering is about to start
  11472. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11473. */
  11474. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11475. /**
  11476. * An event triggered when sprites rendering is done
  11477. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11478. */
  11479. onAfterSpritesRenderingObservable: Observable<Scene>;
  11480. /** @hidden */
  11481. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11482. /** Launch a ray to try to pick a sprite in the scene
  11483. * @param x position on screen
  11484. * @param y position on screen
  11485. * @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
  11486. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11487. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11488. * @returns a PickingInfo
  11489. */
  11490. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11491. /** Use the given ray to pick a sprite in the scene
  11492. * @param ray The ray (in world space) to use to pick meshes
  11493. * @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
  11494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11495. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11496. * @returns a PickingInfo
  11497. */
  11498. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11499. /** @hidden */
  11500. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11501. /** Launch a ray to try to pick sprites in the scene
  11502. * @param x position on screen
  11503. * @param y position on screen
  11504. * @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
  11505. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11506. * @returns a PickingInfo array
  11507. */
  11508. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11509. /** Use the given ray to pick sprites in the scene
  11510. * @param ray The ray (in world space) to use to pick meshes
  11511. * @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
  11512. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11513. * @returns a PickingInfo array
  11514. */
  11515. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11516. /**
  11517. * Force the sprite under the pointer
  11518. * @param sprite defines the sprite to use
  11519. */
  11520. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11521. /**
  11522. * Gets the sprite under the pointer
  11523. * @returns a Sprite or null if no sprite is under the pointer
  11524. */
  11525. getPointerOverSprite(): Nullable<Sprite>;
  11526. }
  11527. }
  11528. /**
  11529. * Defines the sprite scene component responsible to manage sprites
  11530. * in a given scene.
  11531. */
  11532. export class SpriteSceneComponent implements ISceneComponent {
  11533. /**
  11534. * The component name helpfull to identify the component in the list of scene components.
  11535. */
  11536. readonly name: string;
  11537. /**
  11538. * The scene the component belongs to.
  11539. */
  11540. scene: Scene;
  11541. /** @hidden */
  11542. private _spritePredicate;
  11543. /**
  11544. * Creates a new instance of the component for the given scene
  11545. * @param scene Defines the scene to register the component in
  11546. */
  11547. constructor(scene: Scene);
  11548. /**
  11549. * Registers the component in a given scene
  11550. */
  11551. register(): void;
  11552. /**
  11553. * Rebuilds the elements related to this component in case of
  11554. * context lost for instance.
  11555. */
  11556. rebuild(): void;
  11557. /**
  11558. * Disposes the component and the associated resources.
  11559. */
  11560. dispose(): void;
  11561. private _pickSpriteButKeepRay;
  11562. private _pointerMove;
  11563. private _pointerDown;
  11564. private _pointerUp;
  11565. }
  11566. }
  11567. declare module "babylonjs/Misc/timingTools" {
  11568. /**
  11569. * Class used to provide helper for timing
  11570. */
  11571. export class TimingTools {
  11572. /**
  11573. * Polyfill for setImmediate
  11574. * @param action defines the action to execute after the current execution block
  11575. */
  11576. static SetImmediate(action: () => void): void;
  11577. }
  11578. }
  11579. declare module "babylonjs/Misc/instantiationTools" {
  11580. /**
  11581. * Class used to enable instantiation of objects by class name
  11582. */
  11583. export class InstantiationTools {
  11584. /**
  11585. * Use this object to register external classes like custom textures or material
  11586. * to allow the loaders to instantiate them
  11587. */
  11588. static RegisteredExternalClasses: {
  11589. [key: string]: Object;
  11590. };
  11591. /**
  11592. * Tries to instantiate a new object from a given class name
  11593. * @param className defines the class name to instantiate
  11594. * @returns the new object or null if the system was not able to do the instantiation
  11595. */
  11596. static Instantiate(className: string): any;
  11597. }
  11598. }
  11599. declare module "babylonjs/Misc/copyTools" {
  11600. import { ISize } from "babylonjs/Maths/math.size";
  11601. import { Nullable } from "babylonjs/types";
  11602. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11603. /**
  11604. * Class used to host copy specific utilities
  11605. */
  11606. export class CopyTools {
  11607. /**
  11608. * Transform some pixel data to a base64 string
  11609. * @param pixels defines the pixel data to transform to base64
  11610. * @param size defines the width and height of the (texture) data
  11611. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11612. * @returns The base64 encoded string or null
  11613. */
  11614. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11615. /**
  11616. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11617. * @param texture defines the texture to read pixels from
  11618. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11619. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11620. * @returns The base64 encoded string or null
  11621. */
  11622. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11623. /**
  11624. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11625. * @param texture defines the texture to read pixels from
  11626. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11627. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11628. * @returns The base64 encoded string or null wrapped in a promise
  11629. */
  11630. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11631. }
  11632. }
  11633. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  11634. /**
  11635. * Define options used to create a depth texture
  11636. */
  11637. export class DepthTextureCreationOptions {
  11638. /** Specifies whether or not a stencil should be allocated in the texture */
  11639. generateStencil?: boolean;
  11640. /** Specifies whether or not bilinear filtering is enable on the texture */
  11641. bilinearFiltering?: boolean;
  11642. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11643. comparisonFunction?: number;
  11644. /** Specifies if the created texture is a cube texture */
  11645. isCube?: boolean;
  11646. /** Specifies the sample count of the depth/stencil texture texture */
  11647. samples?: number;
  11648. }
  11649. }
  11650. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  11651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11652. import { Nullable } from "babylonjs/types";
  11653. import { Scene } from "babylonjs/scene";
  11654. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11655. module "babylonjs/Engines/thinEngine" {
  11656. interface ThinEngine {
  11657. /**
  11658. * Creates a depth stencil cube texture.
  11659. * This is only available in WebGL 2.
  11660. * @param size The size of face edge in the cube texture.
  11661. * @param options The options defining the cube texture.
  11662. * @returns The cube texture
  11663. */
  11664. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11665. /**
  11666. * Creates a cube texture
  11667. * @param rootUrl defines the url where the files to load is located
  11668. * @param scene defines the current scene
  11669. * @param files defines the list of files to load (1 per face)
  11670. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11671. * @param onLoad defines an optional callback raised when the texture is loaded
  11672. * @param onError defines an optional callback raised if there is an issue to load the texture
  11673. * @param format defines the format of the data
  11674. * @param forcedExtension defines the extension to use to pick the right loader
  11675. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11676. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11677. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11678. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11679. * @param loaderOptions options to be passed to the loader
  11680. * @returns the cube texture as an InternalTexture
  11681. */
  11682. 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;
  11683. /**
  11684. * Creates a cube texture
  11685. * @param rootUrl defines the url where the files to load is located
  11686. * @param scene defines the current scene
  11687. * @param files defines the list of files to load (1 per face)
  11688. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11689. * @param onLoad defines an optional callback raised when the texture is loaded
  11690. * @param onError defines an optional callback raised if there is an issue to load the texture
  11691. * @param format defines the format of the data
  11692. * @param forcedExtension defines the extension to use to pick the right loader
  11693. * @returns the cube texture as an InternalTexture
  11694. */
  11695. 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;
  11696. /**
  11697. * Creates a cube texture
  11698. * @param rootUrl defines the url where the files to load is located
  11699. * @param scene defines the current scene
  11700. * @param files defines the list of files to load (1 per face)
  11701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11702. * @param onLoad defines an optional callback raised when the texture is loaded
  11703. * @param onError defines an optional callback raised if there is an issue to load the texture
  11704. * @param format defines the format of the data
  11705. * @param forcedExtension defines the extension to use to pick the right loader
  11706. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11707. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11708. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11709. * @returns the cube texture as an InternalTexture
  11710. */
  11711. 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;
  11712. /** @hidden */
  11713. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11714. /** @hidden */
  11715. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11716. /** @hidden */
  11717. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11718. /** @hidden */
  11719. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11720. /** @hidden */
  11721. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11722. /**
  11723. * @hidden
  11724. */
  11725. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11726. }
  11727. }
  11728. }
  11729. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11730. import { Nullable } from "babylonjs/types";
  11731. import { Scene } from "babylonjs/scene";
  11732. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11734. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11735. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11736. import { Observable } from "babylonjs/Misc/observable";
  11737. /**
  11738. * Class for creating a cube texture
  11739. */
  11740. export class CubeTexture extends BaseTexture {
  11741. private _delayedOnLoad;
  11742. /**
  11743. * Observable triggered once the texture has been loaded.
  11744. */
  11745. onLoadObservable: Observable<CubeTexture>;
  11746. /**
  11747. * The url of the texture
  11748. */
  11749. url: string;
  11750. /**
  11751. * Gets or sets the center of the bounding box associated with the cube texture.
  11752. * It must define where the camera used to render the texture was set
  11753. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11754. */
  11755. boundingBoxPosition: Vector3;
  11756. private _boundingBoxSize;
  11757. /**
  11758. * Gets or sets the size of the bounding box associated with the cube texture
  11759. * When defined, the cubemap will switch to local mode
  11760. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11761. * @example https://www.babylonjs-playground.com/#RNASML
  11762. */
  11763. set boundingBoxSize(value: Vector3);
  11764. /**
  11765. * Returns the bounding box size
  11766. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11767. */
  11768. get boundingBoxSize(): Vector3;
  11769. protected _rotationY: number;
  11770. /**
  11771. * Sets texture matrix rotation angle around Y axis in radians.
  11772. */
  11773. set rotationY(value: number);
  11774. /**
  11775. * Gets texture matrix rotation angle around Y axis radians.
  11776. */
  11777. get rotationY(): number;
  11778. /**
  11779. * Are mip maps generated for this texture or not.
  11780. */
  11781. get noMipmap(): boolean;
  11782. private _noMipmap;
  11783. private _files;
  11784. protected _forcedExtension: Nullable<string>;
  11785. private _extensions;
  11786. private _textureMatrix;
  11787. private _format;
  11788. private _createPolynomials;
  11789. private _loaderOptions;
  11790. /**
  11791. * Creates a cube texture from an array of image urls
  11792. * @param files defines an array of image urls
  11793. * @param scene defines the hosting scene
  11794. * @param noMipmap specifies if mip maps are not used
  11795. * @returns a cube texture
  11796. */
  11797. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11798. /**
  11799. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11800. * @param url defines the url of the prefiltered texture
  11801. * @param scene defines the scene the texture is attached to
  11802. * @param forcedExtension defines the extension of the file if different from the url
  11803. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11804. * @return the prefiltered texture
  11805. */
  11806. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11807. /**
  11808. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11809. * as prefiltered data.
  11810. * @param rootUrl defines the url of the texture or the root name of the six images
  11811. * @param null defines the scene or engine the texture is attached to
  11812. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11813. * @param noMipmap defines if mipmaps should be created or not
  11814. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11815. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  11816. * @param onError defines a callback triggered in case of error during load
  11817. * @param format defines the internal format to use for the texture once loaded
  11818. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11819. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11820. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11821. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11822. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11823. * @param loaderOptions options to be passed to the loader
  11824. * @return the cube texture
  11825. */
  11826. 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);
  11827. /**
  11828. * Get the current class name of the texture useful for serialization or dynamic coding.
  11829. * @returns "CubeTexture"
  11830. */
  11831. getClassName(): string;
  11832. /**
  11833. * Update the url (and optional buffer) of this texture if url was null during construction.
  11834. * @param url the url of the texture
  11835. * @param forcedExtension defines the extension to use
  11836. * @param onLoad callback called when the texture is loaded (defaults to null)
  11837. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11838. */
  11839. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11840. /**
  11841. * Delays loading of the cube texture
  11842. * @param forcedExtension defines the extension to use
  11843. */
  11844. delayLoad(forcedExtension?: string): void;
  11845. /**
  11846. * Returns the reflection texture matrix
  11847. * @returns the reflection texture matrix
  11848. */
  11849. getReflectionTextureMatrix(): Matrix;
  11850. /**
  11851. * Sets the reflection texture matrix
  11852. * @param value Reflection texture matrix
  11853. */
  11854. setReflectionTextureMatrix(value: Matrix): void;
  11855. /**
  11856. * Parses text to create a cube texture
  11857. * @param parsedTexture define the serialized text to read from
  11858. * @param scene defines the hosting scene
  11859. * @param rootUrl defines the root url of the cube texture
  11860. * @returns a cube texture
  11861. */
  11862. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11863. /**
  11864. * Makes a clone, or deep copy, of the cube texture
  11865. * @returns a new cube texture
  11866. */
  11867. clone(): CubeTexture;
  11868. }
  11869. }
  11870. declare module "babylonjs/Materials/colorCurves" {
  11871. import { Effect } from "babylonjs/Materials/effect";
  11872. /**
  11873. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  11874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11875. * 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;
  11876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11877. */
  11878. export class ColorCurves {
  11879. private _dirty;
  11880. private _tempColor;
  11881. private _globalCurve;
  11882. private _highlightsCurve;
  11883. private _midtonesCurve;
  11884. private _shadowsCurve;
  11885. private _positiveCurve;
  11886. private _negativeCurve;
  11887. private _globalHue;
  11888. private _globalDensity;
  11889. private _globalSaturation;
  11890. private _globalExposure;
  11891. /**
  11892. * Gets the global Hue value.
  11893. * 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).
  11894. */
  11895. get globalHue(): number;
  11896. /**
  11897. * Sets the global Hue value.
  11898. * 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).
  11899. */
  11900. set globalHue(value: number);
  11901. /**
  11902. * Gets the global Density value.
  11903. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11904. * Values less than zero provide a filter of opposite hue.
  11905. */
  11906. get globalDensity(): number;
  11907. /**
  11908. * Sets the global Density value.
  11909. * 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.
  11910. * Values less than zero provide a filter of opposite hue.
  11911. */
  11912. set globalDensity(value: number);
  11913. /**
  11914. * Gets the global Saturation value.
  11915. * 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.
  11916. */
  11917. get globalSaturation(): number;
  11918. /**
  11919. * Sets the global Saturation value.
  11920. * 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.
  11921. */
  11922. set globalSaturation(value: number);
  11923. /**
  11924. * Gets the global Exposure value.
  11925. * 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.
  11926. */
  11927. get globalExposure(): number;
  11928. /**
  11929. * Sets the global Exposure value.
  11930. * 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.
  11931. */
  11932. set globalExposure(value: number);
  11933. private _highlightsHue;
  11934. private _highlightsDensity;
  11935. private _highlightsSaturation;
  11936. private _highlightsExposure;
  11937. /**
  11938. * Gets the highlights Hue value.
  11939. * 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).
  11940. */
  11941. get highlightsHue(): number;
  11942. /**
  11943. * Sets the highlights Hue value.
  11944. * 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).
  11945. */
  11946. set highlightsHue(value: number);
  11947. /**
  11948. * Gets the highlights Density value.
  11949. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11950. * Values less than zero provide a filter of opposite hue.
  11951. */
  11952. get highlightsDensity(): number;
  11953. /**
  11954. * Sets the highlights Density value.
  11955. * 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.
  11956. * Values less than zero provide a filter of opposite hue.
  11957. */
  11958. set highlightsDensity(value: number);
  11959. /**
  11960. * Gets the highlights Saturation value.
  11961. * 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.
  11962. */
  11963. get highlightsSaturation(): number;
  11964. /**
  11965. * Sets the highlights Saturation value.
  11966. * 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.
  11967. */
  11968. set highlightsSaturation(value: number);
  11969. /**
  11970. * Gets the highlights Exposure value.
  11971. * 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.
  11972. */
  11973. get highlightsExposure(): number;
  11974. /**
  11975. * Sets the highlights Exposure value.
  11976. * 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.
  11977. */
  11978. set highlightsExposure(value: number);
  11979. private _midtonesHue;
  11980. private _midtonesDensity;
  11981. private _midtonesSaturation;
  11982. private _midtonesExposure;
  11983. /**
  11984. * Gets the midtones Hue value.
  11985. * 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).
  11986. */
  11987. get midtonesHue(): number;
  11988. /**
  11989. * Sets the midtones Hue value.
  11990. * 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).
  11991. */
  11992. set midtonesHue(value: number);
  11993. /**
  11994. * Gets the midtones Density value.
  11995. * 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.
  11996. * Values less than zero provide a filter of opposite hue.
  11997. */
  11998. get midtonesDensity(): number;
  11999. /**
  12000. * Sets the midtones Density value.
  12001. * 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.
  12002. * Values less than zero provide a filter of opposite hue.
  12003. */
  12004. set midtonesDensity(value: number);
  12005. /**
  12006. * Gets the midtones Saturation value.
  12007. * 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.
  12008. */
  12009. get midtonesSaturation(): number;
  12010. /**
  12011. * Sets the midtones Saturation value.
  12012. * 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.
  12013. */
  12014. set midtonesSaturation(value: number);
  12015. /**
  12016. * Gets the midtones Exposure value.
  12017. * 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.
  12018. */
  12019. get midtonesExposure(): number;
  12020. /**
  12021. * Sets the midtones Exposure value.
  12022. * 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.
  12023. */
  12024. set midtonesExposure(value: number);
  12025. private _shadowsHue;
  12026. private _shadowsDensity;
  12027. private _shadowsSaturation;
  12028. private _shadowsExposure;
  12029. /**
  12030. * Gets the shadows Hue value.
  12031. * 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).
  12032. */
  12033. get shadowsHue(): number;
  12034. /**
  12035. * Sets the shadows Hue value.
  12036. * 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).
  12037. */
  12038. set shadowsHue(value: number);
  12039. /**
  12040. * Gets the shadows Density value.
  12041. * 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.
  12042. * Values less than zero provide a filter of opposite hue.
  12043. */
  12044. get shadowsDensity(): number;
  12045. /**
  12046. * Sets the shadows Density value.
  12047. * 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.
  12048. * Values less than zero provide a filter of opposite hue.
  12049. */
  12050. set shadowsDensity(value: number);
  12051. /**
  12052. * Gets the shadows Saturation value.
  12053. * 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.
  12054. */
  12055. get shadowsSaturation(): number;
  12056. /**
  12057. * Sets the shadows Saturation value.
  12058. * 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.
  12059. */
  12060. set shadowsSaturation(value: number);
  12061. /**
  12062. * Gets the shadows Exposure value.
  12063. * 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.
  12064. */
  12065. get shadowsExposure(): number;
  12066. /**
  12067. * Sets the shadows Exposure value.
  12068. * 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.
  12069. */
  12070. set shadowsExposure(value: number);
  12071. /**
  12072. * Returns the class name
  12073. * @returns The class name
  12074. */
  12075. getClassName(): string;
  12076. /**
  12077. * Binds the color curves to the shader.
  12078. * @param colorCurves The color curve to bind
  12079. * @param effect The effect to bind to
  12080. * @param positiveUniform The positive uniform shader parameter
  12081. * @param neutralUniform The neutral uniform shader parameter
  12082. * @param negativeUniform The negative uniform shader parameter
  12083. */
  12084. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12085. /**
  12086. * Prepare the list of uniforms associated with the ColorCurves effects.
  12087. * @param uniformsList The list of uniforms used in the effect
  12088. */
  12089. static PrepareUniforms(uniformsList: string[]): void;
  12090. /**
  12091. * Returns color grading data based on a hue, density, saturation and exposure value.
  12092. * @param filterHue The hue of the color filter.
  12093. * @param filterDensity The density of the color filter.
  12094. * @param saturation The saturation.
  12095. * @param exposure The exposure.
  12096. * @param result The result data container.
  12097. */
  12098. private getColorGradingDataToRef;
  12099. /**
  12100. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12101. * @param value The input slider value in range [-100,100].
  12102. * @returns Adjusted value.
  12103. */
  12104. private static applyColorGradingSliderNonlinear;
  12105. /**
  12106. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12107. * @param hue The hue (H) input.
  12108. * @param saturation The saturation (S) input.
  12109. * @param brightness The brightness (B) input.
  12110. * @result An RGBA color represented as Vector4.
  12111. */
  12112. private static fromHSBToRef;
  12113. /**
  12114. * Returns a value clamped between min and max
  12115. * @param value The value to clamp
  12116. * @param min The minimum of value
  12117. * @param max The maximum of value
  12118. * @returns The clamped value.
  12119. */
  12120. private static clamp;
  12121. /**
  12122. * Clones the current color curve instance.
  12123. * @return The cloned curves
  12124. */
  12125. clone(): ColorCurves;
  12126. /**
  12127. * Serializes the current color curve instance to a json representation.
  12128. * @return a JSON representation
  12129. */
  12130. serialize(): any;
  12131. /**
  12132. * Parses the color curve from a json representation.
  12133. * @param source the JSON source to parse
  12134. * @return The parsed curves
  12135. */
  12136. static Parse(source: any): ColorCurves;
  12137. }
  12138. }
  12139. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  12140. import { Observable } from "babylonjs/Misc/observable";
  12141. import { Nullable } from "babylonjs/types";
  12142. import { Color4 } from "babylonjs/Maths/math.color";
  12143. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  12144. import { Effect } from "babylonjs/Materials/effect";
  12145. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12146. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  12147. /**
  12148. * Interface to follow in your material defines to integrate easily the
  12149. * Image processing functions.
  12150. * @hidden
  12151. */
  12152. export interface IImageProcessingConfigurationDefines {
  12153. IMAGEPROCESSING: boolean;
  12154. VIGNETTE: boolean;
  12155. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12156. VIGNETTEBLENDMODEOPAQUE: boolean;
  12157. TONEMAPPING: boolean;
  12158. TONEMAPPING_ACES: boolean;
  12159. CONTRAST: boolean;
  12160. EXPOSURE: boolean;
  12161. COLORCURVES: boolean;
  12162. COLORGRADING: boolean;
  12163. COLORGRADING3D: boolean;
  12164. SAMPLER3DGREENDEPTH: boolean;
  12165. SAMPLER3DBGRMAP: boolean;
  12166. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12167. }
  12168. /**
  12169. * @hidden
  12170. */
  12171. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12172. IMAGEPROCESSING: boolean;
  12173. VIGNETTE: boolean;
  12174. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12175. VIGNETTEBLENDMODEOPAQUE: boolean;
  12176. TONEMAPPING: boolean;
  12177. TONEMAPPING_ACES: boolean;
  12178. CONTRAST: boolean;
  12179. COLORCURVES: boolean;
  12180. COLORGRADING: boolean;
  12181. COLORGRADING3D: boolean;
  12182. SAMPLER3DGREENDEPTH: boolean;
  12183. SAMPLER3DBGRMAP: boolean;
  12184. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12185. EXPOSURE: boolean;
  12186. constructor();
  12187. }
  12188. /**
  12189. * This groups together the common properties used for image processing either in direct forward pass
  12190. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12191. * or not.
  12192. */
  12193. export class ImageProcessingConfiguration {
  12194. /**
  12195. * Default tone mapping applied in BabylonJS.
  12196. */
  12197. static readonly TONEMAPPING_STANDARD: number;
  12198. /**
  12199. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  12200. * to other engines rendering to increase portability.
  12201. */
  12202. static readonly TONEMAPPING_ACES: number;
  12203. /**
  12204. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12205. */
  12206. colorCurves: Nullable<ColorCurves>;
  12207. private _colorCurvesEnabled;
  12208. /**
  12209. * Gets whether the color curves effect is enabled.
  12210. */
  12211. get colorCurvesEnabled(): boolean;
  12212. /**
  12213. * Sets whether the color curves effect is enabled.
  12214. */
  12215. set colorCurvesEnabled(value: boolean);
  12216. private _colorGradingTexture;
  12217. /**
  12218. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12219. */
  12220. get colorGradingTexture(): Nullable<BaseTexture>;
  12221. /**
  12222. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12223. */
  12224. set colorGradingTexture(value: Nullable<BaseTexture>);
  12225. private _colorGradingEnabled;
  12226. /**
  12227. * Gets whether the color grading effect is enabled.
  12228. */
  12229. get colorGradingEnabled(): boolean;
  12230. /**
  12231. * Sets whether the color grading effect is enabled.
  12232. */
  12233. set colorGradingEnabled(value: boolean);
  12234. private _colorGradingWithGreenDepth;
  12235. /**
  12236. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  12237. */
  12238. get colorGradingWithGreenDepth(): boolean;
  12239. /**
  12240. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  12241. */
  12242. set colorGradingWithGreenDepth(value: boolean);
  12243. private _colorGradingBGR;
  12244. /**
  12245. * Gets whether the color grading texture contains BGR values.
  12246. */
  12247. get colorGradingBGR(): boolean;
  12248. /**
  12249. * Sets whether the color grading texture contains BGR values.
  12250. */
  12251. set colorGradingBGR(value: boolean);
  12252. /** @hidden */
  12253. _exposure: number;
  12254. /**
  12255. * Gets the Exposure used in the effect.
  12256. */
  12257. get exposure(): number;
  12258. /**
  12259. * Sets the Exposure used in the effect.
  12260. */
  12261. set exposure(value: number);
  12262. private _toneMappingEnabled;
  12263. /**
  12264. * Gets whether the tone mapping effect is enabled.
  12265. */
  12266. get toneMappingEnabled(): boolean;
  12267. /**
  12268. * Sets whether the tone mapping effect is enabled.
  12269. */
  12270. set toneMappingEnabled(value: boolean);
  12271. private _toneMappingType;
  12272. /**
  12273. * Gets the type of tone mapping effect.
  12274. */
  12275. get toneMappingType(): number;
  12276. /**
  12277. * Sets the type of tone mapping effect used in BabylonJS.
  12278. */
  12279. set toneMappingType(value: number);
  12280. protected _contrast: number;
  12281. /**
  12282. * Gets the contrast used in the effect.
  12283. */
  12284. get contrast(): number;
  12285. /**
  12286. * Sets the contrast used in the effect.
  12287. */
  12288. set contrast(value: number);
  12289. /**
  12290. * Vignette stretch size.
  12291. */
  12292. vignetteStretch: number;
  12293. /**
  12294. * Vignette centre X Offset.
  12295. */
  12296. vignetteCentreX: number;
  12297. /**
  12298. * Vignette centre Y Offset.
  12299. */
  12300. vignetteCentreY: number;
  12301. /**
  12302. * Vignette weight or intensity of the vignette effect.
  12303. */
  12304. vignetteWeight: number;
  12305. /**
  12306. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12307. * if vignetteEnabled is set to true.
  12308. */
  12309. vignetteColor: Color4;
  12310. /**
  12311. * Camera field of view used by the Vignette effect.
  12312. */
  12313. vignetteCameraFov: number;
  12314. private _vignetteBlendMode;
  12315. /**
  12316. * Gets the vignette blend mode allowing different kind of effect.
  12317. */
  12318. get vignetteBlendMode(): number;
  12319. /**
  12320. * Sets the vignette blend mode allowing different kind of effect.
  12321. */
  12322. set vignetteBlendMode(value: number);
  12323. private _vignetteEnabled;
  12324. /**
  12325. * Gets whether the vignette effect is enabled.
  12326. */
  12327. get vignetteEnabled(): boolean;
  12328. /**
  12329. * Sets whether the vignette effect is enabled.
  12330. */
  12331. set vignetteEnabled(value: boolean);
  12332. private _applyByPostProcess;
  12333. /**
  12334. * Gets whether the image processing is applied through a post process or not.
  12335. */
  12336. get applyByPostProcess(): boolean;
  12337. /**
  12338. * Sets whether the image processing is applied through a post process or not.
  12339. */
  12340. set applyByPostProcess(value: boolean);
  12341. private _isEnabled;
  12342. /**
  12343. * Gets whether the image processing is enabled or not.
  12344. */
  12345. get isEnabled(): boolean;
  12346. /**
  12347. * Sets whether the image processing is enabled or not.
  12348. */
  12349. set isEnabled(value: boolean);
  12350. /**
  12351. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12352. */
  12353. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12354. /**
  12355. * Method called each time the image processing information changes requires to recompile the effect.
  12356. */
  12357. protected _updateParameters(): void;
  12358. /**
  12359. * Gets the current class name.
  12360. * @return "ImageProcessingConfiguration"
  12361. */
  12362. getClassName(): string;
  12363. /**
  12364. * Prepare the list of uniforms associated with the Image Processing effects.
  12365. * @param uniforms The list of uniforms used in the effect
  12366. * @param defines the list of defines currently in use
  12367. */
  12368. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12369. /**
  12370. * Prepare the list of samplers associated with the Image Processing effects.
  12371. * @param samplersList The list of uniforms used in the effect
  12372. * @param defines the list of defines currently in use
  12373. */
  12374. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12375. /**
  12376. * Prepare the list of defines associated to the shader.
  12377. * @param defines the list of defines to complete
  12378. * @param forPostProcess Define if we are currently in post process mode or not
  12379. */
  12380. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12381. /**
  12382. * Returns true if all the image processing information are ready.
  12383. * @returns True if ready, otherwise, false
  12384. */
  12385. isReady(): boolean;
  12386. /**
  12387. * Binds the image processing to the shader.
  12388. * @param effect The effect to bind to
  12389. * @param overrideAspectRatio Override the aspect ratio of the effect
  12390. */
  12391. bind(effect: Effect, overrideAspectRatio?: number): void;
  12392. /**
  12393. * Clones the current image processing instance.
  12394. * @return The cloned image processing
  12395. */
  12396. clone(): ImageProcessingConfiguration;
  12397. /**
  12398. * Serializes the current image processing instance to a json representation.
  12399. * @return a JSON representation
  12400. */
  12401. serialize(): any;
  12402. /**
  12403. * Parses the image processing from a json representation.
  12404. * @param source the JSON source to parse
  12405. * @return The parsed image processing
  12406. */
  12407. static Parse(source: any): ImageProcessingConfiguration;
  12408. private static _VIGNETTEMODE_MULTIPLY;
  12409. private static _VIGNETTEMODE_OPAQUE;
  12410. /**
  12411. * Used to apply the vignette as a mix with the pixel color.
  12412. */
  12413. static get VIGNETTEMODE_MULTIPLY(): number;
  12414. /**
  12415. * Used to apply the vignette as a replacement of the pixel color.
  12416. */
  12417. static get VIGNETTEMODE_OPAQUE(): number;
  12418. }
  12419. }
  12420. declare module "babylonjs/Shaders/postprocess.vertex" {
  12421. /** @hidden */
  12422. export var postprocessVertexShader: {
  12423. name: string;
  12424. shader: string;
  12425. };
  12426. }
  12427. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  12428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12429. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  12430. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  12431. /**
  12432. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12433. */
  12434. export type RenderTargetTextureSize = number | {
  12435. width: number;
  12436. height: number;
  12437. layers?: number;
  12438. };
  12439. module "babylonjs/Engines/thinEngine" {
  12440. interface ThinEngine {
  12441. /**
  12442. * Creates a new render target texture
  12443. * @param size defines the size of the texture
  12444. * @param options defines the options used to create the texture
  12445. * @returns a new render target texture stored in an InternalTexture
  12446. */
  12447. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12448. /**
  12449. * Creates a depth stencil texture.
  12450. * This is only available in WebGL 2 or with the depth texture extension available.
  12451. * @param size The size of face edge in the texture.
  12452. * @param options The options defining the texture.
  12453. * @returns The texture
  12454. */
  12455. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12456. /** @hidden */
  12457. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12458. }
  12459. }
  12460. }
  12461. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  12462. /**
  12463. * Defines the kind of connection point for node based material
  12464. */
  12465. export enum NodeMaterialBlockConnectionPointTypes {
  12466. /** Float */
  12467. Float = 1,
  12468. /** Int */
  12469. Int = 2,
  12470. /** Vector2 */
  12471. Vector2 = 4,
  12472. /** Vector3 */
  12473. Vector3 = 8,
  12474. /** Vector4 */
  12475. Vector4 = 16,
  12476. /** Color3 */
  12477. Color3 = 32,
  12478. /** Color4 */
  12479. Color4 = 64,
  12480. /** Matrix */
  12481. Matrix = 128,
  12482. /** Custom object */
  12483. Object = 256,
  12484. /** Detect type based on connection */
  12485. AutoDetect = 1024,
  12486. /** Output type that will be defined by input type */
  12487. BasedOnInput = 2048
  12488. }
  12489. }
  12490. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  12491. /**
  12492. * Enum used to define the target of a block
  12493. */
  12494. export enum NodeMaterialBlockTargets {
  12495. /** Vertex shader */
  12496. Vertex = 1,
  12497. /** Fragment shader */
  12498. Fragment = 2,
  12499. /** Neutral */
  12500. Neutral = 4,
  12501. /** Vertex and Fragment */
  12502. VertexAndFragment = 3
  12503. }
  12504. }
  12505. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  12506. /**
  12507. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12508. */
  12509. export enum NodeMaterialBlockConnectionPointMode {
  12510. /** Value is an uniform */
  12511. Uniform = 0,
  12512. /** Value is a mesh attribute */
  12513. Attribute = 1,
  12514. /** Value is a varying between vertex and fragment shaders */
  12515. Varying = 2,
  12516. /** Mode is undefined */
  12517. Undefined = 3
  12518. }
  12519. }
  12520. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  12521. /**
  12522. * Enum used to define system values e.g. values automatically provided by the system
  12523. */
  12524. export enum NodeMaterialSystemValues {
  12525. /** World */
  12526. World = 1,
  12527. /** View */
  12528. View = 2,
  12529. /** Projection */
  12530. Projection = 3,
  12531. /** ViewProjection */
  12532. ViewProjection = 4,
  12533. /** WorldView */
  12534. WorldView = 5,
  12535. /** WorldViewProjection */
  12536. WorldViewProjection = 6,
  12537. /** CameraPosition */
  12538. CameraPosition = 7,
  12539. /** Fog Color */
  12540. FogColor = 8,
  12541. /** Delta time */
  12542. DeltaTime = 9
  12543. }
  12544. }
  12545. declare module "babylonjs/Maths/math.frustum" {
  12546. import { Matrix } from "babylonjs/Maths/math.vector";
  12547. import { DeepImmutable } from "babylonjs/types";
  12548. import { Plane } from "babylonjs/Maths/math.plane";
  12549. /**
  12550. * Represents a camera frustum
  12551. */
  12552. export class Frustum {
  12553. /**
  12554. * Gets the planes representing the frustum
  12555. * @param transform matrix to be applied to the returned planes
  12556. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12557. */
  12558. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12559. /**
  12560. * Gets the near frustum plane transformed by the transform matrix
  12561. * @param transform transformation matrix to be applied to the resulting frustum plane
  12562. * @param frustumPlane the resuling frustum plane
  12563. */
  12564. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12565. /**
  12566. * Gets the far frustum plane transformed by the transform matrix
  12567. * @param transform transformation matrix to be applied to the resulting frustum plane
  12568. * @param frustumPlane the resuling frustum plane
  12569. */
  12570. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12571. /**
  12572. * Gets the left frustum plane transformed by the transform matrix
  12573. * @param transform transformation matrix to be applied to the resulting frustum plane
  12574. * @param frustumPlane the resuling frustum plane
  12575. */
  12576. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12577. /**
  12578. * Gets the right frustum plane transformed by the transform matrix
  12579. * @param transform transformation matrix to be applied to the resulting frustum plane
  12580. * @param frustumPlane the resuling frustum plane
  12581. */
  12582. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12583. /**
  12584. * Gets the top frustum plane transformed by the transform matrix
  12585. * @param transform transformation matrix to be applied to the resulting frustum plane
  12586. * @param frustumPlane the resuling frustum plane
  12587. */
  12588. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12589. /**
  12590. * Gets the bottom frustum plane transformed by the transform matrix
  12591. * @param transform transformation matrix to be applied to the resulting frustum plane
  12592. * @param frustumPlane the resuling frustum plane
  12593. */
  12594. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12595. /**
  12596. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12597. * @param transform transformation matrix to be applied to the resulting frustum planes
  12598. * @param frustumPlanes the resuling frustum planes
  12599. */
  12600. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12601. }
  12602. }
  12603. declare module "babylonjs/Maths/math.vertexFormat" {
  12604. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12605. /**
  12606. * Contains position and normal vectors for a vertex
  12607. */
  12608. export class PositionNormalVertex {
  12609. /** the position of the vertex (defaut: 0,0,0) */
  12610. position: Vector3;
  12611. /** the normal of the vertex (defaut: 0,1,0) */
  12612. normal: Vector3;
  12613. /**
  12614. * Creates a PositionNormalVertex
  12615. * @param position the position of the vertex (defaut: 0,0,0)
  12616. * @param normal the normal of the vertex (defaut: 0,1,0)
  12617. */
  12618. constructor(
  12619. /** the position of the vertex (defaut: 0,0,0) */
  12620. position?: Vector3,
  12621. /** the normal of the vertex (defaut: 0,1,0) */
  12622. normal?: Vector3);
  12623. /**
  12624. * Clones the PositionNormalVertex
  12625. * @returns the cloned PositionNormalVertex
  12626. */
  12627. clone(): PositionNormalVertex;
  12628. }
  12629. /**
  12630. * Contains position, normal and uv vectors for a vertex
  12631. */
  12632. export class PositionNormalTextureVertex {
  12633. /** the position of the vertex (defaut: 0,0,0) */
  12634. position: Vector3;
  12635. /** the normal of the vertex (defaut: 0,1,0) */
  12636. normal: Vector3;
  12637. /** the uv of the vertex (default: 0,0) */
  12638. uv: Vector2;
  12639. /**
  12640. * Creates a PositionNormalTextureVertex
  12641. * @param position the position of the vertex (defaut: 0,0,0)
  12642. * @param normal the normal of the vertex (defaut: 0,1,0)
  12643. * @param uv the uv of the vertex (default: 0,0)
  12644. */
  12645. constructor(
  12646. /** the position of the vertex (defaut: 0,0,0) */
  12647. position?: Vector3,
  12648. /** the normal of the vertex (defaut: 0,1,0) */
  12649. normal?: Vector3,
  12650. /** the uv of the vertex (default: 0,0) */
  12651. uv?: Vector2);
  12652. /**
  12653. * Clones the PositionNormalTextureVertex
  12654. * @returns the cloned PositionNormalTextureVertex
  12655. */
  12656. clone(): PositionNormalTextureVertex;
  12657. }
  12658. }
  12659. declare module "babylonjs/Maths/math" {
  12660. export * from "babylonjs/Maths/math.axis";
  12661. export * from "babylonjs/Maths/math.color";
  12662. export * from "babylonjs/Maths/math.constants";
  12663. export * from "babylonjs/Maths/math.frustum";
  12664. export * from "babylonjs/Maths/math.path";
  12665. export * from "babylonjs/Maths/math.plane";
  12666. export * from "babylonjs/Maths/math.size";
  12667. export * from "babylonjs/Maths/math.vector";
  12668. export * from "babylonjs/Maths/math.vertexFormat";
  12669. export * from "babylonjs/Maths/math.viewport";
  12670. }
  12671. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  12672. /**
  12673. * Enum defining the type of animations supported by InputBlock
  12674. */
  12675. export enum AnimatedInputBlockTypes {
  12676. /** No animation */
  12677. None = 0,
  12678. /** Time based animation. Will only work for floats */
  12679. Time = 1
  12680. }
  12681. }
  12682. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  12683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12684. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12685. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  12686. import { Nullable } from "babylonjs/types";
  12687. import { Effect } from "babylonjs/Materials/effect";
  12688. import { Matrix } from "babylonjs/Maths/math.vector";
  12689. import { Scene } from "babylonjs/scene";
  12690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12692. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12693. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12694. import { Observable } from "babylonjs/Misc/observable";
  12695. /**
  12696. * Block used to expose an input value
  12697. */
  12698. export class InputBlock extends NodeMaterialBlock {
  12699. private _mode;
  12700. private _associatedVariableName;
  12701. private _storedValue;
  12702. private _valueCallback;
  12703. private _type;
  12704. private _animationType;
  12705. /** Gets or set a value used to limit the range of float values */
  12706. min: number;
  12707. /** Gets or set a value used to limit the range of float values */
  12708. max: number;
  12709. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12710. isBoolean: boolean;
  12711. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12712. matrixMode: number;
  12713. /** @hidden */
  12714. _systemValue: Nullable<NodeMaterialSystemValues>;
  12715. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12716. isConstant: boolean;
  12717. /** Gets or sets the group to use to display this block in the Inspector */
  12718. groupInInspector: string;
  12719. /** Gets an observable raised when the value is changed */
  12720. onValueChangedObservable: Observable<InputBlock>;
  12721. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12722. convertToGammaSpace: boolean;
  12723. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12724. convertToLinearSpace: boolean;
  12725. /**
  12726. * Gets or sets the connection point type (default is float)
  12727. */
  12728. get type(): NodeMaterialBlockConnectionPointTypes;
  12729. /**
  12730. * Creates a new InputBlock
  12731. * @param name defines the block name
  12732. * @param target defines the target of that block (Vertex by default)
  12733. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12734. */
  12735. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12736. /**
  12737. * Validates if a name is a reserve word.
  12738. * @param newName the new name to be given to the node.
  12739. * @returns false if the name is a reserve word, else true.
  12740. */
  12741. validateBlockName(newName: string): boolean;
  12742. /**
  12743. * Gets the output component
  12744. */
  12745. get output(): NodeMaterialConnectionPoint;
  12746. /**
  12747. * Set the source of this connection point to a vertex attribute
  12748. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12749. * @returns the current connection point
  12750. */
  12751. setAsAttribute(attributeName?: string): InputBlock;
  12752. /**
  12753. * Set the source of this connection point to a system value
  12754. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12755. * @returns the current connection point
  12756. */
  12757. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12758. /**
  12759. * Gets or sets the value of that point.
  12760. * Please note that this value will be ignored if valueCallback is defined
  12761. */
  12762. get value(): any;
  12763. set value(value: any);
  12764. /**
  12765. * Gets or sets a callback used to get the value of that point.
  12766. * Please note that setting this value will force the connection point to ignore the value property
  12767. */
  12768. get valueCallback(): () => any;
  12769. set valueCallback(value: () => any);
  12770. /**
  12771. * Gets or sets the associated variable name in the shader
  12772. */
  12773. get associatedVariableName(): string;
  12774. set associatedVariableName(value: string);
  12775. /** Gets or sets the type of animation applied to the input */
  12776. get animationType(): AnimatedInputBlockTypes;
  12777. set animationType(value: AnimatedInputBlockTypes);
  12778. /**
  12779. * Gets a boolean indicating that this connection point not defined yet
  12780. */
  12781. get isUndefined(): boolean;
  12782. /**
  12783. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12784. * In this case the connection point name must be the name of the uniform to use.
  12785. * Can only be set on inputs
  12786. */
  12787. get isUniform(): boolean;
  12788. set isUniform(value: boolean);
  12789. /**
  12790. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12791. * In this case the connection point name must be the name of the attribute to use
  12792. * Can only be set on inputs
  12793. */
  12794. get isAttribute(): boolean;
  12795. set isAttribute(value: boolean);
  12796. /**
  12797. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12798. * Can only be set on exit points
  12799. */
  12800. get isVarying(): boolean;
  12801. set isVarying(value: boolean);
  12802. /**
  12803. * Gets a boolean indicating that the current connection point is a system value
  12804. */
  12805. get isSystemValue(): boolean;
  12806. /**
  12807. * Gets or sets the current well known value or null if not defined as a system value
  12808. */
  12809. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12810. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12811. /**
  12812. * Gets the current class name
  12813. * @returns the class name
  12814. */
  12815. getClassName(): string;
  12816. /**
  12817. * Animate the input if animationType !== None
  12818. * @param scene defines the rendering scene
  12819. */
  12820. animate(scene: Scene): void;
  12821. private _emitDefine;
  12822. initialize(state: NodeMaterialBuildState): void;
  12823. /**
  12824. * Set the input block to its default value (based on its type)
  12825. */
  12826. setDefaultValue(): void;
  12827. private _emitConstant;
  12828. /** @hidden */
  12829. get _noContextSwitch(): boolean;
  12830. private _emit;
  12831. /** @hidden */
  12832. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12833. /** @hidden */
  12834. _transmit(effect: Effect, scene: Scene): void;
  12835. protected _buildBlock(state: NodeMaterialBuildState): void;
  12836. protected _dumpPropertiesCode(): string;
  12837. dispose(): void;
  12838. serialize(): any;
  12839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12840. }
  12841. }
  12842. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12843. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12844. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12845. import { Nullable } from "babylonjs/types";
  12846. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12847. import { Observable } from "babylonjs/Misc/observable";
  12848. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12849. /**
  12850. * Enum used to define the compatibility state between two connection points
  12851. */
  12852. export enum NodeMaterialConnectionPointCompatibilityStates {
  12853. /** Points are compatibles */
  12854. Compatible = 0,
  12855. /** Points are incompatible because of their types */
  12856. TypeIncompatible = 1,
  12857. /** Points are incompatible because of their targets (vertex vs fragment) */
  12858. TargetIncompatible = 2
  12859. }
  12860. /**
  12861. * Defines the direction of a connection point
  12862. */
  12863. export enum NodeMaterialConnectionPointDirection {
  12864. /** Input */
  12865. Input = 0,
  12866. /** Output */
  12867. Output = 1
  12868. }
  12869. /**
  12870. * Defines a connection point for a block
  12871. */
  12872. export class NodeMaterialConnectionPoint {
  12873. /**
  12874. * Checks if two types are equivalent
  12875. * @param type1 type 1 to check
  12876. * @param type2 type 2 to check
  12877. * @returns true if both types are equivalent, else false
  12878. */
  12879. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12880. /** @hidden */
  12881. _ownerBlock: NodeMaterialBlock;
  12882. /** @hidden */
  12883. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12884. private _endpoints;
  12885. private _associatedVariableName;
  12886. private _direction;
  12887. /** @hidden */
  12888. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12889. /** @hidden */
  12890. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12891. /** @hidden */
  12892. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12893. private _type;
  12894. /** @hidden */
  12895. _enforceAssociatedVariableName: boolean;
  12896. /** Gets the direction of the point */
  12897. get direction(): NodeMaterialConnectionPointDirection;
  12898. /** Indicates that this connection point needs dual validation before being connected to another point */
  12899. needDualDirectionValidation: boolean;
  12900. /**
  12901. * Gets or sets the additional types supported by this connection point
  12902. */
  12903. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12904. /**
  12905. * Gets or sets the additional types excluded by this connection point
  12906. */
  12907. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12908. /**
  12909. * Observable triggered when this point is connected
  12910. */
  12911. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12912. /**
  12913. * Gets or sets the associated variable name in the shader
  12914. */
  12915. get associatedVariableName(): string;
  12916. set associatedVariableName(value: string);
  12917. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12918. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12919. /**
  12920. * Gets or sets the connection point type (default is float)
  12921. */
  12922. get type(): NodeMaterialBlockConnectionPointTypes;
  12923. set type(value: NodeMaterialBlockConnectionPointTypes);
  12924. /**
  12925. * Gets or sets the connection point name
  12926. */
  12927. name: string;
  12928. /**
  12929. * Gets or sets the connection point name
  12930. */
  12931. displayName: string;
  12932. /**
  12933. * Gets or sets a boolean indicating that this connection point can be omitted
  12934. */
  12935. isOptional: boolean;
  12936. /**
  12937. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12938. */
  12939. isExposedOnFrame: boolean;
  12940. /**
  12941. * Gets or sets number indicating the position that the port is exposed to on a frame
  12942. */
  12943. exposedPortPosition: number;
  12944. /**
  12945. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12946. */
  12947. define: string;
  12948. /** @hidden */
  12949. _prioritizeVertex: boolean;
  12950. private _target;
  12951. /** Gets or sets the target of that connection point */
  12952. get target(): NodeMaterialBlockTargets;
  12953. set target(value: NodeMaterialBlockTargets);
  12954. /**
  12955. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12956. */
  12957. get isConnected(): boolean;
  12958. /**
  12959. * Gets a boolean indicating that the current point is connected to an input block
  12960. */
  12961. get isConnectedToInputBlock(): boolean;
  12962. /**
  12963. * Gets a the connected input block (if any)
  12964. */
  12965. get connectInputBlock(): Nullable<InputBlock>;
  12966. /** Get the other side of the connection (if any) */
  12967. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12968. /** Get the block that owns this connection point */
  12969. get ownerBlock(): NodeMaterialBlock;
  12970. /** Get the block connected on the other side of this connection (if any) */
  12971. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12972. /** Get the block connected on the endpoints of this connection (if any) */
  12973. get connectedBlocks(): Array<NodeMaterialBlock>;
  12974. /** Gets the list of connected endpoints */
  12975. get endpoints(): NodeMaterialConnectionPoint[];
  12976. /** Gets a boolean indicating if that output point is connected to at least one input */
  12977. get hasEndpoints(): boolean;
  12978. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12979. get isConnectedInVertexShader(): boolean;
  12980. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12981. get isConnectedInFragmentShader(): boolean;
  12982. /**
  12983. * Creates a block suitable to be used as an input for this input point.
  12984. * If null is returned, a block based on the point type will be created.
  12985. * @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
  12986. */
  12987. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12988. /**
  12989. * Creates a new connection point
  12990. * @param name defines the connection point name
  12991. * @param ownerBlock defines the block hosting this connection point
  12992. * @param direction defines the direction of the connection point
  12993. */
  12994. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12995. /**
  12996. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12997. * @returns the class name
  12998. */
  12999. getClassName(): string;
  13000. /**
  13001. * Gets a boolean indicating if the current point can be connected to another point
  13002. * @param connectionPoint defines the other connection point
  13003. * @returns a boolean
  13004. */
  13005. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  13006. /**
  13007. * Gets a number indicating if the current point can be connected to another point
  13008. * @param connectionPoint defines the other connection point
  13009. * @returns a number defining the compatibility state
  13010. */
  13011. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13012. /**
  13013. * Connect this point to another connection point
  13014. * @param connectionPoint defines the other connection point
  13015. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  13016. * @returns the current connection point
  13017. */
  13018. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  13019. /**
  13020. * Disconnect this point from one of his endpoint
  13021. * @param endpoint defines the other connection point
  13022. * @returns the current connection point
  13023. */
  13024. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  13025. /**
  13026. * Serializes this point in a JSON representation
  13027. * @param isInput defines if the connection point is an input (default is true)
  13028. * @returns the serialized point object
  13029. */
  13030. serialize(isInput?: boolean): any;
  13031. /**
  13032. * Release resources
  13033. */
  13034. dispose(): void;
  13035. }
  13036. }
  13037. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  13038. /**
  13039. * Enum used to define the material modes
  13040. */
  13041. export enum NodeMaterialModes {
  13042. /** Regular material */
  13043. Material = 0,
  13044. /** For post process */
  13045. PostProcess = 1,
  13046. /** For particle system */
  13047. Particle = 2,
  13048. /** For procedural texture */
  13049. ProceduralTexture = 3
  13050. }
  13051. }
  13052. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  13053. /** @hidden */
  13054. export var helperFunctions: {
  13055. name: string;
  13056. shader: string;
  13057. };
  13058. }
  13059. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  13060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13062. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13065. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13066. import { Effect } from "babylonjs/Materials/effect";
  13067. import { Mesh } from "babylonjs/Meshes/mesh";
  13068. import { Nullable } from "babylonjs/types";
  13069. import { Texture } from "babylonjs/Materials/Textures/texture";
  13070. import { Scene } from "babylonjs/scene";
  13071. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  13072. /**
  13073. * Block used to read a texture from a sampler
  13074. */
  13075. export class TextureBlock extends NodeMaterialBlock {
  13076. private _defineName;
  13077. private _linearDefineName;
  13078. private _gammaDefineName;
  13079. private _tempTextureRead;
  13080. private _samplerName;
  13081. private _transformedUVName;
  13082. private _textureTransformName;
  13083. private _textureInfoName;
  13084. private _mainUVName;
  13085. private _mainUVDefineName;
  13086. private _fragmentOnly;
  13087. /**
  13088. * Gets or sets the texture associated with the node
  13089. */
  13090. texture: Nullable<Texture>;
  13091. /**
  13092. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13093. */
  13094. convertToGammaSpace: boolean;
  13095. /**
  13096. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13097. */
  13098. convertToLinearSpace: boolean;
  13099. /**
  13100. * Create a new TextureBlock
  13101. * @param name defines the block name
  13102. */
  13103. constructor(name: string, fragmentOnly?: boolean);
  13104. /**
  13105. * Gets the current class name
  13106. * @returns the class name
  13107. */
  13108. getClassName(): string;
  13109. /**
  13110. * Gets the uv input component
  13111. */
  13112. get uv(): NodeMaterialConnectionPoint;
  13113. /**
  13114. * Gets the rgba output component
  13115. */
  13116. get rgba(): NodeMaterialConnectionPoint;
  13117. /**
  13118. * Gets the rgb output component
  13119. */
  13120. get rgb(): NodeMaterialConnectionPoint;
  13121. /**
  13122. * Gets the r output component
  13123. */
  13124. get r(): NodeMaterialConnectionPoint;
  13125. /**
  13126. * Gets the g output component
  13127. */
  13128. get g(): NodeMaterialConnectionPoint;
  13129. /**
  13130. * Gets the b output component
  13131. */
  13132. get b(): NodeMaterialConnectionPoint;
  13133. /**
  13134. * Gets the a output component
  13135. */
  13136. get a(): NodeMaterialConnectionPoint;
  13137. get target(): NodeMaterialBlockTargets;
  13138. autoConfigure(material: NodeMaterial): void;
  13139. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13141. isReady(): boolean;
  13142. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13143. private get _isMixed();
  13144. private _injectVertexCode;
  13145. private _writeTextureRead;
  13146. private _generateConversionCode;
  13147. private _writeOutput;
  13148. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13149. protected _dumpPropertiesCode(): string;
  13150. serialize(): any;
  13151. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13152. }
  13153. }
  13154. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  13155. /** @hidden */
  13156. export var reflectionFunction: {
  13157. name: string;
  13158. shader: string;
  13159. };
  13160. }
  13161. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  13162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13167. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13168. import { Effect } from "babylonjs/Materials/effect";
  13169. import { Mesh } from "babylonjs/Meshes/mesh";
  13170. import { Nullable } from "babylonjs/types";
  13171. import { Scene } from "babylonjs/scene";
  13172. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  13173. /**
  13174. * Base block used to read a reflection texture from a sampler
  13175. */
  13176. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  13177. /** @hidden */
  13178. _define3DName: string;
  13179. /** @hidden */
  13180. _defineCubicName: string;
  13181. /** @hidden */
  13182. _defineExplicitName: string;
  13183. /** @hidden */
  13184. _defineProjectionName: string;
  13185. /** @hidden */
  13186. _defineLocalCubicName: string;
  13187. /** @hidden */
  13188. _defineSphericalName: string;
  13189. /** @hidden */
  13190. _definePlanarName: string;
  13191. /** @hidden */
  13192. _defineEquirectangularName: string;
  13193. /** @hidden */
  13194. _defineMirroredEquirectangularFixedName: string;
  13195. /** @hidden */
  13196. _defineEquirectangularFixedName: string;
  13197. /** @hidden */
  13198. _defineSkyboxName: string;
  13199. /** @hidden */
  13200. _defineOppositeZ: string;
  13201. /** @hidden */
  13202. _cubeSamplerName: string;
  13203. /** @hidden */
  13204. _2DSamplerName: string;
  13205. protected _positionUVWName: string;
  13206. protected _directionWName: string;
  13207. protected _reflectionVectorName: string;
  13208. /** @hidden */
  13209. _reflectionCoordsName: string;
  13210. /** @hidden */
  13211. _reflectionMatrixName: string;
  13212. protected _reflectionColorName: string;
  13213. /**
  13214. * Gets or sets the texture associated with the node
  13215. */
  13216. texture: Nullable<BaseTexture>;
  13217. /**
  13218. * Create a new ReflectionTextureBaseBlock
  13219. * @param name defines the block name
  13220. */
  13221. constructor(name: string);
  13222. /**
  13223. * Gets the current class name
  13224. * @returns the class name
  13225. */
  13226. getClassName(): string;
  13227. /**
  13228. * Gets the world position input component
  13229. */
  13230. abstract get position(): NodeMaterialConnectionPoint;
  13231. /**
  13232. * Gets the world position input component
  13233. */
  13234. abstract get worldPosition(): NodeMaterialConnectionPoint;
  13235. /**
  13236. * Gets the world normal input component
  13237. */
  13238. abstract get worldNormal(): NodeMaterialConnectionPoint;
  13239. /**
  13240. * Gets the world input component
  13241. */
  13242. abstract get world(): NodeMaterialConnectionPoint;
  13243. /**
  13244. * Gets the camera (or eye) position component
  13245. */
  13246. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  13247. /**
  13248. * Gets the view input component
  13249. */
  13250. abstract get view(): NodeMaterialConnectionPoint;
  13251. protected _getTexture(): Nullable<BaseTexture>;
  13252. autoConfigure(material: NodeMaterial): void;
  13253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13254. isReady(): boolean;
  13255. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  13256. /**
  13257. * Gets the code to inject in the vertex shader
  13258. * @param state current state of the node material building
  13259. * @returns the shader code
  13260. */
  13261. handleVertexSide(state: NodeMaterialBuildState): string;
  13262. /**
  13263. * Handles the inits for the fragment code path
  13264. * @param state node material build state
  13265. */
  13266. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  13267. /**
  13268. * Generates the reflection coords code for the fragment code path
  13269. * @param worldNormalVarName name of the world normal variable
  13270. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13271. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13272. * @returns the shader code
  13273. */
  13274. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13275. /**
  13276. * Generates the reflection color code for the fragment code path
  13277. * @param lodVarName name of the lod variable
  13278. * @param swizzleLookupTexture swizzle to use for the final color variable
  13279. * @returns the shader code
  13280. */
  13281. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13282. /**
  13283. * Generates the code corresponding to the connected output points
  13284. * @param state node material build state
  13285. * @param varName name of the variable to output
  13286. * @returns the shader code
  13287. */
  13288. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13289. protected _buildBlock(state: NodeMaterialBuildState): this;
  13290. protected _dumpPropertiesCode(): string;
  13291. serialize(): any;
  13292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13293. }
  13294. }
  13295. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  13296. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13297. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13298. import { Nullable } from "babylonjs/types";
  13299. /**
  13300. * Defines a connection point to be used for points with a custom object type
  13301. */
  13302. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13303. private _blockType;
  13304. private _blockName;
  13305. private _nameForCheking?;
  13306. /**
  13307. * Creates a new connection point
  13308. * @param name defines the connection point name
  13309. * @param ownerBlock defines the block hosting this connection point
  13310. * @param direction defines the direction of the connection point
  13311. */
  13312. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13313. /**
  13314. * Gets a number indicating if the current point can be connected to another point
  13315. * @param connectionPoint defines the other connection point
  13316. * @returns a number defining the compatibility state
  13317. */
  13318. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13319. /**
  13320. * Creates a block suitable to be used as an input for this input point.
  13321. * If null is returned, a block based on the point type will be created.
  13322. * @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
  13323. */
  13324. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13325. }
  13326. }
  13327. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  13328. /**
  13329. * Enum defining the type of properties that can be edited in the property pages in the NME
  13330. */
  13331. export enum PropertyTypeForEdition {
  13332. /** property is a boolean */
  13333. Boolean = 0,
  13334. /** property is a float */
  13335. Float = 1,
  13336. /** property is a Vector2 */
  13337. Vector2 = 2,
  13338. /** property is a list of values */
  13339. List = 3
  13340. }
  13341. /**
  13342. * Interface that defines an option in a variable of type list
  13343. */
  13344. export interface IEditablePropertyListOption {
  13345. /** label of the option */
  13346. "label": string;
  13347. /** value of the option */
  13348. "value": number;
  13349. }
  13350. /**
  13351. * Interface that defines the options available for an editable property
  13352. */
  13353. export interface IEditablePropertyOption {
  13354. /** min value */
  13355. "min"?: number;
  13356. /** max value */
  13357. "max"?: number;
  13358. /** notifiers: indicates which actions to take when the property is changed */
  13359. "notifiers"?: {
  13360. /** the material should be rebuilt */
  13361. "rebuild"?: boolean;
  13362. /** the preview should be updated */
  13363. "update"?: boolean;
  13364. };
  13365. /** list of the options for a variable of type list */
  13366. "options"?: IEditablePropertyListOption[];
  13367. }
  13368. /**
  13369. * Interface that describes an editable property
  13370. */
  13371. export interface IPropertyDescriptionForEdition {
  13372. /** name of the property */
  13373. "propertyName": string;
  13374. /** display name of the property */
  13375. "displayName": string;
  13376. /** type of the property */
  13377. "type": PropertyTypeForEdition;
  13378. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13379. "groupName": string;
  13380. /** options for the property */
  13381. "options": IEditablePropertyOption;
  13382. }
  13383. /**
  13384. * Decorator that flags a property in a node material block as being editable
  13385. */
  13386. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13387. }
  13388. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  13389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13391. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13393. import { Nullable } from "babylonjs/types";
  13394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13395. import { Mesh } from "babylonjs/Meshes/mesh";
  13396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13397. import { Effect } from "babylonjs/Materials/effect";
  13398. import { Scene } from "babylonjs/scene";
  13399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13400. /**
  13401. * Block used to implement the refraction part of the sub surface module of the PBR material
  13402. */
  13403. export class RefractionBlock extends NodeMaterialBlock {
  13404. /** @hidden */
  13405. _define3DName: string;
  13406. /** @hidden */
  13407. _refractionMatrixName: string;
  13408. /** @hidden */
  13409. _defineLODRefractionAlpha: string;
  13410. /** @hidden */
  13411. _defineLinearSpecularRefraction: string;
  13412. /** @hidden */
  13413. _defineOppositeZ: string;
  13414. /** @hidden */
  13415. _cubeSamplerName: string;
  13416. /** @hidden */
  13417. _2DSamplerName: string;
  13418. /** @hidden */
  13419. _vRefractionMicrosurfaceInfosName: string;
  13420. /** @hidden */
  13421. _vRefractionInfosName: string;
  13422. /** @hidden */
  13423. _vRefractionFilteringInfoName: string;
  13424. private _scene;
  13425. /**
  13426. * The properties below are set by the main PBR block prior to calling methods of this class.
  13427. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13428. * It's less burden on the user side in the editor part.
  13429. */
  13430. /** @hidden */
  13431. viewConnectionPoint: NodeMaterialConnectionPoint;
  13432. /** @hidden */
  13433. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13434. /**
  13435. * This parameters will make the material used its opacity to control how much it is refracting against not.
  13436. * Materials half opaque for instance using refraction could benefit from this control.
  13437. */
  13438. linkRefractionWithTransparency: boolean;
  13439. /**
  13440. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13441. */
  13442. invertRefractionY: boolean;
  13443. /**
  13444. * Gets or sets the texture associated with the node
  13445. */
  13446. texture: Nullable<BaseTexture>;
  13447. /**
  13448. * Create a new RefractionBlock
  13449. * @param name defines the block name
  13450. */
  13451. constructor(name: string);
  13452. /**
  13453. * Gets the current class name
  13454. * @returns the class name
  13455. */
  13456. getClassName(): string;
  13457. /**
  13458. * Gets the intensity input component
  13459. */
  13460. get intensity(): NodeMaterialConnectionPoint;
  13461. /**
  13462. * Gets the tint at distance input component
  13463. */
  13464. get tintAtDistance(): NodeMaterialConnectionPoint;
  13465. /**
  13466. * Gets the view input component
  13467. */
  13468. get view(): NodeMaterialConnectionPoint;
  13469. /**
  13470. * Gets the refraction object output component
  13471. */
  13472. get refraction(): NodeMaterialConnectionPoint;
  13473. /**
  13474. * Returns true if the block has a texture
  13475. */
  13476. get hasTexture(): boolean;
  13477. protected _getTexture(): Nullable<BaseTexture>;
  13478. autoConfigure(material: NodeMaterial): void;
  13479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13480. isReady(): boolean;
  13481. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13482. /**
  13483. * Gets the main code of the block (fragment side)
  13484. * @param state current state of the node material building
  13485. * @returns the shader code
  13486. */
  13487. getCode(state: NodeMaterialBuildState): string;
  13488. protected _buildBlock(state: NodeMaterialBuildState): this;
  13489. protected _dumpPropertiesCode(): string;
  13490. serialize(): any;
  13491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13492. }
  13493. }
  13494. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  13495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13497. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13500. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13502. import { Nullable } from "babylonjs/types";
  13503. import { Scene } from "babylonjs/scene";
  13504. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  13505. /**
  13506. * Base block used as input for post process
  13507. */
  13508. export class CurrentScreenBlock extends NodeMaterialBlock {
  13509. private _samplerName;
  13510. private _linearDefineName;
  13511. private _gammaDefineName;
  13512. private _mainUVName;
  13513. private _tempTextureRead;
  13514. /**
  13515. * Gets or sets the texture associated with the node
  13516. */
  13517. texture: Nullable<BaseTexture>;
  13518. /**
  13519. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13520. */
  13521. convertToGammaSpace: boolean;
  13522. /**
  13523. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13524. */
  13525. convertToLinearSpace: boolean;
  13526. /**
  13527. * Create a new CurrentScreenBlock
  13528. * @param name defines the block name
  13529. */
  13530. constructor(name: string);
  13531. /**
  13532. * Gets the current class name
  13533. * @returns the class name
  13534. */
  13535. getClassName(): string;
  13536. /**
  13537. * Gets the uv input component
  13538. */
  13539. get uv(): NodeMaterialConnectionPoint;
  13540. /**
  13541. * Gets the rgba output component
  13542. */
  13543. get rgba(): NodeMaterialConnectionPoint;
  13544. /**
  13545. * Gets the rgb output component
  13546. */
  13547. get rgb(): NodeMaterialConnectionPoint;
  13548. /**
  13549. * Gets the r output component
  13550. */
  13551. get r(): NodeMaterialConnectionPoint;
  13552. /**
  13553. * Gets the g output component
  13554. */
  13555. get g(): NodeMaterialConnectionPoint;
  13556. /**
  13557. * Gets the b output component
  13558. */
  13559. get b(): NodeMaterialConnectionPoint;
  13560. /**
  13561. * Gets the a output component
  13562. */
  13563. get a(): NodeMaterialConnectionPoint;
  13564. /**
  13565. * Initialize the block and prepare the context for build
  13566. * @param state defines the state that will be used for the build
  13567. */
  13568. initialize(state: NodeMaterialBuildState): void;
  13569. get target(): NodeMaterialBlockTargets;
  13570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13571. isReady(): boolean;
  13572. private _injectVertexCode;
  13573. private _writeTextureRead;
  13574. private _writeOutput;
  13575. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13576. serialize(): any;
  13577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13578. }
  13579. }
  13580. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  13581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13585. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13587. import { Nullable } from "babylonjs/types";
  13588. import { Scene } from "babylonjs/scene";
  13589. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  13590. /**
  13591. * Base block used for the particle texture
  13592. */
  13593. export class ParticleTextureBlock extends NodeMaterialBlock {
  13594. private _samplerName;
  13595. private _linearDefineName;
  13596. private _gammaDefineName;
  13597. private _tempTextureRead;
  13598. /**
  13599. * Gets or sets the texture associated with the node
  13600. */
  13601. texture: Nullable<BaseTexture>;
  13602. /**
  13603. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13604. */
  13605. convertToGammaSpace: boolean;
  13606. /**
  13607. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13608. */
  13609. convertToLinearSpace: boolean;
  13610. /**
  13611. * Create a new ParticleTextureBlock
  13612. * @param name defines the block name
  13613. */
  13614. constructor(name: string);
  13615. /**
  13616. * Gets the current class name
  13617. * @returns the class name
  13618. */
  13619. getClassName(): string;
  13620. /**
  13621. * Gets the uv input component
  13622. */
  13623. get uv(): NodeMaterialConnectionPoint;
  13624. /**
  13625. * Gets the rgba output component
  13626. */
  13627. get rgba(): NodeMaterialConnectionPoint;
  13628. /**
  13629. * Gets the rgb output component
  13630. */
  13631. get rgb(): NodeMaterialConnectionPoint;
  13632. /**
  13633. * Gets the r output component
  13634. */
  13635. get r(): NodeMaterialConnectionPoint;
  13636. /**
  13637. * Gets the g output component
  13638. */
  13639. get g(): NodeMaterialConnectionPoint;
  13640. /**
  13641. * Gets the b output component
  13642. */
  13643. get b(): NodeMaterialConnectionPoint;
  13644. /**
  13645. * Gets the a output component
  13646. */
  13647. get a(): NodeMaterialConnectionPoint;
  13648. /**
  13649. * Initialize the block and prepare the context for build
  13650. * @param state defines the state that will be used for the build
  13651. */
  13652. initialize(state: NodeMaterialBuildState): void;
  13653. autoConfigure(material: NodeMaterial): void;
  13654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13655. isReady(): boolean;
  13656. private _writeOutput;
  13657. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13658. serialize(): any;
  13659. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13660. }
  13661. }
  13662. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  13663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13665. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  13666. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  13667. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  13668. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  13669. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  13670. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  13671. import { Scene } from "babylonjs/scene";
  13672. /**
  13673. * Class used to store shared data between 2 NodeMaterialBuildState
  13674. */
  13675. export class NodeMaterialBuildStateSharedData {
  13676. /**
  13677. * Gets the list of emitted varyings
  13678. */
  13679. temps: string[];
  13680. /**
  13681. * Gets the list of emitted varyings
  13682. */
  13683. varyings: string[];
  13684. /**
  13685. * Gets the varying declaration string
  13686. */
  13687. varyingDeclaration: string;
  13688. /**
  13689. * Input blocks
  13690. */
  13691. inputBlocks: InputBlock[];
  13692. /**
  13693. * Input blocks
  13694. */
  13695. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13696. /**
  13697. * Bindable blocks (Blocks that need to set data to the effect)
  13698. */
  13699. bindableBlocks: NodeMaterialBlock[];
  13700. /**
  13701. * List of blocks that can provide a compilation fallback
  13702. */
  13703. blocksWithFallbacks: NodeMaterialBlock[];
  13704. /**
  13705. * List of blocks that can provide a define update
  13706. */
  13707. blocksWithDefines: NodeMaterialBlock[];
  13708. /**
  13709. * List of blocks that can provide a repeatable content
  13710. */
  13711. repeatableContentBlocks: NodeMaterialBlock[];
  13712. /**
  13713. * List of blocks that can provide a dynamic list of uniforms
  13714. */
  13715. dynamicUniformBlocks: NodeMaterialBlock[];
  13716. /**
  13717. * List of blocks that can block the isReady function for the material
  13718. */
  13719. blockingBlocks: NodeMaterialBlock[];
  13720. /**
  13721. * Gets the list of animated inputs
  13722. */
  13723. animatedInputs: InputBlock[];
  13724. /**
  13725. * Build Id used to avoid multiple recompilations
  13726. */
  13727. buildId: number;
  13728. /** List of emitted variables */
  13729. variableNames: {
  13730. [key: string]: number;
  13731. };
  13732. /** List of emitted defines */
  13733. defineNames: {
  13734. [key: string]: number;
  13735. };
  13736. /** Should emit comments? */
  13737. emitComments: boolean;
  13738. /** Emit build activity */
  13739. verbose: boolean;
  13740. /** Gets or sets the hosting scene */
  13741. scene: Scene;
  13742. /**
  13743. * Gets the compilation hints emitted at compilation time
  13744. */
  13745. hints: {
  13746. needWorldViewMatrix: boolean;
  13747. needWorldViewProjectionMatrix: boolean;
  13748. needAlphaBlending: boolean;
  13749. needAlphaTesting: boolean;
  13750. };
  13751. /**
  13752. * List of compilation checks
  13753. */
  13754. checks: {
  13755. emitVertex: boolean;
  13756. emitFragment: boolean;
  13757. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13758. };
  13759. /**
  13760. * Is vertex program allowed to be empty?
  13761. */
  13762. allowEmptyVertexProgram: boolean;
  13763. /** Creates a new shared data */
  13764. constructor();
  13765. /**
  13766. * Emits console errors and exceptions if there is a failing check
  13767. */
  13768. emitErrors(): void;
  13769. }
  13770. }
  13771. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13772. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13773. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13774. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13775. /**
  13776. * Class used to store node based material build state
  13777. */
  13778. export class NodeMaterialBuildState {
  13779. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13780. supportUniformBuffers: boolean;
  13781. /**
  13782. * Gets the list of emitted attributes
  13783. */
  13784. attributes: string[];
  13785. /**
  13786. * Gets the list of emitted uniforms
  13787. */
  13788. uniforms: string[];
  13789. /**
  13790. * Gets the list of emitted constants
  13791. */
  13792. constants: string[];
  13793. /**
  13794. * Gets the list of emitted samplers
  13795. */
  13796. samplers: string[];
  13797. /**
  13798. * Gets the list of emitted functions
  13799. */
  13800. functions: {
  13801. [key: string]: string;
  13802. };
  13803. /**
  13804. * Gets the list of emitted extensions
  13805. */
  13806. extensions: {
  13807. [key: string]: string;
  13808. };
  13809. /**
  13810. * Gets the target of the compilation state
  13811. */
  13812. target: NodeMaterialBlockTargets;
  13813. /**
  13814. * Gets the list of emitted counters
  13815. */
  13816. counters: {
  13817. [key: string]: number;
  13818. };
  13819. /**
  13820. * Shared data between multiple NodeMaterialBuildState instances
  13821. */
  13822. sharedData: NodeMaterialBuildStateSharedData;
  13823. /** @hidden */
  13824. _vertexState: NodeMaterialBuildState;
  13825. /** @hidden */
  13826. _attributeDeclaration: string;
  13827. /** @hidden */
  13828. _uniformDeclaration: string;
  13829. /** @hidden */
  13830. _constantDeclaration: string;
  13831. /** @hidden */
  13832. _samplerDeclaration: string;
  13833. /** @hidden */
  13834. _varyingTransfer: string;
  13835. /** @hidden */
  13836. _injectAtEnd: string;
  13837. private _repeatableContentAnchorIndex;
  13838. /** @hidden */
  13839. _builtCompilationString: string;
  13840. /**
  13841. * Gets the emitted compilation strings
  13842. */
  13843. compilationString: string;
  13844. /**
  13845. * Finalize the compilation strings
  13846. * @param state defines the current compilation state
  13847. */
  13848. finalize(state: NodeMaterialBuildState): void;
  13849. /** @hidden */
  13850. get _repeatableContentAnchor(): string;
  13851. /** @hidden */
  13852. _getFreeVariableName(prefix: string): string;
  13853. /** @hidden */
  13854. _getFreeDefineName(prefix: string): string;
  13855. /** @hidden */
  13856. _excludeVariableName(name: string): void;
  13857. /** @hidden */
  13858. _emit2DSampler(name: string): void;
  13859. /** @hidden */
  13860. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13861. /** @hidden */
  13862. _emitExtension(name: string, extension: string, define?: string): void;
  13863. /** @hidden */
  13864. _emitFunction(name: string, code: string, comments: string): void;
  13865. /** @hidden */
  13866. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13867. replaceStrings?: {
  13868. search: RegExp;
  13869. replace: string;
  13870. }[];
  13871. repeatKey?: string;
  13872. }): string;
  13873. /** @hidden */
  13874. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13875. repeatKey?: string;
  13876. removeAttributes?: boolean;
  13877. removeUniforms?: boolean;
  13878. removeVaryings?: boolean;
  13879. removeIfDef?: boolean;
  13880. replaceStrings?: {
  13881. search: RegExp;
  13882. replace: string;
  13883. }[];
  13884. }, storeKey?: string): void;
  13885. /** @hidden */
  13886. _registerTempVariable(name: string): boolean;
  13887. /** @hidden */
  13888. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13889. /** @hidden */
  13890. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13891. /** @hidden */
  13892. _emitFloat(value: number): string;
  13893. }
  13894. }
  13895. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13896. /**
  13897. * Helper class used to generate session unique ID
  13898. */
  13899. export class UniqueIdGenerator {
  13900. private static _UniqueIdCounter;
  13901. /**
  13902. * Gets an unique (relatively to the current scene) Id
  13903. */
  13904. static get UniqueId(): number;
  13905. }
  13906. }
  13907. declare module "babylonjs/Materials/effectFallbacks" {
  13908. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13909. import { Effect } from "babylonjs/Materials/effect";
  13910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13911. /**
  13912. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13913. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13914. */
  13915. export class EffectFallbacks implements IEffectFallbacks {
  13916. private _defines;
  13917. private _currentRank;
  13918. private _maxRank;
  13919. private _mesh;
  13920. /**
  13921. * Removes the fallback from the bound mesh.
  13922. */
  13923. unBindMesh(): void;
  13924. /**
  13925. * Adds a fallback on the specified property.
  13926. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13927. * @param define The name of the define in the shader
  13928. */
  13929. addFallback(rank: number, define: string): void;
  13930. /**
  13931. * Sets the mesh to use CPU skinning when needing to fallback.
  13932. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13933. * @param mesh The mesh to use the fallbacks.
  13934. */
  13935. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13936. /**
  13937. * Checks to see if more fallbacks are still available.
  13938. */
  13939. get hasMoreFallbacks(): boolean;
  13940. /**
  13941. * Removes the defines that should be removed when falling back.
  13942. * @param currentDefines defines the current define statements for the shader.
  13943. * @param effect defines the current effect we try to compile
  13944. * @returns The resulting defines with defines of the current rank removed.
  13945. */
  13946. reduce(currentDefines: string, effect: Effect): string;
  13947. }
  13948. }
  13949. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13950. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13952. import { Nullable } from "babylonjs/types";
  13953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13954. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13955. import { Effect } from "babylonjs/Materials/effect";
  13956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13957. import { Mesh } from "babylonjs/Meshes/mesh";
  13958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13959. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13960. import { Scene } from "babylonjs/scene";
  13961. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13962. /**
  13963. * Defines a block that can be used inside a node based material
  13964. */
  13965. export class NodeMaterialBlock {
  13966. private _buildId;
  13967. private _buildTarget;
  13968. private _target;
  13969. private _isFinalMerger;
  13970. private _isInput;
  13971. private _name;
  13972. protected _isUnique: boolean;
  13973. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13974. inputsAreExclusive: boolean;
  13975. /** @hidden */
  13976. _codeVariableName: string;
  13977. /** @hidden */
  13978. _inputs: NodeMaterialConnectionPoint[];
  13979. /** @hidden */
  13980. _outputs: NodeMaterialConnectionPoint[];
  13981. /** @hidden */
  13982. _preparationId: number;
  13983. /** @hidden */
  13984. readonly _originalTargetIsNeutral: boolean;
  13985. /**
  13986. * Gets the name of the block
  13987. */
  13988. get name(): string;
  13989. /**
  13990. * Sets the name of the block. Will check if the name is valid.
  13991. */
  13992. set name(newName: string);
  13993. /**
  13994. * Gets or sets the unique id of the node
  13995. */
  13996. uniqueId: number;
  13997. /**
  13998. * Gets or sets the comments associated with this block
  13999. */
  14000. comments: string;
  14001. /**
  14002. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  14003. */
  14004. get isUnique(): boolean;
  14005. /**
  14006. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  14007. */
  14008. get isFinalMerger(): boolean;
  14009. /**
  14010. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  14011. */
  14012. get isInput(): boolean;
  14013. /**
  14014. * Gets or sets the build Id
  14015. */
  14016. get buildId(): number;
  14017. set buildId(value: number);
  14018. /**
  14019. * Gets or sets the target of the block
  14020. */
  14021. get target(): NodeMaterialBlockTargets;
  14022. set target(value: NodeMaterialBlockTargets);
  14023. /**
  14024. * Gets the list of input points
  14025. */
  14026. get inputs(): NodeMaterialConnectionPoint[];
  14027. /** Gets the list of output points */
  14028. get outputs(): NodeMaterialConnectionPoint[];
  14029. /**
  14030. * Find an input by its name
  14031. * @param name defines the name of the input to look for
  14032. * @returns the input or null if not found
  14033. */
  14034. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  14035. /**
  14036. * Find an output by its name
  14037. * @param name defines the name of the output to look for
  14038. * @returns the output or null if not found
  14039. */
  14040. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  14041. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  14042. visibleInInspector: boolean;
  14043. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  14044. visibleOnFrame: boolean;
  14045. /**
  14046. * Creates a new NodeMaterialBlock
  14047. * @param name defines the block name
  14048. * @param target defines the target of that block (Vertex by default)
  14049. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  14050. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  14051. */
  14052. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  14053. /**
  14054. * Initialize the block and prepare the context for build
  14055. * @param state defines the state that will be used for the build
  14056. */
  14057. initialize(state: NodeMaterialBuildState): void;
  14058. /**
  14059. * Bind data to effect. Will only be called for blocks with isBindable === true
  14060. * @param effect defines the effect to bind data to
  14061. * @param nodeMaterial defines the hosting NodeMaterial
  14062. * @param mesh defines the mesh that will be rendered
  14063. * @param subMesh defines the submesh that will be rendered
  14064. */
  14065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  14066. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  14067. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  14068. protected _writeFloat(value: number): string;
  14069. /**
  14070. * Gets the current class name e.g. "NodeMaterialBlock"
  14071. * @returns the class name
  14072. */
  14073. getClassName(): string;
  14074. /**
  14075. * Register a new input. Must be called inside a block constructor
  14076. * @param name defines the connection point name
  14077. * @param type defines the connection point type
  14078. * @param isOptional defines a boolean indicating that this input can be omitted
  14079. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14080. * @param point an already created connection point. If not provided, create a new one
  14081. * @returns the current block
  14082. */
  14083. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14084. /**
  14085. * Register a new output. Must be called inside a block constructor
  14086. * @param name defines the connection point name
  14087. * @param type defines the connection point type
  14088. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  14089. * @param point an already created connection point. If not provided, create a new one
  14090. * @returns the current block
  14091. */
  14092. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  14093. /**
  14094. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  14095. * @param forOutput defines an optional connection point to check compatibility with
  14096. * @returns the first available input or null
  14097. */
  14098. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  14099. /**
  14100. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  14101. * @param forBlock defines an optional block to check compatibility with
  14102. * @returns the first available input or null
  14103. */
  14104. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  14105. /**
  14106. * Gets the sibling of the given output
  14107. * @param current defines the current output
  14108. * @returns the next output in the list or null
  14109. */
  14110. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  14111. /**
  14112. * Connect current block with another block
  14113. * @param other defines the block to connect with
  14114. * @param options define the various options to help pick the right connections
  14115. * @returns the current block
  14116. */
  14117. connectTo(other: NodeMaterialBlock, options?: {
  14118. input?: string;
  14119. output?: string;
  14120. outputSwizzle?: string;
  14121. }): this | undefined;
  14122. protected _buildBlock(state: NodeMaterialBuildState): void;
  14123. /**
  14124. * Add uniforms, samplers and uniform buffers at compilation time
  14125. * @param state defines the state to update
  14126. * @param nodeMaterial defines the node material requesting the update
  14127. * @param defines defines the material defines to update
  14128. * @param uniformBuffers defines the list of uniform buffer names
  14129. */
  14130. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  14131. /**
  14132. * Add potential fallbacks if shader compilation fails
  14133. * @param mesh defines the mesh to be rendered
  14134. * @param fallbacks defines the current prioritized list of fallbacks
  14135. */
  14136. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  14137. /**
  14138. * Initialize defines for shader compilation
  14139. * @param mesh defines the mesh to be rendered
  14140. * @param nodeMaterial defines the node material requesting the update
  14141. * @param defines defines the material defines to update
  14142. * @param useInstances specifies that instances should be used
  14143. */
  14144. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  14145. /**
  14146. * Update defines for shader compilation
  14147. * @param mesh defines the mesh to be rendered
  14148. * @param nodeMaterial defines the node material requesting the update
  14149. * @param defines defines the material defines to update
  14150. * @param useInstances specifies that instances should be used
  14151. * @param subMesh defines which submesh to render
  14152. */
  14153. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14154. /**
  14155. * Lets the block try to connect some inputs automatically
  14156. * @param material defines the hosting NodeMaterial
  14157. */
  14158. autoConfigure(material: NodeMaterial): void;
  14159. /**
  14160. * Function called when a block is declared as repeatable content generator
  14161. * @param vertexShaderState defines the current compilation state for the vertex shader
  14162. * @param fragmentShaderState defines the current compilation state for the fragment shader
  14163. * @param mesh defines the mesh to be rendered
  14164. * @param defines defines the material defines to update
  14165. */
  14166. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  14167. /**
  14168. * Checks if the block is ready
  14169. * @param mesh defines the mesh to be rendered
  14170. * @param nodeMaterial defines the node material requesting the update
  14171. * @param defines defines the material defines to update
  14172. * @param useInstances specifies that instances should be used
  14173. * @returns true if the block is ready
  14174. */
  14175. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  14176. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  14177. private _processBuild;
  14178. /**
  14179. * Validates the new name for the block node.
  14180. * @param newName the new name to be given to the node.
  14181. * @returns false if the name is a reserve word, else true.
  14182. */
  14183. validateBlockName(newName: string): boolean;
  14184. /**
  14185. * Compile the current node and generate the shader code
  14186. * @param state defines the current compilation state (uniforms, samplers, current string)
  14187. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  14188. * @returns true if already built
  14189. */
  14190. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  14191. protected _inputRename(name: string): string;
  14192. protected _outputRename(name: string): string;
  14193. protected _dumpPropertiesCode(): string;
  14194. /** @hidden */
  14195. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  14196. /** @hidden */
  14197. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  14198. /**
  14199. * Clone the current block to a new identical block
  14200. * @param scene defines the hosting scene
  14201. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  14202. * @returns a copy of the current block
  14203. */
  14204. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  14205. /**
  14206. * Serializes this block in a JSON representation
  14207. * @returns the serialized block object
  14208. */
  14209. serialize(): any;
  14210. /** @hidden */
  14211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14212. private _deserializePortDisplayNamesAndExposedOnFrame;
  14213. /**
  14214. * Release resources
  14215. */
  14216. dispose(): void;
  14217. }
  14218. }
  14219. declare module "babylonjs/Materials/pushMaterial" {
  14220. import { Nullable } from "babylonjs/types";
  14221. import { Scene } from "babylonjs/scene";
  14222. import { Matrix } from "babylonjs/Maths/math.vector";
  14223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14224. import { Mesh } from "babylonjs/Meshes/mesh";
  14225. import { Material } from "babylonjs/Materials/material";
  14226. import { Effect } from "babylonjs/Materials/effect";
  14227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14228. /**
  14229. * Base class of materials working in push mode in babylon JS
  14230. * @hidden
  14231. */
  14232. export class PushMaterial extends Material {
  14233. protected _activeEffect: Effect;
  14234. protected _normalMatrix: Matrix;
  14235. constructor(name: string, scene: Scene);
  14236. getEffect(): Effect;
  14237. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14238. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  14239. /**
  14240. * Binds the given world matrix to the active effect
  14241. *
  14242. * @param world the matrix to bind
  14243. */
  14244. bindOnlyWorldMatrix(world: Matrix): void;
  14245. /**
  14246. * Binds the given normal matrix to the active effect
  14247. *
  14248. * @param normalMatrix the matrix to bind
  14249. */
  14250. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14251. bind(world: Matrix, mesh?: Mesh): void;
  14252. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14253. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14254. }
  14255. }
  14256. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  14257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14258. /**
  14259. * Root class for all node material optimizers
  14260. */
  14261. export class NodeMaterialOptimizer {
  14262. /**
  14263. * Function used to optimize a NodeMaterial graph
  14264. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  14265. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  14266. */
  14267. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  14268. }
  14269. }
  14270. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  14271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14274. import { Scene } from "babylonjs/scene";
  14275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14276. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  14277. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14278. /**
  14279. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  14280. */
  14281. export class TransformBlock extends NodeMaterialBlock {
  14282. /**
  14283. * Defines the value to use to complement W value to transform it to a Vector4
  14284. */
  14285. complementW: number;
  14286. /**
  14287. * Defines the value to use to complement z value to transform it to a Vector4
  14288. */
  14289. complementZ: number;
  14290. /**
  14291. * Creates a new TransformBlock
  14292. * @param name defines the block name
  14293. */
  14294. constructor(name: string);
  14295. /**
  14296. * Gets the current class name
  14297. * @returns the class name
  14298. */
  14299. getClassName(): string;
  14300. /**
  14301. * Gets the vector input
  14302. */
  14303. get vector(): NodeMaterialConnectionPoint;
  14304. /**
  14305. * Gets the output component
  14306. */
  14307. get output(): NodeMaterialConnectionPoint;
  14308. /**
  14309. * Gets the xyz output component
  14310. */
  14311. get xyz(): NodeMaterialConnectionPoint;
  14312. /**
  14313. * Gets the matrix transform input
  14314. */
  14315. get transform(): NodeMaterialConnectionPoint;
  14316. protected _buildBlock(state: NodeMaterialBuildState): this;
  14317. /**
  14318. * Update defines for shader compilation
  14319. * @param mesh defines the mesh to be rendered
  14320. * @param nodeMaterial defines the node material requesting the update
  14321. * @param defines defines the material defines to update
  14322. * @param useInstances specifies that instances should be used
  14323. * @param subMesh defines which submesh to render
  14324. */
  14325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  14326. serialize(): any;
  14327. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14328. protected _dumpPropertiesCode(): string;
  14329. }
  14330. }
  14331. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  14332. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14333. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14334. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14335. /**
  14336. * Block used to output the vertex position
  14337. */
  14338. export class VertexOutputBlock extends NodeMaterialBlock {
  14339. /**
  14340. * Creates a new VertexOutputBlock
  14341. * @param name defines the block name
  14342. */
  14343. constructor(name: string);
  14344. /**
  14345. * Gets the current class name
  14346. * @returns the class name
  14347. */
  14348. getClassName(): string;
  14349. /**
  14350. * Gets the vector input component
  14351. */
  14352. get vector(): NodeMaterialConnectionPoint;
  14353. protected _buildBlock(state: NodeMaterialBuildState): this;
  14354. }
  14355. }
  14356. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  14357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14360. /**
  14361. * Block used to output the final color
  14362. */
  14363. export class FragmentOutputBlock extends NodeMaterialBlock {
  14364. /**
  14365. * Create a new FragmentOutputBlock
  14366. * @param name defines the block name
  14367. */
  14368. constructor(name: string);
  14369. /**
  14370. * Gets the current class name
  14371. * @returns the class name
  14372. */
  14373. getClassName(): string;
  14374. /**
  14375. * Gets the rgba input component
  14376. */
  14377. get rgba(): NodeMaterialConnectionPoint;
  14378. /**
  14379. * Gets the rgb input component
  14380. */
  14381. get rgb(): NodeMaterialConnectionPoint;
  14382. /**
  14383. * Gets the a input component
  14384. */
  14385. get a(): NodeMaterialConnectionPoint;
  14386. protected _buildBlock(state: NodeMaterialBuildState): this;
  14387. }
  14388. }
  14389. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  14390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14393. /**
  14394. * Block used for the particle ramp gradient section
  14395. */
  14396. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14397. /**
  14398. * Create a new ParticleRampGradientBlock
  14399. * @param name defines the block name
  14400. */
  14401. constructor(name: string);
  14402. /**
  14403. * Gets the current class name
  14404. * @returns the class name
  14405. */
  14406. getClassName(): string;
  14407. /**
  14408. * Gets the color input component
  14409. */
  14410. get color(): NodeMaterialConnectionPoint;
  14411. /**
  14412. * Gets the rampColor output component
  14413. */
  14414. get rampColor(): NodeMaterialConnectionPoint;
  14415. /**
  14416. * Initialize the block and prepare the context for build
  14417. * @param state defines the state that will be used for the build
  14418. */
  14419. initialize(state: NodeMaterialBuildState): void;
  14420. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14421. }
  14422. }
  14423. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  14424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14427. /**
  14428. * Block used for the particle blend multiply section
  14429. */
  14430. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14431. /**
  14432. * Create a new ParticleBlendMultiplyBlock
  14433. * @param name defines the block name
  14434. */
  14435. constructor(name: string);
  14436. /**
  14437. * Gets the current class name
  14438. * @returns the class name
  14439. */
  14440. getClassName(): string;
  14441. /**
  14442. * Gets the color input component
  14443. */
  14444. get color(): NodeMaterialConnectionPoint;
  14445. /**
  14446. * Gets the alphaTexture input component
  14447. */
  14448. get alphaTexture(): NodeMaterialConnectionPoint;
  14449. /**
  14450. * Gets the alphaColor input component
  14451. */
  14452. get alphaColor(): NodeMaterialConnectionPoint;
  14453. /**
  14454. * Gets the blendColor output component
  14455. */
  14456. get blendColor(): NodeMaterialConnectionPoint;
  14457. /**
  14458. * Initialize the block and prepare the context for build
  14459. * @param state defines the state that will be used for the build
  14460. */
  14461. initialize(state: NodeMaterialBuildState): void;
  14462. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14463. }
  14464. }
  14465. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  14466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14469. /**
  14470. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14471. */
  14472. export class VectorMergerBlock extends NodeMaterialBlock {
  14473. /**
  14474. * Create a new VectorMergerBlock
  14475. * @param name defines the block name
  14476. */
  14477. constructor(name: string);
  14478. /**
  14479. * Gets the current class name
  14480. * @returns the class name
  14481. */
  14482. getClassName(): string;
  14483. /**
  14484. * Gets the xyz component (input)
  14485. */
  14486. get xyzIn(): NodeMaterialConnectionPoint;
  14487. /**
  14488. * Gets the xy component (input)
  14489. */
  14490. get xyIn(): NodeMaterialConnectionPoint;
  14491. /**
  14492. * Gets the x component (input)
  14493. */
  14494. get x(): NodeMaterialConnectionPoint;
  14495. /**
  14496. * Gets the y component (input)
  14497. */
  14498. get y(): NodeMaterialConnectionPoint;
  14499. /**
  14500. * Gets the z component (input)
  14501. */
  14502. get z(): NodeMaterialConnectionPoint;
  14503. /**
  14504. * Gets the w component (input)
  14505. */
  14506. get w(): NodeMaterialConnectionPoint;
  14507. /**
  14508. * Gets the xyzw component (output)
  14509. */
  14510. get xyzw(): NodeMaterialConnectionPoint;
  14511. /**
  14512. * Gets the xyz component (output)
  14513. */
  14514. get xyzOut(): NodeMaterialConnectionPoint;
  14515. /**
  14516. * Gets the xy component (output)
  14517. */
  14518. get xyOut(): NodeMaterialConnectionPoint;
  14519. /**
  14520. * Gets the xy component (output)
  14521. * @deprecated Please use xyOut instead.
  14522. */
  14523. get xy(): NodeMaterialConnectionPoint;
  14524. /**
  14525. * Gets the xyz component (output)
  14526. * @deprecated Please use xyzOut instead.
  14527. */
  14528. get xyz(): NodeMaterialConnectionPoint;
  14529. protected _buildBlock(state: NodeMaterialBuildState): this;
  14530. }
  14531. }
  14532. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  14533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14536. import { Vector2 } from "babylonjs/Maths/math.vector";
  14537. import { Scene } from "babylonjs/scene";
  14538. /**
  14539. * Block used to remap a float from a range to a new one
  14540. */
  14541. export class RemapBlock extends NodeMaterialBlock {
  14542. /**
  14543. * Gets or sets the source range
  14544. */
  14545. sourceRange: Vector2;
  14546. /**
  14547. * Gets or sets the target range
  14548. */
  14549. targetRange: Vector2;
  14550. /**
  14551. * Creates a new RemapBlock
  14552. * @param name defines the block name
  14553. */
  14554. constructor(name: string);
  14555. /**
  14556. * Gets the current class name
  14557. * @returns the class name
  14558. */
  14559. getClassName(): string;
  14560. /**
  14561. * Gets the input component
  14562. */
  14563. get input(): NodeMaterialConnectionPoint;
  14564. /**
  14565. * Gets the source min input component
  14566. */
  14567. get sourceMin(): NodeMaterialConnectionPoint;
  14568. /**
  14569. * Gets the source max input component
  14570. */
  14571. get sourceMax(): NodeMaterialConnectionPoint;
  14572. /**
  14573. * Gets the target min input component
  14574. */
  14575. get targetMin(): NodeMaterialConnectionPoint;
  14576. /**
  14577. * Gets the target max input component
  14578. */
  14579. get targetMax(): NodeMaterialConnectionPoint;
  14580. /**
  14581. * Gets the output component
  14582. */
  14583. get output(): NodeMaterialConnectionPoint;
  14584. protected _buildBlock(state: NodeMaterialBuildState): this;
  14585. protected _dumpPropertiesCode(): string;
  14586. serialize(): any;
  14587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14588. }
  14589. }
  14590. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  14591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  14592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  14593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  14594. /**
  14595. * Block used to multiply 2 values
  14596. */
  14597. export class MultiplyBlock extends NodeMaterialBlock {
  14598. /**
  14599. * Creates a new MultiplyBlock
  14600. * @param name defines the block name
  14601. */
  14602. constructor(name: string);
  14603. /**
  14604. * Gets the current class name
  14605. * @returns the class name
  14606. */
  14607. getClassName(): string;
  14608. /**
  14609. * Gets the left operand input component
  14610. */
  14611. get left(): NodeMaterialConnectionPoint;
  14612. /**
  14613. * Gets the right operand input component
  14614. */
  14615. get right(): NodeMaterialConnectionPoint;
  14616. /**
  14617. * Gets the output component
  14618. */
  14619. get output(): NodeMaterialConnectionPoint;
  14620. protected _buildBlock(state: NodeMaterialBuildState): this;
  14621. }
  14622. }
  14623. declare module "babylonjs/Misc/gradients" {
  14624. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14625. /** Interface used by value gradients (color, factor, ...) */
  14626. export interface IValueGradient {
  14627. /**
  14628. * Gets or sets the gradient value (between 0 and 1)
  14629. */
  14630. gradient: number;
  14631. }
  14632. /** Class used to store color4 gradient */
  14633. export class ColorGradient implements IValueGradient {
  14634. /**
  14635. * Gets or sets the gradient value (between 0 and 1)
  14636. */
  14637. gradient: number;
  14638. /**
  14639. * Gets or sets first associated color
  14640. */
  14641. color1: Color4;
  14642. /**
  14643. * Gets or sets second associated color
  14644. */
  14645. color2?: Color4 | undefined;
  14646. /**
  14647. * Creates a new color4 gradient
  14648. * @param gradient gets or sets the gradient value (between 0 and 1)
  14649. * @param color1 gets or sets first associated color
  14650. * @param color2 gets or sets first second color
  14651. */
  14652. constructor(
  14653. /**
  14654. * Gets or sets the gradient value (between 0 and 1)
  14655. */
  14656. gradient: number,
  14657. /**
  14658. * Gets or sets first associated color
  14659. */
  14660. color1: Color4,
  14661. /**
  14662. * Gets or sets second associated color
  14663. */
  14664. color2?: Color4 | undefined);
  14665. /**
  14666. * Will get a color picked randomly between color1 and color2.
  14667. * If color2 is undefined then color1 will be used
  14668. * @param result defines the target Color4 to store the result in
  14669. */
  14670. getColorToRef(result: Color4): void;
  14671. }
  14672. /** Class used to store color 3 gradient */
  14673. export class Color3Gradient implements IValueGradient {
  14674. /**
  14675. * Gets or sets the gradient value (between 0 and 1)
  14676. */
  14677. gradient: number;
  14678. /**
  14679. * Gets or sets the associated color
  14680. */
  14681. color: Color3;
  14682. /**
  14683. * Creates a new color3 gradient
  14684. * @param gradient gets or sets the gradient value (between 0 and 1)
  14685. * @param color gets or sets associated color
  14686. */
  14687. constructor(
  14688. /**
  14689. * Gets or sets the gradient value (between 0 and 1)
  14690. */
  14691. gradient: number,
  14692. /**
  14693. * Gets or sets the associated color
  14694. */
  14695. color: Color3);
  14696. }
  14697. /** Class used to store factor gradient */
  14698. export class FactorGradient implements IValueGradient {
  14699. /**
  14700. * Gets or sets the gradient value (between 0 and 1)
  14701. */
  14702. gradient: number;
  14703. /**
  14704. * Gets or sets first associated factor
  14705. */
  14706. factor1: number;
  14707. /**
  14708. * Gets or sets second associated factor
  14709. */
  14710. factor2?: number | undefined;
  14711. /**
  14712. * Creates a new factor gradient
  14713. * @param gradient gets or sets the gradient value (between 0 and 1)
  14714. * @param factor1 gets or sets first associated factor
  14715. * @param factor2 gets or sets second associated factor
  14716. */
  14717. constructor(
  14718. /**
  14719. * Gets or sets the gradient value (between 0 and 1)
  14720. */
  14721. gradient: number,
  14722. /**
  14723. * Gets or sets first associated factor
  14724. */
  14725. factor1: number,
  14726. /**
  14727. * Gets or sets second associated factor
  14728. */
  14729. factor2?: number | undefined);
  14730. /**
  14731. * Will get a number picked randomly between factor1 and factor2.
  14732. * If factor2 is undefined then factor1 will be used
  14733. * @returns the picked number
  14734. */
  14735. getFactor(): number;
  14736. }
  14737. /**
  14738. * Helper used to simplify some generic gradient tasks
  14739. */
  14740. export class GradientHelper {
  14741. /**
  14742. * Gets the current gradient from an array of IValueGradient
  14743. * @param ratio defines the current ratio to get
  14744. * @param gradients defines the array of IValueGradient
  14745. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14746. */
  14747. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14748. }
  14749. }
  14750. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14751. import { Nullable } from "babylonjs/types";
  14752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14753. import { Scene } from "babylonjs/scene";
  14754. module "babylonjs/Engines/thinEngine" {
  14755. interface ThinEngine {
  14756. /**
  14757. * Creates a raw texture
  14758. * @param data defines the data to store in the texture
  14759. * @param width defines the width of the texture
  14760. * @param height defines the height of the texture
  14761. * @param format defines the format of the data
  14762. * @param generateMipMaps defines if the engine should generate the mip levels
  14763. * @param invertY defines if data must be stored with Y axis inverted
  14764. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14765. * @param compression defines the compression used (null by default)
  14766. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14767. * @returns the raw texture inside an InternalTexture
  14768. */
  14769. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14770. /**
  14771. * Update a raw texture
  14772. * @param texture defines the texture to update
  14773. * @param data defines the data to store in the texture
  14774. * @param format defines the format of the data
  14775. * @param invertY defines if data must be stored with Y axis inverted
  14776. */
  14777. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14778. /**
  14779. * Update a raw texture
  14780. * @param texture defines the texture to update
  14781. * @param data defines the data to store in the texture
  14782. * @param format defines the format of the data
  14783. * @param invertY defines if data must be stored with Y axis inverted
  14784. * @param compression defines the compression used (null by default)
  14785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14786. */
  14787. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14788. /**
  14789. * Creates a new raw cube texture
  14790. * @param data defines the array of data to use to create each face
  14791. * @param size defines the size of the textures
  14792. * @param format defines the format of the data
  14793. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14794. * @param generateMipMaps defines if the engine should generate the mip levels
  14795. * @param invertY defines if data must be stored with Y axis inverted
  14796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14797. * @param compression defines the compression used (null by default)
  14798. * @returns the cube texture as an InternalTexture
  14799. */
  14800. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14801. /**
  14802. * Update a raw cube texture
  14803. * @param texture defines the texture to update
  14804. * @param data defines the data to store
  14805. * @param format defines the data format
  14806. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14807. * @param invertY defines if data must be stored with Y axis inverted
  14808. */
  14809. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14810. /**
  14811. * Update a raw cube texture
  14812. * @param texture defines the texture to update
  14813. * @param data defines the data to store
  14814. * @param format defines the data format
  14815. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14816. * @param invertY defines if data must be stored with Y axis inverted
  14817. * @param compression defines the compression used (null by default)
  14818. */
  14819. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14820. /**
  14821. * Update a raw cube texture
  14822. * @param texture defines the texture to update
  14823. * @param data defines the data to store
  14824. * @param format defines the data format
  14825. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14826. * @param invertY defines if data must be stored with Y axis inverted
  14827. * @param compression defines the compression used (null by default)
  14828. * @param level defines which level of the texture to update
  14829. */
  14830. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14831. /**
  14832. * Creates a new raw cube texture from a specified url
  14833. * @param url defines the url where the data is located
  14834. * @param scene defines the current scene
  14835. * @param size defines the size of the textures
  14836. * @param format defines the format of the data
  14837. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14838. * @param noMipmap defines if the engine should avoid generating the mip levels
  14839. * @param callback defines a callback used to extract texture data from loaded data
  14840. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14841. * @param onLoad defines a callback called when texture is loaded
  14842. * @param onError defines a callback called if there is an error
  14843. * @returns the cube texture as an InternalTexture
  14844. */
  14845. 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;
  14846. /**
  14847. * Creates a new raw cube texture from a specified url
  14848. * @param url defines the url where the data is located
  14849. * @param scene defines the current scene
  14850. * @param size defines the size of the textures
  14851. * @param format defines the format of the data
  14852. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14853. * @param noMipmap defines if the engine should avoid generating the mip levels
  14854. * @param callback defines a callback used to extract texture data from loaded data
  14855. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14856. * @param onLoad defines a callback called when texture is loaded
  14857. * @param onError defines a callback called if there is an error
  14858. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14859. * @param invertY defines if data must be stored with Y axis inverted
  14860. * @returns the cube texture as an InternalTexture
  14861. */
  14862. 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;
  14863. /**
  14864. * Creates a new raw 3D texture
  14865. * @param data defines the data used to create the texture
  14866. * @param width defines the width of the texture
  14867. * @param height defines the height of the texture
  14868. * @param depth defines the depth of the texture
  14869. * @param format defines the format of the texture
  14870. * @param generateMipMaps defines if the engine must generate mip levels
  14871. * @param invertY defines if data must be stored with Y axis inverted
  14872. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14873. * @param compression defines the compressed used (can be null)
  14874. * @param textureType defines the compressed used (can be null)
  14875. * @returns a new raw 3D texture (stored in an InternalTexture)
  14876. */
  14877. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14878. /**
  14879. * Update a raw 3D texture
  14880. * @param texture defines the texture to update
  14881. * @param data defines the data to store
  14882. * @param format defines the data format
  14883. * @param invertY defines if data must be stored with Y axis inverted
  14884. */
  14885. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14886. /**
  14887. * Update a raw 3D texture
  14888. * @param texture defines the texture to update
  14889. * @param data defines the data to store
  14890. * @param format defines the data format
  14891. * @param invertY defines if data must be stored with Y axis inverted
  14892. * @param compression defines the used compression (can be null)
  14893. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14894. */
  14895. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14896. /**
  14897. * Creates a new raw 2D array texture
  14898. * @param data defines the data used to create the texture
  14899. * @param width defines the width of the texture
  14900. * @param height defines the height of the texture
  14901. * @param depth defines the number of layers of the texture
  14902. * @param format defines the format of the texture
  14903. * @param generateMipMaps defines if the engine must generate mip levels
  14904. * @param invertY defines if data must be stored with Y axis inverted
  14905. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14906. * @param compression defines the compressed used (can be null)
  14907. * @param textureType defines the compressed used (can be null)
  14908. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14909. */
  14910. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14911. /**
  14912. * Update a raw 2D array texture
  14913. * @param texture defines the texture to update
  14914. * @param data defines the data to store
  14915. * @param format defines the data format
  14916. * @param invertY defines if data must be stored with Y axis inverted
  14917. */
  14918. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14919. /**
  14920. * Update a raw 2D array texture
  14921. * @param texture defines the texture to update
  14922. * @param data defines the data to store
  14923. * @param format defines the data format
  14924. * @param invertY defines if data must be stored with Y axis inverted
  14925. * @param compression defines the used compression (can be null)
  14926. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14927. */
  14928. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14929. }
  14930. }
  14931. }
  14932. declare module "babylonjs/Materials/Textures/rawTexture" {
  14933. import { Texture } from "babylonjs/Materials/Textures/texture";
  14934. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14935. import { Nullable } from "babylonjs/types";
  14936. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14937. import { Scene } from "babylonjs/scene";
  14938. /**
  14939. * Raw texture can help creating a texture directly from an array of data.
  14940. * This can be super useful if you either get the data from an uncompressed source or
  14941. * if you wish to create your texture pixel by pixel.
  14942. */
  14943. export class RawTexture extends Texture {
  14944. /**
  14945. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14946. */
  14947. format: number;
  14948. /**
  14949. * Instantiates a new RawTexture.
  14950. * Raw texture can help creating a texture directly from an array of data.
  14951. * This can be super useful if you either get the data from an uncompressed source or
  14952. * if you wish to create your texture pixel by pixel.
  14953. * @param data define the array of data to use to create the texture
  14954. * @param width define the width of the texture
  14955. * @param height define the height of the texture
  14956. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14957. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14958. * @param generateMipMaps define whether mip maps should be generated or not
  14959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14962. */
  14963. constructor(data: ArrayBufferView, width: number, height: number,
  14964. /**
  14965. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14966. */
  14967. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14968. /**
  14969. * Updates the texture underlying data.
  14970. * @param data Define the new data of the texture
  14971. */
  14972. update(data: ArrayBufferView): void;
  14973. /**
  14974. * Creates a luminance texture from some data.
  14975. * @param data Define the texture data
  14976. * @param width Define the width of the texture
  14977. * @param height Define the height of the texture
  14978. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14979. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14980. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14981. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14982. * @returns the luminance texture
  14983. */
  14984. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14985. /**
  14986. * Creates a luminance alpha texture from some data.
  14987. * @param data Define the texture data
  14988. * @param width Define the width of the texture
  14989. * @param height Define the height of the texture
  14990. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14991. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14992. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14993. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14994. * @returns the luminance alpha texture
  14995. */
  14996. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14997. /**
  14998. * Creates an alpha texture from some data.
  14999. * @param data Define the texture data
  15000. * @param width Define the width of the texture
  15001. * @param height Define the height of the texture
  15002. * @param sceneOrEngine defines the scene or engine the texture will belong to
  15003. * @param generateMipMaps Define whether or not to create mip maps for the texture
  15004. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  15005. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  15006. * @returns the alpha texture
  15007. */
  15008. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  15009. /**
  15010. * Creates a RGB texture from some data.
  15011. * @param data Define the texture data
  15012. * @param width Define the width of the texture
  15013. * @param height Define the height of the texture
  15014. * @param sceneOrEngine defines the scene or engine the texture will belong to
  15015. * @param generateMipMaps Define whether or not to create mip maps for the texture
  15016. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  15017. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  15018. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  15019. * @returns the RGB alpha texture
  15020. */
  15021. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  15022. /**
  15023. * Creates a RGBA texture from some data.
  15024. * @param data Define the texture data
  15025. * @param width Define the width of the texture
  15026. * @param height Define the height of the texture
  15027. * @param sceneOrEngine defines the scene or engine the texture will belong to
  15028. * @param generateMipMaps Define whether or not to create mip maps for the texture
  15029. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  15030. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  15031. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  15032. * @returns the RGBA texture
  15033. */
  15034. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  15035. /**
  15036. * Creates a R texture from some data.
  15037. * @param data Define the texture data
  15038. * @param width Define the width of the texture
  15039. * @param height Define the height of the texture
  15040. * @param sceneOrEngine defines the scene or engine the texture will belong to
  15041. * @param generateMipMaps Define whether or not to create mip maps for the texture
  15042. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  15043. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  15044. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  15045. * @returns the R texture
  15046. */
  15047. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  15048. }
  15049. }
  15050. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  15051. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  15052. import { IndicesArray, DataArray } from "babylonjs/types";
  15053. module "babylonjs/Engines/thinEngine" {
  15054. interface ThinEngine {
  15055. /**
  15056. * Update a dynamic index buffer
  15057. * @param indexBuffer defines the target index buffer
  15058. * @param indices defines the data to update
  15059. * @param offset defines the offset in the target index buffer where update should start
  15060. */
  15061. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  15062. /**
  15063. * Updates a dynamic vertex buffer.
  15064. * @param vertexBuffer the vertex buffer to update
  15065. * @param data the data used to update the vertex buffer
  15066. * @param byteOffset the byte offset of the data
  15067. * @param byteLength the byte length of the data
  15068. */
  15069. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  15070. }
  15071. }
  15072. }
  15073. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  15074. import { Scene } from "babylonjs/scene";
  15075. import { ISceneComponent } from "babylonjs/sceneComponent";
  15076. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  15077. module "babylonjs/abstractScene" {
  15078. interface AbstractScene {
  15079. /**
  15080. * The list of procedural textures added to the scene
  15081. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15082. */
  15083. proceduralTextures: Array<ProceduralTexture>;
  15084. }
  15085. }
  15086. /**
  15087. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15088. * in a given scene.
  15089. */
  15090. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15091. /**
  15092. * The component name helpful to identify the component in the list of scene components.
  15093. */
  15094. readonly name: string;
  15095. /**
  15096. * The scene the component belongs to.
  15097. */
  15098. scene: Scene;
  15099. /**
  15100. * Creates a new instance of the component for the given scene
  15101. * @param scene Defines the scene to register the component in
  15102. */
  15103. constructor(scene: Scene);
  15104. /**
  15105. * Registers the component in a given scene
  15106. */
  15107. register(): void;
  15108. /**
  15109. * Rebuilds the elements related to this component in case of
  15110. * context lost for instance.
  15111. */
  15112. rebuild(): void;
  15113. /**
  15114. * Disposes the component and the associated resources.
  15115. */
  15116. dispose(): void;
  15117. private _beforeClear;
  15118. }
  15119. }
  15120. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  15121. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15122. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  15123. module "babylonjs/Engines/thinEngine" {
  15124. interface ThinEngine {
  15125. /**
  15126. * Creates a new render target cube texture
  15127. * @param size defines the size of the texture
  15128. * @param options defines the options used to create the texture
  15129. * @returns a new render target cube texture stored in an InternalTexture
  15130. */
  15131. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15132. }
  15133. }
  15134. }
  15135. declare module "babylonjs/Shaders/procedural.vertex" {
  15136. /** @hidden */
  15137. export var proceduralVertexShader: {
  15138. name: string;
  15139. shader: string;
  15140. };
  15141. }
  15142. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  15143. import { Observable } from "babylonjs/Misc/observable";
  15144. import { Nullable } from "babylonjs/types";
  15145. import { Scene } from "babylonjs/scene";
  15146. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  15147. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15148. import { Effect } from "babylonjs/Materials/effect";
  15149. import { Texture } from "babylonjs/Materials/Textures/texture";
  15150. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15151. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  15152. import "babylonjs/Shaders/procedural.vertex";
  15153. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  15154. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  15155. /**
  15156. * 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.
  15157. * This is the base class of any Procedural texture and contains most of the shareable code.
  15158. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15159. */
  15160. export class ProceduralTexture extends Texture {
  15161. /**
  15162. * Define if the texture is enabled or not (disabled texture will not render)
  15163. */
  15164. isEnabled: boolean;
  15165. /**
  15166. * Define if the texture must be cleared before rendering (default is true)
  15167. */
  15168. autoClear: boolean;
  15169. /**
  15170. * Callback called when the texture is generated
  15171. */
  15172. onGenerated: () => void;
  15173. /**
  15174. * Event raised when the texture is generated
  15175. */
  15176. onGeneratedObservable: Observable<ProceduralTexture>;
  15177. /**
  15178. * Event raised before the texture is generated
  15179. */
  15180. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  15181. /**
  15182. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  15183. */
  15184. nodeMaterialSource: Nullable<NodeMaterial>;
  15185. /** @hidden */
  15186. _generateMipMaps: boolean;
  15187. /** @hidden **/
  15188. _effect: Effect;
  15189. /** @hidden */
  15190. _textures: {
  15191. [key: string]: Texture;
  15192. };
  15193. /** @hidden */
  15194. protected _fallbackTexture: Nullable<Texture>;
  15195. private _size;
  15196. private _textureType;
  15197. private _currentRefreshId;
  15198. private _frameId;
  15199. private _refreshRate;
  15200. private _vertexBuffers;
  15201. private _indexBuffer;
  15202. private _uniforms;
  15203. private _samplers;
  15204. private _fragment;
  15205. private _floats;
  15206. private _ints;
  15207. private _floatsArrays;
  15208. private _colors3;
  15209. private _colors4;
  15210. private _vectors2;
  15211. private _vectors3;
  15212. private _matrices;
  15213. private _fallbackTextureUsed;
  15214. private _fullEngine;
  15215. private _cachedDefines;
  15216. private _contentUpdateId;
  15217. private _contentData;
  15218. /**
  15219. * Instantiates a new procedural texture.
  15220. * 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.
  15221. * This is the base class of any Procedural texture and contains most of the shareable code.
  15222. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15223. * @param name Define the name of the texture
  15224. * @param size Define the size of the texture to create
  15225. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15226. * @param scene Define the scene the texture belongs to
  15227. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15228. * @param generateMipMaps Define if the texture should creates mip maps or not
  15229. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15230. * @param textureType The FBO internal texture type
  15231. */
  15232. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  15233. /**
  15234. * The effect that is created when initializing the post process.
  15235. * @returns The created effect corresponding the the postprocess.
  15236. */
  15237. getEffect(): Effect;
  15238. /**
  15239. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15240. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  15241. */
  15242. getContent(): Nullable<Promise<ArrayBufferView>>;
  15243. private _createIndexBuffer;
  15244. /** @hidden */
  15245. _rebuild(): void;
  15246. /**
  15247. * Resets the texture in order to recreate its associated resources.
  15248. * This can be called in case of context loss
  15249. */
  15250. reset(): void;
  15251. protected _getDefines(): string;
  15252. /**
  15253. * Is the texture ready to be used ? (rendered at least once)
  15254. * @returns true if ready, otherwise, false.
  15255. */
  15256. isReady(): boolean;
  15257. /**
  15258. * Resets the refresh counter of the texture and start bak from scratch.
  15259. * Could be useful to regenerate the texture if it is setup to render only once.
  15260. */
  15261. resetRefreshCounter(): void;
  15262. /**
  15263. * Set the fragment shader to use in order to render the texture.
  15264. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15265. */
  15266. setFragment(fragment: any): void;
  15267. /**
  15268. * Define the refresh rate of the texture or the rendering frequency.
  15269. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15270. */
  15271. get refreshRate(): number;
  15272. set refreshRate(value: number);
  15273. /** @hidden */
  15274. _shouldRender(): boolean;
  15275. /**
  15276. * Get the size the texture is rendering at.
  15277. * @returns the size (on cube texture it is always squared)
  15278. */
  15279. getRenderSize(): RenderTargetTextureSize;
  15280. /**
  15281. * Resize the texture to new value.
  15282. * @param size Define the new size the texture should have
  15283. * @param generateMipMaps Define whether the new texture should create mip maps
  15284. */
  15285. resize(size: number, generateMipMaps: boolean): void;
  15286. private _checkUniform;
  15287. /**
  15288. * Set a texture in the shader program used to render.
  15289. * @param name Define the name of the uniform samplers as defined in the shader
  15290. * @param texture Define the texture to bind to this sampler
  15291. * @return the texture itself allowing "fluent" like uniform updates
  15292. */
  15293. setTexture(name: string, texture: Texture): ProceduralTexture;
  15294. /**
  15295. * Set a float in the shader.
  15296. * @param name Define the name of the uniform as defined in the shader
  15297. * @param value Define the value to give to the uniform
  15298. * @return the texture itself allowing "fluent" like uniform updates
  15299. */
  15300. setFloat(name: string, value: number): ProceduralTexture;
  15301. /**
  15302. * Set a int in the shader.
  15303. * @param name Define the name of the uniform as defined in the shader
  15304. * @param value Define the value to give to the uniform
  15305. * @return the texture itself allowing "fluent" like uniform updates
  15306. */
  15307. setInt(name: string, value: number): ProceduralTexture;
  15308. /**
  15309. * Set an array of floats in the shader.
  15310. * @param name Define the name of the uniform as defined in the shader
  15311. * @param value Define the value to give to the uniform
  15312. * @return the texture itself allowing "fluent" like uniform updates
  15313. */
  15314. setFloats(name: string, value: number[]): ProceduralTexture;
  15315. /**
  15316. * Set a vec3 in the shader from a Color3.
  15317. * @param name Define the name of the uniform as defined in the shader
  15318. * @param value Define the value to give to the uniform
  15319. * @return the texture itself allowing "fluent" like uniform updates
  15320. */
  15321. setColor3(name: string, value: Color3): ProceduralTexture;
  15322. /**
  15323. * Set a vec4 in the shader from a Color4.
  15324. * @param name Define the name of the uniform as defined in the shader
  15325. * @param value Define the value to give to the uniform
  15326. * @return the texture itself allowing "fluent" like uniform updates
  15327. */
  15328. setColor4(name: string, value: Color4): ProceduralTexture;
  15329. /**
  15330. * Set a vec2 in the shader from a Vector2.
  15331. * @param name Define the name of the uniform as defined in the shader
  15332. * @param value Define the value to give to the uniform
  15333. * @return the texture itself allowing "fluent" like uniform updates
  15334. */
  15335. setVector2(name: string, value: Vector2): ProceduralTexture;
  15336. /**
  15337. * Set a vec3 in the shader from a Vector3.
  15338. * @param name Define the name of the uniform as defined in the shader
  15339. * @param value Define the value to give to the uniform
  15340. * @return the texture itself allowing "fluent" like uniform updates
  15341. */
  15342. setVector3(name: string, value: Vector3): ProceduralTexture;
  15343. /**
  15344. * Set a mat4 in the shader from a MAtrix.
  15345. * @param name Define the name of the uniform as defined in the shader
  15346. * @param value Define the value to give to the uniform
  15347. * @return the texture itself allowing "fluent" like uniform updates
  15348. */
  15349. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15350. /**
  15351. * Render the texture to its associated render target.
  15352. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15353. */
  15354. render(useCameraPostProcess?: boolean): void;
  15355. /**
  15356. * Clone the texture.
  15357. * @returns the cloned texture
  15358. */
  15359. clone(): ProceduralTexture;
  15360. /**
  15361. * Dispose the texture and release its associated resources.
  15362. */
  15363. dispose(): void;
  15364. }
  15365. }
  15366. declare module "babylonjs/Particles/baseParticleSystem" {
  15367. import { Nullable } from "babylonjs/types";
  15368. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  15369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15370. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  15371. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  15372. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15374. import { Color4 } from "babylonjs/Maths/math.color";
  15375. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15376. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  15377. import { Animation } from "babylonjs/Animations/animation";
  15378. import { Scene } from "babylonjs/scene";
  15379. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  15380. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15381. /**
  15382. * This represents the base class for particle system in Babylon.
  15383. * 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.
  15384. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15385. * @example https://doc.babylonjs.com/babylon101/particles
  15386. */
  15387. export class BaseParticleSystem {
  15388. /**
  15389. * Source color is added to the destination color without alpha affecting the result
  15390. */
  15391. static BLENDMODE_ONEONE: number;
  15392. /**
  15393. * Blend current color and particle color using particle’s alpha
  15394. */
  15395. static BLENDMODE_STANDARD: number;
  15396. /**
  15397. * Add current color and particle color multiplied by particle’s alpha
  15398. */
  15399. static BLENDMODE_ADD: number;
  15400. /**
  15401. * Multiply current color with particle color
  15402. */
  15403. static BLENDMODE_MULTIPLY: number;
  15404. /**
  15405. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15406. */
  15407. static BLENDMODE_MULTIPLYADD: number;
  15408. /**
  15409. * List of animations used by the particle system.
  15410. */
  15411. animations: Animation[];
  15412. /**
  15413. * Gets or sets the unique id of the particle system
  15414. */
  15415. uniqueId: number;
  15416. /**
  15417. * The id of the Particle system.
  15418. */
  15419. id: string;
  15420. /**
  15421. * The friendly name of the Particle system.
  15422. */
  15423. name: string;
  15424. /**
  15425. * Snippet ID if the particle system was created from the snippet server
  15426. */
  15427. snippetId: string;
  15428. /**
  15429. * The rendering group used by the Particle system to chose when to render.
  15430. */
  15431. renderingGroupId: number;
  15432. /**
  15433. * The emitter represents the Mesh or position we are attaching the particle system to.
  15434. */
  15435. emitter: Nullable<AbstractMesh | Vector3>;
  15436. /**
  15437. * The maximum number of particles to emit per frame
  15438. */
  15439. emitRate: number;
  15440. /**
  15441. * If you want to launch only a few particles at once, that can be done, as well.
  15442. */
  15443. manualEmitCount: number;
  15444. /**
  15445. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15446. */
  15447. updateSpeed: number;
  15448. /**
  15449. * The amount of time the particle system is running (depends of the overall update speed).
  15450. */
  15451. targetStopDuration: number;
  15452. /**
  15453. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15454. */
  15455. disposeOnStop: boolean;
  15456. /**
  15457. * Minimum power of emitting particles.
  15458. */
  15459. minEmitPower: number;
  15460. /**
  15461. * Maximum power of emitting particles.
  15462. */
  15463. maxEmitPower: number;
  15464. /**
  15465. * Minimum life time of emitting particles.
  15466. */
  15467. minLifeTime: number;
  15468. /**
  15469. * Maximum life time of emitting particles.
  15470. */
  15471. maxLifeTime: number;
  15472. /**
  15473. * Minimum Size of emitting particles.
  15474. */
  15475. minSize: number;
  15476. /**
  15477. * Maximum Size of emitting particles.
  15478. */
  15479. maxSize: number;
  15480. /**
  15481. * Minimum scale of emitting particles on X axis.
  15482. */
  15483. minScaleX: number;
  15484. /**
  15485. * Maximum scale of emitting particles on X axis.
  15486. */
  15487. maxScaleX: number;
  15488. /**
  15489. * Minimum scale of emitting particles on Y axis.
  15490. */
  15491. minScaleY: number;
  15492. /**
  15493. * Maximum scale of emitting particles on Y axis.
  15494. */
  15495. maxScaleY: number;
  15496. /**
  15497. * Gets or sets the minimal initial rotation in radians.
  15498. */
  15499. minInitialRotation: number;
  15500. /**
  15501. * Gets or sets the maximal initial rotation in radians.
  15502. */
  15503. maxInitialRotation: number;
  15504. /**
  15505. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15506. */
  15507. minAngularSpeed: number;
  15508. /**
  15509. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15510. */
  15511. maxAngularSpeed: number;
  15512. /**
  15513. * The texture used to render each particle. (this can be a spritesheet)
  15514. */
  15515. particleTexture: Nullable<BaseTexture>;
  15516. /**
  15517. * The layer mask we are rendering the particles through.
  15518. */
  15519. layerMask: number;
  15520. /**
  15521. * This can help using your own shader to render the particle system.
  15522. * The according effect will be created
  15523. */
  15524. customShader: any;
  15525. /**
  15526. * By default particle system starts as soon as they are created. This prevents the
  15527. * automatic start to happen and let you decide when to start emitting particles.
  15528. */
  15529. preventAutoStart: boolean;
  15530. protected _rootUrl: string;
  15531. private _noiseTexture;
  15532. /**
  15533. * Gets or sets a texture used to add random noise to particle positions
  15534. */
  15535. get noiseTexture(): Nullable<ProceduralTexture>;
  15536. set noiseTexture(value: Nullable<ProceduralTexture>);
  15537. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15538. noiseStrength: Vector3;
  15539. /**
  15540. * Callback triggered when the particle animation is ending.
  15541. */
  15542. onAnimationEnd: Nullable<() => void>;
  15543. /**
  15544. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15545. */
  15546. blendMode: number;
  15547. /**
  15548. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15549. * to override the particles.
  15550. */
  15551. forceDepthWrite: boolean;
  15552. /** 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 */
  15553. preWarmCycles: number;
  15554. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15555. preWarmStepOffset: number;
  15556. /**
  15557. * 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)
  15558. */
  15559. spriteCellChangeSpeed: number;
  15560. /**
  15561. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15562. */
  15563. startSpriteCellID: number;
  15564. /**
  15565. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15566. */
  15567. endSpriteCellID: number;
  15568. /**
  15569. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15570. */
  15571. spriteCellWidth: number;
  15572. /**
  15573. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15574. */
  15575. spriteCellHeight: number;
  15576. /**
  15577. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15578. */
  15579. spriteRandomStartCell: boolean;
  15580. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15581. translationPivot: Vector2;
  15582. /** @hidden */
  15583. protected _isAnimationSheetEnabled: boolean;
  15584. /**
  15585. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15586. */
  15587. beginAnimationOnStart: boolean;
  15588. /**
  15589. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15590. */
  15591. beginAnimationFrom: number;
  15592. /**
  15593. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15594. */
  15595. beginAnimationTo: number;
  15596. /**
  15597. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15598. */
  15599. beginAnimationLoop: boolean;
  15600. /**
  15601. * Gets or sets a world offset applied to all particles
  15602. */
  15603. worldOffset: Vector3;
  15604. /**
  15605. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15606. */
  15607. get isAnimationSheetEnabled(): boolean;
  15608. set isAnimationSheetEnabled(value: boolean);
  15609. /**
  15610. * Get hosting scene
  15611. * @returns the scene
  15612. */
  15613. getScene(): Nullable<Scene>;
  15614. /**
  15615. * You can use gravity if you want to give an orientation to your particles.
  15616. */
  15617. gravity: Vector3;
  15618. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15619. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15620. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15621. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15622. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15623. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15624. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15625. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15626. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15627. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15628. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15629. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15630. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15631. /**
  15632. * Defines the delay in milliseconds before starting the system (0 by default)
  15633. */
  15634. startDelay: number;
  15635. /**
  15636. * Gets the current list of drag gradients.
  15637. * You must use addDragGradient and removeDragGradient to update this list
  15638. * @returns the list of drag gradients
  15639. */
  15640. getDragGradients(): Nullable<Array<FactorGradient>>;
  15641. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15642. limitVelocityDamping: number;
  15643. /**
  15644. * Gets the current list of limit velocity gradients.
  15645. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  15646. * @returns the list of limit velocity gradients
  15647. */
  15648. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15649. /**
  15650. * Gets the current list of color gradients.
  15651. * You must use addColorGradient and removeColorGradient to update this list
  15652. * @returns the list of color gradients
  15653. */
  15654. getColorGradients(): Nullable<Array<ColorGradient>>;
  15655. /**
  15656. * Gets the current list of size gradients.
  15657. * You must use addSizeGradient and removeSizeGradient to update this list
  15658. * @returns the list of size gradients
  15659. */
  15660. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15661. /**
  15662. * Gets the current list of color remap gradients.
  15663. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  15664. * @returns the list of color remap gradients
  15665. */
  15666. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15667. /**
  15668. * Gets the current list of alpha remap gradients.
  15669. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  15670. * @returns the list of alpha remap gradients
  15671. */
  15672. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15673. /**
  15674. * Gets the current list of life time gradients.
  15675. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  15676. * @returns the list of life time gradients
  15677. */
  15678. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15679. /**
  15680. * Gets the current list of angular speed gradients.
  15681. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  15682. * @returns the list of angular speed gradients
  15683. */
  15684. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15685. /**
  15686. * Gets the current list of velocity gradients.
  15687. * You must use addVelocityGradient and removeVelocityGradient to update this list
  15688. * @returns the list of velocity gradients
  15689. */
  15690. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15691. /**
  15692. * Gets the current list of start size gradients.
  15693. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  15694. * @returns the list of start size gradients
  15695. */
  15696. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15697. /**
  15698. * Gets the current list of emit rate gradients.
  15699. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  15700. * @returns the list of emit rate gradients
  15701. */
  15702. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15703. /**
  15704. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15705. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15706. */
  15707. get direction1(): Vector3;
  15708. set direction1(value: Vector3);
  15709. /**
  15710. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15711. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15712. */
  15713. get direction2(): Vector3;
  15714. set direction2(value: Vector3);
  15715. /**
  15716. * 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.
  15717. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15718. */
  15719. get minEmitBox(): Vector3;
  15720. set minEmitBox(value: Vector3);
  15721. /**
  15722. * 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.
  15723. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15724. */
  15725. get maxEmitBox(): Vector3;
  15726. set maxEmitBox(value: Vector3);
  15727. /**
  15728. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15729. */
  15730. color1: Color4;
  15731. /**
  15732. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15733. */
  15734. color2: Color4;
  15735. /**
  15736. * Color the particle will have at the end of its lifetime
  15737. */
  15738. colorDead: Color4;
  15739. /**
  15740. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15741. */
  15742. textureMask: Color4;
  15743. /**
  15744. * The particle emitter type defines the emitter used by the particle system.
  15745. * It can be for example box, sphere, or cone...
  15746. */
  15747. particleEmitterType: IParticleEmitterType;
  15748. /** @hidden */
  15749. _isSubEmitter: boolean;
  15750. /**
  15751. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15752. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15753. */
  15754. billboardMode: number;
  15755. protected _isBillboardBased: boolean;
  15756. /**
  15757. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15758. */
  15759. get isBillboardBased(): boolean;
  15760. set isBillboardBased(value: boolean);
  15761. /**
  15762. * The scene the particle system belongs to.
  15763. */
  15764. protected _scene: Nullable<Scene>;
  15765. /**
  15766. * The engine the particle system belongs to.
  15767. */
  15768. protected _engine: ThinEngine;
  15769. /**
  15770. * Local cache of defines for image processing.
  15771. */
  15772. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15773. /**
  15774. * Default configuration related to image processing available in the standard Material.
  15775. */
  15776. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15777. /**
  15778. * Gets the image processing configuration used either in this material.
  15779. */
  15780. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15781. /**
  15782. * Sets the Default image processing configuration used either in the this material.
  15783. *
  15784. * If sets to null, the scene one is in use.
  15785. */
  15786. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15787. /**
  15788. * Attaches a new image processing configuration to the Standard Material.
  15789. * @param configuration
  15790. */
  15791. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15792. /** @hidden */
  15793. protected _reset(): void;
  15794. /** @hidden */
  15795. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15796. /**
  15797. * Instantiates a particle system.
  15798. * 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.
  15799. * @param name The name of the particle system
  15800. */
  15801. constructor(name: string);
  15802. /**
  15803. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15804. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15805. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15806. * @returns the emitter
  15807. */
  15808. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15809. /**
  15810. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15811. * @param radius The radius of the hemisphere to emit from
  15812. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15813. * @returns the emitter
  15814. */
  15815. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15816. /**
  15817. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15818. * @param radius The radius of the sphere to emit from
  15819. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15820. * @returns the emitter
  15821. */
  15822. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15823. /**
  15824. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15825. * @param radius The radius of the sphere to emit from
  15826. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15827. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15828. * @returns the emitter
  15829. */
  15830. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15831. /**
  15832. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15833. * @param radius The radius of the emission cylinder
  15834. * @param height The height of the emission cylinder
  15835. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15836. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15837. * @returns the emitter
  15838. */
  15839. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15840. /**
  15841. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15842. * @param radius The radius of the cylinder to emit from
  15843. * @param height The height of the emission cylinder
  15844. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15845. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15846. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15847. * @returns the emitter
  15848. */
  15849. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15850. /**
  15851. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15852. * @param radius The radius of the cone to emit from
  15853. * @param angle The base angle of the cone
  15854. * @returns the emitter
  15855. */
  15856. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15857. /**
  15858. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15859. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15860. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15861. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15862. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15863. * @returns the emitter
  15864. */
  15865. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15866. }
  15867. }
  15868. declare module "babylonjs/Particles/subEmitter" {
  15869. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15870. import { Scene } from "babylonjs/scene";
  15871. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15872. /**
  15873. * Type of sub emitter
  15874. */
  15875. export enum SubEmitterType {
  15876. /**
  15877. * Attached to the particle over it's lifetime
  15878. */
  15879. ATTACHED = 0,
  15880. /**
  15881. * Created when the particle dies
  15882. */
  15883. END = 1
  15884. }
  15885. /**
  15886. * Sub emitter class used to emit particles from an existing particle
  15887. */
  15888. export class SubEmitter {
  15889. /**
  15890. * the particle system to be used by the sub emitter
  15891. */
  15892. particleSystem: ParticleSystem;
  15893. /**
  15894. * Type of the submitter (Default: END)
  15895. */
  15896. type: SubEmitterType;
  15897. /**
  15898. * 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)
  15899. * Note: This only is supported when using an emitter of type Mesh
  15900. */
  15901. inheritDirection: boolean;
  15902. /**
  15903. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15904. */
  15905. inheritedVelocityAmount: number;
  15906. /**
  15907. * Creates a sub emitter
  15908. * @param particleSystem the particle system to be used by the sub emitter
  15909. */
  15910. constructor(
  15911. /**
  15912. * the particle system to be used by the sub emitter
  15913. */
  15914. particleSystem: ParticleSystem);
  15915. /**
  15916. * Clones the sub emitter
  15917. * @returns the cloned sub emitter
  15918. */
  15919. clone(): SubEmitter;
  15920. /**
  15921. * Serialize current object to a JSON object
  15922. * @returns the serialized object
  15923. */
  15924. serialize(): any;
  15925. /** @hidden */
  15926. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15927. /**
  15928. * Creates a new SubEmitter from a serialized JSON version
  15929. * @param serializationObject defines the JSON object to read from
  15930. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15931. * @param rootUrl defines the rootUrl for data loading
  15932. * @returns a new SubEmitter
  15933. */
  15934. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15935. /** Release associated resources */
  15936. dispose(): void;
  15937. }
  15938. }
  15939. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15940. /** @hidden */
  15941. export var clipPlaneFragmentDeclaration: {
  15942. name: string;
  15943. shader: string;
  15944. };
  15945. }
  15946. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15947. /** @hidden */
  15948. export var imageProcessingDeclaration: {
  15949. name: string;
  15950. shader: string;
  15951. };
  15952. }
  15953. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15954. /** @hidden */
  15955. export var imageProcessingFunctions: {
  15956. name: string;
  15957. shader: string;
  15958. };
  15959. }
  15960. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15961. /** @hidden */
  15962. export var clipPlaneFragment: {
  15963. name: string;
  15964. shader: string;
  15965. };
  15966. }
  15967. declare module "babylonjs/Shaders/particles.fragment" {
  15968. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15969. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15970. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15971. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15972. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15973. /** @hidden */
  15974. export var particlesPixelShader: {
  15975. name: string;
  15976. shader: string;
  15977. };
  15978. }
  15979. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15980. /** @hidden */
  15981. export var clipPlaneVertexDeclaration: {
  15982. name: string;
  15983. shader: string;
  15984. };
  15985. }
  15986. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15987. /** @hidden */
  15988. export var clipPlaneVertex: {
  15989. name: string;
  15990. shader: string;
  15991. };
  15992. }
  15993. declare module "babylonjs/Shaders/particles.vertex" {
  15994. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15995. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15996. /** @hidden */
  15997. export var particlesVertexShader: {
  15998. name: string;
  15999. shader: string;
  16000. };
  16001. }
  16002. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  16003. import { Nullable } from "babylonjs/types";
  16004. import { Plane } from "babylonjs/Maths/math";
  16005. /**
  16006. * Interface used to define entities containing multiple clip planes
  16007. */
  16008. export interface IClipPlanesHolder {
  16009. /**
  16010. * Gets or sets the active clipplane 1
  16011. */
  16012. clipPlane: Nullable<Plane>;
  16013. /**
  16014. * Gets or sets the active clipplane 2
  16015. */
  16016. clipPlane2: Nullable<Plane>;
  16017. /**
  16018. * Gets or sets the active clipplane 3
  16019. */
  16020. clipPlane3: Nullable<Plane>;
  16021. /**
  16022. * Gets or sets the active clipplane 4
  16023. */
  16024. clipPlane4: Nullable<Plane>;
  16025. /**
  16026. * Gets or sets the active clipplane 5
  16027. */
  16028. clipPlane5: Nullable<Plane>;
  16029. /**
  16030. * Gets or sets the active clipplane 6
  16031. */
  16032. clipPlane6: Nullable<Plane>;
  16033. }
  16034. }
  16035. declare module "babylonjs/Materials/thinMaterialHelper" {
  16036. import { Effect } from "babylonjs/Materials/effect";
  16037. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  16038. /**
  16039. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  16040. *
  16041. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  16042. *
  16043. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  16044. */
  16045. export class ThinMaterialHelper {
  16046. /**
  16047. * Binds the clip plane information from the holder to the effect.
  16048. * @param effect The effect we are binding the data to
  16049. * @param holder The entity containing the clip plane information
  16050. */
  16051. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  16052. }
  16053. }
  16054. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  16055. module "babylonjs/Engines/thinEngine" {
  16056. interface ThinEngine {
  16057. /**
  16058. * Sets alpha constants used by some alpha blending modes
  16059. * @param r defines the red component
  16060. * @param g defines the green component
  16061. * @param b defines the blue component
  16062. * @param a defines the alpha component
  16063. */
  16064. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  16065. /**
  16066. * Sets the current alpha mode
  16067. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  16068. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  16069. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  16070. */
  16071. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  16072. /**
  16073. * Gets the current alpha mode
  16074. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  16075. * @returns the current alpha mode
  16076. */
  16077. getAlphaMode(): number;
  16078. /**
  16079. * Sets the current alpha equation
  16080. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  16081. */
  16082. setAlphaEquation(equation: number): void;
  16083. /**
  16084. * Gets the current alpha equation.
  16085. * @returns the current alpha equation
  16086. */
  16087. getAlphaEquation(): number;
  16088. }
  16089. }
  16090. }
  16091. declare module "babylonjs/Particles/particleSystem" {
  16092. import { Nullable } from "babylonjs/types";
  16093. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16094. import { Observable } from "babylonjs/Misc/observable";
  16095. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16096. import { Effect } from "babylonjs/Materials/effect";
  16097. import { IDisposable } from "babylonjs/scene";
  16098. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16099. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  16100. import { Particle } from "babylonjs/Particles/particle";
  16101. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  16102. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16103. import "babylonjs/Shaders/particles.fragment";
  16104. import "babylonjs/Shaders/particles.vertex";
  16105. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16106. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16107. import "babylonjs/Engines/Extensions/engine.alpha";
  16108. import { Scene } from "babylonjs/scene";
  16109. /**
  16110. * This represents a particle system in Babylon.
  16111. * 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.
  16112. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16113. * @example https://doc.babylonjs.com/babylon101/particles
  16114. */
  16115. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16116. /**
  16117. * Billboard mode will only apply to Y axis
  16118. */
  16119. static readonly BILLBOARDMODE_Y: number;
  16120. /**
  16121. * Billboard mode will apply to all axes
  16122. */
  16123. static readonly BILLBOARDMODE_ALL: number;
  16124. /**
  16125. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16126. */
  16127. static readonly BILLBOARDMODE_STRETCHED: number;
  16128. /**
  16129. * This function can be defined to provide custom update for active particles.
  16130. * This function will be called instead of regular update (age, position, color, etc.).
  16131. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16132. */
  16133. updateFunction: (particles: Particle[]) => void;
  16134. private _emitterWorldMatrix;
  16135. /**
  16136. * This function can be defined to specify initial direction for every new particle.
  16137. * It by default use the emitterType defined function
  16138. */
  16139. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  16140. /**
  16141. * This function can be defined to specify initial position for every new particle.
  16142. * It by default use the emitterType defined function
  16143. */
  16144. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  16145. /**
  16146. * @hidden
  16147. */
  16148. _inheritedVelocityOffset: Vector3;
  16149. /**
  16150. * An event triggered when the system is disposed
  16151. */
  16152. onDisposeObservable: Observable<IParticleSystem>;
  16153. /**
  16154. * An event triggered when the system is stopped
  16155. */
  16156. onStoppedObservable: Observable<IParticleSystem>;
  16157. private _onDisposeObserver;
  16158. /**
  16159. * Sets a callback that will be triggered when the system is disposed
  16160. */
  16161. set onDispose(callback: () => void);
  16162. private _particles;
  16163. private _epsilon;
  16164. private _capacity;
  16165. private _stockParticles;
  16166. private _newPartsExcess;
  16167. private _vertexData;
  16168. private _vertexBuffer;
  16169. private _vertexBuffers;
  16170. private _spriteBuffer;
  16171. private _indexBuffer;
  16172. private _effect;
  16173. private _customEffect;
  16174. private _cachedDefines;
  16175. private _scaledColorStep;
  16176. private _colorDiff;
  16177. private _scaledDirection;
  16178. private _scaledGravity;
  16179. private _currentRenderId;
  16180. private _alive;
  16181. private _useInstancing;
  16182. private _vertexArrayObject;
  16183. private _started;
  16184. private _stopped;
  16185. private _actualFrame;
  16186. private _scaledUpdateSpeed;
  16187. private _vertexBufferSize;
  16188. /** @hidden */
  16189. _currentEmitRateGradient: Nullable<FactorGradient>;
  16190. /** @hidden */
  16191. _currentEmitRate1: number;
  16192. /** @hidden */
  16193. _currentEmitRate2: number;
  16194. /** @hidden */
  16195. _currentStartSizeGradient: Nullable<FactorGradient>;
  16196. /** @hidden */
  16197. _currentStartSize1: number;
  16198. /** @hidden */
  16199. _currentStartSize2: number;
  16200. private readonly _rawTextureWidth;
  16201. private _rampGradientsTexture;
  16202. private _useRampGradients;
  16203. /** Gets or sets a matrix to use to compute projection */
  16204. defaultProjectionMatrix: Matrix;
  16205. /** Gets or sets a matrix to use to compute view */
  16206. defaultViewMatrix: Matrix;
  16207. /** Gets or sets a boolean indicating that ramp gradients must be used
  16208. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16209. */
  16210. get useRampGradients(): boolean;
  16211. set useRampGradients(value: boolean);
  16212. /**
  16213. * 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.
  16214. * 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: [])
  16215. */
  16216. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16217. private _subEmitters;
  16218. /**
  16219. * @hidden
  16220. * If the particle systems emitter should be disposed when the particle system is disposed
  16221. */
  16222. _disposeEmitterOnDispose: boolean;
  16223. /**
  16224. * The current active Sub-systems, this property is used by the root particle system only.
  16225. */
  16226. activeSubSystems: Array<ParticleSystem>;
  16227. /**
  16228. * Specifies if the particles are updated in emitter local space or world space
  16229. */
  16230. isLocal: boolean;
  16231. private _rootParticleSystem;
  16232. /**
  16233. * Gets the current list of active particles
  16234. */
  16235. get particles(): Particle[];
  16236. /**
  16237. * Gets the number of particles active at the same time.
  16238. * @returns The number of active particles.
  16239. */
  16240. getActiveCount(): number;
  16241. /**
  16242. * Returns the string "ParticleSystem"
  16243. * @returns a string containing the class name
  16244. */
  16245. getClassName(): string;
  16246. /**
  16247. * Gets a boolean indicating that the system is stopping
  16248. * @returns true if the system is currently stopping
  16249. */
  16250. isStopping(): boolean;
  16251. /**
  16252. * Gets the custom effect used to render the particles
  16253. * @param blendMode Blend mode for which the effect should be retrieved
  16254. * @returns The effect
  16255. */
  16256. getCustomEffect(blendMode?: number): Nullable<Effect>;
  16257. /**
  16258. * Sets the custom effect used to render the particles
  16259. * @param effect The effect to set
  16260. * @param blendMode Blend mode for which the effect should be set
  16261. */
  16262. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  16263. /** @hidden */
  16264. private _onBeforeDrawParticlesObservable;
  16265. /**
  16266. * Observable that will be called just before the particles are drawn
  16267. */
  16268. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  16269. /**
  16270. * Gets the name of the particle vertex shader
  16271. */
  16272. get vertexShaderName(): string;
  16273. /**
  16274. * Instantiates a particle system.
  16275. * 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.
  16276. * @param name The name of the particle system
  16277. * @param capacity The max number of particles alive at the same time
  16278. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  16279. * @param customEffect a custom effect used to change the way particles are rendered by default
  16280. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16281. * @param epsilon Offset used to render the particles
  16282. */
  16283. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16284. private _addFactorGradient;
  16285. private _removeFactorGradient;
  16286. /**
  16287. * Adds a new life time gradient
  16288. * @param gradient defines the gradient to use (between 0 and 1)
  16289. * @param factor defines the life time factor to affect to the specified gradient
  16290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16291. * @returns the current particle system
  16292. */
  16293. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16294. /**
  16295. * Remove a specific life time gradient
  16296. * @param gradient defines the gradient to remove
  16297. * @returns the current particle system
  16298. */
  16299. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16300. /**
  16301. * Adds a new size gradient
  16302. * @param gradient defines the gradient to use (between 0 and 1)
  16303. * @param factor defines the size factor to affect to the specified gradient
  16304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16305. * @returns the current particle system
  16306. */
  16307. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16308. /**
  16309. * Remove a specific size gradient
  16310. * @param gradient defines the gradient to remove
  16311. * @returns the current particle system
  16312. */
  16313. removeSizeGradient(gradient: number): IParticleSystem;
  16314. /**
  16315. * Adds a new color remap gradient
  16316. * @param gradient defines the gradient to use (between 0 and 1)
  16317. * @param min defines the color remap minimal range
  16318. * @param max defines the color remap maximal range
  16319. * @returns the current particle system
  16320. */
  16321. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16322. /**
  16323. * Remove a specific color remap gradient
  16324. * @param gradient defines the gradient to remove
  16325. * @returns the current particle system
  16326. */
  16327. removeColorRemapGradient(gradient: number): IParticleSystem;
  16328. /**
  16329. * Adds a new alpha remap gradient
  16330. * @param gradient defines the gradient to use (between 0 and 1)
  16331. * @param min defines the alpha remap minimal range
  16332. * @param max defines the alpha remap maximal range
  16333. * @returns the current particle system
  16334. */
  16335. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16336. /**
  16337. * Remove a specific alpha remap gradient
  16338. * @param gradient defines the gradient to remove
  16339. * @returns the current particle system
  16340. */
  16341. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16342. /**
  16343. * Adds a new angular speed gradient
  16344. * @param gradient defines the gradient to use (between 0 and 1)
  16345. * @param factor defines the angular speed to affect to the specified gradient
  16346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16347. * @returns the current particle system
  16348. */
  16349. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16350. /**
  16351. * Remove a specific angular speed gradient
  16352. * @param gradient defines the gradient to remove
  16353. * @returns the current particle system
  16354. */
  16355. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16356. /**
  16357. * Adds a new velocity gradient
  16358. * @param gradient defines the gradient to use (between 0 and 1)
  16359. * @param factor defines the velocity to affect to the specified gradient
  16360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16361. * @returns the current particle system
  16362. */
  16363. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16364. /**
  16365. * Remove a specific velocity gradient
  16366. * @param gradient defines the gradient to remove
  16367. * @returns the current particle system
  16368. */
  16369. removeVelocityGradient(gradient: number): IParticleSystem;
  16370. /**
  16371. * Adds a new limit velocity gradient
  16372. * @param gradient defines the gradient to use (between 0 and 1)
  16373. * @param factor defines the limit velocity value to affect to the specified gradient
  16374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16375. * @returns the current particle system
  16376. */
  16377. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16378. /**
  16379. * Remove a specific limit velocity gradient
  16380. * @param gradient defines the gradient to remove
  16381. * @returns the current particle system
  16382. */
  16383. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16384. /**
  16385. * Adds a new drag gradient
  16386. * @param gradient defines the gradient to use (between 0 and 1)
  16387. * @param factor defines the drag value to affect to the specified gradient
  16388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16389. * @returns the current particle system
  16390. */
  16391. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16392. /**
  16393. * Remove a specific drag gradient
  16394. * @param gradient defines the gradient to remove
  16395. * @returns the current particle system
  16396. */
  16397. removeDragGradient(gradient: number): IParticleSystem;
  16398. /**
  16399. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16400. * @param gradient defines the gradient to use (between 0 and 1)
  16401. * @param factor defines the emit rate value to affect to the specified gradient
  16402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16403. * @returns the current particle system
  16404. */
  16405. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16406. /**
  16407. * Remove a specific emit rate gradient
  16408. * @param gradient defines the gradient to remove
  16409. * @returns the current particle system
  16410. */
  16411. removeEmitRateGradient(gradient: number): IParticleSystem;
  16412. /**
  16413. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16414. * @param gradient defines the gradient to use (between 0 and 1)
  16415. * @param factor defines the start size value to affect to the specified gradient
  16416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16417. * @returns the current particle system
  16418. */
  16419. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16420. /**
  16421. * Remove a specific start size gradient
  16422. * @param gradient defines the gradient to remove
  16423. * @returns the current particle system
  16424. */
  16425. removeStartSizeGradient(gradient: number): IParticleSystem;
  16426. private _createRampGradientTexture;
  16427. /**
  16428. * Gets the current list of ramp gradients.
  16429. * You must use addRampGradient and removeRampGradient to update this list
  16430. * @returns the list of ramp gradients
  16431. */
  16432. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16433. /** Force the system to rebuild all gradients that need to be resync */
  16434. forceRefreshGradients(): void;
  16435. private _syncRampGradientTexture;
  16436. /**
  16437. * Adds a new ramp gradient used to remap particle colors
  16438. * @param gradient defines the gradient to use (between 0 and 1)
  16439. * @param color defines the color to affect to the specified gradient
  16440. * @returns the current particle system
  16441. */
  16442. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16443. /**
  16444. * Remove a specific ramp gradient
  16445. * @param gradient defines the gradient to remove
  16446. * @returns the current particle system
  16447. */
  16448. removeRampGradient(gradient: number): ParticleSystem;
  16449. /**
  16450. * Adds a new color gradient
  16451. * @param gradient defines the gradient to use (between 0 and 1)
  16452. * @param color1 defines the color to affect to the specified gradient
  16453. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16454. * @returns this particle system
  16455. */
  16456. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16457. /**
  16458. * Remove a specific color gradient
  16459. * @param gradient defines the gradient to remove
  16460. * @returns this particle system
  16461. */
  16462. removeColorGradient(gradient: number): IParticleSystem;
  16463. private _fetchR;
  16464. protected _reset(): void;
  16465. private _resetEffect;
  16466. private _createVertexBuffers;
  16467. private _createIndexBuffer;
  16468. /**
  16469. * Gets the maximum number of particles active at the same time.
  16470. * @returns The max number of active particles.
  16471. */
  16472. getCapacity(): number;
  16473. /**
  16474. * Gets whether there are still active particles in the system.
  16475. * @returns True if it is alive, otherwise false.
  16476. */
  16477. isAlive(): boolean;
  16478. /**
  16479. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16480. * @returns True if it has been started, otherwise false.
  16481. */
  16482. isStarted(): boolean;
  16483. private _prepareSubEmitterInternalArray;
  16484. /**
  16485. * Starts the particle system and begins to emit
  16486. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16487. */
  16488. start(delay?: number): void;
  16489. /**
  16490. * Stops the particle system.
  16491. * @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.
  16492. */
  16493. stop(stopSubEmitters?: boolean): void;
  16494. /**
  16495. * Remove all active particles
  16496. */
  16497. reset(): void;
  16498. /**
  16499. * @hidden (for internal use only)
  16500. */
  16501. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16502. /**
  16503. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16504. * Its lifetime will start back at 0.
  16505. */
  16506. recycleParticle: (particle: Particle) => void;
  16507. private _stopSubEmitters;
  16508. private _createParticle;
  16509. private _removeFromRoot;
  16510. private _emitFromParticle;
  16511. private _update;
  16512. /** @hidden */
  16513. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16514. /** @hidden */
  16515. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16516. /**
  16517. * Fill the defines array according to the current settings of the particle system
  16518. * @param defines Array to be updated
  16519. * @param blendMode blend mode to take into account when updating the array
  16520. */
  16521. fillDefines(defines: Array<string>, blendMode: number): void;
  16522. /**
  16523. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16524. * @param uniforms Uniforms array to fill
  16525. * @param attributes Attributes array to fill
  16526. * @param samplers Samplers array to fill
  16527. */
  16528. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16529. /** @hidden */
  16530. private _getEffect;
  16531. /**
  16532. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16533. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16534. */
  16535. animate(preWarmOnly?: boolean): void;
  16536. private _appendParticleVertices;
  16537. /**
  16538. * Rebuilds the particle system.
  16539. */
  16540. rebuild(): void;
  16541. /**
  16542. * Is this system ready to be used/rendered
  16543. * @return true if the system is ready
  16544. */
  16545. isReady(): boolean;
  16546. private _render;
  16547. /**
  16548. * Renders the particle system in its current state.
  16549. * @returns the current number of particles
  16550. */
  16551. render(): number;
  16552. /**
  16553. * Disposes the particle system and free the associated resources
  16554. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  16555. */
  16556. dispose(disposeTexture?: boolean): void;
  16557. /**
  16558. * Clones the particle system.
  16559. * @param name The name of the cloned object
  16560. * @param newEmitter The new emitter to use
  16561. * @returns the cloned particle system
  16562. */
  16563. clone(name: string, newEmitter: any): ParticleSystem;
  16564. /**
  16565. * Serializes the particle system to a JSON object
  16566. * @param serializeTexture defines if the texture must be serialized as well
  16567. * @returns the JSON object
  16568. */
  16569. serialize(serializeTexture?: boolean): any;
  16570. /** @hidden */
  16571. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16572. /** @hidden */
  16573. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16574. /**
  16575. * Parses a JSON object to create a particle system.
  16576. * @param parsedParticleSystem The JSON object to parse
  16577. * @param sceneOrEngine The scene or the engine to create the particle system in
  16578. * @param rootUrl The root url to use to load external dependencies like texture
  16579. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16580. * @returns the Parsed particle system
  16581. */
  16582. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16583. }
  16584. }
  16585. declare module "babylonjs/Particles/particle" {
  16586. import { Nullable } from "babylonjs/types";
  16587. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  16588. import { Color4 } from "babylonjs/Maths/math.color";
  16589. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  16590. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  16591. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  16592. /**
  16593. * A particle represents one of the element emitted by a particle system.
  16594. * This is mainly define by its coordinates, direction, velocity and age.
  16595. */
  16596. export class Particle {
  16597. /**
  16598. * The particle system the particle belongs to.
  16599. */
  16600. particleSystem: ParticleSystem;
  16601. private static _Count;
  16602. /**
  16603. * Unique ID of the particle
  16604. */
  16605. id: number;
  16606. /**
  16607. * The world position of the particle in the scene.
  16608. */
  16609. position: Vector3;
  16610. /**
  16611. * The world direction of the particle in the scene.
  16612. */
  16613. direction: Vector3;
  16614. /**
  16615. * The color of the particle.
  16616. */
  16617. color: Color4;
  16618. /**
  16619. * The color change of the particle per step.
  16620. */
  16621. colorStep: Color4;
  16622. /**
  16623. * Defines how long will the life of the particle be.
  16624. */
  16625. lifeTime: number;
  16626. /**
  16627. * The current age of the particle.
  16628. */
  16629. age: number;
  16630. /**
  16631. * The current size of the particle.
  16632. */
  16633. size: number;
  16634. /**
  16635. * The current scale of the particle.
  16636. */
  16637. scale: Vector2;
  16638. /**
  16639. * The current angle of the particle.
  16640. */
  16641. angle: number;
  16642. /**
  16643. * Defines how fast is the angle changing.
  16644. */
  16645. angularSpeed: number;
  16646. /**
  16647. * Defines the cell index used by the particle to be rendered from a sprite.
  16648. */
  16649. cellIndex: number;
  16650. /**
  16651. * The information required to support color remapping
  16652. */
  16653. remapData: Vector4;
  16654. /** @hidden */
  16655. _randomCellOffset?: number;
  16656. /** @hidden */
  16657. _initialDirection: Nullable<Vector3>;
  16658. /** @hidden */
  16659. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16660. /** @hidden */
  16661. _initialStartSpriteCellID: number;
  16662. /** @hidden */
  16663. _initialEndSpriteCellID: number;
  16664. /** @hidden */
  16665. _currentColorGradient: Nullable<ColorGradient>;
  16666. /** @hidden */
  16667. _currentColor1: Color4;
  16668. /** @hidden */
  16669. _currentColor2: Color4;
  16670. /** @hidden */
  16671. _currentSizeGradient: Nullable<FactorGradient>;
  16672. /** @hidden */
  16673. _currentSize1: number;
  16674. /** @hidden */
  16675. _currentSize2: number;
  16676. /** @hidden */
  16677. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16678. /** @hidden */
  16679. _currentAngularSpeed1: number;
  16680. /** @hidden */
  16681. _currentAngularSpeed2: number;
  16682. /** @hidden */
  16683. _currentVelocityGradient: Nullable<FactorGradient>;
  16684. /** @hidden */
  16685. _currentVelocity1: number;
  16686. /** @hidden */
  16687. _currentVelocity2: number;
  16688. /** @hidden */
  16689. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16690. /** @hidden */
  16691. _currentLimitVelocity1: number;
  16692. /** @hidden */
  16693. _currentLimitVelocity2: number;
  16694. /** @hidden */
  16695. _currentDragGradient: Nullable<FactorGradient>;
  16696. /** @hidden */
  16697. _currentDrag1: number;
  16698. /** @hidden */
  16699. _currentDrag2: number;
  16700. /** @hidden */
  16701. _randomNoiseCoordinates1: Vector3;
  16702. /** @hidden */
  16703. _randomNoiseCoordinates2: Vector3;
  16704. /** @hidden */
  16705. _localPosition?: Vector3;
  16706. /**
  16707. * Creates a new instance Particle
  16708. * @param particleSystem the particle system the particle belongs to
  16709. */
  16710. constructor(
  16711. /**
  16712. * The particle system the particle belongs to.
  16713. */
  16714. particleSystem: ParticleSystem);
  16715. private updateCellInfoFromSystem;
  16716. /**
  16717. * Defines how the sprite cell index is updated for the particle
  16718. */
  16719. updateCellIndex(): void;
  16720. /** @hidden */
  16721. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16722. /** @hidden */
  16723. _inheritParticleInfoToSubEmitters(): void;
  16724. /** @hidden */
  16725. _reset(): void;
  16726. /**
  16727. * Copy the properties of particle to another one.
  16728. * @param other the particle to copy the information to.
  16729. */
  16730. copyTo(other: Particle): void;
  16731. }
  16732. }
  16733. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16734. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16735. import { Effect } from "babylonjs/Materials/effect";
  16736. import { Particle } from "babylonjs/Particles/particle";
  16737. import { Nullable } from "babylonjs/types";
  16738. import { Scene } from "babylonjs/scene";
  16739. /**
  16740. * Particle emitter represents a volume emitting particles.
  16741. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16742. */
  16743. export interface IParticleEmitterType {
  16744. /**
  16745. * Called by the particle System when the direction is computed for the created particle.
  16746. * @param worldMatrix is the world matrix of the particle system
  16747. * @param directionToUpdate is the direction vector to update with the result
  16748. * @param particle is the particle we are computed the direction for
  16749. * @param isLocal defines if the direction should be set in local space
  16750. */
  16751. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16752. /**
  16753. * Called by the particle System when the position is computed for the created particle.
  16754. * @param worldMatrix is the world matrix of the particle system
  16755. * @param positionToUpdate is the position vector to update with the result
  16756. * @param particle is the particle we are computed the position for
  16757. * @param isLocal defines if the position should be set in local space
  16758. */
  16759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16760. /**
  16761. * Clones the current emitter and returns a copy of it
  16762. * @returns the new emitter
  16763. */
  16764. clone(): IParticleEmitterType;
  16765. /**
  16766. * Called by the GPUParticleSystem to setup the update shader
  16767. * @param effect defines the update shader
  16768. */
  16769. applyToShader(effect: Effect): void;
  16770. /**
  16771. * Returns a string to use to update the GPU particles update shader
  16772. * @returns the effect defines string
  16773. */
  16774. getEffectDefines(): string;
  16775. /**
  16776. * Returns a string representing the class name
  16777. * @returns a string containing the class name
  16778. */
  16779. getClassName(): string;
  16780. /**
  16781. * Serializes the particle system to a JSON object.
  16782. * @returns the JSON object
  16783. */
  16784. serialize(): any;
  16785. /**
  16786. * Parse properties from a JSON object
  16787. * @param serializationObject defines the JSON object
  16788. * @param scene defines the hosting scene
  16789. */
  16790. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16791. }
  16792. }
  16793. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16794. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16795. import { Effect } from "babylonjs/Materials/effect";
  16796. import { Particle } from "babylonjs/Particles/particle";
  16797. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16798. /**
  16799. * Particle emitter emitting particles from the inside of a box.
  16800. * It emits the particles randomly between 2 given directions.
  16801. */
  16802. export class BoxParticleEmitter implements IParticleEmitterType {
  16803. /**
  16804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16805. */
  16806. direction1: Vector3;
  16807. /**
  16808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16809. */
  16810. direction2: Vector3;
  16811. /**
  16812. * 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.
  16813. */
  16814. minEmitBox: Vector3;
  16815. /**
  16816. * 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.
  16817. */
  16818. maxEmitBox: Vector3;
  16819. /**
  16820. * Creates a new instance BoxParticleEmitter
  16821. */
  16822. constructor();
  16823. /**
  16824. * Called by the particle System when the direction is computed for the created particle.
  16825. * @param worldMatrix is the world matrix of the particle system
  16826. * @param directionToUpdate is the direction vector to update with the result
  16827. * @param particle is the particle we are computed the direction for
  16828. * @param isLocal defines if the direction should be set in local space
  16829. */
  16830. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16831. /**
  16832. * Called by the particle System when the position is computed for the created particle.
  16833. * @param worldMatrix is the world matrix of the particle system
  16834. * @param positionToUpdate is the position vector to update with the result
  16835. * @param particle is the particle we are computed the position for
  16836. * @param isLocal defines if the position should be set in local space
  16837. */
  16838. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16839. /**
  16840. * Clones the current emitter and returns a copy of it
  16841. * @returns the new emitter
  16842. */
  16843. clone(): BoxParticleEmitter;
  16844. /**
  16845. * Called by the GPUParticleSystem to setup the update shader
  16846. * @param effect defines the update shader
  16847. */
  16848. applyToShader(effect: Effect): void;
  16849. /**
  16850. * Returns a string to use to update the GPU particles update shader
  16851. * @returns a string containing the defines string
  16852. */
  16853. getEffectDefines(): string;
  16854. /**
  16855. * Returns the string "BoxParticleEmitter"
  16856. * @returns a string containing the class name
  16857. */
  16858. getClassName(): string;
  16859. /**
  16860. * Serializes the particle system to a JSON object.
  16861. * @returns the JSON object
  16862. */
  16863. serialize(): any;
  16864. /**
  16865. * Parse properties from a JSON object
  16866. * @param serializationObject defines the JSON object
  16867. */
  16868. parse(serializationObject: any): void;
  16869. }
  16870. }
  16871. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16872. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16873. import { Effect } from "babylonjs/Materials/effect";
  16874. import { Particle } from "babylonjs/Particles/particle";
  16875. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16876. /**
  16877. * Particle emitter emitting particles from the inside of a cone.
  16878. * It emits the particles alongside the cone volume from the base to the particle.
  16879. * The emission direction might be randomized.
  16880. */
  16881. export class ConeParticleEmitter implements IParticleEmitterType {
  16882. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16883. directionRandomizer: number;
  16884. private _radius;
  16885. private _angle;
  16886. private _height;
  16887. /**
  16888. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16889. */
  16890. radiusRange: number;
  16891. /**
  16892. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16893. */
  16894. heightRange: number;
  16895. /**
  16896. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16897. */
  16898. emitFromSpawnPointOnly: boolean;
  16899. /**
  16900. * Gets or sets the radius of the emission cone
  16901. */
  16902. get radius(): number;
  16903. set radius(value: number);
  16904. /**
  16905. * Gets or sets the angle of the emission cone
  16906. */
  16907. get angle(): number;
  16908. set angle(value: number);
  16909. private _buildHeight;
  16910. /**
  16911. * Creates a new instance ConeParticleEmitter
  16912. * @param radius the radius of the emission cone (1 by default)
  16913. * @param angle the cone base angle (PI by default)
  16914. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16915. */
  16916. constructor(radius?: number, angle?: number,
  16917. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16918. directionRandomizer?: number);
  16919. /**
  16920. * Called by the particle System when the direction is computed for the created particle.
  16921. * @param worldMatrix is the world matrix of the particle system
  16922. * @param directionToUpdate is the direction vector to update with the result
  16923. * @param particle is the particle we are computed the direction for
  16924. * @param isLocal defines if the direction should be set in local space
  16925. */
  16926. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16927. /**
  16928. * Called by the particle System when the position is computed for the created particle.
  16929. * @param worldMatrix is the world matrix of the particle system
  16930. * @param positionToUpdate is the position vector to update with the result
  16931. * @param particle is the particle we are computed the position for
  16932. * @param isLocal defines if the position should be set in local space
  16933. */
  16934. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16935. /**
  16936. * Clones the current emitter and returns a copy of it
  16937. * @returns the new emitter
  16938. */
  16939. clone(): ConeParticleEmitter;
  16940. /**
  16941. * Called by the GPUParticleSystem to setup the update shader
  16942. * @param effect defines the update shader
  16943. */
  16944. applyToShader(effect: Effect): void;
  16945. /**
  16946. * Returns a string to use to update the GPU particles update shader
  16947. * @returns a string containing the defines string
  16948. */
  16949. getEffectDefines(): string;
  16950. /**
  16951. * Returns the string "ConeParticleEmitter"
  16952. * @returns a string containing the class name
  16953. */
  16954. getClassName(): string;
  16955. /**
  16956. * Serializes the particle system to a JSON object.
  16957. * @returns the JSON object
  16958. */
  16959. serialize(): any;
  16960. /**
  16961. * Parse properties from a JSON object
  16962. * @param serializationObject defines the JSON object
  16963. */
  16964. parse(serializationObject: any): void;
  16965. }
  16966. }
  16967. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16968. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16969. import { Effect } from "babylonjs/Materials/effect";
  16970. import { Particle } from "babylonjs/Particles/particle";
  16971. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16972. /**
  16973. * Particle emitter emitting particles from the inside of a cylinder.
  16974. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16975. */
  16976. export class CylinderParticleEmitter implements IParticleEmitterType {
  16977. /**
  16978. * The radius of the emission cylinder.
  16979. */
  16980. radius: number;
  16981. /**
  16982. * The height of the emission cylinder.
  16983. */
  16984. height: number;
  16985. /**
  16986. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16987. */
  16988. radiusRange: number;
  16989. /**
  16990. * How much to randomize the particle direction [0-1].
  16991. */
  16992. directionRandomizer: number;
  16993. /**
  16994. * Creates a new instance CylinderParticleEmitter
  16995. * @param radius the radius of the emission cylinder (1 by default)
  16996. * @param height the height of the emission cylinder (1 by default)
  16997. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16998. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16999. */
  17000. constructor(
  17001. /**
  17002. * The radius of the emission cylinder.
  17003. */
  17004. radius?: number,
  17005. /**
  17006. * The height of the emission cylinder.
  17007. */
  17008. height?: number,
  17009. /**
  17010. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17011. */
  17012. radiusRange?: number,
  17013. /**
  17014. * How much to randomize the particle direction [0-1].
  17015. */
  17016. directionRandomizer?: number);
  17017. /**
  17018. * Called by the particle System when the direction is computed for the created particle.
  17019. * @param worldMatrix is the world matrix of the particle system
  17020. * @param directionToUpdate is the direction vector to update with the result
  17021. * @param particle is the particle we are computed the direction for
  17022. * @param isLocal defines if the direction should be set in local space
  17023. */
  17024. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17025. /**
  17026. * Called by the particle System when the position is computed for the created particle.
  17027. * @param worldMatrix is the world matrix of the particle system
  17028. * @param positionToUpdate is the position vector to update with the result
  17029. * @param particle is the particle we are computed the position for
  17030. * @param isLocal defines if the position should be set in local space
  17031. */
  17032. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17033. /**
  17034. * Clones the current emitter and returns a copy of it
  17035. * @returns the new emitter
  17036. */
  17037. clone(): CylinderParticleEmitter;
  17038. /**
  17039. * Called by the GPUParticleSystem to setup the update shader
  17040. * @param effect defines the update shader
  17041. */
  17042. applyToShader(effect: Effect): void;
  17043. /**
  17044. * Returns a string to use to update the GPU particles update shader
  17045. * @returns a string containing the defines string
  17046. */
  17047. getEffectDefines(): string;
  17048. /**
  17049. * Returns the string "CylinderParticleEmitter"
  17050. * @returns a string containing the class name
  17051. */
  17052. getClassName(): string;
  17053. /**
  17054. * Serializes the particle system to a JSON object.
  17055. * @returns the JSON object
  17056. */
  17057. serialize(): any;
  17058. /**
  17059. * Parse properties from a JSON object
  17060. * @param serializationObject defines the JSON object
  17061. */
  17062. parse(serializationObject: any): void;
  17063. }
  17064. /**
  17065. * Particle emitter emitting particles from the inside of a cylinder.
  17066. * It emits the particles randomly between two vectors.
  17067. */
  17068. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17069. /**
  17070. * The min limit of the emission direction.
  17071. */
  17072. direction1: Vector3;
  17073. /**
  17074. * The max limit of the emission direction.
  17075. */
  17076. direction2: Vector3;
  17077. /**
  17078. * Creates a new instance CylinderDirectedParticleEmitter
  17079. * @param radius the radius of the emission cylinder (1 by default)
  17080. * @param height the height of the emission cylinder (1 by default)
  17081. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17082. * @param direction1 the min limit of the emission direction (up vector by default)
  17083. * @param direction2 the max limit of the emission direction (up vector by default)
  17084. */
  17085. constructor(radius?: number, height?: number, radiusRange?: number,
  17086. /**
  17087. * The min limit of the emission direction.
  17088. */
  17089. direction1?: Vector3,
  17090. /**
  17091. * The max limit of the emission direction.
  17092. */
  17093. direction2?: Vector3);
  17094. /**
  17095. * Called by the particle System when the direction is computed for the created particle.
  17096. * @param worldMatrix is the world matrix of the particle system
  17097. * @param directionToUpdate is the direction vector to update with the result
  17098. * @param particle is the particle we are computed the direction for
  17099. */
  17100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17101. /**
  17102. * Clones the current emitter and returns a copy of it
  17103. * @returns the new emitter
  17104. */
  17105. clone(): CylinderDirectedParticleEmitter;
  17106. /**
  17107. * Called by the GPUParticleSystem to setup the update shader
  17108. * @param effect defines the update shader
  17109. */
  17110. applyToShader(effect: Effect): void;
  17111. /**
  17112. * Returns a string to use to update the GPU particles update shader
  17113. * @returns a string containing the defines string
  17114. */
  17115. getEffectDefines(): string;
  17116. /**
  17117. * Returns the string "CylinderDirectedParticleEmitter"
  17118. * @returns a string containing the class name
  17119. */
  17120. getClassName(): string;
  17121. /**
  17122. * Serializes the particle system to a JSON object.
  17123. * @returns the JSON object
  17124. */
  17125. serialize(): any;
  17126. /**
  17127. * Parse properties from a JSON object
  17128. * @param serializationObject defines the JSON object
  17129. */
  17130. parse(serializationObject: any): void;
  17131. }
  17132. }
  17133. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  17134. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17135. import { Effect } from "babylonjs/Materials/effect";
  17136. import { Particle } from "babylonjs/Particles/particle";
  17137. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17138. /**
  17139. * Particle emitter emitting particles from the inside of a hemisphere.
  17140. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17141. */
  17142. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17143. /**
  17144. * The radius of the emission hemisphere.
  17145. */
  17146. radius: number;
  17147. /**
  17148. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17149. */
  17150. radiusRange: number;
  17151. /**
  17152. * How much to randomize the particle direction [0-1].
  17153. */
  17154. directionRandomizer: number;
  17155. /**
  17156. * Creates a new instance HemisphericParticleEmitter
  17157. * @param radius the radius of the emission hemisphere (1 by default)
  17158. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17159. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17160. */
  17161. constructor(
  17162. /**
  17163. * The radius of the emission hemisphere.
  17164. */
  17165. radius?: number,
  17166. /**
  17167. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17168. */
  17169. radiusRange?: number,
  17170. /**
  17171. * How much to randomize the particle direction [0-1].
  17172. */
  17173. directionRandomizer?: number);
  17174. /**
  17175. * Called by the particle System when the direction is computed for the created particle.
  17176. * @param worldMatrix is the world matrix of the particle system
  17177. * @param directionToUpdate is the direction vector to update with the result
  17178. * @param particle is the particle we are computed the direction for
  17179. * @param isLocal defines if the direction should be set in local space
  17180. */
  17181. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17182. /**
  17183. * Called by the particle System when the position is computed for the created particle.
  17184. * @param worldMatrix is the world matrix of the particle system
  17185. * @param positionToUpdate is the position vector to update with the result
  17186. * @param particle is the particle we are computed the position for
  17187. * @param isLocal defines if the position should be set in local space
  17188. */
  17189. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17190. /**
  17191. * Clones the current emitter and returns a copy of it
  17192. * @returns the new emitter
  17193. */
  17194. clone(): HemisphericParticleEmitter;
  17195. /**
  17196. * Called by the GPUParticleSystem to setup the update shader
  17197. * @param effect defines the update shader
  17198. */
  17199. applyToShader(effect: Effect): void;
  17200. /**
  17201. * Returns a string to use to update the GPU particles update shader
  17202. * @returns a string containing the defines string
  17203. */
  17204. getEffectDefines(): string;
  17205. /**
  17206. * Returns the string "HemisphericParticleEmitter"
  17207. * @returns a string containing the class name
  17208. */
  17209. getClassName(): string;
  17210. /**
  17211. * Serializes the particle system to a JSON object.
  17212. * @returns the JSON object
  17213. */
  17214. serialize(): any;
  17215. /**
  17216. * Parse properties from a JSON object
  17217. * @param serializationObject defines the JSON object
  17218. */
  17219. parse(serializationObject: any): void;
  17220. }
  17221. }
  17222. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  17223. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17224. import { Effect } from "babylonjs/Materials/effect";
  17225. import { Particle } from "babylonjs/Particles/particle";
  17226. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17227. /**
  17228. * Particle emitter emitting particles from a point.
  17229. * It emits the particles randomly between 2 given directions.
  17230. */
  17231. export class PointParticleEmitter implements IParticleEmitterType {
  17232. /**
  17233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17234. */
  17235. direction1: Vector3;
  17236. /**
  17237. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17238. */
  17239. direction2: Vector3;
  17240. /**
  17241. * Creates a new instance PointParticleEmitter
  17242. */
  17243. constructor();
  17244. /**
  17245. * Called by the particle System when the direction is computed for the created particle.
  17246. * @param worldMatrix is the world matrix of the particle system
  17247. * @param directionToUpdate is the direction vector to update with the result
  17248. * @param particle is the particle we are computed the direction for
  17249. * @param isLocal defines if the direction should be set in local space
  17250. */
  17251. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17252. /**
  17253. * Called by the particle System when the position is computed for the created particle.
  17254. * @param worldMatrix is the world matrix of the particle system
  17255. * @param positionToUpdate is the position vector to update with the result
  17256. * @param particle is the particle we are computed the position for
  17257. * @param isLocal defines if the position should be set in local space
  17258. */
  17259. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17260. /**
  17261. * Clones the current emitter and returns a copy of it
  17262. * @returns the new emitter
  17263. */
  17264. clone(): PointParticleEmitter;
  17265. /**
  17266. * Called by the GPUParticleSystem to setup the update shader
  17267. * @param effect defines the update shader
  17268. */
  17269. applyToShader(effect: Effect): void;
  17270. /**
  17271. * Returns a string to use to update the GPU particles update shader
  17272. * @returns a string containing the defines string
  17273. */
  17274. getEffectDefines(): string;
  17275. /**
  17276. * Returns the string "PointParticleEmitter"
  17277. * @returns a string containing the class name
  17278. */
  17279. getClassName(): string;
  17280. /**
  17281. * Serializes the particle system to a JSON object.
  17282. * @returns the JSON object
  17283. */
  17284. serialize(): any;
  17285. /**
  17286. * Parse properties from a JSON object
  17287. * @param serializationObject defines the JSON object
  17288. */
  17289. parse(serializationObject: any): void;
  17290. }
  17291. }
  17292. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  17293. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17294. import { Effect } from "babylonjs/Materials/effect";
  17295. import { Particle } from "babylonjs/Particles/particle";
  17296. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17297. /**
  17298. * Particle emitter emitting particles from the inside of a sphere.
  17299. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17300. */
  17301. export class SphereParticleEmitter implements IParticleEmitterType {
  17302. /**
  17303. * The radius of the emission sphere.
  17304. */
  17305. radius: number;
  17306. /**
  17307. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17308. */
  17309. radiusRange: number;
  17310. /**
  17311. * How much to randomize the particle direction [0-1].
  17312. */
  17313. directionRandomizer: number;
  17314. /**
  17315. * Creates a new instance SphereParticleEmitter
  17316. * @param radius the radius of the emission sphere (1 by default)
  17317. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17318. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17319. */
  17320. constructor(
  17321. /**
  17322. * The radius of the emission sphere.
  17323. */
  17324. radius?: number,
  17325. /**
  17326. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17327. */
  17328. radiusRange?: number,
  17329. /**
  17330. * How much to randomize the particle direction [0-1].
  17331. */
  17332. directionRandomizer?: number);
  17333. /**
  17334. * Called by the particle System when the direction is computed for the created particle.
  17335. * @param worldMatrix is the world matrix of the particle system
  17336. * @param directionToUpdate is the direction vector to update with the result
  17337. * @param particle is the particle we are computed the direction for
  17338. * @param isLocal defines if the direction should be set in local space
  17339. */
  17340. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17341. /**
  17342. * Called by the particle System when the position is computed for the created particle.
  17343. * @param worldMatrix is the world matrix of the particle system
  17344. * @param positionToUpdate is the position vector to update with the result
  17345. * @param particle is the particle we are computed the position for
  17346. * @param isLocal defines if the position should be set in local space
  17347. */
  17348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17349. /**
  17350. * Clones the current emitter and returns a copy of it
  17351. * @returns the new emitter
  17352. */
  17353. clone(): SphereParticleEmitter;
  17354. /**
  17355. * Called by the GPUParticleSystem to setup the update shader
  17356. * @param effect defines the update shader
  17357. */
  17358. applyToShader(effect: Effect): void;
  17359. /**
  17360. * Returns a string to use to update the GPU particles update shader
  17361. * @returns a string containing the defines string
  17362. */
  17363. getEffectDefines(): string;
  17364. /**
  17365. * Returns the string "SphereParticleEmitter"
  17366. * @returns a string containing the class name
  17367. */
  17368. getClassName(): string;
  17369. /**
  17370. * Serializes the particle system to a JSON object.
  17371. * @returns the JSON object
  17372. */
  17373. serialize(): any;
  17374. /**
  17375. * Parse properties from a JSON object
  17376. * @param serializationObject defines the JSON object
  17377. */
  17378. parse(serializationObject: any): void;
  17379. }
  17380. /**
  17381. * Particle emitter emitting particles from the inside of a sphere.
  17382. * It emits the particles randomly between two vectors.
  17383. */
  17384. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17385. /**
  17386. * The min limit of the emission direction.
  17387. */
  17388. direction1: Vector3;
  17389. /**
  17390. * The max limit of the emission direction.
  17391. */
  17392. direction2: Vector3;
  17393. /**
  17394. * Creates a new instance SphereDirectedParticleEmitter
  17395. * @param radius the radius of the emission sphere (1 by default)
  17396. * @param direction1 the min limit of the emission direction (up vector by default)
  17397. * @param direction2 the max limit of the emission direction (up vector by default)
  17398. */
  17399. constructor(radius?: number,
  17400. /**
  17401. * The min limit of the emission direction.
  17402. */
  17403. direction1?: Vector3,
  17404. /**
  17405. * The max limit of the emission direction.
  17406. */
  17407. direction2?: Vector3);
  17408. /**
  17409. * Called by the particle System when the direction is computed for the created particle.
  17410. * @param worldMatrix is the world matrix of the particle system
  17411. * @param directionToUpdate is the direction vector to update with the result
  17412. * @param particle is the particle we are computed the direction for
  17413. */
  17414. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17415. /**
  17416. * Clones the current emitter and returns a copy of it
  17417. * @returns the new emitter
  17418. */
  17419. clone(): SphereDirectedParticleEmitter;
  17420. /**
  17421. * Called by the GPUParticleSystem to setup the update shader
  17422. * @param effect defines the update shader
  17423. */
  17424. applyToShader(effect: Effect): void;
  17425. /**
  17426. * Returns a string to use to update the GPU particles update shader
  17427. * @returns a string containing the defines string
  17428. */
  17429. getEffectDefines(): string;
  17430. /**
  17431. * Returns the string "SphereDirectedParticleEmitter"
  17432. * @returns a string containing the class name
  17433. */
  17434. getClassName(): string;
  17435. /**
  17436. * Serializes the particle system to a JSON object.
  17437. * @returns the JSON object
  17438. */
  17439. serialize(): any;
  17440. /**
  17441. * Parse properties from a JSON object
  17442. * @param serializationObject defines the JSON object
  17443. */
  17444. parse(serializationObject: any): void;
  17445. }
  17446. }
  17447. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  17448. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17449. import { Effect } from "babylonjs/Materials/effect";
  17450. import { Particle } from "babylonjs/Particles/particle";
  17451. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17452. import { Nullable } from "babylonjs/types";
  17453. /**
  17454. * Particle emitter emitting particles from a custom list of positions.
  17455. */
  17456. export class CustomParticleEmitter implements IParticleEmitterType {
  17457. /**
  17458. * Gets or sets the position generator that will create the initial position of each particle.
  17459. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17460. */
  17461. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  17462. /**
  17463. * Gets or sets the destination generator that will create the final destination of each particle.
  17464. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  17465. */
  17466. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  17467. /**
  17468. * Creates a new instance CustomParticleEmitter
  17469. */
  17470. constructor();
  17471. /**
  17472. * Called by the particle System when the direction is computed for the created particle.
  17473. * @param worldMatrix is the world matrix of the particle system
  17474. * @param directionToUpdate is the direction vector to update with the result
  17475. * @param particle is the particle we are computed the direction for
  17476. * @param isLocal defines if the direction should be set in local space
  17477. */
  17478. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17479. /**
  17480. * Called by the particle System when the position is computed for the created particle.
  17481. * @param worldMatrix is the world matrix of the particle system
  17482. * @param positionToUpdate is the position vector to update with the result
  17483. * @param particle is the particle we are computed the position for
  17484. * @param isLocal defines if the position should be set in local space
  17485. */
  17486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17487. /**
  17488. * Clones the current emitter and returns a copy of it
  17489. * @returns the new emitter
  17490. */
  17491. clone(): CustomParticleEmitter;
  17492. /**
  17493. * Called by the GPUParticleSystem to setup the update shader
  17494. * @param effect defines the update shader
  17495. */
  17496. applyToShader(effect: Effect): void;
  17497. /**
  17498. * Returns a string to use to update the GPU particles update shader
  17499. * @returns a string containing the defines string
  17500. */
  17501. getEffectDefines(): string;
  17502. /**
  17503. * Returns the string "PointParticleEmitter"
  17504. * @returns a string containing the class name
  17505. */
  17506. getClassName(): string;
  17507. /**
  17508. * Serializes the particle system to a JSON object.
  17509. * @returns the JSON object
  17510. */
  17511. serialize(): any;
  17512. /**
  17513. * Parse properties from a JSON object
  17514. * @param serializationObject defines the JSON object
  17515. */
  17516. parse(serializationObject: any): void;
  17517. }
  17518. }
  17519. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  17520. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17521. import { Effect } from "babylonjs/Materials/effect";
  17522. import { Particle } from "babylonjs/Particles/particle";
  17523. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17524. import { Nullable } from "babylonjs/types";
  17525. import { Scene } from "babylonjs/scene";
  17526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17527. /**
  17528. * Particle emitter emitting particles from the inside of a box.
  17529. * It emits the particles randomly between 2 given directions.
  17530. */
  17531. export class MeshParticleEmitter implements IParticleEmitterType {
  17532. private _indices;
  17533. private _positions;
  17534. private _normals;
  17535. private _storedNormal;
  17536. private _mesh;
  17537. /**
  17538. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17539. */
  17540. direction1: Vector3;
  17541. /**
  17542. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17543. */
  17544. direction2: Vector3;
  17545. /**
  17546. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17547. */
  17548. useMeshNormalsForDirection: boolean;
  17549. /** Defines the mesh to use as source */
  17550. get mesh(): Nullable<AbstractMesh>;
  17551. set mesh(value: Nullable<AbstractMesh>);
  17552. /**
  17553. * Creates a new instance MeshParticleEmitter
  17554. * @param mesh defines the mesh to use as source
  17555. */
  17556. constructor(mesh?: Nullable<AbstractMesh>);
  17557. /**
  17558. * Called by the particle System when the direction is computed for the created particle.
  17559. * @param worldMatrix is the world matrix of the particle system
  17560. * @param directionToUpdate is the direction vector to update with the result
  17561. * @param particle is the particle we are computed the direction for
  17562. * @param isLocal defines if the direction should be set in local space
  17563. */
  17564. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17565. /**
  17566. * Called by the particle System when the position is computed for the created particle.
  17567. * @param worldMatrix is the world matrix of the particle system
  17568. * @param positionToUpdate is the position vector to update with the result
  17569. * @param particle is the particle we are computed the position for
  17570. * @param isLocal defines if the position should be set in local space
  17571. */
  17572. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17573. /**
  17574. * Clones the current emitter and returns a copy of it
  17575. * @returns the new emitter
  17576. */
  17577. clone(): MeshParticleEmitter;
  17578. /**
  17579. * Called by the GPUParticleSystem to setup the update shader
  17580. * @param effect defines the update shader
  17581. */
  17582. applyToShader(effect: Effect): void;
  17583. /**
  17584. * Returns a string to use to update the GPU particles update shader
  17585. * @returns a string containing the defines string
  17586. */
  17587. getEffectDefines(): string;
  17588. /**
  17589. * Returns the string "BoxParticleEmitter"
  17590. * @returns a string containing the class name
  17591. */
  17592. getClassName(): string;
  17593. /**
  17594. * Serializes the particle system to a JSON object.
  17595. * @returns the JSON object
  17596. */
  17597. serialize(): any;
  17598. /**
  17599. * Parse properties from a JSON object
  17600. * @param serializationObject defines the JSON object
  17601. * @param scene defines the hosting scene
  17602. */
  17603. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17604. }
  17605. }
  17606. declare module "babylonjs/Particles/EmitterTypes/index" {
  17607. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  17608. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  17609. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  17610. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  17611. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17612. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  17613. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  17614. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  17615. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  17616. }
  17617. declare module "babylonjs/Particles/IParticleSystem" {
  17618. import { Nullable } from "babylonjs/types";
  17619. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17620. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17622. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17623. import { Scene } from "babylonjs/scene";
  17624. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17625. import { Effect } from "babylonjs/Materials/effect";
  17626. import { Observable } from "babylonjs/Misc/observable";
  17627. import { Animation } from "babylonjs/Animations/animation";
  17628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17629. /**
  17630. * Interface representing a particle system in Babylon.js.
  17631. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17632. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17633. */
  17634. export interface IParticleSystem {
  17635. /**
  17636. * List of animations used by the particle system.
  17637. */
  17638. animations: Animation[];
  17639. /**
  17640. * The id of the Particle system.
  17641. */
  17642. id: string;
  17643. /**
  17644. * The name of the Particle system.
  17645. */
  17646. name: string;
  17647. /**
  17648. * The emitter represents the Mesh or position we are attaching the particle system to.
  17649. */
  17650. emitter: Nullable<AbstractMesh | Vector3>;
  17651. /**
  17652. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17653. */
  17654. isBillboardBased: boolean;
  17655. /**
  17656. * The rendering group used by the Particle system to chose when to render.
  17657. */
  17658. renderingGroupId: number;
  17659. /**
  17660. * The layer mask we are rendering the particles through.
  17661. */
  17662. layerMask: number;
  17663. /**
  17664. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17665. */
  17666. updateSpeed: number;
  17667. /**
  17668. * The amount of time the particle system is running (depends of the overall update speed).
  17669. */
  17670. targetStopDuration: number;
  17671. /**
  17672. * The texture used to render each particle. (this can be a spritesheet)
  17673. */
  17674. particleTexture: Nullable<BaseTexture>;
  17675. /**
  17676. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17677. */
  17678. blendMode: number;
  17679. /**
  17680. * Minimum life time of emitting particles.
  17681. */
  17682. minLifeTime: number;
  17683. /**
  17684. * Maximum life time of emitting particles.
  17685. */
  17686. maxLifeTime: number;
  17687. /**
  17688. * Minimum Size of emitting particles.
  17689. */
  17690. minSize: number;
  17691. /**
  17692. * Maximum Size of emitting particles.
  17693. */
  17694. maxSize: number;
  17695. /**
  17696. * Minimum scale of emitting particles on X axis.
  17697. */
  17698. minScaleX: number;
  17699. /**
  17700. * Maximum scale of emitting particles on X axis.
  17701. */
  17702. maxScaleX: number;
  17703. /**
  17704. * Minimum scale of emitting particles on Y axis.
  17705. */
  17706. minScaleY: number;
  17707. /**
  17708. * Maximum scale of emitting particles on Y axis.
  17709. */
  17710. maxScaleY: number;
  17711. /**
  17712. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17713. */
  17714. color1: Color4;
  17715. /**
  17716. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17717. */
  17718. color2: Color4;
  17719. /**
  17720. * Color the particle will have at the end of its lifetime.
  17721. */
  17722. colorDead: Color4;
  17723. /**
  17724. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17725. */
  17726. emitRate: number;
  17727. /**
  17728. * You can use gravity if you want to give an orientation to your particles.
  17729. */
  17730. gravity: Vector3;
  17731. /**
  17732. * Minimum power of emitting particles.
  17733. */
  17734. minEmitPower: number;
  17735. /**
  17736. * Maximum power of emitting particles.
  17737. */
  17738. maxEmitPower: number;
  17739. /**
  17740. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17741. */
  17742. minAngularSpeed: number;
  17743. /**
  17744. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17745. */
  17746. maxAngularSpeed: number;
  17747. /**
  17748. * Gets or sets the minimal initial rotation in radians.
  17749. */
  17750. minInitialRotation: number;
  17751. /**
  17752. * Gets or sets the maximal initial rotation in radians.
  17753. */
  17754. maxInitialRotation: number;
  17755. /**
  17756. * The particle emitter type defines the emitter used by the particle system.
  17757. * It can be for example box, sphere, or cone...
  17758. */
  17759. particleEmitterType: Nullable<IParticleEmitterType>;
  17760. /**
  17761. * Defines the delay in milliseconds before starting the system (0 by default)
  17762. */
  17763. startDelay: number;
  17764. /**
  17765. * 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
  17766. */
  17767. preWarmCycles: number;
  17768. /**
  17769. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17770. */
  17771. preWarmStepOffset: number;
  17772. /**
  17773. * 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)
  17774. */
  17775. spriteCellChangeSpeed: number;
  17776. /**
  17777. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17778. */
  17779. startSpriteCellID: number;
  17780. /**
  17781. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17782. */
  17783. endSpriteCellID: number;
  17784. /**
  17785. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17786. */
  17787. spriteCellWidth: number;
  17788. /**
  17789. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17790. */
  17791. spriteCellHeight: number;
  17792. /**
  17793. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17794. */
  17795. spriteRandomStartCell: boolean;
  17796. /**
  17797. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17798. */
  17799. isAnimationSheetEnabled: boolean;
  17800. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17801. translationPivot: Vector2;
  17802. /**
  17803. * Gets or sets a texture used to add random noise to particle positions
  17804. */
  17805. noiseTexture: Nullable<BaseTexture>;
  17806. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17807. noiseStrength: Vector3;
  17808. /**
  17809. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17810. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17811. */
  17812. billboardMode: number;
  17813. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17814. limitVelocityDamping: number;
  17815. /**
  17816. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17817. */
  17818. beginAnimationOnStart: boolean;
  17819. /**
  17820. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17821. */
  17822. beginAnimationFrom: number;
  17823. /**
  17824. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17825. */
  17826. beginAnimationTo: number;
  17827. /**
  17828. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17829. */
  17830. beginAnimationLoop: boolean;
  17831. /**
  17832. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17833. */
  17834. disposeOnStop: boolean;
  17835. /**
  17836. * If you want to launch only a few particles at once, that can be done, as well.
  17837. */
  17838. manualEmitCount: number;
  17839. /**
  17840. * Specifies if the particles are updated in emitter local space or world space
  17841. */
  17842. isLocal: boolean;
  17843. /** Snippet ID if the particle system was created from the snippet server */
  17844. snippetId: string;
  17845. /** Gets or sets a matrix to use to compute projection */
  17846. defaultProjectionMatrix: Matrix;
  17847. /**
  17848. * Gets the maximum number of particles active at the same time.
  17849. * @returns The max number of active particles.
  17850. */
  17851. getCapacity(): number;
  17852. /**
  17853. * Gets the number of particles active at the same time.
  17854. * @returns The number of active particles.
  17855. */
  17856. getActiveCount(): number;
  17857. /**
  17858. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17859. * @returns True if it has been started, otherwise false.
  17860. */
  17861. isStarted(): boolean;
  17862. /**
  17863. * Animates the particle system for this frame.
  17864. */
  17865. animate(): void;
  17866. /**
  17867. * Renders the particle system in its current state.
  17868. * @returns the current number of particles
  17869. */
  17870. render(): number;
  17871. /**
  17872. * Dispose the particle system and frees its associated resources.
  17873. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  17874. */
  17875. dispose(disposeTexture?: boolean): void;
  17876. /**
  17877. * An event triggered when the system is disposed
  17878. */
  17879. onDisposeObservable: Observable<IParticleSystem>;
  17880. /**
  17881. * An event triggered when the system is stopped
  17882. */
  17883. onStoppedObservable: Observable<IParticleSystem>;
  17884. /**
  17885. * Clones the particle system.
  17886. * @param name The name of the cloned object
  17887. * @param newEmitter The new emitter to use
  17888. * @returns the cloned particle system
  17889. */
  17890. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17891. /**
  17892. * Serializes the particle system to a JSON object
  17893. * @param serializeTexture defines if the texture must be serialized as well
  17894. * @returns the JSON object
  17895. */
  17896. serialize(serializeTexture: boolean): any;
  17897. /**
  17898. * Rebuild the particle system
  17899. */
  17900. rebuild(): void;
  17901. /** Force the system to rebuild all gradients that need to be resync */
  17902. forceRefreshGradients(): void;
  17903. /**
  17904. * Starts the particle system and begins to emit
  17905. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17906. */
  17907. start(delay?: number): void;
  17908. /**
  17909. * Stops the particle system.
  17910. */
  17911. stop(): void;
  17912. /**
  17913. * Remove all active particles
  17914. */
  17915. reset(): void;
  17916. /**
  17917. * Gets a boolean indicating that the system is stopping
  17918. * @returns true if the system is currently stopping
  17919. */
  17920. isStopping(): boolean;
  17921. /**
  17922. * Is this system ready to be used/rendered
  17923. * @return true if the system is ready
  17924. */
  17925. isReady(): boolean;
  17926. /**
  17927. * Returns the string "ParticleSystem"
  17928. * @returns a string containing the class name
  17929. */
  17930. getClassName(): string;
  17931. /**
  17932. * Gets the custom effect used to render the particles
  17933. * @param blendMode Blend mode for which the effect should be retrieved
  17934. * @returns The effect
  17935. */
  17936. getCustomEffect(blendMode: number): Nullable<Effect>;
  17937. /**
  17938. * Sets the custom effect used to render the particles
  17939. * @param effect The effect to set
  17940. * @param blendMode Blend mode for which the effect should be set
  17941. */
  17942. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17943. /**
  17944. * Fill the defines array according to the current settings of the particle system
  17945. * @param defines Array to be updated
  17946. * @param blendMode blend mode to take into account when updating the array
  17947. */
  17948. fillDefines(defines: Array<string>, blendMode: number): void;
  17949. /**
  17950. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17951. * @param uniforms Uniforms array to fill
  17952. * @param attributes Attributes array to fill
  17953. * @param samplers Samplers array to fill
  17954. */
  17955. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17956. /**
  17957. * Observable that will be called just before the particles are drawn
  17958. */
  17959. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17960. /**
  17961. * Gets the name of the particle vertex shader
  17962. */
  17963. vertexShaderName: string;
  17964. /**
  17965. * Adds a new color gradient
  17966. * @param gradient defines the gradient to use (between 0 and 1)
  17967. * @param color1 defines the color to affect to the specified gradient
  17968. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17969. * @returns the current particle system
  17970. */
  17971. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17972. /**
  17973. * Remove a specific color gradient
  17974. * @param gradient defines the gradient to remove
  17975. * @returns the current particle system
  17976. */
  17977. removeColorGradient(gradient: number): IParticleSystem;
  17978. /**
  17979. * Adds a new size gradient
  17980. * @param gradient defines the gradient to use (between 0 and 1)
  17981. * @param factor defines the size factor to affect to the specified gradient
  17982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17983. * @returns the current particle system
  17984. */
  17985. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17986. /**
  17987. * Remove a specific size gradient
  17988. * @param gradient defines the gradient to remove
  17989. * @returns the current particle system
  17990. */
  17991. removeSizeGradient(gradient: number): IParticleSystem;
  17992. /**
  17993. * Gets the current list of color gradients.
  17994. * You must use addColorGradient and removeColorGradient to update this list
  17995. * @returns the list of color gradients
  17996. */
  17997. getColorGradients(): Nullable<Array<ColorGradient>>;
  17998. /**
  17999. * Gets the current list of size gradients.
  18000. * You must use addSizeGradient and removeSizeGradient to update this list
  18001. * @returns the list of size gradients
  18002. */
  18003. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18004. /**
  18005. * Gets the current list of angular speed gradients.
  18006. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  18007. * @returns the list of angular speed gradients
  18008. */
  18009. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18010. /**
  18011. * Adds a new angular speed gradient
  18012. * @param gradient defines the gradient to use (between 0 and 1)
  18013. * @param factor defines the angular speed to affect to the specified gradient
  18014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18015. * @returns the current particle system
  18016. */
  18017. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18018. /**
  18019. * Remove a specific angular speed gradient
  18020. * @param gradient defines the gradient to remove
  18021. * @returns the current particle system
  18022. */
  18023. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18024. /**
  18025. * Gets the current list of velocity gradients.
  18026. * You must use addVelocityGradient and removeVelocityGradient to update this list
  18027. * @returns the list of velocity gradients
  18028. */
  18029. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18030. /**
  18031. * Adds a new velocity gradient
  18032. * @param gradient defines the gradient to use (between 0 and 1)
  18033. * @param factor defines the velocity to affect to the specified gradient
  18034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18035. * @returns the current particle system
  18036. */
  18037. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18038. /**
  18039. * Remove a specific velocity gradient
  18040. * @param gradient defines the gradient to remove
  18041. * @returns the current particle system
  18042. */
  18043. removeVelocityGradient(gradient: number): IParticleSystem;
  18044. /**
  18045. * Gets the current list of limit velocity gradients.
  18046. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  18047. * @returns the list of limit velocity gradients
  18048. */
  18049. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18050. /**
  18051. * Adds a new limit velocity gradient
  18052. * @param gradient defines the gradient to use (between 0 and 1)
  18053. * @param factor defines the limit velocity to affect to the specified gradient
  18054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18055. * @returns the current particle system
  18056. */
  18057. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18058. /**
  18059. * Remove a specific limit velocity gradient
  18060. * @param gradient defines the gradient to remove
  18061. * @returns the current particle system
  18062. */
  18063. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18064. /**
  18065. * Adds a new drag gradient
  18066. * @param gradient defines the gradient to use (between 0 and 1)
  18067. * @param factor defines the drag to affect to the specified gradient
  18068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18069. * @returns the current particle system
  18070. */
  18071. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18072. /**
  18073. * Remove a specific drag gradient
  18074. * @param gradient defines the gradient to remove
  18075. * @returns the current particle system
  18076. */
  18077. removeDragGradient(gradient: number): IParticleSystem;
  18078. /**
  18079. * Gets the current list of drag gradients.
  18080. * You must use addDragGradient and removeDragGradient to update this list
  18081. * @returns the list of drag gradients
  18082. */
  18083. getDragGradients(): Nullable<Array<FactorGradient>>;
  18084. /**
  18085. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18086. * @param gradient defines the gradient to use (between 0 and 1)
  18087. * @param factor defines the emit rate to affect to the specified gradient
  18088. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18089. * @returns the current particle system
  18090. */
  18091. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18092. /**
  18093. * Remove a specific emit rate gradient
  18094. * @param gradient defines the gradient to remove
  18095. * @returns the current particle system
  18096. */
  18097. removeEmitRateGradient(gradient: number): IParticleSystem;
  18098. /**
  18099. * Gets the current list of emit rate gradients.
  18100. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  18101. * @returns the list of emit rate gradients
  18102. */
  18103. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18104. /**
  18105. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18106. * @param gradient defines the gradient to use (between 0 and 1)
  18107. * @param factor defines the start size to affect to the specified gradient
  18108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18109. * @returns the current particle system
  18110. */
  18111. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18112. /**
  18113. * Remove a specific start size gradient
  18114. * @param gradient defines the gradient to remove
  18115. * @returns the current particle system
  18116. */
  18117. removeStartSizeGradient(gradient: number): IParticleSystem;
  18118. /**
  18119. * Gets the current list of start size gradients.
  18120. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  18121. * @returns the list of start size gradients
  18122. */
  18123. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18124. /**
  18125. * Adds a new life time gradient
  18126. * @param gradient defines the gradient to use (between 0 and 1)
  18127. * @param factor defines the life time factor to affect to the specified gradient
  18128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18129. * @returns the current particle system
  18130. */
  18131. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18132. /**
  18133. * Remove a specific life time gradient
  18134. * @param gradient defines the gradient to remove
  18135. * @returns the current particle system
  18136. */
  18137. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18138. /**
  18139. * Gets the current list of life time gradients.
  18140. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  18141. * @returns the list of life time gradients
  18142. */
  18143. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18144. /**
  18145. * Gets the current list of color gradients.
  18146. * You must use addColorGradient and removeColorGradient to update this list
  18147. * @returns the list of color gradients
  18148. */
  18149. getColorGradients(): Nullable<Array<ColorGradient>>;
  18150. /**
  18151. * Adds a new ramp gradient used to remap particle colors
  18152. * @param gradient defines the gradient to use (between 0 and 1)
  18153. * @param color defines the color to affect to the specified gradient
  18154. * @returns the current particle system
  18155. */
  18156. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18157. /**
  18158. * Gets the current list of ramp gradients.
  18159. * You must use addRampGradient and removeRampGradient to update this list
  18160. * @returns the list of ramp gradients
  18161. */
  18162. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18163. /** Gets or sets a boolean indicating that ramp gradients must be used
  18164. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18165. */
  18166. useRampGradients: boolean;
  18167. /**
  18168. * Adds a new color remap gradient
  18169. * @param gradient defines the gradient to use (between 0 and 1)
  18170. * @param min defines the color remap minimal range
  18171. * @param max defines the color remap maximal range
  18172. * @returns the current particle system
  18173. */
  18174. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18175. /**
  18176. * Gets the current list of color remap gradients.
  18177. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  18178. * @returns the list of color remap gradients
  18179. */
  18180. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18181. /**
  18182. * Adds a new alpha remap gradient
  18183. * @param gradient defines the gradient to use (between 0 and 1)
  18184. * @param min defines the alpha remap minimal range
  18185. * @param max defines the alpha remap maximal range
  18186. * @returns the current particle system
  18187. */
  18188. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18189. /**
  18190. * Gets the current list of alpha remap gradients.
  18191. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  18192. * @returns the list of alpha remap gradients
  18193. */
  18194. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18195. /**
  18196. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18197. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18198. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18199. * @returns the emitter
  18200. */
  18201. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18202. /**
  18203. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18204. * @param radius The radius of the hemisphere to emit from
  18205. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18206. * @returns the emitter
  18207. */
  18208. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18209. /**
  18210. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18211. * @param radius The radius of the sphere to emit from
  18212. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18213. * @returns the emitter
  18214. */
  18215. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18216. /**
  18217. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18218. * @param radius The radius of the sphere to emit from
  18219. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18220. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18221. * @returns the emitter
  18222. */
  18223. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18224. /**
  18225. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18226. * @param radius The radius of the emission cylinder
  18227. * @param height The height of the emission cylinder
  18228. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18229. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18230. * @returns the emitter
  18231. */
  18232. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18233. /**
  18234. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18235. * @param radius The radius of the cylinder to emit from
  18236. * @param height The height of the emission cylinder
  18237. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18238. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18239. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18240. * @returns the emitter
  18241. */
  18242. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18243. /**
  18244. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18245. * @param radius The radius of the cone to emit from
  18246. * @param angle The base angle of the cone
  18247. * @returns the emitter
  18248. */
  18249. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18250. /**
  18251. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18252. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18253. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18254. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18255. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18256. * @returns the emitter
  18257. */
  18258. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18259. /**
  18260. * Get hosting scene
  18261. * @returns the scene
  18262. */
  18263. getScene(): Nullable<Scene>;
  18264. }
  18265. }
  18266. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  18267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  18269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  18270. /**
  18271. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  18272. */
  18273. export class ColorSplitterBlock extends NodeMaterialBlock {
  18274. /**
  18275. * Create a new ColorSplitterBlock
  18276. * @param name defines the block name
  18277. */
  18278. constructor(name: string);
  18279. /**
  18280. * Gets the current class name
  18281. * @returns the class name
  18282. */
  18283. getClassName(): string;
  18284. /**
  18285. * Gets the rgba component (input)
  18286. */
  18287. get rgba(): NodeMaterialConnectionPoint;
  18288. /**
  18289. * Gets the rgb component (input)
  18290. */
  18291. get rgbIn(): NodeMaterialConnectionPoint;
  18292. /**
  18293. * Gets the rgb component (output)
  18294. */
  18295. get rgbOut(): NodeMaterialConnectionPoint;
  18296. /**
  18297. * Gets the r component (output)
  18298. */
  18299. get r(): NodeMaterialConnectionPoint;
  18300. /**
  18301. * Gets the g component (output)
  18302. */
  18303. get g(): NodeMaterialConnectionPoint;
  18304. /**
  18305. * Gets the b component (output)
  18306. */
  18307. get b(): NodeMaterialConnectionPoint;
  18308. /**
  18309. * Gets the a component (output)
  18310. */
  18311. get a(): NodeMaterialConnectionPoint;
  18312. protected _inputRename(name: string): string;
  18313. protected _outputRename(name: string): string;
  18314. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  18315. }
  18316. }
  18317. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  18318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  18320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  18321. import { Scene } from "babylonjs/scene";
  18322. /**
  18323. * Operations supported by the Trigonometry block
  18324. */
  18325. export enum TrigonometryBlockOperations {
  18326. /** Cos */
  18327. Cos = 0,
  18328. /** Sin */
  18329. Sin = 1,
  18330. /** Abs */
  18331. Abs = 2,
  18332. /** Exp */
  18333. Exp = 3,
  18334. /** Exp2 */
  18335. Exp2 = 4,
  18336. /** Round */
  18337. Round = 5,
  18338. /** Floor */
  18339. Floor = 6,
  18340. /** Ceiling */
  18341. Ceiling = 7,
  18342. /** Square root */
  18343. Sqrt = 8,
  18344. /** Log */
  18345. Log = 9,
  18346. /** Tangent */
  18347. Tan = 10,
  18348. /** Arc tangent */
  18349. ArcTan = 11,
  18350. /** Arc cosinus */
  18351. ArcCos = 12,
  18352. /** Arc sinus */
  18353. ArcSin = 13,
  18354. /** Fraction */
  18355. Fract = 14,
  18356. /** Sign */
  18357. Sign = 15,
  18358. /** To radians (from degrees) */
  18359. Radians = 16,
  18360. /** To degrees (from radians) */
  18361. Degrees = 17
  18362. }
  18363. /**
  18364. * Block used to apply trigonometry operation to floats
  18365. */
  18366. export class TrigonometryBlock extends NodeMaterialBlock {
  18367. /**
  18368. * Gets or sets the operation applied by the block
  18369. */
  18370. operation: TrigonometryBlockOperations;
  18371. /**
  18372. * Creates a new TrigonometryBlock
  18373. * @param name defines the block name
  18374. */
  18375. constructor(name: string);
  18376. /**
  18377. * Gets the current class name
  18378. * @returns the class name
  18379. */
  18380. getClassName(): string;
  18381. /**
  18382. * Gets the input component
  18383. */
  18384. get input(): NodeMaterialConnectionPoint;
  18385. /**
  18386. * Gets the output component
  18387. */
  18388. get output(): NodeMaterialConnectionPoint;
  18389. protected _buildBlock(state: NodeMaterialBuildState): this;
  18390. serialize(): any;
  18391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  18392. protected _dumpPropertiesCode(): string;
  18393. }
  18394. }
  18395. declare module "babylonjs/Materials/Node/nodeMaterial" {
  18396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  18397. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  18398. import { Scene } from "babylonjs/scene";
  18399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18400. import { Matrix } from "babylonjs/Maths/math.vector";
  18401. import { Mesh } from "babylonjs/Meshes/mesh";
  18402. import { Engine } from "babylonjs/Engines/engine";
  18403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18404. import { Observable } from "babylonjs/Misc/observable";
  18405. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18406. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18407. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  18408. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  18409. import { Nullable } from "babylonjs/types";
  18410. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  18411. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  18412. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  18413. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  18414. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  18415. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  18416. import { Effect } from "babylonjs/Materials/effect";
  18417. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18418. import { Camera } from "babylonjs/Cameras/camera";
  18419. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  18420. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18421. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  18422. /**
  18423. * Interface used to configure the node material editor
  18424. */
  18425. export interface INodeMaterialEditorOptions {
  18426. /** Define the URl to load node editor script */
  18427. editorURL?: string;
  18428. }
  18429. /** @hidden */
  18430. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18431. NORMAL: boolean;
  18432. TANGENT: boolean;
  18433. UV1: boolean;
  18434. /** BONES */
  18435. NUM_BONE_INFLUENCERS: number;
  18436. BonesPerMesh: number;
  18437. BONETEXTURE: boolean;
  18438. /** MORPH TARGETS */
  18439. MORPHTARGETS: boolean;
  18440. MORPHTARGETS_NORMAL: boolean;
  18441. MORPHTARGETS_TANGENT: boolean;
  18442. MORPHTARGETS_UV: boolean;
  18443. NUM_MORPH_INFLUENCERS: number;
  18444. MORPHTARGETS_TEXTURE: boolean;
  18445. /** IMAGE PROCESSING */
  18446. IMAGEPROCESSING: boolean;
  18447. VIGNETTE: boolean;
  18448. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18449. VIGNETTEBLENDMODEOPAQUE: boolean;
  18450. TONEMAPPING: boolean;
  18451. TONEMAPPING_ACES: boolean;
  18452. CONTRAST: boolean;
  18453. EXPOSURE: boolean;
  18454. COLORCURVES: boolean;
  18455. COLORGRADING: boolean;
  18456. COLORGRADING3D: boolean;
  18457. SAMPLER3DGREENDEPTH: boolean;
  18458. SAMPLER3DBGRMAP: boolean;
  18459. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18460. /** MISC. */
  18461. BUMPDIRECTUV: number;
  18462. constructor();
  18463. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  18464. }
  18465. /**
  18466. * Class used to configure NodeMaterial
  18467. */
  18468. export interface INodeMaterialOptions {
  18469. /**
  18470. * Defines if blocks should emit comments
  18471. */
  18472. emitComments: boolean;
  18473. }
  18474. /**
  18475. * Class used to create a node based material built by assembling shader blocks
  18476. */
  18477. export class NodeMaterial extends PushMaterial {
  18478. private static _BuildIdGenerator;
  18479. private _options;
  18480. private _vertexCompilationState;
  18481. private _fragmentCompilationState;
  18482. private _sharedData;
  18483. private _buildId;
  18484. private _buildWasSuccessful;
  18485. private _cachedWorldViewMatrix;
  18486. private _cachedWorldViewProjectionMatrix;
  18487. private _optimizers;
  18488. private _animationFrame;
  18489. /** Define the Url to load node editor script */
  18490. static EditorURL: string;
  18491. /** Define the Url to load snippets */
  18492. static SnippetUrl: string;
  18493. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  18494. static IgnoreTexturesAtLoadTime: boolean;
  18495. private BJSNODEMATERIALEDITOR;
  18496. /** Get the inspector from bundle or global */
  18497. private _getGlobalNodeMaterialEditor;
  18498. /**
  18499. * Snippet ID if the material was created from the snippet server
  18500. */
  18501. snippetId: string;
  18502. /**
  18503. * Gets or sets data used by visual editor
  18504. * @see https://nme.babylonjs.com
  18505. */
  18506. editorData: any;
  18507. /**
  18508. * 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)
  18509. */
  18510. ignoreAlpha: boolean;
  18511. /**
  18512. * Defines the maximum number of lights that can be used in the material
  18513. */
  18514. maxSimultaneousLights: number;
  18515. /**
  18516. * Observable raised when the material is built
  18517. */
  18518. onBuildObservable: Observable<NodeMaterial>;
  18519. /**
  18520. * Gets or sets the root nodes of the material vertex shader
  18521. */
  18522. _vertexOutputNodes: NodeMaterialBlock[];
  18523. /**
  18524. * Gets or sets the root nodes of the material fragment (pixel) shader
  18525. */
  18526. _fragmentOutputNodes: NodeMaterialBlock[];
  18527. /** Gets or sets options to control the node material overall behavior */
  18528. get options(): INodeMaterialOptions;
  18529. set options(options: INodeMaterialOptions);
  18530. /**
  18531. * Default configuration related to image processing available in the standard Material.
  18532. */
  18533. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18534. /**
  18535. * Gets the image processing configuration used either in this material.
  18536. */
  18537. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18538. /**
  18539. * Sets the Default image processing configuration used either in the this material.
  18540. *
  18541. * If sets to null, the scene one is in use.
  18542. */
  18543. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18544. /**
  18545. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  18546. */
  18547. attachedBlocks: NodeMaterialBlock[];
  18548. /**
  18549. * Specifies the mode of the node material
  18550. * @hidden
  18551. */
  18552. _mode: NodeMaterialModes;
  18553. /**
  18554. * Gets the mode property
  18555. */
  18556. get mode(): NodeMaterialModes;
  18557. /**
  18558. * A free comment about the material
  18559. */
  18560. comment: string;
  18561. /**
  18562. * Create a new node based material
  18563. * @param name defines the material name
  18564. * @param scene defines the hosting scene
  18565. * @param options defines creation option
  18566. */
  18567. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18568. /**
  18569. * Gets the current class name of the material e.g. "NodeMaterial"
  18570. * @returns the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Keep track of the image processing observer to allow dispose and replace.
  18575. */
  18576. private _imageProcessingObserver;
  18577. /**
  18578. * Attaches a new image processing configuration to the Standard Material.
  18579. * @param configuration
  18580. */
  18581. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18582. /**
  18583. * Get a block by its name
  18584. * @param name defines the name of the block to retrieve
  18585. * @returns the required block or null if not found
  18586. */
  18587. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18588. /**
  18589. * Get a block by its name
  18590. * @param predicate defines the predicate used to find the good candidate
  18591. * @returns the required block or null if not found
  18592. */
  18593. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18594. /**
  18595. * Get an input block by its name
  18596. * @param predicate defines the predicate used to find the good candidate
  18597. * @returns the required input block or null if not found
  18598. */
  18599. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18600. /**
  18601. * Gets the list of input blocks attached to this material
  18602. * @returns an array of InputBlocks
  18603. */
  18604. getInputBlocks(): InputBlock[];
  18605. /**
  18606. * Adds a new optimizer to the list of optimizers
  18607. * @param optimizer defines the optimizers to add
  18608. * @returns the current material
  18609. */
  18610. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18611. /**
  18612. * Remove an optimizer from the list of optimizers
  18613. * @param optimizer defines the optimizers to remove
  18614. * @returns the current material
  18615. */
  18616. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18617. /**
  18618. * Add a new block to the list of output nodes
  18619. * @param node defines the node to add
  18620. * @returns the current material
  18621. */
  18622. addOutputNode(node: NodeMaterialBlock): this;
  18623. /**
  18624. * Remove a block from the list of root nodes
  18625. * @param node defines the node to remove
  18626. * @returns the current material
  18627. */
  18628. removeOutputNode(node: NodeMaterialBlock): this;
  18629. private _addVertexOutputNode;
  18630. private _removeVertexOutputNode;
  18631. private _addFragmentOutputNode;
  18632. private _removeFragmentOutputNode;
  18633. /**
  18634. * Specifies if the material will require alpha blending
  18635. * @returns a boolean specifying if alpha blending is needed
  18636. */
  18637. needAlphaBlending(): boolean;
  18638. /**
  18639. * Specifies if this material should be rendered in alpha test mode
  18640. * @returns a boolean specifying if an alpha test is needed.
  18641. */
  18642. needAlphaTesting(): boolean;
  18643. private _initializeBlock;
  18644. private _resetDualBlocks;
  18645. /**
  18646. * Remove a block from the current node material
  18647. * @param block defines the block to remove
  18648. */
  18649. removeBlock(block: NodeMaterialBlock): void;
  18650. /**
  18651. * Build the material and generates the inner effect
  18652. * @param verbose defines if the build should log activity
  18653. */
  18654. build(verbose?: boolean): void;
  18655. /**
  18656. * Runs an otpimization phase to try to improve the shader code
  18657. */
  18658. optimize(): void;
  18659. private _prepareDefinesForAttributes;
  18660. /**
  18661. * Create a post process from the material
  18662. * @param camera The camera to apply the render pass to.
  18663. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18665. * @param engine The engine which the post process will be applied. (default: current engine)
  18666. * @param reusable If the post process can be reused on the same frame. (default: false)
  18667. * @param textureType Type of textures used when performing the post process. (default: 0)
  18668. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18669. * @returns the post process created
  18670. */
  18671. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18672. /**
  18673. * Create the post process effect from the material
  18674. * @param postProcess The post process to create the effect for
  18675. */
  18676. createEffectForPostProcess(postProcess: PostProcess): void;
  18677. private _createEffectForPostProcess;
  18678. /**
  18679. * Create a new procedural texture based on this node material
  18680. * @param size defines the size of the texture
  18681. * @param scene defines the hosting scene
  18682. * @returns the new procedural texture attached to this node material
  18683. */
  18684. createProceduralTexture(size: number | {
  18685. width: number;
  18686. height: number;
  18687. layers?: number;
  18688. }, scene: Scene): Nullable<ProceduralTexture>;
  18689. private _createEffectForParticles;
  18690. private _checkInternals;
  18691. /**
  18692. * Create the effect to be used as the custom effect for a particle system
  18693. * @param particleSystem Particle system to create the effect for
  18694. * @param onCompiled defines a function to call when the effect creation is successful
  18695. * @param onError defines a function to call when the effect creation has failed
  18696. */
  18697. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18698. private _processDefines;
  18699. /**
  18700. * Get if the submesh is ready to be used and all its information available.
  18701. * Child classes can use it to update shaders
  18702. * @param mesh defines the mesh to check
  18703. * @param subMesh defines which submesh to check
  18704. * @param useInstances specifies that instances should be used
  18705. * @returns a boolean indicating that the submesh is ready or not
  18706. */
  18707. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18708. /**
  18709. * Get a string representing the shaders built by the current node graph
  18710. */
  18711. get compiledShaders(): string;
  18712. /**
  18713. * Binds the world matrix to the material
  18714. * @param world defines the world transformation matrix
  18715. */
  18716. bindOnlyWorldMatrix(world: Matrix): void;
  18717. /**
  18718. * Binds the submesh to this material by preparing the effect and shader to draw
  18719. * @param world defines the world transformation matrix
  18720. * @param mesh defines the mesh containing the submesh
  18721. * @param subMesh defines the submesh to bind the material to
  18722. */
  18723. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18724. /**
  18725. * Gets the active textures from the material
  18726. * @returns an array of textures
  18727. */
  18728. getActiveTextures(): BaseTexture[];
  18729. /**
  18730. * Gets the list of texture blocks
  18731. * @returns an array of texture blocks
  18732. */
  18733. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18734. /**
  18735. * Specifies if the material uses a texture
  18736. * @param texture defines the texture to check against the material
  18737. * @returns a boolean specifying if the material uses the texture
  18738. */
  18739. hasTexture(texture: BaseTexture): boolean;
  18740. /**
  18741. * Disposes the material
  18742. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18743. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18744. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18745. */
  18746. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18747. /** Creates the node editor window. */
  18748. private _createNodeEditor;
  18749. /**
  18750. * Launch the node material editor
  18751. * @param config Define the configuration of the editor
  18752. * @return a promise fulfilled when the node editor is visible
  18753. */
  18754. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18755. /**
  18756. * Clear the current material
  18757. */
  18758. clear(): void;
  18759. /**
  18760. * Clear the current material and set it to a default state
  18761. */
  18762. setToDefault(): void;
  18763. /**
  18764. * Clear the current material and set it to a default state for post process
  18765. */
  18766. setToDefaultPostProcess(): void;
  18767. /**
  18768. * Clear the current material and set it to a default state for procedural texture
  18769. */
  18770. setToDefaultProceduralTexture(): void;
  18771. /**
  18772. * Clear the current material and set it to a default state for particle
  18773. */
  18774. setToDefaultParticle(): void;
  18775. /**
  18776. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18777. * @param url defines the url to load from
  18778. * @returns a promise that will fulfil when the material is fully loaded
  18779. */
  18780. loadAsync(url: string): Promise<void>;
  18781. private _gatherBlocks;
  18782. /**
  18783. * Generate a string containing the code declaration required to create an equivalent of this material
  18784. * @returns a string
  18785. */
  18786. generateCode(): string;
  18787. /**
  18788. * Serializes this material in a JSON representation
  18789. * @returns the serialized material object
  18790. */
  18791. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18792. private _restoreConnections;
  18793. /**
  18794. * Clear the current graph and load a new one from a serialization object
  18795. * @param source defines the JSON representation of the material
  18796. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18797. * @param merge defines whether or not the source must be merged or replace the current content
  18798. */
  18799. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18800. /**
  18801. * Makes a duplicate of the current material.
  18802. * @param name - name to use for the new material.
  18803. */
  18804. clone(name: string): NodeMaterial;
  18805. /**
  18806. * Creates a node material from parsed material data
  18807. * @param source defines the JSON representation of the material
  18808. * @param scene defines the hosting scene
  18809. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18810. * @returns a new node material
  18811. */
  18812. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18813. /**
  18814. * Creates a node material from a snippet saved in a remote file
  18815. * @param name defines the name of the material to create
  18816. * @param url defines the url to load from
  18817. * @param scene defines the hosting scene
  18818. * @returns a promise that will resolve to the new node material
  18819. */
  18820. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18821. /**
  18822. * Creates a node material from a snippet saved by the node material editor
  18823. * @param snippetId defines the snippet to load
  18824. * @param scene defines the hosting scene
  18825. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18826. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18827. * @returns a promise that will resolve to the new node material
  18828. */
  18829. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18830. /**
  18831. * Creates a new node material set to default basic configuration
  18832. * @param name defines the name of the material
  18833. * @param scene defines the hosting scene
  18834. * @returns a new NodeMaterial
  18835. */
  18836. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18837. }
  18838. }
  18839. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18840. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18841. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18842. import { IColor4Like } from "babylonjs/Maths/math.like";
  18843. import { Nullable } from "babylonjs/types";
  18844. module "babylonjs/Engines/thinEngine" {
  18845. interface ThinEngine {
  18846. /**
  18847. * Unbind a list of render target textures from the webGL context
  18848. * This is used only when drawBuffer extension or webGL2 are active
  18849. * @param textures defines the render target textures to unbind
  18850. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18851. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18852. */
  18853. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18854. /**
  18855. * Create a multi render target texture
  18856. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18857. * @param size defines the size of the texture
  18858. * @param options defines the creation options
  18859. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18860. * @returns the cube texture as an InternalTexture
  18861. */
  18862. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18863. /**
  18864. * Update the sample count for a given multiple render target texture
  18865. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18866. * @param textures defines the textures to update
  18867. * @param samples defines the sample count to set
  18868. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18869. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18870. */
  18871. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18872. /**
  18873. * Select a subsets of attachments to draw to.
  18874. * @param attachments gl attachments
  18875. */
  18876. bindAttachments(attachments: number[]): void;
  18877. /**
  18878. * Creates a layout object to draw/clear on specific textures in a MRT
  18879. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18880. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18881. */
  18882. buildTextureLayout(textureStatus: boolean[]): number[];
  18883. /**
  18884. * Restores the webgl state to only draw on the main color attachment
  18885. * when the frame buffer associated is the canvas frame buffer
  18886. */
  18887. restoreSingleAttachment(): void;
  18888. /**
  18889. * Restores the webgl state to only draw on the main color attachment
  18890. * when the frame buffer associated is not the canvas frame buffer
  18891. */
  18892. restoreSingleAttachmentForRenderTarget(): void;
  18893. /**
  18894. * Clears a list of attachments
  18895. * @param attachments list of the attachments
  18896. * @param colorMain clear color for the main attachment (the first one)
  18897. * @param colorOthers clear color for the other attachments
  18898. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18899. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18900. */
  18901. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18902. }
  18903. }
  18904. }
  18905. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18906. import { Scene } from "babylonjs/scene";
  18907. import { Engine } from "babylonjs/Engines/engine";
  18908. import { Texture } from "babylonjs/Materials/Textures/texture";
  18909. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18910. import "babylonjs/Engines/Extensions/engine.multiRender";
  18911. /**
  18912. * Creation options of the multi render target texture.
  18913. */
  18914. export interface IMultiRenderTargetOptions {
  18915. /**
  18916. * Define if the texture needs to create mip maps after render.
  18917. */
  18918. generateMipMaps?: boolean;
  18919. /**
  18920. * Define the types of all the draw buffers we want to create
  18921. */
  18922. types?: number[];
  18923. /**
  18924. * Define the sampling modes of all the draw buffers we want to create
  18925. */
  18926. samplingModes?: number[];
  18927. /**
  18928. * Define if a depth buffer is required
  18929. */
  18930. generateDepthBuffer?: boolean;
  18931. /**
  18932. * Define if a stencil buffer is required
  18933. */
  18934. generateStencilBuffer?: boolean;
  18935. /**
  18936. * Define if a depth texture is required instead of a depth buffer
  18937. */
  18938. generateDepthTexture?: boolean;
  18939. /**
  18940. * Define the number of desired draw buffers
  18941. */
  18942. textureCount?: number;
  18943. /**
  18944. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18945. */
  18946. doNotChangeAspectRatio?: boolean;
  18947. /**
  18948. * Define the default type of the buffers we are creating
  18949. */
  18950. defaultType?: number;
  18951. /**
  18952. * Define the default type of the buffers we are creating
  18953. */
  18954. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18955. }
  18956. /**
  18957. * A multi render target, like a render target provides the ability to render to a texture.
  18958. * Unlike the render target, it can render to several draw buffers in one draw.
  18959. * This is specially interesting in deferred rendering or for any effects requiring more than
  18960. * just one color from a single pass.
  18961. */
  18962. export class MultiRenderTarget extends RenderTargetTexture {
  18963. private _internalTextures;
  18964. private _textures;
  18965. private _multiRenderTargetOptions;
  18966. private _count;
  18967. private _drawOnlyOnFirstAttachmentByDefault;
  18968. /**
  18969. * Get if draw buffers are currently supported by the used hardware and browser.
  18970. */
  18971. get isSupported(): boolean;
  18972. /**
  18973. * Get the list of textures generated by the multi render target.
  18974. */
  18975. get textures(): Texture[];
  18976. /**
  18977. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18978. */
  18979. get count(): number;
  18980. /**
  18981. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18982. */
  18983. get depthTexture(): Texture;
  18984. /**
  18985. * Set the wrapping mode on U of all the textures we are rendering to.
  18986. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18987. */
  18988. set wrapU(wrap: number);
  18989. /**
  18990. * Set the wrapping mode on V of all the textures we are rendering to.
  18991. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18992. */
  18993. set wrapV(wrap: number);
  18994. /**
  18995. * Instantiate a new multi render target texture.
  18996. * A multi render target, like a render target provides the ability to render to a texture.
  18997. * Unlike the render target, it can render to several draw buffers in one draw.
  18998. * This is specially interesting in deferred rendering or for any effects requiring more than
  18999. * just one color from a single pass.
  19000. * @param name Define the name of the texture
  19001. * @param size Define the size of the buffers to render to
  19002. * @param count Define the number of target we are rendering into
  19003. * @param scene Define the scene the texture belongs to
  19004. * @param options Define the options used to create the multi render target
  19005. */
  19006. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  19007. private _initTypes;
  19008. /** @hidden */
  19009. _rebuild(forceFullRebuild?: boolean): void;
  19010. private _createInternalTextures;
  19011. private _createTextures;
  19012. /**
  19013. * Replaces a texture within the MRT.
  19014. * @param texture The new texture to insert in the MRT
  19015. * @param index The index of the texture to replace
  19016. */
  19017. replaceTexture(texture: Texture, index: number): void;
  19018. /**
  19019. * Define the number of samples used if MSAA is enabled.
  19020. */
  19021. get samples(): number;
  19022. set samples(value: number);
  19023. /**
  19024. * Resize all the textures in the multi render target.
  19025. * Be careful as it will recreate all the data in the new texture.
  19026. * @param size Define the new size
  19027. */
  19028. resize(size: any): void;
  19029. /**
  19030. * Changes the number of render targets in this MRT
  19031. * Be careful as it will recreate all the data in the new texture.
  19032. * @param count new texture count
  19033. * @param options Specifies texture types and sampling modes for new textures
  19034. */
  19035. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  19036. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19037. /**
  19038. * Dispose the render targets and their associated resources
  19039. */
  19040. dispose(): void;
  19041. /**
  19042. * Release all the underlying texture used as draw buffers.
  19043. */
  19044. releaseInternalTextures(): void;
  19045. }
  19046. }
  19047. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  19048. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19049. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19050. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19051. /** @hidden */
  19052. export var imageProcessingPixelShader: {
  19053. name: string;
  19054. shader: string;
  19055. };
  19056. }
  19057. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  19058. import { Nullable } from "babylonjs/types";
  19059. import { Color4 } from "babylonjs/Maths/math.color";
  19060. import { Camera } from "babylonjs/Cameras/camera";
  19061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19062. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19063. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  19064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  19065. import { Engine } from "babylonjs/Engines/engine";
  19066. import "babylonjs/Shaders/imageProcessing.fragment";
  19067. import "babylonjs/Shaders/postprocess.vertex";
  19068. /**
  19069. * ImageProcessingPostProcess
  19070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  19071. */
  19072. export class ImageProcessingPostProcess extends PostProcess {
  19073. /**
  19074. * Default configuration related to image processing available in the PBR Material.
  19075. */
  19076. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19077. /**
  19078. * Gets the image processing configuration used either in this material.
  19079. */
  19080. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19081. /**
  19082. * Sets the Default image processing configuration used either in the this material.
  19083. *
  19084. * If sets to null, the scene one is in use.
  19085. */
  19086. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19087. /**
  19088. * Keep track of the image processing observer to allow dispose and replace.
  19089. */
  19090. private _imageProcessingObserver;
  19091. /**
  19092. * Attaches a new image processing configuration to the PBR Material.
  19093. * @param configuration
  19094. */
  19095. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  19096. /**
  19097. * If the post process is supported.
  19098. */
  19099. get isSupported(): boolean;
  19100. /**
  19101. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19102. */
  19103. get colorCurves(): Nullable<ColorCurves>;
  19104. /**
  19105. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19106. */
  19107. set colorCurves(value: Nullable<ColorCurves>);
  19108. /**
  19109. * Gets whether the color curves effect is enabled.
  19110. */
  19111. get colorCurvesEnabled(): boolean;
  19112. /**
  19113. * Sets whether the color curves effect is enabled.
  19114. */
  19115. set colorCurvesEnabled(value: boolean);
  19116. /**
  19117. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19118. */
  19119. get colorGradingTexture(): Nullable<BaseTexture>;
  19120. /**
  19121. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19122. */
  19123. set colorGradingTexture(value: Nullable<BaseTexture>);
  19124. /**
  19125. * Gets whether the color grading effect is enabled.
  19126. */
  19127. get colorGradingEnabled(): boolean;
  19128. /**
  19129. * Gets whether the color grading effect is enabled.
  19130. */
  19131. set colorGradingEnabled(value: boolean);
  19132. /**
  19133. * Gets exposure used in the effect.
  19134. */
  19135. get exposure(): number;
  19136. /**
  19137. * Sets exposure used in the effect.
  19138. */
  19139. set exposure(value: number);
  19140. /**
  19141. * Gets whether tonemapping is enabled or not.
  19142. */
  19143. get toneMappingEnabled(): boolean;
  19144. /**
  19145. * Sets whether tonemapping is enabled or not
  19146. */
  19147. set toneMappingEnabled(value: boolean);
  19148. /**
  19149. * Gets the type of tone mapping effect.
  19150. */
  19151. get toneMappingType(): number;
  19152. /**
  19153. * Sets the type of tone mapping effect.
  19154. */
  19155. set toneMappingType(value: number);
  19156. /**
  19157. * Gets contrast used in the effect.
  19158. */
  19159. get contrast(): number;
  19160. /**
  19161. * Sets contrast used in the effect.
  19162. */
  19163. set contrast(value: number);
  19164. /**
  19165. * Gets Vignette stretch size.
  19166. */
  19167. get vignetteStretch(): number;
  19168. /**
  19169. * Sets Vignette stretch size.
  19170. */
  19171. set vignetteStretch(value: number);
  19172. /**
  19173. * Gets Vignette centre X Offset.
  19174. */
  19175. get vignetteCentreX(): number;
  19176. /**
  19177. * Sets Vignette centre X Offset.
  19178. */
  19179. set vignetteCentreX(value: number);
  19180. /**
  19181. * Gets Vignette centre Y Offset.
  19182. */
  19183. get vignetteCentreY(): number;
  19184. /**
  19185. * Sets Vignette centre Y Offset.
  19186. */
  19187. set vignetteCentreY(value: number);
  19188. /**
  19189. * Gets Vignette weight or intensity of the vignette effect.
  19190. */
  19191. get vignetteWeight(): number;
  19192. /**
  19193. * Sets Vignette weight or intensity of the vignette effect.
  19194. */
  19195. set vignetteWeight(value: number);
  19196. /**
  19197. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19198. * if vignetteEnabled is set to true.
  19199. */
  19200. get vignetteColor(): Color4;
  19201. /**
  19202. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19203. * if vignetteEnabled is set to true.
  19204. */
  19205. set vignetteColor(value: Color4);
  19206. /**
  19207. * Gets Camera field of view used by the Vignette effect.
  19208. */
  19209. get vignetteCameraFov(): number;
  19210. /**
  19211. * Sets Camera field of view used by the Vignette effect.
  19212. */
  19213. set vignetteCameraFov(value: number);
  19214. /**
  19215. * Gets the vignette blend mode allowing different kind of effect.
  19216. */
  19217. get vignetteBlendMode(): number;
  19218. /**
  19219. * Sets the vignette blend mode allowing different kind of effect.
  19220. */
  19221. set vignetteBlendMode(value: number);
  19222. /**
  19223. * Gets whether the vignette effect is enabled.
  19224. */
  19225. get vignetteEnabled(): boolean;
  19226. /**
  19227. * Sets whether the vignette effect is enabled.
  19228. */
  19229. set vignetteEnabled(value: boolean);
  19230. private _fromLinearSpace;
  19231. /**
  19232. * Gets whether the input of the processing is in Gamma or Linear Space.
  19233. */
  19234. get fromLinearSpace(): boolean;
  19235. /**
  19236. * Sets whether the input of the processing is in Gamma or Linear Space.
  19237. */
  19238. set fromLinearSpace(value: boolean);
  19239. /**
  19240. * Defines cache preventing GC.
  19241. */
  19242. private _defines;
  19243. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  19244. /**
  19245. * "ImageProcessingPostProcess"
  19246. * @returns "ImageProcessingPostProcess"
  19247. */
  19248. getClassName(): string;
  19249. /**
  19250. * @hidden
  19251. */
  19252. _updateParameters(): void;
  19253. dispose(camera?: Camera): void;
  19254. }
  19255. }
  19256. declare module "babylonjs/Materials/Textures/prePassRenderTarget" {
  19257. import { MultiRenderTarget, IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  19258. import { Engine } from "babylonjs/Engines/engine";
  19259. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19260. import { Scene } from "babylonjs/scene";
  19261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19262. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  19263. import { Nullable } from "babylonjs/types";
  19264. /**
  19265. * A multi render target designed to render the prepass.
  19266. * Prepass is a scene component used to render information in multiple textures
  19267. * alongside with the scene materials rendering.
  19268. * Note : This is an internal class, and you should NOT need to instanciate this.
  19269. * Only the `PrePassRenderer` should instanciate this class.
  19270. * It is more likely that you need a regular `MultiRenderTarget`
  19271. * @hidden
  19272. */
  19273. export class PrePassRenderTarget extends MultiRenderTarget {
  19274. /**
  19275. * @hidden
  19276. */
  19277. _beforeCompositionPostProcesses: PostProcess[];
  19278. /**
  19279. * Image processing post process for composition
  19280. */
  19281. imageProcessingPostProcess: ImageProcessingPostProcess;
  19282. /**
  19283. * @hidden
  19284. */
  19285. _engine: Engine;
  19286. /**
  19287. * @hidden
  19288. */
  19289. _scene: Scene;
  19290. /**
  19291. * @hidden
  19292. */
  19293. _outputPostProcess: Nullable<PostProcess>;
  19294. /**
  19295. * @hidden
  19296. */
  19297. _internalTextureDirty: boolean;
  19298. /**
  19299. * Is this render target enabled for prepass rendering
  19300. */
  19301. enabled: boolean;
  19302. /**
  19303. * Render target associated with this prePassRenderTarget
  19304. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  19305. */
  19306. renderTargetTexture: Nullable<RenderTargetTexture>;
  19307. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  19308. /**
  19309. * Creates a composition effect for this RT
  19310. * @hidden
  19311. */
  19312. _createCompositionEffect(): void;
  19313. /**
  19314. * Checks that the size of this RT is still adapted to the desired render size.
  19315. * @hidden
  19316. */
  19317. _checkSize(): void;
  19318. /**
  19319. * Changes the number of render targets in this MRT
  19320. * Be careful as it will recreate all the data in the new texture.
  19321. * @param count new texture count
  19322. * @param options Specifies texture types and sampling modes for new textures
  19323. */
  19324. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  19325. /**
  19326. * Resets the post processes chains applied to this RT.
  19327. * @hidden
  19328. */
  19329. _resetPostProcessChain(): void;
  19330. /**
  19331. * Diposes this render target
  19332. */
  19333. dispose(): void;
  19334. }
  19335. }
  19336. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  19337. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19338. /**
  19339. * Interface for defining prepass effects in the prepass post-process pipeline
  19340. */
  19341. export interface PrePassEffectConfiguration {
  19342. /**
  19343. * Name of the effect
  19344. */
  19345. name: string;
  19346. /**
  19347. * Post process to attach for this effect
  19348. */
  19349. postProcess?: PostProcess;
  19350. /**
  19351. * Textures required in the MRT
  19352. */
  19353. texturesRequired: number[];
  19354. /**
  19355. * Is the effect enabled
  19356. */
  19357. enabled: boolean;
  19358. /**
  19359. * Does the output of this prepass need to go through imageprocessing
  19360. */
  19361. needsImageProcessing?: boolean;
  19362. /**
  19363. * Disposes the effect configuration
  19364. */
  19365. dispose?: () => void;
  19366. /**
  19367. * Creates the associated post process
  19368. */
  19369. createPostProcess?: () => PostProcess;
  19370. }
  19371. }
  19372. declare module "babylonjs/Materials/fresnelParameters" {
  19373. import { DeepImmutable } from "babylonjs/types";
  19374. import { Color3 } from "babylonjs/Maths/math.color";
  19375. /**
  19376. * Options to be used when creating a FresnelParameters.
  19377. */
  19378. export type IFresnelParametersCreationOptions = {
  19379. /**
  19380. * Define the color used on edges (grazing angle)
  19381. */
  19382. leftColor?: Color3;
  19383. /**
  19384. * Define the color used on center
  19385. */
  19386. rightColor?: Color3;
  19387. /**
  19388. * Define bias applied to computed fresnel term
  19389. */
  19390. bias?: number;
  19391. /**
  19392. * Defined the power exponent applied to fresnel term
  19393. */
  19394. power?: number;
  19395. /**
  19396. * Define if the fresnel effect is enable or not.
  19397. */
  19398. isEnabled?: boolean;
  19399. };
  19400. /**
  19401. * Serialized format for FresnelParameters.
  19402. */
  19403. export type IFresnelParametersSerialized = {
  19404. /**
  19405. * Define the color used on edges (grazing angle) [as an array]
  19406. */
  19407. leftColor: number[];
  19408. /**
  19409. * Define the color used on center [as an array]
  19410. */
  19411. rightColor: number[];
  19412. /**
  19413. * Define bias applied to computed fresnel term
  19414. */
  19415. bias: number;
  19416. /**
  19417. * Defined the power exponent applied to fresnel term
  19418. */
  19419. power?: number;
  19420. /**
  19421. * Define if the fresnel effect is enable or not.
  19422. */
  19423. isEnabled: boolean;
  19424. };
  19425. /**
  19426. * This represents all the required information to add a fresnel effect on a material:
  19427. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19428. */
  19429. export class FresnelParameters {
  19430. private _isEnabled;
  19431. /**
  19432. * Define if the fresnel effect is enable or not.
  19433. */
  19434. get isEnabled(): boolean;
  19435. set isEnabled(value: boolean);
  19436. /**
  19437. * Define the color used on edges (grazing angle)
  19438. */
  19439. leftColor: Color3;
  19440. /**
  19441. * Define the color used on center
  19442. */
  19443. rightColor: Color3;
  19444. /**
  19445. * Define bias applied to computed fresnel term
  19446. */
  19447. bias: number;
  19448. /**
  19449. * Defined the power exponent applied to fresnel term
  19450. */
  19451. power: number;
  19452. /**
  19453. * Creates a new FresnelParameters object.
  19454. *
  19455. * @param options provide your own settings to optionally to override defaults
  19456. */
  19457. constructor(options?: IFresnelParametersCreationOptions);
  19458. /**
  19459. * Clones the current fresnel and its values
  19460. * @returns a clone fresnel configuration
  19461. */
  19462. clone(): FresnelParameters;
  19463. /**
  19464. * Determines equality between FresnelParameters objects
  19465. * @param otherFresnelParameters defines the second operand
  19466. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  19467. */
  19468. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  19469. /**
  19470. * Serializes the current fresnel parameters to a JSON representation.
  19471. * @return the JSON serialization
  19472. */
  19473. serialize(): IFresnelParametersSerialized;
  19474. /**
  19475. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  19476. * @param parsedFresnelParameters Define the JSON representation
  19477. * @returns the parsed parameters
  19478. */
  19479. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  19480. }
  19481. }
  19482. declare module "babylonjs/Materials/materialFlags" {
  19483. /**
  19484. * This groups all the flags used to control the materials channel.
  19485. */
  19486. export class MaterialFlags {
  19487. private static _DiffuseTextureEnabled;
  19488. /**
  19489. * Are diffuse textures enabled in the application.
  19490. */
  19491. static get DiffuseTextureEnabled(): boolean;
  19492. static set DiffuseTextureEnabled(value: boolean);
  19493. private static _DetailTextureEnabled;
  19494. /**
  19495. * Are detail textures enabled in the application.
  19496. */
  19497. static get DetailTextureEnabled(): boolean;
  19498. static set DetailTextureEnabled(value: boolean);
  19499. private static _AmbientTextureEnabled;
  19500. /**
  19501. * Are ambient textures enabled in the application.
  19502. */
  19503. static get AmbientTextureEnabled(): boolean;
  19504. static set AmbientTextureEnabled(value: boolean);
  19505. private static _OpacityTextureEnabled;
  19506. /**
  19507. * Are opacity textures enabled in the application.
  19508. */
  19509. static get OpacityTextureEnabled(): boolean;
  19510. static set OpacityTextureEnabled(value: boolean);
  19511. private static _ReflectionTextureEnabled;
  19512. /**
  19513. * Are reflection textures enabled in the application.
  19514. */
  19515. static get ReflectionTextureEnabled(): boolean;
  19516. static set ReflectionTextureEnabled(value: boolean);
  19517. private static _EmissiveTextureEnabled;
  19518. /**
  19519. * Are emissive textures enabled in the application.
  19520. */
  19521. static get EmissiveTextureEnabled(): boolean;
  19522. static set EmissiveTextureEnabled(value: boolean);
  19523. private static _SpecularTextureEnabled;
  19524. /**
  19525. * Are specular textures enabled in the application.
  19526. */
  19527. static get SpecularTextureEnabled(): boolean;
  19528. static set SpecularTextureEnabled(value: boolean);
  19529. private static _BumpTextureEnabled;
  19530. /**
  19531. * Are bump textures enabled in the application.
  19532. */
  19533. static get BumpTextureEnabled(): boolean;
  19534. static set BumpTextureEnabled(value: boolean);
  19535. private static _LightmapTextureEnabled;
  19536. /**
  19537. * Are lightmap textures enabled in the application.
  19538. */
  19539. static get LightmapTextureEnabled(): boolean;
  19540. static set LightmapTextureEnabled(value: boolean);
  19541. private static _RefractionTextureEnabled;
  19542. /**
  19543. * Are refraction textures enabled in the application.
  19544. */
  19545. static get RefractionTextureEnabled(): boolean;
  19546. static set RefractionTextureEnabled(value: boolean);
  19547. private static _ColorGradingTextureEnabled;
  19548. /**
  19549. * Are color grading textures enabled in the application.
  19550. */
  19551. static get ColorGradingTextureEnabled(): boolean;
  19552. static set ColorGradingTextureEnabled(value: boolean);
  19553. private static _FresnelEnabled;
  19554. /**
  19555. * Are fresnels enabled in the application.
  19556. */
  19557. static get FresnelEnabled(): boolean;
  19558. static set FresnelEnabled(value: boolean);
  19559. private static _ClearCoatTextureEnabled;
  19560. /**
  19561. * Are clear coat textures enabled in the application.
  19562. */
  19563. static get ClearCoatTextureEnabled(): boolean;
  19564. static set ClearCoatTextureEnabled(value: boolean);
  19565. private static _ClearCoatBumpTextureEnabled;
  19566. /**
  19567. * Are clear coat bump textures enabled in the application.
  19568. */
  19569. static get ClearCoatBumpTextureEnabled(): boolean;
  19570. static set ClearCoatBumpTextureEnabled(value: boolean);
  19571. private static _ClearCoatTintTextureEnabled;
  19572. /**
  19573. * Are clear coat tint textures enabled in the application.
  19574. */
  19575. static get ClearCoatTintTextureEnabled(): boolean;
  19576. static set ClearCoatTintTextureEnabled(value: boolean);
  19577. private static _SheenTextureEnabled;
  19578. /**
  19579. * Are sheen textures enabled in the application.
  19580. */
  19581. static get SheenTextureEnabled(): boolean;
  19582. static set SheenTextureEnabled(value: boolean);
  19583. private static _AnisotropicTextureEnabled;
  19584. /**
  19585. * Are anisotropic textures enabled in the application.
  19586. */
  19587. static get AnisotropicTextureEnabled(): boolean;
  19588. static set AnisotropicTextureEnabled(value: boolean);
  19589. private static _ThicknessTextureEnabled;
  19590. /**
  19591. * Are thickness textures enabled in the application.
  19592. */
  19593. static get ThicknessTextureEnabled(): boolean;
  19594. static set ThicknessTextureEnabled(value: boolean);
  19595. }
  19596. }
  19597. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  19598. /** @hidden */
  19599. export var defaultFragmentDeclaration: {
  19600. name: string;
  19601. shader: string;
  19602. };
  19603. }
  19604. declare module "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration" {
  19605. /** @hidden */
  19606. export var sceneUboDeclaration: {
  19607. name: string;
  19608. shader: string;
  19609. };
  19610. }
  19611. declare module "babylonjs/Shaders/ShadersInclude/meshUboDeclaration" {
  19612. /** @hidden */
  19613. export var meshUboDeclaration: {
  19614. name: string;
  19615. shader: string;
  19616. };
  19617. }
  19618. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  19619. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  19620. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  19621. /** @hidden */
  19622. export var defaultUboDeclaration: {
  19623. name: string;
  19624. shader: string;
  19625. };
  19626. }
  19627. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  19628. /** @hidden */
  19629. export var prePassDeclaration: {
  19630. name: string;
  19631. shader: string;
  19632. };
  19633. }
  19634. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  19635. /** @hidden */
  19636. export var lightFragmentDeclaration: {
  19637. name: string;
  19638. shader: string;
  19639. };
  19640. }
  19641. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  19642. /** @hidden */
  19643. export var lightUboDeclaration: {
  19644. name: string;
  19645. shader: string;
  19646. };
  19647. }
  19648. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  19649. /** @hidden */
  19650. export var lightsFragmentFunctions: {
  19651. name: string;
  19652. shader: string;
  19653. };
  19654. }
  19655. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  19656. /** @hidden */
  19657. export var shadowsFragmentFunctions: {
  19658. name: string;
  19659. shader: string;
  19660. };
  19661. }
  19662. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  19663. /** @hidden */
  19664. export var fresnelFunction: {
  19665. name: string;
  19666. shader: string;
  19667. };
  19668. }
  19669. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  19670. /** @hidden */
  19671. export var bumpFragmentMainFunctions: {
  19672. name: string;
  19673. shader: string;
  19674. };
  19675. }
  19676. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  19677. /** @hidden */
  19678. export var bumpFragmentFunctions: {
  19679. name: string;
  19680. shader: string;
  19681. };
  19682. }
  19683. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  19684. /** @hidden */
  19685. export var logDepthDeclaration: {
  19686. name: string;
  19687. shader: string;
  19688. };
  19689. }
  19690. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  19691. /** @hidden */
  19692. export var fogFragmentDeclaration: {
  19693. name: string;
  19694. shader: string;
  19695. };
  19696. }
  19697. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  19698. /** @hidden */
  19699. export var bumpFragment: {
  19700. name: string;
  19701. shader: string;
  19702. };
  19703. }
  19704. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  19705. /** @hidden */
  19706. export var depthPrePass: {
  19707. name: string;
  19708. shader: string;
  19709. };
  19710. }
  19711. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  19712. /** @hidden */
  19713. export var lightFragment: {
  19714. name: string;
  19715. shader: string;
  19716. };
  19717. }
  19718. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  19719. /** @hidden */
  19720. export var logDepthFragment: {
  19721. name: string;
  19722. shader: string;
  19723. };
  19724. }
  19725. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  19726. /** @hidden */
  19727. export var fogFragment: {
  19728. name: string;
  19729. shader: string;
  19730. };
  19731. }
  19732. declare module "babylonjs/Shaders/default.fragment" {
  19733. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  19734. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19735. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  19736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19737. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19738. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19739. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  19740. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  19741. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  19742. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  19743. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19744. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19745. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  19746. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  19747. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19748. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19749. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  19750. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19751. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  19752. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  19753. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  19754. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  19755. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  19756. /** @hidden */
  19757. export var defaultPixelShader: {
  19758. name: string;
  19759. shader: string;
  19760. };
  19761. }
  19762. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  19763. /** @hidden */
  19764. export var defaultVertexDeclaration: {
  19765. name: string;
  19766. shader: string;
  19767. };
  19768. }
  19769. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  19770. /** @hidden */
  19771. export var bonesDeclaration: {
  19772. name: string;
  19773. shader: string;
  19774. };
  19775. }
  19776. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  19777. /** @hidden */
  19778. export var prePassVertexDeclaration: {
  19779. name: string;
  19780. shader: string;
  19781. };
  19782. }
  19783. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  19784. /** @hidden */
  19785. export var bumpVertexDeclaration: {
  19786. name: string;
  19787. shader: string;
  19788. };
  19789. }
  19790. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  19791. /** @hidden */
  19792. export var fogVertexDeclaration: {
  19793. name: string;
  19794. shader: string;
  19795. };
  19796. }
  19797. declare module "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration" {
  19798. /** @hidden */
  19799. export var lightVxFragmentDeclaration: {
  19800. name: string;
  19801. shader: string;
  19802. };
  19803. }
  19804. declare module "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration" {
  19805. /** @hidden */
  19806. export var lightVxUboDeclaration: {
  19807. name: string;
  19808. shader: string;
  19809. };
  19810. }
  19811. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  19812. /** @hidden */
  19813. export var morphTargetsVertexGlobalDeclaration: {
  19814. name: string;
  19815. shader: string;
  19816. };
  19817. }
  19818. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  19819. /** @hidden */
  19820. export var morphTargetsVertexDeclaration: {
  19821. name: string;
  19822. shader: string;
  19823. };
  19824. }
  19825. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal" {
  19826. /** @hidden */
  19827. export var morphTargetsVertexGlobal: {
  19828. name: string;
  19829. shader: string;
  19830. };
  19831. }
  19832. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  19833. /** @hidden */
  19834. export var morphTargetsVertex: {
  19835. name: string;
  19836. shader: string;
  19837. };
  19838. }
  19839. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19840. /** @hidden */
  19841. export var instancesVertex: {
  19842. name: string;
  19843. shader: string;
  19844. };
  19845. }
  19846. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19847. /** @hidden */
  19848. export var bonesVertex: {
  19849. name: string;
  19850. shader: string;
  19851. };
  19852. }
  19853. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19854. /** @hidden */
  19855. export var prePassVertex: {
  19856. name: string;
  19857. shader: string;
  19858. };
  19859. }
  19860. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19861. /** @hidden */
  19862. export var bumpVertex: {
  19863. name: string;
  19864. shader: string;
  19865. };
  19866. }
  19867. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19868. /** @hidden */
  19869. export var fogVertex: {
  19870. name: string;
  19871. shader: string;
  19872. };
  19873. }
  19874. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19875. /** @hidden */
  19876. export var shadowsVertex: {
  19877. name: string;
  19878. shader: string;
  19879. };
  19880. }
  19881. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19882. /** @hidden */
  19883. export var pointCloudVertex: {
  19884. name: string;
  19885. shader: string;
  19886. };
  19887. }
  19888. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19889. /** @hidden */
  19890. export var logDepthVertex: {
  19891. name: string;
  19892. shader: string;
  19893. };
  19894. }
  19895. declare module "babylonjs/Shaders/default.vertex" {
  19896. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19897. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19898. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19899. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19900. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19901. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19902. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19903. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19904. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  19905. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  19906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19908. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19909. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal";
  19910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19911. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19912. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19913. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19914. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19915. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19916. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19917. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19918. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19919. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19920. /** @hidden */
  19921. export var defaultVertexShader: {
  19922. name: string;
  19923. shader: string;
  19924. };
  19925. }
  19926. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19927. import { Nullable } from "babylonjs/types";
  19928. import { Scene } from "babylonjs/scene";
  19929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19930. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19931. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19932. /**
  19933. * @hidden
  19934. */
  19935. export interface IMaterialDetailMapDefines {
  19936. DETAIL: boolean;
  19937. DETAILDIRECTUV: number;
  19938. DETAIL_NORMALBLENDMETHOD: number;
  19939. /** @hidden */
  19940. _areTexturesDirty: boolean;
  19941. }
  19942. /**
  19943. * Define the code related to the detail map parameters of a material
  19944. *
  19945. * Inspired from:
  19946. * 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
  19947. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19948. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19949. */
  19950. export class DetailMapConfiguration {
  19951. private _texture;
  19952. /**
  19953. * The detail texture of the material.
  19954. */
  19955. texture: Nullable<BaseTexture>;
  19956. /**
  19957. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19958. * Bigger values mean stronger blending
  19959. */
  19960. diffuseBlendLevel: number;
  19961. /**
  19962. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19963. * Bigger values mean stronger blending. Only used with PBR materials
  19964. */
  19965. roughnessBlendLevel: number;
  19966. /**
  19967. * Defines how strong the bump effect from the detail map is
  19968. * Bigger values mean stronger effect
  19969. */
  19970. bumpLevel: number;
  19971. private _normalBlendMethod;
  19972. /**
  19973. * The method used to blend the bump and detail normals together
  19974. */
  19975. normalBlendMethod: number;
  19976. private _isEnabled;
  19977. /**
  19978. * Enable or disable the detail map on this material
  19979. */
  19980. isEnabled: boolean;
  19981. /** @hidden */
  19982. private _internalMarkAllSubMeshesAsTexturesDirty;
  19983. /** @hidden */
  19984. _markAllSubMeshesAsTexturesDirty(): void;
  19985. /**
  19986. * Instantiate a new detail map
  19987. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19988. */
  19989. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19990. /**
  19991. * Gets whether the submesh is ready to be used or not.
  19992. * @param defines the list of "defines" to update.
  19993. * @param scene defines the scene the material belongs to.
  19994. * @returns - boolean indicating that the submesh is ready or not.
  19995. */
  19996. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19997. /**
  19998. * Update the defines for detail map usage
  19999. * @param defines the list of "defines" to update.
  20000. * @param scene defines the scene the material belongs to.
  20001. */
  20002. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  20003. /**
  20004. * Binds the material data.
  20005. * @param uniformBuffer defines the Uniform buffer to fill in.
  20006. * @param scene defines the scene the material belongs to.
  20007. * @param isFrozen defines whether the material is frozen or not.
  20008. */
  20009. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20010. /**
  20011. * Checks to see if a texture is used in the material.
  20012. * @param texture - Base texture to use.
  20013. * @returns - Boolean specifying if a texture is used in the material.
  20014. */
  20015. hasTexture(texture: BaseTexture): boolean;
  20016. /**
  20017. * Returns an array of the actively used textures.
  20018. * @param activeTextures Array of BaseTextures
  20019. */
  20020. getActiveTextures(activeTextures: BaseTexture[]): void;
  20021. /**
  20022. * Returns the animatable textures.
  20023. * @param animatables Array of animatable textures.
  20024. */
  20025. getAnimatables(animatables: IAnimatable[]): void;
  20026. /**
  20027. * Disposes the resources of the material.
  20028. * @param forceDisposeTextures - Forces the disposal of all textures.
  20029. */
  20030. dispose(forceDisposeTextures?: boolean): void;
  20031. /**
  20032. * Get the current class name useful for serialization or dynamic coding.
  20033. * @returns "DetailMap"
  20034. */
  20035. getClassName(): string;
  20036. /**
  20037. * Add the required uniforms to the current list.
  20038. * @param uniforms defines the current uniform list.
  20039. */
  20040. static AddUniforms(uniforms: string[]): void;
  20041. /**
  20042. * Add the required samplers to the current list.
  20043. * @param samplers defines the current sampler list.
  20044. */
  20045. static AddSamplers(samplers: string[]): void;
  20046. /**
  20047. * Add the required uniforms to the current buffer.
  20048. * @param uniformBuffer defines the current uniform buffer.
  20049. */
  20050. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20051. /**
  20052. * Makes a duplicate of the current instance into another one.
  20053. * @param detailMap define the instance where to copy the info
  20054. */
  20055. copyTo(detailMap: DetailMapConfiguration): void;
  20056. /**
  20057. * Serializes this detail map instance
  20058. * @returns - An object with the serialized instance.
  20059. */
  20060. serialize(): any;
  20061. /**
  20062. * Parses a detail map setting from a serialized object.
  20063. * @param source - Serialized object.
  20064. * @param scene Defines the scene we are parsing for
  20065. * @param rootUrl Defines the rootUrl to load from
  20066. */
  20067. parse(source: any, scene: Scene, rootUrl: string): void;
  20068. }
  20069. }
  20070. declare module "babylonjs/Materials/standardMaterial" {
  20071. import { SmartArray } from "babylonjs/Misc/smartArray";
  20072. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20073. import { Nullable } from "babylonjs/types";
  20074. import { Scene } from "babylonjs/scene";
  20075. import { Matrix } from "babylonjs/Maths/math.vector";
  20076. import { Color3 } from "babylonjs/Maths/math.color";
  20077. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20079. import { Mesh } from "babylonjs/Meshes/mesh";
  20080. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20081. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  20082. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  20083. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  20084. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20085. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  20086. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20087. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20088. import "babylonjs/Shaders/default.fragment";
  20089. import "babylonjs/Shaders/default.vertex";
  20090. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  20091. /** @hidden */
  20092. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  20093. MAINUV1: boolean;
  20094. MAINUV2: boolean;
  20095. DIFFUSE: boolean;
  20096. DIFFUSEDIRECTUV: number;
  20097. DETAIL: boolean;
  20098. DETAILDIRECTUV: number;
  20099. DETAIL_NORMALBLENDMETHOD: number;
  20100. AMBIENT: boolean;
  20101. AMBIENTDIRECTUV: number;
  20102. OPACITY: boolean;
  20103. OPACITYDIRECTUV: number;
  20104. OPACITYRGB: boolean;
  20105. REFLECTION: boolean;
  20106. EMISSIVE: boolean;
  20107. EMISSIVEDIRECTUV: number;
  20108. SPECULAR: boolean;
  20109. SPECULARDIRECTUV: number;
  20110. BUMP: boolean;
  20111. BUMPDIRECTUV: number;
  20112. PARALLAX: boolean;
  20113. PARALLAXOCCLUSION: boolean;
  20114. SPECULAROVERALPHA: boolean;
  20115. CLIPPLANE: boolean;
  20116. CLIPPLANE2: boolean;
  20117. CLIPPLANE3: boolean;
  20118. CLIPPLANE4: boolean;
  20119. CLIPPLANE5: boolean;
  20120. CLIPPLANE6: boolean;
  20121. ALPHATEST: boolean;
  20122. DEPTHPREPASS: boolean;
  20123. ALPHAFROMDIFFUSE: boolean;
  20124. POINTSIZE: boolean;
  20125. FOG: boolean;
  20126. SPECULARTERM: boolean;
  20127. DIFFUSEFRESNEL: boolean;
  20128. OPACITYFRESNEL: boolean;
  20129. REFLECTIONFRESNEL: boolean;
  20130. REFRACTIONFRESNEL: boolean;
  20131. EMISSIVEFRESNEL: boolean;
  20132. FRESNEL: boolean;
  20133. NORMAL: boolean;
  20134. UV1: boolean;
  20135. UV2: boolean;
  20136. VERTEXCOLOR: boolean;
  20137. VERTEXALPHA: boolean;
  20138. NUM_BONE_INFLUENCERS: number;
  20139. BonesPerMesh: number;
  20140. BONETEXTURE: boolean;
  20141. BONES_VELOCITY_ENABLED: boolean;
  20142. INSTANCES: boolean;
  20143. THIN_INSTANCES: boolean;
  20144. GLOSSINESS: boolean;
  20145. ROUGHNESS: boolean;
  20146. EMISSIVEASILLUMINATION: boolean;
  20147. LINKEMISSIVEWITHDIFFUSE: boolean;
  20148. REFLECTIONFRESNELFROMSPECULAR: boolean;
  20149. LIGHTMAP: boolean;
  20150. LIGHTMAPDIRECTUV: number;
  20151. OBJECTSPACE_NORMALMAP: boolean;
  20152. USELIGHTMAPASSHADOWMAP: boolean;
  20153. REFLECTIONMAP_3D: boolean;
  20154. REFLECTIONMAP_SPHERICAL: boolean;
  20155. REFLECTIONMAP_PLANAR: boolean;
  20156. REFLECTIONMAP_CUBIC: boolean;
  20157. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20158. REFLECTIONMAP_PROJECTION: boolean;
  20159. REFLECTIONMAP_SKYBOX: boolean;
  20160. REFLECTIONMAP_EXPLICIT: boolean;
  20161. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20162. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20163. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20164. REFLECTIONMAP_OPPOSITEZ: boolean;
  20165. INVERTCUBICMAP: boolean;
  20166. LOGARITHMICDEPTH: boolean;
  20167. REFRACTION: boolean;
  20168. REFRACTIONMAP_3D: boolean;
  20169. REFLECTIONOVERALPHA: boolean;
  20170. TWOSIDEDLIGHTING: boolean;
  20171. SHADOWFLOAT: boolean;
  20172. MORPHTARGETS: boolean;
  20173. MORPHTARGETS_NORMAL: boolean;
  20174. MORPHTARGETS_TANGENT: boolean;
  20175. MORPHTARGETS_UV: boolean;
  20176. NUM_MORPH_INFLUENCERS: number;
  20177. MORPHTARGETS_TEXTURE: boolean;
  20178. NONUNIFORMSCALING: boolean;
  20179. PREMULTIPLYALPHA: boolean;
  20180. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  20181. ALPHABLEND: boolean;
  20182. PREPASS: boolean;
  20183. PREPASS_IRRADIANCE: boolean;
  20184. PREPASS_IRRADIANCE_INDEX: number;
  20185. PREPASS_ALBEDO: boolean;
  20186. PREPASS_ALBEDO_INDEX: number;
  20187. PREPASS_DEPTH: boolean;
  20188. PREPASS_DEPTH_INDEX: number;
  20189. PREPASS_NORMAL: boolean;
  20190. PREPASS_NORMAL_INDEX: number;
  20191. PREPASS_POSITION: boolean;
  20192. PREPASS_POSITION_INDEX: number;
  20193. PREPASS_VELOCITY: boolean;
  20194. PREPASS_VELOCITY_INDEX: number;
  20195. PREPASS_REFLECTIVITY: boolean;
  20196. PREPASS_REFLECTIVITY_INDEX: number;
  20197. SCENE_MRT_COUNT: number;
  20198. RGBDLIGHTMAP: boolean;
  20199. RGBDREFLECTION: boolean;
  20200. RGBDREFRACTION: boolean;
  20201. IMAGEPROCESSING: boolean;
  20202. VIGNETTE: boolean;
  20203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20204. VIGNETTEBLENDMODEOPAQUE: boolean;
  20205. TONEMAPPING: boolean;
  20206. TONEMAPPING_ACES: boolean;
  20207. CONTRAST: boolean;
  20208. COLORCURVES: boolean;
  20209. COLORGRADING: boolean;
  20210. COLORGRADING3D: boolean;
  20211. SAMPLER3DGREENDEPTH: boolean;
  20212. SAMPLER3DBGRMAP: boolean;
  20213. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20214. MULTIVIEW: boolean;
  20215. /**
  20216. * If the reflection texture on this material is in linear color space
  20217. * @hidden
  20218. */
  20219. IS_REFLECTION_LINEAR: boolean;
  20220. /**
  20221. * If the refraction texture on this material is in linear color space
  20222. * @hidden
  20223. */
  20224. IS_REFRACTION_LINEAR: boolean;
  20225. EXPOSURE: boolean;
  20226. constructor();
  20227. setReflectionMode(modeToEnable: string): void;
  20228. }
  20229. /**
  20230. * This is the default material used in Babylon. It is the best trade off between quality
  20231. * and performances.
  20232. * @see https://doc.babylonjs.com/babylon101/materials
  20233. */
  20234. export class StandardMaterial extends PushMaterial {
  20235. private _diffuseTexture;
  20236. /**
  20237. * The basic texture of the material as viewed under a light.
  20238. */
  20239. diffuseTexture: Nullable<BaseTexture>;
  20240. private _ambientTexture;
  20241. /**
  20242. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  20243. */
  20244. ambientTexture: Nullable<BaseTexture>;
  20245. private _opacityTexture;
  20246. /**
  20247. * Define the transparency of the material from a texture.
  20248. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  20249. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  20250. */
  20251. opacityTexture: Nullable<BaseTexture>;
  20252. private _reflectionTexture;
  20253. /**
  20254. * Define the texture used to display the reflection.
  20255. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20256. */
  20257. reflectionTexture: Nullable<BaseTexture>;
  20258. private _emissiveTexture;
  20259. /**
  20260. * Define texture of the material as if self lit.
  20261. * This will be mixed in the final result even in the absence of light.
  20262. */
  20263. emissiveTexture: Nullable<BaseTexture>;
  20264. private _specularTexture;
  20265. /**
  20266. * Define how the color and intensity of the highlight given by the light in the material.
  20267. */
  20268. specularTexture: Nullable<BaseTexture>;
  20269. private _bumpTexture;
  20270. /**
  20271. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  20272. * 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.
  20273. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  20274. */
  20275. bumpTexture: Nullable<BaseTexture>;
  20276. private _lightmapTexture;
  20277. /**
  20278. * Complex lighting can be computationally expensive to compute at runtime.
  20279. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  20280. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  20281. */
  20282. lightmapTexture: Nullable<BaseTexture>;
  20283. private _refractionTexture;
  20284. /**
  20285. * Define the texture used to display the refraction.
  20286. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20287. */
  20288. refractionTexture: Nullable<BaseTexture>;
  20289. /**
  20290. * The color of the material lit by the environmental background lighting.
  20291. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  20292. */
  20293. ambientColor: Color3;
  20294. /**
  20295. * The basic color of the material as viewed under a light.
  20296. */
  20297. diffuseColor: Color3;
  20298. /**
  20299. * Define how the color and intensity of the highlight given by the light in the material.
  20300. */
  20301. specularColor: Color3;
  20302. /**
  20303. * Define the color of the material as if self lit.
  20304. * This will be mixed in the final result even in the absence of light.
  20305. */
  20306. emissiveColor: Color3;
  20307. /**
  20308. * Defines how sharp are the highlights in the material.
  20309. * The bigger the value the sharper giving a more glossy feeling to the result.
  20310. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  20311. */
  20312. specularPower: number;
  20313. private _useAlphaFromDiffuseTexture;
  20314. /**
  20315. * Does the transparency come from the diffuse texture alpha channel.
  20316. */
  20317. useAlphaFromDiffuseTexture: boolean;
  20318. private _useEmissiveAsIllumination;
  20319. /**
  20320. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  20321. */
  20322. useEmissiveAsIllumination: boolean;
  20323. private _linkEmissiveWithDiffuse;
  20324. /**
  20325. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  20326. * the emissive level when the final color is close to one.
  20327. */
  20328. linkEmissiveWithDiffuse: boolean;
  20329. private _useSpecularOverAlpha;
  20330. /**
  20331. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  20332. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  20333. */
  20334. useSpecularOverAlpha: boolean;
  20335. private _useReflectionOverAlpha;
  20336. /**
  20337. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  20338. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  20339. */
  20340. useReflectionOverAlpha: boolean;
  20341. private _disableLighting;
  20342. /**
  20343. * Does lights from the scene impacts this material.
  20344. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  20345. */
  20346. disableLighting: boolean;
  20347. private _useObjectSpaceNormalMap;
  20348. /**
  20349. * Allows using an object space normal map (instead of tangent space).
  20350. */
  20351. useObjectSpaceNormalMap: boolean;
  20352. private _useParallax;
  20353. /**
  20354. * Is parallax enabled or not.
  20355. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20356. */
  20357. useParallax: boolean;
  20358. private _useParallaxOcclusion;
  20359. /**
  20360. * Is parallax occlusion enabled or not.
  20361. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  20362. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20363. */
  20364. useParallaxOcclusion: boolean;
  20365. /**
  20366. * 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.
  20367. */
  20368. parallaxScaleBias: number;
  20369. private _roughness;
  20370. /**
  20371. * Helps to define how blurry the reflections should appears in the material.
  20372. */
  20373. roughness: number;
  20374. /**
  20375. * In case of refraction, define the value of the index of refraction.
  20376. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20377. */
  20378. indexOfRefraction: number;
  20379. /**
  20380. * Invert the refraction texture alongside the y axis.
  20381. * It can be useful with procedural textures or probe for instance.
  20382. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20383. */
  20384. invertRefractionY: boolean;
  20385. /**
  20386. * Defines the alpha limits in alpha test mode.
  20387. */
  20388. alphaCutOff: number;
  20389. private _useLightmapAsShadowmap;
  20390. /**
  20391. * In case of light mapping, define whether the map contains light or shadow informations.
  20392. */
  20393. useLightmapAsShadowmap: boolean;
  20394. private _diffuseFresnelParameters;
  20395. /**
  20396. * Define the diffuse fresnel parameters of the material.
  20397. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20398. */
  20399. diffuseFresnelParameters: FresnelParameters;
  20400. private _opacityFresnelParameters;
  20401. /**
  20402. * Define the opacity fresnel parameters of the material.
  20403. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20404. */
  20405. opacityFresnelParameters: FresnelParameters;
  20406. private _reflectionFresnelParameters;
  20407. /**
  20408. * Define the reflection fresnel parameters of the material.
  20409. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20410. */
  20411. reflectionFresnelParameters: FresnelParameters;
  20412. private _refractionFresnelParameters;
  20413. /**
  20414. * Define the refraction fresnel parameters of the material.
  20415. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20416. */
  20417. refractionFresnelParameters: FresnelParameters;
  20418. private _emissiveFresnelParameters;
  20419. /**
  20420. * Define the emissive fresnel parameters of the material.
  20421. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20422. */
  20423. emissiveFresnelParameters: FresnelParameters;
  20424. private _useReflectionFresnelFromSpecular;
  20425. /**
  20426. * If true automatically deducts the fresnels values from the material specularity.
  20427. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20428. */
  20429. useReflectionFresnelFromSpecular: boolean;
  20430. private _useGlossinessFromSpecularMapAlpha;
  20431. /**
  20432. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  20433. */
  20434. useGlossinessFromSpecularMapAlpha: boolean;
  20435. private _maxSimultaneousLights;
  20436. /**
  20437. * Defines the maximum number of lights that can be used in the material
  20438. */
  20439. maxSimultaneousLights: number;
  20440. private _invertNormalMapX;
  20441. /**
  20442. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20443. */
  20444. invertNormalMapX: boolean;
  20445. private _invertNormalMapY;
  20446. /**
  20447. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20448. */
  20449. invertNormalMapY: boolean;
  20450. private _twoSidedLighting;
  20451. /**
  20452. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20453. */
  20454. twoSidedLighting: boolean;
  20455. /**
  20456. * Default configuration related to image processing available in the standard Material.
  20457. */
  20458. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20459. /**
  20460. * Gets the image processing configuration used either in this material.
  20461. */
  20462. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  20463. /**
  20464. * Sets the Default image processing configuration used either in the this material.
  20465. *
  20466. * If sets to null, the scene one is in use.
  20467. */
  20468. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  20469. /**
  20470. * Keep track of the image processing observer to allow dispose and replace.
  20471. */
  20472. private _imageProcessingObserver;
  20473. /**
  20474. * Attaches a new image processing configuration to the Standard Material.
  20475. * @param configuration
  20476. */
  20477. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20478. /**
  20479. * Defines additional PrePass parameters for the material.
  20480. */
  20481. readonly prePassConfiguration: PrePassConfiguration;
  20482. /**
  20483. * Can this material render to prepass
  20484. */
  20485. get isPrePassCapable(): boolean;
  20486. /**
  20487. * Gets whether the color curves effect is enabled.
  20488. */
  20489. get cameraColorCurvesEnabled(): boolean;
  20490. /**
  20491. * Sets whether the color curves effect is enabled.
  20492. */
  20493. set cameraColorCurvesEnabled(value: boolean);
  20494. /**
  20495. * Gets whether the color grading effect is enabled.
  20496. */
  20497. get cameraColorGradingEnabled(): boolean;
  20498. /**
  20499. * Gets whether the color grading effect is enabled.
  20500. */
  20501. set cameraColorGradingEnabled(value: boolean);
  20502. /**
  20503. * Gets whether tonemapping is enabled or not.
  20504. */
  20505. get cameraToneMappingEnabled(): boolean;
  20506. /**
  20507. * Sets whether tonemapping is enabled or not
  20508. */
  20509. set cameraToneMappingEnabled(value: boolean);
  20510. /**
  20511. * The camera exposure used on this material.
  20512. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20513. * This corresponds to a photographic exposure.
  20514. */
  20515. get cameraExposure(): number;
  20516. /**
  20517. * The camera exposure used on this material.
  20518. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20519. * This corresponds to a photographic exposure.
  20520. */
  20521. set cameraExposure(value: number);
  20522. /**
  20523. * Gets The camera contrast used on this material.
  20524. */
  20525. get cameraContrast(): number;
  20526. /**
  20527. * Sets The camera contrast used on this material.
  20528. */
  20529. set cameraContrast(value: number);
  20530. /**
  20531. * Gets the Color Grading 2D Lookup Texture.
  20532. */
  20533. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  20534. /**
  20535. * Sets the Color Grading 2D Lookup Texture.
  20536. */
  20537. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  20538. /**
  20539. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20540. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20541. * 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;
  20542. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20543. */
  20544. get cameraColorCurves(): Nullable<ColorCurves>;
  20545. /**
  20546. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  20547. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20548. * 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;
  20549. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20550. */
  20551. set cameraColorCurves(value: Nullable<ColorCurves>);
  20552. /**
  20553. * Can this material render to several textures at once
  20554. */
  20555. get canRenderToMRT(): boolean;
  20556. /**
  20557. * Defines the detail map parameters for the material.
  20558. */
  20559. readonly detailMap: DetailMapConfiguration;
  20560. protected _renderTargets: SmartArray<RenderTargetTexture>;
  20561. protected _worldViewProjectionMatrix: Matrix;
  20562. protected _globalAmbientColor: Color3;
  20563. protected _useLogarithmicDepth: boolean;
  20564. protected _rebuildInParallel: boolean;
  20565. /**
  20566. * Instantiates a new standard material.
  20567. * This is the default material used in Babylon. It is the best trade off between quality
  20568. * and performances.
  20569. * @see https://doc.babylonjs.com/babylon101/materials
  20570. * @param name Define the name of the material in the scene
  20571. * @param scene Define the scene the material belong to
  20572. */
  20573. constructor(name: string, scene: Scene);
  20574. /**
  20575. * Gets a boolean indicating that current material needs to register RTT
  20576. */
  20577. get hasRenderTargetTextures(): boolean;
  20578. /**
  20579. * Gets the current class name of the material e.g. "StandardMaterial"
  20580. * Mainly use in serialization.
  20581. * @returns the class name
  20582. */
  20583. getClassName(): string;
  20584. /**
  20585. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  20586. * You can try switching to logarithmic depth.
  20587. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  20588. */
  20589. get useLogarithmicDepth(): boolean;
  20590. set useLogarithmicDepth(value: boolean);
  20591. /**
  20592. * Specifies if the material will require alpha blending
  20593. * @returns a boolean specifying if alpha blending is needed
  20594. */
  20595. needAlphaBlending(): boolean;
  20596. /**
  20597. * Specifies if this material should be rendered in alpha test mode
  20598. * @returns a boolean specifying if an alpha test is needed.
  20599. */
  20600. needAlphaTesting(): boolean;
  20601. /**
  20602. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  20603. */
  20604. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  20605. /**
  20606. * Specifies whether or not there is a usable alpha channel for transparency.
  20607. */
  20608. protected _hasAlphaChannel(): boolean;
  20609. /**
  20610. * Get the texture used for alpha test purpose.
  20611. * @returns the diffuse texture in case of the standard material.
  20612. */
  20613. getAlphaTestTexture(): Nullable<BaseTexture>;
  20614. /**
  20615. * Get if the submesh is ready to be used and all its information available.
  20616. * Child classes can use it to update shaders
  20617. * @param mesh defines the mesh to check
  20618. * @param subMesh defines which submesh to check
  20619. * @param useInstances specifies that instances should be used
  20620. * @returns a boolean indicating that the submesh is ready or not
  20621. */
  20622. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20623. /**
  20624. * Builds the material UBO layouts.
  20625. * Used internally during the effect preparation.
  20626. */
  20627. buildUniformLayout(): void;
  20628. /**
  20629. * Unbinds the material from the mesh
  20630. */
  20631. unbind(): void;
  20632. /**
  20633. * Binds the submesh to this material by preparing the effect and shader to draw
  20634. * @param world defines the world transformation matrix
  20635. * @param mesh defines the mesh containing the submesh
  20636. * @param subMesh defines the submesh to bind the material to
  20637. */
  20638. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20639. /**
  20640. * Get the list of animatables in the material.
  20641. * @returns the list of animatables object used in the material
  20642. */
  20643. getAnimatables(): IAnimatable[];
  20644. /**
  20645. * Gets the active textures from the material
  20646. * @returns an array of textures
  20647. */
  20648. getActiveTextures(): BaseTexture[];
  20649. /**
  20650. * Specifies if the material uses a texture
  20651. * @param texture defines the texture to check against the material
  20652. * @returns a boolean specifying if the material uses the texture
  20653. */
  20654. hasTexture(texture: BaseTexture): boolean;
  20655. /**
  20656. * Disposes the material
  20657. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20658. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20659. */
  20660. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20661. /**
  20662. * Makes a duplicate of the material, and gives it a new name
  20663. * @param name defines the new name for the duplicated material
  20664. * @returns the cloned material
  20665. */
  20666. clone(name: string): StandardMaterial;
  20667. /**
  20668. * Serializes this material in a JSON representation
  20669. * @returns the serialized material object
  20670. */
  20671. serialize(): any;
  20672. /**
  20673. * Creates a standard material from parsed material data
  20674. * @param source defines the JSON representation of the material
  20675. * @param scene defines the hosting scene
  20676. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20677. * @returns a new standard material
  20678. */
  20679. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20680. /**
  20681. * Are diffuse textures enabled in the application.
  20682. */
  20683. static get DiffuseTextureEnabled(): boolean;
  20684. static set DiffuseTextureEnabled(value: boolean);
  20685. /**
  20686. * Are detail textures enabled in the application.
  20687. */
  20688. static get DetailTextureEnabled(): boolean;
  20689. static set DetailTextureEnabled(value: boolean);
  20690. /**
  20691. * Are ambient textures enabled in the application.
  20692. */
  20693. static get AmbientTextureEnabled(): boolean;
  20694. static set AmbientTextureEnabled(value: boolean);
  20695. /**
  20696. * Are opacity textures enabled in the application.
  20697. */
  20698. static get OpacityTextureEnabled(): boolean;
  20699. static set OpacityTextureEnabled(value: boolean);
  20700. /**
  20701. * Are reflection textures enabled in the application.
  20702. */
  20703. static get ReflectionTextureEnabled(): boolean;
  20704. static set ReflectionTextureEnabled(value: boolean);
  20705. /**
  20706. * Are emissive textures enabled in the application.
  20707. */
  20708. static get EmissiveTextureEnabled(): boolean;
  20709. static set EmissiveTextureEnabled(value: boolean);
  20710. /**
  20711. * Are specular textures enabled in the application.
  20712. */
  20713. static get SpecularTextureEnabled(): boolean;
  20714. static set SpecularTextureEnabled(value: boolean);
  20715. /**
  20716. * Are bump textures enabled in the application.
  20717. */
  20718. static get BumpTextureEnabled(): boolean;
  20719. static set BumpTextureEnabled(value: boolean);
  20720. /**
  20721. * Are lightmap textures enabled in the application.
  20722. */
  20723. static get LightmapTextureEnabled(): boolean;
  20724. static set LightmapTextureEnabled(value: boolean);
  20725. /**
  20726. * Are refraction textures enabled in the application.
  20727. */
  20728. static get RefractionTextureEnabled(): boolean;
  20729. static set RefractionTextureEnabled(value: boolean);
  20730. /**
  20731. * Are color grading textures enabled in the application.
  20732. */
  20733. static get ColorGradingTextureEnabled(): boolean;
  20734. static set ColorGradingTextureEnabled(value: boolean);
  20735. /**
  20736. * Are fresnels enabled in the application.
  20737. */
  20738. static get FresnelEnabled(): boolean;
  20739. static set FresnelEnabled(value: boolean);
  20740. }
  20741. }
  20742. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  20743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20744. /** @hidden */
  20745. export var rgbdDecodePixelShader: {
  20746. name: string;
  20747. shader: string;
  20748. };
  20749. }
  20750. declare module "babylonjs/Shaders/pass.fragment" {
  20751. /** @hidden */
  20752. export var passPixelShader: {
  20753. name: string;
  20754. shader: string;
  20755. };
  20756. }
  20757. declare module "babylonjs/Shaders/passCube.fragment" {
  20758. /** @hidden */
  20759. export var passCubePixelShader: {
  20760. name: string;
  20761. shader: string;
  20762. };
  20763. }
  20764. declare module "babylonjs/PostProcesses/passPostProcess" {
  20765. import { Nullable } from "babylonjs/types";
  20766. import { Camera } from "babylonjs/Cameras/camera";
  20767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20768. import { Engine } from "babylonjs/Engines/engine";
  20769. import "babylonjs/Shaders/pass.fragment";
  20770. import "babylonjs/Shaders/passCube.fragment";
  20771. import { Scene } from "babylonjs/scene";
  20772. /**
  20773. * PassPostProcess which produces an output the same as it's input
  20774. */
  20775. export class PassPostProcess extends PostProcess {
  20776. /**
  20777. * Gets a string identifying the name of the class
  20778. * @returns "PassPostProcess" string
  20779. */
  20780. getClassName(): string;
  20781. /**
  20782. * Creates the PassPostProcess
  20783. * @param name The name of the effect.
  20784. * @param options The required width/height ratio to downsize to before computing the render pass.
  20785. * @param camera The camera to apply the render pass to.
  20786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20787. * @param engine The engine which the post process will be applied. (default: current engine)
  20788. * @param reusable If the post process can be reused on the same frame. (default: false)
  20789. * @param textureType The type of texture to be used when performing the post processing.
  20790. * @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)
  20791. */
  20792. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20793. /** @hidden */
  20794. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20795. }
  20796. /**
  20797. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20798. */
  20799. export class PassCubePostProcess extends PostProcess {
  20800. private _face;
  20801. /**
  20802. * Gets or sets the cube face to display.
  20803. * * 0 is +X
  20804. * * 1 is -X
  20805. * * 2 is +Y
  20806. * * 3 is -Y
  20807. * * 4 is +Z
  20808. * * 5 is -Z
  20809. */
  20810. get face(): number;
  20811. set face(value: number);
  20812. /**
  20813. * Gets a string identifying the name of the class
  20814. * @returns "PassCubePostProcess" string
  20815. */
  20816. getClassName(): string;
  20817. /**
  20818. * Creates the PassCubePostProcess
  20819. * @param name The name of the effect.
  20820. * @param options The required width/height ratio to downsize to before computing the render pass.
  20821. * @param camera The camera to apply the render pass to.
  20822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20823. * @param engine The engine which the post process will be applied. (default: current engine)
  20824. * @param reusable If the post process can be reused on the same frame. (default: false)
  20825. * @param textureType The type of texture to be used when performing the post processing.
  20826. * @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)
  20827. */
  20828. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20829. /** @hidden */
  20830. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20831. }
  20832. }
  20833. declare module "babylonjs/Misc/textureTools" {
  20834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20835. import { Texture } from "babylonjs/Materials/Textures/texture";
  20836. import { Scene } from "babylonjs/scene";
  20837. /**
  20838. * Class used to host texture specific utilities
  20839. */
  20840. export class TextureTools {
  20841. /**
  20842. * Uses the GPU to create a copy texture rescaled at a given size
  20843. * @param texture Texture to copy from
  20844. * @param width defines the desired width
  20845. * @param height defines the desired height
  20846. * @param useBilinearMode defines if bilinear mode has to be used
  20847. * @return the generated texture
  20848. */
  20849. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20850. /**
  20851. * Apply a post process to a texture
  20852. * @param postProcessName name of the fragment post process
  20853. * @param internalTexture the texture to encode
  20854. * @param scene the scene hosting the texture
  20855. * @param type type of the output texture. If not provided, use the one from internalTexture
  20856. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20857. * @param format format of the output texture. If not provided, use the one from internalTexture
  20858. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20859. */
  20860. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20861. }
  20862. }
  20863. declare module "babylonjs/Misc/rgbdTextureTools" {
  20864. import "babylonjs/Shaders/rgbdDecode.fragment";
  20865. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20866. import { Texture } from "babylonjs/Materials/Textures/texture";
  20867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20868. import { Scene } from "babylonjs/scene";
  20869. /**
  20870. * Class used to host RGBD texture specific utilities
  20871. */
  20872. export class RGBDTextureTools {
  20873. /**
  20874. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20875. * @param texture the texture to expand.
  20876. */
  20877. static ExpandRGBDTexture(texture: Texture): void;
  20878. /**
  20879. * Encode the texture to RGBD if possible.
  20880. * @param internalTexture the texture to encode
  20881. * @param scene the scene hosting the texture
  20882. * @param outputTextureType type of the texture in which the encoding is performed
  20883. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20884. */
  20885. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20886. }
  20887. }
  20888. declare module "babylonjs/Misc/brdfTextureTools" {
  20889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20890. import { Scene } from "babylonjs/scene";
  20891. /**
  20892. * Class used to host texture specific utilities
  20893. */
  20894. export class BRDFTextureTools {
  20895. /**
  20896. * Prevents texture cache collision
  20897. */
  20898. private static _instanceNumber;
  20899. /**
  20900. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20901. * @param scene defines the hosting scene
  20902. * @returns the environment BRDF texture
  20903. */
  20904. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20905. private static _environmentBRDFBase64Texture;
  20906. }
  20907. }
  20908. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  20909. import { Nullable } from "babylonjs/types";
  20910. import { Color3 } from "babylonjs/Maths/math.color";
  20911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20912. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20913. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20914. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20916. import { Engine } from "babylonjs/Engines/engine";
  20917. import { Scene } from "babylonjs/scene";
  20918. /**
  20919. * @hidden
  20920. */
  20921. export interface IMaterialClearCoatDefines {
  20922. CLEARCOAT: boolean;
  20923. CLEARCOAT_DEFAULTIOR: boolean;
  20924. CLEARCOAT_TEXTURE: boolean;
  20925. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20926. CLEARCOAT_TEXTUREDIRECTUV: number;
  20927. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20928. CLEARCOAT_BUMP: boolean;
  20929. CLEARCOAT_BUMPDIRECTUV: number;
  20930. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20931. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20932. CLEARCOAT_REMAP_F0: boolean;
  20933. CLEARCOAT_TINT: boolean;
  20934. CLEARCOAT_TINT_TEXTURE: boolean;
  20935. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20936. /** @hidden */
  20937. _areTexturesDirty: boolean;
  20938. }
  20939. /**
  20940. * Define the code related to the clear coat parameters of the pbr material.
  20941. */
  20942. export class PBRClearCoatConfiguration {
  20943. /**
  20944. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20945. * The default fits with a polyurethane material.
  20946. * @hidden
  20947. */
  20948. static readonly _DefaultIndexOfRefraction: number;
  20949. private _isEnabled;
  20950. /**
  20951. * Defines if the clear coat is enabled in the material.
  20952. */
  20953. isEnabled: boolean;
  20954. /**
  20955. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20956. */
  20957. intensity: number;
  20958. /**
  20959. * Defines the clear coat layer roughness.
  20960. */
  20961. roughness: number;
  20962. private _indexOfRefraction;
  20963. /**
  20964. * Defines the index of refraction of the clear coat.
  20965. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20966. * The default fits with a polyurethane material.
  20967. * Changing the default value is more performance intensive.
  20968. */
  20969. indexOfRefraction: number;
  20970. private _texture;
  20971. /**
  20972. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20973. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20974. * if textureRoughness is not empty, else no texture roughness is used
  20975. */
  20976. texture: Nullable<BaseTexture>;
  20977. private _useRoughnessFromMainTexture;
  20978. /**
  20979. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20980. * If false, the green channel from textureRoughness is used for roughness
  20981. */
  20982. useRoughnessFromMainTexture: boolean;
  20983. private _textureRoughness;
  20984. /**
  20985. * Stores the clear coat roughness in a texture (green channel)
  20986. * Not used if useRoughnessFromMainTexture is true
  20987. */
  20988. textureRoughness: Nullable<BaseTexture>;
  20989. private _remapF0OnInterfaceChange;
  20990. /**
  20991. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20992. */
  20993. remapF0OnInterfaceChange: boolean;
  20994. private _bumpTexture;
  20995. /**
  20996. * Define the clear coat specific bump texture.
  20997. */
  20998. bumpTexture: Nullable<BaseTexture>;
  20999. private _isTintEnabled;
  21000. /**
  21001. * Defines if the clear coat tint is enabled in the material.
  21002. */
  21003. isTintEnabled: boolean;
  21004. /**
  21005. * Defines the clear coat tint of the material.
  21006. * This is only use if tint is enabled
  21007. */
  21008. tintColor: Color3;
  21009. /**
  21010. * Defines the distance at which the tint color should be found in the
  21011. * clear coat media.
  21012. * This is only use if tint is enabled
  21013. */
  21014. tintColorAtDistance: number;
  21015. /**
  21016. * Defines the clear coat layer thickness.
  21017. * This is only use if tint is enabled
  21018. */
  21019. tintThickness: number;
  21020. private _tintTexture;
  21021. /**
  21022. * Stores the clear tint values in a texture.
  21023. * rgb is tint
  21024. * a is a thickness factor
  21025. */
  21026. tintTexture: Nullable<BaseTexture>;
  21027. /** @hidden */
  21028. private _internalMarkAllSubMeshesAsTexturesDirty;
  21029. /** @hidden */
  21030. _markAllSubMeshesAsTexturesDirty(): void;
  21031. /**
  21032. * Instantiate a new instance of clear coat configuration.
  21033. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21034. */
  21035. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21036. /**
  21037. * Gets whether the submesh is ready to be used or not.
  21038. * @param defines the list of "defines" to update.
  21039. * @param scene defines the scene the material belongs to.
  21040. * @param engine defines the engine the material belongs to.
  21041. * @param disableBumpMap defines whether the material disables bump or not.
  21042. * @returns - boolean indicating that the submesh is ready or not.
  21043. */
  21044. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  21045. /**
  21046. * Checks to see if a texture is used in the material.
  21047. * @param defines the list of "defines" to update.
  21048. * @param scene defines the scene to the material belongs to.
  21049. */
  21050. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  21051. /**
  21052. * Binds the material data.
  21053. * @param uniformBuffer defines the Uniform buffer to fill in.
  21054. * @param scene defines the scene the material belongs to.
  21055. * @param engine defines the engine the material belongs to.
  21056. * @param disableBumpMap defines whether the material disables bump or not.
  21057. * @param isFrozen defines whether the material is frozen or not.
  21058. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21059. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21060. * @param subMesh the submesh to bind data for
  21061. */
  21062. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  21063. /**
  21064. * Checks to see if a texture is used in the material.
  21065. * @param texture - Base texture to use.
  21066. * @returns - Boolean specifying if a texture is used in the material.
  21067. */
  21068. hasTexture(texture: BaseTexture): boolean;
  21069. /**
  21070. * Returns an array of the actively used textures.
  21071. * @param activeTextures Array of BaseTextures
  21072. */
  21073. getActiveTextures(activeTextures: BaseTexture[]): void;
  21074. /**
  21075. * Returns the animatable textures.
  21076. * @param animatables Array of animatable textures.
  21077. */
  21078. getAnimatables(animatables: IAnimatable[]): void;
  21079. /**
  21080. * Disposes the resources of the material.
  21081. * @param forceDisposeTextures - Forces the disposal of all textures.
  21082. */
  21083. dispose(forceDisposeTextures?: boolean): void;
  21084. /**
  21085. * Get the current class name of the texture useful for serialization or dynamic coding.
  21086. * @returns "PBRClearCoatConfiguration"
  21087. */
  21088. getClassName(): string;
  21089. /**
  21090. * Add fallbacks to the effect fallbacks list.
  21091. * @param defines defines the Base texture to use.
  21092. * @param fallbacks defines the current fallback list.
  21093. * @param currentRank defines the current fallback rank.
  21094. * @returns the new fallback rank.
  21095. */
  21096. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21097. /**
  21098. * Add the required uniforms to the current list.
  21099. * @param uniforms defines the current uniform list.
  21100. */
  21101. static AddUniforms(uniforms: string[]): void;
  21102. /**
  21103. * Add the required samplers to the current list.
  21104. * @param samplers defines the current sampler list.
  21105. */
  21106. static AddSamplers(samplers: string[]): void;
  21107. /**
  21108. * Add the required uniforms to the current buffer.
  21109. * @param uniformBuffer defines the current uniform buffer.
  21110. */
  21111. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21112. /**
  21113. * Makes a duplicate of the current configuration into another one.
  21114. * @param clearCoatConfiguration define the config where to copy the info
  21115. */
  21116. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  21117. /**
  21118. * Serializes this clear coat configuration.
  21119. * @returns - An object with the serialized config.
  21120. */
  21121. serialize(): any;
  21122. /**
  21123. * Parses a anisotropy Configuration from a serialized object.
  21124. * @param source - Serialized object.
  21125. * @param scene Defines the scene we are parsing for
  21126. * @param rootUrl Defines the rootUrl to load from
  21127. */
  21128. parse(source: any, scene: Scene, rootUrl: string): void;
  21129. }
  21130. }
  21131. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  21132. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21134. import { Vector2 } from "babylonjs/Maths/math.vector";
  21135. import { Scene } from "babylonjs/scene";
  21136. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21137. import { Nullable } from "babylonjs/types";
  21138. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21139. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21140. /**
  21141. * @hidden
  21142. */
  21143. export interface IMaterialAnisotropicDefines {
  21144. ANISOTROPIC: boolean;
  21145. ANISOTROPIC_TEXTURE: boolean;
  21146. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21147. MAINUV1: boolean;
  21148. _areTexturesDirty: boolean;
  21149. _needUVs: boolean;
  21150. }
  21151. /**
  21152. * Define the code related to the anisotropic parameters of the pbr material.
  21153. */
  21154. export class PBRAnisotropicConfiguration {
  21155. private _isEnabled;
  21156. /**
  21157. * Defines if the anisotropy is enabled in the material.
  21158. */
  21159. isEnabled: boolean;
  21160. /**
  21161. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  21162. */
  21163. intensity: number;
  21164. /**
  21165. * Defines if the effect is along the tangents, bitangents or in between.
  21166. * By default, the effect is "stretching" the highlights along the tangents.
  21167. */
  21168. direction: Vector2;
  21169. private _texture;
  21170. /**
  21171. * Stores the anisotropy values in a texture.
  21172. * rg is direction (like normal from -1 to 1)
  21173. * b is a intensity
  21174. */
  21175. texture: Nullable<BaseTexture>;
  21176. /** @hidden */
  21177. private _internalMarkAllSubMeshesAsTexturesDirty;
  21178. /** @hidden */
  21179. _markAllSubMeshesAsTexturesDirty(): void;
  21180. /**
  21181. * Instantiate a new instance of anisotropy configuration.
  21182. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21183. */
  21184. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21185. /**
  21186. * Specifies that the submesh is ready to be used.
  21187. * @param defines the list of "defines" to update.
  21188. * @param scene defines the scene the material belongs to.
  21189. * @returns - boolean indicating that the submesh is ready or not.
  21190. */
  21191. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  21192. /**
  21193. * Checks to see if a texture is used in the material.
  21194. * @param defines the list of "defines" to update.
  21195. * @param mesh the mesh we are preparing the defines for.
  21196. * @param scene defines the scene the material belongs to.
  21197. */
  21198. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  21199. /**
  21200. * Binds the material data.
  21201. * @param uniformBuffer defines the Uniform buffer to fill in.
  21202. * @param scene defines the scene the material belongs to.
  21203. * @param isFrozen defines whether the material is frozen or not.
  21204. */
  21205. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  21206. /**
  21207. * Checks to see if a texture is used in the material.
  21208. * @param texture - Base texture to use.
  21209. * @returns - Boolean specifying if a texture is used in the material.
  21210. */
  21211. hasTexture(texture: BaseTexture): boolean;
  21212. /**
  21213. * Returns an array of the actively used textures.
  21214. * @param activeTextures Array of BaseTextures
  21215. */
  21216. getActiveTextures(activeTextures: BaseTexture[]): void;
  21217. /**
  21218. * Returns the animatable textures.
  21219. * @param animatables Array of animatable textures.
  21220. */
  21221. getAnimatables(animatables: IAnimatable[]): void;
  21222. /**
  21223. * Disposes the resources of the material.
  21224. * @param forceDisposeTextures - Forces the disposal of all textures.
  21225. */
  21226. dispose(forceDisposeTextures?: boolean): void;
  21227. /**
  21228. * Get the current class name of the texture useful for serialization or dynamic coding.
  21229. * @returns "PBRAnisotropicConfiguration"
  21230. */
  21231. getClassName(): string;
  21232. /**
  21233. * Add fallbacks to the effect fallbacks list.
  21234. * @param defines defines the Base texture to use.
  21235. * @param fallbacks defines the current fallback list.
  21236. * @param currentRank defines the current fallback rank.
  21237. * @returns the new fallback rank.
  21238. */
  21239. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21240. /**
  21241. * Add the required uniforms to the current list.
  21242. * @param uniforms defines the current uniform list.
  21243. */
  21244. static AddUniforms(uniforms: string[]): void;
  21245. /**
  21246. * Add the required uniforms to the current buffer.
  21247. * @param uniformBuffer defines the current uniform buffer.
  21248. */
  21249. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21250. /**
  21251. * Add the required samplers to the current list.
  21252. * @param samplers defines the current sampler list.
  21253. */
  21254. static AddSamplers(samplers: string[]): void;
  21255. /**
  21256. * Makes a duplicate of the current configuration into another one.
  21257. * @param anisotropicConfiguration define the config where to copy the info
  21258. */
  21259. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  21260. /**
  21261. * Serializes this anisotropy configuration.
  21262. * @returns - An object with the serialized config.
  21263. */
  21264. serialize(): any;
  21265. /**
  21266. * Parses a anisotropy Configuration from a serialized object.
  21267. * @param source - Serialized object.
  21268. * @param scene Defines the scene we are parsing for
  21269. * @param rootUrl Defines the rootUrl to load from
  21270. */
  21271. parse(source: any, scene: Scene, rootUrl: string): void;
  21272. }
  21273. }
  21274. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  21275. import { Scene } from "babylonjs/scene";
  21276. /**
  21277. * @hidden
  21278. */
  21279. export interface IMaterialBRDFDefines {
  21280. BRDF_V_HEIGHT_CORRELATED: boolean;
  21281. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21282. SPHERICAL_HARMONICS: boolean;
  21283. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21284. /** @hidden */
  21285. _areMiscDirty: boolean;
  21286. }
  21287. /**
  21288. * Define the code related to the BRDF parameters of the pbr material.
  21289. */
  21290. export class PBRBRDFConfiguration {
  21291. /**
  21292. * Default value used for the energy conservation.
  21293. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21294. */
  21295. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  21296. /**
  21297. * Default value used for the Smith Visibility Height Correlated mode.
  21298. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21299. */
  21300. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  21301. /**
  21302. * Default value used for the IBL diffuse part.
  21303. * This can help switching back to the polynomials mode globally which is a tiny bit
  21304. * less GPU intensive at the drawback of a lower quality.
  21305. */
  21306. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  21307. /**
  21308. * Default value used for activating energy conservation for the specular workflow.
  21309. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21310. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21311. */
  21312. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  21313. private _useEnergyConservation;
  21314. /**
  21315. * Defines if the material uses energy conservation.
  21316. */
  21317. useEnergyConservation: boolean;
  21318. private _useSmithVisibilityHeightCorrelated;
  21319. /**
  21320. * LEGACY Mode set to false
  21321. * Defines if the material uses height smith correlated visibility term.
  21322. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  21323. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  21324. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  21325. * Not relying on height correlated will also disable energy conservation.
  21326. */
  21327. useSmithVisibilityHeightCorrelated: boolean;
  21328. private _useSphericalHarmonics;
  21329. /**
  21330. * LEGACY Mode set to false
  21331. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  21332. * diffuse part of the IBL.
  21333. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  21334. * to the ground truth.
  21335. */
  21336. useSphericalHarmonics: boolean;
  21337. private _useSpecularGlossinessInputEnergyConservation;
  21338. /**
  21339. * Defines if the material uses energy conservation, when the specular workflow is active.
  21340. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21341. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21342. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  21343. */
  21344. useSpecularGlossinessInputEnergyConservation: boolean;
  21345. /** @hidden */
  21346. private _internalMarkAllSubMeshesAsMiscDirty;
  21347. /** @hidden */
  21348. _markAllSubMeshesAsMiscDirty(): void;
  21349. /**
  21350. * Instantiate a new instance of clear coat configuration.
  21351. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  21352. */
  21353. constructor(markAllSubMeshesAsMiscDirty: () => void);
  21354. /**
  21355. * Checks to see if a texture is used in the material.
  21356. * @param defines the list of "defines" to update.
  21357. */
  21358. prepareDefines(defines: IMaterialBRDFDefines): void;
  21359. /**
  21360. * Get the current class name of the texture useful for serialization or dynamic coding.
  21361. * @returns "PBRClearCoatConfiguration"
  21362. */
  21363. getClassName(): string;
  21364. /**
  21365. * Makes a duplicate of the current configuration into another one.
  21366. * @param brdfConfiguration define the config where to copy the info
  21367. */
  21368. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  21369. /**
  21370. * Serializes this BRDF configuration.
  21371. * @returns - An object with the serialized config.
  21372. */
  21373. serialize(): any;
  21374. /**
  21375. * Parses a anisotropy Configuration from a serialized object.
  21376. * @param source - Serialized object.
  21377. * @param scene Defines the scene we are parsing for
  21378. * @param rootUrl Defines the rootUrl to load from
  21379. */
  21380. parse(source: any, scene: Scene, rootUrl: string): void;
  21381. }
  21382. }
  21383. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  21384. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21385. import { Color3 } from "babylonjs/Maths/math.color";
  21386. import { Scene } from "babylonjs/scene";
  21387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21388. import { Nullable } from "babylonjs/types";
  21389. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21390. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21391. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21392. /**
  21393. * @hidden
  21394. */
  21395. export interface IMaterialSheenDefines {
  21396. SHEEN: boolean;
  21397. SHEEN_TEXTURE: boolean;
  21398. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21399. SHEEN_TEXTUREDIRECTUV: number;
  21400. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21401. SHEEN_LINKWITHALBEDO: boolean;
  21402. SHEEN_ROUGHNESS: boolean;
  21403. SHEEN_ALBEDOSCALING: boolean;
  21404. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21405. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21406. /** @hidden */
  21407. _areTexturesDirty: boolean;
  21408. }
  21409. /**
  21410. * Define the code related to the Sheen parameters of the pbr material.
  21411. */
  21412. export class PBRSheenConfiguration {
  21413. private _isEnabled;
  21414. /**
  21415. * Defines if the material uses sheen.
  21416. */
  21417. isEnabled: boolean;
  21418. private _linkSheenWithAlbedo;
  21419. /**
  21420. * Defines if the sheen is linked to the sheen color.
  21421. */
  21422. linkSheenWithAlbedo: boolean;
  21423. /**
  21424. * Defines the sheen intensity.
  21425. */
  21426. intensity: number;
  21427. /**
  21428. * Defines the sheen color.
  21429. */
  21430. color: Color3;
  21431. private _texture;
  21432. /**
  21433. * Stores the sheen tint values in a texture.
  21434. * rgb is tint
  21435. * 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)
  21436. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  21437. */
  21438. texture: Nullable<BaseTexture>;
  21439. private _useRoughnessFromMainTexture;
  21440. /**
  21441. * Indicates that the alpha channel of the texture property will be used for roughness.
  21442. * Has no effect if the roughness (and texture!) property is not defined
  21443. */
  21444. useRoughnessFromMainTexture: boolean;
  21445. private _roughness;
  21446. /**
  21447. * Defines the sheen roughness.
  21448. * It is not taken into account if linkSheenWithAlbedo is true.
  21449. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  21450. */
  21451. roughness: Nullable<number>;
  21452. private _textureRoughness;
  21453. /**
  21454. * Stores the sheen roughness in a texture.
  21455. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  21456. */
  21457. textureRoughness: Nullable<BaseTexture>;
  21458. private _albedoScaling;
  21459. /**
  21460. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  21461. * It allows the strength of the sheen effect to not depend on the base color of the material,
  21462. * making it easier to setup and tweak the effect
  21463. */
  21464. albedoScaling: boolean;
  21465. /** @hidden */
  21466. private _internalMarkAllSubMeshesAsTexturesDirty;
  21467. /** @hidden */
  21468. _markAllSubMeshesAsTexturesDirty(): void;
  21469. /**
  21470. * Instantiate a new instance of clear coat configuration.
  21471. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21472. */
  21473. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21474. /**
  21475. * Specifies that the submesh is ready to be used.
  21476. * @param defines the list of "defines" to update.
  21477. * @param scene defines the scene the material belongs to.
  21478. * @returns - boolean indicating that the submesh is ready or not.
  21479. */
  21480. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  21481. /**
  21482. * Checks to see if a texture is used in the material.
  21483. * @param defines the list of "defines" to update.
  21484. * @param scene defines the scene the material belongs to.
  21485. */
  21486. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  21487. /**
  21488. * Binds the material data.
  21489. * @param uniformBuffer defines the Uniform buffer to fill in.
  21490. * @param scene defines the scene the material belongs to.
  21491. * @param isFrozen defines whether the material is frozen or not.
  21492. * @param subMesh the submesh to bind data for
  21493. */
  21494. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  21495. /**
  21496. * Checks to see if a texture is used in the material.
  21497. * @param texture - Base texture to use.
  21498. * @returns - Boolean specifying if a texture is used in the material.
  21499. */
  21500. hasTexture(texture: BaseTexture): boolean;
  21501. /**
  21502. * Returns an array of the actively used textures.
  21503. * @param activeTextures Array of BaseTextures
  21504. */
  21505. getActiveTextures(activeTextures: BaseTexture[]): void;
  21506. /**
  21507. * Returns the animatable textures.
  21508. * @param animatables Array of animatable textures.
  21509. */
  21510. getAnimatables(animatables: IAnimatable[]): void;
  21511. /**
  21512. * Disposes the resources of the material.
  21513. * @param forceDisposeTextures - Forces the disposal of all textures.
  21514. */
  21515. dispose(forceDisposeTextures?: boolean): void;
  21516. /**
  21517. * Get the current class name of the texture useful for serialization or dynamic coding.
  21518. * @returns "PBRSheenConfiguration"
  21519. */
  21520. getClassName(): string;
  21521. /**
  21522. * Add fallbacks to the effect fallbacks list.
  21523. * @param defines defines the Base texture to use.
  21524. * @param fallbacks defines the current fallback list.
  21525. * @param currentRank defines the current fallback rank.
  21526. * @returns the new fallback rank.
  21527. */
  21528. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21529. /**
  21530. * Add the required uniforms to the current list.
  21531. * @param uniforms defines the current uniform list.
  21532. */
  21533. static AddUniforms(uniforms: string[]): void;
  21534. /**
  21535. * Add the required uniforms to the current buffer.
  21536. * @param uniformBuffer defines the current uniform buffer.
  21537. */
  21538. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21539. /**
  21540. * Add the required samplers to the current list.
  21541. * @param samplers defines the current sampler list.
  21542. */
  21543. static AddSamplers(samplers: string[]): void;
  21544. /**
  21545. * Makes a duplicate of the current configuration into another one.
  21546. * @param sheenConfiguration define the config where to copy the info
  21547. */
  21548. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  21549. /**
  21550. * Serializes this BRDF configuration.
  21551. * @returns - An object with the serialized config.
  21552. */
  21553. serialize(): any;
  21554. /**
  21555. * Parses a anisotropy Configuration from a serialized object.
  21556. * @param source - Serialized object.
  21557. * @param scene Defines the scene we are parsing for
  21558. * @param rootUrl Defines the rootUrl to load from
  21559. */
  21560. parse(source: any, scene: Scene, rootUrl: string): void;
  21561. }
  21562. }
  21563. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  21564. import { Nullable } from "babylonjs/types";
  21565. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21566. import { Color3 } from "babylonjs/Maths/math.color";
  21567. import { SmartArray } from "babylonjs/Misc/smartArray";
  21568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21569. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21570. import { Effect } from "babylonjs/Materials/effect";
  21571. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21572. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21573. import { Engine } from "babylonjs/Engines/engine";
  21574. import { Scene } from "babylonjs/scene";
  21575. /**
  21576. * @hidden
  21577. */
  21578. export interface IMaterialSubSurfaceDefines {
  21579. SUBSURFACE: boolean;
  21580. SS_REFRACTION: boolean;
  21581. SS_TRANSLUCENCY: boolean;
  21582. SS_SCATTERING: boolean;
  21583. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21584. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21585. SS_REFRACTIONMAP_3D: boolean;
  21586. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21587. SS_LODINREFRACTIONALPHA: boolean;
  21588. SS_GAMMAREFRACTION: boolean;
  21589. SS_RGBDREFRACTION: boolean;
  21590. SS_LINEARSPECULARREFRACTION: boolean;
  21591. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21592. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21593. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21594. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21595. /** @hidden */
  21596. _areTexturesDirty: boolean;
  21597. }
  21598. /**
  21599. * Define the code related to the sub surface parameters of the pbr material.
  21600. */
  21601. export class PBRSubSurfaceConfiguration {
  21602. private _isRefractionEnabled;
  21603. /**
  21604. * Defines if the refraction is enabled in the material.
  21605. */
  21606. isRefractionEnabled: boolean;
  21607. private _isTranslucencyEnabled;
  21608. /**
  21609. * Defines if the translucency is enabled in the material.
  21610. */
  21611. isTranslucencyEnabled: boolean;
  21612. private _isScatteringEnabled;
  21613. /**
  21614. * Defines if the sub surface scattering is enabled in the material.
  21615. */
  21616. isScatteringEnabled: boolean;
  21617. private _scatteringDiffusionProfileIndex;
  21618. /**
  21619. * Diffusion profile for subsurface scattering.
  21620. * Useful for better scattering in the skins or foliages.
  21621. */
  21622. get scatteringDiffusionProfile(): Nullable<Color3>;
  21623. set scatteringDiffusionProfile(c: Nullable<Color3>);
  21624. /**
  21625. * Defines the refraction intensity of the material.
  21626. * The refraction when enabled replaces the Diffuse part of the material.
  21627. * The intensity helps transitioning between diffuse and refraction.
  21628. */
  21629. refractionIntensity: number;
  21630. /**
  21631. * Defines the translucency intensity of the material.
  21632. * When translucency has been enabled, this defines how much of the "translucency"
  21633. * is added to the diffuse part of the material.
  21634. */
  21635. translucencyIntensity: number;
  21636. /**
  21637. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  21638. */
  21639. useAlbedoToTintRefraction: boolean;
  21640. private _thicknessTexture;
  21641. /**
  21642. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  21643. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  21644. * 0 would mean minimumThickness
  21645. * 1 would mean maximumThickness
  21646. * The other channels might be use as a mask to vary the different effects intensity.
  21647. */
  21648. thicknessTexture: Nullable<BaseTexture>;
  21649. private _refractionTexture;
  21650. /**
  21651. * Defines the texture to use for refraction.
  21652. */
  21653. refractionTexture: Nullable<BaseTexture>;
  21654. private _indexOfRefraction;
  21655. /**
  21656. * Index of refraction of the material base layer.
  21657. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21658. *
  21659. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21660. *
  21661. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21662. */
  21663. indexOfRefraction: number;
  21664. private _volumeIndexOfRefraction;
  21665. /**
  21666. * Index of refraction of the material's volume.
  21667. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21668. *
  21669. * This ONLY impacts refraction. If not provided or given a non-valid value,
  21670. * the volume will use the same IOR as the surface.
  21671. */
  21672. get volumeIndexOfRefraction(): number;
  21673. set volumeIndexOfRefraction(value: number);
  21674. private _invertRefractionY;
  21675. /**
  21676. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21677. */
  21678. invertRefractionY: boolean;
  21679. private _linkRefractionWithTransparency;
  21680. /**
  21681. * This parameters will make the material used its opacity to control how much it is refracting against not.
  21682. * Materials half opaque for instance using refraction could benefit from this control.
  21683. */
  21684. linkRefractionWithTransparency: boolean;
  21685. /**
  21686. * Defines the minimum thickness stored in the thickness map.
  21687. * If no thickness map is defined, this value will be used to simulate thickness.
  21688. */
  21689. minimumThickness: number;
  21690. /**
  21691. * Defines the maximum thickness stored in the thickness map.
  21692. */
  21693. maximumThickness: number;
  21694. /**
  21695. * Defines the volume tint of the material.
  21696. * This is used for both translucency and scattering.
  21697. */
  21698. tintColor: Color3;
  21699. /**
  21700. * Defines the distance at which the tint color should be found in the media.
  21701. * This is used for refraction only.
  21702. */
  21703. tintColorAtDistance: number;
  21704. /**
  21705. * Defines how far each channel transmit through the media.
  21706. * It is defined as a color to simplify it selection.
  21707. */
  21708. diffusionDistance: Color3;
  21709. private _useMaskFromThicknessTexture;
  21710. /**
  21711. * Stores the intensity of the different subsurface effects in the thickness texture.
  21712. * * the green channel is the translucency intensity.
  21713. * * the blue channel is the scattering intensity.
  21714. * * the alpha channel is the refraction intensity.
  21715. */
  21716. useMaskFromThicknessTexture: boolean;
  21717. private _scene;
  21718. private _useMaskFromThicknessTextureGltf;
  21719. /**
  21720. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21721. * matches the channel-packing that is used by glTF.
  21722. * * the red channel is the transmission/translucency intensity.
  21723. * * the green channel is the thickness.
  21724. */
  21725. useMaskFromThicknessTextureGltf: boolean;
  21726. /** @hidden */
  21727. private _internalMarkAllSubMeshesAsTexturesDirty;
  21728. private _internalMarkScenePrePassDirty;
  21729. /** @hidden */
  21730. _markAllSubMeshesAsTexturesDirty(): void;
  21731. /** @hidden */
  21732. _markScenePrePassDirty(): void;
  21733. /**
  21734. * Instantiate a new instance of sub surface configuration.
  21735. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21736. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21737. * @param scene The scene
  21738. */
  21739. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21740. /**
  21741. * Gets whether the submesh is ready to be used or not.
  21742. * @param defines the list of "defines" to update.
  21743. * @param scene defines the scene the material belongs to.
  21744. * @returns - boolean indicating that the submesh is ready or not.
  21745. */
  21746. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21747. /**
  21748. * Checks to see if a texture is used in the material.
  21749. * @param defines the list of "defines" to update.
  21750. * @param scene defines the scene to the material belongs to.
  21751. */
  21752. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21753. /**
  21754. * Binds the material data.
  21755. * @param uniformBuffer defines the Uniform buffer to fill in.
  21756. * @param scene defines the scene the material belongs to.
  21757. * @param engine defines the engine the material belongs to.
  21758. * @param isFrozen defines whether the material is frozen or not.
  21759. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21760. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21761. */
  21762. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21763. /**
  21764. * Unbinds the material from the mesh.
  21765. * @param activeEffect defines the effect that should be unbound from.
  21766. * @returns true if unbound, otherwise false
  21767. */
  21768. unbind(activeEffect: Effect): boolean;
  21769. /**
  21770. * Returns the texture used for refraction or null if none is used.
  21771. * @param scene defines the scene the material belongs to.
  21772. * @returns - Refraction texture if present. If no refraction texture and refraction
  21773. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21774. */
  21775. private _getRefractionTexture;
  21776. /**
  21777. * Returns true if alpha blending should be disabled.
  21778. */
  21779. get disableAlphaBlending(): boolean;
  21780. /**
  21781. * Fills the list of render target textures.
  21782. * @param renderTargets the list of render targets to update
  21783. */
  21784. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21785. /**
  21786. * Checks to see if a texture is used in the material.
  21787. * @param texture - Base texture to use.
  21788. * @returns - Boolean specifying if a texture is used in the material.
  21789. */
  21790. hasTexture(texture: BaseTexture): boolean;
  21791. /**
  21792. * Gets a boolean indicating that current material needs to register RTT
  21793. * @returns true if this uses a render target otherwise false.
  21794. */
  21795. hasRenderTargetTextures(): boolean;
  21796. /**
  21797. * Returns an array of the actively used textures.
  21798. * @param activeTextures Array of BaseTextures
  21799. */
  21800. getActiveTextures(activeTextures: BaseTexture[]): void;
  21801. /**
  21802. * Returns the animatable textures.
  21803. * @param animatables Array of animatable textures.
  21804. */
  21805. getAnimatables(animatables: IAnimatable[]): void;
  21806. /**
  21807. * Disposes the resources of the material.
  21808. * @param forceDisposeTextures - Forces the disposal of all textures.
  21809. */
  21810. dispose(forceDisposeTextures?: boolean): void;
  21811. /**
  21812. * Get the current class name of the texture useful for serialization or dynamic coding.
  21813. * @returns "PBRSubSurfaceConfiguration"
  21814. */
  21815. getClassName(): string;
  21816. /**
  21817. * Add fallbacks to the effect fallbacks list.
  21818. * @param defines defines the Base texture to use.
  21819. * @param fallbacks defines the current fallback list.
  21820. * @param currentRank defines the current fallback rank.
  21821. * @returns the new fallback rank.
  21822. */
  21823. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21824. /**
  21825. * Add the required uniforms to the current list.
  21826. * @param uniforms defines the current uniform list.
  21827. */
  21828. static AddUniforms(uniforms: string[]): void;
  21829. /**
  21830. * Add the required samplers to the current list.
  21831. * @param samplers defines the current sampler list.
  21832. */
  21833. static AddSamplers(samplers: string[]): void;
  21834. /**
  21835. * Add the required uniforms to the current buffer.
  21836. * @param uniformBuffer defines the current uniform buffer.
  21837. */
  21838. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21839. /**
  21840. * Makes a duplicate of the current configuration into another one.
  21841. * @param configuration define the config where to copy the info
  21842. */
  21843. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21844. /**
  21845. * Serializes this Sub Surface configuration.
  21846. * @returns - An object with the serialized config.
  21847. */
  21848. serialize(): any;
  21849. /**
  21850. * Parses a anisotropy Configuration from a serialized object.
  21851. * @param source - Serialized object.
  21852. * @param scene Defines the scene we are parsing for
  21853. * @param rootUrl Defines the rootUrl to load from
  21854. */
  21855. parse(source: any, scene: Scene, rootUrl: string): void;
  21856. }
  21857. }
  21858. declare module "babylonjs/Maths/sphericalPolynomial" {
  21859. import { Vector3 } from "babylonjs/Maths/math.vector";
  21860. import { Color3 } from "babylonjs/Maths/math.color";
  21861. /**
  21862. * Class representing spherical harmonics coefficients to the 3rd degree
  21863. */
  21864. export class SphericalHarmonics {
  21865. /**
  21866. * Defines whether or not the harmonics have been prescaled for rendering.
  21867. */
  21868. preScaled: boolean;
  21869. /**
  21870. * The l0,0 coefficients of the spherical harmonics
  21871. */
  21872. l00: Vector3;
  21873. /**
  21874. * The l1,-1 coefficients of the spherical harmonics
  21875. */
  21876. l1_1: Vector3;
  21877. /**
  21878. * The l1,0 coefficients of the spherical harmonics
  21879. */
  21880. l10: Vector3;
  21881. /**
  21882. * The l1,1 coefficients of the spherical harmonics
  21883. */
  21884. l11: Vector3;
  21885. /**
  21886. * The l2,-2 coefficients of the spherical harmonics
  21887. */
  21888. l2_2: Vector3;
  21889. /**
  21890. * The l2,-1 coefficients of the spherical harmonics
  21891. */
  21892. l2_1: Vector3;
  21893. /**
  21894. * The l2,0 coefficients of the spherical harmonics
  21895. */
  21896. l20: Vector3;
  21897. /**
  21898. * The l2,1 coefficients of the spherical harmonics
  21899. */
  21900. l21: Vector3;
  21901. /**
  21902. * The l2,2 coefficients of the spherical harmonics
  21903. */
  21904. l22: Vector3;
  21905. /**
  21906. * Adds a light to the spherical harmonics
  21907. * @param direction the direction of the light
  21908. * @param color the color of the light
  21909. * @param deltaSolidAngle the delta solid angle of the light
  21910. */
  21911. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21912. /**
  21913. * Scales the spherical harmonics by the given amount
  21914. * @param scale the amount to scale
  21915. */
  21916. scaleInPlace(scale: number): void;
  21917. /**
  21918. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21919. *
  21920. * ```
  21921. * E_lm = A_l * L_lm
  21922. * ```
  21923. *
  21924. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21925. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21926. * the scaling factors are given in equation 9.
  21927. */
  21928. convertIncidentRadianceToIrradiance(): void;
  21929. /**
  21930. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21931. *
  21932. * ```
  21933. * L = (1/pi) * E * rho
  21934. * ```
  21935. *
  21936. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21937. */
  21938. convertIrradianceToLambertianRadiance(): void;
  21939. /**
  21940. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21941. * required operations at run time.
  21942. *
  21943. * This is simply done by scaling back the SH with Ylm constants parameter.
  21944. * The trigonometric part being applied by the shader at run time.
  21945. */
  21946. preScaleForRendering(): void;
  21947. /**
  21948. * Constructs a spherical harmonics from an array.
  21949. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21950. * @returns the spherical harmonics
  21951. */
  21952. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21953. /**
  21954. * Gets the spherical harmonics from polynomial
  21955. * @param polynomial the spherical polynomial
  21956. * @returns the spherical harmonics
  21957. */
  21958. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21959. }
  21960. /**
  21961. * Class representing spherical polynomial coefficients to the 3rd degree
  21962. */
  21963. export class SphericalPolynomial {
  21964. private _harmonics;
  21965. /**
  21966. * The spherical harmonics used to create the polynomials.
  21967. */
  21968. get preScaledHarmonics(): SphericalHarmonics;
  21969. /**
  21970. * The x coefficients of the spherical polynomial
  21971. */
  21972. x: Vector3;
  21973. /**
  21974. * The y coefficients of the spherical polynomial
  21975. */
  21976. y: Vector3;
  21977. /**
  21978. * The z coefficients of the spherical polynomial
  21979. */
  21980. z: Vector3;
  21981. /**
  21982. * The xx coefficients of the spherical polynomial
  21983. */
  21984. xx: Vector3;
  21985. /**
  21986. * The yy coefficients of the spherical polynomial
  21987. */
  21988. yy: Vector3;
  21989. /**
  21990. * The zz coefficients of the spherical polynomial
  21991. */
  21992. zz: Vector3;
  21993. /**
  21994. * The xy coefficients of the spherical polynomial
  21995. */
  21996. xy: Vector3;
  21997. /**
  21998. * The yz coefficients of the spherical polynomial
  21999. */
  22000. yz: Vector3;
  22001. /**
  22002. * The zx coefficients of the spherical polynomial
  22003. */
  22004. zx: Vector3;
  22005. /**
  22006. * Adds an ambient color to the spherical polynomial
  22007. * @param color the color to add
  22008. */
  22009. addAmbient(color: Color3): void;
  22010. /**
  22011. * Scales the spherical polynomial by the given amount
  22012. * @param scale the amount to scale
  22013. */
  22014. scaleInPlace(scale: number): void;
  22015. /**
  22016. * Gets the spherical polynomial from harmonics
  22017. * @param harmonics the spherical harmonics
  22018. * @returns the spherical polynomial
  22019. */
  22020. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  22021. /**
  22022. * Constructs a spherical polynomial from an array.
  22023. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  22024. * @returns the spherical polynomial
  22025. */
  22026. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  22027. }
  22028. }
  22029. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  22030. import { Nullable } from "babylonjs/types";
  22031. /**
  22032. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  22033. */
  22034. export interface CubeMapInfo {
  22035. /**
  22036. * The pixel array for the front face.
  22037. * This is stored in format, left to right, up to down format.
  22038. */
  22039. front: Nullable<ArrayBufferView>;
  22040. /**
  22041. * The pixel array for the back face.
  22042. * This is stored in format, left to right, up to down format.
  22043. */
  22044. back: Nullable<ArrayBufferView>;
  22045. /**
  22046. * The pixel array for the left face.
  22047. * This is stored in format, left to right, up to down format.
  22048. */
  22049. left: Nullable<ArrayBufferView>;
  22050. /**
  22051. * The pixel array for the right face.
  22052. * This is stored in format, left to right, up to down format.
  22053. */
  22054. right: Nullable<ArrayBufferView>;
  22055. /**
  22056. * The pixel array for the up face.
  22057. * This is stored in format, left to right, up to down format.
  22058. */
  22059. up: Nullable<ArrayBufferView>;
  22060. /**
  22061. * The pixel array for the down face.
  22062. * This is stored in format, left to right, up to down format.
  22063. */
  22064. down: Nullable<ArrayBufferView>;
  22065. /**
  22066. * The size of the cubemap stored.
  22067. *
  22068. * Each faces will be size * size pixels.
  22069. */
  22070. size: number;
  22071. /**
  22072. * The format of the texture.
  22073. *
  22074. * RGBA, RGB.
  22075. */
  22076. format: number;
  22077. /**
  22078. * The type of the texture data.
  22079. *
  22080. * UNSIGNED_INT, FLOAT.
  22081. */
  22082. type: number;
  22083. /**
  22084. * Specifies whether the texture is in gamma space.
  22085. */
  22086. gammaSpace: boolean;
  22087. }
  22088. /**
  22089. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  22090. */
  22091. export class PanoramaToCubeMapTools {
  22092. private static FACE_LEFT;
  22093. private static FACE_RIGHT;
  22094. private static FACE_FRONT;
  22095. private static FACE_BACK;
  22096. private static FACE_DOWN;
  22097. private static FACE_UP;
  22098. /**
  22099. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  22100. *
  22101. * @param float32Array The source data.
  22102. * @param inputWidth The width of the input panorama.
  22103. * @param inputHeight The height of the input panorama.
  22104. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  22105. * @return The cubemap data
  22106. */
  22107. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  22108. private static CreateCubemapTexture;
  22109. private static CalcProjectionSpherical;
  22110. }
  22111. }
  22112. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  22113. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  22114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22115. import { Nullable } from "babylonjs/types";
  22116. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  22117. /**
  22118. * Helper class dealing with the extraction of spherical polynomial dataArray
  22119. * from a cube map.
  22120. */
  22121. export class CubeMapToSphericalPolynomialTools {
  22122. private static FileFaces;
  22123. /**
  22124. * Converts a texture to the according Spherical Polynomial data.
  22125. * This extracts the first 3 orders only as they are the only one used in the lighting.
  22126. *
  22127. * @param texture The texture to extract the information from.
  22128. * @return The Spherical Polynomial data.
  22129. */
  22130. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  22131. /**
  22132. * Converts a cubemap to the according Spherical Polynomial data.
  22133. * This extracts the first 3 orders only as they are the only one used in the lighting.
  22134. *
  22135. * @param cubeInfo The Cube map to extract the information from.
  22136. * @return The Spherical Polynomial data.
  22137. */
  22138. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  22139. }
  22140. }
  22141. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  22142. import { Nullable } from "babylonjs/types";
  22143. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  22144. module "babylonjs/Materials/Textures/baseTexture" {
  22145. interface BaseTexture {
  22146. /**
  22147. * Get the polynomial representation of the texture data.
  22148. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  22149. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  22150. */
  22151. sphericalPolynomial: Nullable<SphericalPolynomial>;
  22152. }
  22153. }
  22154. }
  22155. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  22156. /** @hidden */
  22157. export var pbrFragmentDeclaration: {
  22158. name: string;
  22159. shader: string;
  22160. };
  22161. }
  22162. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  22163. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  22164. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  22165. /** @hidden */
  22166. export var pbrUboDeclaration: {
  22167. name: string;
  22168. shader: string;
  22169. };
  22170. }
  22171. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  22172. /** @hidden */
  22173. export var pbrFragmentExtraDeclaration: {
  22174. name: string;
  22175. shader: string;
  22176. };
  22177. }
  22178. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  22179. /** @hidden */
  22180. export var pbrFragmentSamplersDeclaration: {
  22181. name: string;
  22182. shader: string;
  22183. };
  22184. }
  22185. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  22186. /** @hidden */
  22187. export var subSurfaceScatteringFunctions: {
  22188. name: string;
  22189. shader: string;
  22190. };
  22191. }
  22192. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  22193. /** @hidden */
  22194. export var importanceSampling: {
  22195. name: string;
  22196. shader: string;
  22197. };
  22198. }
  22199. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  22200. /** @hidden */
  22201. export var pbrHelperFunctions: {
  22202. name: string;
  22203. shader: string;
  22204. };
  22205. }
  22206. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  22207. /** @hidden */
  22208. export var harmonicsFunctions: {
  22209. name: string;
  22210. shader: string;
  22211. };
  22212. }
  22213. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  22214. /** @hidden */
  22215. export var pbrDirectLightingSetupFunctions: {
  22216. name: string;
  22217. shader: string;
  22218. };
  22219. }
  22220. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  22221. /** @hidden */
  22222. export var pbrDirectLightingFalloffFunctions: {
  22223. name: string;
  22224. shader: string;
  22225. };
  22226. }
  22227. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  22228. /** @hidden */
  22229. export var pbrBRDFFunctions: {
  22230. name: string;
  22231. shader: string;
  22232. };
  22233. }
  22234. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  22235. /** @hidden */
  22236. export var hdrFilteringFunctions: {
  22237. name: string;
  22238. shader: string;
  22239. };
  22240. }
  22241. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  22242. /** @hidden */
  22243. export var pbrDirectLightingFunctions: {
  22244. name: string;
  22245. shader: string;
  22246. };
  22247. }
  22248. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  22249. /** @hidden */
  22250. export var pbrIBLFunctions: {
  22251. name: string;
  22252. shader: string;
  22253. };
  22254. }
  22255. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  22256. /** @hidden */
  22257. export var pbrBlockAlbedoOpacity: {
  22258. name: string;
  22259. shader: string;
  22260. };
  22261. }
  22262. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  22263. /** @hidden */
  22264. export var pbrBlockReflectivity: {
  22265. name: string;
  22266. shader: string;
  22267. };
  22268. }
  22269. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  22270. /** @hidden */
  22271. export var pbrBlockAmbientOcclusion: {
  22272. name: string;
  22273. shader: string;
  22274. };
  22275. }
  22276. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  22277. /** @hidden */
  22278. export var pbrBlockAlphaFresnel: {
  22279. name: string;
  22280. shader: string;
  22281. };
  22282. }
  22283. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  22284. /** @hidden */
  22285. export var pbrBlockAnisotropic: {
  22286. name: string;
  22287. shader: string;
  22288. };
  22289. }
  22290. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  22291. /** @hidden */
  22292. export var pbrBlockReflection: {
  22293. name: string;
  22294. shader: string;
  22295. };
  22296. }
  22297. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  22298. /** @hidden */
  22299. export var pbrBlockSheen: {
  22300. name: string;
  22301. shader: string;
  22302. };
  22303. }
  22304. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  22305. /** @hidden */
  22306. export var pbrBlockClearcoat: {
  22307. name: string;
  22308. shader: string;
  22309. };
  22310. }
  22311. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  22312. /** @hidden */
  22313. export var pbrBlockSubSurface: {
  22314. name: string;
  22315. shader: string;
  22316. };
  22317. }
  22318. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  22319. /** @hidden */
  22320. export var pbrBlockNormalGeometric: {
  22321. name: string;
  22322. shader: string;
  22323. };
  22324. }
  22325. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  22326. /** @hidden */
  22327. export var pbrBlockNormalFinal: {
  22328. name: string;
  22329. shader: string;
  22330. };
  22331. }
  22332. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  22333. /** @hidden */
  22334. export var pbrBlockLightmapInit: {
  22335. name: string;
  22336. shader: string;
  22337. };
  22338. }
  22339. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  22340. /** @hidden */
  22341. export var pbrBlockGeometryInfo: {
  22342. name: string;
  22343. shader: string;
  22344. };
  22345. }
  22346. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  22347. /** @hidden */
  22348. export var pbrBlockReflectance0: {
  22349. name: string;
  22350. shader: string;
  22351. };
  22352. }
  22353. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  22354. /** @hidden */
  22355. export var pbrBlockReflectance: {
  22356. name: string;
  22357. shader: string;
  22358. };
  22359. }
  22360. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  22361. /** @hidden */
  22362. export var pbrBlockDirectLighting: {
  22363. name: string;
  22364. shader: string;
  22365. };
  22366. }
  22367. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  22368. /** @hidden */
  22369. export var pbrBlockFinalLitComponents: {
  22370. name: string;
  22371. shader: string;
  22372. };
  22373. }
  22374. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  22375. /** @hidden */
  22376. export var pbrBlockFinalUnlitComponents: {
  22377. name: string;
  22378. shader: string;
  22379. };
  22380. }
  22381. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  22382. /** @hidden */
  22383. export var pbrBlockFinalColorComposition: {
  22384. name: string;
  22385. shader: string;
  22386. };
  22387. }
  22388. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  22389. /** @hidden */
  22390. export var pbrBlockImageProcessing: {
  22391. name: string;
  22392. shader: string;
  22393. };
  22394. }
  22395. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  22396. /** @hidden */
  22397. export var pbrDebug: {
  22398. name: string;
  22399. shader: string;
  22400. };
  22401. }
  22402. declare module "babylonjs/Shaders/pbr.fragment" {
  22403. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  22404. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  22405. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22406. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  22407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  22408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  22409. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  22410. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  22411. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  22412. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22413. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  22414. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22415. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  22416. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  22417. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  22418. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  22419. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  22420. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22421. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  22422. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  22423. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  22424. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  22425. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  22426. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  22427. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22428. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22429. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  22430. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  22431. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  22432. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  22433. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  22434. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  22435. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  22436. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  22437. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  22438. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  22439. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  22440. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  22441. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22442. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  22443. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  22444. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  22445. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  22446. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  22447. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  22448. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  22449. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  22450. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  22451. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  22452. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  22453. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  22454. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  22455. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  22456. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  22457. /** @hidden */
  22458. export var pbrPixelShader: {
  22459. name: string;
  22460. shader: string;
  22461. };
  22462. }
  22463. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  22464. /** @hidden */
  22465. export var pbrVertexDeclaration: {
  22466. name: string;
  22467. shader: string;
  22468. };
  22469. }
  22470. declare module "babylonjs/Shaders/pbr.vertex" {
  22471. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  22472. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22474. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22475. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  22476. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22477. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  22478. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  22479. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  22480. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  22481. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  22482. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22483. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22484. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal";
  22486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22487. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22488. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22489. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  22490. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22491. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  22492. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  22493. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  22494. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  22495. /** @hidden */
  22496. export var pbrVertexShader: {
  22497. name: string;
  22498. shader: string;
  22499. };
  22500. }
  22501. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  22502. import { Nullable } from "babylonjs/types";
  22503. import { Scene } from "babylonjs/scene";
  22504. import { Matrix } from "babylonjs/Maths/math.vector";
  22505. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22507. import { Mesh } from "babylonjs/Meshes/mesh";
  22508. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  22509. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  22510. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  22511. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  22512. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  22513. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  22514. import { Color3 } from "babylonjs/Maths/math.color";
  22515. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22516. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  22517. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22518. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22521. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  22522. import "babylonjs/Shaders/pbr.fragment";
  22523. import "babylonjs/Shaders/pbr.vertex";
  22524. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  22525. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22526. /**
  22527. * Manages the defines for the PBR Material.
  22528. * @hidden
  22529. */
  22530. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  22531. PBR: boolean;
  22532. NUM_SAMPLES: string;
  22533. REALTIME_FILTERING: boolean;
  22534. MAINUV1: boolean;
  22535. MAINUV2: boolean;
  22536. UV1: boolean;
  22537. UV2: boolean;
  22538. ALBEDO: boolean;
  22539. GAMMAALBEDO: boolean;
  22540. ALBEDODIRECTUV: number;
  22541. VERTEXCOLOR: boolean;
  22542. DETAIL: boolean;
  22543. DETAILDIRECTUV: number;
  22544. DETAIL_NORMALBLENDMETHOD: number;
  22545. AMBIENT: boolean;
  22546. AMBIENTDIRECTUV: number;
  22547. AMBIENTINGRAYSCALE: boolean;
  22548. OPACITY: boolean;
  22549. VERTEXALPHA: boolean;
  22550. OPACITYDIRECTUV: number;
  22551. OPACITYRGB: boolean;
  22552. ALPHATEST: boolean;
  22553. DEPTHPREPASS: boolean;
  22554. ALPHABLEND: boolean;
  22555. ALPHAFROMALBEDO: boolean;
  22556. ALPHATESTVALUE: string;
  22557. SPECULAROVERALPHA: boolean;
  22558. RADIANCEOVERALPHA: boolean;
  22559. ALPHAFRESNEL: boolean;
  22560. LINEARALPHAFRESNEL: boolean;
  22561. PREMULTIPLYALPHA: boolean;
  22562. EMISSIVE: boolean;
  22563. EMISSIVEDIRECTUV: number;
  22564. REFLECTIVITY: boolean;
  22565. REFLECTIVITYDIRECTUV: number;
  22566. SPECULARTERM: boolean;
  22567. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  22568. MICROSURFACEAUTOMATIC: boolean;
  22569. LODBASEDMICROSFURACE: boolean;
  22570. MICROSURFACEMAP: boolean;
  22571. MICROSURFACEMAPDIRECTUV: number;
  22572. METALLICWORKFLOW: boolean;
  22573. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  22574. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  22575. METALLNESSSTOREINMETALMAPBLUE: boolean;
  22576. AOSTOREINMETALMAPRED: boolean;
  22577. METALLIC_REFLECTANCE: boolean;
  22578. METALLIC_REFLECTANCEDIRECTUV: number;
  22579. ENVIRONMENTBRDF: boolean;
  22580. ENVIRONMENTBRDF_RGBD: boolean;
  22581. NORMAL: boolean;
  22582. TANGENT: boolean;
  22583. BUMP: boolean;
  22584. BUMPDIRECTUV: number;
  22585. OBJECTSPACE_NORMALMAP: boolean;
  22586. PARALLAX: boolean;
  22587. PARALLAXOCCLUSION: boolean;
  22588. NORMALXYSCALE: boolean;
  22589. LIGHTMAP: boolean;
  22590. LIGHTMAPDIRECTUV: number;
  22591. USELIGHTMAPASSHADOWMAP: boolean;
  22592. GAMMALIGHTMAP: boolean;
  22593. RGBDLIGHTMAP: boolean;
  22594. REFLECTION: boolean;
  22595. REFLECTIONMAP_3D: boolean;
  22596. REFLECTIONMAP_SPHERICAL: boolean;
  22597. REFLECTIONMAP_PLANAR: boolean;
  22598. REFLECTIONMAP_CUBIC: boolean;
  22599. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  22600. REFLECTIONMAP_PROJECTION: boolean;
  22601. REFLECTIONMAP_SKYBOX: boolean;
  22602. REFLECTIONMAP_EXPLICIT: boolean;
  22603. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  22604. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  22605. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  22606. INVERTCUBICMAP: boolean;
  22607. USESPHERICALFROMREFLECTIONMAP: boolean;
  22608. USEIRRADIANCEMAP: boolean;
  22609. SPHERICAL_HARMONICS: boolean;
  22610. USESPHERICALINVERTEX: boolean;
  22611. REFLECTIONMAP_OPPOSITEZ: boolean;
  22612. LODINREFLECTIONALPHA: boolean;
  22613. GAMMAREFLECTION: boolean;
  22614. RGBDREFLECTION: boolean;
  22615. LINEARSPECULARREFLECTION: boolean;
  22616. RADIANCEOCCLUSION: boolean;
  22617. HORIZONOCCLUSION: boolean;
  22618. INSTANCES: boolean;
  22619. THIN_INSTANCES: boolean;
  22620. PREPASS: boolean;
  22621. PREPASS_IRRADIANCE: boolean;
  22622. PREPASS_IRRADIANCE_INDEX: number;
  22623. PREPASS_ALBEDO: boolean;
  22624. PREPASS_ALBEDO_INDEX: number;
  22625. PREPASS_DEPTH: boolean;
  22626. PREPASS_DEPTH_INDEX: number;
  22627. PREPASS_NORMAL: boolean;
  22628. PREPASS_NORMAL_INDEX: number;
  22629. PREPASS_POSITION: boolean;
  22630. PREPASS_POSITION_INDEX: number;
  22631. PREPASS_VELOCITY: boolean;
  22632. PREPASS_VELOCITY_INDEX: number;
  22633. PREPASS_REFLECTIVITY: boolean;
  22634. PREPASS_REFLECTIVITY_INDEX: number;
  22635. SCENE_MRT_COUNT: number;
  22636. NUM_BONE_INFLUENCERS: number;
  22637. BonesPerMesh: number;
  22638. BONETEXTURE: boolean;
  22639. BONES_VELOCITY_ENABLED: boolean;
  22640. NONUNIFORMSCALING: boolean;
  22641. MORPHTARGETS: boolean;
  22642. MORPHTARGETS_NORMAL: boolean;
  22643. MORPHTARGETS_TANGENT: boolean;
  22644. MORPHTARGETS_UV: boolean;
  22645. NUM_MORPH_INFLUENCERS: number;
  22646. MORPHTARGETS_TEXTURE: boolean;
  22647. IMAGEPROCESSING: boolean;
  22648. VIGNETTE: boolean;
  22649. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22650. VIGNETTEBLENDMODEOPAQUE: boolean;
  22651. TONEMAPPING: boolean;
  22652. TONEMAPPING_ACES: boolean;
  22653. CONTRAST: boolean;
  22654. COLORCURVES: boolean;
  22655. COLORGRADING: boolean;
  22656. COLORGRADING3D: boolean;
  22657. SAMPLER3DGREENDEPTH: boolean;
  22658. SAMPLER3DBGRMAP: boolean;
  22659. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22660. EXPOSURE: boolean;
  22661. MULTIVIEW: boolean;
  22662. USEPHYSICALLIGHTFALLOFF: boolean;
  22663. USEGLTFLIGHTFALLOFF: boolean;
  22664. TWOSIDEDLIGHTING: boolean;
  22665. SHADOWFLOAT: boolean;
  22666. CLIPPLANE: boolean;
  22667. CLIPPLANE2: boolean;
  22668. CLIPPLANE3: boolean;
  22669. CLIPPLANE4: boolean;
  22670. CLIPPLANE5: boolean;
  22671. CLIPPLANE6: boolean;
  22672. POINTSIZE: boolean;
  22673. FOG: boolean;
  22674. LOGARITHMICDEPTH: boolean;
  22675. FORCENORMALFORWARD: boolean;
  22676. SPECULARAA: boolean;
  22677. CLEARCOAT: boolean;
  22678. CLEARCOAT_DEFAULTIOR: boolean;
  22679. CLEARCOAT_TEXTURE: boolean;
  22680. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  22681. CLEARCOAT_TEXTUREDIRECTUV: number;
  22682. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  22683. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22684. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22685. CLEARCOAT_BUMP: boolean;
  22686. CLEARCOAT_BUMPDIRECTUV: number;
  22687. CLEARCOAT_REMAP_F0: boolean;
  22688. CLEARCOAT_TINT: boolean;
  22689. CLEARCOAT_TINT_TEXTURE: boolean;
  22690. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  22691. ANISOTROPIC: boolean;
  22692. ANISOTROPIC_TEXTURE: boolean;
  22693. ANISOTROPIC_TEXTUREDIRECTUV: number;
  22694. BRDF_V_HEIGHT_CORRELATED: boolean;
  22695. MS_BRDF_ENERGY_CONSERVATION: boolean;
  22696. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  22697. SHEEN: boolean;
  22698. SHEEN_TEXTURE: boolean;
  22699. SHEEN_TEXTURE_ROUGHNESS: boolean;
  22700. SHEEN_TEXTUREDIRECTUV: number;
  22701. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  22702. SHEEN_LINKWITHALBEDO: boolean;
  22703. SHEEN_ROUGHNESS: boolean;
  22704. SHEEN_ALBEDOSCALING: boolean;
  22705. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22706. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22707. SUBSURFACE: boolean;
  22708. SS_REFRACTION: boolean;
  22709. SS_TRANSLUCENCY: boolean;
  22710. SS_SCATTERING: boolean;
  22711. SS_THICKNESSANDMASK_TEXTURE: boolean;
  22712. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  22713. SS_REFRACTIONMAP_3D: boolean;
  22714. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  22715. SS_LODINREFRACTIONALPHA: boolean;
  22716. SS_GAMMAREFRACTION: boolean;
  22717. SS_RGBDREFRACTION: boolean;
  22718. SS_LINEARSPECULARREFRACTION: boolean;
  22719. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  22720. SS_ALBEDOFORREFRACTIONTINT: boolean;
  22721. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  22722. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  22723. UNLIT: boolean;
  22724. DEBUGMODE: number;
  22725. /**
  22726. * Initializes the PBR Material defines.
  22727. */
  22728. constructor();
  22729. /**
  22730. * Resets the PBR Material defines.
  22731. */
  22732. reset(): void;
  22733. }
  22734. /**
  22735. * The Physically based material base class of BJS.
  22736. *
  22737. * This offers the main features of a standard PBR material.
  22738. * For more information, please refer to the documentation :
  22739. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22740. */
  22741. export abstract class PBRBaseMaterial extends PushMaterial {
  22742. /**
  22743. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22744. */
  22745. static readonly PBRMATERIAL_OPAQUE: number;
  22746. /**
  22747. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22748. */
  22749. static readonly PBRMATERIAL_ALPHATEST: number;
  22750. /**
  22751. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22752. */
  22753. static readonly PBRMATERIAL_ALPHABLEND: number;
  22754. /**
  22755. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22756. * They are also discarded below the alpha cutoff threshold to improve performances.
  22757. */
  22758. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22759. /**
  22760. * Defines the default value of how much AO map is occluding the analytical lights
  22761. * (point spot...).
  22762. */
  22763. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22764. /**
  22765. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  22766. */
  22767. static readonly LIGHTFALLOFF_PHYSICAL: number;
  22768. /**
  22769. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  22770. * to enhance interoperability with other engines.
  22771. */
  22772. static readonly LIGHTFALLOFF_GLTF: number;
  22773. /**
  22774. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  22775. * to enhance interoperability with other materials.
  22776. */
  22777. static readonly LIGHTFALLOFF_STANDARD: number;
  22778. /**
  22779. * Intensity of the direct lights e.g. the four lights available in your scene.
  22780. * This impacts both the direct diffuse and specular highlights.
  22781. */
  22782. protected _directIntensity: number;
  22783. /**
  22784. * Intensity of the emissive part of the material.
  22785. * This helps controlling the emissive effect without modifying the emissive color.
  22786. */
  22787. protected _emissiveIntensity: number;
  22788. /**
  22789. * Intensity of the environment e.g. how much the environment will light the object
  22790. * either through harmonics for rough material or through the reflection for shiny ones.
  22791. */
  22792. protected _environmentIntensity: number;
  22793. /**
  22794. * This is a special control allowing the reduction of the specular highlights coming from the
  22795. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22796. */
  22797. protected _specularIntensity: number;
  22798. /**
  22799. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  22800. */
  22801. private _lightingInfos;
  22802. /**
  22803. * Debug Control allowing disabling the bump map on this material.
  22804. */
  22805. protected _disableBumpMap: boolean;
  22806. /**
  22807. * AKA Diffuse Texture in standard nomenclature.
  22808. */
  22809. protected _albedoTexture: Nullable<BaseTexture>;
  22810. /**
  22811. * AKA Occlusion Texture in other nomenclature.
  22812. */
  22813. protected _ambientTexture: Nullable<BaseTexture>;
  22814. /**
  22815. * AKA Occlusion Texture Intensity in other nomenclature.
  22816. */
  22817. protected _ambientTextureStrength: number;
  22818. /**
  22819. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22820. * 1 means it completely occludes it
  22821. * 0 mean it has no impact
  22822. */
  22823. protected _ambientTextureImpactOnAnalyticalLights: number;
  22824. /**
  22825. * Stores the alpha values in a texture.
  22826. */
  22827. protected _opacityTexture: Nullable<BaseTexture>;
  22828. /**
  22829. * Stores the reflection values in a texture.
  22830. */
  22831. protected _reflectionTexture: Nullable<BaseTexture>;
  22832. /**
  22833. * Stores the emissive values in a texture.
  22834. */
  22835. protected _emissiveTexture: Nullable<BaseTexture>;
  22836. /**
  22837. * AKA Specular texture in other nomenclature.
  22838. */
  22839. protected _reflectivityTexture: Nullable<BaseTexture>;
  22840. /**
  22841. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22842. */
  22843. protected _metallicTexture: Nullable<BaseTexture>;
  22844. /**
  22845. * Specifies the metallic scalar of the metallic/roughness workflow.
  22846. * Can also be used to scale the metalness values of the metallic texture.
  22847. */
  22848. protected _metallic: Nullable<number>;
  22849. /**
  22850. * Specifies the roughness scalar of the metallic/roughness workflow.
  22851. * Can also be used to scale the roughness values of the metallic texture.
  22852. */
  22853. protected _roughness: Nullable<number>;
  22854. /**
  22855. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22856. * By default the indexOfrefraction is used to compute F0;
  22857. *
  22858. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22859. *
  22860. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22861. * F90 = metallicReflectanceColor;
  22862. */
  22863. protected _metallicF0Factor: number;
  22864. /**
  22865. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22866. * By default the F90 is always 1;
  22867. *
  22868. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22869. *
  22870. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22871. * F90 = metallicReflectanceColor;
  22872. */
  22873. protected _metallicReflectanceColor: Color3;
  22874. /**
  22875. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22876. * This is multiply against the scalar values defined in the material.
  22877. */
  22878. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22879. /**
  22880. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22881. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22882. */
  22883. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22884. /**
  22885. * Stores surface normal data used to displace a mesh in a texture.
  22886. */
  22887. protected _bumpTexture: Nullable<BaseTexture>;
  22888. /**
  22889. * Stores the pre-calculated light information of a mesh in a texture.
  22890. */
  22891. protected _lightmapTexture: Nullable<BaseTexture>;
  22892. /**
  22893. * The color of a material in ambient lighting.
  22894. */
  22895. protected _ambientColor: Color3;
  22896. /**
  22897. * AKA Diffuse Color in other nomenclature.
  22898. */
  22899. protected _albedoColor: Color3;
  22900. /**
  22901. * AKA Specular Color in other nomenclature.
  22902. */
  22903. protected _reflectivityColor: Color3;
  22904. /**
  22905. * The color applied when light is reflected from a material.
  22906. */
  22907. protected _reflectionColor: Color3;
  22908. /**
  22909. * The color applied when light is emitted from a material.
  22910. */
  22911. protected _emissiveColor: Color3;
  22912. /**
  22913. * AKA Glossiness in other nomenclature.
  22914. */
  22915. protected _microSurface: number;
  22916. /**
  22917. * Specifies that the material will use the light map as a show map.
  22918. */
  22919. protected _useLightmapAsShadowmap: boolean;
  22920. /**
  22921. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22922. * makes the reflect vector face the model (under horizon).
  22923. */
  22924. protected _useHorizonOcclusion: boolean;
  22925. /**
  22926. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22927. * too much the area relying on ambient texture to define their ambient occlusion.
  22928. */
  22929. protected _useRadianceOcclusion: boolean;
  22930. /**
  22931. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22932. */
  22933. protected _useAlphaFromAlbedoTexture: boolean;
  22934. /**
  22935. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22936. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22937. */
  22938. protected _useSpecularOverAlpha: boolean;
  22939. /**
  22940. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22941. */
  22942. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22943. /**
  22944. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22945. */
  22946. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22947. /**
  22948. * Specifies if the metallic texture contains the roughness information in its green channel.
  22949. */
  22950. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22951. /**
  22952. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22953. */
  22954. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22955. /**
  22956. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22957. */
  22958. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22959. /**
  22960. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22961. */
  22962. protected _useAmbientInGrayScale: boolean;
  22963. /**
  22964. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22965. * The material will try to infer what glossiness each pixel should be.
  22966. */
  22967. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22968. /**
  22969. * Defines the falloff type used in this material.
  22970. * It by default is Physical.
  22971. */
  22972. protected _lightFalloff: number;
  22973. /**
  22974. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22975. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22976. */
  22977. protected _useRadianceOverAlpha: boolean;
  22978. /**
  22979. * Allows using an object space normal map (instead of tangent space).
  22980. */
  22981. protected _useObjectSpaceNormalMap: boolean;
  22982. /**
  22983. * Allows using the bump map in parallax mode.
  22984. */
  22985. protected _useParallax: boolean;
  22986. /**
  22987. * Allows using the bump map in parallax occlusion mode.
  22988. */
  22989. protected _useParallaxOcclusion: boolean;
  22990. /**
  22991. * Controls the scale bias of the parallax mode.
  22992. */
  22993. protected _parallaxScaleBias: number;
  22994. /**
  22995. * If sets to true, disables all the lights affecting the material.
  22996. */
  22997. protected _disableLighting: boolean;
  22998. /**
  22999. * Number of Simultaneous lights allowed on the material.
  23000. */
  23001. protected _maxSimultaneousLights: number;
  23002. /**
  23003. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  23004. */
  23005. protected _invertNormalMapX: boolean;
  23006. /**
  23007. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  23008. */
  23009. protected _invertNormalMapY: boolean;
  23010. /**
  23011. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23012. */
  23013. protected _twoSidedLighting: boolean;
  23014. /**
  23015. * Defines the alpha limits in alpha test mode.
  23016. */
  23017. protected _alphaCutOff: number;
  23018. /**
  23019. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  23020. */
  23021. protected _forceAlphaTest: boolean;
  23022. /**
  23023. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23024. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23025. */
  23026. protected _useAlphaFresnel: boolean;
  23027. /**
  23028. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23029. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23030. */
  23031. protected _useLinearAlphaFresnel: boolean;
  23032. /**
  23033. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  23034. * from cos theta and roughness:
  23035. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  23036. */
  23037. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  23038. /**
  23039. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23040. */
  23041. protected _forceIrradianceInFragment: boolean;
  23042. private _realTimeFiltering;
  23043. /**
  23044. * Enables realtime filtering on the texture.
  23045. */
  23046. get realTimeFiltering(): boolean;
  23047. set realTimeFiltering(b: boolean);
  23048. private _realTimeFilteringQuality;
  23049. /**
  23050. * Quality switch for realtime filtering
  23051. */
  23052. get realTimeFilteringQuality(): number;
  23053. set realTimeFilteringQuality(n: number);
  23054. /**
  23055. * Can this material render to several textures at once
  23056. */
  23057. get canRenderToMRT(): boolean;
  23058. /**
  23059. * Force normal to face away from face.
  23060. */
  23061. protected _forceNormalForward: boolean;
  23062. /**
  23063. * Enables specular anti aliasing in the PBR shader.
  23064. * It will both interacts on the Geometry for analytical and IBL lighting.
  23065. * It also prefilter the roughness map based on the bump values.
  23066. */
  23067. protected _enableSpecularAntiAliasing: boolean;
  23068. /**
  23069. * Default configuration related to image processing available in the PBR Material.
  23070. */
  23071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23072. /**
  23073. * Keep track of the image processing observer to allow dispose and replace.
  23074. */
  23075. private _imageProcessingObserver;
  23076. /**
  23077. * Attaches a new image processing configuration to the PBR Material.
  23078. * @param configuration
  23079. */
  23080. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23081. /**
  23082. * Stores the available render targets.
  23083. */
  23084. private _renderTargets;
  23085. /**
  23086. * Sets the global ambient color for the material used in lighting calculations.
  23087. */
  23088. private _globalAmbientColor;
  23089. /**
  23090. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  23091. */
  23092. private _useLogarithmicDepth;
  23093. /**
  23094. * If set to true, no lighting calculations will be applied.
  23095. */
  23096. private _unlit;
  23097. private _debugMode;
  23098. /**
  23099. * @hidden
  23100. * This is reserved for the inspector.
  23101. * Defines the material debug mode.
  23102. * It helps seeing only some components of the material while troubleshooting.
  23103. */
  23104. debugMode: number;
  23105. /**
  23106. * @hidden
  23107. * This is reserved for the inspector.
  23108. * Specify from where on screen the debug mode should start.
  23109. * The value goes from -1 (full screen) to 1 (not visible)
  23110. * It helps with side by side comparison against the final render
  23111. * This defaults to -1
  23112. */
  23113. private debugLimit;
  23114. /**
  23115. * @hidden
  23116. * This is reserved for the inspector.
  23117. * As the default viewing range might not be enough (if the ambient is really small for instance)
  23118. * You can use the factor to better multiply the final value.
  23119. */
  23120. private debugFactor;
  23121. /**
  23122. * Defines the clear coat layer parameters for the material.
  23123. */
  23124. readonly clearCoat: PBRClearCoatConfiguration;
  23125. /**
  23126. * Defines the anisotropic parameters for the material.
  23127. */
  23128. readonly anisotropy: PBRAnisotropicConfiguration;
  23129. /**
  23130. * Defines the BRDF parameters for the material.
  23131. */
  23132. readonly brdf: PBRBRDFConfiguration;
  23133. /**
  23134. * Defines the Sheen parameters for the material.
  23135. */
  23136. readonly sheen: PBRSheenConfiguration;
  23137. /**
  23138. * Defines the SubSurface parameters for the material.
  23139. */
  23140. readonly subSurface: PBRSubSurfaceConfiguration;
  23141. /**
  23142. * Defines additional PrePass parameters for the material.
  23143. */
  23144. readonly prePassConfiguration: PrePassConfiguration;
  23145. /**
  23146. * Defines the detail map parameters for the material.
  23147. */
  23148. readonly detailMap: DetailMapConfiguration;
  23149. protected _rebuildInParallel: boolean;
  23150. /**
  23151. * Instantiates a new PBRMaterial instance.
  23152. *
  23153. * @param name The material name
  23154. * @param scene The scene the material will be use in.
  23155. */
  23156. constructor(name: string, scene: Scene);
  23157. /**
  23158. * Gets a boolean indicating that current material needs to register RTT
  23159. */
  23160. get hasRenderTargetTextures(): boolean;
  23161. /**
  23162. * Can this material render to prepass
  23163. */
  23164. get isPrePassCapable(): boolean;
  23165. /**
  23166. * Gets the name of the material class.
  23167. */
  23168. getClassName(): string;
  23169. /**
  23170. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  23171. */
  23172. get useLogarithmicDepth(): boolean;
  23173. /**
  23174. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  23175. */
  23176. set useLogarithmicDepth(value: boolean);
  23177. /**
  23178. * Returns true if alpha blending should be disabled.
  23179. */
  23180. protected get _disableAlphaBlending(): boolean;
  23181. /**
  23182. * Specifies whether or not this material should be rendered in alpha blend mode.
  23183. */
  23184. needAlphaBlending(): boolean;
  23185. /**
  23186. * Specifies whether or not this material should be rendered in alpha test mode.
  23187. */
  23188. needAlphaTesting(): boolean;
  23189. /**
  23190. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  23191. */
  23192. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  23193. /**
  23194. * Specifies whether or not there is a usable alpha channel for transparency.
  23195. */
  23196. protected _hasAlphaChannel(): boolean;
  23197. /**
  23198. * Gets the texture used for the alpha test.
  23199. */
  23200. getAlphaTestTexture(): Nullable<BaseTexture>;
  23201. /**
  23202. * Specifies that the submesh is ready to be used.
  23203. * @param mesh - BJS mesh.
  23204. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  23205. * @param useInstances - Specifies that instances should be used.
  23206. * @returns - boolean indicating that the submesh is ready or not.
  23207. */
  23208. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23209. /**
  23210. * Specifies if the material uses metallic roughness workflow.
  23211. * @returns boolean specifying if the material uses metallic roughness workflow.
  23212. */
  23213. isMetallicWorkflow(): boolean;
  23214. private _prepareEffect;
  23215. private _prepareDefines;
  23216. /**
  23217. * Force shader compilation
  23218. */
  23219. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  23220. /**
  23221. * Initializes the uniform buffer layout for the shader.
  23222. */
  23223. buildUniformLayout(): void;
  23224. /**
  23225. * Unbinds the material from the mesh
  23226. */
  23227. unbind(): void;
  23228. /**
  23229. * Binds the submesh data.
  23230. * @param world - The world matrix.
  23231. * @param mesh - The BJS mesh.
  23232. * @param subMesh - A submesh of the BJS mesh.
  23233. */
  23234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23235. /**
  23236. * Returns the animatable textures.
  23237. * @returns - Array of animatable textures.
  23238. */
  23239. getAnimatables(): IAnimatable[];
  23240. /**
  23241. * Returns the texture used for reflections.
  23242. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  23243. */
  23244. private _getReflectionTexture;
  23245. /**
  23246. * Returns an array of the actively used textures.
  23247. * @returns - Array of BaseTextures
  23248. */
  23249. getActiveTextures(): BaseTexture[];
  23250. /**
  23251. * Checks to see if a texture is used in the material.
  23252. * @param texture - Base texture to use.
  23253. * @returns - Boolean specifying if a texture is used in the material.
  23254. */
  23255. hasTexture(texture: BaseTexture): boolean;
  23256. /**
  23257. * Sets the required values to the prepass renderer.
  23258. * @param prePassRenderer defines the prepass renderer to setup
  23259. */
  23260. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23261. /**
  23262. * Disposes the resources of the material.
  23263. * @param forceDisposeEffect - Forces the disposal of effects.
  23264. * @param forceDisposeTextures - Forces the disposal of all textures.
  23265. */
  23266. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23267. }
  23268. }
  23269. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  23270. import { Nullable } from "babylonjs/types";
  23271. import { Scene } from "babylonjs/scene";
  23272. import { Color3 } from "babylonjs/Maths/math.color";
  23273. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23274. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23276. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  23277. /**
  23278. * The Physically based material of BJS.
  23279. *
  23280. * This offers the main features of a standard PBR material.
  23281. * For more information, please refer to the documentation :
  23282. * https://doc.babylonjs.com/how_to/physically_based_rendering
  23283. */
  23284. export class PBRMaterial extends PBRBaseMaterial {
  23285. /**
  23286. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23287. */
  23288. static readonly PBRMATERIAL_OPAQUE: number;
  23289. /**
  23290. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23291. */
  23292. static readonly PBRMATERIAL_ALPHATEST: number;
  23293. /**
  23294. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23295. */
  23296. static readonly PBRMATERIAL_ALPHABLEND: number;
  23297. /**
  23298. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23299. * They are also discarded below the alpha cutoff threshold to improve performances.
  23300. */
  23301. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  23302. /**
  23303. * Defines the default value of how much AO map is occluding the analytical lights
  23304. * (point spot...).
  23305. */
  23306. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  23307. /**
  23308. * Intensity of the direct lights e.g. the four lights available in your scene.
  23309. * This impacts both the direct diffuse and specular highlights.
  23310. */
  23311. directIntensity: number;
  23312. /**
  23313. * Intensity of the emissive part of the material.
  23314. * This helps controlling the emissive effect without modifying the emissive color.
  23315. */
  23316. emissiveIntensity: number;
  23317. /**
  23318. * Intensity of the environment e.g. how much the environment will light the object
  23319. * either through harmonics for rough material or through the reflection for shiny ones.
  23320. */
  23321. environmentIntensity: number;
  23322. /**
  23323. * This is a special control allowing the reduction of the specular highlights coming from the
  23324. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  23325. */
  23326. specularIntensity: number;
  23327. /**
  23328. * Debug Control allowing disabling the bump map on this material.
  23329. */
  23330. disableBumpMap: boolean;
  23331. /**
  23332. * AKA Diffuse Texture in standard nomenclature.
  23333. */
  23334. albedoTexture: BaseTexture;
  23335. /**
  23336. * AKA Occlusion Texture in other nomenclature.
  23337. */
  23338. ambientTexture: BaseTexture;
  23339. /**
  23340. * AKA Occlusion Texture Intensity in other nomenclature.
  23341. */
  23342. ambientTextureStrength: number;
  23343. /**
  23344. * Defines how much the AO map is occluding the analytical lights (point spot...).
  23345. * 1 means it completely occludes it
  23346. * 0 mean it has no impact
  23347. */
  23348. ambientTextureImpactOnAnalyticalLights: number;
  23349. /**
  23350. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  23351. */
  23352. opacityTexture: BaseTexture;
  23353. /**
  23354. * Stores the reflection values in a texture.
  23355. */
  23356. reflectionTexture: Nullable<BaseTexture>;
  23357. /**
  23358. * Stores the emissive values in a texture.
  23359. */
  23360. emissiveTexture: BaseTexture;
  23361. /**
  23362. * AKA Specular texture in other nomenclature.
  23363. */
  23364. reflectivityTexture: BaseTexture;
  23365. /**
  23366. * Used to switch from specular/glossiness to metallic/roughness workflow.
  23367. */
  23368. metallicTexture: BaseTexture;
  23369. /**
  23370. * Specifies the metallic scalar of the metallic/roughness workflow.
  23371. * Can also be used to scale the metalness values of the metallic texture.
  23372. */
  23373. metallic: Nullable<number>;
  23374. /**
  23375. * Specifies the roughness scalar of the metallic/roughness workflow.
  23376. * Can also be used to scale the roughness values of the metallic texture.
  23377. */
  23378. roughness: Nullable<number>;
  23379. /**
  23380. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  23381. * By default the indexOfrefraction is used to compute F0;
  23382. *
  23383. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  23384. *
  23385. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  23386. * F90 = metallicReflectanceColor;
  23387. */
  23388. metallicF0Factor: number;
  23389. /**
  23390. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  23391. * By default the F90 is always 1;
  23392. *
  23393. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  23394. *
  23395. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  23396. * F90 = metallicReflectanceColor;
  23397. */
  23398. metallicReflectanceColor: Color3;
  23399. /**
  23400. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  23401. * This is multiply against the scalar values defined in the material.
  23402. */
  23403. metallicReflectanceTexture: Nullable<BaseTexture>;
  23404. /**
  23405. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  23406. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  23407. */
  23408. microSurfaceTexture: BaseTexture;
  23409. /**
  23410. * Stores surface normal data used to displace a mesh in a texture.
  23411. */
  23412. bumpTexture: BaseTexture;
  23413. /**
  23414. * Stores the pre-calculated light information of a mesh in a texture.
  23415. */
  23416. lightmapTexture: BaseTexture;
  23417. /**
  23418. * Stores the refracted light information in a texture.
  23419. */
  23420. get refractionTexture(): Nullable<BaseTexture>;
  23421. set refractionTexture(value: Nullable<BaseTexture>);
  23422. /**
  23423. * The color of a material in ambient lighting.
  23424. */
  23425. ambientColor: Color3;
  23426. /**
  23427. * AKA Diffuse Color in other nomenclature.
  23428. */
  23429. albedoColor: Color3;
  23430. /**
  23431. * AKA Specular Color in other nomenclature.
  23432. */
  23433. reflectivityColor: Color3;
  23434. /**
  23435. * The color reflected from the material.
  23436. */
  23437. reflectionColor: Color3;
  23438. /**
  23439. * The color emitted from the material.
  23440. */
  23441. emissiveColor: Color3;
  23442. /**
  23443. * AKA Glossiness in other nomenclature.
  23444. */
  23445. microSurface: number;
  23446. /**
  23447. * Index of refraction of the material base layer.
  23448. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  23449. *
  23450. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  23451. *
  23452. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  23453. */
  23454. get indexOfRefraction(): number;
  23455. set indexOfRefraction(value: number);
  23456. /**
  23457. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  23458. */
  23459. get invertRefractionY(): boolean;
  23460. set invertRefractionY(value: boolean);
  23461. /**
  23462. * This parameters will make the material used its opacity to control how much it is refracting against not.
  23463. * Materials half opaque for instance using refraction could benefit from this control.
  23464. */
  23465. get linkRefractionWithTransparency(): boolean;
  23466. set linkRefractionWithTransparency(value: boolean);
  23467. /**
  23468. * If true, the light map contains occlusion information instead of lighting info.
  23469. */
  23470. useLightmapAsShadowmap: boolean;
  23471. /**
  23472. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  23473. */
  23474. useAlphaFromAlbedoTexture: boolean;
  23475. /**
  23476. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  23477. */
  23478. forceAlphaTest: boolean;
  23479. /**
  23480. * Defines the alpha limits in alpha test mode.
  23481. */
  23482. alphaCutOff: number;
  23483. /**
  23484. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  23485. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  23486. */
  23487. useSpecularOverAlpha: boolean;
  23488. /**
  23489. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  23490. */
  23491. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  23492. /**
  23493. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  23494. */
  23495. useRoughnessFromMetallicTextureAlpha: boolean;
  23496. /**
  23497. * Specifies if the metallic texture contains the roughness information in its green channel.
  23498. */
  23499. useRoughnessFromMetallicTextureGreen: boolean;
  23500. /**
  23501. * Specifies if the metallic texture contains the metallness information in its blue channel.
  23502. */
  23503. useMetallnessFromMetallicTextureBlue: boolean;
  23504. /**
  23505. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  23506. */
  23507. useAmbientOcclusionFromMetallicTextureRed: boolean;
  23508. /**
  23509. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  23510. */
  23511. useAmbientInGrayScale: boolean;
  23512. /**
  23513. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  23514. * The material will try to infer what glossiness each pixel should be.
  23515. */
  23516. useAutoMicroSurfaceFromReflectivityMap: boolean;
  23517. /**
  23518. * BJS is using an hardcoded light falloff based on a manually sets up range.
  23519. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  23520. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23521. */
  23522. get usePhysicalLightFalloff(): boolean;
  23523. /**
  23524. * BJS is using an hardcoded light falloff based on a manually sets up range.
  23525. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  23526. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23527. */
  23528. set usePhysicalLightFalloff(value: boolean);
  23529. /**
  23530. * In order to support the falloff compatibility with gltf, a special mode has been added
  23531. * to reproduce the gltf light falloff.
  23532. */
  23533. get useGLTFLightFalloff(): boolean;
  23534. /**
  23535. * In order to support the falloff compatibility with gltf, a special mode has been added
  23536. * to reproduce the gltf light falloff.
  23537. */
  23538. set useGLTFLightFalloff(value: boolean);
  23539. /**
  23540. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  23541. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  23542. */
  23543. useRadianceOverAlpha: boolean;
  23544. /**
  23545. * Allows using an object space normal map (instead of tangent space).
  23546. */
  23547. useObjectSpaceNormalMap: boolean;
  23548. /**
  23549. * Allows using the bump map in parallax mode.
  23550. */
  23551. useParallax: boolean;
  23552. /**
  23553. * Allows using the bump map in parallax occlusion mode.
  23554. */
  23555. useParallaxOcclusion: boolean;
  23556. /**
  23557. * Controls the scale bias of the parallax mode.
  23558. */
  23559. parallaxScaleBias: number;
  23560. /**
  23561. * If sets to true, disables all the lights affecting the material.
  23562. */
  23563. disableLighting: boolean;
  23564. /**
  23565. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23566. */
  23567. forceIrradianceInFragment: boolean;
  23568. /**
  23569. * Number of Simultaneous lights allowed on the material.
  23570. */
  23571. maxSimultaneousLights: number;
  23572. /**
  23573. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23574. */
  23575. invertNormalMapX: boolean;
  23576. /**
  23577. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23578. */
  23579. invertNormalMapY: boolean;
  23580. /**
  23581. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23582. */
  23583. twoSidedLighting: boolean;
  23584. /**
  23585. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23586. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23587. */
  23588. useAlphaFresnel: boolean;
  23589. /**
  23590. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23591. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23592. */
  23593. useLinearAlphaFresnel: boolean;
  23594. /**
  23595. * Let user defines the brdf lookup texture used for IBL.
  23596. * A default 8bit version is embedded but you could point at :
  23597. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  23598. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  23599. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  23600. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  23601. */
  23602. environmentBRDFTexture: Nullable<BaseTexture>;
  23603. /**
  23604. * Force normal to face away from face.
  23605. */
  23606. forceNormalForward: boolean;
  23607. /**
  23608. * Enables specular anti aliasing in the PBR shader.
  23609. * It will both interacts on the Geometry for analytical and IBL lighting.
  23610. * It also prefilter the roughness map based on the bump values.
  23611. */
  23612. enableSpecularAntiAliasing: boolean;
  23613. /**
  23614. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23615. * makes the reflect vector face the model (under horizon).
  23616. */
  23617. useHorizonOcclusion: boolean;
  23618. /**
  23619. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23620. * too much the area relying on ambient texture to define their ambient occlusion.
  23621. */
  23622. useRadianceOcclusion: boolean;
  23623. /**
  23624. * If set to true, no lighting calculations will be applied.
  23625. */
  23626. unlit: boolean;
  23627. /**
  23628. * Gets the image processing configuration used either in this material.
  23629. */
  23630. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23631. /**
  23632. * Sets the Default image processing configuration used either in the this material.
  23633. *
  23634. * If sets to null, the scene one is in use.
  23635. */
  23636. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23637. /**
  23638. * Gets whether the color curves effect is enabled.
  23639. */
  23640. get cameraColorCurvesEnabled(): boolean;
  23641. /**
  23642. * Sets whether the color curves effect is enabled.
  23643. */
  23644. set cameraColorCurvesEnabled(value: boolean);
  23645. /**
  23646. * Gets whether the color grading effect is enabled.
  23647. */
  23648. get cameraColorGradingEnabled(): boolean;
  23649. /**
  23650. * Gets whether the color grading effect is enabled.
  23651. */
  23652. set cameraColorGradingEnabled(value: boolean);
  23653. /**
  23654. * Gets whether tonemapping is enabled or not.
  23655. */
  23656. get cameraToneMappingEnabled(): boolean;
  23657. /**
  23658. * Sets whether tonemapping is enabled or not
  23659. */
  23660. set cameraToneMappingEnabled(value: boolean);
  23661. /**
  23662. * The camera exposure used on this material.
  23663. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23664. * This corresponds to a photographic exposure.
  23665. */
  23666. get cameraExposure(): number;
  23667. /**
  23668. * The camera exposure used on this material.
  23669. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23670. * This corresponds to a photographic exposure.
  23671. */
  23672. set cameraExposure(value: number);
  23673. /**
  23674. * Gets The camera contrast used on this material.
  23675. */
  23676. get cameraContrast(): number;
  23677. /**
  23678. * Sets The camera contrast used on this material.
  23679. */
  23680. set cameraContrast(value: number);
  23681. /**
  23682. * Gets the Color Grading 2D Lookup Texture.
  23683. */
  23684. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  23685. /**
  23686. * Sets the Color Grading 2D Lookup Texture.
  23687. */
  23688. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  23689. /**
  23690. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  23691. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23692. * 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;
  23693. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23694. */
  23695. get cameraColorCurves(): Nullable<ColorCurves>;
  23696. /**
  23697. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  23698. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23699. * 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;
  23700. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23701. */
  23702. set cameraColorCurves(value: Nullable<ColorCurves>);
  23703. /**
  23704. * Instantiates a new PBRMaterial instance.
  23705. *
  23706. * @param name The material name
  23707. * @param scene The scene the material will be use in.
  23708. */
  23709. constructor(name: string, scene: Scene);
  23710. /**
  23711. * Returns the name of this material class.
  23712. */
  23713. getClassName(): string;
  23714. /**
  23715. * Makes a duplicate of the current material.
  23716. * @param name - name to use for the new material.
  23717. */
  23718. clone(name: string): PBRMaterial;
  23719. /**
  23720. * Serializes this PBR Material.
  23721. * @returns - An object with the serialized material.
  23722. */
  23723. serialize(): any;
  23724. /**
  23725. * Parses a PBR Material from a serialized object.
  23726. * @param source - Serialized object.
  23727. * @param scene - BJS scene instance.
  23728. * @param rootUrl - url for the scene object
  23729. * @returns - PBRMaterial
  23730. */
  23731. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  23732. }
  23733. }
  23734. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  23735. /** @hidden */
  23736. export var mrtFragmentDeclaration: {
  23737. name: string;
  23738. shader: string;
  23739. };
  23740. }
  23741. declare module "babylonjs/Shaders/geometry.fragment" {
  23742. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  23743. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  23744. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  23745. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  23746. /** @hidden */
  23747. export var geometryPixelShader: {
  23748. name: string;
  23749. shader: string;
  23750. };
  23751. }
  23752. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  23753. /** @hidden */
  23754. export var instancesDeclaration: {
  23755. name: string;
  23756. shader: string;
  23757. };
  23758. }
  23759. declare module "babylonjs/Shaders/ShadersInclude/geometryVertexDeclaration" {
  23760. /** @hidden */
  23761. export var geometryVertexDeclaration: {
  23762. name: string;
  23763. shader: string;
  23764. };
  23765. }
  23766. declare module "babylonjs/Shaders/ShadersInclude/geometryUboDeclaration" {
  23767. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  23768. /** @hidden */
  23769. export var geometryUboDeclaration: {
  23770. name: string;
  23771. shader: string;
  23772. };
  23773. }
  23774. declare module "babylonjs/Shaders/geometry.vertex" {
  23775. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  23776. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  23777. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  23778. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  23779. import "babylonjs/Shaders/ShadersInclude/geometryVertexDeclaration";
  23780. import "babylonjs/Shaders/ShadersInclude/geometryUboDeclaration";
  23781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal";
  23782. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  23783. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  23784. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  23785. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  23786. /** @hidden */
  23787. export var geometryVertexShader: {
  23788. name: string;
  23789. shader: string;
  23790. };
  23791. }
  23792. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  23793. import { Matrix } from "babylonjs/Maths/math.vector";
  23794. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23795. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23796. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23797. import { Effect } from "babylonjs/Materials/effect";
  23798. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23799. import { Scene } from "babylonjs/scene";
  23800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23801. import { Nullable } from "babylonjs/types";
  23802. import "babylonjs/Shaders/geometry.fragment";
  23803. import "babylonjs/Shaders/geometry.vertex";
  23804. /** @hidden */
  23805. interface ISavedTransformationMatrix {
  23806. world: Matrix;
  23807. viewProjection: Matrix;
  23808. }
  23809. /**
  23810. * This renderer is helpful to fill one of the render target with a geometry buffer.
  23811. */
  23812. export class GeometryBufferRenderer {
  23813. /**
  23814. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  23815. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  23816. */
  23817. static readonly DEPTH_TEXTURE_TYPE: number;
  23818. /**
  23819. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  23820. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  23821. */
  23822. static readonly NORMAL_TEXTURE_TYPE: number;
  23823. /**
  23824. * Constant used to retrieve the position texture index in the G-Buffer textures array
  23825. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  23826. */
  23827. static readonly POSITION_TEXTURE_TYPE: number;
  23828. /**
  23829. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  23830. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  23831. */
  23832. static readonly VELOCITY_TEXTURE_TYPE: number;
  23833. /**
  23834. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  23835. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  23836. */
  23837. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  23838. /**
  23839. * Dictionary used to store the previous transformation matrices of each rendered mesh
  23840. * in order to compute objects velocities when enableVelocity is set to "true"
  23841. * @hidden
  23842. */
  23843. _previousTransformationMatrices: {
  23844. [index: number]: ISavedTransformationMatrix;
  23845. };
  23846. /**
  23847. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  23848. * in order to compute objects velocities when enableVelocity is set to "true"
  23849. * @hidden
  23850. */
  23851. _previousBonesTransformationMatrices: {
  23852. [index: number]: Float32Array;
  23853. };
  23854. /**
  23855. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  23856. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  23857. */
  23858. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  23859. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  23860. renderTransparentMeshes: boolean;
  23861. private _scene;
  23862. private _resizeObserver;
  23863. private _multiRenderTarget;
  23864. private _ratio;
  23865. private _enablePosition;
  23866. private _enableVelocity;
  23867. private _enableReflectivity;
  23868. private _positionIndex;
  23869. private _velocityIndex;
  23870. private _reflectivityIndex;
  23871. private _depthIndex;
  23872. private _normalIndex;
  23873. private _linkedWithPrePass;
  23874. private _prePassRenderer;
  23875. private _attachments;
  23876. private _useUbo;
  23877. protected _effect: Effect;
  23878. protected _cachedDefines: string;
  23879. /**
  23880. * @hidden
  23881. * Sets up internal structures to share outputs with PrePassRenderer
  23882. * This method should only be called by the PrePassRenderer itself
  23883. */
  23884. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23885. /**
  23886. * @hidden
  23887. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23888. * This method should only be called by the PrePassRenderer itself
  23889. */
  23890. _unlinkPrePassRenderer(): void;
  23891. /**
  23892. * @hidden
  23893. * Resets the geometry buffer layout
  23894. */
  23895. _resetLayout(): void;
  23896. /**
  23897. * @hidden
  23898. * Replaces a texture in the geometry buffer renderer
  23899. * Useful when linking textures of the prepass renderer
  23900. */
  23901. _forceTextureType(geometryBufferType: number, index: number): void;
  23902. /**
  23903. * @hidden
  23904. * Sets texture attachments
  23905. * Useful when linking textures of the prepass renderer
  23906. */
  23907. _setAttachments(attachments: number[]): void;
  23908. /**
  23909. * @hidden
  23910. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23911. * Useful when linking textures of the prepass renderer
  23912. */
  23913. _linkInternalTexture(internalTexture: InternalTexture): void;
  23914. /**
  23915. * Gets the render list (meshes to be rendered) used in the G buffer.
  23916. */
  23917. get renderList(): Nullable<AbstractMesh[]>;
  23918. /**
  23919. * Set the render list (meshes to be rendered) used in the G buffer.
  23920. */
  23921. set renderList(meshes: Nullable<AbstractMesh[]>);
  23922. /**
  23923. * Gets whether or not G buffer are supported by the running hardware.
  23924. * This requires draw buffer supports
  23925. */
  23926. get isSupported(): boolean;
  23927. /**
  23928. * Returns the index of the given texture type in the G-Buffer textures array
  23929. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23930. * @returns the index of the given texture type in the G-Buffer textures array
  23931. */
  23932. getTextureIndex(textureType: number): number;
  23933. /**
  23934. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23935. */
  23936. get enablePosition(): boolean;
  23937. /**
  23938. * Sets whether or not objects positions are enabled for the G buffer.
  23939. */
  23940. set enablePosition(enable: boolean);
  23941. /**
  23942. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23943. */
  23944. get enableVelocity(): boolean;
  23945. /**
  23946. * Sets whether or not objects velocities are enabled for the G buffer.
  23947. */
  23948. set enableVelocity(enable: boolean);
  23949. /**
  23950. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23951. */
  23952. get enableReflectivity(): boolean;
  23953. /**
  23954. * Sets whether or not objects roughness are enabled for the G buffer.
  23955. */
  23956. set enableReflectivity(enable: boolean);
  23957. /**
  23958. * Gets the scene associated with the buffer.
  23959. */
  23960. get scene(): Scene;
  23961. /**
  23962. * Gets the ratio used by the buffer during its creation.
  23963. * How big is the buffer related to the main canvas.
  23964. */
  23965. get ratio(): number;
  23966. /** @hidden */
  23967. static _SceneComponentInitialization: (scene: Scene) => void;
  23968. /**
  23969. * Creates a new G Buffer for the scene
  23970. * @param scene The scene the buffer belongs to
  23971. * @param ratio How big is the buffer related to the main canvas.
  23972. */
  23973. constructor(scene: Scene, ratio?: number);
  23974. /**
  23975. * Checks whether everything is ready to render a submesh to the G buffer.
  23976. * @param subMesh the submesh to check readiness for
  23977. * @param useInstances is the mesh drawn using instance or not
  23978. * @returns true if ready otherwise false
  23979. */
  23980. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23981. /**
  23982. * Gets the current underlying G Buffer.
  23983. * @returns the buffer
  23984. */
  23985. getGBuffer(): MultiRenderTarget;
  23986. /**
  23987. * Gets the number of samples used to render the buffer (anti aliasing).
  23988. */
  23989. get samples(): number;
  23990. /**
  23991. * Sets the number of samples used to render the buffer (anti aliasing).
  23992. */
  23993. set samples(value: number);
  23994. /**
  23995. * Disposes the renderer and frees up associated resources.
  23996. */
  23997. dispose(): void;
  23998. private _assignRenderTargetIndices;
  23999. protected _createRenderTargets(): void;
  24000. private _copyBonesTransformationMatrices;
  24001. }
  24002. }
  24003. declare module "babylonjs/Rendering/prePassRenderer" {
  24004. import { PrePassRenderTarget } from "babylonjs/Materials/Textures/prePassRenderTarget";
  24005. import { Scene } from "babylonjs/scene";
  24006. import { Effect } from "babylonjs/Materials/effect";
  24007. import { Nullable } from "babylonjs/types";
  24008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24009. import { Camera } from "babylonjs/Cameras/camera";
  24010. import { Material } from "babylonjs/Materials/material";
  24011. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24012. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24014. /**
  24015. * Renders a pre pass of the scene
  24016. * This means every mesh in the scene will be rendered to a render target texture
  24017. * And then this texture will be composited to the rendering canvas with post processes
  24018. * It is necessary for effects like subsurface scattering or deferred shading
  24019. */
  24020. export class PrePassRenderer {
  24021. /** @hidden */
  24022. static _SceneComponentInitialization: (scene: Scene) => void;
  24023. /**
  24024. * To save performance, we can excluded skinned meshes from the prepass
  24025. */
  24026. excludedSkinnedMesh: AbstractMesh[];
  24027. /**
  24028. * Force material to be excluded from the prepass
  24029. * Can be useful when `useGeometryBufferFallback` is set to `true`
  24030. * and you don't want a material to show in the effect.
  24031. */
  24032. excludedMaterials: Material[];
  24033. private _scene;
  24034. private _engine;
  24035. /**
  24036. * Number of textures in the multi render target texture where the scene is directly rendered
  24037. */
  24038. mrtCount: number;
  24039. private _mrtFormats;
  24040. private _mrtLayout;
  24041. private _textureIndices;
  24042. private _multiRenderAttachments;
  24043. private _defaultAttachments;
  24044. private _clearAttachments;
  24045. /**
  24046. * Returns the index of a texture in the multi render target texture array.
  24047. * @param type Texture type
  24048. * @return The index
  24049. */
  24050. getIndex(type: number): number;
  24051. /**
  24052. * How many samples are used for MSAA of the scene render target
  24053. */
  24054. get samples(): number;
  24055. set samples(n: number);
  24056. private static _textureFormats;
  24057. private _isDirty;
  24058. /**
  24059. * The render target where the scene is directly rendered
  24060. */
  24061. defaultRT: PrePassRenderTarget;
  24062. /**
  24063. * Configuration for prepass effects
  24064. */
  24065. private _effectConfigurations;
  24066. /**
  24067. * @return the prepass render target for the rendering pass.
  24068. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  24069. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  24070. */
  24071. getRenderTarget(): PrePassRenderTarget;
  24072. /**
  24073. * @hidden
  24074. * Managed by the scene component
  24075. * @param prePassRenderTarget
  24076. */
  24077. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  24078. /**
  24079. * Returns true if the currently rendered prePassRenderTarget is the one
  24080. * associated with the scene.
  24081. */
  24082. get currentRTisSceneRT(): boolean;
  24083. private _geometryBuffer;
  24084. /**
  24085. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  24086. */
  24087. doNotUseGeometryRendererFallback: boolean;
  24088. private _refreshGeometryBufferRendererLink;
  24089. private _currentTarget;
  24090. /**
  24091. * All the render targets generated by prepass
  24092. */
  24093. renderTargets: PrePassRenderTarget[];
  24094. private readonly _clearColor;
  24095. private _enabled;
  24096. private _needsCompositionForThisPass;
  24097. private _postProcessesSourceForThisPass;
  24098. /**
  24099. * Indicates if the prepass is enabled
  24100. */
  24101. get enabled(): boolean;
  24102. /**
  24103. * Set to true to disable gamma transform in PrePass.
  24104. * Can be useful in case you already proceed to gamma transform on a material level
  24105. * and your post processes don't need to be in linear color space.
  24106. */
  24107. disableGammaTransform: boolean;
  24108. /**
  24109. * Instanciates a prepass renderer
  24110. * @param scene The scene
  24111. */
  24112. constructor(scene: Scene);
  24113. /**
  24114. * Creates a new PrePassRenderTarget
  24115. * This should be the only way to instanciate a `PrePassRenderTarget`
  24116. * @param name Name of the `PrePassRenderTarget`
  24117. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  24118. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  24119. * @hidden
  24120. */
  24121. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  24122. /**
  24123. * Indicates if rendering a prepass is supported
  24124. */
  24125. get isSupported(): boolean;
  24126. /**
  24127. * Sets the proper output textures to draw in the engine.
  24128. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24129. * @param subMesh Submesh on which the effect is applied
  24130. */
  24131. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  24132. private _reinitializeAttachments;
  24133. private _resetLayout;
  24134. private _updateGeometryBufferLayout;
  24135. /**
  24136. * Restores attachments for single texture draw.
  24137. */
  24138. restoreAttachments(): void;
  24139. /**
  24140. * @hidden
  24141. */
  24142. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  24143. private _prepareFrame;
  24144. private _renderPostProcesses;
  24145. /**
  24146. * @hidden
  24147. */
  24148. _afterDraw(faceIndex?: number, layer?: number): void;
  24149. /**
  24150. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  24151. * @hidden
  24152. */
  24153. _clear(): void;
  24154. private _bindFrameBuffer;
  24155. private _setEnabled;
  24156. private _setRenderTargetEnabled;
  24157. /**
  24158. * Adds an effect configuration to the prepass render target.
  24159. * If an effect has already been added, it won't add it twice and will return the configuration
  24160. * already present.
  24161. * @param cfg the effect configuration
  24162. * @return the effect configuration now used by the prepass
  24163. */
  24164. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  24165. private _enable;
  24166. private _disable;
  24167. private _getPostProcessesSource;
  24168. private _setupOutputForThisPass;
  24169. private _linkInternalTexture;
  24170. private _needsImageProcessing;
  24171. private _hasImageProcessing;
  24172. /**
  24173. * Internal, gets the first post proces.
  24174. * @returns the first post process to be run on this camera.
  24175. */
  24176. private _getFirstPostProcess;
  24177. /**
  24178. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24179. */
  24180. markAsDirty(): void;
  24181. /**
  24182. * Enables a texture on the MultiRenderTarget for prepass
  24183. */
  24184. private _enableTextures;
  24185. private _update;
  24186. private _markAllMaterialsAsPrePassDirty;
  24187. /**
  24188. * Disposes the prepass renderer.
  24189. */
  24190. dispose(): void;
  24191. }
  24192. }
  24193. declare module "babylonjs/PostProcesses/postProcess" {
  24194. import { Nullable } from "babylonjs/types";
  24195. import { SmartArray } from "babylonjs/Misc/smartArray";
  24196. import { Observable } from "babylonjs/Misc/observable";
  24197. import { Vector2 } from "babylonjs/Maths/math.vector";
  24198. import { Camera } from "babylonjs/Cameras/camera";
  24199. import { Effect } from "babylonjs/Materials/effect";
  24200. import "babylonjs/Shaders/postprocess.vertex";
  24201. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24202. import { Engine } from "babylonjs/Engines/engine";
  24203. import { Color4 } from "babylonjs/Maths/math.color";
  24204. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24205. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  24206. import { Scene } from "babylonjs/scene";
  24207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24208. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  24209. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24210. /**
  24211. * Size options for a post process
  24212. */
  24213. export type PostProcessOptions = {
  24214. width: number;
  24215. height: number;
  24216. };
  24217. /**
  24218. * PostProcess can be used to apply a shader to a texture after it has been rendered
  24219. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24220. */
  24221. export class PostProcess {
  24222. /**
  24223. * Gets or sets the unique id of the post process
  24224. */
  24225. uniqueId: number;
  24226. /** Name of the PostProcess. */
  24227. name: string;
  24228. /**
  24229. * Width of the texture to apply the post process on
  24230. */
  24231. width: number;
  24232. /**
  24233. * Height of the texture to apply the post process on
  24234. */
  24235. height: number;
  24236. /**
  24237. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  24238. */
  24239. nodeMaterialSource: Nullable<NodeMaterial>;
  24240. /**
  24241. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  24242. * @hidden
  24243. */
  24244. _outputTexture: Nullable<InternalTexture>;
  24245. /**
  24246. * Sampling mode used by the shader
  24247. * See https://doc.babylonjs.com/classes/3.1/texture
  24248. */
  24249. renderTargetSamplingMode: number;
  24250. /**
  24251. * Clear color to use when screen clearing
  24252. */
  24253. clearColor: Color4;
  24254. /**
  24255. * If the buffer needs to be cleared before applying the post process. (default: true)
  24256. * Should be set to false if shader will overwrite all previous pixels.
  24257. */
  24258. autoClear: boolean;
  24259. /**
  24260. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  24261. */
  24262. alphaMode: number;
  24263. /**
  24264. * Sets the setAlphaBlendConstants of the babylon engine
  24265. */
  24266. alphaConstants: Color4;
  24267. /**
  24268. * Animations to be used for the post processing
  24269. */
  24270. animations: import("babylonjs/Animations/animation").Animation[];
  24271. /**
  24272. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  24273. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  24274. */
  24275. enablePixelPerfectMode: boolean;
  24276. /**
  24277. * Force the postprocess to be applied without taking in account viewport
  24278. */
  24279. forceFullscreenViewport: boolean;
  24280. /**
  24281. * List of inspectable custom properties (used by the Inspector)
  24282. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24283. */
  24284. inspectableCustomProperties: IInspectable[];
  24285. /**
  24286. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  24287. *
  24288. * | Value | Type | Description |
  24289. * | ----- | ----------------------------------- | ----------- |
  24290. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  24291. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  24292. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  24293. *
  24294. */
  24295. scaleMode: number;
  24296. /**
  24297. * Force textures to be a power of two (default: false)
  24298. */
  24299. alwaysForcePOT: boolean;
  24300. private _samples;
  24301. /**
  24302. * Number of sample textures (default: 1)
  24303. */
  24304. get samples(): number;
  24305. set samples(n: number);
  24306. /**
  24307. * Modify the scale of the post process to be the same as the viewport (default: false)
  24308. */
  24309. adaptScaleToCurrentViewport: boolean;
  24310. private _camera;
  24311. protected _scene: Scene;
  24312. private _engine;
  24313. private _options;
  24314. private _reusable;
  24315. private _renderId;
  24316. private _textureType;
  24317. private _textureFormat;
  24318. /**
  24319. * Smart array of input and output textures for the post process.
  24320. * @hidden
  24321. */
  24322. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  24323. /**
  24324. * Smart array of input and output textures for the post process.
  24325. * @hidden
  24326. */
  24327. private _textureCache;
  24328. /**
  24329. * The index in _textures that corresponds to the output texture.
  24330. * @hidden
  24331. */
  24332. _currentRenderTextureInd: number;
  24333. private _effect;
  24334. private _samplers;
  24335. private _fragmentUrl;
  24336. private _vertexUrl;
  24337. private _parameters;
  24338. protected _postProcessDefines: Nullable<string>;
  24339. private _scaleRatio;
  24340. protected _indexParameters: any;
  24341. private _shareOutputWithPostProcess;
  24342. private _texelSize;
  24343. /** @hidden */
  24344. _forcedOutputTexture: Nullable<InternalTexture>;
  24345. /**
  24346. * Prepass configuration in case this post process needs a texture from prepass
  24347. * @hidden
  24348. */
  24349. _prePassEffectConfiguration: PrePassEffectConfiguration;
  24350. /**
  24351. * Returns the fragment url or shader name used in the post process.
  24352. * @returns the fragment url or name in the shader store.
  24353. */
  24354. getEffectName(): string;
  24355. /**
  24356. * An event triggered when the postprocess is activated.
  24357. */
  24358. onActivateObservable: Observable<Camera>;
  24359. private _onActivateObserver;
  24360. /**
  24361. * A function that is added to the onActivateObservable
  24362. */
  24363. set onActivate(callback: Nullable<(camera: Camera) => void>);
  24364. /**
  24365. * An event triggered when the postprocess changes its size.
  24366. */
  24367. onSizeChangedObservable: Observable<PostProcess>;
  24368. private _onSizeChangedObserver;
  24369. /**
  24370. * A function that is added to the onSizeChangedObservable
  24371. */
  24372. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  24373. /**
  24374. * An event triggered when the postprocess applies its effect.
  24375. */
  24376. onApplyObservable: Observable<Effect>;
  24377. private _onApplyObserver;
  24378. /**
  24379. * A function that is added to the onApplyObservable
  24380. */
  24381. set onApply(callback: (effect: Effect) => void);
  24382. /**
  24383. * An event triggered before rendering the postprocess
  24384. */
  24385. onBeforeRenderObservable: Observable<Effect>;
  24386. private _onBeforeRenderObserver;
  24387. /**
  24388. * A function that is added to the onBeforeRenderObservable
  24389. */
  24390. set onBeforeRender(callback: (effect: Effect) => void);
  24391. /**
  24392. * An event triggered after rendering the postprocess
  24393. */
  24394. onAfterRenderObservable: Observable<Effect>;
  24395. private _onAfterRenderObserver;
  24396. /**
  24397. * A function that is added to the onAfterRenderObservable
  24398. */
  24399. set onAfterRender(callback: (efect: Effect) => void);
  24400. /**
  24401. * 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
  24402. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24403. */
  24404. get inputTexture(): InternalTexture;
  24405. set inputTexture(value: InternalTexture);
  24406. /**
  24407. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  24408. * the only way to unset it is to use this function to restore its internal state
  24409. */
  24410. restoreDefaultInputTexture(): void;
  24411. /**
  24412. * Gets the camera which post process is applied to.
  24413. * @returns The camera the post process is applied to.
  24414. */
  24415. getCamera(): Camera;
  24416. /**
  24417. * Gets the texel size of the postprocess.
  24418. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24419. */
  24420. get texelSize(): Vector2;
  24421. /**
  24422. * Creates a new instance PostProcess
  24423. * @param name The name of the PostProcess.
  24424. * @param fragmentUrl The url of the fragment shader to be used.
  24425. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24426. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24427. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24428. * @param camera The camera to apply the render pass to.
  24429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24430. * @param engine The engine which the post process will be applied. (default: current engine)
  24431. * @param reusable If the post process can be reused on the same frame. (default: false)
  24432. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24433. * @param textureType Type of textures used when performing the post process. (default: 0)
  24434. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24435. * @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
  24436. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  24437. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  24438. */
  24439. 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);
  24440. /**
  24441. * Gets a string identifying the name of the class
  24442. * @returns "PostProcess" string
  24443. */
  24444. getClassName(): string;
  24445. /**
  24446. * Gets the engine which this post process belongs to.
  24447. * @returns The engine the post process was enabled with.
  24448. */
  24449. getEngine(): Engine;
  24450. /**
  24451. * The effect that is created when initializing the post process.
  24452. * @returns The created effect corresponding the the postprocess.
  24453. */
  24454. getEffect(): Effect;
  24455. /**
  24456. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24457. * @param postProcess The post process to share the output with.
  24458. * @returns This post process.
  24459. */
  24460. shareOutputWith(postProcess: PostProcess): PostProcess;
  24461. /**
  24462. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24463. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24464. */
  24465. useOwnOutput(): void;
  24466. /**
  24467. * Updates the effect with the current post process compile time values and recompiles the shader.
  24468. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24469. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24470. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24471. * @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
  24472. * @param onCompiled Called when the shader has been compiled.
  24473. * @param onError Called if there is an error when compiling a shader.
  24474. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  24475. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  24476. */
  24477. 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;
  24478. /**
  24479. * The post process is reusable if it can be used multiple times within one frame.
  24480. * @returns If the post process is reusable
  24481. */
  24482. isReusable(): boolean;
  24483. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24484. markTextureDirty(): void;
  24485. private _createRenderTargetTexture;
  24486. private _flushTextureCache;
  24487. private _resize;
  24488. /**
  24489. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24490. * 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.
  24491. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24492. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24493. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24494. * @returns The target texture that was bound to be written to.
  24495. */
  24496. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24497. /**
  24498. * If the post process is supported.
  24499. */
  24500. get isSupported(): boolean;
  24501. /**
  24502. * The aspect ratio of the output texture.
  24503. */
  24504. get aspectRatio(): number;
  24505. /**
  24506. * Get a value indicating if the post-process is ready to be used
  24507. * @returns true if the post-process is ready (shader is compiled)
  24508. */
  24509. isReady(): boolean;
  24510. /**
  24511. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24512. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  24513. */
  24514. apply(): Nullable<Effect>;
  24515. private _disposeTextures;
  24516. private _disposeTextureCache;
  24517. /**
  24518. * Sets the required values to the prepass renderer.
  24519. * @param prePassRenderer defines the prepass renderer to setup.
  24520. * @returns true if the pre pass is needed.
  24521. */
  24522. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24523. /**
  24524. * Disposes the post process.
  24525. * @param camera The camera to dispose the post process on.
  24526. */
  24527. dispose(camera?: Camera): void;
  24528. /**
  24529. * Serializes the particle system to a JSON object
  24530. * @returns the JSON object
  24531. */
  24532. serialize(): any;
  24533. /**
  24534. * Clones this post process
  24535. * @returns a new post process similar to this one
  24536. */
  24537. clone(): Nullable<PostProcess>;
  24538. /**
  24539. * Creates a material from parsed material data
  24540. * @param parsedPostProcess defines parsed post process data
  24541. * @param scene defines the hosting scene
  24542. * @param rootUrl defines the root URL to use to load textures
  24543. * @returns a new post process
  24544. */
  24545. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24546. /** @hidden */
  24547. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24548. }
  24549. }
  24550. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  24551. /** @hidden */
  24552. export var kernelBlurVaryingDeclaration: {
  24553. name: string;
  24554. shader: string;
  24555. };
  24556. }
  24557. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  24558. /** @hidden */
  24559. export var packingFunctions: {
  24560. name: string;
  24561. shader: string;
  24562. };
  24563. }
  24564. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  24565. /** @hidden */
  24566. export var kernelBlurFragment: {
  24567. name: string;
  24568. shader: string;
  24569. };
  24570. }
  24571. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  24572. /** @hidden */
  24573. export var kernelBlurFragment2: {
  24574. name: string;
  24575. shader: string;
  24576. };
  24577. }
  24578. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  24579. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24580. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  24581. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  24582. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  24583. /** @hidden */
  24584. export var kernelBlurPixelShader: {
  24585. name: string;
  24586. shader: string;
  24587. };
  24588. }
  24589. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  24590. /** @hidden */
  24591. export var kernelBlurVertex: {
  24592. name: string;
  24593. shader: string;
  24594. };
  24595. }
  24596. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  24597. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24598. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  24599. /** @hidden */
  24600. export var kernelBlurVertexShader: {
  24601. name: string;
  24602. shader: string;
  24603. };
  24604. }
  24605. declare module "babylonjs/PostProcesses/blurPostProcess" {
  24606. import { Vector2 } from "babylonjs/Maths/math.vector";
  24607. import { Nullable } from "babylonjs/types";
  24608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24609. import { Camera } from "babylonjs/Cameras/camera";
  24610. import { Effect } from "babylonjs/Materials/effect";
  24611. import { Engine } from "babylonjs/Engines/engine";
  24612. import "babylonjs/Shaders/kernelBlur.fragment";
  24613. import "babylonjs/Shaders/kernelBlur.vertex";
  24614. import { Scene } from "babylonjs/scene";
  24615. /**
  24616. * The Blur Post Process which blurs an image based on a kernel and direction.
  24617. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  24618. */
  24619. export class BlurPostProcess extends PostProcess {
  24620. private blockCompilation;
  24621. protected _kernel: number;
  24622. protected _idealKernel: number;
  24623. protected _packedFloat: boolean;
  24624. private _staticDefines;
  24625. /** The direction in which to blur the image. */
  24626. direction: Vector2;
  24627. /**
  24628. * Sets the length in pixels of the blur sample region
  24629. */
  24630. set kernel(v: number);
  24631. /**
  24632. * Gets the length in pixels of the blur sample region
  24633. */
  24634. get kernel(): number;
  24635. /**
  24636. * Sets whether or not the blur needs to unpack/repack floats
  24637. */
  24638. set packedFloat(v: boolean);
  24639. /**
  24640. * Gets whether or not the blur is unpacking/repacking floats
  24641. */
  24642. get packedFloat(): boolean;
  24643. /**
  24644. * Gets a string identifying the name of the class
  24645. * @returns "BlurPostProcess" string
  24646. */
  24647. getClassName(): string;
  24648. /**
  24649. * Creates a new instance BlurPostProcess
  24650. * @param name The name of the effect.
  24651. * @param direction The direction in which to blur the image.
  24652. * @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.
  24653. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24654. * @param camera The camera to apply the render pass to.
  24655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24656. * @param engine The engine which the post process will be applied. (default: current engine)
  24657. * @param reusable If the post process can be reused on the same frame. (default: false)
  24658. * @param textureType Type of textures used when performing the post process. (default: 0)
  24659. * @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)
  24660. */
  24661. 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);
  24662. /**
  24663. * Updates the effect with the current post process compile time values and recompiles the shader.
  24664. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24665. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24666. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24667. * @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
  24668. * @param onCompiled Called when the shader has been compiled.
  24669. * @param onError Called if there is an error when compiling a shader.
  24670. */
  24671. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24672. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24673. /**
  24674. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24675. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24676. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24677. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24678. * The gaps between physical kernels are compensated for in the weighting of the samples
  24679. * @param idealKernel Ideal blur kernel.
  24680. * @return Nearest best kernel.
  24681. */
  24682. protected _nearestBestKernel(idealKernel: number): number;
  24683. /**
  24684. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24685. * @param x The point on the Gaussian distribution to sample.
  24686. * @return the value of the Gaussian function at x.
  24687. */
  24688. protected _gaussianWeight(x: number): number;
  24689. /**
  24690. * Generates a string that can be used as a floating point number in GLSL.
  24691. * @param x Value to print.
  24692. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24693. * @return GLSL float string.
  24694. */
  24695. protected _glslFloat(x: number, decimalFigures?: number): string;
  24696. /** @hidden */
  24697. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24698. }
  24699. }
  24700. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24701. import { Scene } from "babylonjs/scene";
  24702. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24703. import { Plane } from "babylonjs/Maths/math.plane";
  24704. /**
  24705. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24706. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24707. * You can then easily use it as a reflectionTexture on a flat surface.
  24708. * In case the surface is not a plane, please consider relying on reflection probes.
  24709. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24710. */
  24711. export class MirrorTexture extends RenderTargetTexture {
  24712. private scene;
  24713. /**
  24714. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24715. * 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.
  24716. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24717. */
  24718. mirrorPlane: Plane;
  24719. /**
  24720. * Define the blur ratio used to blur the reflection if needed.
  24721. */
  24722. set blurRatio(value: number);
  24723. get blurRatio(): number;
  24724. /**
  24725. * Define the adaptive blur kernel used to blur the reflection if needed.
  24726. * This will autocompute the closest best match for the `blurKernel`
  24727. */
  24728. set adaptiveBlurKernel(value: number);
  24729. /**
  24730. * Define the blur kernel used to blur the reflection if needed.
  24731. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24732. */
  24733. set blurKernel(value: number);
  24734. /**
  24735. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24736. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24737. */
  24738. set blurKernelX(value: number);
  24739. get blurKernelX(): number;
  24740. /**
  24741. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24742. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24743. */
  24744. set blurKernelY(value: number);
  24745. get blurKernelY(): number;
  24746. private _autoComputeBlurKernel;
  24747. protected _onRatioRescale(): void;
  24748. private _updateGammaSpace;
  24749. private _imageProcessingConfigChangeObserver;
  24750. private _transformMatrix;
  24751. private _mirrorMatrix;
  24752. private _blurX;
  24753. private _blurY;
  24754. private _adaptiveBlurKernel;
  24755. private _blurKernelX;
  24756. private _blurKernelY;
  24757. private _blurRatio;
  24758. /**
  24759. * Instantiates a Mirror Texture.
  24760. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24761. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24762. * You can then easily use it as a reflectionTexture on a flat surface.
  24763. * In case the surface is not a plane, please consider relying on reflection probes.
  24764. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24765. * @param name
  24766. * @param size
  24767. * @param scene
  24768. * @param generateMipMaps
  24769. * @param type
  24770. * @param samplingMode
  24771. * @param generateDepthBuffer
  24772. */
  24773. constructor(name: string, size: number | {
  24774. width: number;
  24775. height: number;
  24776. } | {
  24777. ratio: number;
  24778. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24779. private _preparePostProcesses;
  24780. /**
  24781. * Clone the mirror texture.
  24782. * @returns the cloned texture
  24783. */
  24784. clone(): MirrorTexture;
  24785. /**
  24786. * Serialize the texture to a JSON representation you could use in Parse later on
  24787. * @returns the serialized JSON representation
  24788. */
  24789. serialize(): any;
  24790. /**
  24791. * Dispose the texture and release its associated resources.
  24792. */
  24793. dispose(): void;
  24794. }
  24795. }
  24796. declare module "babylonjs/Materials/Textures/texture" {
  24797. import { Observable } from "babylonjs/Misc/observable";
  24798. import { Nullable } from "babylonjs/types";
  24799. import { Matrix } from "babylonjs/Maths/math.vector";
  24800. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24801. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24802. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24803. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24804. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24806. import { Scene } from "babylonjs/scene";
  24807. /**
  24808. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24809. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24810. */
  24811. export class Texture extends BaseTexture {
  24812. /**
  24813. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24814. */
  24815. static SerializeBuffers: boolean;
  24816. /**
  24817. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  24818. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  24819. */
  24820. static ForceSerializeBuffers: boolean;
  24821. /** @hidden */
  24822. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24823. /** @hidden */
  24824. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24825. /** @hidden */
  24826. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24827. /** nearest is mag = nearest and min = nearest and mip = linear */
  24828. static readonly NEAREST_SAMPLINGMODE: number;
  24829. /** nearest is mag = nearest and min = nearest and mip = linear */
  24830. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24831. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24832. static readonly BILINEAR_SAMPLINGMODE: number;
  24833. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24834. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24835. /** Trilinear is mag = linear and min = linear and mip = linear */
  24836. static readonly TRILINEAR_SAMPLINGMODE: number;
  24837. /** Trilinear is mag = linear and min = linear and mip = linear */
  24838. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24839. /** mag = nearest and min = nearest and mip = nearest */
  24840. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24841. /** mag = nearest and min = linear and mip = nearest */
  24842. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24843. /** mag = nearest and min = linear and mip = linear */
  24844. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24845. /** mag = nearest and min = linear and mip = none */
  24846. static readonly NEAREST_LINEAR: number;
  24847. /** mag = nearest and min = nearest and mip = none */
  24848. static readonly NEAREST_NEAREST: number;
  24849. /** mag = linear and min = nearest and mip = nearest */
  24850. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24851. /** mag = linear and min = nearest and mip = linear */
  24852. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24853. /** mag = linear and min = linear and mip = none */
  24854. static readonly LINEAR_LINEAR: number;
  24855. /** mag = linear and min = nearest and mip = none */
  24856. static readonly LINEAR_NEAREST: number;
  24857. /** Explicit coordinates mode */
  24858. static readonly EXPLICIT_MODE: number;
  24859. /** Spherical coordinates mode */
  24860. static readonly SPHERICAL_MODE: number;
  24861. /** Planar coordinates mode */
  24862. static readonly PLANAR_MODE: number;
  24863. /** Cubic coordinates mode */
  24864. static readonly CUBIC_MODE: number;
  24865. /** Projection coordinates mode */
  24866. static readonly PROJECTION_MODE: number;
  24867. /** Inverse Cubic coordinates mode */
  24868. static readonly SKYBOX_MODE: number;
  24869. /** Inverse Cubic coordinates mode */
  24870. static readonly INVCUBIC_MODE: number;
  24871. /** Equirectangular coordinates mode */
  24872. static readonly EQUIRECTANGULAR_MODE: number;
  24873. /** Equirectangular Fixed coordinates mode */
  24874. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24875. /** Equirectangular Fixed Mirrored coordinates mode */
  24876. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24877. /** Texture is not repeating outside of 0..1 UVs */
  24878. static readonly CLAMP_ADDRESSMODE: number;
  24879. /** Texture is repeating outside of 0..1 UVs */
  24880. static readonly WRAP_ADDRESSMODE: number;
  24881. /** Texture is repeating and mirrored */
  24882. static readonly MIRROR_ADDRESSMODE: number;
  24883. /**
  24884. * 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
  24885. */
  24886. static UseSerializedUrlIfAny: boolean;
  24887. /**
  24888. * Define the url of the texture.
  24889. */
  24890. url: Nullable<string>;
  24891. /**
  24892. * Define an offset on the texture to offset the u coordinates of the UVs
  24893. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24894. */
  24895. uOffset: number;
  24896. /**
  24897. * Define an offset on the texture to offset the v coordinates of the UVs
  24898. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24899. */
  24900. vOffset: number;
  24901. /**
  24902. * Define an offset on the texture to scale the u coordinates of the UVs
  24903. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24904. */
  24905. uScale: number;
  24906. /**
  24907. * Define an offset on the texture to scale the v coordinates of the UVs
  24908. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24909. */
  24910. vScale: number;
  24911. /**
  24912. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24913. * @see https://doc.babylonjs.com/how_to/more_materials
  24914. */
  24915. uAng: number;
  24916. /**
  24917. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24918. * @see https://doc.babylonjs.com/how_to/more_materials
  24919. */
  24920. vAng: number;
  24921. /**
  24922. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24923. * @see https://doc.babylonjs.com/how_to/more_materials
  24924. */
  24925. wAng: number;
  24926. /**
  24927. * Defines the center of rotation (U)
  24928. */
  24929. uRotationCenter: number;
  24930. /**
  24931. * Defines the center of rotation (V)
  24932. */
  24933. vRotationCenter: number;
  24934. /**
  24935. * Defines the center of rotation (W)
  24936. */
  24937. wRotationCenter: number;
  24938. /**
  24939. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24940. */
  24941. homogeneousRotationInUVTransform: boolean;
  24942. /**
  24943. * Are mip maps generated for this texture or not.
  24944. */
  24945. get noMipmap(): boolean;
  24946. /**
  24947. * List of inspectable custom properties (used by the Inspector)
  24948. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24949. */
  24950. inspectableCustomProperties: Nullable<IInspectable[]>;
  24951. private _noMipmap;
  24952. /** @hidden */
  24953. _invertY: boolean;
  24954. private _rowGenerationMatrix;
  24955. private _cachedTextureMatrix;
  24956. private _projectionModeMatrix;
  24957. private _t0;
  24958. private _t1;
  24959. private _t2;
  24960. private _cachedUOffset;
  24961. private _cachedVOffset;
  24962. private _cachedUScale;
  24963. private _cachedVScale;
  24964. private _cachedUAng;
  24965. private _cachedVAng;
  24966. private _cachedWAng;
  24967. private _cachedProjectionMatrixId;
  24968. private _cachedURotationCenter;
  24969. private _cachedVRotationCenter;
  24970. private _cachedWRotationCenter;
  24971. private _cachedHomogeneousRotationInUVTransform;
  24972. private _cachedCoordinatesMode;
  24973. /** @hidden */
  24974. protected _initialSamplingMode: number;
  24975. /** @hidden */
  24976. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24977. private _deleteBuffer;
  24978. protected _format: Nullable<number>;
  24979. private _delayedOnLoad;
  24980. private _delayedOnError;
  24981. private _mimeType?;
  24982. private _loaderOptions?;
  24983. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24984. get mimeType(): string | undefined;
  24985. /**
  24986. * Observable triggered once the texture has been loaded.
  24987. */
  24988. onLoadObservable: Observable<Texture>;
  24989. protected _isBlocking: boolean;
  24990. /**
  24991. * Is the texture preventing material to render while loading.
  24992. * If false, a default texture will be used instead of the loading one during the preparation step.
  24993. */
  24994. set isBlocking(value: boolean);
  24995. get isBlocking(): boolean;
  24996. /**
  24997. * Get the current sampling mode associated with the texture.
  24998. */
  24999. get samplingMode(): number;
  25000. /**
  25001. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  25002. */
  25003. get invertY(): boolean;
  25004. /**
  25005. * Instantiates a new texture.
  25006. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  25007. * @see https://doc.babylonjs.com/babylon101/materials#texture
  25008. * @param url defines the url of the picture to load as a texture
  25009. * @param sceneOrEngine defines the scene or engine the texture will belong to
  25010. * @param noMipmap defines if the texture will require mip maps or not
  25011. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  25012. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  25013. * @param onLoad defines a callback triggered when the texture has been loaded
  25014. * @param onError defines a callback triggered when an error occurred during the loading session
  25015. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  25016. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  25017. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25018. * @param mimeType defines an optional mime type information
  25019. * @param loaderOptions options to be passed to the loader
  25020. */
  25021. 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);
  25022. /**
  25023. * Update the url (and optional buffer) of this texture if url was null during construction.
  25024. * @param url the url of the texture
  25025. * @param buffer the buffer of the texture (defaults to null)
  25026. * @param onLoad callback called when the texture is loaded (defaults to null)
  25027. */
  25028. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  25029. /**
  25030. * Finish the loading sequence of a texture flagged as delayed load.
  25031. * @hidden
  25032. */
  25033. delayLoad(): void;
  25034. private _prepareRowForTextureGeneration;
  25035. /**
  25036. * Checks if the texture has the same transform matrix than another texture
  25037. * @param texture texture to check against
  25038. * @returns true if the transforms are the same, else false
  25039. */
  25040. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  25041. /**
  25042. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  25043. * @returns the transform matrix of the texture.
  25044. */
  25045. getTextureMatrix(uBase?: number): Matrix;
  25046. /**
  25047. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  25048. * @returns The reflection texture transform
  25049. */
  25050. getReflectionTextureMatrix(): Matrix;
  25051. /**
  25052. * Clones the texture.
  25053. * @returns the cloned texture
  25054. */
  25055. clone(): Texture;
  25056. /**
  25057. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  25058. * @returns The JSON representation of the texture
  25059. */
  25060. serialize(): any;
  25061. /**
  25062. * Get the current class name of the texture useful for serialization or dynamic coding.
  25063. * @returns "Texture"
  25064. */
  25065. getClassName(): string;
  25066. /**
  25067. * Dispose the texture and release its associated resources.
  25068. */
  25069. dispose(): void;
  25070. /**
  25071. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  25072. * @param parsedTexture Define the JSON representation of the texture
  25073. * @param scene Define the scene the parsed texture should be instantiated in
  25074. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  25075. * @returns The parsed texture if successful
  25076. */
  25077. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  25078. /**
  25079. * Creates a texture from its base 64 representation.
  25080. * @param data Define the base64 payload without the data: prefix
  25081. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  25082. * @param scene Define the scene the texture should belong to
  25083. * @param noMipmap Forces the texture to not create mip map information if true
  25084. * @param invertY define if the texture needs to be inverted on the y axis during loading
  25085. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  25086. * @param onLoad define a callback triggered when the texture has been loaded
  25087. * @param onError define a callback triggered when an error occurred during the loading session
  25088. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25089. * @returns the created texture
  25090. */
  25091. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  25092. /**
  25093. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  25094. * @param data Define the base64 payload without the data: prefix
  25095. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  25096. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  25097. * @param scene Define the scene the texture should belong to
  25098. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  25099. * @param noMipmap Forces the texture to not create mip map information if true
  25100. * @param invertY define if the texture needs to be inverted on the y axis during loading
  25101. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  25102. * @param onLoad define a callback triggered when the texture has been loaded
  25103. * @param onError define a callback triggered when an error occurred during the loading session
  25104. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25105. * @returns the created texture
  25106. */
  25107. 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;
  25108. }
  25109. }
  25110. declare module "babylonjs/Sprites/thinSprite" {
  25111. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  25112. import { Nullable } from "babylonjs/types";
  25113. /**
  25114. * ThinSprite Class used to represent a thin sprite
  25115. * This is the base class for sprites but can also directly be used with ThinEngine
  25116. * @see https://doc.babylonjs.com/babylon101/sprites
  25117. */
  25118. export class ThinSprite {
  25119. /** Gets or sets the cell index in the sprite sheet */
  25120. cellIndex: number;
  25121. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  25122. cellRef: string;
  25123. /** Gets or sets the current world position */
  25124. position: IVector3Like;
  25125. /** Gets or sets the main color */
  25126. color: IColor4Like;
  25127. /** Gets or sets the width */
  25128. width: number;
  25129. /** Gets or sets the height */
  25130. height: number;
  25131. /** Gets or sets rotation angle */
  25132. angle: number;
  25133. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  25134. invertU: boolean;
  25135. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  25136. invertV: boolean;
  25137. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  25138. isVisible: boolean;
  25139. /**
  25140. * Returns a boolean indicating if the animation is started
  25141. */
  25142. get animationStarted(): boolean;
  25143. /** Gets the initial key for the animation (setting it will restart the animation) */
  25144. get fromIndex(): number;
  25145. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  25146. get toIndex(): number;
  25147. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  25148. get loopAnimation(): boolean;
  25149. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  25150. get delay(): number;
  25151. /** @hidden */
  25152. _xOffset: number;
  25153. /** @hidden */
  25154. _yOffset: number;
  25155. /** @hidden */
  25156. _xSize: number;
  25157. /** @hidden */
  25158. _ySize: number;
  25159. private _animationStarted;
  25160. protected _loopAnimation: boolean;
  25161. protected _fromIndex: number;
  25162. protected _toIndex: number;
  25163. protected _delay: number;
  25164. private _direction;
  25165. private _time;
  25166. private _onBaseAnimationEnd;
  25167. /**
  25168. * Creates a new Thin Sprite
  25169. */
  25170. constructor();
  25171. /**
  25172. * Starts an animation
  25173. * @param from defines the initial key
  25174. * @param to defines the end key
  25175. * @param loop defines if the animation must loop
  25176. * @param delay defines the start delay (in ms)
  25177. * @param onAnimationEnd defines a callback for when the animation ends
  25178. */
  25179. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  25180. /** Stops current animation (if any) */
  25181. stopAnimation(): void;
  25182. /** @hidden */
  25183. _animate(deltaTime: number): void;
  25184. }
  25185. }
  25186. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  25187. /** @hidden */
  25188. export var imageProcessingCompatibility: {
  25189. name: string;
  25190. shader: string;
  25191. };
  25192. }
  25193. declare module "babylonjs/Shaders/sprites.fragment" {
  25194. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  25195. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  25196. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  25197. /** @hidden */
  25198. export var spritesPixelShader: {
  25199. name: string;
  25200. shader: string;
  25201. };
  25202. }
  25203. declare module "babylonjs/Shaders/sprites.vertex" {
  25204. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  25205. /** @hidden */
  25206. export var spritesVertexShader: {
  25207. name: string;
  25208. shader: string;
  25209. };
  25210. }
  25211. declare module "babylonjs/Sprites/spriteRenderer" {
  25212. import { Nullable } from "babylonjs/types";
  25213. import { IMatrixLike } from "babylonjs/Maths/math.like";
  25214. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  25215. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  25216. import { ISize } from "babylonjs/Maths/math.size";
  25217. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  25218. import { Scene } from "babylonjs/scene";
  25219. import "babylonjs/Engines/Extensions/engine.alpha";
  25220. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  25221. import "babylonjs/Shaders/sprites.fragment";
  25222. import "babylonjs/Shaders/sprites.vertex";
  25223. /**
  25224. * Class used to render sprites.
  25225. *
  25226. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  25227. */
  25228. export class SpriteRenderer {
  25229. /**
  25230. * Defines the texture of the spritesheet
  25231. */
  25232. texture: Nullable<ThinTexture>;
  25233. /**
  25234. * Defines the default width of a cell in the spritesheet
  25235. */
  25236. cellWidth: number;
  25237. /**
  25238. * Defines the default height of a cell in the spritesheet
  25239. */
  25240. cellHeight: number;
  25241. /**
  25242. * Blend mode use to render the particle, it can be any of
  25243. * the static Constants.ALPHA_x properties provided in this class.
  25244. * Default value is Constants.ALPHA_COMBINE
  25245. */
  25246. blendMode: number;
  25247. /**
  25248. * Gets or sets a boolean indicating if alpha mode is automatically
  25249. * reset.
  25250. */
  25251. autoResetAlpha: boolean;
  25252. /**
  25253. * Disables writing to the depth buffer when rendering the sprites.
  25254. * It can be handy to disable depth writing when using textures without alpha channel
  25255. * and setting some specific blend modes.
  25256. */
  25257. disableDepthWrite: boolean;
  25258. /**
  25259. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  25260. */
  25261. fogEnabled: boolean;
  25262. /**
  25263. * Gets the capacity of the manager
  25264. */
  25265. get capacity(): number;
  25266. private readonly _engine;
  25267. private readonly _useVAO;
  25268. private readonly _useInstancing;
  25269. private readonly _scene;
  25270. private readonly _capacity;
  25271. private readonly _epsilon;
  25272. private _vertexBufferSize;
  25273. private _vertexData;
  25274. private _buffer;
  25275. private _vertexBuffers;
  25276. private _spriteBuffer;
  25277. private _indexBuffer;
  25278. private _effectBase;
  25279. private _effectFog;
  25280. private _vertexArrayObject;
  25281. /**
  25282. * Creates a new sprite Renderer
  25283. * @param engine defines the engine the renderer works with
  25284. * @param capacity defines the maximum allowed number of sprites
  25285. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  25286. * @param scene defines the hosting scene
  25287. */
  25288. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  25289. /**
  25290. * Render all child sprites
  25291. * @param sprites defines the list of sprites to render
  25292. * @param deltaTime defines the time since last frame
  25293. * @param viewMatrix defines the viewMatrix to use to render the sprites
  25294. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  25295. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  25296. */
  25297. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  25298. private _appendSpriteVertex;
  25299. /**
  25300. * Release associated resources
  25301. */
  25302. dispose(): void;
  25303. }
  25304. }
  25305. declare module "babylonjs/Sprites/spriteManager" {
  25306. import { IDisposable, Scene } from "babylonjs/scene";
  25307. import { Nullable } from "babylonjs/types";
  25308. import { Observable } from "babylonjs/Misc/observable";
  25309. import { Sprite } from "babylonjs/Sprites/sprite";
  25310. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25311. import { Camera } from "babylonjs/Cameras/camera";
  25312. import { Texture } from "babylonjs/Materials/Textures/texture";
  25313. import { Ray } from "babylonjs/Culling/ray";
  25314. /**
  25315. * Defines the minimum interface to fulfill in order to be a sprite manager.
  25316. */
  25317. export interface ISpriteManager extends IDisposable {
  25318. /**
  25319. * Gets manager's name
  25320. */
  25321. name: string;
  25322. /**
  25323. * Restricts the camera to viewing objects with the same layerMask.
  25324. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  25325. */
  25326. layerMask: number;
  25327. /**
  25328. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25329. */
  25330. isPickable: boolean;
  25331. /**
  25332. * Gets the hosting scene
  25333. */
  25334. scene: Scene;
  25335. /**
  25336. * Specifies the rendering group id for this mesh (0 by default)
  25337. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25338. */
  25339. renderingGroupId: number;
  25340. /**
  25341. * Defines the list of sprites managed by the manager.
  25342. */
  25343. sprites: Array<Sprite>;
  25344. /**
  25345. * Gets or sets the spritesheet texture
  25346. */
  25347. texture: Texture;
  25348. /** Defines the default width of a cell in the spritesheet */
  25349. cellWidth: number;
  25350. /** Defines the default height of a cell in the spritesheet */
  25351. cellHeight: number;
  25352. /**
  25353. * Tests the intersection of a sprite with a specific ray.
  25354. * @param ray The ray we are sending to test the collision
  25355. * @param camera The camera space we are sending rays in
  25356. * @param predicate A predicate allowing excluding sprites from the list of object to test
  25357. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25358. * @returns picking info or null.
  25359. */
  25360. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25361. /**
  25362. * Intersects the sprites with a ray
  25363. * @param ray defines the ray to intersect with
  25364. * @param camera defines the current active camera
  25365. * @param predicate defines a predicate used to select candidate sprites
  25366. * @returns null if no hit or a PickingInfo array
  25367. */
  25368. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25369. /**
  25370. * Renders the list of sprites on screen.
  25371. */
  25372. render(): void;
  25373. }
  25374. /**
  25375. * Class used to manage multiple sprites on the same spritesheet
  25376. * @see https://doc.babylonjs.com/babylon101/sprites
  25377. */
  25378. export class SpriteManager implements ISpriteManager {
  25379. /** defines the manager's name */
  25380. name: string;
  25381. /** Define the Url to load snippets */
  25382. static SnippetUrl: string;
  25383. /** Snippet ID if the manager was created from the snippet server */
  25384. snippetId: string;
  25385. /** Gets the list of sprites */
  25386. sprites: Sprite[];
  25387. /** Gets or sets the rendering group id (0 by default) */
  25388. renderingGroupId: number;
  25389. /** Gets or sets camera layer mask */
  25390. layerMask: number;
  25391. /** Gets or sets a boolean indicating if the sprites are pickable */
  25392. isPickable: boolean;
  25393. /**
  25394. * An event triggered when the manager is disposed.
  25395. */
  25396. onDisposeObservable: Observable<SpriteManager>;
  25397. /**
  25398. * Callback called when the manager is disposed
  25399. */
  25400. set onDispose(callback: () => void);
  25401. /**
  25402. * Gets or sets the unique id of the sprite
  25403. */
  25404. uniqueId: number;
  25405. /**
  25406. * Gets the array of sprites
  25407. */
  25408. get children(): Sprite[];
  25409. /**
  25410. * Gets the hosting scene
  25411. */
  25412. get scene(): Scene;
  25413. /**
  25414. * Gets the capacity of the manager
  25415. */
  25416. get capacity(): number;
  25417. /**
  25418. * Gets or sets the spritesheet texture
  25419. */
  25420. get texture(): Texture;
  25421. set texture(value: Texture);
  25422. /** Defines the default width of a cell in the spritesheet */
  25423. get cellWidth(): number;
  25424. set cellWidth(value: number);
  25425. /** Defines the default height of a cell in the spritesheet */
  25426. get cellHeight(): number;
  25427. set cellHeight(value: number);
  25428. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  25429. get fogEnabled(): boolean;
  25430. set fogEnabled(value: boolean);
  25431. /**
  25432. * Blend mode use to render the particle, it can be any of
  25433. * the static Constants.ALPHA_x properties provided in this class.
  25434. * Default value is Constants.ALPHA_COMBINE
  25435. */
  25436. get blendMode(): number;
  25437. set blendMode(blendMode: number);
  25438. /** Disables writing to the depth buffer when rendering the sprites.
  25439. * It can be handy to disable depth writing when using textures without alpha channel
  25440. * and setting some specific blend modes.
  25441. */
  25442. disableDepthWrite: boolean;
  25443. private _spriteRenderer;
  25444. /** Associative array from JSON sprite data file */
  25445. private _cellData;
  25446. /** Array of sprite names from JSON sprite data file */
  25447. private _spriteMap;
  25448. /** True when packed cell data from JSON file is ready*/
  25449. private _packedAndReady;
  25450. private _textureContent;
  25451. private _onDisposeObserver;
  25452. private _fromPacked;
  25453. private _scene;
  25454. /**
  25455. * Creates a new sprite manager
  25456. * @param name defines the manager's name
  25457. * @param imgUrl defines the sprite sheet url
  25458. * @param capacity defines the maximum allowed number of sprites
  25459. * @param cellSize defines the size of a sprite cell
  25460. * @param scene defines the hosting scene
  25461. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  25462. * @param samplingMode defines the sampling mode to use with spritesheet
  25463. * @param fromPacked set to false; do not alter
  25464. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  25465. */
  25466. constructor(
  25467. /** defines the manager's name */
  25468. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  25469. /**
  25470. * Returns the string "SpriteManager"
  25471. * @returns "SpriteManager"
  25472. */
  25473. getClassName(): string;
  25474. private _makePacked;
  25475. private _checkTextureAlpha;
  25476. /**
  25477. * Intersects the sprites with a ray
  25478. * @param ray defines the ray to intersect with
  25479. * @param camera defines the current active camera
  25480. * @param predicate defines a predicate used to select candidate sprites
  25481. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  25482. * @returns null if no hit or a PickingInfo
  25483. */
  25484. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25485. /**
  25486. * Intersects the sprites with a ray
  25487. * @param ray defines the ray to intersect with
  25488. * @param camera defines the current active camera
  25489. * @param predicate defines a predicate used to select candidate sprites
  25490. * @returns null if no hit or a PickingInfo array
  25491. */
  25492. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25493. /**
  25494. * Render all child sprites
  25495. */
  25496. render(): void;
  25497. private _customUpdate;
  25498. /**
  25499. * Release associated resources
  25500. */
  25501. dispose(): void;
  25502. /**
  25503. * Serializes the sprite manager to a JSON object
  25504. * @param serializeTexture defines if the texture must be serialized as well
  25505. * @returns the JSON object
  25506. */
  25507. serialize(serializeTexture?: boolean): any;
  25508. /**
  25509. * Parses a JSON object to create a new sprite manager.
  25510. * @param parsedManager The JSON object to parse
  25511. * @param scene The scene to create the sprite manager
  25512. * @param rootUrl The root url to use to load external dependencies like texture
  25513. * @returns the new sprite manager
  25514. */
  25515. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  25516. /**
  25517. * Creates a sprite manager from a snippet saved in a remote file
  25518. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  25519. * @param url defines the url to load from
  25520. * @param scene defines the hosting scene
  25521. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25522. * @returns a promise that will resolve to the new sprite manager
  25523. */
  25524. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25525. /**
  25526. * Creates a sprite manager from a snippet saved by the sprite editor
  25527. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  25528. * @param scene defines the hosting scene
  25529. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25530. * @returns a promise that will resolve to the new sprite manager
  25531. */
  25532. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25533. }
  25534. }
  25535. declare module "babylonjs/Sprites/sprite" {
  25536. import { Vector3 } from "babylonjs/Maths/math.vector";
  25537. import { Nullable } from "babylonjs/types";
  25538. import { ActionManager } from "babylonjs/Actions/actionManager";
  25539. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  25540. import { Color4 } from "babylonjs/Maths/math.color";
  25541. import { Observable } from "babylonjs/Misc/observable";
  25542. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25543. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  25544. import { Animation } from "babylonjs/Animations/animation";
  25545. /**
  25546. * Class used to represent a sprite
  25547. * @see https://doc.babylonjs.com/babylon101/sprites
  25548. */
  25549. export class Sprite extends ThinSprite implements IAnimatable {
  25550. /** defines the name */
  25551. name: string;
  25552. /** Gets or sets the current world position */
  25553. position: Vector3;
  25554. /** Gets or sets the main color */
  25555. color: Color4;
  25556. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  25557. disposeWhenFinishedAnimating: boolean;
  25558. /** Gets the list of attached animations */
  25559. animations: Nullable<Array<Animation>>;
  25560. /** Gets or sets a boolean indicating if the sprite can be picked */
  25561. isPickable: boolean;
  25562. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  25563. useAlphaForPicking: boolean;
  25564. /**
  25565. * Gets or sets the associated action manager
  25566. */
  25567. actionManager: Nullable<ActionManager>;
  25568. /**
  25569. * An event triggered when the control has been disposed
  25570. */
  25571. onDisposeObservable: Observable<Sprite>;
  25572. private _manager;
  25573. private _onAnimationEnd;
  25574. /**
  25575. * Gets or sets the sprite size
  25576. */
  25577. get size(): number;
  25578. set size(value: number);
  25579. /**
  25580. * Gets or sets the unique id of the sprite
  25581. */
  25582. uniqueId: number;
  25583. /**
  25584. * Gets the manager of this sprite
  25585. */
  25586. get manager(): ISpriteManager;
  25587. /**
  25588. * Creates a new Sprite
  25589. * @param name defines the name
  25590. * @param manager defines the manager
  25591. */
  25592. constructor(
  25593. /** defines the name */
  25594. name: string, manager: ISpriteManager);
  25595. /**
  25596. * Returns the string "Sprite"
  25597. * @returns "Sprite"
  25598. */
  25599. getClassName(): string;
  25600. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  25601. get fromIndex(): number;
  25602. set fromIndex(value: number);
  25603. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  25604. get toIndex(): number;
  25605. set toIndex(value: number);
  25606. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  25607. get loopAnimation(): boolean;
  25608. set loopAnimation(value: boolean);
  25609. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  25610. get delay(): number;
  25611. set delay(value: number);
  25612. /**
  25613. * Starts an animation
  25614. * @param from defines the initial key
  25615. * @param to defines the end key
  25616. * @param loop defines if the animation must loop
  25617. * @param delay defines the start delay (in ms)
  25618. * @param onAnimationEnd defines a callback to call when animation ends
  25619. */
  25620. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  25621. private _endAnimation;
  25622. /** Release associated resources */
  25623. dispose(): void;
  25624. /**
  25625. * Serializes the sprite to a JSON object
  25626. * @returns the JSON object
  25627. */
  25628. serialize(): any;
  25629. /**
  25630. * Parses a JSON object to create a new sprite
  25631. * @param parsedSprite The JSON object to parse
  25632. * @param manager defines the hosting manager
  25633. * @returns the new sprite
  25634. */
  25635. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  25636. }
  25637. }
  25638. declare module "babylonjs/Collisions/pickingInfo" {
  25639. import { Nullable } from "babylonjs/types";
  25640. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25642. import { Sprite } from "babylonjs/Sprites/sprite";
  25643. import { Ray } from "babylonjs/Culling/ray";
  25644. /**
  25645. * Information about the result of picking within a scene
  25646. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  25647. */
  25648. export class PickingInfo {
  25649. /** @hidden */
  25650. _pickingUnavailable: boolean;
  25651. /**
  25652. * If the pick collided with an object
  25653. */
  25654. hit: boolean;
  25655. /**
  25656. * Distance away where the pick collided
  25657. */
  25658. distance: number;
  25659. /**
  25660. * The location of pick collision
  25661. */
  25662. pickedPoint: Nullable<Vector3>;
  25663. /**
  25664. * The mesh corresponding the the pick collision
  25665. */
  25666. pickedMesh: Nullable<AbstractMesh>;
  25667. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  25668. bu: number;
  25669. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  25670. bv: number;
  25671. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25672. faceId: number;
  25673. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25674. subMeshFaceId: number;
  25675. /** Id of the the submesh that was picked */
  25676. subMeshId: number;
  25677. /** If a sprite was picked, this will be the sprite the pick collided with */
  25678. pickedSprite: Nullable<Sprite>;
  25679. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  25680. thinInstanceIndex: number;
  25681. /**
  25682. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  25683. */
  25684. originMesh: Nullable<AbstractMesh>;
  25685. /**
  25686. * The ray that was used to perform the picking.
  25687. */
  25688. ray: Nullable<Ray>;
  25689. /**
  25690. * Gets the normal corresponding to the face the pick collided with
  25691. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  25692. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  25693. * @returns The normal corresponding to the face the pick collided with
  25694. */
  25695. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  25696. /**
  25697. * Gets the texture coordinates of where the pick occurred
  25698. * @returns the vector containing the coordinates of the texture
  25699. */
  25700. getTextureCoordinates(): Nullable<Vector2>;
  25701. }
  25702. }
  25703. declare module "babylonjs/Events/pointerEvents" {
  25704. import { Nullable } from "babylonjs/types";
  25705. import { Vector2 } from "babylonjs/Maths/math.vector";
  25706. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25707. import { Ray } from "babylonjs/Culling/ray";
  25708. /**
  25709. * Gather the list of pointer event types as constants.
  25710. */
  25711. export class PointerEventTypes {
  25712. /**
  25713. * 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.
  25714. */
  25715. static readonly POINTERDOWN: number;
  25716. /**
  25717. * The pointerup event is fired when a pointer is no longer active.
  25718. */
  25719. static readonly POINTERUP: number;
  25720. /**
  25721. * The pointermove event is fired when a pointer changes coordinates.
  25722. */
  25723. static readonly POINTERMOVE: number;
  25724. /**
  25725. * The pointerwheel event is fired when a mouse wheel has been rotated.
  25726. */
  25727. static readonly POINTERWHEEL: number;
  25728. /**
  25729. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  25730. */
  25731. static readonly POINTERPICK: number;
  25732. /**
  25733. * The pointertap event is fired when a the object has been touched and released without drag.
  25734. */
  25735. static readonly POINTERTAP: number;
  25736. /**
  25737. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  25738. */
  25739. static readonly POINTERDOUBLETAP: number;
  25740. }
  25741. /**
  25742. * Base class of pointer info types.
  25743. */
  25744. export class PointerInfoBase {
  25745. /**
  25746. * Defines the type of event (PointerEventTypes)
  25747. */
  25748. type: number;
  25749. /**
  25750. * Defines the related dom event
  25751. */
  25752. event: PointerEvent | MouseWheelEvent;
  25753. /**
  25754. * Instantiates the base class of pointers info.
  25755. * @param type Defines the type of event (PointerEventTypes)
  25756. * @param event Defines the related dom event
  25757. */
  25758. constructor(
  25759. /**
  25760. * Defines the type of event (PointerEventTypes)
  25761. */
  25762. type: number,
  25763. /**
  25764. * Defines the related dom event
  25765. */
  25766. event: PointerEvent | MouseWheelEvent);
  25767. }
  25768. /**
  25769. * This class is used to store pointer related info for the onPrePointerObservable event.
  25770. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  25771. */
  25772. export class PointerInfoPre extends PointerInfoBase {
  25773. /**
  25774. * Ray from a pointer if availible (eg. 6dof controller)
  25775. */
  25776. ray: Nullable<Ray>;
  25777. /**
  25778. * Defines the local position of the pointer on the canvas.
  25779. */
  25780. localPosition: Vector2;
  25781. /**
  25782. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  25783. */
  25784. skipOnPointerObservable: boolean;
  25785. /**
  25786. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  25787. * @param type Defines the type of event (PointerEventTypes)
  25788. * @param event Defines the related dom event
  25789. * @param localX Defines the local x coordinates of the pointer when the event occured
  25790. * @param localY Defines the local y coordinates of the pointer when the event occured
  25791. */
  25792. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  25793. }
  25794. /**
  25795. * This type contains all the data related to a pointer event in Babylon.js.
  25796. * 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.
  25797. */
  25798. export class PointerInfo extends PointerInfoBase {
  25799. /**
  25800. * Defines the picking info associated to the info (if any)\
  25801. */
  25802. pickInfo: Nullable<PickingInfo>;
  25803. /**
  25804. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  25805. * @param type Defines the type of event (PointerEventTypes)
  25806. * @param event Defines the related dom event
  25807. * @param pickInfo Defines the picking info associated to the info (if any)\
  25808. */
  25809. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  25810. /**
  25811. * Defines the picking info associated to the info (if any)\
  25812. */
  25813. pickInfo: Nullable<PickingInfo>);
  25814. }
  25815. /**
  25816. * Data relating to a touch event on the screen.
  25817. */
  25818. export interface PointerTouch {
  25819. /**
  25820. * X coordinate of touch.
  25821. */
  25822. x: number;
  25823. /**
  25824. * Y coordinate of touch.
  25825. */
  25826. y: number;
  25827. /**
  25828. * Id of touch. Unique for each finger.
  25829. */
  25830. pointerId: number;
  25831. /**
  25832. * Event type passed from DOM.
  25833. */
  25834. type: any;
  25835. }
  25836. }
  25837. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  25838. import { Observable } from "babylonjs/Misc/observable";
  25839. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25840. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25841. /**
  25842. * Manage the mouse inputs to control the movement of a free camera.
  25843. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25844. */
  25845. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  25846. /**
  25847. * Define if touch is enabled in the mouse input
  25848. */
  25849. touchEnabled: boolean;
  25850. /**
  25851. * Defines the camera the input is attached to.
  25852. */
  25853. camera: FreeCamera;
  25854. /**
  25855. * Defines the buttons associated with the input to handle camera move.
  25856. */
  25857. buttons: number[];
  25858. /**
  25859. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  25860. */
  25861. angularSensibility: number;
  25862. private _pointerInput;
  25863. private _onMouseMove;
  25864. private _observer;
  25865. private previousPosition;
  25866. /**
  25867. * Observable for when a pointer move event occurs containing the move offset
  25868. */
  25869. onPointerMovedObservable: Observable<{
  25870. offsetX: number;
  25871. offsetY: number;
  25872. }>;
  25873. /**
  25874. * @hidden
  25875. * If the camera should be rotated automatically based on pointer movement
  25876. */
  25877. _allowCameraRotation: boolean;
  25878. /**
  25879. * Manage the mouse inputs to control the movement of a free camera.
  25880. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25881. * @param touchEnabled Defines if touch is enabled or not
  25882. */
  25883. constructor(
  25884. /**
  25885. * Define if touch is enabled in the mouse input
  25886. */
  25887. touchEnabled?: boolean);
  25888. /**
  25889. * Attach the input controls to a specific dom element to get the input from.
  25890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25891. */
  25892. attachControl(noPreventDefault?: boolean): void;
  25893. /**
  25894. * Called on JS contextmenu event.
  25895. * Override this method to provide functionality.
  25896. */
  25897. protected onContextMenu(evt: PointerEvent): void;
  25898. /**
  25899. * Detach the current controls from the specified dom element.
  25900. */
  25901. detachControl(): void;
  25902. /**
  25903. * Gets the class name of the current input.
  25904. * @returns the class name
  25905. */
  25906. getClassName(): string;
  25907. /**
  25908. * Get the friendly name associated with the input class.
  25909. * @returns the input friendly name
  25910. */
  25911. getSimpleName(): string;
  25912. }
  25913. }
  25914. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  25915. import { Observable } from "babylonjs/Misc/observable";
  25916. import { Camera } from "babylonjs/Cameras/camera";
  25917. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25918. /**
  25919. * Base class for mouse wheel input..
  25920. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  25921. * for example usage.
  25922. */
  25923. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  25924. /**
  25925. * Defines the camera the input is attached to.
  25926. */
  25927. abstract camera: Camera;
  25928. /**
  25929. * How fast is the camera moves in relation to X axis mouseWheel events.
  25930. * Use negative value to reverse direction.
  25931. */
  25932. wheelPrecisionX: number;
  25933. /**
  25934. * How fast is the camera moves in relation to Y axis mouseWheel events.
  25935. * Use negative value to reverse direction.
  25936. */
  25937. wheelPrecisionY: number;
  25938. /**
  25939. * How fast is the camera moves in relation to Z axis mouseWheel events.
  25940. * Use negative value to reverse direction.
  25941. */
  25942. wheelPrecisionZ: number;
  25943. /**
  25944. * Observable for when a mouse wheel move event occurs.
  25945. */
  25946. onChangedObservable: Observable<{
  25947. wheelDeltaX: number;
  25948. wheelDeltaY: number;
  25949. wheelDeltaZ: number;
  25950. }>;
  25951. private _wheel;
  25952. private _observer;
  25953. /**
  25954. * Attach the input controls to a specific dom element to get the input from.
  25955. * @param noPreventDefault Defines whether event caught by the controls
  25956. * should call preventdefault().
  25957. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25958. */
  25959. attachControl(noPreventDefault?: boolean): void;
  25960. /**
  25961. * Detach the current controls from the specified dom element.
  25962. */
  25963. detachControl(): void;
  25964. /**
  25965. * Called for each rendered frame.
  25966. */
  25967. checkInputs(): void;
  25968. /**
  25969. * Gets the class name of the current input.
  25970. * @returns the class name
  25971. */
  25972. getClassName(): string;
  25973. /**
  25974. * Get the friendly name associated with the input class.
  25975. * @returns the input friendly name
  25976. */
  25977. getSimpleName(): string;
  25978. /**
  25979. * Incremental value of multiple mouse wheel movements of the X axis.
  25980. * Should be zero-ed when read.
  25981. */
  25982. protected _wheelDeltaX: number;
  25983. /**
  25984. * Incremental value of multiple mouse wheel movements of the Y axis.
  25985. * Should be zero-ed when read.
  25986. */
  25987. protected _wheelDeltaY: number;
  25988. /**
  25989. * Incremental value of multiple mouse wheel movements of the Z axis.
  25990. * Should be zero-ed when read.
  25991. */
  25992. protected _wheelDeltaZ: number;
  25993. /**
  25994. * Firefox uses a different scheme to report scroll distances to other
  25995. * browsers. Rather than use complicated methods to calculate the exact
  25996. * multiple we need to apply, let's just cheat and use a constant.
  25997. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25998. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25999. */
  26000. private readonly _ffMultiplier;
  26001. /**
  26002. * Different event attributes for wheel data fall into a few set ranges.
  26003. * Some relevant but dated date here:
  26004. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  26005. */
  26006. private readonly _normalize;
  26007. }
  26008. }
  26009. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  26010. import { Nullable } from "babylonjs/types";
  26011. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26012. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  26013. import { Coordinate } from "babylonjs/Maths/math.axis";
  26014. /**
  26015. * Manage the mouse wheel inputs to control a free camera.
  26016. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  26017. */
  26018. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  26019. /**
  26020. * Defines the camera the input is attached to.
  26021. */
  26022. camera: FreeCamera;
  26023. /**
  26024. * Gets the class name of the current input.
  26025. * @returns the class name
  26026. */
  26027. getClassName(): string;
  26028. /**
  26029. * Set which movement axis (relative to camera's orientation) the mouse
  26030. * wheel's X axis controls.
  26031. * @param axis The axis to be moved. Set null to clear.
  26032. */
  26033. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  26034. /**
  26035. * Get the configured movement axis (relative to camera's orientation) the
  26036. * mouse wheel's X axis controls.
  26037. * @returns The configured axis or null if none.
  26038. */
  26039. get wheelXMoveRelative(): Nullable<Coordinate>;
  26040. /**
  26041. * Set which movement axis (relative to camera's orientation) the mouse
  26042. * wheel's Y axis controls.
  26043. * @param axis The axis to be moved. Set null to clear.
  26044. */
  26045. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  26046. /**
  26047. * Get the configured movement axis (relative to camera's orientation) the
  26048. * mouse wheel's Y axis controls.
  26049. * @returns The configured axis or null if none.
  26050. */
  26051. get wheelYMoveRelative(): Nullable<Coordinate>;
  26052. /**
  26053. * Set which movement axis (relative to camera's orientation) the mouse
  26054. * wheel's Z axis controls.
  26055. * @param axis The axis to be moved. Set null to clear.
  26056. */
  26057. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  26058. /**
  26059. * Get the configured movement axis (relative to camera's orientation) the
  26060. * mouse wheel's Z axis controls.
  26061. * @returns The configured axis or null if none.
  26062. */
  26063. get wheelZMoveRelative(): Nullable<Coordinate>;
  26064. /**
  26065. * Set which rotation axis (relative to camera's orientation) the mouse
  26066. * wheel's X axis controls.
  26067. * @param axis The axis to be moved. Set null to clear.
  26068. */
  26069. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  26070. /**
  26071. * Get the configured rotation axis (relative to camera's orientation) the
  26072. * mouse wheel's X axis controls.
  26073. * @returns The configured axis or null if none.
  26074. */
  26075. get wheelXRotateRelative(): Nullable<Coordinate>;
  26076. /**
  26077. * Set which rotation axis (relative to camera's orientation) the mouse
  26078. * wheel's Y axis controls.
  26079. * @param axis The axis to be moved. Set null to clear.
  26080. */
  26081. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  26082. /**
  26083. * Get the configured rotation axis (relative to camera's orientation) the
  26084. * mouse wheel's Y axis controls.
  26085. * @returns The configured axis or null if none.
  26086. */
  26087. get wheelYRotateRelative(): Nullable<Coordinate>;
  26088. /**
  26089. * Set which rotation axis (relative to camera's orientation) the mouse
  26090. * wheel's Z axis controls.
  26091. * @param axis The axis to be moved. Set null to clear.
  26092. */
  26093. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  26094. /**
  26095. * Get the configured rotation axis (relative to camera's orientation) the
  26096. * mouse wheel's Z axis controls.
  26097. * @returns The configured axis or null if none.
  26098. */
  26099. get wheelZRotateRelative(): Nullable<Coordinate>;
  26100. /**
  26101. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  26102. * controls.
  26103. * @param axis The axis to be moved. Set null to clear.
  26104. */
  26105. set wheelXMoveScene(axis: Nullable<Coordinate>);
  26106. /**
  26107. * Get the configured movement axis (relative to the scene) the mouse wheel's
  26108. * X axis controls.
  26109. * @returns The configured axis or null if none.
  26110. */
  26111. get wheelXMoveScene(): Nullable<Coordinate>;
  26112. /**
  26113. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  26114. * controls.
  26115. * @param axis The axis to be moved. Set null to clear.
  26116. */
  26117. set wheelYMoveScene(axis: Nullable<Coordinate>);
  26118. /**
  26119. * Get the configured movement axis (relative to the scene) the mouse wheel's
  26120. * Y axis controls.
  26121. * @returns The configured axis or null if none.
  26122. */
  26123. get wheelYMoveScene(): Nullable<Coordinate>;
  26124. /**
  26125. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  26126. * controls.
  26127. * @param axis The axis to be moved. Set null to clear.
  26128. */
  26129. set wheelZMoveScene(axis: Nullable<Coordinate>);
  26130. /**
  26131. * Get the configured movement axis (relative to the scene) the mouse wheel's
  26132. * Z axis controls.
  26133. * @returns The configured axis or null if none.
  26134. */
  26135. get wheelZMoveScene(): Nullable<Coordinate>;
  26136. /**
  26137. * Called for each rendered frame.
  26138. */
  26139. checkInputs(): void;
  26140. private _moveRelative;
  26141. private _rotateRelative;
  26142. private _moveScene;
  26143. /**
  26144. * These are set to the desired default behaviour.
  26145. */
  26146. private _wheelXAction;
  26147. private _wheelXActionCoordinate;
  26148. private _wheelYAction;
  26149. private _wheelYActionCoordinate;
  26150. private _wheelZAction;
  26151. private _wheelZActionCoordinate;
  26152. /**
  26153. * Update the camera according to any configured properties for the 3
  26154. * mouse-wheel axis.
  26155. */
  26156. private _updateCamera;
  26157. /**
  26158. * Update one property of the camera.
  26159. */
  26160. private _updateCameraProperty;
  26161. }
  26162. }
  26163. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  26164. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  26165. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26166. /**
  26167. * Manage the touch inputs to control the movement of a free camera.
  26168. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  26169. */
  26170. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  26171. /**
  26172. * Define if mouse events can be treated as touch events
  26173. */
  26174. allowMouse: boolean;
  26175. /**
  26176. * Defines the camera the input is attached to.
  26177. */
  26178. camera: FreeCamera;
  26179. /**
  26180. * Defines the touch sensibility for rotation.
  26181. * The higher the faster.
  26182. */
  26183. touchAngularSensibility: number;
  26184. /**
  26185. * Defines the touch sensibility for move.
  26186. * The higher the faster.
  26187. */
  26188. touchMoveSensibility: number;
  26189. private _offsetX;
  26190. private _offsetY;
  26191. private _pointerPressed;
  26192. private _pointerInput?;
  26193. private _observer;
  26194. private _onLostFocus;
  26195. /**
  26196. * Manage the touch inputs to control the movement of a free camera.
  26197. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  26198. * @param allowMouse Defines if mouse events can be treated as touch events
  26199. */
  26200. constructor(
  26201. /**
  26202. * Define if mouse events can be treated as touch events
  26203. */
  26204. allowMouse?: boolean);
  26205. /**
  26206. * Attach the input controls to a specific dom element to get the input from.
  26207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26208. */
  26209. attachControl(noPreventDefault?: boolean): void;
  26210. /**
  26211. * Detach the current controls from the specified dom element.
  26212. */
  26213. detachControl(): void;
  26214. /**
  26215. * Update the current camera state depending on the inputs that have been used this frame.
  26216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  26217. */
  26218. checkInputs(): void;
  26219. /**
  26220. * Gets the class name of the current input.
  26221. * @returns the class name
  26222. */
  26223. getClassName(): string;
  26224. /**
  26225. * Get the friendly name associated with the input class.
  26226. * @returns the input friendly name
  26227. */
  26228. getSimpleName(): string;
  26229. }
  26230. }
  26231. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  26232. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26233. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26234. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  26235. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  26236. import { Nullable } from "babylonjs/types";
  26237. /**
  26238. * Default Inputs manager for the FreeCamera.
  26239. * It groups all the default supported inputs for ease of use.
  26240. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  26241. */
  26242. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  26243. /**
  26244. * @hidden
  26245. */
  26246. _mouseInput: Nullable<FreeCameraMouseInput>;
  26247. /**
  26248. * @hidden
  26249. */
  26250. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  26251. /**
  26252. * Instantiates a new FreeCameraInputsManager.
  26253. * @param camera Defines the camera the inputs belong to
  26254. */
  26255. constructor(camera: FreeCamera);
  26256. /**
  26257. * Add keyboard input support to the input manager.
  26258. * @returns the current input manager
  26259. */
  26260. addKeyboard(): FreeCameraInputsManager;
  26261. /**
  26262. * Add mouse input support to the input manager.
  26263. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  26264. * @returns the current input manager
  26265. */
  26266. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  26267. /**
  26268. * Removes the mouse input support from the manager
  26269. * @returns the current input manager
  26270. */
  26271. removeMouse(): FreeCameraInputsManager;
  26272. /**
  26273. * Add mouse wheel input support to the input manager.
  26274. * @returns the current input manager
  26275. */
  26276. addMouseWheel(): FreeCameraInputsManager;
  26277. /**
  26278. * Removes the mouse wheel input support from the manager
  26279. * @returns the current input manager
  26280. */
  26281. removeMouseWheel(): FreeCameraInputsManager;
  26282. /**
  26283. * Add touch input support to the input manager.
  26284. * @returns the current input manager
  26285. */
  26286. addTouch(): FreeCameraInputsManager;
  26287. /**
  26288. * Remove all attached input methods from a camera
  26289. */
  26290. clear(): void;
  26291. }
  26292. }
  26293. declare module "babylonjs/Cameras/freeCamera" {
  26294. import { Vector3 } from "babylonjs/Maths/math.vector";
  26295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26296. import { Scene } from "babylonjs/scene";
  26297. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  26298. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  26299. /**
  26300. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  26301. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  26302. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  26303. */
  26304. export class FreeCamera extends TargetCamera {
  26305. /**
  26306. * Define the collision ellipsoid of the camera.
  26307. * This is helpful to simulate a camera body like the player body around the camera
  26308. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  26309. */
  26310. ellipsoid: Vector3;
  26311. /**
  26312. * Define an offset for the position of the ellipsoid around the camera.
  26313. * This can be helpful to determine the center of the body near the gravity center of the body
  26314. * instead of its head.
  26315. */
  26316. ellipsoidOffset: Vector3;
  26317. /**
  26318. * Enable or disable collisions of the camera with the rest of the scene objects.
  26319. */
  26320. checkCollisions: boolean;
  26321. /**
  26322. * Enable or disable gravity on the camera.
  26323. */
  26324. applyGravity: boolean;
  26325. /**
  26326. * Define the input manager associated to the camera.
  26327. */
  26328. inputs: FreeCameraInputsManager;
  26329. /**
  26330. * Gets the input sensibility for a mouse input. (default is 2000.0)
  26331. * Higher values reduce sensitivity.
  26332. */
  26333. get angularSensibility(): number;
  26334. /**
  26335. * Sets the input sensibility for a mouse input. (default is 2000.0)
  26336. * Higher values reduce sensitivity.
  26337. */
  26338. set angularSensibility(value: number);
  26339. /**
  26340. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  26341. */
  26342. get keysUp(): number[];
  26343. set keysUp(value: number[]);
  26344. /**
  26345. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  26346. */
  26347. get keysUpward(): number[];
  26348. set keysUpward(value: number[]);
  26349. /**
  26350. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  26351. */
  26352. get keysDown(): number[];
  26353. set keysDown(value: number[]);
  26354. /**
  26355. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  26356. */
  26357. get keysDownward(): number[];
  26358. set keysDownward(value: number[]);
  26359. /**
  26360. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  26361. */
  26362. get keysLeft(): number[];
  26363. set keysLeft(value: number[]);
  26364. /**
  26365. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  26366. */
  26367. get keysRight(): number[];
  26368. set keysRight(value: number[]);
  26369. /**
  26370. * Event raised when the camera collide with a mesh in the scene.
  26371. */
  26372. onCollide: (collidedMesh: AbstractMesh) => void;
  26373. private _collider;
  26374. private _needMoveForGravity;
  26375. private _oldPosition;
  26376. private _diffPosition;
  26377. private _newPosition;
  26378. /** @hidden */
  26379. _localDirection: Vector3;
  26380. /** @hidden */
  26381. _transformedDirection: Vector3;
  26382. /**
  26383. * Instantiates a Free Camera.
  26384. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  26385. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  26386. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  26387. * @param name Define the name of the camera in the scene
  26388. * @param position Define the start position of the camera in the scene
  26389. * @param scene Define the scene the camera belongs to
  26390. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  26391. */
  26392. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26393. /**
  26394. * Attach the input controls to a specific dom element to get the input from.
  26395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26396. */
  26397. attachControl(noPreventDefault?: boolean): void;
  26398. /**
  26399. * Attach the input controls to a specific dom element to get the input from.
  26400. * @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
  26401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26402. * BACK COMPAT SIGNATURE ONLY.
  26403. */
  26404. attachControl(ignored: any, noPreventDefault?: boolean): void;
  26405. /**
  26406. * Detach the current controls from the specified dom element.
  26407. */
  26408. detachControl(): void;
  26409. /**
  26410. * Detach the current controls from the specified dom element.
  26411. * @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
  26412. */
  26413. detachControl(ignored: any): void;
  26414. private _collisionMask;
  26415. /**
  26416. * Define a collision mask to limit the list of object the camera can collide with
  26417. */
  26418. get collisionMask(): number;
  26419. set collisionMask(mask: number);
  26420. /** @hidden */
  26421. _collideWithWorld(displacement: Vector3): void;
  26422. private _onCollisionPositionChange;
  26423. /** @hidden */
  26424. _checkInputs(): void;
  26425. /** @hidden */
  26426. _decideIfNeedsToMove(): boolean;
  26427. /** @hidden */
  26428. _updatePosition(): void;
  26429. /**
  26430. * Destroy the camera and release the current resources hold by it.
  26431. */
  26432. dispose(): void;
  26433. /**
  26434. * Gets the current object class name.
  26435. * @return the class name
  26436. */
  26437. getClassName(): string;
  26438. }
  26439. }
  26440. declare module "babylonjs/Gamepads/gamepad" {
  26441. import { Observable } from "babylonjs/Misc/observable";
  26442. /**
  26443. * Represents a gamepad control stick position
  26444. */
  26445. export class StickValues {
  26446. /**
  26447. * The x component of the control stick
  26448. */
  26449. x: number;
  26450. /**
  26451. * The y component of the control stick
  26452. */
  26453. y: number;
  26454. /**
  26455. * Initializes the gamepad x and y control stick values
  26456. * @param x The x component of the gamepad control stick value
  26457. * @param y The y component of the gamepad control stick value
  26458. */
  26459. constructor(
  26460. /**
  26461. * The x component of the control stick
  26462. */
  26463. x: number,
  26464. /**
  26465. * The y component of the control stick
  26466. */
  26467. y: number);
  26468. }
  26469. /**
  26470. * An interface which manages callbacks for gamepad button changes
  26471. */
  26472. export interface GamepadButtonChanges {
  26473. /**
  26474. * Called when a gamepad has been changed
  26475. */
  26476. changed: boolean;
  26477. /**
  26478. * Called when a gamepad press event has been triggered
  26479. */
  26480. pressChanged: boolean;
  26481. /**
  26482. * Called when a touch event has been triggered
  26483. */
  26484. touchChanged: boolean;
  26485. /**
  26486. * Called when a value has changed
  26487. */
  26488. valueChanged: boolean;
  26489. }
  26490. /**
  26491. * Represents a gamepad
  26492. */
  26493. export class Gamepad {
  26494. /**
  26495. * The id of the gamepad
  26496. */
  26497. id: string;
  26498. /**
  26499. * The index of the gamepad
  26500. */
  26501. index: number;
  26502. /**
  26503. * The browser gamepad
  26504. */
  26505. browserGamepad: any;
  26506. /**
  26507. * Specifies what type of gamepad this represents
  26508. */
  26509. type: number;
  26510. private _leftStick;
  26511. private _rightStick;
  26512. /** @hidden */
  26513. _isConnected: boolean;
  26514. private _leftStickAxisX;
  26515. private _leftStickAxisY;
  26516. private _rightStickAxisX;
  26517. private _rightStickAxisY;
  26518. /**
  26519. * Triggered when the left control stick has been changed
  26520. */
  26521. private _onleftstickchanged;
  26522. /**
  26523. * Triggered when the right control stick has been changed
  26524. */
  26525. private _onrightstickchanged;
  26526. /**
  26527. * Represents a gamepad controller
  26528. */
  26529. static GAMEPAD: number;
  26530. /**
  26531. * Represents a generic controller
  26532. */
  26533. static GENERIC: number;
  26534. /**
  26535. * Represents an XBox controller
  26536. */
  26537. static XBOX: number;
  26538. /**
  26539. * Represents a pose-enabled controller
  26540. */
  26541. static POSE_ENABLED: number;
  26542. /**
  26543. * Represents an Dual Shock controller
  26544. */
  26545. static DUALSHOCK: number;
  26546. /**
  26547. * Specifies whether the left control stick should be Y-inverted
  26548. */
  26549. protected _invertLeftStickY: boolean;
  26550. /**
  26551. * Specifies if the gamepad has been connected
  26552. */
  26553. get isConnected(): boolean;
  26554. /**
  26555. * Initializes the gamepad
  26556. * @param id The id of the gamepad
  26557. * @param index The index of the gamepad
  26558. * @param browserGamepad The browser gamepad
  26559. * @param leftStickX The x component of the left joystick
  26560. * @param leftStickY The y component of the left joystick
  26561. * @param rightStickX The x component of the right joystick
  26562. * @param rightStickY The y component of the right joystick
  26563. */
  26564. constructor(
  26565. /**
  26566. * The id of the gamepad
  26567. */
  26568. id: string,
  26569. /**
  26570. * The index of the gamepad
  26571. */
  26572. index: number,
  26573. /**
  26574. * The browser gamepad
  26575. */
  26576. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  26577. /**
  26578. * Callback triggered when the left joystick has changed
  26579. * @param callback
  26580. */
  26581. onleftstickchanged(callback: (values: StickValues) => void): void;
  26582. /**
  26583. * Callback triggered when the right joystick has changed
  26584. * @param callback
  26585. */
  26586. onrightstickchanged(callback: (values: StickValues) => void): void;
  26587. /**
  26588. * Gets the left joystick
  26589. */
  26590. get leftStick(): StickValues;
  26591. /**
  26592. * Sets the left joystick values
  26593. */
  26594. set leftStick(newValues: StickValues);
  26595. /**
  26596. * Gets the right joystick
  26597. */
  26598. get rightStick(): StickValues;
  26599. /**
  26600. * Sets the right joystick value
  26601. */
  26602. set rightStick(newValues: StickValues);
  26603. /**
  26604. * Updates the gamepad joystick positions
  26605. */
  26606. update(): void;
  26607. /**
  26608. * Disposes the gamepad
  26609. */
  26610. dispose(): void;
  26611. }
  26612. /**
  26613. * Represents a generic gamepad
  26614. */
  26615. export class GenericPad extends Gamepad {
  26616. private _buttons;
  26617. private _onbuttondown;
  26618. private _onbuttonup;
  26619. /**
  26620. * Observable triggered when a button has been pressed
  26621. */
  26622. onButtonDownObservable: Observable<number>;
  26623. /**
  26624. * Observable triggered when a button has been released
  26625. */
  26626. onButtonUpObservable: Observable<number>;
  26627. /**
  26628. * Callback triggered when a button has been pressed
  26629. * @param callback Called when a button has been pressed
  26630. */
  26631. onbuttondown(callback: (buttonPressed: number) => void): void;
  26632. /**
  26633. * Callback triggered when a button has been released
  26634. * @param callback Called when a button has been released
  26635. */
  26636. onbuttonup(callback: (buttonReleased: number) => void): void;
  26637. /**
  26638. * Initializes the generic gamepad
  26639. * @param id The id of the generic gamepad
  26640. * @param index The index of the generic gamepad
  26641. * @param browserGamepad The browser gamepad
  26642. */
  26643. constructor(id: string, index: number, browserGamepad: any);
  26644. private _setButtonValue;
  26645. /**
  26646. * Updates the generic gamepad
  26647. */
  26648. update(): void;
  26649. /**
  26650. * Disposes the generic gamepad
  26651. */
  26652. dispose(): void;
  26653. }
  26654. }
  26655. declare module "babylonjs/Animations/runtimeAnimation" {
  26656. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  26657. import { Animatable } from "babylonjs/Animations/animatable";
  26658. import { Scene } from "babylonjs/scene";
  26659. /**
  26660. * Defines a runtime animation
  26661. */
  26662. export class RuntimeAnimation {
  26663. private _events;
  26664. /**
  26665. * The current frame of the runtime animation
  26666. */
  26667. private _currentFrame;
  26668. /**
  26669. * The animation used by the runtime animation
  26670. */
  26671. private _animation;
  26672. /**
  26673. * The target of the runtime animation
  26674. */
  26675. private _target;
  26676. /**
  26677. * The initiating animatable
  26678. */
  26679. private _host;
  26680. /**
  26681. * The original value of the runtime animation
  26682. */
  26683. private _originalValue;
  26684. /**
  26685. * The original blend value of the runtime animation
  26686. */
  26687. private _originalBlendValue;
  26688. /**
  26689. * The offsets cache of the runtime animation
  26690. */
  26691. private _offsetsCache;
  26692. /**
  26693. * The high limits cache of the runtime animation
  26694. */
  26695. private _highLimitsCache;
  26696. /**
  26697. * Specifies if the runtime animation has been stopped
  26698. */
  26699. private _stopped;
  26700. /**
  26701. * The blending factor of the runtime animation
  26702. */
  26703. private _blendingFactor;
  26704. /**
  26705. * The BabylonJS scene
  26706. */
  26707. private _scene;
  26708. /**
  26709. * The current value of the runtime animation
  26710. */
  26711. private _currentValue;
  26712. /** @hidden */
  26713. _animationState: _IAnimationState;
  26714. /**
  26715. * The active target of the runtime animation
  26716. */
  26717. private _activeTargets;
  26718. private _currentActiveTarget;
  26719. private _directTarget;
  26720. /**
  26721. * The target path of the runtime animation
  26722. */
  26723. private _targetPath;
  26724. /**
  26725. * The weight of the runtime animation
  26726. */
  26727. private _weight;
  26728. /**
  26729. * The ratio offset of the runtime animation
  26730. */
  26731. private _ratioOffset;
  26732. /**
  26733. * The previous delay of the runtime animation
  26734. */
  26735. private _previousDelay;
  26736. /**
  26737. * The previous ratio of the runtime animation
  26738. */
  26739. private _previousRatio;
  26740. private _enableBlending;
  26741. private _keys;
  26742. private _minFrame;
  26743. private _maxFrame;
  26744. private _minValue;
  26745. private _maxValue;
  26746. private _targetIsArray;
  26747. /**
  26748. * Gets the current frame of the runtime animation
  26749. */
  26750. get currentFrame(): number;
  26751. /**
  26752. * Gets the weight of the runtime animation
  26753. */
  26754. get weight(): number;
  26755. /**
  26756. * Gets the current value of the runtime animation
  26757. */
  26758. get currentValue(): any;
  26759. /**
  26760. * Gets the target path of the runtime animation
  26761. */
  26762. get targetPath(): string;
  26763. /**
  26764. * Gets the actual target of the runtime animation
  26765. */
  26766. get target(): any;
  26767. /**
  26768. * Gets the additive state of the runtime animation
  26769. */
  26770. get isAdditive(): boolean;
  26771. /** @hidden */
  26772. _onLoop: () => void;
  26773. /**
  26774. * Create a new RuntimeAnimation object
  26775. * @param target defines the target of the animation
  26776. * @param animation defines the source animation object
  26777. * @param scene defines the hosting scene
  26778. * @param host defines the initiating Animatable
  26779. */
  26780. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  26781. private _preparePath;
  26782. /**
  26783. * Gets the animation from the runtime animation
  26784. */
  26785. get animation(): Animation;
  26786. /**
  26787. * Resets the runtime animation to the beginning
  26788. * @param restoreOriginal defines whether to restore the target property to the original value
  26789. */
  26790. reset(restoreOriginal?: boolean): void;
  26791. /**
  26792. * Specifies if the runtime animation is stopped
  26793. * @returns Boolean specifying if the runtime animation is stopped
  26794. */
  26795. isStopped(): boolean;
  26796. /**
  26797. * Disposes of the runtime animation
  26798. */
  26799. dispose(): void;
  26800. /**
  26801. * Apply the interpolated value to the target
  26802. * @param currentValue defines the value computed by the animation
  26803. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  26804. */
  26805. setValue(currentValue: any, weight: number): void;
  26806. private _getOriginalValues;
  26807. private _setValue;
  26808. /**
  26809. * Gets the loop pmode of the runtime animation
  26810. * @returns Loop Mode
  26811. */
  26812. private _getCorrectLoopMode;
  26813. /**
  26814. * Move the current animation to a given frame
  26815. * @param frame defines the frame to move to
  26816. */
  26817. goToFrame(frame: number): void;
  26818. /**
  26819. * @hidden Internal use only
  26820. */
  26821. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  26822. /**
  26823. * Execute the current animation
  26824. * @param delay defines the delay to add to the current frame
  26825. * @param from defines the lower bound of the animation range
  26826. * @param to defines the upper bound of the animation range
  26827. * @param loop defines if the current animation must loop
  26828. * @param speedRatio defines the current speed ratio
  26829. * @param weight defines the weight of the animation (default is -1 so no weight)
  26830. * @param onLoop optional callback called when animation loops
  26831. * @returns a boolean indicating if the animation is running
  26832. */
  26833. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  26834. }
  26835. }
  26836. declare module "babylonjs/Animations/animatable" {
  26837. import { Animation } from "babylonjs/Animations/animation";
  26838. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26839. import { Nullable } from "babylonjs/types";
  26840. import { Observable } from "babylonjs/Misc/observable";
  26841. import { Scene } from "babylonjs/scene";
  26842. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  26843. import { Node } from "babylonjs/node";
  26844. /**
  26845. * Class used to store an actual running animation
  26846. */
  26847. export class Animatable {
  26848. /** defines the target object */
  26849. target: any;
  26850. /** defines the starting frame number (default is 0) */
  26851. fromFrame: number;
  26852. /** defines the ending frame number (default is 100) */
  26853. toFrame: number;
  26854. /** defines if the animation must loop (default is false) */
  26855. loopAnimation: boolean;
  26856. /** defines a callback to call when animation ends if it is not looping */
  26857. onAnimationEnd?: (() => void) | null | undefined;
  26858. /** defines a callback to call when animation loops */
  26859. onAnimationLoop?: (() => void) | null | undefined;
  26860. /** defines whether the animation should be evaluated additively */
  26861. isAdditive: boolean;
  26862. private _localDelayOffset;
  26863. private _pausedDelay;
  26864. private _runtimeAnimations;
  26865. private _paused;
  26866. private _scene;
  26867. private _speedRatio;
  26868. private _weight;
  26869. private _syncRoot;
  26870. /**
  26871. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  26872. * This will only apply for non looping animation (default is true)
  26873. */
  26874. disposeOnEnd: boolean;
  26875. /**
  26876. * Gets a boolean indicating if the animation has started
  26877. */
  26878. animationStarted: boolean;
  26879. /**
  26880. * Observer raised when the animation ends
  26881. */
  26882. onAnimationEndObservable: Observable<Animatable>;
  26883. /**
  26884. * Observer raised when the animation loops
  26885. */
  26886. onAnimationLoopObservable: Observable<Animatable>;
  26887. /**
  26888. * Gets the root Animatable used to synchronize and normalize animations
  26889. */
  26890. get syncRoot(): Nullable<Animatable>;
  26891. /**
  26892. * Gets the current frame of the first RuntimeAnimation
  26893. * Used to synchronize Animatables
  26894. */
  26895. get masterFrame(): number;
  26896. /**
  26897. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  26898. */
  26899. get weight(): number;
  26900. set weight(value: number);
  26901. /**
  26902. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  26903. */
  26904. get speedRatio(): number;
  26905. set speedRatio(value: number);
  26906. /**
  26907. * Creates a new Animatable
  26908. * @param scene defines the hosting scene
  26909. * @param target defines the target object
  26910. * @param fromFrame defines the starting frame number (default is 0)
  26911. * @param toFrame defines the ending frame number (default is 100)
  26912. * @param loopAnimation defines if the animation must loop (default is false)
  26913. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  26914. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  26915. * @param animations defines a group of animation to add to the new Animatable
  26916. * @param onAnimationLoop defines a callback to call when animation loops
  26917. * @param isAdditive defines whether the animation should be evaluated additively
  26918. */
  26919. constructor(scene: Scene,
  26920. /** defines the target object */
  26921. target: any,
  26922. /** defines the starting frame number (default is 0) */
  26923. fromFrame?: number,
  26924. /** defines the ending frame number (default is 100) */
  26925. toFrame?: number,
  26926. /** defines if the animation must loop (default is false) */
  26927. loopAnimation?: boolean, speedRatio?: number,
  26928. /** defines a callback to call when animation ends if it is not looping */
  26929. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  26930. /** defines a callback to call when animation loops */
  26931. onAnimationLoop?: (() => void) | null | undefined,
  26932. /** defines whether the animation should be evaluated additively */
  26933. isAdditive?: boolean);
  26934. /**
  26935. * Synchronize and normalize current Animatable with a source Animatable
  26936. * This is useful when using animation weights and when animations are not of the same length
  26937. * @param root defines the root Animatable to synchronize with
  26938. * @returns the current Animatable
  26939. */
  26940. syncWith(root: Animatable): Animatable;
  26941. /**
  26942. * Gets the list of runtime animations
  26943. * @returns an array of RuntimeAnimation
  26944. */
  26945. getAnimations(): RuntimeAnimation[];
  26946. /**
  26947. * Adds more animations to the current animatable
  26948. * @param target defines the target of the animations
  26949. * @param animations defines the new animations to add
  26950. */
  26951. appendAnimations(target: any, animations: Animation[]): void;
  26952. /**
  26953. * Gets the source animation for a specific property
  26954. * @param property defines the property to look for
  26955. * @returns null or the source animation for the given property
  26956. */
  26957. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  26958. /**
  26959. * Gets the runtime animation for a specific property
  26960. * @param property defines the property to look for
  26961. * @returns null or the runtime animation for the given property
  26962. */
  26963. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  26964. /**
  26965. * Resets the animatable to its original state
  26966. */
  26967. reset(): void;
  26968. /**
  26969. * Allows the animatable to blend with current running animations
  26970. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26971. * @param blendingSpeed defines the blending speed to use
  26972. */
  26973. enableBlending(blendingSpeed: number): void;
  26974. /**
  26975. * Disable animation blending
  26976. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26977. */
  26978. disableBlending(): void;
  26979. /**
  26980. * Jump directly to a given frame
  26981. * @param frame defines the frame to jump to
  26982. */
  26983. goToFrame(frame: number): void;
  26984. /**
  26985. * Pause the animation
  26986. */
  26987. pause(): void;
  26988. /**
  26989. * Restart the animation
  26990. */
  26991. restart(): void;
  26992. private _raiseOnAnimationEnd;
  26993. /**
  26994. * Stop and delete the current animation
  26995. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26996. * @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)
  26997. */
  26998. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26999. /**
  27000. * Wait asynchronously for the animation to end
  27001. * @returns a promise which will be fulfilled when the animation ends
  27002. */
  27003. waitAsync(): Promise<Animatable>;
  27004. /** @hidden */
  27005. _animate(delay: number): boolean;
  27006. }
  27007. module "babylonjs/scene" {
  27008. interface Scene {
  27009. /** @hidden */
  27010. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  27011. /** @hidden */
  27012. _processLateAnimationBindingsForMatrices(holder: {
  27013. totalWeight: number;
  27014. totalAdditiveWeight: number;
  27015. animations: RuntimeAnimation[];
  27016. additiveAnimations: RuntimeAnimation[];
  27017. originalValue: Matrix;
  27018. }): any;
  27019. /** @hidden */
  27020. _processLateAnimationBindingsForQuaternions(holder: {
  27021. totalWeight: number;
  27022. totalAdditiveWeight: number;
  27023. animations: RuntimeAnimation[];
  27024. additiveAnimations: RuntimeAnimation[];
  27025. originalValue: Quaternion;
  27026. }, refQuaternion: Quaternion): Quaternion;
  27027. /** @hidden */
  27028. _processLateAnimationBindings(): void;
  27029. /**
  27030. * Will start the animation sequence of a given target
  27031. * @param target defines the target
  27032. * @param from defines from which frame should animation start
  27033. * @param to defines until which frame should animation run.
  27034. * @param weight defines the weight to apply to the animation (1.0 by default)
  27035. * @param loop defines if the animation loops
  27036. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  27037. * @param onAnimationEnd defines the function to be executed when the animation ends
  27038. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  27039. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  27040. * @param onAnimationLoop defines the callback to call when an animation loops
  27041. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  27042. * @returns the animatable object created for this animation
  27043. */
  27044. 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;
  27045. /**
  27046. * Will start the animation sequence of a given target
  27047. * @param target defines the target
  27048. * @param from defines from which frame should animation start
  27049. * @param to defines until which frame should animation run.
  27050. * @param loop defines if the animation loops
  27051. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  27052. * @param onAnimationEnd defines the function to be executed when the animation ends
  27053. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  27054. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  27055. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  27056. * @param onAnimationLoop defines the callback to call when an animation loops
  27057. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  27058. * @returns the animatable object created for this animation
  27059. */
  27060. 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;
  27061. /**
  27062. * Will start the animation sequence of a given target and its hierarchy
  27063. * @param target defines the target
  27064. * @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.
  27065. * @param from defines from which frame should animation start
  27066. * @param to defines until which frame should animation run.
  27067. * @param loop defines if the animation loops
  27068. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  27069. * @param onAnimationEnd defines the function to be executed when the animation ends
  27070. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  27071. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  27072. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  27073. * @param onAnimationLoop defines the callback to call when an animation loops
  27074. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  27075. * @returns the list of created animatables
  27076. */
  27077. 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[];
  27078. /**
  27079. * Begin a new animation on a given node
  27080. * @param target defines the target where the animation will take place
  27081. * @param animations defines the list of animations to start
  27082. * @param from defines the initial value
  27083. * @param to defines the final value
  27084. * @param loop defines if you want animation to loop (off by default)
  27085. * @param speedRatio defines the speed ratio to apply to all animations
  27086. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27087. * @param onAnimationLoop defines the callback to call when an animation loops
  27088. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  27089. * @returns the list of created animatables
  27090. */
  27091. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  27092. /**
  27093. * Begin a new animation on a given node and its hierarchy
  27094. * @param target defines the root node where the animation will take place
  27095. * @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.
  27096. * @param animations defines the list of animations to start
  27097. * @param from defines the initial value
  27098. * @param to defines the final value
  27099. * @param loop defines if you want animation to loop (off by default)
  27100. * @param speedRatio defines the speed ratio to apply to all animations
  27101. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27102. * @param onAnimationLoop defines the callback to call when an animation loops
  27103. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  27104. * @returns the list of animatables created for all nodes
  27105. */
  27106. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  27107. /**
  27108. * Gets the animatable associated with a specific target
  27109. * @param target defines the target of the animatable
  27110. * @returns the required animatable if found
  27111. */
  27112. getAnimatableByTarget(target: any): Nullable<Animatable>;
  27113. /**
  27114. * Gets all animatables associated with a given target
  27115. * @param target defines the target to look animatables for
  27116. * @returns an array of Animatables
  27117. */
  27118. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  27119. /**
  27120. * Stops and removes all animations that have been applied to the scene
  27121. */
  27122. stopAllAnimations(): void;
  27123. /**
  27124. * Gets the current delta time used by animation engine
  27125. */
  27126. deltaTime: number;
  27127. }
  27128. }
  27129. module "babylonjs/Bones/bone" {
  27130. interface Bone {
  27131. /**
  27132. * Copy an animation range from another bone
  27133. * @param source defines the source bone
  27134. * @param rangeName defines the range name to copy
  27135. * @param frameOffset defines the frame offset
  27136. * @param rescaleAsRequired defines if rescaling must be applied if required
  27137. * @param skelDimensionsRatio defines the scaling ratio
  27138. * @returns true if operation was successful
  27139. */
  27140. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  27141. }
  27142. }
  27143. }
  27144. declare module "babylonjs/Animations/animationPropertiesOverride" {
  27145. /**
  27146. * Class used to override all child animations of a given target
  27147. */
  27148. export class AnimationPropertiesOverride {
  27149. /**
  27150. * Gets or sets a value indicating if animation blending must be used
  27151. */
  27152. enableBlending: boolean;
  27153. /**
  27154. * Gets or sets the blending speed to use when enableBlending is true
  27155. */
  27156. blendingSpeed: number;
  27157. /**
  27158. * Gets or sets the default loop mode to use
  27159. */
  27160. loopMode: number;
  27161. }
  27162. }
  27163. declare module "babylonjs/Bones/skeleton" {
  27164. import { Bone } from "babylonjs/Bones/bone";
  27165. import { Observable } from "babylonjs/Misc/observable";
  27166. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  27167. import { Scene } from "babylonjs/scene";
  27168. import { Nullable } from "babylonjs/types";
  27169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27170. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  27171. import { Animatable } from "babylonjs/Animations/animatable";
  27172. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27173. import { Animation } from "babylonjs/Animations/animation";
  27174. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27175. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27176. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27177. /**
  27178. * Class used to handle skinning animations
  27179. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27180. */
  27181. export class Skeleton implements IAnimatable {
  27182. /** defines the skeleton name */
  27183. name: string;
  27184. /** defines the skeleton Id */
  27185. id: string;
  27186. /**
  27187. * Defines the list of child bones
  27188. */
  27189. bones: Bone[];
  27190. /**
  27191. * Defines an estimate of the dimension of the skeleton at rest
  27192. */
  27193. dimensionsAtRest: Vector3;
  27194. /**
  27195. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  27196. */
  27197. needInitialSkinMatrix: boolean;
  27198. /**
  27199. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  27200. */
  27201. overrideMesh: Nullable<AbstractMesh>;
  27202. /**
  27203. * Gets the list of animations attached to this skeleton
  27204. */
  27205. animations: Array<Animation>;
  27206. private _scene;
  27207. private _isDirty;
  27208. private _transformMatrices;
  27209. private _transformMatrixTexture;
  27210. private _meshesWithPoseMatrix;
  27211. private _animatables;
  27212. private _identity;
  27213. private _synchronizedWithMesh;
  27214. private _ranges;
  27215. private _lastAbsoluteTransformsUpdateId;
  27216. private _canUseTextureForBones;
  27217. private _uniqueId;
  27218. /** @hidden */
  27219. _numBonesWithLinkedTransformNode: number;
  27220. /** @hidden */
  27221. _hasWaitingData: Nullable<boolean>;
  27222. /** @hidden */
  27223. _waitingOverrideMeshId: Nullable<string>;
  27224. /**
  27225. * Specifies if the skeleton should be serialized
  27226. */
  27227. doNotSerialize: boolean;
  27228. private _useTextureToStoreBoneMatrices;
  27229. /**
  27230. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  27231. * Please note that this option is not available if the hardware does not support it
  27232. */
  27233. get useTextureToStoreBoneMatrices(): boolean;
  27234. set useTextureToStoreBoneMatrices(value: boolean);
  27235. private _animationPropertiesOverride;
  27236. /**
  27237. * Gets or sets the animation properties override
  27238. */
  27239. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27240. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27241. /**
  27242. * List of inspectable custom properties (used by the Inspector)
  27243. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27244. */
  27245. inspectableCustomProperties: IInspectable[];
  27246. /**
  27247. * An observable triggered before computing the skeleton's matrices
  27248. */
  27249. onBeforeComputeObservable: Observable<Skeleton>;
  27250. /**
  27251. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  27252. */
  27253. get isUsingTextureForMatrices(): boolean;
  27254. /**
  27255. * Gets the unique ID of this skeleton
  27256. */
  27257. get uniqueId(): number;
  27258. /**
  27259. * Creates a new skeleton
  27260. * @param name defines the skeleton name
  27261. * @param id defines the skeleton Id
  27262. * @param scene defines the hosting scene
  27263. */
  27264. constructor(
  27265. /** defines the skeleton name */
  27266. name: string,
  27267. /** defines the skeleton Id */
  27268. id: string, scene: Scene);
  27269. /**
  27270. * Gets the current object class name.
  27271. * @return the class name
  27272. */
  27273. getClassName(): string;
  27274. /**
  27275. * Returns an array containing the root bones
  27276. * @returns an array containing the root bones
  27277. */
  27278. getChildren(): Array<Bone>;
  27279. /**
  27280. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  27281. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  27282. * @returns a Float32Array containing matrices data
  27283. */
  27284. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  27285. /**
  27286. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  27287. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  27288. * @returns a raw texture containing the data
  27289. */
  27290. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  27291. /**
  27292. * Gets the current hosting scene
  27293. * @returns a scene object
  27294. */
  27295. getScene(): Scene;
  27296. /**
  27297. * Gets a string representing the current skeleton data
  27298. * @param fullDetails defines a boolean indicating if we want a verbose version
  27299. * @returns a string representing the current skeleton data
  27300. */
  27301. toString(fullDetails?: boolean): string;
  27302. /**
  27303. * Get bone's index searching by name
  27304. * @param name defines bone's name to search for
  27305. * @return the indice of the bone. Returns -1 if not found
  27306. */
  27307. getBoneIndexByName(name: string): number;
  27308. /**
  27309. * Create a new animation range
  27310. * @param name defines the name of the range
  27311. * @param from defines the start key
  27312. * @param to defines the end key
  27313. */
  27314. createAnimationRange(name: string, from: number, to: number): void;
  27315. /**
  27316. * Delete a specific animation range
  27317. * @param name defines the name of the range
  27318. * @param deleteFrames defines if frames must be removed as well
  27319. */
  27320. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27321. /**
  27322. * Gets a specific animation range
  27323. * @param name defines the name of the range to look for
  27324. * @returns the requested animation range or null if not found
  27325. */
  27326. getAnimationRange(name: string): Nullable<AnimationRange>;
  27327. /**
  27328. * Gets the list of all animation ranges defined on this skeleton
  27329. * @returns an array
  27330. */
  27331. getAnimationRanges(): Nullable<AnimationRange>[];
  27332. /**
  27333. * Copy animation range from a source skeleton.
  27334. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  27335. * @param source defines the source skeleton
  27336. * @param name defines the name of the range to copy
  27337. * @param rescaleAsRequired defines if rescaling must be applied if required
  27338. * @returns true if operation was successful
  27339. */
  27340. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  27341. /**
  27342. * Forces the skeleton to go to rest pose
  27343. */
  27344. returnToRest(): void;
  27345. private _getHighestAnimationFrame;
  27346. /**
  27347. * Begin a specific animation range
  27348. * @param name defines the name of the range to start
  27349. * @param loop defines if looping must be turned on (false by default)
  27350. * @param speedRatio defines the speed ratio to apply (1 by default)
  27351. * @param onAnimationEnd defines a callback which will be called when animation will end
  27352. * @returns a new animatable
  27353. */
  27354. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27355. /**
  27356. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  27357. * @param skeleton defines the Skeleton containing the animation range to convert
  27358. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  27359. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  27360. * @returns the original skeleton
  27361. */
  27362. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  27363. /** @hidden */
  27364. _markAsDirty(): void;
  27365. /** @hidden */
  27366. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27367. /** @hidden */
  27368. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27369. private _computeTransformMatrices;
  27370. /**
  27371. * Build all resources required to render a skeleton
  27372. */
  27373. prepare(): void;
  27374. /**
  27375. * Gets the list of animatables currently running for this skeleton
  27376. * @returns an array of animatables
  27377. */
  27378. getAnimatables(): IAnimatable[];
  27379. /**
  27380. * Clone the current skeleton
  27381. * @param name defines the name of the new skeleton
  27382. * @param id defines the id of the new skeleton
  27383. * @returns the new skeleton
  27384. */
  27385. clone(name: string, id?: string): Skeleton;
  27386. /**
  27387. * Enable animation blending for this skeleton
  27388. * @param blendingSpeed defines the blending speed to apply
  27389. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  27390. */
  27391. enableBlending(blendingSpeed?: number): void;
  27392. /**
  27393. * Releases all resources associated with the current skeleton
  27394. */
  27395. dispose(): void;
  27396. /**
  27397. * Serialize the skeleton in a JSON object
  27398. * @returns a JSON object
  27399. */
  27400. serialize(): any;
  27401. /**
  27402. * Creates a new skeleton from serialized data
  27403. * @param parsedSkeleton defines the serialized data
  27404. * @param scene defines the hosting scene
  27405. * @returns a new skeleton
  27406. */
  27407. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  27408. /**
  27409. * Compute all node absolute transforms
  27410. * @param forceUpdate defines if computation must be done even if cache is up to date
  27411. */
  27412. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  27413. /**
  27414. * Gets the root pose matrix
  27415. * @returns a matrix
  27416. */
  27417. getPoseMatrix(): Nullable<Matrix>;
  27418. /**
  27419. * Sorts bones per internal index
  27420. */
  27421. sortBones(): void;
  27422. private _sortBones;
  27423. /**
  27424. * Set the current local matrix as the restPose for all bones in the skeleton.
  27425. */
  27426. setCurrentPoseAsRest(): void;
  27427. }
  27428. }
  27429. declare module "babylonjs/Bones/bone" {
  27430. import { Skeleton } from "babylonjs/Bones/skeleton";
  27431. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  27432. import { Nullable } from "babylonjs/types";
  27433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27434. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27435. import { Node } from "babylonjs/node";
  27436. import { Space } from "babylonjs/Maths/math.axis";
  27437. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27438. /**
  27439. * Class used to store bone information
  27440. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27441. */
  27442. export class Bone extends Node {
  27443. /**
  27444. * defines the bone name
  27445. */
  27446. name: string;
  27447. private static _tmpVecs;
  27448. private static _tmpQuat;
  27449. private static _tmpMats;
  27450. /**
  27451. * Gets the list of child bones
  27452. */
  27453. children: Bone[];
  27454. /** Gets the animations associated with this bone */
  27455. animations: import("babylonjs/Animations/animation").Animation[];
  27456. /**
  27457. * Gets or sets bone length
  27458. */
  27459. length: number;
  27460. /**
  27461. * @hidden Internal only
  27462. * Set this value to map this bone to a different index in the transform matrices
  27463. * Set this value to -1 to exclude the bone from the transform matrices
  27464. */
  27465. _index: Nullable<number>;
  27466. private _skeleton;
  27467. private _localMatrix;
  27468. private _restPose;
  27469. private _bindPose;
  27470. private _baseMatrix;
  27471. private _absoluteTransform;
  27472. private _invertedAbsoluteTransform;
  27473. private _parent;
  27474. private _scalingDeterminant;
  27475. private _worldTransform;
  27476. private _localScaling;
  27477. private _localRotation;
  27478. private _localPosition;
  27479. private _needToDecompose;
  27480. private _needToCompose;
  27481. /** @hidden */
  27482. _linkedTransformNode: Nullable<TransformNode>;
  27483. /** @hidden */
  27484. _waitingTransformNodeId: Nullable<string>;
  27485. /** @hidden */
  27486. get _matrix(): Matrix;
  27487. /** @hidden */
  27488. set _matrix(value: Matrix);
  27489. /**
  27490. * Create a new bone
  27491. * @param name defines the bone name
  27492. * @param skeleton defines the parent skeleton
  27493. * @param parentBone defines the parent (can be null if the bone is the root)
  27494. * @param localMatrix defines the local matrix
  27495. * @param restPose defines the rest pose matrix
  27496. * @param baseMatrix defines the base matrix
  27497. * @param index defines index of the bone in the hierarchy
  27498. */
  27499. constructor(
  27500. /**
  27501. * defines the bone name
  27502. */
  27503. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  27504. /**
  27505. * Gets the current object class name.
  27506. * @return the class name
  27507. */
  27508. getClassName(): string;
  27509. /**
  27510. * Gets the parent skeleton
  27511. * @returns a skeleton
  27512. */
  27513. getSkeleton(): Skeleton;
  27514. /**
  27515. * Gets parent bone
  27516. * @returns a bone or null if the bone is the root of the bone hierarchy
  27517. */
  27518. getParent(): Nullable<Bone>;
  27519. /**
  27520. * Returns an array containing the root bones
  27521. * @returns an array containing the root bones
  27522. */
  27523. getChildren(): Array<Bone>;
  27524. /**
  27525. * Gets the node index in matrix array generated for rendering
  27526. * @returns the node index
  27527. */
  27528. getIndex(): number;
  27529. /**
  27530. * Sets the parent bone
  27531. * @param parent defines the parent (can be null if the bone is the root)
  27532. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27533. */
  27534. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  27535. /**
  27536. * Gets the local matrix
  27537. * @returns a matrix
  27538. */
  27539. getLocalMatrix(): Matrix;
  27540. /**
  27541. * Gets the base matrix (initial matrix which remains unchanged)
  27542. * @returns a matrix
  27543. */
  27544. getBaseMatrix(): Matrix;
  27545. /**
  27546. * Gets the rest pose matrix
  27547. * @returns a matrix
  27548. */
  27549. getRestPose(): Matrix;
  27550. /**
  27551. * Sets the rest pose matrix
  27552. * @param matrix the local-space rest pose to set for this bone
  27553. */
  27554. setRestPose(matrix: Matrix): void;
  27555. /**
  27556. * Gets the bind pose matrix
  27557. * @returns the bind pose matrix
  27558. */
  27559. getBindPose(): Matrix;
  27560. /**
  27561. * Sets the bind pose matrix
  27562. * @param matrix the local-space bind pose to set for this bone
  27563. */
  27564. setBindPose(matrix: Matrix): void;
  27565. /**
  27566. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  27567. */
  27568. getWorldMatrix(): Matrix;
  27569. /**
  27570. * Sets the local matrix to rest pose matrix
  27571. */
  27572. returnToRest(): void;
  27573. /**
  27574. * Gets the inverse of the absolute transform matrix.
  27575. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  27576. * @returns a matrix
  27577. */
  27578. getInvertedAbsoluteTransform(): Matrix;
  27579. /**
  27580. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  27581. * @returns a matrix
  27582. */
  27583. getAbsoluteTransform(): Matrix;
  27584. /**
  27585. * Links with the given transform node.
  27586. * The local matrix of this bone is copied from the transform node every frame.
  27587. * @param transformNode defines the transform node to link to
  27588. */
  27589. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  27590. /**
  27591. * Gets the node used to drive the bone's transformation
  27592. * @returns a transform node or null
  27593. */
  27594. getTransformNode(): Nullable<TransformNode>;
  27595. /** Gets or sets current position (in local space) */
  27596. get position(): Vector3;
  27597. set position(newPosition: Vector3);
  27598. /** Gets or sets current rotation (in local space) */
  27599. get rotation(): Vector3;
  27600. set rotation(newRotation: Vector3);
  27601. /** Gets or sets current rotation quaternion (in local space) */
  27602. get rotationQuaternion(): Quaternion;
  27603. set rotationQuaternion(newRotation: Quaternion);
  27604. /** Gets or sets current scaling (in local space) */
  27605. get scaling(): Vector3;
  27606. set scaling(newScaling: Vector3);
  27607. /**
  27608. * Gets the animation properties override
  27609. */
  27610. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27611. private _decompose;
  27612. private _compose;
  27613. /**
  27614. * Update the base and local matrices
  27615. * @param matrix defines the new base or local matrix
  27616. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27617. * @param updateLocalMatrix defines if the local matrix should be updated
  27618. */
  27619. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  27620. /** @hidden */
  27621. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  27622. /**
  27623. * Flag the bone as dirty (Forcing it to update everything)
  27624. */
  27625. markAsDirty(): void;
  27626. /** @hidden */
  27627. _markAsDirtyAndCompose(): void;
  27628. private _markAsDirtyAndDecompose;
  27629. /**
  27630. * Translate the bone in local or world space
  27631. * @param vec The amount to translate the bone
  27632. * @param space The space that the translation is in
  27633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27634. */
  27635. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27636. /**
  27637. * Set the position of the bone in local or world space
  27638. * @param position The position to set the bone
  27639. * @param space The space that the position is in
  27640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27641. */
  27642. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27643. /**
  27644. * Set the absolute position of the bone (world space)
  27645. * @param position The position to set the bone
  27646. * @param mesh The mesh that this bone is attached to
  27647. */
  27648. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  27649. /**
  27650. * Scale the bone on the x, y and z axes (in local space)
  27651. * @param x The amount to scale the bone on the x axis
  27652. * @param y The amount to scale the bone on the y axis
  27653. * @param z The amount to scale the bone on the z axis
  27654. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  27655. */
  27656. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  27657. /**
  27658. * Set the bone scaling in local space
  27659. * @param scale defines the scaling vector
  27660. */
  27661. setScale(scale: Vector3): void;
  27662. /**
  27663. * Gets the current scaling in local space
  27664. * @returns the current scaling vector
  27665. */
  27666. getScale(): Vector3;
  27667. /**
  27668. * Gets the current scaling in local space and stores it in a target vector
  27669. * @param result defines the target vector
  27670. */
  27671. getScaleToRef(result: Vector3): void;
  27672. /**
  27673. * Set the yaw, pitch, and roll of the bone in local or world space
  27674. * @param yaw The rotation of the bone on the y axis
  27675. * @param pitch The rotation of the bone on the x axis
  27676. * @param roll The rotation of the bone on the z axis
  27677. * @param space The space that the axes of rotation are in
  27678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27679. */
  27680. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  27681. /**
  27682. * Add a rotation to the bone on an axis in local or world space
  27683. * @param axis The axis to rotate the bone on
  27684. * @param amount The amount to rotate the bone
  27685. * @param space The space that the axis is in
  27686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27687. */
  27688. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  27689. /**
  27690. * Set the rotation of the bone to a particular axis angle in local or world space
  27691. * @param axis The axis to rotate the bone on
  27692. * @param angle The angle that the bone should be rotated to
  27693. * @param space The space that the axis is in
  27694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27695. */
  27696. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  27697. /**
  27698. * Set the euler rotation of the bone in local or world space
  27699. * @param rotation The euler rotation that the bone should be set to
  27700. * @param space The space that the rotation is in
  27701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27702. */
  27703. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27704. /**
  27705. * Set the quaternion rotation of the bone in local or world space
  27706. * @param quat The quaternion rotation that the bone should be set to
  27707. * @param space The space that the rotation is in
  27708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27709. */
  27710. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  27711. /**
  27712. * Set the rotation matrix of the bone in local or world space
  27713. * @param rotMat The rotation matrix that the bone should be set to
  27714. * @param space The space that the rotation is in
  27715. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27716. */
  27717. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  27718. private _rotateWithMatrix;
  27719. private _getNegativeRotationToRef;
  27720. /**
  27721. * Get the position of the bone in local or world space
  27722. * @param space The space that the returned position is in
  27723. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27724. * @returns The position of the bone
  27725. */
  27726. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27727. /**
  27728. * Copy the position of the bone to a vector3 in local or world space
  27729. * @param space The space that the returned position is in
  27730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27731. * @param result The vector3 to copy the position to
  27732. */
  27733. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  27734. /**
  27735. * Get the absolute position of the bone (world space)
  27736. * @param mesh The mesh that this bone is attached to
  27737. * @returns The absolute position of the bone
  27738. */
  27739. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  27740. /**
  27741. * Copy the absolute position of the bone (world space) to the result param
  27742. * @param mesh The mesh that this bone is attached to
  27743. * @param result The vector3 to copy the absolute position to
  27744. */
  27745. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  27746. /**
  27747. * Compute the absolute transforms of this bone and its children
  27748. */
  27749. computeAbsoluteTransforms(): void;
  27750. /**
  27751. * Get the world direction from an axis that is in the local space of the bone
  27752. * @param localAxis The local direction that is used to compute the world direction
  27753. * @param mesh The mesh that this bone is attached to
  27754. * @returns The world direction
  27755. */
  27756. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27757. /**
  27758. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  27759. * @param localAxis The local direction that is used to compute the world direction
  27760. * @param mesh The mesh that this bone is attached to
  27761. * @param result The vector3 that the world direction will be copied to
  27762. */
  27763. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27764. /**
  27765. * Get the euler rotation of the bone in local or world space
  27766. * @param space The space that the rotation should be in
  27767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27768. * @returns The euler rotation
  27769. */
  27770. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27771. /**
  27772. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  27773. * @param space The space that the rotation should be in
  27774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27775. * @param result The vector3 that the rotation should be copied to
  27776. */
  27777. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27778. /**
  27779. * Get the quaternion rotation of the bone in either local or world space
  27780. * @param space The space that the rotation should be in
  27781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27782. * @returns The quaternion rotation
  27783. */
  27784. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  27785. /**
  27786. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  27787. * @param space The space that the rotation should be in
  27788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27789. * @param result The quaternion that the rotation should be copied to
  27790. */
  27791. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  27792. /**
  27793. * Get the rotation matrix of the bone in local or world space
  27794. * @param space The space that the rotation should be in
  27795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27796. * @returns The rotation matrix
  27797. */
  27798. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  27799. /**
  27800. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  27801. * @param space The space that the rotation should be in
  27802. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27803. * @param result The quaternion that the rotation should be copied to
  27804. */
  27805. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  27806. /**
  27807. * Get the world position of a point that is in the local space of the bone
  27808. * @param position The local position
  27809. * @param mesh The mesh that this bone is attached to
  27810. * @returns The world position
  27811. */
  27812. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27813. /**
  27814. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  27815. * @param position The local position
  27816. * @param mesh The mesh that this bone is attached to
  27817. * @param result The vector3 that the world position should be copied to
  27818. */
  27819. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27820. /**
  27821. * Get the local position of a point that is in world space
  27822. * @param position The world position
  27823. * @param mesh The mesh that this bone is attached to
  27824. * @returns The local position
  27825. */
  27826. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27827. /**
  27828. * Get the local position of a point that is in world space and copy it to the result param
  27829. * @param position The world position
  27830. * @param mesh The mesh that this bone is attached to
  27831. * @param result The vector3 that the local position should be copied to
  27832. */
  27833. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27834. /**
  27835. * Set the current local matrix as the restPose for this bone.
  27836. */
  27837. setCurrentPoseAsRest(): void;
  27838. }
  27839. }
  27840. declare module "babylonjs/Meshes/transformNode" {
  27841. import { DeepImmutable } from "babylonjs/types";
  27842. import { Observable } from "babylonjs/Misc/observable";
  27843. import { Nullable } from "babylonjs/types";
  27844. import { Camera } from "babylonjs/Cameras/camera";
  27845. import { Scene } from "babylonjs/scene";
  27846. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27847. import { Node } from "babylonjs/node";
  27848. import { Bone } from "babylonjs/Bones/bone";
  27849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27850. import { Space } from "babylonjs/Maths/math.axis";
  27851. /**
  27852. * 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.
  27853. * @see https://doc.babylonjs.com/how_to/transformnode
  27854. */
  27855. export class TransformNode extends Node {
  27856. /**
  27857. * Object will not rotate to face the camera
  27858. */
  27859. static BILLBOARDMODE_NONE: number;
  27860. /**
  27861. * Object will rotate to face the camera but only on the x axis
  27862. */
  27863. static BILLBOARDMODE_X: number;
  27864. /**
  27865. * Object will rotate to face the camera but only on the y axis
  27866. */
  27867. static BILLBOARDMODE_Y: number;
  27868. /**
  27869. * Object will rotate to face the camera but only on the z axis
  27870. */
  27871. static BILLBOARDMODE_Z: number;
  27872. /**
  27873. * Object will rotate to face the camera
  27874. */
  27875. static BILLBOARDMODE_ALL: number;
  27876. /**
  27877. * Object will rotate to face the camera's position instead of orientation
  27878. */
  27879. static BILLBOARDMODE_USE_POSITION: number;
  27880. private static _TmpRotation;
  27881. private static _TmpScaling;
  27882. private static _TmpTranslation;
  27883. private _forward;
  27884. private _forwardInverted;
  27885. private _up;
  27886. private _right;
  27887. private _rightInverted;
  27888. private _position;
  27889. private _rotation;
  27890. private _rotationQuaternion;
  27891. protected _scaling: Vector3;
  27892. protected _isDirty: boolean;
  27893. private _transformToBoneReferal;
  27894. private _isAbsoluteSynced;
  27895. private _billboardMode;
  27896. /**
  27897. * Gets or sets the billboard mode. Default is 0.
  27898. *
  27899. * | Value | Type | Description |
  27900. * | --- | --- | --- |
  27901. * | 0 | BILLBOARDMODE_NONE | |
  27902. * | 1 | BILLBOARDMODE_X | |
  27903. * | 2 | BILLBOARDMODE_Y | |
  27904. * | 4 | BILLBOARDMODE_Z | |
  27905. * | 7 | BILLBOARDMODE_ALL | |
  27906. *
  27907. */
  27908. get billboardMode(): number;
  27909. set billboardMode(value: number);
  27910. private _preserveParentRotationForBillboard;
  27911. /**
  27912. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  27913. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  27914. */
  27915. get preserveParentRotationForBillboard(): boolean;
  27916. set preserveParentRotationForBillboard(value: boolean);
  27917. /**
  27918. * 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
  27919. */
  27920. scalingDeterminant: number;
  27921. private _infiniteDistance;
  27922. /**
  27923. * Gets or sets the distance of the object to max, often used by skybox
  27924. */
  27925. get infiniteDistance(): boolean;
  27926. set infiniteDistance(value: boolean);
  27927. /**
  27928. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  27929. * By default the system will update normals to compensate
  27930. */
  27931. ignoreNonUniformScaling: boolean;
  27932. /**
  27933. * 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
  27934. */
  27935. reIntegrateRotationIntoRotationQuaternion: boolean;
  27936. /** @hidden */
  27937. _poseMatrix: Nullable<Matrix>;
  27938. /** @hidden */
  27939. _localMatrix: Matrix;
  27940. private _usePivotMatrix;
  27941. private _absolutePosition;
  27942. private _absoluteScaling;
  27943. private _absoluteRotationQuaternion;
  27944. private _pivotMatrix;
  27945. private _pivotMatrixInverse;
  27946. /** @hidden */
  27947. _postMultiplyPivotMatrix: boolean;
  27948. protected _isWorldMatrixFrozen: boolean;
  27949. /** @hidden */
  27950. _indexInSceneTransformNodesArray: number;
  27951. /**
  27952. * An event triggered after the world matrix is updated
  27953. */
  27954. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  27955. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  27956. /**
  27957. * Gets a string identifying the name of the class
  27958. * @returns "TransformNode" string
  27959. */
  27960. getClassName(): string;
  27961. /**
  27962. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  27963. */
  27964. get position(): Vector3;
  27965. set position(newPosition: Vector3);
  27966. /**
  27967. * 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)).
  27968. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  27969. */
  27970. get rotation(): Vector3;
  27971. set rotation(newRotation: Vector3);
  27972. /**
  27973. * 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)).
  27974. */
  27975. get scaling(): Vector3;
  27976. set scaling(newScaling: Vector3);
  27977. /**
  27978. * 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).
  27979. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  27980. */
  27981. get rotationQuaternion(): Nullable<Quaternion>;
  27982. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  27983. /**
  27984. * The forward direction of that transform in world space.
  27985. */
  27986. get forward(): Vector3;
  27987. /**
  27988. * The up direction of that transform in world space.
  27989. */
  27990. get up(): Vector3;
  27991. /**
  27992. * The right direction of that transform in world space.
  27993. */
  27994. get right(): Vector3;
  27995. /**
  27996. * Copies the parameter passed Matrix into the mesh Pose matrix.
  27997. * @param matrix the matrix to copy the pose from
  27998. * @returns this TransformNode.
  27999. */
  28000. updatePoseMatrix(matrix: Matrix): TransformNode;
  28001. /**
  28002. * Returns the mesh Pose matrix.
  28003. * @returns the pose matrix
  28004. */
  28005. getPoseMatrix(): Matrix;
  28006. /** @hidden */
  28007. _isSynchronized(): boolean;
  28008. /** @hidden */
  28009. _initCache(): void;
  28010. /**
  28011. * Flag the transform node as dirty (Forcing it to update everything)
  28012. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  28013. * @returns this transform node
  28014. */
  28015. markAsDirty(property: string): TransformNode;
  28016. /**
  28017. * Returns the current mesh absolute position.
  28018. * Returns a Vector3.
  28019. */
  28020. get absolutePosition(): Vector3;
  28021. /**
  28022. * Returns the current mesh absolute scaling.
  28023. * Returns a Vector3.
  28024. */
  28025. get absoluteScaling(): Vector3;
  28026. /**
  28027. * Returns the current mesh absolute rotation.
  28028. * Returns a Quaternion.
  28029. */
  28030. get absoluteRotationQuaternion(): Quaternion;
  28031. /**
  28032. * Sets a new matrix to apply before all other transformation
  28033. * @param matrix defines the transform matrix
  28034. * @returns the current TransformNode
  28035. */
  28036. setPreTransformMatrix(matrix: Matrix): TransformNode;
  28037. /**
  28038. * Sets a new pivot matrix to the current node
  28039. * @param matrix defines the new pivot matrix to use
  28040. * @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
  28041. * @returns the current TransformNode
  28042. */
  28043. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  28044. /**
  28045. * Returns the mesh pivot matrix.
  28046. * Default : Identity.
  28047. * @returns the matrix
  28048. */
  28049. getPivotMatrix(): Matrix;
  28050. /**
  28051. * Instantiate (when possible) or clone that node with its hierarchy
  28052. * @param newParent defines the new parent to use for the instance (or clone)
  28053. * @param options defines options to configure how copy is done
  28054. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  28055. * @returns an instance (or a clone) of the current node with its hiearchy
  28056. */
  28057. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28058. doNotInstantiate: boolean;
  28059. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28060. /**
  28061. * Prevents the World matrix to be computed any longer
  28062. * @param newWorldMatrix defines an optional matrix to use as world matrix
  28063. * @returns the TransformNode.
  28064. */
  28065. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  28066. /**
  28067. * Allows back the World matrix computation.
  28068. * @returns the TransformNode.
  28069. */
  28070. unfreezeWorldMatrix(): this;
  28071. /**
  28072. * True if the World matrix has been frozen.
  28073. */
  28074. get isWorldMatrixFrozen(): boolean;
  28075. /**
  28076. * Returns the mesh absolute position in the World.
  28077. * @returns a Vector3.
  28078. */
  28079. getAbsolutePosition(): Vector3;
  28080. /**
  28081. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  28082. * @param absolutePosition the absolute position to set
  28083. * @returns the TransformNode.
  28084. */
  28085. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28086. /**
  28087. * Sets the mesh position in its local space.
  28088. * @param vector3 the position to set in localspace
  28089. * @returns the TransformNode.
  28090. */
  28091. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  28092. /**
  28093. * Returns the mesh position in the local space from the current World matrix values.
  28094. * @returns a new Vector3.
  28095. */
  28096. getPositionExpressedInLocalSpace(): Vector3;
  28097. /**
  28098. * Translates the mesh along the passed Vector3 in its local space.
  28099. * @param vector3 the distance to translate in localspace
  28100. * @returns the TransformNode.
  28101. */
  28102. locallyTranslate(vector3: Vector3): TransformNode;
  28103. private static _lookAtVectorCache;
  28104. /**
  28105. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  28106. * @param targetPoint the position (must be in same space as current mesh) to look at
  28107. * @param yawCor optional yaw (y-axis) correction in radians
  28108. * @param pitchCor optional pitch (x-axis) correction in radians
  28109. * @param rollCor optional roll (z-axis) correction in radians
  28110. * @param space the chosen space of the target
  28111. * @returns the TransformNode.
  28112. */
  28113. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  28114. /**
  28115. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28116. * This Vector3 is expressed in the World space.
  28117. * @param localAxis axis to rotate
  28118. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28119. */
  28120. getDirection(localAxis: Vector3): Vector3;
  28121. /**
  28122. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  28123. * localAxis is expressed in the mesh local space.
  28124. * result is computed in the Wordl space from the mesh World matrix.
  28125. * @param localAxis axis to rotate
  28126. * @param result the resulting transformnode
  28127. * @returns this TransformNode.
  28128. */
  28129. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  28130. /**
  28131. * Sets this transform node rotation to the given local axis.
  28132. * @param localAxis the axis in local space
  28133. * @param yawCor optional yaw (y-axis) correction in radians
  28134. * @param pitchCor optional pitch (x-axis) correction in radians
  28135. * @param rollCor optional roll (z-axis) correction in radians
  28136. * @returns this TransformNode
  28137. */
  28138. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  28139. /**
  28140. * Sets a new pivot point to the current node
  28141. * @param point defines the new pivot point to use
  28142. * @param space defines if the point is in world or local space (local by default)
  28143. * @returns the current TransformNode
  28144. */
  28145. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  28146. /**
  28147. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  28148. * @returns the pivot point
  28149. */
  28150. getPivotPoint(): Vector3;
  28151. /**
  28152. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  28153. * @param result the vector3 to store the result
  28154. * @returns this TransformNode.
  28155. */
  28156. getPivotPointToRef(result: Vector3): TransformNode;
  28157. /**
  28158. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  28159. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  28160. */
  28161. getAbsolutePivotPoint(): Vector3;
  28162. /**
  28163. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  28164. * @param result vector3 to store the result
  28165. * @returns this TransformNode.
  28166. */
  28167. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  28168. /**
  28169. * Defines the passed node as the parent of the current node.
  28170. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  28171. * @see https://doc.babylonjs.com/how_to/parenting
  28172. * @param node the node ot set as the parent
  28173. * @returns this TransformNode.
  28174. */
  28175. setParent(node: Nullable<Node>): TransformNode;
  28176. private _nonUniformScaling;
  28177. /**
  28178. * True if the scaling property of this object is non uniform eg. (1,2,1)
  28179. */
  28180. get nonUniformScaling(): boolean;
  28181. /** @hidden */
  28182. _updateNonUniformScalingState(value: boolean): boolean;
  28183. /**
  28184. * Attach the current TransformNode to another TransformNode associated with a bone
  28185. * @param bone Bone affecting the TransformNode
  28186. * @param affectedTransformNode TransformNode associated with the bone
  28187. * @returns this object
  28188. */
  28189. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  28190. /**
  28191. * Detach the transform node if its associated with a bone
  28192. * @returns this object
  28193. */
  28194. detachFromBone(): TransformNode;
  28195. private static _rotationAxisCache;
  28196. /**
  28197. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  28198. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  28199. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28200. * The passed axis is also normalized.
  28201. * @param axis the axis to rotate around
  28202. * @param amount the amount to rotate in radians
  28203. * @param space Space to rotate in (Default: local)
  28204. * @returns the TransformNode.
  28205. */
  28206. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28207. /**
  28208. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  28209. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28210. * The passed axis is also normalized. .
  28211. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  28212. * @param point the point to rotate around
  28213. * @param axis the axis to rotate around
  28214. * @param amount the amount to rotate in radians
  28215. * @returns the TransformNode
  28216. */
  28217. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  28218. /**
  28219. * Translates the mesh along the axis vector for the passed distance in the given space.
  28220. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  28221. * @param axis the axis to translate in
  28222. * @param distance the distance to translate
  28223. * @param space Space to rotate in (Default: local)
  28224. * @returns the TransformNode.
  28225. */
  28226. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28227. /**
  28228. * Adds a rotation step to the mesh current rotation.
  28229. * x, y, z are Euler angles expressed in radians.
  28230. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  28231. * This means this rotation is made in the mesh local space only.
  28232. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  28233. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  28234. * ```javascript
  28235. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  28236. * ```
  28237. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  28238. * 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.
  28239. * @param x Rotation to add
  28240. * @param y Rotation to add
  28241. * @param z Rotation to add
  28242. * @returns the TransformNode.
  28243. */
  28244. addRotation(x: number, y: number, z: number): TransformNode;
  28245. /**
  28246. * @hidden
  28247. */
  28248. protected _getEffectiveParent(): Nullable<Node>;
  28249. /**
  28250. * Computes the world matrix of the node
  28251. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28252. * @returns the world matrix
  28253. */
  28254. computeWorldMatrix(force?: boolean): Matrix;
  28255. /**
  28256. * Resets this nodeTransform's local matrix to Matrix.Identity().
  28257. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  28258. */
  28259. resetLocalMatrix(independentOfChildren?: boolean): void;
  28260. protected _afterComputeWorldMatrix(): void;
  28261. /**
  28262. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  28263. * @param func callback function to add
  28264. *
  28265. * @returns the TransformNode.
  28266. */
  28267. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28268. /**
  28269. * Removes a registered callback function.
  28270. * @param func callback function to remove
  28271. * @returns the TransformNode.
  28272. */
  28273. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28274. /**
  28275. * Gets the position of the current mesh in camera space
  28276. * @param camera defines the camera to use
  28277. * @returns a position
  28278. */
  28279. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  28280. /**
  28281. * Returns the distance from the mesh to the active camera
  28282. * @param camera defines the camera to use
  28283. * @returns the distance
  28284. */
  28285. getDistanceToCamera(camera?: Nullable<Camera>): number;
  28286. /**
  28287. * Clone the current transform node
  28288. * @param name Name of the new clone
  28289. * @param newParent New parent for the clone
  28290. * @param doNotCloneChildren Do not clone children hierarchy
  28291. * @returns the new transform node
  28292. */
  28293. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  28294. /**
  28295. * Serializes the objects information.
  28296. * @param currentSerializationObject defines the object to serialize in
  28297. * @returns the serialized object
  28298. */
  28299. serialize(currentSerializationObject?: any): any;
  28300. /**
  28301. * Returns a new TransformNode object parsed from the source provided.
  28302. * @param parsedTransformNode is the source.
  28303. * @param scene the scene the object belongs to
  28304. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  28305. * @returns a new TransformNode object parsed from the source provided.
  28306. */
  28307. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  28308. /**
  28309. * Get all child-transformNodes of this node
  28310. * @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
  28311. * @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
  28312. * @returns an array of TransformNode
  28313. */
  28314. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  28315. /**
  28316. * Releases resources associated with this transform node.
  28317. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28318. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28319. */
  28320. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28321. /**
  28322. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28323. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28324. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28325. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28326. * @returns the current mesh
  28327. */
  28328. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  28329. private _syncAbsoluteScalingAndRotation;
  28330. }
  28331. }
  28332. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  28333. import { Observable } from "babylonjs/Misc/observable";
  28334. import { Nullable } from "babylonjs/types";
  28335. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28338. import { Ray } from "babylonjs/Culling/ray";
  28339. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  28340. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  28341. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  28342. /**
  28343. * Defines the types of pose enabled controllers that are supported
  28344. */
  28345. export enum PoseEnabledControllerType {
  28346. /**
  28347. * HTC Vive
  28348. */
  28349. VIVE = 0,
  28350. /**
  28351. * Oculus Rift
  28352. */
  28353. OCULUS = 1,
  28354. /**
  28355. * Windows mixed reality
  28356. */
  28357. WINDOWS = 2,
  28358. /**
  28359. * Samsung gear VR
  28360. */
  28361. GEAR_VR = 3,
  28362. /**
  28363. * Google Daydream
  28364. */
  28365. DAYDREAM = 4,
  28366. /**
  28367. * Generic
  28368. */
  28369. GENERIC = 5
  28370. }
  28371. /**
  28372. * Defines the MutableGamepadButton interface for the state of a gamepad button
  28373. */
  28374. export interface MutableGamepadButton {
  28375. /**
  28376. * Value of the button/trigger
  28377. */
  28378. value: number;
  28379. /**
  28380. * If the button/trigger is currently touched
  28381. */
  28382. touched: boolean;
  28383. /**
  28384. * If the button/trigger is currently pressed
  28385. */
  28386. pressed: boolean;
  28387. }
  28388. /**
  28389. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  28390. * @hidden
  28391. */
  28392. export interface ExtendedGamepadButton extends GamepadButton {
  28393. /**
  28394. * If the button/trigger is currently pressed
  28395. */
  28396. readonly pressed: boolean;
  28397. /**
  28398. * If the button/trigger is currently touched
  28399. */
  28400. readonly touched: boolean;
  28401. /**
  28402. * Value of the button/trigger
  28403. */
  28404. readonly value: number;
  28405. }
  28406. /** @hidden */
  28407. export interface _GamePadFactory {
  28408. /**
  28409. * Returns whether or not the current gamepad can be created for this type of controller.
  28410. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28411. * @returns true if it can be created, otherwise false
  28412. */
  28413. canCreate(gamepadInfo: any): boolean;
  28414. /**
  28415. * Creates a new instance of the Gamepad.
  28416. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28417. * @returns the new gamepad instance
  28418. */
  28419. create(gamepadInfo: any): Gamepad;
  28420. }
  28421. /**
  28422. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28423. */
  28424. export class PoseEnabledControllerHelper {
  28425. /** @hidden */
  28426. static _ControllerFactories: _GamePadFactory[];
  28427. /** @hidden */
  28428. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  28429. /**
  28430. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28431. * @param vrGamepad the gamepad to initialized
  28432. * @returns a vr controller of the type the gamepad identified as
  28433. */
  28434. static InitiateController(vrGamepad: any): Gamepad;
  28435. }
  28436. /**
  28437. * Defines the PoseEnabledController object that contains state of a vr capable controller
  28438. */
  28439. export class PoseEnabledController extends Gamepad implements PoseControlled {
  28440. /**
  28441. * If the controller is used in a webXR session
  28442. */
  28443. isXR: boolean;
  28444. private _deviceRoomPosition;
  28445. private _deviceRoomRotationQuaternion;
  28446. /**
  28447. * The device position in babylon space
  28448. */
  28449. devicePosition: Vector3;
  28450. /**
  28451. * The device rotation in babylon space
  28452. */
  28453. deviceRotationQuaternion: Quaternion;
  28454. /**
  28455. * The scale factor of the device in babylon space
  28456. */
  28457. deviceScaleFactor: number;
  28458. /**
  28459. * (Likely devicePosition should be used instead) The device position in its room space
  28460. */
  28461. position: Vector3;
  28462. /**
  28463. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  28464. */
  28465. rotationQuaternion: Quaternion;
  28466. /**
  28467. * The type of controller (Eg. Windows mixed reality)
  28468. */
  28469. controllerType: PoseEnabledControllerType;
  28470. protected _calculatedPosition: Vector3;
  28471. private _calculatedRotation;
  28472. /**
  28473. * The raw pose from the device
  28474. */
  28475. rawPose: DevicePose;
  28476. private _trackPosition;
  28477. private _maxRotationDistFromHeadset;
  28478. private _draggedRoomRotation;
  28479. /**
  28480. * @hidden
  28481. */
  28482. _disableTrackPosition(fixedPosition: Vector3): void;
  28483. /**
  28484. * Internal, the mesh attached to the controller
  28485. * @hidden
  28486. */
  28487. _mesh: Nullable<AbstractMesh>;
  28488. private _poseControlledCamera;
  28489. private _leftHandSystemQuaternion;
  28490. /**
  28491. * Internal, matrix used to convert room space to babylon space
  28492. * @hidden
  28493. */
  28494. _deviceToWorld: Matrix;
  28495. /**
  28496. * Node to be used when casting a ray from the controller
  28497. * @hidden
  28498. */
  28499. _pointingPoseNode: Nullable<TransformNode>;
  28500. /**
  28501. * Name of the child mesh that can be used to cast a ray from the controller
  28502. */
  28503. static readonly POINTING_POSE: string;
  28504. /**
  28505. * Creates a new PoseEnabledController from a gamepad
  28506. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  28507. */
  28508. constructor(browserGamepad: any);
  28509. private _workingMatrix;
  28510. /**
  28511. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  28512. */
  28513. update(): void;
  28514. /**
  28515. * Updates only the pose device and mesh without doing any button event checking
  28516. */
  28517. protected _updatePoseAndMesh(): void;
  28518. /**
  28519. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  28520. * @param poseData raw pose fromthe device
  28521. */
  28522. updateFromDevice(poseData: DevicePose): void;
  28523. /**
  28524. * @hidden
  28525. */
  28526. _meshAttachedObservable: Observable<AbstractMesh>;
  28527. /**
  28528. * Attaches a mesh to the controller
  28529. * @param mesh the mesh to be attached
  28530. */
  28531. attachToMesh(mesh: AbstractMesh): void;
  28532. /**
  28533. * Attaches the controllers mesh to a camera
  28534. * @param camera the camera the mesh should be attached to
  28535. */
  28536. attachToPoseControlledCamera(camera: TargetCamera): void;
  28537. /**
  28538. * Disposes of the controller
  28539. */
  28540. dispose(): void;
  28541. /**
  28542. * The mesh that is attached to the controller
  28543. */
  28544. get mesh(): Nullable<AbstractMesh>;
  28545. /**
  28546. * Gets the ray of the controller in the direction the controller is pointing
  28547. * @param length the length the resulting ray should be
  28548. * @returns a ray in the direction the controller is pointing
  28549. */
  28550. getForwardRay(length?: number): Ray;
  28551. }
  28552. }
  28553. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  28554. import { Observable } from "babylonjs/Misc/observable";
  28555. import { Scene } from "babylonjs/scene";
  28556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28557. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  28558. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  28559. import { Nullable } from "babylonjs/types";
  28560. /**
  28561. * Defines the WebVRController object that represents controllers tracked in 3D space
  28562. */
  28563. export abstract class WebVRController extends PoseEnabledController {
  28564. /**
  28565. * Internal, the default controller model for the controller
  28566. */
  28567. protected _defaultModel: Nullable<AbstractMesh>;
  28568. /**
  28569. * Fired when the trigger state has changed
  28570. */
  28571. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  28572. /**
  28573. * Fired when the main button state has changed
  28574. */
  28575. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28576. /**
  28577. * Fired when the secondary button state has changed
  28578. */
  28579. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28580. /**
  28581. * Fired when the pad state has changed
  28582. */
  28583. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  28584. /**
  28585. * Fired when controllers stick values have changed
  28586. */
  28587. onPadValuesChangedObservable: Observable<StickValues>;
  28588. /**
  28589. * Array of button availible on the controller
  28590. */
  28591. protected _buttons: Array<MutableGamepadButton>;
  28592. private _onButtonStateChange;
  28593. /**
  28594. * Fired when a controller button's state has changed
  28595. * @param callback the callback containing the button that was modified
  28596. */
  28597. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  28598. /**
  28599. * X and Y axis corresponding to the controllers joystick
  28600. */
  28601. pad: StickValues;
  28602. /**
  28603. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  28604. */
  28605. hand: string;
  28606. /**
  28607. * The default controller model for the controller
  28608. */
  28609. get defaultModel(): Nullable<AbstractMesh>;
  28610. /**
  28611. * Creates a new WebVRController from a gamepad
  28612. * @param vrGamepad the gamepad that the WebVRController should be created from
  28613. */
  28614. constructor(vrGamepad: any);
  28615. /**
  28616. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  28617. */
  28618. update(): void;
  28619. /**
  28620. * Function to be called when a button is modified
  28621. */
  28622. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28623. /**
  28624. * Loads a mesh and attaches it to the controller
  28625. * @param scene the scene the mesh should be added to
  28626. * @param meshLoaded callback for when the mesh has been loaded
  28627. */
  28628. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28629. private _setButtonValue;
  28630. private _changes;
  28631. private _checkChanges;
  28632. /**
  28633. * Disposes of th webVRCOntroller
  28634. */
  28635. dispose(): void;
  28636. }
  28637. }
  28638. declare module "babylonjs/Lights/hemisphericLight" {
  28639. import { Nullable } from "babylonjs/types";
  28640. import { Scene } from "babylonjs/scene";
  28641. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28642. import { Color3 } from "babylonjs/Maths/math.color";
  28643. import { Effect } from "babylonjs/Materials/effect";
  28644. import { Light } from "babylonjs/Lights/light";
  28645. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  28646. /**
  28647. * The HemisphericLight simulates the ambient environment light,
  28648. * so the passed direction is the light reflection direction, not the incoming direction.
  28649. */
  28650. export class HemisphericLight extends Light {
  28651. /**
  28652. * The groundColor is the light in the opposite direction to the one specified during creation.
  28653. * 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.
  28654. */
  28655. groundColor: Color3;
  28656. /**
  28657. * The light reflection direction, not the incoming direction.
  28658. */
  28659. direction: Vector3;
  28660. /**
  28661. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  28662. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  28663. * The HemisphericLight can't cast shadows.
  28664. * Documentation : https://doc.babylonjs.com/babylon101/lights
  28665. * @param name The friendly name of the light
  28666. * @param direction The direction of the light reflection
  28667. * @param scene The scene the light belongs to
  28668. */
  28669. constructor(name: string, direction: Vector3, scene: Scene);
  28670. protected _buildUniformLayout(): void;
  28671. /**
  28672. * Returns the string "HemisphericLight".
  28673. * @return The class name
  28674. */
  28675. getClassName(): string;
  28676. /**
  28677. * Sets the HemisphericLight direction towards the passed target (Vector3).
  28678. * Returns the updated direction.
  28679. * @param target The target the direction should point to
  28680. * @return The computed direction
  28681. */
  28682. setDirectionToTarget(target: Vector3): Vector3;
  28683. /**
  28684. * Returns the shadow generator associated to the light.
  28685. * @returns Always null for hemispheric lights because it does not support shadows.
  28686. */
  28687. getShadowGenerator(): Nullable<IShadowGenerator>;
  28688. /**
  28689. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  28690. * @param effect The effect to update
  28691. * @param lightIndex The index of the light in the effect to update
  28692. * @returns The hemispheric light
  28693. */
  28694. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  28695. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  28696. /**
  28697. * Computes the world matrix of the node
  28698. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28699. * @param useWasUpdatedFlag defines a reserved property
  28700. * @returns the world matrix
  28701. */
  28702. computeWorldMatrix(): Matrix;
  28703. /**
  28704. * Returns the integer 3.
  28705. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  28706. */
  28707. getTypeID(): number;
  28708. /**
  28709. * Prepares the list of defines specific to the light type.
  28710. * @param defines the list of defines
  28711. * @param lightIndex defines the index of the light for the effect
  28712. */
  28713. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  28714. }
  28715. }
  28716. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  28717. /** @hidden */
  28718. export var vrMultiviewToSingleviewPixelShader: {
  28719. name: string;
  28720. shader: string;
  28721. };
  28722. }
  28723. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  28724. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28725. import { Scene } from "babylonjs/scene";
  28726. /**
  28727. * Renders to multiple views with a single draw call
  28728. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  28729. */
  28730. export class MultiviewRenderTarget extends RenderTargetTexture {
  28731. /**
  28732. * Creates a multiview render target
  28733. * @param scene scene used with the render target
  28734. * @param size the size of the render target (used for each view)
  28735. */
  28736. constructor(scene: Scene, size?: number | {
  28737. width: number;
  28738. height: number;
  28739. } | {
  28740. ratio: number;
  28741. });
  28742. /**
  28743. * @hidden
  28744. * @param faceIndex the face index, if its a cube texture
  28745. */
  28746. _bindFrameBuffer(faceIndex?: number): void;
  28747. /**
  28748. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28749. * @returns the view count
  28750. */
  28751. getViewCount(): number;
  28752. }
  28753. }
  28754. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  28755. import { Camera } from "babylonjs/Cameras/camera";
  28756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28757. import { Nullable } from "babylonjs/types";
  28758. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28759. import { Matrix } from "babylonjs/Maths/math.vector";
  28760. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28761. module "babylonjs/Engines/engine" {
  28762. interface Engine {
  28763. /**
  28764. * Creates a new multiview render target
  28765. * @param width defines the width of the texture
  28766. * @param height defines the height of the texture
  28767. * @returns the created multiview texture
  28768. */
  28769. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  28770. /**
  28771. * Binds a multiview framebuffer to be drawn to
  28772. * @param multiviewTexture texture to bind
  28773. */
  28774. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  28775. }
  28776. }
  28777. module "babylonjs/Cameras/camera" {
  28778. interface Camera {
  28779. /**
  28780. * @hidden
  28781. * 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)
  28782. */
  28783. _useMultiviewToSingleView: boolean;
  28784. /**
  28785. * @hidden
  28786. * 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)
  28787. */
  28788. _multiviewTexture: Nullable<RenderTargetTexture>;
  28789. /**
  28790. * @hidden
  28791. * ensures the multiview texture of the camera exists and has the specified width/height
  28792. * @param width height to set on the multiview texture
  28793. * @param height width to set on the multiview texture
  28794. */
  28795. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  28796. }
  28797. }
  28798. module "babylonjs/scene" {
  28799. interface Scene {
  28800. /** @hidden */
  28801. _transformMatrixR: Matrix;
  28802. /** @hidden */
  28803. _multiviewSceneUbo: Nullable<UniformBuffer>;
  28804. /** @hidden */
  28805. _createMultiviewUbo(): void;
  28806. /** @hidden */
  28807. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  28808. /** @hidden */
  28809. _renderMultiviewToSingleView(camera: Camera): void;
  28810. }
  28811. }
  28812. }
  28813. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  28814. import { Camera } from "babylonjs/Cameras/camera";
  28815. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28816. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  28817. import "babylonjs/Engines/Extensions/engine.multiview";
  28818. /**
  28819. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  28820. * This will not be used for webXR as it supports displaying texture arrays directly
  28821. */
  28822. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  28823. /**
  28824. * Gets a string identifying the name of the class
  28825. * @returns "VRMultiviewToSingleviewPostProcess" string
  28826. */
  28827. getClassName(): string;
  28828. /**
  28829. * Initializes a VRMultiviewToSingleview
  28830. * @param name name of the post process
  28831. * @param camera camera to be applied to
  28832. * @param scaleFactor scaling factor to the size of the output texture
  28833. */
  28834. constructor(name: string, camera: Camera, scaleFactor: number);
  28835. }
  28836. }
  28837. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  28838. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  28839. import { Nullable } from "babylonjs/types";
  28840. import { Size } from "babylonjs/Maths/math.size";
  28841. import { Observable } from "babylonjs/Misc/observable";
  28842. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  28843. /**
  28844. * Interface used to define additional presentation attributes
  28845. */
  28846. export interface IVRPresentationAttributes {
  28847. /**
  28848. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  28849. */
  28850. highRefreshRate: boolean;
  28851. /**
  28852. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  28853. */
  28854. foveationLevel: number;
  28855. }
  28856. module "babylonjs/Engines/engine" {
  28857. interface Engine {
  28858. /** @hidden */
  28859. _vrDisplay: any;
  28860. /** @hidden */
  28861. _vrSupported: boolean;
  28862. /** @hidden */
  28863. _oldSize: Size;
  28864. /** @hidden */
  28865. _oldHardwareScaleFactor: number;
  28866. /** @hidden */
  28867. _vrExclusivePointerMode: boolean;
  28868. /** @hidden */
  28869. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  28870. /** @hidden */
  28871. _onVRDisplayPointerRestricted: () => void;
  28872. /** @hidden */
  28873. _onVRDisplayPointerUnrestricted: () => void;
  28874. /** @hidden */
  28875. _onVrDisplayConnect: Nullable<(display: any) => void>;
  28876. /** @hidden */
  28877. _onVrDisplayDisconnect: Nullable<() => void>;
  28878. /** @hidden */
  28879. _onVrDisplayPresentChange: Nullable<() => void>;
  28880. /**
  28881. * Observable signaled when VR display mode changes
  28882. */
  28883. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28884. /**
  28885. * Observable signaled when VR request present is complete
  28886. */
  28887. onVRRequestPresentComplete: Observable<boolean>;
  28888. /**
  28889. * Observable signaled when VR request present starts
  28890. */
  28891. onVRRequestPresentStart: Observable<Engine>;
  28892. /**
  28893. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28894. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28895. */
  28896. isInVRExclusivePointerMode: boolean;
  28897. /**
  28898. * Gets a boolean indicating if a webVR device was detected
  28899. * @returns true if a webVR device was detected
  28900. */
  28901. isVRDevicePresent(): boolean;
  28902. /**
  28903. * Gets the current webVR device
  28904. * @returns the current webVR device (or null)
  28905. */
  28906. getVRDevice(): any;
  28907. /**
  28908. * Initializes a webVR display and starts listening to display change events
  28909. * The onVRDisplayChangedObservable will be notified upon these changes
  28910. * @returns A promise containing a VRDisplay and if vr is supported
  28911. */
  28912. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28913. /** @hidden */
  28914. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  28915. /**
  28916. * Gets or sets the presentation attributes used to configure VR rendering
  28917. */
  28918. vrPresentationAttributes?: IVRPresentationAttributes;
  28919. /**
  28920. * Call this function to switch to webVR mode
  28921. * Will do nothing if webVR is not supported or if there is no webVR device
  28922. * @param options the webvr options provided to the camera. mainly used for multiview
  28923. * @see https://doc.babylonjs.com/how_to/webvr_camera
  28924. */
  28925. enableVR(options: WebVROptions): void;
  28926. /** @hidden */
  28927. _onVRFullScreenTriggered(): void;
  28928. }
  28929. }
  28930. }
  28931. declare module "babylonjs/Cameras/VR/webVRCamera" {
  28932. import { Nullable } from "babylonjs/types";
  28933. import { Observable } from "babylonjs/Misc/observable";
  28934. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  28935. import { Scene } from "babylonjs/scene";
  28936. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28937. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  28938. import { Node } from "babylonjs/node";
  28939. import { Ray } from "babylonjs/Culling/ray";
  28940. import "babylonjs/Cameras/RigModes/webVRRigMode";
  28941. import "babylonjs/Engines/Extensions/engine.webVR";
  28942. /**
  28943. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  28944. * IMPORTANT!! The data is right-hand data.
  28945. * @export
  28946. * @interface DevicePose
  28947. */
  28948. export interface DevicePose {
  28949. /**
  28950. * The position of the device, values in array are [x,y,z].
  28951. */
  28952. readonly position: Nullable<Float32Array>;
  28953. /**
  28954. * The linearVelocity of the device, values in array are [x,y,z].
  28955. */
  28956. readonly linearVelocity: Nullable<Float32Array>;
  28957. /**
  28958. * The linearAcceleration of the device, values in array are [x,y,z].
  28959. */
  28960. readonly linearAcceleration: Nullable<Float32Array>;
  28961. /**
  28962. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  28963. */
  28964. readonly orientation: Nullable<Float32Array>;
  28965. /**
  28966. * The angularVelocity of the device, values in array are [x,y,z].
  28967. */
  28968. readonly angularVelocity: Nullable<Float32Array>;
  28969. /**
  28970. * The angularAcceleration of the device, values in array are [x,y,z].
  28971. */
  28972. readonly angularAcceleration: Nullable<Float32Array>;
  28973. }
  28974. /**
  28975. * Interface representing a pose controlled object in Babylon.
  28976. * A pose controlled object has both regular pose values as well as pose values
  28977. * from an external device such as a VR head mounted display
  28978. */
  28979. export interface PoseControlled {
  28980. /**
  28981. * The position of the object in babylon space.
  28982. */
  28983. position: Vector3;
  28984. /**
  28985. * The rotation quaternion of the object in babylon space.
  28986. */
  28987. rotationQuaternion: Quaternion;
  28988. /**
  28989. * The position of the device in babylon space.
  28990. */
  28991. devicePosition?: Vector3;
  28992. /**
  28993. * The rotation quaternion of the device in babylon space.
  28994. */
  28995. deviceRotationQuaternion: Quaternion;
  28996. /**
  28997. * The raw pose coming from the device.
  28998. */
  28999. rawPose: Nullable<DevicePose>;
  29000. /**
  29001. * The scale of the device to be used when translating from device space to babylon space.
  29002. */
  29003. deviceScaleFactor: number;
  29004. /**
  29005. * Updates the poseControlled values based on the input device pose.
  29006. * @param poseData the pose data to update the object with
  29007. */
  29008. updateFromDevice(poseData: DevicePose): void;
  29009. }
  29010. /**
  29011. * Set of options to customize the webVRCamera
  29012. */
  29013. export interface WebVROptions {
  29014. /**
  29015. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  29016. */
  29017. trackPosition?: boolean;
  29018. /**
  29019. * Sets the scale of the vrDevice in babylon space. (default: 1)
  29020. */
  29021. positionScale?: number;
  29022. /**
  29023. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  29024. */
  29025. displayName?: string;
  29026. /**
  29027. * Should the native controller meshes be initialized. (default: true)
  29028. */
  29029. controllerMeshes?: boolean;
  29030. /**
  29031. * Creating a default HemiLight only on controllers. (default: true)
  29032. */
  29033. defaultLightingOnControllers?: boolean;
  29034. /**
  29035. * If you don't want to use the default VR button of the helper. (default: false)
  29036. */
  29037. useCustomVRButton?: boolean;
  29038. /**
  29039. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  29040. */
  29041. customVRButton?: HTMLButtonElement;
  29042. /**
  29043. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  29044. */
  29045. rayLength?: number;
  29046. /**
  29047. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  29048. */
  29049. defaultHeight?: number;
  29050. /**
  29051. * If multiview should be used if available (default: false)
  29052. */
  29053. useMultiview?: boolean;
  29054. }
  29055. /**
  29056. * This represents a WebVR camera.
  29057. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  29058. * @example https://doc.babylonjs.com/how_to/webvr_camera
  29059. */
  29060. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  29061. private webVROptions;
  29062. /**
  29063. * @hidden
  29064. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  29065. */
  29066. _vrDevice: any;
  29067. /**
  29068. * The rawPose of the vrDevice.
  29069. */
  29070. rawPose: Nullable<DevicePose>;
  29071. private _onVREnabled;
  29072. private _specsVersion;
  29073. private _attached;
  29074. private _frameData;
  29075. protected _descendants: Array<Node>;
  29076. private _deviceRoomPosition;
  29077. /** @hidden */
  29078. _deviceRoomRotationQuaternion: Quaternion;
  29079. private _standingMatrix;
  29080. /**
  29081. * Represents device position in babylon space.
  29082. */
  29083. devicePosition: Vector3;
  29084. /**
  29085. * Represents device rotation in babylon space.
  29086. */
  29087. deviceRotationQuaternion: Quaternion;
  29088. /**
  29089. * The scale of the device to be used when translating from device space to babylon space.
  29090. */
  29091. deviceScaleFactor: number;
  29092. private _deviceToWorld;
  29093. private _worldToDevice;
  29094. /**
  29095. * References to the webVR controllers for the vrDevice.
  29096. */
  29097. controllers: Array<WebVRController>;
  29098. /**
  29099. * Emits an event when a controller is attached.
  29100. */
  29101. onControllersAttachedObservable: Observable<WebVRController[]>;
  29102. /**
  29103. * Emits an event when a controller's mesh has been loaded;
  29104. */
  29105. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29106. /**
  29107. * Emits an event when the HMD's pose has been updated.
  29108. */
  29109. onPoseUpdatedFromDeviceObservable: Observable<any>;
  29110. private _poseSet;
  29111. /**
  29112. * If the rig cameras be used as parent instead of this camera.
  29113. */
  29114. rigParenting: boolean;
  29115. private _lightOnControllers;
  29116. private _defaultHeight?;
  29117. /**
  29118. * Instantiates a WebVRFreeCamera.
  29119. * @param name The name of the WebVRFreeCamera
  29120. * @param position The starting anchor position for the camera
  29121. * @param scene The scene the camera belongs to
  29122. * @param webVROptions a set of customizable options for the webVRCamera
  29123. */
  29124. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  29125. /**
  29126. * Gets the device distance from the ground in meters.
  29127. * @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.
  29128. */
  29129. deviceDistanceToRoomGround(): number;
  29130. /**
  29131. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29132. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  29133. */
  29134. useStandingMatrix(callback?: (bool: boolean) => void): void;
  29135. /**
  29136. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29137. * @returns A promise with a boolean set to if the standing matrix is supported.
  29138. */
  29139. useStandingMatrixAsync(): Promise<boolean>;
  29140. /**
  29141. * Disposes the camera
  29142. */
  29143. dispose(): void;
  29144. /**
  29145. * Gets a vrController by name.
  29146. * @param name The name of the controller to retreive
  29147. * @returns the controller matching the name specified or null if not found
  29148. */
  29149. getControllerByName(name: string): Nullable<WebVRController>;
  29150. private _leftController;
  29151. /**
  29152. * The controller corresponding to the users left hand.
  29153. */
  29154. get leftController(): Nullable<WebVRController>;
  29155. private _rightController;
  29156. /**
  29157. * The controller corresponding to the users right hand.
  29158. */
  29159. get rightController(): Nullable<WebVRController>;
  29160. /**
  29161. * Casts a ray forward from the vrCamera's gaze.
  29162. * @param length Length of the ray (default: 100)
  29163. * @returns the ray corresponding to the gaze
  29164. */
  29165. getForwardRay(length?: number): Ray;
  29166. /**
  29167. * @hidden
  29168. * Updates the camera based on device's frame data
  29169. */
  29170. _checkInputs(): void;
  29171. /**
  29172. * Updates the poseControlled values based on the input device pose.
  29173. * @param poseData Pose coming from the device
  29174. */
  29175. updateFromDevice(poseData: DevicePose): void;
  29176. private _detachIfAttached;
  29177. /**
  29178. * WebVR's attach control will start broadcasting frames to the device.
  29179. * Note that in certain browsers (chrome for example) this function must be called
  29180. * within a user-interaction callback. Example:
  29181. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  29182. *
  29183. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  29184. */
  29185. attachControl(noPreventDefault?: boolean): void;
  29186. /**
  29187. * Detach the current controls from the specified dom element.
  29188. */
  29189. detachControl(): void;
  29190. /**
  29191. * @returns the name of this class
  29192. */
  29193. getClassName(): string;
  29194. /**
  29195. * Calls resetPose on the vrDisplay
  29196. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  29197. */
  29198. resetToCurrentRotation(): void;
  29199. /**
  29200. * @hidden
  29201. * Updates the rig cameras (left and right eye)
  29202. */
  29203. _updateRigCameras(): void;
  29204. private _workingVector;
  29205. private _oneVector;
  29206. private _workingMatrix;
  29207. private updateCacheCalled;
  29208. private _correctPositionIfNotTrackPosition;
  29209. /**
  29210. * @hidden
  29211. * Updates the cached values of the camera
  29212. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  29213. */
  29214. _updateCache(ignoreParentClass?: boolean): void;
  29215. /**
  29216. * @hidden
  29217. * Get current device position in babylon world
  29218. */
  29219. _computeDevicePosition(): void;
  29220. /**
  29221. * Updates the current device position and rotation in the babylon world
  29222. */
  29223. update(): void;
  29224. /**
  29225. * @hidden
  29226. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  29227. * @returns an identity matrix
  29228. */
  29229. _getViewMatrix(): Matrix;
  29230. private _tmpMatrix;
  29231. /**
  29232. * This function is called by the two RIG cameras.
  29233. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  29234. * @hidden
  29235. */
  29236. _getWebVRViewMatrix(): Matrix;
  29237. /** @hidden */
  29238. _getWebVRProjectionMatrix(): Matrix;
  29239. private _onGamepadConnectedObserver;
  29240. private _onGamepadDisconnectedObserver;
  29241. private _updateCacheWhenTrackingDisabledObserver;
  29242. /**
  29243. * Initializes the controllers and their meshes
  29244. */
  29245. initControllers(): void;
  29246. }
  29247. }
  29248. declare module "babylonjs/Materials/materialHelper" {
  29249. import { Nullable } from "babylonjs/types";
  29250. import { Scene } from "babylonjs/scene";
  29251. import { Engine } from "babylonjs/Engines/engine";
  29252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29253. import { Light } from "babylonjs/Lights/light";
  29254. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  29255. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29256. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29258. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29259. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  29260. import { Vector4 } from "babylonjs/Maths/math.vector";
  29261. /**
  29262. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  29263. *
  29264. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  29265. *
  29266. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  29267. */
  29268. export class MaterialHelper {
  29269. /**
  29270. * Bind the current view position to an effect.
  29271. * @param effect The effect to be bound
  29272. * @param scene The scene the eyes position is used from
  29273. * @param variableName name of the shader variable that will hold the eye position
  29274. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  29275. * @return the computed eye position
  29276. */
  29277. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  29278. /**
  29279. * Update the scene ubo before it can be used in rendering processing
  29280. * @param scene the scene to retrieve the ubo from
  29281. * @returns the scene UniformBuffer
  29282. */
  29283. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  29284. /**
  29285. * Binds the scene's uniform buffer to the effect.
  29286. * @param effect defines the effect to bind to the scene uniform buffer
  29287. * @param sceneUbo defines the uniform buffer storing scene data
  29288. */
  29289. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29290. /**
  29291. * Helps preparing the defines values about the UVs in used in the effect.
  29292. * UVs are shared as much as we can across channels in the shaders.
  29293. * @param texture The texture we are preparing the UVs for
  29294. * @param defines The defines to update
  29295. * @param key The channel key "diffuse", "specular"... used in the shader
  29296. */
  29297. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  29298. /**
  29299. * Binds a texture matrix value to its corresponding uniform
  29300. * @param texture The texture to bind the matrix for
  29301. * @param uniformBuffer The uniform buffer receiving the data
  29302. * @param key The channel key "diffuse", "specular"... used in the shader
  29303. */
  29304. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  29305. /**
  29306. * Gets the current status of the fog (should it be enabled?)
  29307. * @param mesh defines the mesh to evaluate for fog support
  29308. * @param scene defines the hosting scene
  29309. * @returns true if fog must be enabled
  29310. */
  29311. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  29312. /**
  29313. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  29314. * @param mesh defines the current mesh
  29315. * @param scene defines the current scene
  29316. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  29317. * @param pointsCloud defines if point cloud rendering has to be turned on
  29318. * @param fogEnabled defines if fog has to be turned on
  29319. * @param alphaTest defines if alpha testing has to be turned on
  29320. * @param defines defines the current list of defines
  29321. */
  29322. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  29323. /**
  29324. * Helper used to prepare the list of defines associated with frame values for shader compilation
  29325. * @param scene defines the current scene
  29326. * @param engine defines the current engine
  29327. * @param defines specifies the list of active defines
  29328. * @param useInstances defines if instances have to be turned on
  29329. * @param useClipPlane defines if clip plane have to be turned on
  29330. * @param useInstances defines if instances have to be turned on
  29331. * @param useThinInstances defines if thin instances have to be turned on
  29332. */
  29333. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  29334. /**
  29335. * Prepares the defines for bones
  29336. * @param mesh The mesh containing the geometry data we will draw
  29337. * @param defines The defines to update
  29338. */
  29339. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  29340. /**
  29341. * Prepares the defines for morph targets
  29342. * @param mesh The mesh containing the geometry data we will draw
  29343. * @param defines The defines to update
  29344. */
  29345. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  29346. /**
  29347. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  29348. * @param mesh The mesh containing the geometry data we will draw
  29349. * @param defines The defines to update
  29350. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  29351. * @param useBones Precise whether bones should be used or not (override mesh info)
  29352. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  29353. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  29354. * @returns false if defines are considered not dirty and have not been checked
  29355. */
  29356. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  29357. /**
  29358. * Prepares the defines related to multiview
  29359. * @param scene The scene we are intending to draw
  29360. * @param defines The defines to update
  29361. */
  29362. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  29363. /**
  29364. * Prepares the defines related to the prepass
  29365. * @param scene The scene we are intending to draw
  29366. * @param defines The defines to update
  29367. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  29368. */
  29369. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  29370. /**
  29371. * Prepares the defines related to the light information passed in parameter
  29372. * @param scene The scene we are intending to draw
  29373. * @param mesh The mesh the effect is compiling for
  29374. * @param light The light the effect is compiling for
  29375. * @param lightIndex The index of the light
  29376. * @param defines The defines to update
  29377. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29378. * @param state Defines the current state regarding what is needed (normals, etc...)
  29379. */
  29380. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  29381. needNormals: boolean;
  29382. needRebuild: boolean;
  29383. shadowEnabled: boolean;
  29384. specularEnabled: boolean;
  29385. lightmapMode: boolean;
  29386. }): void;
  29387. /**
  29388. * Prepares the defines related to the light information passed in parameter
  29389. * @param scene The scene we are intending to draw
  29390. * @param mesh The mesh the effect is compiling for
  29391. * @param defines The defines to update
  29392. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29393. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  29394. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  29395. * @returns true if normals will be required for the rest of the effect
  29396. */
  29397. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  29398. /**
  29399. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  29400. * @param lightIndex defines the light index
  29401. * @param uniformsList The uniform list
  29402. * @param samplersList The sampler list
  29403. * @param projectedLightTexture defines if projected texture must be used
  29404. * @param uniformBuffersList defines an optional list of uniform buffers
  29405. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  29406. */
  29407. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  29408. /**
  29409. * Prepares the uniforms and samplers list to be used in the effect
  29410. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  29411. * @param samplersList The sampler list
  29412. * @param defines The defines helping in the list generation
  29413. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  29414. */
  29415. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  29416. /**
  29417. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  29418. * @param defines The defines to update while falling back
  29419. * @param fallbacks The authorized effect fallbacks
  29420. * @param maxSimultaneousLights The maximum number of lights allowed
  29421. * @param rank the current rank of the Effect
  29422. * @returns The newly affected rank
  29423. */
  29424. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  29425. private static _TmpMorphInfluencers;
  29426. /**
  29427. * Prepares the list of attributes required for morph targets according to the effect defines.
  29428. * @param attribs The current list of supported attribs
  29429. * @param mesh The mesh to prepare the morph targets attributes for
  29430. * @param influencers The number of influencers
  29431. */
  29432. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  29433. /**
  29434. * Prepares the list of attributes required for morph targets according to the effect defines.
  29435. * @param attribs The current list of supported attribs
  29436. * @param mesh The mesh to prepare the morph targets attributes for
  29437. * @param defines The current Defines of the effect
  29438. */
  29439. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  29440. /**
  29441. * Prepares the list of attributes required for bones according to the effect defines.
  29442. * @param attribs The current list of supported attribs
  29443. * @param mesh The mesh to prepare the bones attributes for
  29444. * @param defines The current Defines of the effect
  29445. * @param fallbacks The current effect fallback strategy
  29446. */
  29447. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  29448. /**
  29449. * Check and prepare the list of attributes required for instances according to the effect defines.
  29450. * @param attribs The current list of supported attribs
  29451. * @param defines The current MaterialDefines of the effect
  29452. */
  29453. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  29454. /**
  29455. * Add the list of attributes required for instances to the attribs array.
  29456. * @param attribs The current list of supported attribs
  29457. */
  29458. static PushAttributesForInstances(attribs: string[]): void;
  29459. /**
  29460. * Binds the light information to the effect.
  29461. * @param light The light containing the generator
  29462. * @param effect The effect we are binding the data to
  29463. * @param lightIndex The light index in the effect used to render
  29464. */
  29465. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  29466. /**
  29467. * Binds the lights information from the scene to the effect for the given mesh.
  29468. * @param light Light to bind
  29469. * @param lightIndex Light index
  29470. * @param scene The scene where the light belongs to
  29471. * @param effect The effect we are binding the data to
  29472. * @param useSpecular Defines if specular is supported
  29473. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29474. */
  29475. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  29476. /**
  29477. * Binds the lights information from the scene to the effect for the given mesh.
  29478. * @param scene The scene the lights belongs to
  29479. * @param mesh The mesh we are binding the information to render
  29480. * @param effect The effect we are binding the data to
  29481. * @param defines The generated defines for the effect
  29482. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  29483. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29484. */
  29485. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  29486. private static _tempFogColor;
  29487. /**
  29488. * Binds the fog information from the scene to the effect for the given mesh.
  29489. * @param scene The scene the lights belongs to
  29490. * @param mesh The mesh we are binding the information to render
  29491. * @param effect The effect we are binding the data to
  29492. * @param linearSpace Defines if the fog effect is applied in linear space
  29493. */
  29494. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  29495. /**
  29496. * Binds the bones information from the mesh to the effect.
  29497. * @param mesh The mesh we are binding the information to render
  29498. * @param effect The effect we are binding the data to
  29499. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  29500. */
  29501. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  29502. private static _CopyBonesTransformationMatrices;
  29503. /**
  29504. * Binds the morph targets information from the mesh to the effect.
  29505. * @param abstractMesh The mesh we are binding the information to render
  29506. * @param effect The effect we are binding the data to
  29507. */
  29508. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  29509. /**
  29510. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  29511. * @param defines The generated defines used in the effect
  29512. * @param effect The effect we are binding the data to
  29513. * @param scene The scene we are willing to render with logarithmic scale for
  29514. */
  29515. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  29516. /**
  29517. * Binds the clip plane information from the scene to the effect.
  29518. * @param scene The scene the clip plane information are extracted from
  29519. * @param effect The effect we are binding the data to
  29520. */
  29521. static BindClipPlane(effect: Effect, scene: Scene): void;
  29522. }
  29523. }
  29524. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  29525. /** @hidden */
  29526. export var bayerDitherFunctions: {
  29527. name: string;
  29528. shader: string;
  29529. };
  29530. }
  29531. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  29532. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29533. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  29534. /** @hidden */
  29535. export var shadowMapFragmentDeclaration: {
  29536. name: string;
  29537. shader: string;
  29538. };
  29539. }
  29540. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  29541. /** @hidden */
  29542. export var shadowMapFragment: {
  29543. name: string;
  29544. shader: string;
  29545. };
  29546. }
  29547. declare module "babylonjs/Shaders/shadowMap.fragment" {
  29548. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  29549. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29550. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29551. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  29552. /** @hidden */
  29553. export var shadowMapPixelShader: {
  29554. name: string;
  29555. shader: string;
  29556. };
  29557. }
  29558. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  29559. /** @hidden */
  29560. export var shadowMapVertexDeclaration: {
  29561. name: string;
  29562. shader: string;
  29563. };
  29564. }
  29565. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  29566. /** @hidden */
  29567. export var shadowMapVertexNormalBias: {
  29568. name: string;
  29569. shader: string;
  29570. };
  29571. }
  29572. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  29573. /** @hidden */
  29574. export var shadowMapVertexMetric: {
  29575. name: string;
  29576. shader: string;
  29577. };
  29578. }
  29579. declare module "babylonjs/Shaders/shadowMap.vertex" {
  29580. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29581. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  29582. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  29583. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29584. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  29585. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  29586. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal";
  29588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  29589. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29590. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29591. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  29592. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  29593. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29594. /** @hidden */
  29595. export var shadowMapVertexShader: {
  29596. name: string;
  29597. shader: string;
  29598. };
  29599. }
  29600. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  29601. /** @hidden */
  29602. export var depthBoxBlurPixelShader: {
  29603. name: string;
  29604. shader: string;
  29605. };
  29606. }
  29607. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  29608. /** @hidden */
  29609. export var shadowMapFragmentSoftTransparentShadow: {
  29610. name: string;
  29611. shader: string;
  29612. };
  29613. }
  29614. declare module "babylonjs/Meshes/instancedMesh" {
  29615. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29616. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29617. import { Camera } from "babylonjs/Cameras/camera";
  29618. import { Node } from "babylonjs/node";
  29619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29620. import { Mesh } from "babylonjs/Meshes/mesh";
  29621. import { Material } from "babylonjs/Materials/material";
  29622. import { Skeleton } from "babylonjs/Bones/skeleton";
  29623. import { Light } from "babylonjs/Lights/light";
  29624. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29625. /**
  29626. * Creates an instance based on a source mesh.
  29627. */
  29628. export class InstancedMesh extends AbstractMesh {
  29629. private _sourceMesh;
  29630. private _currentLOD;
  29631. /** @hidden */
  29632. _indexInSourceMeshInstanceArray: number;
  29633. constructor(name: string, source: Mesh);
  29634. /**
  29635. * Returns the string "InstancedMesh".
  29636. */
  29637. getClassName(): string;
  29638. /** Gets the list of lights affecting that mesh */
  29639. get lightSources(): Light[];
  29640. _resyncLightSources(): void;
  29641. _resyncLightSource(light: Light): void;
  29642. _removeLightSource(light: Light, dispose: boolean): void;
  29643. /**
  29644. * If the source mesh receives shadows
  29645. */
  29646. get receiveShadows(): boolean;
  29647. /**
  29648. * The material of the source mesh
  29649. */
  29650. get material(): Nullable<Material>;
  29651. /**
  29652. * Visibility of the source mesh
  29653. */
  29654. get visibility(): number;
  29655. /**
  29656. * Skeleton of the source mesh
  29657. */
  29658. get skeleton(): Nullable<Skeleton>;
  29659. /**
  29660. * Rendering ground id of the source mesh
  29661. */
  29662. get renderingGroupId(): number;
  29663. set renderingGroupId(value: number);
  29664. /**
  29665. * Returns the total number of vertices (integer).
  29666. */
  29667. getTotalVertices(): number;
  29668. /**
  29669. * Returns a positive integer : the total number of indices in this mesh geometry.
  29670. * @returns the numner of indices or zero if the mesh has no geometry.
  29671. */
  29672. getTotalIndices(): number;
  29673. /**
  29674. * The source mesh of the instance
  29675. */
  29676. get sourceMesh(): Mesh;
  29677. /**
  29678. * Creates a new InstancedMesh object from the mesh model.
  29679. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29680. * @param name defines the name of the new instance
  29681. * @returns a new InstancedMesh
  29682. */
  29683. createInstance(name: string): InstancedMesh;
  29684. /**
  29685. * Is this node ready to be used/rendered
  29686. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29687. * @return {boolean} is it ready
  29688. */
  29689. isReady(completeCheck?: boolean): boolean;
  29690. /**
  29691. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29692. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  29693. * @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.
  29694. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  29695. */
  29696. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  29697. /**
  29698. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29699. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29700. * The `data` are either a numeric array either a Float32Array.
  29701. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  29702. * 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).
  29703. * Note that a new underlying VertexBuffer object is created each call.
  29704. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29705. *
  29706. * Possible `kind` values :
  29707. * - VertexBuffer.PositionKind
  29708. * - VertexBuffer.UVKind
  29709. * - VertexBuffer.UV2Kind
  29710. * - VertexBuffer.UV3Kind
  29711. * - VertexBuffer.UV4Kind
  29712. * - VertexBuffer.UV5Kind
  29713. * - VertexBuffer.UV6Kind
  29714. * - VertexBuffer.ColorKind
  29715. * - VertexBuffer.MatricesIndicesKind
  29716. * - VertexBuffer.MatricesIndicesExtraKind
  29717. * - VertexBuffer.MatricesWeightsKind
  29718. * - VertexBuffer.MatricesWeightsExtraKind
  29719. *
  29720. * Returns the Mesh.
  29721. */
  29722. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29723. /**
  29724. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29725. * If the mesh has no geometry, it is simply returned as it is.
  29726. * The `data` are either a numeric array either a Float32Array.
  29727. * No new underlying VertexBuffer object is created.
  29728. * 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.
  29729. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  29730. *
  29731. * Possible `kind` values :
  29732. * - VertexBuffer.PositionKind
  29733. * - VertexBuffer.UVKind
  29734. * - VertexBuffer.UV2Kind
  29735. * - VertexBuffer.UV3Kind
  29736. * - VertexBuffer.UV4Kind
  29737. * - VertexBuffer.UV5Kind
  29738. * - VertexBuffer.UV6Kind
  29739. * - VertexBuffer.ColorKind
  29740. * - VertexBuffer.MatricesIndicesKind
  29741. * - VertexBuffer.MatricesIndicesExtraKind
  29742. * - VertexBuffer.MatricesWeightsKind
  29743. * - VertexBuffer.MatricesWeightsExtraKind
  29744. *
  29745. * Returns the Mesh.
  29746. */
  29747. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  29748. /**
  29749. * Sets the mesh indices.
  29750. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  29751. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29752. * This method creates a new index buffer each call.
  29753. * Returns the Mesh.
  29754. */
  29755. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  29756. /**
  29757. * Boolean : True if the mesh owns the requested kind of data.
  29758. */
  29759. isVerticesDataPresent(kind: string): boolean;
  29760. /**
  29761. * Returns an array of indices (IndicesArray).
  29762. */
  29763. getIndices(): Nullable<IndicesArray>;
  29764. get _positions(): Nullable<Vector3[]>;
  29765. /**
  29766. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29767. * This means the mesh underlying bounding box and sphere are recomputed.
  29768. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29769. * @returns the current mesh
  29770. */
  29771. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  29772. /** @hidden */
  29773. _preActivate(): InstancedMesh;
  29774. /** @hidden */
  29775. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29776. /** @hidden */
  29777. _postActivate(): void;
  29778. getWorldMatrix(): Matrix;
  29779. get isAnInstance(): boolean;
  29780. /**
  29781. * Returns the current associated LOD AbstractMesh.
  29782. */
  29783. getLOD(camera: Camera): AbstractMesh;
  29784. /** @hidden */
  29785. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29786. /** @hidden */
  29787. _syncSubMeshes(): InstancedMesh;
  29788. /** @hidden */
  29789. _generatePointsArray(): boolean;
  29790. /** @hidden */
  29791. _updateBoundingInfo(): AbstractMesh;
  29792. /**
  29793. * Creates a new InstancedMesh from the current mesh.
  29794. * - name (string) : the cloned mesh name
  29795. * - newParent (optional Node) : the optional Node to parent the clone to.
  29796. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  29797. *
  29798. * Returns the clone.
  29799. */
  29800. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  29801. /**
  29802. * Disposes the InstancedMesh.
  29803. * Returns nothing.
  29804. */
  29805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29806. }
  29807. module "babylonjs/Meshes/mesh" {
  29808. interface Mesh {
  29809. /**
  29810. * Register a custom buffer that will be instanced
  29811. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29812. * @param kind defines the buffer kind
  29813. * @param stride defines the stride in floats
  29814. */
  29815. registerInstancedBuffer(kind: string, stride: number): void;
  29816. /**
  29817. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  29818. */
  29819. _invalidateInstanceVertexArrayObject(): void;
  29820. /**
  29821. * true to use the edge renderer for all instances of this mesh
  29822. */
  29823. edgesShareWithInstances: boolean;
  29824. /** @hidden */
  29825. _userInstancedBuffersStorage: {
  29826. data: {
  29827. [key: string]: Float32Array;
  29828. };
  29829. sizes: {
  29830. [key: string]: number;
  29831. };
  29832. vertexBuffers: {
  29833. [key: string]: Nullable<VertexBuffer>;
  29834. };
  29835. strides: {
  29836. [key: string]: number;
  29837. };
  29838. vertexArrayObjects?: {
  29839. [key: string]: WebGLVertexArrayObject;
  29840. };
  29841. };
  29842. }
  29843. }
  29844. module "babylonjs/Meshes/abstractMesh" {
  29845. interface AbstractMesh {
  29846. /**
  29847. * Object used to store instanced buffers defined by user
  29848. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29849. */
  29850. instancedBuffers: {
  29851. [key: string]: any;
  29852. };
  29853. }
  29854. }
  29855. }
  29856. declare module "babylonjs/Materials/shaderMaterial" {
  29857. import { Nullable } from "babylonjs/types";
  29858. import { Scene } from "babylonjs/scene";
  29859. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29861. import { Mesh } from "babylonjs/Meshes/mesh";
  29862. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29864. import { Effect } from "babylonjs/Materials/effect";
  29865. import { Material } from "babylonjs/Materials/material";
  29866. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29867. /**
  29868. * Defines the options associated with the creation of a shader material.
  29869. */
  29870. export interface IShaderMaterialOptions {
  29871. /**
  29872. * Does the material work in alpha blend mode
  29873. */
  29874. needAlphaBlending: boolean;
  29875. /**
  29876. * Does the material work in alpha test mode
  29877. */
  29878. needAlphaTesting: boolean;
  29879. /**
  29880. * The list of attribute names used in the shader
  29881. */
  29882. attributes: string[];
  29883. /**
  29884. * The list of uniform names used in the shader
  29885. */
  29886. uniforms: string[];
  29887. /**
  29888. * The list of UBO names used in the shader
  29889. */
  29890. uniformBuffers: string[];
  29891. /**
  29892. * The list of sampler names used in the shader
  29893. */
  29894. samplers: string[];
  29895. /**
  29896. * The list of defines used in the shader
  29897. */
  29898. defines: string[];
  29899. }
  29900. /**
  29901. * 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.
  29902. *
  29903. * This returned material effects how the mesh will look based on the code in the shaders.
  29904. *
  29905. * @see https://doc.babylonjs.com/how_to/shader_material
  29906. */
  29907. export class ShaderMaterial extends Material {
  29908. private _shaderPath;
  29909. private _options;
  29910. private _textures;
  29911. private _textureArrays;
  29912. private _floats;
  29913. private _ints;
  29914. private _floatsArrays;
  29915. private _colors3;
  29916. private _colors3Arrays;
  29917. private _colors4;
  29918. private _colors4Arrays;
  29919. private _vectors2;
  29920. private _vectors3;
  29921. private _vectors4;
  29922. private _matrices;
  29923. private _matrixArrays;
  29924. private _matrices3x3;
  29925. private _matrices2x2;
  29926. private _vectors2Arrays;
  29927. private _vectors3Arrays;
  29928. private _vectors4Arrays;
  29929. private _cachedWorldViewMatrix;
  29930. private _cachedWorldViewProjectionMatrix;
  29931. private _renderId;
  29932. private _multiview;
  29933. private _cachedDefines;
  29934. /** Define the Url to load snippets */
  29935. static SnippetUrl: string;
  29936. /** Snippet ID if the material was created from the snippet server */
  29937. snippetId: string;
  29938. /**
  29939. * Instantiate a new shader material.
  29940. * 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.
  29941. * This returned material effects how the mesh will look based on the code in the shaders.
  29942. * @see https://doc.babylonjs.com/how_to/shader_material
  29943. * @param name Define the name of the material in the scene
  29944. * @param scene Define the scene the material belongs to
  29945. * @param shaderPath Defines the route to the shader code in one of three ways:
  29946. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  29947. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  29948. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  29949. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  29950. * @param options Define the options used to create the shader
  29951. */
  29952. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  29953. /**
  29954. * Gets the shader path used to define the shader code
  29955. * It can be modified to trigger a new compilation
  29956. */
  29957. get shaderPath(): any;
  29958. /**
  29959. * Sets the shader path used to define the shader code
  29960. * It can be modified to trigger a new compilation
  29961. */
  29962. set shaderPath(shaderPath: any);
  29963. /**
  29964. * Gets the options used to compile the shader.
  29965. * They can be modified to trigger a new compilation
  29966. */
  29967. get options(): IShaderMaterialOptions;
  29968. /**
  29969. * Gets the current class name of the material e.g. "ShaderMaterial"
  29970. * Mainly use in serialization.
  29971. * @returns the class name
  29972. */
  29973. getClassName(): string;
  29974. /**
  29975. * Specifies if the material will require alpha blending
  29976. * @returns a boolean specifying if alpha blending is needed
  29977. */
  29978. needAlphaBlending(): boolean;
  29979. /**
  29980. * Specifies if this material should be rendered in alpha test mode
  29981. * @returns a boolean specifying if an alpha test is needed.
  29982. */
  29983. needAlphaTesting(): boolean;
  29984. private _checkUniform;
  29985. /**
  29986. * Set a texture in the shader.
  29987. * @param name Define the name of the uniform samplers as defined in the shader
  29988. * @param texture Define the texture to bind to this sampler
  29989. * @return the material itself allowing "fluent" like uniform updates
  29990. */
  29991. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  29992. /**
  29993. * Set a texture array in the shader.
  29994. * @param name Define the name of the uniform sampler array as defined in the shader
  29995. * @param textures Define the list of textures to bind to this sampler
  29996. * @return the material itself allowing "fluent" like uniform updates
  29997. */
  29998. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  29999. /**
  30000. * Set a float in the shader.
  30001. * @param name Define the name of the uniform as defined in the shader
  30002. * @param value Define the value to give to the uniform
  30003. * @return the material itself allowing "fluent" like uniform updates
  30004. */
  30005. setFloat(name: string, value: number): ShaderMaterial;
  30006. /**
  30007. * Set a int in the shader.
  30008. * @param name Define the name of the uniform as defined in the shader
  30009. * @param value Define the value to give to the uniform
  30010. * @return the material itself allowing "fluent" like uniform updates
  30011. */
  30012. setInt(name: string, value: number): ShaderMaterial;
  30013. /**
  30014. * Set an array of floats in the shader.
  30015. * @param name Define the name of the uniform as defined in the shader
  30016. * @param value Define the value to give to the uniform
  30017. * @return the material itself allowing "fluent" like uniform updates
  30018. */
  30019. setFloats(name: string, value: number[]): ShaderMaterial;
  30020. /**
  30021. * Set a vec3 in the shader from a Color3.
  30022. * @param name Define the name of the uniform as defined in the shader
  30023. * @param value Define the value to give to the uniform
  30024. * @return the material itself allowing "fluent" like uniform updates
  30025. */
  30026. setColor3(name: string, value: Color3): ShaderMaterial;
  30027. /**
  30028. * Set a vec3 array in the shader from a Color3 array.
  30029. * @param name Define the name of the uniform as defined in the shader
  30030. * @param value Define the value to give to the uniform
  30031. * @return the material itself allowing "fluent" like uniform updates
  30032. */
  30033. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  30034. /**
  30035. * Set a vec4 in the shader from a Color4.
  30036. * @param name Define the name of the uniform as defined in the shader
  30037. * @param value Define the value to give to the uniform
  30038. * @return the material itself allowing "fluent" like uniform updates
  30039. */
  30040. setColor4(name: string, value: Color4): ShaderMaterial;
  30041. /**
  30042. * Set a vec4 array in the shader from a Color4 array.
  30043. * @param name Define the name of the uniform as defined in the shader
  30044. * @param value Define the value to give to the uniform
  30045. * @return the material itself allowing "fluent" like uniform updates
  30046. */
  30047. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  30048. /**
  30049. * Set a vec2 in the shader from a Vector2.
  30050. * @param name Define the name of the uniform as defined in the shader
  30051. * @param value Define the value to give to the uniform
  30052. * @return the material itself allowing "fluent" like uniform updates
  30053. */
  30054. setVector2(name: string, value: Vector2): ShaderMaterial;
  30055. /**
  30056. * Set a vec3 in the shader from a Vector3.
  30057. * @param name Define the name of the uniform as defined in the shader
  30058. * @param value Define the value to give to the uniform
  30059. * @return the material itself allowing "fluent" like uniform updates
  30060. */
  30061. setVector3(name: string, value: Vector3): ShaderMaterial;
  30062. /**
  30063. * Set a vec4 in the shader from a Vector4.
  30064. * @param name Define the name of the uniform as defined in the shader
  30065. * @param value Define the value to give to the uniform
  30066. * @return the material itself allowing "fluent" like uniform updates
  30067. */
  30068. setVector4(name: string, value: Vector4): ShaderMaterial;
  30069. /**
  30070. * Set a mat4 in the shader from a Matrix.
  30071. * @param name Define the name of the uniform as defined in the shader
  30072. * @param value Define the value to give to the uniform
  30073. * @return the material itself allowing "fluent" like uniform updates
  30074. */
  30075. setMatrix(name: string, value: Matrix): ShaderMaterial;
  30076. /**
  30077. * Set a float32Array in the shader from a matrix array.
  30078. * @param name Define the name of the uniform as defined in the shader
  30079. * @param value Define the value to give to the uniform
  30080. * @return the material itself allowing "fluent" like uniform updates
  30081. */
  30082. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  30083. /**
  30084. * Set a mat3 in the shader from a Float32Array.
  30085. * @param name Define the name of the uniform as defined in the shader
  30086. * @param value Define the value to give to the uniform
  30087. * @return the material itself allowing "fluent" like uniform updates
  30088. */
  30089. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  30090. /**
  30091. * Set a mat2 in the shader from a Float32Array.
  30092. * @param name Define the name of the uniform as defined in the shader
  30093. * @param value Define the value to give to the uniform
  30094. * @return the material itself allowing "fluent" like uniform updates
  30095. */
  30096. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  30097. /**
  30098. * Set a vec2 array in the shader from a number array.
  30099. * @param name Define the name of the uniform as defined in the shader
  30100. * @param value Define the value to give to the uniform
  30101. * @return the material itself allowing "fluent" like uniform updates
  30102. */
  30103. setArray2(name: string, value: number[]): ShaderMaterial;
  30104. /**
  30105. * Set a vec3 array in the shader from a number array.
  30106. * @param name Define the name of the uniform as defined in the shader
  30107. * @param value Define the value to give to the uniform
  30108. * @return the material itself allowing "fluent" like uniform updates
  30109. */
  30110. setArray3(name: string, value: number[]): ShaderMaterial;
  30111. /**
  30112. * Set a vec4 array in the shader from a number array.
  30113. * @param name Define the name of the uniform as defined in the shader
  30114. * @param value Define the value to give to the uniform
  30115. * @return the material itself allowing "fluent" like uniform updates
  30116. */
  30117. setArray4(name: string, value: number[]): ShaderMaterial;
  30118. private _checkCache;
  30119. /**
  30120. * Specifies that the submesh is ready to be used
  30121. * @param mesh defines the mesh to check
  30122. * @param subMesh defines which submesh to check
  30123. * @param useInstances specifies that instances should be used
  30124. * @returns a boolean indicating that the submesh is ready or not
  30125. */
  30126. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30127. /**
  30128. * Checks if the material is ready to render the requested mesh
  30129. * @param mesh Define the mesh to render
  30130. * @param useInstances Define whether or not the material is used with instances
  30131. * @returns true if ready, otherwise false
  30132. */
  30133. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30134. /**
  30135. * Binds the world matrix to the material
  30136. * @param world defines the world transformation matrix
  30137. * @param effectOverride - If provided, use this effect instead of internal effect
  30138. */
  30139. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  30140. /**
  30141. * Binds the submesh to this material by preparing the effect and shader to draw
  30142. * @param world defines the world transformation matrix
  30143. * @param mesh defines the mesh containing the submesh
  30144. * @param subMesh defines the submesh to bind the material to
  30145. */
  30146. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30147. /**
  30148. * Binds the material to the mesh
  30149. * @param world defines the world transformation matrix
  30150. * @param mesh defines the mesh to bind the material to
  30151. * @param effectOverride - If provided, use this effect instead of internal effect
  30152. */
  30153. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  30154. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30155. /**
  30156. * Gets the active textures from the material
  30157. * @returns an array of textures
  30158. */
  30159. getActiveTextures(): BaseTexture[];
  30160. /**
  30161. * Specifies if the material uses a texture
  30162. * @param texture defines the texture to check against the material
  30163. * @returns a boolean specifying if the material uses the texture
  30164. */
  30165. hasTexture(texture: BaseTexture): boolean;
  30166. /**
  30167. * Makes a duplicate of the material, and gives it a new name
  30168. * @param name defines the new name for the duplicated material
  30169. * @returns the cloned material
  30170. */
  30171. clone(name: string): ShaderMaterial;
  30172. /**
  30173. * Disposes the material
  30174. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30175. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30176. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30177. */
  30178. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30179. /**
  30180. * Serializes this material in a JSON representation
  30181. * @returns the serialized material object
  30182. */
  30183. serialize(): any;
  30184. /**
  30185. * Creates a shader material from parsed shader material data
  30186. * @param source defines the JSON representation of the material
  30187. * @param scene defines the hosting scene
  30188. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30189. * @returns a new material
  30190. */
  30191. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  30192. /**
  30193. * Creates a new ShaderMaterial from a snippet saved in a remote file
  30194. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  30195. * @param url defines the url to load from
  30196. * @param scene defines the hosting scene
  30197. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30198. * @returns a promise that will resolve to the new ShaderMaterial
  30199. */
  30200. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  30201. /**
  30202. * Creates a ShaderMaterial from a snippet saved by the Inspector
  30203. * @param snippetId defines the snippet to load
  30204. * @param scene defines the hosting scene
  30205. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30206. * @returns a promise that will resolve to the new ShaderMaterial
  30207. */
  30208. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  30209. }
  30210. }
  30211. declare module "babylonjs/Shaders/color.fragment" {
  30212. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30213. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30214. /** @hidden */
  30215. export var colorPixelShader: {
  30216. name: string;
  30217. shader: string;
  30218. };
  30219. }
  30220. declare module "babylonjs/Shaders/color.vertex" {
  30221. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30222. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30223. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30224. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30225. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30226. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30227. /** @hidden */
  30228. export var colorVertexShader: {
  30229. name: string;
  30230. shader: string;
  30231. };
  30232. }
  30233. declare module "babylonjs/Meshes/linesMesh" {
  30234. import { Nullable } from "babylonjs/types";
  30235. import { Scene } from "babylonjs/scene";
  30236. import { Color3 } from "babylonjs/Maths/math.color";
  30237. import { Node } from "babylonjs/node";
  30238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30239. import { Mesh } from "babylonjs/Meshes/mesh";
  30240. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  30241. import { Effect } from "babylonjs/Materials/effect";
  30242. import { Material } from "babylonjs/Materials/material";
  30243. import "babylonjs/Shaders/color.fragment";
  30244. import "babylonjs/Shaders/color.vertex";
  30245. /**
  30246. * Line mesh
  30247. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  30248. */
  30249. export class LinesMesh extends Mesh {
  30250. /**
  30251. * If vertex color should be applied to the mesh
  30252. */
  30253. readonly useVertexColor?: boolean | undefined;
  30254. /**
  30255. * If vertex alpha should be applied to the mesh
  30256. */
  30257. readonly useVertexAlpha?: boolean | undefined;
  30258. /**
  30259. * Color of the line (Default: White)
  30260. */
  30261. color: Color3;
  30262. /**
  30263. * Alpha of the line (Default: 1)
  30264. */
  30265. alpha: number;
  30266. /**
  30267. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  30268. * This margin is expressed in world space coordinates, so its value may vary.
  30269. * Default value is 0.1
  30270. */
  30271. intersectionThreshold: number;
  30272. private _colorShader;
  30273. private color4;
  30274. /**
  30275. * Creates a new LinesMesh
  30276. * @param name defines the name
  30277. * @param scene defines the hosting scene
  30278. * @param parent defines the parent mesh if any
  30279. * @param source defines the optional source LinesMesh used to clone data from
  30280. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  30281. * When false, achieved by calling a clone(), also passing False.
  30282. * This will make creation of children, recursive.
  30283. * @param useVertexColor defines if this LinesMesh supports vertex color
  30284. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  30285. */
  30286. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  30287. /**
  30288. * If vertex color should be applied to the mesh
  30289. */
  30290. useVertexColor?: boolean | undefined,
  30291. /**
  30292. * If vertex alpha should be applied to the mesh
  30293. */
  30294. useVertexAlpha?: boolean | undefined);
  30295. private _addClipPlaneDefine;
  30296. private _removeClipPlaneDefine;
  30297. isReady(): boolean;
  30298. /**
  30299. * Returns the string "LineMesh"
  30300. */
  30301. getClassName(): string;
  30302. /**
  30303. * @hidden
  30304. */
  30305. get material(): Material;
  30306. /**
  30307. * @hidden
  30308. */
  30309. set material(value: Material);
  30310. /**
  30311. * @hidden
  30312. */
  30313. get checkCollisions(): boolean;
  30314. set checkCollisions(value: boolean);
  30315. /** @hidden */
  30316. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  30317. /** @hidden */
  30318. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  30319. /**
  30320. * Disposes of the line mesh
  30321. * @param doNotRecurse If children should be disposed
  30322. */
  30323. dispose(doNotRecurse?: boolean): void;
  30324. /**
  30325. * Returns a new LineMesh object cloned from the current one.
  30326. */
  30327. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  30328. /**
  30329. * Creates a new InstancedLinesMesh object from the mesh model.
  30330. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  30331. * @param name defines the name of the new instance
  30332. * @returns a new InstancedLinesMesh
  30333. */
  30334. createInstance(name: string): InstancedLinesMesh;
  30335. }
  30336. /**
  30337. * Creates an instance based on a source LinesMesh
  30338. */
  30339. export class InstancedLinesMesh extends InstancedMesh {
  30340. /**
  30341. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  30342. * This margin is expressed in world space coordinates, so its value may vary.
  30343. * Initialized with the intersectionThreshold value of the source LinesMesh
  30344. */
  30345. intersectionThreshold: number;
  30346. constructor(name: string, source: LinesMesh);
  30347. /**
  30348. * Returns the string "InstancedLinesMesh".
  30349. */
  30350. getClassName(): string;
  30351. }
  30352. }
  30353. declare module "babylonjs/Shaders/line.fragment" {
  30354. /** @hidden */
  30355. export var linePixelShader: {
  30356. name: string;
  30357. shader: string;
  30358. };
  30359. }
  30360. declare module "babylonjs/Shaders/line.vertex" {
  30361. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30362. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30363. /** @hidden */
  30364. export var lineVertexShader: {
  30365. name: string;
  30366. shader: string;
  30367. };
  30368. }
  30369. declare module "babylonjs/Rendering/edgesRenderer" {
  30370. import { Immutable, Nullable } from "babylonjs/types";
  30371. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30373. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  30374. import { IDisposable } from "babylonjs/scene";
  30375. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  30376. import "babylonjs/Shaders/line.fragment";
  30377. import "babylonjs/Shaders/line.vertex";
  30378. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30379. import { SmartArray } from "babylonjs/Misc/smartArray";
  30380. module "babylonjs/scene" {
  30381. interface Scene {
  30382. /** @hidden */
  30383. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  30384. }
  30385. }
  30386. module "babylonjs/Meshes/abstractMesh" {
  30387. interface AbstractMesh {
  30388. /**
  30389. * Gets the edgesRenderer associated with the mesh
  30390. */
  30391. edgesRenderer: Nullable<EdgesRenderer>;
  30392. }
  30393. }
  30394. module "babylonjs/Meshes/linesMesh" {
  30395. interface LinesMesh {
  30396. /**
  30397. * Enables the edge rendering mode on the mesh.
  30398. * This mode makes the mesh edges visible
  30399. * @param epsilon defines the maximal distance between two angles to detect a face
  30400. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30401. * @returns the currentAbstractMesh
  30402. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30403. */
  30404. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30405. }
  30406. }
  30407. module "babylonjs/Meshes/linesMesh" {
  30408. interface InstancedLinesMesh {
  30409. /**
  30410. * Enables the edge rendering mode on the mesh.
  30411. * This mode makes the mesh edges visible
  30412. * @param epsilon defines the maximal distance between two angles to detect a face
  30413. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30414. * @returns the current InstancedLinesMesh
  30415. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30416. */
  30417. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  30418. }
  30419. }
  30420. /**
  30421. * Defines the minimum contract an Edges renderer should follow.
  30422. */
  30423. export interface IEdgesRenderer extends IDisposable {
  30424. /**
  30425. * Gets or sets a boolean indicating if the edgesRenderer is active
  30426. */
  30427. isEnabled: boolean;
  30428. /**
  30429. * Renders the edges of the attached mesh,
  30430. */
  30431. render(): void;
  30432. /**
  30433. * Checks whether or not the edges renderer is ready to render.
  30434. * @return true if ready, otherwise false.
  30435. */
  30436. isReady(): boolean;
  30437. /**
  30438. * List of instances to render in case the source mesh has instances
  30439. */
  30440. customInstances: SmartArray<Matrix>;
  30441. }
  30442. /**
  30443. * Defines the additional options of the edges renderer
  30444. */
  30445. export interface IEdgesRendererOptions {
  30446. /**
  30447. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  30448. * If not defined, the default value is true
  30449. */
  30450. useAlternateEdgeFinder?: boolean;
  30451. /**
  30452. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  30453. * If not defined, the default value is true.
  30454. * 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)
  30455. * This option is used only if useAlternateEdgeFinder = true
  30456. */
  30457. useFastVertexMerger?: boolean;
  30458. /**
  30459. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  30460. * The default value is 1e-6
  30461. * This option is used only if useAlternateEdgeFinder = true
  30462. */
  30463. epsilonVertexMerge?: number;
  30464. /**
  30465. * 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
  30466. * 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.
  30467. * This option is used only if useAlternateEdgeFinder = true
  30468. */
  30469. applyTessellation?: boolean;
  30470. /**
  30471. * 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
  30472. * The default value is 1e-6
  30473. * This option is used only if useAlternateEdgeFinder = true
  30474. */
  30475. epsilonVertexAligned?: number;
  30476. }
  30477. /**
  30478. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  30479. */
  30480. export class EdgesRenderer implements IEdgesRenderer {
  30481. /**
  30482. * Define the size of the edges with an orthographic camera
  30483. */
  30484. edgesWidthScalerForOrthographic: number;
  30485. /**
  30486. * Define the size of the edges with a perspective camera
  30487. */
  30488. edgesWidthScalerForPerspective: number;
  30489. protected _source: AbstractMesh;
  30490. protected _linesPositions: number[];
  30491. protected _linesNormals: number[];
  30492. protected _linesIndices: number[];
  30493. protected _epsilon: number;
  30494. protected _indicesCount: number;
  30495. protected _lineShader: ShaderMaterial;
  30496. protected _ib: DataBuffer;
  30497. protected _buffers: {
  30498. [key: string]: Nullable<VertexBuffer>;
  30499. };
  30500. protected _buffersForInstances: {
  30501. [key: string]: Nullable<VertexBuffer>;
  30502. };
  30503. protected _checkVerticesInsteadOfIndices: boolean;
  30504. protected _options: Nullable<IEdgesRendererOptions>;
  30505. private _meshRebuildObserver;
  30506. private _meshDisposeObserver;
  30507. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  30508. isEnabled: boolean;
  30509. /** Gets the vertices generated by the edge renderer */
  30510. get linesPositions(): Immutable<Array<number>>;
  30511. /** Gets the normals generated by the edge renderer */
  30512. get linesNormals(): Immutable<Array<number>>;
  30513. /** Gets the indices generated by the edge renderer */
  30514. get linesIndices(): Immutable<Array<number>>;
  30515. /**
  30516. * List of instances to render in case the source mesh has instances
  30517. */
  30518. customInstances: SmartArray<Matrix>;
  30519. private static GetShader;
  30520. /**
  30521. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  30522. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  30523. * @param source Mesh used to create edges
  30524. * @param epsilon sum of angles in adjacency to check for edge
  30525. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  30526. * @param generateEdgesLines - should generate Lines or only prepare resources.
  30527. * @param options The options to apply when generating the edges
  30528. */
  30529. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  30530. protected _prepareRessources(): void;
  30531. /** @hidden */
  30532. _rebuild(): void;
  30533. /**
  30534. * Releases the required resources for the edges renderer
  30535. */
  30536. dispose(): void;
  30537. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  30538. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  30539. /**
  30540. * Checks if the pair of p0 and p1 is en edge
  30541. * @param faceIndex
  30542. * @param edge
  30543. * @param faceNormals
  30544. * @param p0
  30545. * @param p1
  30546. * @private
  30547. */
  30548. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  30549. /**
  30550. * push line into the position, normal and index buffer
  30551. * @protected
  30552. */
  30553. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  30554. /**
  30555. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  30556. */
  30557. private _tessellateTriangle;
  30558. private _generateEdgesLinesAlternate;
  30559. /**
  30560. * Generates lines edges from adjacencjes
  30561. * @private
  30562. */
  30563. _generateEdgesLines(): void;
  30564. /**
  30565. * Checks whether or not the edges renderer is ready to render.
  30566. * @return true if ready, otherwise false.
  30567. */
  30568. isReady(): boolean;
  30569. /**
  30570. * Renders the edges of the attached mesh,
  30571. */
  30572. render(): void;
  30573. }
  30574. /**
  30575. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  30576. */
  30577. export class LineEdgesRenderer extends EdgesRenderer {
  30578. /**
  30579. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  30580. * @param source LineMesh used to generate edges
  30581. * @param epsilon not important (specified angle for edge detection)
  30582. * @param checkVerticesInsteadOfIndices not important for LineMesh
  30583. */
  30584. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  30585. /**
  30586. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  30587. */
  30588. _generateEdgesLines(): void;
  30589. }
  30590. }
  30591. declare module "babylonjs/Rendering/renderingGroup" {
  30592. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  30593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30595. import { Nullable } from "babylonjs/types";
  30596. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30597. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  30598. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30599. import { Material } from "babylonjs/Materials/material";
  30600. import { Scene } from "babylonjs/scene";
  30601. /**
  30602. * This represents the object necessary to create a rendering group.
  30603. * This is exclusively used and created by the rendering manager.
  30604. * To modify the behavior, you use the available helpers in your scene or meshes.
  30605. * @hidden
  30606. */
  30607. export class RenderingGroup {
  30608. index: number;
  30609. private static _zeroVector;
  30610. private _scene;
  30611. private _opaqueSubMeshes;
  30612. private _transparentSubMeshes;
  30613. private _alphaTestSubMeshes;
  30614. private _depthOnlySubMeshes;
  30615. private _particleSystems;
  30616. private _spriteManagers;
  30617. private _opaqueSortCompareFn;
  30618. private _alphaTestSortCompareFn;
  30619. private _transparentSortCompareFn;
  30620. private _renderOpaque;
  30621. private _renderAlphaTest;
  30622. private _renderTransparent;
  30623. /** @hidden */
  30624. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  30625. onBeforeTransparentRendering: () => void;
  30626. /**
  30627. * Set the opaque sort comparison function.
  30628. * If null the sub meshes will be render in the order they were created
  30629. */
  30630. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30631. /**
  30632. * Set the alpha test sort comparison function.
  30633. * If null the sub meshes will be render in the order they were created
  30634. */
  30635. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30636. /**
  30637. * Set the transparent sort comparison function.
  30638. * If null the sub meshes will be render in the order they were created
  30639. */
  30640. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30641. /**
  30642. * Creates a new rendering group.
  30643. * @param index The rendering group index
  30644. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  30645. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  30646. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  30647. */
  30648. 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>);
  30649. /**
  30650. * Render all the sub meshes contained in the group.
  30651. * @param customRenderFunction Used to override the default render behaviour of the group.
  30652. * @returns true if rendered some submeshes.
  30653. */
  30654. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  30655. /**
  30656. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  30657. * @param subMeshes The submeshes to render
  30658. */
  30659. private renderOpaqueSorted;
  30660. /**
  30661. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  30662. * @param subMeshes The submeshes to render
  30663. */
  30664. private renderAlphaTestSorted;
  30665. /**
  30666. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  30667. * @param subMeshes The submeshes to render
  30668. */
  30669. private renderTransparentSorted;
  30670. /**
  30671. * Renders the submeshes in a specified order.
  30672. * @param subMeshes The submeshes to sort before render
  30673. * @param sortCompareFn The comparison function use to sort
  30674. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  30675. * @param transparent Specifies to activate blending if true
  30676. */
  30677. private static renderSorted;
  30678. /**
  30679. * Renders the submeshes in the order they were dispatched (no sort applied).
  30680. * @param subMeshes The submeshes to render
  30681. */
  30682. private static renderUnsorted;
  30683. /**
  30684. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30685. * are rendered back to front if in the same alpha index.
  30686. *
  30687. * @param a The first submesh
  30688. * @param b The second submesh
  30689. * @returns The result of the comparison
  30690. */
  30691. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  30692. /**
  30693. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30694. * are rendered back to front.
  30695. *
  30696. * @param a The first submesh
  30697. * @param b The second submesh
  30698. * @returns The result of the comparison
  30699. */
  30700. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  30701. /**
  30702. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30703. * are rendered front to back (prevent overdraw).
  30704. *
  30705. * @param a The first submesh
  30706. * @param b The second submesh
  30707. * @returns The result of the comparison
  30708. */
  30709. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  30710. /**
  30711. * Resets the different lists of submeshes to prepare a new frame.
  30712. */
  30713. prepare(): void;
  30714. dispose(): void;
  30715. /**
  30716. * Inserts the submesh in its correct queue depending on its material.
  30717. * @param subMesh The submesh to dispatch
  30718. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30719. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30720. */
  30721. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30722. dispatchSprites(spriteManager: ISpriteManager): void;
  30723. dispatchParticles(particleSystem: IParticleSystem): void;
  30724. private _renderParticles;
  30725. private _renderSprites;
  30726. }
  30727. }
  30728. declare module "babylonjs/Rendering/renderingManager" {
  30729. import { Nullable } from "babylonjs/types";
  30730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30731. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30732. import { SmartArray } from "babylonjs/Misc/smartArray";
  30733. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30734. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30735. import { Material } from "babylonjs/Materials/material";
  30736. import { Scene } from "babylonjs/scene";
  30737. import { Camera } from "babylonjs/Cameras/camera";
  30738. /**
  30739. * Interface describing the different options available in the rendering manager
  30740. * regarding Auto Clear between groups.
  30741. */
  30742. export interface IRenderingManagerAutoClearSetup {
  30743. /**
  30744. * Defines whether or not autoclear is enable.
  30745. */
  30746. autoClear: boolean;
  30747. /**
  30748. * Defines whether or not to autoclear the depth buffer.
  30749. */
  30750. depth: boolean;
  30751. /**
  30752. * Defines whether or not to autoclear the stencil buffer.
  30753. */
  30754. stencil: boolean;
  30755. }
  30756. /**
  30757. * This class is used by the onRenderingGroupObservable
  30758. */
  30759. export class RenderingGroupInfo {
  30760. /**
  30761. * The Scene that being rendered
  30762. */
  30763. scene: Scene;
  30764. /**
  30765. * The camera currently used for the rendering pass
  30766. */
  30767. camera: Nullable<Camera>;
  30768. /**
  30769. * The ID of the renderingGroup being processed
  30770. */
  30771. renderingGroupId: number;
  30772. }
  30773. /**
  30774. * This is the manager responsible of all the rendering for meshes sprites and particles.
  30775. * It is enable to manage the different groups as well as the different necessary sort functions.
  30776. * This should not be used directly aside of the few static configurations
  30777. */
  30778. export class RenderingManager {
  30779. /**
  30780. * The max id used for rendering groups (not included)
  30781. */
  30782. static MAX_RENDERINGGROUPS: number;
  30783. /**
  30784. * The min id used for rendering groups (included)
  30785. */
  30786. static MIN_RENDERINGGROUPS: number;
  30787. /**
  30788. * Used to globally prevent autoclearing scenes.
  30789. */
  30790. static AUTOCLEAR: boolean;
  30791. /**
  30792. * @hidden
  30793. */
  30794. _useSceneAutoClearSetup: boolean;
  30795. private _scene;
  30796. private _renderingGroups;
  30797. private _depthStencilBufferAlreadyCleaned;
  30798. private _autoClearDepthStencil;
  30799. private _customOpaqueSortCompareFn;
  30800. private _customAlphaTestSortCompareFn;
  30801. private _customTransparentSortCompareFn;
  30802. private _renderingGroupInfo;
  30803. /**
  30804. * Instantiates a new rendering group for a particular scene
  30805. * @param scene Defines the scene the groups belongs to
  30806. */
  30807. constructor(scene: Scene);
  30808. private _clearDepthStencilBuffer;
  30809. /**
  30810. * Renders the entire managed groups. This is used by the scene or the different render targets.
  30811. * @hidden
  30812. */
  30813. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  30814. /**
  30815. * Resets the different information of the group to prepare a new frame
  30816. * @hidden
  30817. */
  30818. reset(): void;
  30819. /**
  30820. * Dispose and release the group and its associated resources.
  30821. * @hidden
  30822. */
  30823. dispose(): void;
  30824. /**
  30825. * Clear the info related to rendering groups preventing retention points during dispose.
  30826. */
  30827. freeRenderingGroups(): void;
  30828. private _prepareRenderingGroup;
  30829. /**
  30830. * Add a sprite manager to the rendering manager in order to render it this frame.
  30831. * @param spriteManager Define the sprite manager to render
  30832. */
  30833. dispatchSprites(spriteManager: ISpriteManager): void;
  30834. /**
  30835. * Add a particle system to the rendering manager in order to render it this frame.
  30836. * @param particleSystem Define the particle system to render
  30837. */
  30838. dispatchParticles(particleSystem: IParticleSystem): void;
  30839. /**
  30840. * Add a submesh to the manager in order to render it this frame
  30841. * @param subMesh The submesh to dispatch
  30842. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30843. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30844. */
  30845. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30846. /**
  30847. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  30848. * This allowed control for front to back rendering or reversely depending of the special needs.
  30849. *
  30850. * @param renderingGroupId The rendering group id corresponding to its index
  30851. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30852. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30853. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30854. */
  30855. 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;
  30856. /**
  30857. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30858. *
  30859. * @param renderingGroupId The rendering group id corresponding to its index
  30860. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30861. * @param depth Automatically clears depth between groups if true and autoClear is true.
  30862. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  30863. */
  30864. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  30865. /**
  30866. * Gets the current auto clear configuration for one rendering group of the rendering
  30867. * manager.
  30868. * @param index the rendering group index to get the information for
  30869. * @returns The auto clear setup for the requested rendering group
  30870. */
  30871. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  30872. }
  30873. }
  30874. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  30875. import { SmartArray } from "babylonjs/Misc/smartArray";
  30876. import { Nullable } from "babylonjs/types";
  30877. import { Scene } from "babylonjs/scene";
  30878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30879. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30881. import { Mesh } from "babylonjs/Meshes/mesh";
  30882. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  30883. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30884. import { Effect } from "babylonjs/Materials/effect";
  30885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30886. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30887. import "babylonjs/Shaders/shadowMap.fragment";
  30888. import "babylonjs/Shaders/shadowMap.vertex";
  30889. import "babylonjs/Shaders/depthBoxBlur.fragment";
  30890. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  30891. import { Observable } from "babylonjs/Misc/observable";
  30892. /**
  30893. * Defines the options associated with the creation of a custom shader for a shadow generator.
  30894. */
  30895. export interface ICustomShaderOptions {
  30896. /**
  30897. * Gets or sets the custom shader name to use
  30898. */
  30899. shaderName: string;
  30900. /**
  30901. * The list of attribute names used in the shader
  30902. */
  30903. attributes?: string[];
  30904. /**
  30905. * The list of uniform names used in the shader
  30906. */
  30907. uniforms?: string[];
  30908. /**
  30909. * The list of sampler names used in the shader
  30910. */
  30911. samplers?: string[];
  30912. /**
  30913. * The list of defines used in the shader
  30914. */
  30915. defines?: string[];
  30916. }
  30917. /**
  30918. * Interface to implement to create a shadow generator compatible with BJS.
  30919. */
  30920. export interface IShadowGenerator {
  30921. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30922. id: string;
  30923. /**
  30924. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30925. * @returns The render target texture if present otherwise, null
  30926. */
  30927. getShadowMap(): Nullable<RenderTargetTexture>;
  30928. /**
  30929. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30930. * @param subMesh The submesh we want to render in the shadow map
  30931. * @param useInstances Defines whether will draw in the map using instances
  30932. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30933. * @returns true if ready otherwise, false
  30934. */
  30935. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30936. /**
  30937. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30938. * @param defines Defines of the material we want to update
  30939. * @param lightIndex Index of the light in the enabled light list of the material
  30940. */
  30941. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30942. /**
  30943. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30944. * defined in the generator but impacting the effect).
  30945. * It implies the uniforms available on the materials are the standard BJS ones.
  30946. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30947. * @param effect The effect we are binding the information for
  30948. */
  30949. bindShadowLight(lightIndex: string, effect: Effect): void;
  30950. /**
  30951. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30952. * (eq to shadow projection matrix * light transform matrix)
  30953. * @returns The transform matrix used to create the shadow map
  30954. */
  30955. getTransformMatrix(): Matrix;
  30956. /**
  30957. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30958. * Cube and 2D textures for instance.
  30959. */
  30960. recreateShadowMap(): void;
  30961. /**
  30962. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30963. * @param onCompiled Callback triggered at the and of the effects compilation
  30964. * @param options Sets of optional options forcing the compilation with different modes
  30965. */
  30966. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30967. useInstances: boolean;
  30968. }>): void;
  30969. /**
  30970. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30971. * @param options Sets of optional options forcing the compilation with different modes
  30972. * @returns A promise that resolves when the compilation completes
  30973. */
  30974. forceCompilationAsync(options?: Partial<{
  30975. useInstances: boolean;
  30976. }>): Promise<void>;
  30977. /**
  30978. * Serializes the shadow generator setup to a json object.
  30979. * @returns The serialized JSON object
  30980. */
  30981. serialize(): any;
  30982. /**
  30983. * Disposes the Shadow map and related Textures and effects.
  30984. */
  30985. dispose(): void;
  30986. }
  30987. /**
  30988. * Default implementation IShadowGenerator.
  30989. * This is the main object responsible of generating shadows in the framework.
  30990. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30991. */
  30992. export class ShadowGenerator implements IShadowGenerator {
  30993. private static _Counter;
  30994. /**
  30995. * Name of the shadow generator class
  30996. */
  30997. static CLASSNAME: string;
  30998. /**
  30999. * Shadow generator mode None: no filtering applied.
  31000. */
  31001. static readonly FILTER_NONE: number;
  31002. /**
  31003. * Shadow generator mode ESM: Exponential Shadow Mapping.
  31004. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31005. */
  31006. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  31007. /**
  31008. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  31009. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  31010. */
  31011. static readonly FILTER_POISSONSAMPLING: number;
  31012. /**
  31013. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  31014. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31015. */
  31016. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  31017. /**
  31018. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  31019. * edge artifacts on steep falloff.
  31020. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31021. */
  31022. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  31023. /**
  31024. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  31025. * edge artifacts on steep falloff.
  31026. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31027. */
  31028. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  31029. /**
  31030. * Shadow generator mode PCF: Percentage Closer Filtering
  31031. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31032. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  31033. */
  31034. static readonly FILTER_PCF: number;
  31035. /**
  31036. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  31037. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31038. * Contact Hardening
  31039. */
  31040. static readonly FILTER_PCSS: number;
  31041. /**
  31042. * Reserved for PCF and PCSS
  31043. * Highest Quality.
  31044. *
  31045. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  31046. *
  31047. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  31048. */
  31049. static readonly QUALITY_HIGH: number;
  31050. /**
  31051. * Reserved for PCF and PCSS
  31052. * Good tradeoff for quality/perf cross devices
  31053. *
  31054. * Execute PCF on a 3*3 kernel.
  31055. *
  31056. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  31057. */
  31058. static readonly QUALITY_MEDIUM: number;
  31059. /**
  31060. * Reserved for PCF and PCSS
  31061. * The lowest quality but the fastest.
  31062. *
  31063. * Execute PCF on a 1*1 kernel.
  31064. *
  31065. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  31066. */
  31067. static readonly QUALITY_LOW: number;
  31068. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  31069. id: string;
  31070. /** Gets or sets the custom shader name to use */
  31071. customShaderOptions: ICustomShaderOptions;
  31072. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  31073. customAllowRendering: (subMesh: SubMesh) => boolean;
  31074. /**
  31075. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  31076. */
  31077. onBeforeShadowMapRenderObservable: Observable<Effect>;
  31078. /**
  31079. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  31080. */
  31081. onAfterShadowMapRenderObservable: Observable<Effect>;
  31082. /**
  31083. * Observable triggered before a mesh is rendered in the shadow map.
  31084. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  31085. */
  31086. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  31087. /**
  31088. * Observable triggered after a mesh is rendered in the shadow map.
  31089. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  31090. */
  31091. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  31092. protected _bias: number;
  31093. /**
  31094. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  31095. */
  31096. get bias(): number;
  31097. /**
  31098. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  31099. */
  31100. set bias(bias: number);
  31101. protected _normalBias: number;
  31102. /**
  31103. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  31104. */
  31105. get normalBias(): number;
  31106. /**
  31107. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  31108. */
  31109. set normalBias(normalBias: number);
  31110. protected _blurBoxOffset: number;
  31111. /**
  31112. * Gets the blur box offset: offset applied during the blur pass.
  31113. * Only useful if useKernelBlur = false
  31114. */
  31115. get blurBoxOffset(): number;
  31116. /**
  31117. * Sets the blur box offset: offset applied during the blur pass.
  31118. * Only useful if useKernelBlur = false
  31119. */
  31120. set blurBoxOffset(value: number);
  31121. protected _blurScale: number;
  31122. /**
  31123. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  31124. * 2 means half of the size.
  31125. */
  31126. get blurScale(): number;
  31127. /**
  31128. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  31129. * 2 means half of the size.
  31130. */
  31131. set blurScale(value: number);
  31132. protected _blurKernel: number;
  31133. /**
  31134. * Gets the blur kernel: kernel size of the blur pass.
  31135. * Only useful if useKernelBlur = true
  31136. */
  31137. get blurKernel(): number;
  31138. /**
  31139. * Sets the blur kernel: kernel size of the blur pass.
  31140. * Only useful if useKernelBlur = true
  31141. */
  31142. set blurKernel(value: number);
  31143. protected _useKernelBlur: boolean;
  31144. /**
  31145. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  31146. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  31147. */
  31148. get useKernelBlur(): boolean;
  31149. /**
  31150. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  31151. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  31152. */
  31153. set useKernelBlur(value: boolean);
  31154. protected _depthScale: number;
  31155. /**
  31156. * Gets the depth scale used in ESM mode.
  31157. */
  31158. get depthScale(): number;
  31159. /**
  31160. * Sets the depth scale used in ESM mode.
  31161. * This can override the scale stored on the light.
  31162. */
  31163. set depthScale(value: number);
  31164. protected _validateFilter(filter: number): number;
  31165. protected _filter: number;
  31166. /**
  31167. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  31168. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31169. */
  31170. get filter(): number;
  31171. /**
  31172. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  31173. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31174. */
  31175. set filter(value: number);
  31176. /**
  31177. * Gets if the current filter is set to Poisson Sampling.
  31178. */
  31179. get usePoissonSampling(): boolean;
  31180. /**
  31181. * Sets the current filter to Poisson Sampling.
  31182. */
  31183. set usePoissonSampling(value: boolean);
  31184. /**
  31185. * Gets if the current filter is set to ESM.
  31186. */
  31187. get useExponentialShadowMap(): boolean;
  31188. /**
  31189. * Sets the current filter is to ESM.
  31190. */
  31191. set useExponentialShadowMap(value: boolean);
  31192. /**
  31193. * Gets if the current filter is set to filtered ESM.
  31194. */
  31195. get useBlurExponentialShadowMap(): boolean;
  31196. /**
  31197. * Gets if the current filter is set to filtered ESM.
  31198. */
  31199. set useBlurExponentialShadowMap(value: boolean);
  31200. /**
  31201. * Gets if the current filter is set to "close ESM" (using the inverse of the
  31202. * exponential to prevent steep falloff artifacts).
  31203. */
  31204. get useCloseExponentialShadowMap(): boolean;
  31205. /**
  31206. * Sets the current filter to "close ESM" (using the inverse of the
  31207. * exponential to prevent steep falloff artifacts).
  31208. */
  31209. set useCloseExponentialShadowMap(value: boolean);
  31210. /**
  31211. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  31212. * exponential to prevent steep falloff artifacts).
  31213. */
  31214. get useBlurCloseExponentialShadowMap(): boolean;
  31215. /**
  31216. * Sets the current filter to filtered "close ESM" (using the inverse of the
  31217. * exponential to prevent steep falloff artifacts).
  31218. */
  31219. set useBlurCloseExponentialShadowMap(value: boolean);
  31220. /**
  31221. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  31222. */
  31223. get usePercentageCloserFiltering(): boolean;
  31224. /**
  31225. * Sets the current filter to "PCF" (percentage closer filtering).
  31226. */
  31227. set usePercentageCloserFiltering(value: boolean);
  31228. protected _filteringQuality: number;
  31229. /**
  31230. * Gets the PCF or PCSS Quality.
  31231. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31232. */
  31233. get filteringQuality(): number;
  31234. /**
  31235. * Sets the PCF or PCSS Quality.
  31236. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31237. */
  31238. set filteringQuality(filteringQuality: number);
  31239. /**
  31240. * Gets if the current filter is set to "PCSS" (contact hardening).
  31241. */
  31242. get useContactHardeningShadow(): boolean;
  31243. /**
  31244. * Sets the current filter to "PCSS" (contact hardening).
  31245. */
  31246. set useContactHardeningShadow(value: boolean);
  31247. protected _contactHardeningLightSizeUVRatio: number;
  31248. /**
  31249. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31250. * Using a ratio helps keeping shape stability independently of the map size.
  31251. *
  31252. * It does not account for the light projection as it was having too much
  31253. * instability during the light setup or during light position changes.
  31254. *
  31255. * Only valid if useContactHardeningShadow is true.
  31256. */
  31257. get contactHardeningLightSizeUVRatio(): number;
  31258. /**
  31259. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31260. * Using a ratio helps keeping shape stability independently of the map size.
  31261. *
  31262. * It does not account for the light projection as it was having too much
  31263. * instability during the light setup or during light position changes.
  31264. *
  31265. * Only valid if useContactHardeningShadow is true.
  31266. */
  31267. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  31268. protected _darkness: number;
  31269. /** Gets or sets the actual darkness of a shadow */
  31270. get darkness(): number;
  31271. set darkness(value: number);
  31272. /**
  31273. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31274. * 0 means strongest and 1 would means no shadow.
  31275. * @returns the darkness.
  31276. */
  31277. getDarkness(): number;
  31278. /**
  31279. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  31280. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  31281. * @returns the shadow generator allowing fluent coding.
  31282. */
  31283. setDarkness(darkness: number): ShadowGenerator;
  31284. protected _transparencyShadow: boolean;
  31285. /** Gets or sets the ability to have transparent shadow */
  31286. get transparencyShadow(): boolean;
  31287. set transparencyShadow(value: boolean);
  31288. /**
  31289. * Sets the ability to have transparent shadow (boolean).
  31290. * @param transparent True if transparent else False
  31291. * @returns the shadow generator allowing fluent coding
  31292. */
  31293. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  31294. /**
  31295. * Enables or disables shadows with varying strength based on the transparency
  31296. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  31297. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  31298. * mesh.visibility * alphaTexture.a
  31299. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  31300. */
  31301. enableSoftTransparentShadow: boolean;
  31302. protected _shadowMap: Nullable<RenderTargetTexture>;
  31303. protected _shadowMap2: Nullable<RenderTargetTexture>;
  31304. /**
  31305. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31306. * @returns The render target texture if present otherwise, null
  31307. */
  31308. getShadowMap(): Nullable<RenderTargetTexture>;
  31309. /**
  31310. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31311. * @returns The render target texture if the shadow map is present otherwise, null
  31312. */
  31313. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31314. /**
  31315. * Gets the class name of that object
  31316. * @returns "ShadowGenerator"
  31317. */
  31318. getClassName(): string;
  31319. /**
  31320. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31321. * @param mesh Mesh to add
  31322. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31323. * @returns the Shadow Generator itself
  31324. */
  31325. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31326. /**
  31327. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31328. * @param mesh Mesh to remove
  31329. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31330. * @returns the Shadow Generator itself
  31331. */
  31332. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31333. /**
  31334. * Controls the extent to which the shadows fade out at the edge of the frustum
  31335. */
  31336. frustumEdgeFalloff: number;
  31337. protected _light: IShadowLight;
  31338. /**
  31339. * Returns the associated light object.
  31340. * @returns the light generating the shadow
  31341. */
  31342. getLight(): IShadowLight;
  31343. /**
  31344. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31345. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31346. * It might on the other hand introduce peter panning.
  31347. */
  31348. forceBackFacesOnly: boolean;
  31349. protected _scene: Scene;
  31350. protected _lightDirection: Vector3;
  31351. protected _viewMatrix: Matrix;
  31352. protected _projectionMatrix: Matrix;
  31353. protected _transformMatrix: Matrix;
  31354. protected _cachedPosition: Vector3;
  31355. protected _cachedDirection: Vector3;
  31356. protected _cachedDefines: string;
  31357. protected _currentRenderID: number;
  31358. protected _boxBlurPostprocess: Nullable<PostProcess>;
  31359. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  31360. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  31361. protected _blurPostProcesses: PostProcess[];
  31362. protected _mapSize: number;
  31363. protected _currentFaceIndex: number;
  31364. protected _currentFaceIndexCache: number;
  31365. protected _textureType: number;
  31366. protected _defaultTextureMatrix: Matrix;
  31367. protected _storedUniqueId: Nullable<number>;
  31368. protected _nameForCustomEffect: string;
  31369. /** @hidden */
  31370. static _SceneComponentInitialization: (scene: Scene) => void;
  31371. /**
  31372. * Gets or sets the size of the texture what stores the shadows
  31373. */
  31374. get mapSize(): number;
  31375. set mapSize(size: number);
  31376. /**
  31377. * Creates a ShadowGenerator object.
  31378. * A ShadowGenerator is the required tool to use the shadows.
  31379. * Each light casting shadows needs to use its own ShadowGenerator.
  31380. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  31381. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31382. * @param light The light object generating the shadows.
  31383. * @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.
  31384. */
  31385. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  31386. protected _initializeGenerator(): void;
  31387. protected _createTargetRenderTexture(): void;
  31388. protected _initializeShadowMap(): void;
  31389. protected _initializeBlurRTTAndPostProcesses(): void;
  31390. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  31391. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  31392. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  31393. protected _applyFilterValues(): void;
  31394. /**
  31395. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  31396. * @param onCompiled Callback triggered at the and of the effects compilation
  31397. * @param options Sets of optional options forcing the compilation with different modes
  31398. */
  31399. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  31400. useInstances: boolean;
  31401. }>): void;
  31402. /**
  31403. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  31404. * @param options Sets of optional options forcing the compilation with different modes
  31405. * @returns A promise that resolves when the compilation completes
  31406. */
  31407. forceCompilationAsync(options?: Partial<{
  31408. useInstances: boolean;
  31409. }>): Promise<void>;
  31410. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  31411. private _prepareShadowDefines;
  31412. /**
  31413. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31414. * @param subMesh The submesh we want to render in the shadow map
  31415. * @param useInstances Defines whether will draw in the map using instances
  31416. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  31417. * @returns true if ready otherwise, false
  31418. */
  31419. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  31420. /**
  31421. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31422. * @param defines Defines of the material we want to update
  31423. * @param lightIndex Index of the light in the enabled light list of the material
  31424. */
  31425. prepareDefines(defines: any, lightIndex: number): void;
  31426. /**
  31427. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31428. * defined in the generator but impacting the effect).
  31429. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31430. * @param effect The effect we are binding the information for
  31431. */
  31432. bindShadowLight(lightIndex: string, effect: Effect): void;
  31433. /**
  31434. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31435. * (eq to shadow projection matrix * light transform matrix)
  31436. * @returns The transform matrix used to create the shadow map
  31437. */
  31438. getTransformMatrix(): Matrix;
  31439. /**
  31440. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31441. * Cube and 2D textures for instance.
  31442. */
  31443. recreateShadowMap(): void;
  31444. protected _disposeBlurPostProcesses(): void;
  31445. protected _disposeRTTandPostProcesses(): void;
  31446. /**
  31447. * Disposes the ShadowGenerator.
  31448. * Returns nothing.
  31449. */
  31450. dispose(): void;
  31451. /**
  31452. * Serializes the shadow generator setup to a json object.
  31453. * @returns The serialized JSON object
  31454. */
  31455. serialize(): any;
  31456. /**
  31457. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31458. * @param parsedShadowGenerator The JSON object to parse
  31459. * @param scene The scene to create the shadow map for
  31460. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  31461. * @returns The parsed shadow generator
  31462. */
  31463. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  31464. }
  31465. }
  31466. declare module "babylonjs/Materials/shadowDepthWrapper" {
  31467. import { Nullable } from "babylonjs/types";
  31468. import { Scene } from "babylonjs/scene";
  31469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31470. import { Material } from "babylonjs/Materials/material";
  31471. import { Effect } from "babylonjs/Materials/effect";
  31472. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  31473. /**
  31474. * Options to be used when creating a shadow depth material
  31475. */
  31476. export interface IIOptionShadowDepthMaterial {
  31477. /** Variables in the vertex shader code that need to have their names remapped.
  31478. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  31479. * "var_name" should be either: worldPos or vNormalW
  31480. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  31481. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  31482. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  31483. */
  31484. remappedVariables?: string[];
  31485. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  31486. standalone?: boolean;
  31487. }
  31488. /**
  31489. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  31490. */
  31491. export class ShadowDepthWrapper {
  31492. private _scene;
  31493. private _options?;
  31494. private _baseMaterial;
  31495. private _onEffectCreatedObserver;
  31496. private _subMeshToEffect;
  31497. private _subMeshToDepthEffect;
  31498. private _meshes;
  31499. /** @hidden */
  31500. _matriceNames: any;
  31501. /** Gets the standalone status of the wrapper */
  31502. get standalone(): boolean;
  31503. /** Gets the base material the wrapper is built upon */
  31504. get baseMaterial(): Material;
  31505. /**
  31506. * Instantiate a new shadow depth wrapper.
  31507. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  31508. * generate the shadow depth map. For more information, please refer to the documentation:
  31509. * https://doc.babylonjs.com/babylon101/shadows
  31510. * @param baseMaterial Material to wrap
  31511. * @param scene Define the scene the material belongs to
  31512. * @param options Options used to create the wrapper
  31513. */
  31514. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  31515. /**
  31516. * Gets the effect to use to generate the depth map
  31517. * @param subMesh subMesh to get the effect for
  31518. * @param shadowGenerator shadow generator to get the effect for
  31519. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  31520. */
  31521. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  31522. /**
  31523. * Specifies that the submesh is ready to be used for depth rendering
  31524. * @param subMesh submesh to check
  31525. * @param defines the list of defines to take into account when checking the effect
  31526. * @param shadowGenerator combined with subMesh, it defines the effect to check
  31527. * @param useInstances specifies that instances should be used
  31528. * @returns a boolean indicating that the submesh is ready or not
  31529. */
  31530. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  31531. /**
  31532. * Disposes the resources
  31533. */
  31534. dispose(): void;
  31535. private _makeEffect;
  31536. }
  31537. }
  31538. declare module "babylonjs/Materials/material" {
  31539. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31540. import { SmartArray } from "babylonjs/Misc/smartArray";
  31541. import { Observable } from "babylonjs/Misc/observable";
  31542. import { Nullable } from "babylonjs/types";
  31543. import { Matrix } from "babylonjs/Maths/math.vector";
  31544. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31546. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31547. import { Effect } from "babylonjs/Materials/effect";
  31548. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31549. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31550. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31551. import { IInspectable } from "babylonjs/Misc/iInspectable";
  31552. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  31553. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  31554. import { Mesh } from "babylonjs/Meshes/mesh";
  31555. import { Animation } from "babylonjs/Animations/animation";
  31556. import { Scene } from "babylonjs/scene";
  31557. /**
  31558. * Options for compiling materials.
  31559. */
  31560. export interface IMaterialCompilationOptions {
  31561. /**
  31562. * Defines whether clip planes are enabled.
  31563. */
  31564. clipPlane: boolean;
  31565. /**
  31566. * Defines whether instances are enabled.
  31567. */
  31568. useInstances: boolean;
  31569. }
  31570. /**
  31571. * Options passed when calling customShaderNameResolve
  31572. */
  31573. export interface ICustomShaderNameResolveOptions {
  31574. /**
  31575. * 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
  31576. */
  31577. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  31578. }
  31579. /**
  31580. * Base class for the main features of a material in Babylon.js
  31581. */
  31582. export class Material implements IAnimatable {
  31583. /**
  31584. * Returns the triangle fill mode
  31585. */
  31586. static readonly TriangleFillMode: number;
  31587. /**
  31588. * Returns the wireframe mode
  31589. */
  31590. static readonly WireFrameFillMode: number;
  31591. /**
  31592. * Returns the point fill mode
  31593. */
  31594. static readonly PointFillMode: number;
  31595. /**
  31596. * Returns the point list draw mode
  31597. */
  31598. static readonly PointListDrawMode: number;
  31599. /**
  31600. * Returns the line list draw mode
  31601. */
  31602. static readonly LineListDrawMode: number;
  31603. /**
  31604. * Returns the line loop draw mode
  31605. */
  31606. static readonly LineLoopDrawMode: number;
  31607. /**
  31608. * Returns the line strip draw mode
  31609. */
  31610. static readonly LineStripDrawMode: number;
  31611. /**
  31612. * Returns the triangle strip draw mode
  31613. */
  31614. static readonly TriangleStripDrawMode: number;
  31615. /**
  31616. * Returns the triangle fan draw mode
  31617. */
  31618. static readonly TriangleFanDrawMode: number;
  31619. /**
  31620. * Stores the clock-wise side orientation
  31621. */
  31622. static readonly ClockWiseSideOrientation: number;
  31623. /**
  31624. * Stores the counter clock-wise side orientation
  31625. */
  31626. static readonly CounterClockWiseSideOrientation: number;
  31627. /**
  31628. * The dirty texture flag value
  31629. */
  31630. static readonly TextureDirtyFlag: number;
  31631. /**
  31632. * The dirty light flag value
  31633. */
  31634. static readonly LightDirtyFlag: number;
  31635. /**
  31636. * The dirty fresnel flag value
  31637. */
  31638. static readonly FresnelDirtyFlag: number;
  31639. /**
  31640. * The dirty attribute flag value
  31641. */
  31642. static readonly AttributesDirtyFlag: number;
  31643. /**
  31644. * The dirty misc flag value
  31645. */
  31646. static readonly MiscDirtyFlag: number;
  31647. /**
  31648. * The dirty prepass flag value
  31649. */
  31650. static readonly PrePassDirtyFlag: number;
  31651. /**
  31652. * The all dirty flag value
  31653. */
  31654. static readonly AllDirtyFlag: number;
  31655. /**
  31656. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31657. */
  31658. static readonly MATERIAL_OPAQUE: number;
  31659. /**
  31660. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31661. */
  31662. static readonly MATERIAL_ALPHATEST: number;
  31663. /**
  31664. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31665. */
  31666. static readonly MATERIAL_ALPHABLEND: number;
  31667. /**
  31668. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31669. * They are also discarded below the alpha cutoff threshold to improve performances.
  31670. */
  31671. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  31672. /**
  31673. * The Whiteout method is used to blend normals.
  31674. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31675. */
  31676. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  31677. /**
  31678. * The Reoriented Normal Mapping method is used to blend normals.
  31679. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31680. */
  31681. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  31682. /**
  31683. * Custom callback helping to override the default shader used in the material.
  31684. */
  31685. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  31686. /**
  31687. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  31688. */
  31689. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  31690. /**
  31691. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  31692. * This means that the material can keep using a previous shader while a new one is being compiled.
  31693. * This is mostly used when shader parallel compilation is supported (true by default)
  31694. */
  31695. allowShaderHotSwapping: boolean;
  31696. /**
  31697. * The ID of the material
  31698. */
  31699. id: string;
  31700. /**
  31701. * Gets or sets the unique id of the material
  31702. */
  31703. uniqueId: number;
  31704. /**
  31705. * The name of the material
  31706. */
  31707. name: string;
  31708. /**
  31709. * Gets or sets user defined metadata
  31710. */
  31711. metadata: any;
  31712. /**
  31713. * For internal use only. Please do not use.
  31714. */
  31715. reservedDataStore: any;
  31716. /**
  31717. * Specifies if the ready state should be checked on each call
  31718. */
  31719. checkReadyOnEveryCall: boolean;
  31720. /**
  31721. * Specifies if the ready state should be checked once
  31722. */
  31723. checkReadyOnlyOnce: boolean;
  31724. /**
  31725. * The state of the material
  31726. */
  31727. state: string;
  31728. /**
  31729. * If the material can be rendered to several textures with MRT extension
  31730. */
  31731. get canRenderToMRT(): boolean;
  31732. /**
  31733. * The alpha value of the material
  31734. */
  31735. protected _alpha: number;
  31736. /**
  31737. * List of inspectable custom properties (used by the Inspector)
  31738. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31739. */
  31740. inspectableCustomProperties: IInspectable[];
  31741. /**
  31742. * Sets the alpha value of the material
  31743. */
  31744. set alpha(value: number);
  31745. /**
  31746. * Gets the alpha value of the material
  31747. */
  31748. get alpha(): number;
  31749. /**
  31750. * Specifies if back face culling is enabled
  31751. */
  31752. protected _backFaceCulling: boolean;
  31753. /**
  31754. * Sets the back-face culling state
  31755. */
  31756. set backFaceCulling(value: boolean);
  31757. /**
  31758. * Gets the back-face culling state
  31759. */
  31760. get backFaceCulling(): boolean;
  31761. /**
  31762. * Stores the value for side orientation
  31763. */
  31764. sideOrientation: number;
  31765. /**
  31766. * Callback triggered when the material is compiled
  31767. */
  31768. onCompiled: Nullable<(effect: Effect) => void>;
  31769. /**
  31770. * Callback triggered when an error occurs
  31771. */
  31772. onError: Nullable<(effect: Effect, errors: string) => void>;
  31773. /**
  31774. * Callback triggered to get the render target textures
  31775. */
  31776. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  31777. /**
  31778. * Gets a boolean indicating that current material needs to register RTT
  31779. */
  31780. get hasRenderTargetTextures(): boolean;
  31781. /**
  31782. * Specifies if the material should be serialized
  31783. */
  31784. doNotSerialize: boolean;
  31785. /**
  31786. * @hidden
  31787. */
  31788. _storeEffectOnSubMeshes: boolean;
  31789. /**
  31790. * Stores the animations for the material
  31791. */
  31792. animations: Nullable<Array<Animation>>;
  31793. /**
  31794. * An event triggered when the material is disposed
  31795. */
  31796. onDisposeObservable: Observable<Material>;
  31797. /**
  31798. * An observer which watches for dispose events
  31799. */
  31800. private _onDisposeObserver;
  31801. private _onUnBindObservable;
  31802. /**
  31803. * Called during a dispose event
  31804. */
  31805. set onDispose(callback: () => void);
  31806. private _onBindObservable;
  31807. /**
  31808. * An event triggered when the material is bound
  31809. */
  31810. get onBindObservable(): Observable<AbstractMesh>;
  31811. /**
  31812. * An observer which watches for bind events
  31813. */
  31814. private _onBindObserver;
  31815. /**
  31816. * Called during a bind event
  31817. */
  31818. set onBind(callback: (Mesh: AbstractMesh) => void);
  31819. /**
  31820. * An event triggered when the material is unbound
  31821. */
  31822. get onUnBindObservable(): Observable<Material>;
  31823. protected _onEffectCreatedObservable: Nullable<Observable<{
  31824. effect: Effect;
  31825. subMesh: Nullable<SubMesh>;
  31826. }>>;
  31827. /**
  31828. * An event triggered when the effect is (re)created
  31829. */
  31830. get onEffectCreatedObservable(): Observable<{
  31831. effect: Effect;
  31832. subMesh: Nullable<SubMesh>;
  31833. }>;
  31834. /**
  31835. * Stores the value of the alpha mode
  31836. */
  31837. private _alphaMode;
  31838. /**
  31839. * Sets the value of the alpha mode.
  31840. *
  31841. * | Value | Type | Description |
  31842. * | --- | --- | --- |
  31843. * | 0 | ALPHA_DISABLE | |
  31844. * | 1 | ALPHA_ADD | |
  31845. * | 2 | ALPHA_COMBINE | |
  31846. * | 3 | ALPHA_SUBTRACT | |
  31847. * | 4 | ALPHA_MULTIPLY | |
  31848. * | 5 | ALPHA_MAXIMIZED | |
  31849. * | 6 | ALPHA_ONEONE | |
  31850. * | 7 | ALPHA_PREMULTIPLIED | |
  31851. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  31852. * | 9 | ALPHA_INTERPOLATE | |
  31853. * | 10 | ALPHA_SCREENMODE | |
  31854. *
  31855. */
  31856. set alphaMode(value: number);
  31857. /**
  31858. * Gets the value of the alpha mode
  31859. */
  31860. get alphaMode(): number;
  31861. /**
  31862. * Stores the state of the need depth pre-pass value
  31863. */
  31864. private _needDepthPrePass;
  31865. /**
  31866. * Sets the need depth pre-pass value
  31867. */
  31868. set needDepthPrePass(value: boolean);
  31869. /**
  31870. * Gets the depth pre-pass value
  31871. */
  31872. get needDepthPrePass(): boolean;
  31873. /**
  31874. * Can this material render to prepass
  31875. */
  31876. get isPrePassCapable(): boolean;
  31877. /**
  31878. * Specifies if depth writing should be disabled
  31879. */
  31880. disableDepthWrite: boolean;
  31881. /**
  31882. * Specifies if color writing should be disabled
  31883. */
  31884. disableColorWrite: boolean;
  31885. /**
  31886. * Specifies if depth writing should be forced
  31887. */
  31888. forceDepthWrite: boolean;
  31889. /**
  31890. * Specifies the depth function that should be used. 0 means the default engine function
  31891. */
  31892. depthFunction: number;
  31893. /**
  31894. * Specifies if there should be a separate pass for culling
  31895. */
  31896. separateCullingPass: boolean;
  31897. /**
  31898. * Stores the state specifying if fog should be enabled
  31899. */
  31900. private _fogEnabled;
  31901. /**
  31902. * Sets the state for enabling fog
  31903. */
  31904. set fogEnabled(value: boolean);
  31905. /**
  31906. * Gets the value of the fog enabled state
  31907. */
  31908. get fogEnabled(): boolean;
  31909. /**
  31910. * Stores the size of points
  31911. */
  31912. pointSize: number;
  31913. /**
  31914. * Stores the z offset value
  31915. */
  31916. zOffset: number;
  31917. get wireframe(): boolean;
  31918. /**
  31919. * Sets the state of wireframe mode
  31920. */
  31921. set wireframe(value: boolean);
  31922. /**
  31923. * Gets the value specifying if point clouds are enabled
  31924. */
  31925. get pointsCloud(): boolean;
  31926. /**
  31927. * Sets the state of point cloud mode
  31928. */
  31929. set pointsCloud(value: boolean);
  31930. /**
  31931. * Gets the material fill mode
  31932. */
  31933. get fillMode(): number;
  31934. /**
  31935. * Sets the material fill mode
  31936. */
  31937. set fillMode(value: number);
  31938. /**
  31939. * @hidden
  31940. * Stores the effects for the material
  31941. */
  31942. _effect: Nullable<Effect>;
  31943. /**
  31944. * Specifies if uniform buffers should be used
  31945. */
  31946. private _useUBO;
  31947. /**
  31948. * Stores a reference to the scene
  31949. */
  31950. private _scene;
  31951. private _needToBindSceneUbo;
  31952. /**
  31953. * Stores the fill mode state
  31954. */
  31955. private _fillMode;
  31956. /**
  31957. * Specifies if the depth write state should be cached
  31958. */
  31959. private _cachedDepthWriteState;
  31960. /**
  31961. * Specifies if the color write state should be cached
  31962. */
  31963. private _cachedColorWriteState;
  31964. /**
  31965. * Specifies if the depth function state should be cached
  31966. */
  31967. private _cachedDepthFunctionState;
  31968. /**
  31969. * Stores the uniform buffer
  31970. */
  31971. protected _uniformBuffer: UniformBuffer;
  31972. /** @hidden */
  31973. _indexInSceneMaterialArray: number;
  31974. /** @hidden */
  31975. meshMap: Nullable<{
  31976. [id: string]: AbstractMesh | undefined;
  31977. }>;
  31978. /**
  31979. * Creates a material instance
  31980. * @param name defines the name of the material
  31981. * @param scene defines the scene to reference
  31982. * @param doNotAdd specifies if the material should be added to the scene
  31983. */
  31984. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  31985. /**
  31986. * Returns a string representation of the current material
  31987. * @param fullDetails defines a boolean indicating which levels of logging is desired
  31988. * @returns a string with material information
  31989. */
  31990. toString(fullDetails?: boolean): string;
  31991. /**
  31992. * Gets the class name of the material
  31993. * @returns a string with the class name of the material
  31994. */
  31995. getClassName(): string;
  31996. /**
  31997. * Specifies if updates for the material been locked
  31998. */
  31999. get isFrozen(): boolean;
  32000. /**
  32001. * Locks updates for the material
  32002. */
  32003. freeze(): void;
  32004. /**
  32005. * Unlocks updates for the material
  32006. */
  32007. unfreeze(): void;
  32008. /**
  32009. * Specifies if the material is ready to be used
  32010. * @param mesh defines the mesh to check
  32011. * @param useInstances specifies if instances should be used
  32012. * @returns a boolean indicating if the material is ready to be used
  32013. */
  32014. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  32015. /**
  32016. * Specifies that the submesh is ready to be used
  32017. * @param mesh defines the mesh to check
  32018. * @param subMesh defines which submesh to check
  32019. * @param useInstances specifies that instances should be used
  32020. * @returns a boolean indicating that the submesh is ready or not
  32021. */
  32022. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32023. /**
  32024. * Returns the material effect
  32025. * @returns the effect associated with the material
  32026. */
  32027. getEffect(): Nullable<Effect>;
  32028. /**
  32029. * Returns the current scene
  32030. * @returns a Scene
  32031. */
  32032. getScene(): Scene;
  32033. /**
  32034. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32035. */
  32036. protected _forceAlphaTest: boolean;
  32037. /**
  32038. * The transparency mode of the material.
  32039. */
  32040. protected _transparencyMode: Nullable<number>;
  32041. /**
  32042. * Gets the current transparency mode.
  32043. */
  32044. get transparencyMode(): Nullable<number>;
  32045. /**
  32046. * Sets the transparency mode of the material.
  32047. *
  32048. * | Value | Type | Description |
  32049. * | ----- | ----------------------------------- | ----------- |
  32050. * | 0 | OPAQUE | |
  32051. * | 1 | ALPHATEST | |
  32052. * | 2 | ALPHABLEND | |
  32053. * | 3 | ALPHATESTANDBLEND | |
  32054. *
  32055. */
  32056. set transparencyMode(value: Nullable<number>);
  32057. /**
  32058. * Returns true if alpha blending should be disabled.
  32059. */
  32060. protected get _disableAlphaBlending(): boolean;
  32061. /**
  32062. * Specifies whether or not this material should be rendered in alpha blend mode.
  32063. * @returns a boolean specifying if alpha blending is needed
  32064. */
  32065. needAlphaBlending(): boolean;
  32066. /**
  32067. * Specifies if the mesh will require alpha blending
  32068. * @param mesh defines the mesh to check
  32069. * @returns a boolean specifying if alpha blending is needed for the mesh
  32070. */
  32071. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32072. /**
  32073. * Specifies whether or not this material should be rendered in alpha test mode.
  32074. * @returns a boolean specifying if an alpha test is needed.
  32075. */
  32076. needAlphaTesting(): boolean;
  32077. /**
  32078. * Specifies if material alpha testing should be turned on for the mesh
  32079. * @param mesh defines the mesh to check
  32080. */
  32081. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  32082. /**
  32083. * Gets the texture used for the alpha test
  32084. * @returns the texture to use for alpha testing
  32085. */
  32086. getAlphaTestTexture(): Nullable<BaseTexture>;
  32087. /**
  32088. * Marks the material to indicate that it needs to be re-calculated
  32089. */
  32090. markDirty(): void;
  32091. /** @hidden */
  32092. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  32093. /**
  32094. * Binds the material to the mesh
  32095. * @param world defines the world transformation matrix
  32096. * @param mesh defines the mesh to bind the material to
  32097. */
  32098. bind(world: Matrix, mesh?: Mesh): void;
  32099. /**
  32100. * Binds the submesh to the material
  32101. * @param world defines the world transformation matrix
  32102. * @param mesh defines the mesh containing the submesh
  32103. * @param subMesh defines the submesh to bind the material to
  32104. */
  32105. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32106. /**
  32107. * Binds the world matrix to the material
  32108. * @param world defines the world transformation matrix
  32109. */
  32110. bindOnlyWorldMatrix(world: Matrix): void;
  32111. /**
  32112. * Binds the view matrix to the effect
  32113. * @param effect defines the effect to bind the view matrix to
  32114. */
  32115. bindView(effect: Effect): void;
  32116. /**
  32117. * Binds the view projection and projection matrices to the effect
  32118. * @param effect defines the effect to bind the view projection and projection matrices to
  32119. */
  32120. bindViewProjection(effect: Effect): void;
  32121. /**
  32122. * Binds the view matrix to the effect
  32123. * @param effect defines the effect to bind the view matrix to
  32124. * @param variableName name of the shader variable that will hold the eye position
  32125. */
  32126. bindEyePosition(effect: Effect, variableName?: string): void;
  32127. /**
  32128. * Processes to execute after binding the material to a mesh
  32129. * @param mesh defines the rendered mesh
  32130. */
  32131. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  32132. /**
  32133. * Unbinds the material from the mesh
  32134. */
  32135. unbind(): void;
  32136. /**
  32137. * Gets the active textures from the material
  32138. * @returns an array of textures
  32139. */
  32140. getActiveTextures(): BaseTexture[];
  32141. /**
  32142. * Specifies if the material uses a texture
  32143. * @param texture defines the texture to check against the material
  32144. * @returns a boolean specifying if the material uses the texture
  32145. */
  32146. hasTexture(texture: BaseTexture): boolean;
  32147. /**
  32148. * Makes a duplicate of the material, and gives it a new name
  32149. * @param name defines the new name for the duplicated material
  32150. * @returns the cloned material
  32151. */
  32152. clone(name: string): Nullable<Material>;
  32153. /**
  32154. * Gets the meshes bound to the material
  32155. * @returns an array of meshes bound to the material
  32156. */
  32157. getBindedMeshes(): AbstractMesh[];
  32158. /**
  32159. * Force shader compilation
  32160. * @param mesh defines the mesh associated with this material
  32161. * @param onCompiled defines a function to execute once the material is compiled
  32162. * @param options defines the options to configure the compilation
  32163. * @param onError defines a function to execute if the material fails compiling
  32164. */
  32165. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  32166. /**
  32167. * Force shader compilation
  32168. * @param mesh defines the mesh that will use this material
  32169. * @param options defines additional options for compiling the shaders
  32170. * @returns a promise that resolves when the compilation completes
  32171. */
  32172. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  32173. private static readonly _AllDirtyCallBack;
  32174. private static readonly _ImageProcessingDirtyCallBack;
  32175. private static readonly _TextureDirtyCallBack;
  32176. private static readonly _FresnelDirtyCallBack;
  32177. private static readonly _MiscDirtyCallBack;
  32178. private static readonly _PrePassDirtyCallBack;
  32179. private static readonly _LightsDirtyCallBack;
  32180. private static readonly _AttributeDirtyCallBack;
  32181. private static _FresnelAndMiscDirtyCallBack;
  32182. private static _TextureAndMiscDirtyCallBack;
  32183. private static readonly _DirtyCallbackArray;
  32184. private static readonly _RunDirtyCallBacks;
  32185. /**
  32186. * Marks a define in the material to indicate that it needs to be re-computed
  32187. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  32188. */
  32189. markAsDirty(flag: number): void;
  32190. /**
  32191. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  32192. * @param func defines a function which checks material defines against the submeshes
  32193. */
  32194. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  32195. /**
  32196. * Indicates that the scene should check if the rendering now needs a prepass
  32197. */
  32198. protected _markScenePrePassDirty(): void;
  32199. /**
  32200. * Indicates that we need to re-calculated for all submeshes
  32201. */
  32202. protected _markAllSubMeshesAsAllDirty(): void;
  32203. /**
  32204. * Indicates that image processing needs to be re-calculated for all submeshes
  32205. */
  32206. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  32207. /**
  32208. * Indicates that textures need to be re-calculated for all submeshes
  32209. */
  32210. protected _markAllSubMeshesAsTexturesDirty(): void;
  32211. /**
  32212. * Indicates that fresnel needs to be re-calculated for all submeshes
  32213. */
  32214. protected _markAllSubMeshesAsFresnelDirty(): void;
  32215. /**
  32216. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  32217. */
  32218. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  32219. /**
  32220. * Indicates that lights need to be re-calculated for all submeshes
  32221. */
  32222. protected _markAllSubMeshesAsLightsDirty(): void;
  32223. /**
  32224. * Indicates that attributes need to be re-calculated for all submeshes
  32225. */
  32226. protected _markAllSubMeshesAsAttributesDirty(): void;
  32227. /**
  32228. * Indicates that misc needs to be re-calculated for all submeshes
  32229. */
  32230. protected _markAllSubMeshesAsMiscDirty(): void;
  32231. /**
  32232. * Indicates that prepass needs to be re-calculated for all submeshes
  32233. */
  32234. protected _markAllSubMeshesAsPrePassDirty(): void;
  32235. /**
  32236. * Indicates that textures and misc need to be re-calculated for all submeshes
  32237. */
  32238. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  32239. /**
  32240. * Sets the required values to the prepass renderer.
  32241. * @param prePassRenderer defines the prepass renderer to setup.
  32242. * @returns true if the pre pass is needed.
  32243. */
  32244. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  32245. /**
  32246. * Disposes the material
  32247. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32248. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32249. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  32250. */
  32251. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  32252. /** @hidden */
  32253. private releaseVertexArrayObject;
  32254. /**
  32255. * Serializes this material
  32256. * @returns the serialized material object
  32257. */
  32258. serialize(): any;
  32259. /**
  32260. * Creates a material from parsed material data
  32261. * @param parsedMaterial defines parsed material data
  32262. * @param scene defines the hosting scene
  32263. * @param rootUrl defines the root URL to use to load textures
  32264. * @returns a new material
  32265. */
  32266. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  32267. }
  32268. }
  32269. declare module "babylonjs/Materials/multiMaterial" {
  32270. import { Nullable } from "babylonjs/types";
  32271. import { Scene } from "babylonjs/scene";
  32272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32273. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32274. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32275. import { Material } from "babylonjs/Materials/material";
  32276. /**
  32277. * A multi-material is used to apply different materials to different parts of the same object without the need of
  32278. * separate meshes. This can be use to improve performances.
  32279. * @see https://doc.babylonjs.com/how_to/multi_materials
  32280. */
  32281. export class MultiMaterial extends Material {
  32282. private _subMaterials;
  32283. /**
  32284. * Gets or Sets the list of Materials used within the multi material.
  32285. * They need to be ordered according to the submeshes order in the associated mesh
  32286. */
  32287. get subMaterials(): Nullable<Material>[];
  32288. set subMaterials(value: Nullable<Material>[]);
  32289. /**
  32290. * Function used to align with Node.getChildren()
  32291. * @returns the list of Materials used within the multi material
  32292. */
  32293. getChildren(): Nullable<Material>[];
  32294. /**
  32295. * Instantiates a new Multi Material
  32296. * A multi-material is used to apply different materials to different parts of the same object without the need of
  32297. * separate meshes. This can be use to improve performances.
  32298. * @see https://doc.babylonjs.com/how_to/multi_materials
  32299. * @param name Define the name in the scene
  32300. * @param scene Define the scene the material belongs to
  32301. */
  32302. constructor(name: string, scene: Scene);
  32303. private _hookArray;
  32304. /**
  32305. * Get one of the submaterial by its index in the submaterials array
  32306. * @param index The index to look the sub material at
  32307. * @returns The Material if the index has been defined
  32308. */
  32309. getSubMaterial(index: number): Nullable<Material>;
  32310. /**
  32311. * Get the list of active textures for the whole sub materials list.
  32312. * @returns All the textures that will be used during the rendering
  32313. */
  32314. getActiveTextures(): BaseTexture[];
  32315. /**
  32316. * Specifies if any sub-materials of this multi-material use a given texture.
  32317. * @param texture Defines the texture to check against this multi-material's sub-materials.
  32318. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  32319. */
  32320. hasTexture(texture: BaseTexture): boolean;
  32321. /**
  32322. * Gets the current class name of the material e.g. "MultiMaterial"
  32323. * Mainly use in serialization.
  32324. * @returns the class name
  32325. */
  32326. getClassName(): string;
  32327. /**
  32328. * Checks if the material is ready to render the requested sub mesh
  32329. * @param mesh Define the mesh the submesh belongs to
  32330. * @param subMesh Define the sub mesh to look readiness for
  32331. * @param useInstances Define whether or not the material is used with instances
  32332. * @returns true if ready, otherwise false
  32333. */
  32334. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32335. /**
  32336. * Clones the current material and its related sub materials
  32337. * @param name Define the name of the newly cloned material
  32338. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  32339. * @returns the cloned material
  32340. */
  32341. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  32342. /**
  32343. * Serializes the materials into a JSON representation.
  32344. * @returns the JSON representation
  32345. */
  32346. serialize(): any;
  32347. /**
  32348. * Dispose the material and release its associated resources
  32349. * @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)
  32350. * @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)
  32351. * @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)
  32352. */
  32353. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  32354. /**
  32355. * Creates a MultiMaterial from parsed MultiMaterial data.
  32356. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  32357. * @param scene defines the hosting scene
  32358. * @returns a new MultiMaterial
  32359. */
  32360. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  32361. }
  32362. }
  32363. declare module "babylonjs/Meshes/subMesh" {
  32364. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  32365. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32366. import { Engine } from "babylonjs/Engines/engine";
  32367. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  32368. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32369. import { Effect } from "babylonjs/Materials/effect";
  32370. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32371. import { Plane } from "babylonjs/Maths/math.plane";
  32372. import { Collider } from "babylonjs/Collisions/collider";
  32373. import { Material } from "babylonjs/Materials/material";
  32374. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  32375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32376. import { Mesh } from "babylonjs/Meshes/mesh";
  32377. import { Ray } from "babylonjs/Culling/ray";
  32378. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32379. /** @hidden */
  32380. export interface ICustomEffect {
  32381. effect: Effect;
  32382. defines: string;
  32383. }
  32384. /**
  32385. * Defines a subdivision inside a mesh
  32386. */
  32387. export class SubMesh implements ICullable {
  32388. /** the material index to use */
  32389. materialIndex: number;
  32390. /** vertex index start */
  32391. verticesStart: number;
  32392. /** vertices count */
  32393. verticesCount: number;
  32394. /** index start */
  32395. indexStart: number;
  32396. /** indices count */
  32397. indexCount: number;
  32398. /** @hidden */
  32399. _materialDefines: Nullable<MaterialDefines>;
  32400. /** @hidden */
  32401. _materialEffect: Nullable<Effect>;
  32402. /** @hidden */
  32403. _effectOverride: Nullable<Effect>;
  32404. private _customEffects;
  32405. /**
  32406. * Gets material defines used by the effect associated to the sub mesh
  32407. */
  32408. get materialDefines(): Nullable<MaterialDefines>;
  32409. /**
  32410. * Sets material defines used by the effect associated to the sub mesh
  32411. */
  32412. set materialDefines(defines: Nullable<MaterialDefines>);
  32413. /** @hidden */
  32414. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  32415. /** @hidden */
  32416. _removeCustomEffect(name: string): void;
  32417. /**
  32418. * Gets associated effect
  32419. */
  32420. get effect(): Nullable<Effect>;
  32421. /**
  32422. * Sets associated effect (effect used to render this submesh)
  32423. * @param effect defines the effect to associate with
  32424. * @param defines defines the set of defines used to compile this effect
  32425. */
  32426. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  32427. /** @hidden */
  32428. _linesIndexCount: number;
  32429. private _mesh;
  32430. private _renderingMesh;
  32431. private _boundingInfo;
  32432. private _linesIndexBuffer;
  32433. /** @hidden */
  32434. _lastColliderWorldVertices: Nullable<Vector3[]>;
  32435. /** @hidden */
  32436. _trianglePlanes: Plane[];
  32437. /** @hidden */
  32438. _lastColliderTransformMatrix: Nullable<Matrix>;
  32439. /** @hidden */
  32440. _renderId: number;
  32441. /** @hidden */
  32442. _alphaIndex: number;
  32443. /** @hidden */
  32444. _distanceToCamera: number;
  32445. /** @hidden */
  32446. _id: number;
  32447. private _currentMaterial;
  32448. /**
  32449. * Add a new submesh to a mesh
  32450. * @param materialIndex defines the material index to use
  32451. * @param verticesStart defines vertex index start
  32452. * @param verticesCount defines vertices count
  32453. * @param indexStart defines index start
  32454. * @param indexCount defines indices count
  32455. * @param mesh defines the parent mesh
  32456. * @param renderingMesh defines an optional rendering mesh
  32457. * @param createBoundingBox defines if bounding box should be created for this submesh
  32458. * @returns the new submesh
  32459. */
  32460. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  32461. /**
  32462. * Creates a new submesh
  32463. * @param materialIndex defines the material index to use
  32464. * @param verticesStart defines vertex index start
  32465. * @param verticesCount defines vertices count
  32466. * @param indexStart defines index start
  32467. * @param indexCount defines indices count
  32468. * @param mesh defines the parent mesh
  32469. * @param renderingMesh defines an optional rendering mesh
  32470. * @param createBoundingBox defines if bounding box should be created for this submesh
  32471. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  32472. */
  32473. constructor(
  32474. /** the material index to use */
  32475. materialIndex: number,
  32476. /** vertex index start */
  32477. verticesStart: number,
  32478. /** vertices count */
  32479. verticesCount: number,
  32480. /** index start */
  32481. indexStart: number,
  32482. /** indices count */
  32483. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  32484. /**
  32485. * Returns true if this submesh covers the entire parent mesh
  32486. * @ignorenaming
  32487. */
  32488. get IsGlobal(): boolean;
  32489. /**
  32490. * Returns the submesh BoundingInfo object
  32491. * @returns current bounding info (or mesh's one if the submesh is global)
  32492. */
  32493. getBoundingInfo(): BoundingInfo;
  32494. /**
  32495. * Sets the submesh BoundingInfo
  32496. * @param boundingInfo defines the new bounding info to use
  32497. * @returns the SubMesh
  32498. */
  32499. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  32500. /**
  32501. * Returns the mesh of the current submesh
  32502. * @return the parent mesh
  32503. */
  32504. getMesh(): AbstractMesh;
  32505. /**
  32506. * Returns the rendering mesh of the submesh
  32507. * @returns the rendering mesh (could be different from parent mesh)
  32508. */
  32509. getRenderingMesh(): Mesh;
  32510. /**
  32511. * Returns the replacement mesh of the submesh
  32512. * @returns the replacement mesh (could be different from parent mesh)
  32513. */
  32514. getReplacementMesh(): Nullable<AbstractMesh>;
  32515. /**
  32516. * Returns the effective mesh of the submesh
  32517. * @returns the effective mesh (could be different from parent mesh)
  32518. */
  32519. getEffectiveMesh(): AbstractMesh;
  32520. /**
  32521. * Returns the submesh material
  32522. * @returns null or the current material
  32523. */
  32524. getMaterial(): Nullable<Material>;
  32525. private _IsMultiMaterial;
  32526. /**
  32527. * Sets a new updated BoundingInfo object to the submesh
  32528. * @param data defines an optional position array to use to determine the bounding info
  32529. * @returns the SubMesh
  32530. */
  32531. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  32532. /** @hidden */
  32533. _checkCollision(collider: Collider): boolean;
  32534. /**
  32535. * Updates the submesh BoundingInfo
  32536. * @param world defines the world matrix to use to update the bounding info
  32537. * @returns the submesh
  32538. */
  32539. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  32540. /**
  32541. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  32542. * @param frustumPlanes defines the frustum planes
  32543. * @returns true if the submesh is intersecting with the frustum
  32544. */
  32545. isInFrustum(frustumPlanes: Plane[]): boolean;
  32546. /**
  32547. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  32548. * @param frustumPlanes defines the frustum planes
  32549. * @returns true if the submesh is inside the frustum
  32550. */
  32551. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32552. /**
  32553. * Renders the submesh
  32554. * @param enableAlphaMode defines if alpha needs to be used
  32555. * @returns the submesh
  32556. */
  32557. render(enableAlphaMode: boolean): SubMesh;
  32558. /**
  32559. * @hidden
  32560. */
  32561. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  32562. /**
  32563. * Checks if the submesh intersects with a ray
  32564. * @param ray defines the ray to test
  32565. * @returns true is the passed ray intersects the submesh bounding box
  32566. */
  32567. canIntersects(ray: Ray): boolean;
  32568. /**
  32569. * Intersects current submesh with a ray
  32570. * @param ray defines the ray to test
  32571. * @param positions defines mesh's positions array
  32572. * @param indices defines mesh's indices array
  32573. * @param fastCheck defines if the first intersection will be used (and not the closest)
  32574. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32575. * @returns intersection info or null if no intersection
  32576. */
  32577. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  32578. /** @hidden */
  32579. private _intersectLines;
  32580. /** @hidden */
  32581. private _intersectUnIndexedLines;
  32582. /** @hidden */
  32583. private _intersectTriangles;
  32584. /** @hidden */
  32585. private _intersectUnIndexedTriangles;
  32586. /** @hidden */
  32587. _rebuild(): void;
  32588. /**
  32589. * Creates a new submesh from the passed mesh
  32590. * @param newMesh defines the new hosting mesh
  32591. * @param newRenderingMesh defines an optional rendering mesh
  32592. * @returns the new submesh
  32593. */
  32594. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  32595. /**
  32596. * Release associated resources
  32597. */
  32598. dispose(): void;
  32599. /**
  32600. * Gets the class name
  32601. * @returns the string "SubMesh".
  32602. */
  32603. getClassName(): string;
  32604. /**
  32605. * Creates a new submesh from indices data
  32606. * @param materialIndex the index of the main mesh material
  32607. * @param startIndex the index where to start the copy in the mesh indices array
  32608. * @param indexCount the number of indices to copy then from the startIndex
  32609. * @param mesh the main mesh to create the submesh from
  32610. * @param renderingMesh the optional rendering mesh
  32611. * @returns a new submesh
  32612. */
  32613. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  32614. }
  32615. }
  32616. declare module "babylonjs/Loading/sceneLoaderFlags" {
  32617. /**
  32618. * Class used to represent data loading progression
  32619. */
  32620. export class SceneLoaderFlags {
  32621. private static _ForceFullSceneLoadingForIncremental;
  32622. private static _ShowLoadingScreen;
  32623. private static _CleanBoneMatrixWeights;
  32624. private static _loggingLevel;
  32625. /**
  32626. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  32627. */
  32628. static get ForceFullSceneLoadingForIncremental(): boolean;
  32629. static set ForceFullSceneLoadingForIncremental(value: boolean);
  32630. /**
  32631. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  32632. */
  32633. static get ShowLoadingScreen(): boolean;
  32634. static set ShowLoadingScreen(value: boolean);
  32635. /**
  32636. * Defines the current logging level (while loading the scene)
  32637. * @ignorenaming
  32638. */
  32639. static get loggingLevel(): number;
  32640. static set loggingLevel(value: number);
  32641. /**
  32642. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  32643. */
  32644. static get CleanBoneMatrixWeights(): boolean;
  32645. static set CleanBoneMatrixWeights(value: boolean);
  32646. }
  32647. }
  32648. declare module "babylonjs/Meshes/geometry" {
  32649. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  32650. import { Scene } from "babylonjs/scene";
  32651. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32652. import { Engine } from "babylonjs/Engines/engine";
  32653. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  32654. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32655. import { Effect } from "babylonjs/Materials/effect";
  32656. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32657. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32658. import { Mesh } from "babylonjs/Meshes/mesh";
  32659. /**
  32660. * Class used to store geometry data (vertex buffers + index buffer)
  32661. */
  32662. export class Geometry implements IGetSetVerticesData {
  32663. /**
  32664. * Gets or sets the ID of the geometry
  32665. */
  32666. id: string;
  32667. /**
  32668. * Gets or sets the unique ID of the geometry
  32669. */
  32670. uniqueId: number;
  32671. /**
  32672. * Gets the delay loading state of the geometry (none by default which means not delayed)
  32673. */
  32674. delayLoadState: number;
  32675. /**
  32676. * Gets the file containing the data to load when running in delay load state
  32677. */
  32678. delayLoadingFile: Nullable<string>;
  32679. /**
  32680. * Callback called when the geometry is updated
  32681. */
  32682. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  32683. private _scene;
  32684. private _engine;
  32685. private _meshes;
  32686. private _totalVertices;
  32687. /** @hidden */
  32688. _indices: IndicesArray;
  32689. /** @hidden */
  32690. _vertexBuffers: {
  32691. [key: string]: VertexBuffer;
  32692. };
  32693. private _isDisposed;
  32694. private _extend;
  32695. private _boundingBias;
  32696. /** @hidden */
  32697. _delayInfo: Array<string>;
  32698. private _indexBuffer;
  32699. private _indexBufferIsUpdatable;
  32700. /** @hidden */
  32701. _boundingInfo: Nullable<BoundingInfo>;
  32702. /** @hidden */
  32703. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  32704. /** @hidden */
  32705. _softwareSkinningFrameId: number;
  32706. private _vertexArrayObjects;
  32707. private _updatable;
  32708. /** @hidden */
  32709. _positions: Nullable<Vector3[]>;
  32710. private _positionsCache;
  32711. /**
  32712. * 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
  32713. */
  32714. get boundingBias(): Vector2;
  32715. /**
  32716. * 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
  32717. */
  32718. set boundingBias(value: Vector2);
  32719. /**
  32720. * Static function used to attach a new empty geometry to a mesh
  32721. * @param mesh defines the mesh to attach the geometry to
  32722. * @returns the new Geometry
  32723. */
  32724. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  32725. /** Get the list of meshes using this geometry */
  32726. get meshes(): Mesh[];
  32727. /**
  32728. * If set to true (false by default), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  32729. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  32730. */
  32731. useBoundingInfoFromGeometry: boolean;
  32732. /**
  32733. * Creates a new geometry
  32734. * @param id defines the unique ID
  32735. * @param scene defines the hosting scene
  32736. * @param vertexData defines the VertexData used to get geometry data
  32737. * @param updatable defines if geometry must be updatable (false by default)
  32738. * @param mesh defines the mesh that will be associated with the geometry
  32739. */
  32740. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  32741. /**
  32742. * Gets the current extend of the geometry
  32743. */
  32744. get extend(): {
  32745. minimum: Vector3;
  32746. maximum: Vector3;
  32747. };
  32748. /**
  32749. * Gets the hosting scene
  32750. * @returns the hosting Scene
  32751. */
  32752. getScene(): Scene;
  32753. /**
  32754. * Gets the hosting engine
  32755. * @returns the hosting Engine
  32756. */
  32757. getEngine(): Engine;
  32758. /**
  32759. * Defines if the geometry is ready to use
  32760. * @returns true if the geometry is ready to be used
  32761. */
  32762. isReady(): boolean;
  32763. /**
  32764. * Gets a value indicating that the geometry should not be serialized
  32765. */
  32766. get doNotSerialize(): boolean;
  32767. /** @hidden */
  32768. _rebuild(): void;
  32769. /**
  32770. * Affects all geometry data in one call
  32771. * @param vertexData defines the geometry data
  32772. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  32773. */
  32774. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  32775. /**
  32776. * Set specific vertex data
  32777. * @param kind defines the data kind (Position, normal, etc...)
  32778. * @param data defines the vertex data to use
  32779. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  32780. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  32781. */
  32782. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  32783. /**
  32784. * Removes a specific vertex data
  32785. * @param kind defines the data kind (Position, normal, etc...)
  32786. */
  32787. removeVerticesData(kind: string): void;
  32788. /**
  32789. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  32790. * @param buffer defines the vertex buffer to use
  32791. * @param totalVertices defines the total number of vertices for position kind (could be null)
  32792. */
  32793. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  32794. /**
  32795. * Update a specific vertex buffer
  32796. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  32797. * It will do nothing if the buffer is not updatable
  32798. * @param kind defines the data kind (Position, normal, etc...)
  32799. * @param data defines the data to use
  32800. * @param offset defines the offset in the target buffer where to store the data
  32801. * @param useBytes set to true if the offset is in bytes
  32802. */
  32803. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  32804. /**
  32805. * Update a specific vertex buffer
  32806. * This function will create a new buffer if the current one is not updatable
  32807. * @param kind defines the data kind (Position, normal, etc...)
  32808. * @param data defines the data to use
  32809. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  32810. */
  32811. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  32812. private _updateBoundingInfo;
  32813. /** @hidden */
  32814. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  32815. [kind: string]: Nullable<VertexBuffer>;
  32816. }, overrideVertexArrayObjects?: {
  32817. [key: string]: WebGLVertexArrayObject;
  32818. }): void;
  32819. /**
  32820. * Gets total number of vertices
  32821. * @returns the total number of vertices
  32822. */
  32823. getTotalVertices(): number;
  32824. /**
  32825. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  32826. * @param kind defines the data kind (Position, normal, etc...)
  32827. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32828. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32829. * @returns a float array containing vertex data
  32830. */
  32831. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32832. /**
  32833. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  32834. * @param kind defines the data kind (Position, normal, etc...)
  32835. * @returns true if the vertex buffer with the specified kind is updatable
  32836. */
  32837. isVertexBufferUpdatable(kind: string): boolean;
  32838. /**
  32839. * Gets a specific vertex buffer
  32840. * @param kind defines the data kind (Position, normal, etc...)
  32841. * @returns a VertexBuffer
  32842. */
  32843. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32844. /**
  32845. * Returns all vertex buffers
  32846. * @return an object holding all vertex buffers indexed by kind
  32847. */
  32848. getVertexBuffers(): Nullable<{
  32849. [key: string]: VertexBuffer;
  32850. }>;
  32851. /**
  32852. * Gets a boolean indicating if specific vertex buffer is present
  32853. * @param kind defines the data kind (Position, normal, etc...)
  32854. * @returns true if data is present
  32855. */
  32856. isVerticesDataPresent(kind: string): boolean;
  32857. /**
  32858. * Gets a list of all attached data kinds (Position, normal, etc...)
  32859. * @returns a list of string containing all kinds
  32860. */
  32861. getVerticesDataKinds(): string[];
  32862. /**
  32863. * Update index buffer
  32864. * @param indices defines the indices to store in the index buffer
  32865. * @param offset defines the offset in the target buffer where to store the data
  32866. * @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)
  32867. */
  32868. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  32869. /**
  32870. * Creates a new index buffer
  32871. * @param indices defines the indices to store in the index buffer
  32872. * @param totalVertices defines the total number of vertices (could be null)
  32873. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  32874. */
  32875. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  32876. /**
  32877. * Return the total number of indices
  32878. * @returns the total number of indices
  32879. */
  32880. getTotalIndices(): number;
  32881. /**
  32882. * Gets the index buffer array
  32883. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32885. * @returns the index buffer array
  32886. */
  32887. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32888. /**
  32889. * Gets the index buffer
  32890. * @return the index buffer
  32891. */
  32892. getIndexBuffer(): Nullable<DataBuffer>;
  32893. /** @hidden */
  32894. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  32895. /**
  32896. * Release the associated resources for a specific mesh
  32897. * @param mesh defines the source mesh
  32898. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  32899. */
  32900. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  32901. /**
  32902. * Apply current geometry to a given mesh
  32903. * @param mesh defines the mesh to apply geometry to
  32904. */
  32905. applyToMesh(mesh: Mesh): void;
  32906. private _updateExtend;
  32907. private _applyToMesh;
  32908. private notifyUpdate;
  32909. /**
  32910. * Load the geometry if it was flagged as delay loaded
  32911. * @param scene defines the hosting scene
  32912. * @param onLoaded defines a callback called when the geometry is loaded
  32913. */
  32914. load(scene: Scene, onLoaded?: () => void): void;
  32915. private _queueLoad;
  32916. /**
  32917. * Invert the geometry to move from a right handed system to a left handed one.
  32918. */
  32919. toLeftHanded(): void;
  32920. /** @hidden */
  32921. _resetPointsArrayCache(): void;
  32922. /** @hidden */
  32923. _generatePointsArray(): boolean;
  32924. /**
  32925. * Gets a value indicating if the geometry is disposed
  32926. * @returns true if the geometry was disposed
  32927. */
  32928. isDisposed(): boolean;
  32929. private _disposeVertexArrayObjects;
  32930. /**
  32931. * Free all associated resources
  32932. */
  32933. dispose(): void;
  32934. /**
  32935. * Clone the current geometry into a new geometry
  32936. * @param id defines the unique ID of the new geometry
  32937. * @returns a new geometry object
  32938. */
  32939. copy(id: string): Geometry;
  32940. /**
  32941. * Serialize the current geometry info (and not the vertices data) into a JSON object
  32942. * @return a JSON representation of the current geometry data (without the vertices data)
  32943. */
  32944. serialize(): any;
  32945. private toNumberArray;
  32946. /**
  32947. * Serialize all vertices data into a JSON object
  32948. * @returns a JSON representation of the current geometry data
  32949. */
  32950. serializeVerticeData(): any;
  32951. /**
  32952. * Extracts a clone of a mesh geometry
  32953. * @param mesh defines the source mesh
  32954. * @param id defines the unique ID of the new geometry object
  32955. * @returns the new geometry object
  32956. */
  32957. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  32958. /**
  32959. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  32960. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32961. * Be aware Math.random() could cause collisions, but:
  32962. * "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"
  32963. * @returns a string containing a new GUID
  32964. */
  32965. static RandomId(): string;
  32966. /** @hidden */
  32967. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  32968. private static _CleanMatricesWeights;
  32969. /**
  32970. * Create a new geometry from persisted data (Using .babylon file format)
  32971. * @param parsedVertexData defines the persisted data
  32972. * @param scene defines the hosting scene
  32973. * @param rootUrl defines the root url to use to load assets (like delayed data)
  32974. * @returns the new geometry object
  32975. */
  32976. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  32977. }
  32978. }
  32979. declare module "babylonjs/Morph/morphTarget" {
  32980. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32981. import { Observable } from "babylonjs/Misc/observable";
  32982. import { Nullable, FloatArray } from "babylonjs/types";
  32983. import { Scene } from "babylonjs/scene";
  32984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32985. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32986. /**
  32987. * Defines a target to use with MorphTargetManager
  32988. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32989. */
  32990. export class MorphTarget implements IAnimatable {
  32991. /** defines the name of the target */
  32992. name: string;
  32993. /**
  32994. * Gets or sets the list of animations
  32995. */
  32996. animations: import("babylonjs/Animations/animation").Animation[];
  32997. private _scene;
  32998. private _positions;
  32999. private _normals;
  33000. private _tangents;
  33001. private _uvs;
  33002. private _influence;
  33003. private _uniqueId;
  33004. /**
  33005. * Observable raised when the influence changes
  33006. */
  33007. onInfluenceChanged: Observable<boolean>;
  33008. /** @hidden */
  33009. _onDataLayoutChanged: Observable<void>;
  33010. /**
  33011. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  33012. */
  33013. get influence(): number;
  33014. set influence(influence: number);
  33015. /**
  33016. * Gets or sets the id of the morph Target
  33017. */
  33018. id: string;
  33019. private _animationPropertiesOverride;
  33020. /**
  33021. * Gets or sets the animation properties override
  33022. */
  33023. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33024. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33025. /**
  33026. * Creates a new MorphTarget
  33027. * @param name defines the name of the target
  33028. * @param influence defines the influence to use
  33029. * @param scene defines the scene the morphtarget belongs to
  33030. */
  33031. constructor(
  33032. /** defines the name of the target */
  33033. name: string, influence?: number, scene?: Nullable<Scene>);
  33034. /**
  33035. * Gets the unique ID of this manager
  33036. */
  33037. get uniqueId(): number;
  33038. /**
  33039. * Gets a boolean defining if the target contains position data
  33040. */
  33041. get hasPositions(): boolean;
  33042. /**
  33043. * Gets a boolean defining if the target contains normal data
  33044. */
  33045. get hasNormals(): boolean;
  33046. /**
  33047. * Gets a boolean defining if the target contains tangent data
  33048. */
  33049. get hasTangents(): boolean;
  33050. /**
  33051. * Gets a boolean defining if the target contains texture coordinates data
  33052. */
  33053. get hasUVs(): boolean;
  33054. /**
  33055. * Affects position data to this target
  33056. * @param data defines the position data to use
  33057. */
  33058. setPositions(data: Nullable<FloatArray>): void;
  33059. /**
  33060. * Gets the position data stored in this target
  33061. * @returns a FloatArray containing the position data (or null if not present)
  33062. */
  33063. getPositions(): Nullable<FloatArray>;
  33064. /**
  33065. * Affects normal data to this target
  33066. * @param data defines the normal data to use
  33067. */
  33068. setNormals(data: Nullable<FloatArray>): void;
  33069. /**
  33070. * Gets the normal data stored in this target
  33071. * @returns a FloatArray containing the normal data (or null if not present)
  33072. */
  33073. getNormals(): Nullable<FloatArray>;
  33074. /**
  33075. * Affects tangent data to this target
  33076. * @param data defines the tangent data to use
  33077. */
  33078. setTangents(data: Nullable<FloatArray>): void;
  33079. /**
  33080. * Gets the tangent data stored in this target
  33081. * @returns a FloatArray containing the tangent data (or null if not present)
  33082. */
  33083. getTangents(): Nullable<FloatArray>;
  33084. /**
  33085. * Affects texture coordinates data to this target
  33086. * @param data defines the texture coordinates data to use
  33087. */
  33088. setUVs(data: Nullable<FloatArray>): void;
  33089. /**
  33090. * Gets the texture coordinates data stored in this target
  33091. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  33092. */
  33093. getUVs(): Nullable<FloatArray>;
  33094. /**
  33095. * Clone the current target
  33096. * @returns a new MorphTarget
  33097. */
  33098. clone(): MorphTarget;
  33099. /**
  33100. * Serializes the current target into a Serialization object
  33101. * @returns the serialized object
  33102. */
  33103. serialize(): any;
  33104. /**
  33105. * Returns the string "MorphTarget"
  33106. * @returns "MorphTarget"
  33107. */
  33108. getClassName(): string;
  33109. /**
  33110. * Creates a new target from serialized data
  33111. * @param serializationObject defines the serialized data to use
  33112. * @returns a new MorphTarget
  33113. */
  33114. static Parse(serializationObject: any): MorphTarget;
  33115. /**
  33116. * Creates a MorphTarget from mesh data
  33117. * @param mesh defines the source mesh
  33118. * @param name defines the name to use for the new target
  33119. * @param influence defines the influence to attach to the target
  33120. * @returns a new MorphTarget
  33121. */
  33122. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  33123. }
  33124. }
  33125. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  33126. import { Texture } from "babylonjs/Materials/Textures/texture";
  33127. import "babylonjs/Engines/Extensions/engine.rawTexture";
  33128. import { Scene } from "babylonjs/scene";
  33129. /**
  33130. * Class used to store 2D array textures containing user data
  33131. */
  33132. export class RawTexture2DArray extends Texture {
  33133. /** Gets or sets the texture format to use */
  33134. format: number;
  33135. private _depth;
  33136. /**
  33137. * Gets the number of layers of the texture
  33138. */
  33139. get depth(): number;
  33140. /**
  33141. * Create a new RawTexture2DArray
  33142. * @param data defines the data of the texture
  33143. * @param width defines the width of the texture
  33144. * @param height defines the height of the texture
  33145. * @param depth defines the number of layers of the texture
  33146. * @param format defines the texture format to use
  33147. * @param scene defines the hosting scene
  33148. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33149. * @param invertY defines if texture must be stored with Y axis inverted
  33150. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  33151. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  33152. */
  33153. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33154. /** Gets or sets the texture format to use */
  33155. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  33156. /**
  33157. * Update the texture with new data
  33158. * @param data defines the data to store in the texture
  33159. */
  33160. update(data: ArrayBufferView): void;
  33161. /**
  33162. * Creates a RGBA texture from some data.
  33163. * @param data Define the texture data
  33164. * @param width Define the width of the texture
  33165. * @param height Define the height of the texture
  33166. * @param depth defines the number of layers of the texture
  33167. * @param scene defines the scene the texture will belong to
  33168. * @param generateMipMaps Define whether or not to create mip maps for the texture
  33169. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  33170. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  33171. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  33172. * @returns the RGBA texture
  33173. */
  33174. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, depth: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture2DArray;
  33175. }
  33176. }
  33177. declare module "babylonjs/Morph/morphTargetManager" {
  33178. import { Nullable } from "babylonjs/types";
  33179. import { IDisposable, Scene } from "babylonjs/scene";
  33180. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33181. import { Effect } from "babylonjs/Materials/effect";
  33182. import { RawTexture2DArray } from "babylonjs/Materials/Textures/rawTexture2DArray";
  33183. /**
  33184. * This class is used to deform meshes using morphing between different targets
  33185. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33186. */
  33187. export class MorphTargetManager implements IDisposable {
  33188. private _targets;
  33189. private _targetInfluenceChangedObservers;
  33190. private _targetDataLayoutChangedObservers;
  33191. private _activeTargets;
  33192. private _scene;
  33193. private _influences;
  33194. private _supportsNormals;
  33195. private _supportsTangents;
  33196. private _supportsUVs;
  33197. private _vertexCount;
  33198. private _textureVertexStride;
  33199. private _textureWidth;
  33200. private _textureHeight;
  33201. private _uniqueId;
  33202. private _tempInfluences;
  33203. private _canUseTextureForTargets;
  33204. /** @hidden */
  33205. _targetStoreTexture: Nullable<RawTexture2DArray>;
  33206. /**
  33207. * Gets or sets a boolean indicating if normals must be morphed
  33208. */
  33209. enableNormalMorphing: boolean;
  33210. /**
  33211. * Gets or sets a boolean indicating if tangents must be morphed
  33212. */
  33213. enableTangentMorphing: boolean;
  33214. /**
  33215. * Gets or sets a boolean indicating if UV must be morphed
  33216. */
  33217. enableUVMorphing: boolean;
  33218. /**
  33219. * Creates a new MorphTargetManager
  33220. * @param scene defines the current scene
  33221. */
  33222. constructor(scene?: Nullable<Scene>);
  33223. /**
  33224. * Gets the unique ID of this manager
  33225. */
  33226. get uniqueId(): number;
  33227. /**
  33228. * Gets the number of vertices handled by this manager
  33229. */
  33230. get vertexCount(): number;
  33231. /**
  33232. * Gets a boolean indicating if this manager supports morphing of normals
  33233. */
  33234. get supportsNormals(): boolean;
  33235. /**
  33236. * Gets a boolean indicating if this manager supports morphing of tangents
  33237. */
  33238. get supportsTangents(): boolean;
  33239. /**
  33240. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  33241. */
  33242. get supportsUVs(): boolean;
  33243. /**
  33244. * Gets the number of targets stored in this manager
  33245. */
  33246. get numTargets(): number;
  33247. /**
  33248. * Gets the number of influencers (ie. the number of targets with influences > 0)
  33249. */
  33250. get numInfluencers(): number;
  33251. /**
  33252. * Gets the list of influences (one per target)
  33253. */
  33254. get influences(): Float32Array;
  33255. private _useTextureToStoreTargets;
  33256. /**
  33257. * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).
  33258. * Please note that this option is not available if the hardware does not support it
  33259. */
  33260. get useTextureToStoreTargets(): boolean;
  33261. set useTextureToStoreTargets(value: boolean);
  33262. /**
  33263. * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
  33264. */
  33265. get isUsingTextureForTargets(): boolean;
  33266. /**
  33267. * Gets the active target at specified index. An active target is a target with an influence > 0
  33268. * @param index defines the index to check
  33269. * @returns the requested target
  33270. */
  33271. getActiveTarget(index: number): MorphTarget;
  33272. /**
  33273. * Gets the target at specified index
  33274. * @param index defines the index to check
  33275. * @returns the requested target
  33276. */
  33277. getTarget(index: number): MorphTarget;
  33278. /**
  33279. * Add a new target to this manager
  33280. * @param target defines the target to add
  33281. */
  33282. addTarget(target: MorphTarget): void;
  33283. /**
  33284. * Removes a target from the manager
  33285. * @param target defines the target to remove
  33286. */
  33287. removeTarget(target: MorphTarget): void;
  33288. /** @hidden */
  33289. _bind(effect: Effect): void;
  33290. /**
  33291. * Clone the current manager
  33292. * @returns a new MorphTargetManager
  33293. */
  33294. clone(): MorphTargetManager;
  33295. /**
  33296. * Serializes the current manager into a Serialization object
  33297. * @returns the serialized object
  33298. */
  33299. serialize(): any;
  33300. private _syncActiveTargets;
  33301. /**
  33302. * Synchronize the targets with all the meshes using this morph target manager
  33303. */
  33304. synchronize(): void;
  33305. /**
  33306. * Release all resources
  33307. */
  33308. dispose(): void;
  33309. /**
  33310. * Creates a new MorphTargetManager from serialized data
  33311. * @param serializationObject defines the serialized data
  33312. * @param scene defines the hosting scene
  33313. * @returns the new MorphTargetManager
  33314. */
  33315. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  33316. }
  33317. }
  33318. declare module "babylonjs/Meshes/meshLODLevel" {
  33319. import { Mesh } from "babylonjs/Meshes/mesh";
  33320. import { Nullable } from "babylonjs/types";
  33321. /**
  33322. * Class used to represent a specific level of detail of a mesh
  33323. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33324. */
  33325. export class MeshLODLevel {
  33326. /** Defines the distance where this level should start being displayed */
  33327. distance: number;
  33328. /** Defines the mesh to use to render this level */
  33329. mesh: Nullable<Mesh>;
  33330. /**
  33331. * Creates a new LOD level
  33332. * @param distance defines the distance where this level should star being displayed
  33333. * @param mesh defines the mesh to use to render this level
  33334. */
  33335. constructor(
  33336. /** Defines the distance where this level should start being displayed */
  33337. distance: number,
  33338. /** Defines the mesh to use to render this level */
  33339. mesh: Nullable<Mesh>);
  33340. }
  33341. }
  33342. declare module "babylonjs/Misc/canvasGenerator" {
  33343. /**
  33344. * Helper class used to generate a canvas to manipulate images
  33345. */
  33346. export class CanvasGenerator {
  33347. /**
  33348. * Create a new canvas (or offscreen canvas depending on the context)
  33349. * @param width defines the expected width
  33350. * @param height defines the expected height
  33351. * @return a new canvas or offscreen canvas
  33352. */
  33353. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  33354. }
  33355. }
  33356. declare module "babylonjs/Meshes/groundMesh" {
  33357. import { Scene } from "babylonjs/scene";
  33358. import { Vector3 } from "babylonjs/Maths/math.vector";
  33359. import { Mesh } from "babylonjs/Meshes/mesh";
  33360. /**
  33361. * Mesh representing the ground
  33362. */
  33363. export class GroundMesh extends Mesh {
  33364. /** If octree should be generated */
  33365. generateOctree: boolean;
  33366. private _heightQuads;
  33367. /** @hidden */
  33368. _subdivisionsX: number;
  33369. /** @hidden */
  33370. _subdivisionsY: number;
  33371. /** @hidden */
  33372. _width: number;
  33373. /** @hidden */
  33374. _height: number;
  33375. /** @hidden */
  33376. _minX: number;
  33377. /** @hidden */
  33378. _maxX: number;
  33379. /** @hidden */
  33380. _minZ: number;
  33381. /** @hidden */
  33382. _maxZ: number;
  33383. constructor(name: string, scene: Scene);
  33384. /**
  33385. * "GroundMesh"
  33386. * @returns "GroundMesh"
  33387. */
  33388. getClassName(): string;
  33389. /**
  33390. * The minimum of x and y subdivisions
  33391. */
  33392. get subdivisions(): number;
  33393. /**
  33394. * X subdivisions
  33395. */
  33396. get subdivisionsX(): number;
  33397. /**
  33398. * Y subdivisions
  33399. */
  33400. get subdivisionsY(): number;
  33401. /**
  33402. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  33403. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  33404. * @param chunksCount the number of subdivisions for x and y
  33405. * @param octreeBlocksSize (Default: 32)
  33406. */
  33407. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  33408. /**
  33409. * Returns a height (y) value in the World system :
  33410. * the ground altitude at the coordinates (x, z) expressed in the World system.
  33411. * @param x x coordinate
  33412. * @param z z coordinate
  33413. * @returns the ground y position if (x, z) are outside the ground surface.
  33414. */
  33415. getHeightAtCoordinates(x: number, z: number): number;
  33416. /**
  33417. * Returns a normalized vector (Vector3) orthogonal to the ground
  33418. * at the ground coordinates (x, z) expressed in the World system.
  33419. * @param x x coordinate
  33420. * @param z z coordinate
  33421. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  33422. */
  33423. getNormalAtCoordinates(x: number, z: number): Vector3;
  33424. /**
  33425. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  33426. * at the ground coordinates (x, z) expressed in the World system.
  33427. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  33428. * @param x x coordinate
  33429. * @param z z coordinate
  33430. * @param ref vector to store the result
  33431. * @returns the GroundMesh.
  33432. */
  33433. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  33434. /**
  33435. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  33436. * if the ground has been updated.
  33437. * This can be used in the render loop.
  33438. * @returns the GroundMesh.
  33439. */
  33440. updateCoordinateHeights(): GroundMesh;
  33441. private _getFacetAt;
  33442. private _initHeightQuads;
  33443. private _computeHeightQuads;
  33444. /**
  33445. * Serializes this ground mesh
  33446. * @param serializationObject object to write serialization to
  33447. */
  33448. serialize(serializationObject: any): void;
  33449. /**
  33450. * Parses a serialized ground mesh
  33451. * @param parsedMesh the serialized mesh
  33452. * @param scene the scene to create the ground mesh in
  33453. * @returns the created ground mesh
  33454. */
  33455. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  33456. }
  33457. }
  33458. declare module "babylonjs/Physics/physicsJoint" {
  33459. import { Vector3 } from "babylonjs/Maths/math.vector";
  33460. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  33461. /**
  33462. * Interface for Physics-Joint data
  33463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33464. */
  33465. export interface PhysicsJointData {
  33466. /**
  33467. * The main pivot of the joint
  33468. */
  33469. mainPivot?: Vector3;
  33470. /**
  33471. * The connected pivot of the joint
  33472. */
  33473. connectedPivot?: Vector3;
  33474. /**
  33475. * The main axis of the joint
  33476. */
  33477. mainAxis?: Vector3;
  33478. /**
  33479. * The connected axis of the joint
  33480. */
  33481. connectedAxis?: Vector3;
  33482. /**
  33483. * The collision of the joint
  33484. */
  33485. collision?: boolean;
  33486. /**
  33487. * Native Oimo/Cannon/Energy data
  33488. */
  33489. nativeParams?: any;
  33490. }
  33491. /**
  33492. * This is a holder class for the physics joint created by the physics plugin
  33493. * It holds a set of functions to control the underlying joint
  33494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33495. */
  33496. export class PhysicsJoint {
  33497. /**
  33498. * The type of the physics joint
  33499. */
  33500. type: number;
  33501. /**
  33502. * The data for the physics joint
  33503. */
  33504. jointData: PhysicsJointData;
  33505. private _physicsJoint;
  33506. protected _physicsPlugin: IPhysicsEnginePlugin;
  33507. /**
  33508. * Initializes the physics joint
  33509. * @param type The type of the physics joint
  33510. * @param jointData The data for the physics joint
  33511. */
  33512. constructor(
  33513. /**
  33514. * The type of the physics joint
  33515. */
  33516. type: number,
  33517. /**
  33518. * The data for the physics joint
  33519. */
  33520. jointData: PhysicsJointData);
  33521. /**
  33522. * Gets the physics joint
  33523. */
  33524. get physicsJoint(): any;
  33525. /**
  33526. * Sets the physics joint
  33527. */
  33528. set physicsJoint(newJoint: any);
  33529. /**
  33530. * Sets the physics plugin
  33531. */
  33532. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  33533. /**
  33534. * Execute a function that is physics-plugin specific.
  33535. * @param {Function} func the function that will be executed.
  33536. * It accepts two parameters: the physics world and the physics joint
  33537. */
  33538. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33539. /**
  33540. * Distance-Joint type
  33541. */
  33542. static DistanceJoint: number;
  33543. /**
  33544. * Hinge-Joint type
  33545. */
  33546. static HingeJoint: number;
  33547. /**
  33548. * Ball-and-Socket joint type
  33549. */
  33550. static BallAndSocketJoint: number;
  33551. /**
  33552. * Wheel-Joint type
  33553. */
  33554. static WheelJoint: number;
  33555. /**
  33556. * Slider-Joint type
  33557. */
  33558. static SliderJoint: number;
  33559. /**
  33560. * Prismatic-Joint type
  33561. */
  33562. static PrismaticJoint: number;
  33563. /**
  33564. * Universal-Joint type
  33565. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33566. */
  33567. static UniversalJoint: number;
  33568. /**
  33569. * Hinge-Joint 2 type
  33570. */
  33571. static Hinge2Joint: number;
  33572. /**
  33573. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33574. */
  33575. static PointToPointJoint: number;
  33576. /**
  33577. * Spring-Joint type
  33578. */
  33579. static SpringJoint: number;
  33580. /**
  33581. * Lock-Joint type
  33582. */
  33583. static LockJoint: number;
  33584. }
  33585. /**
  33586. * A class representing a physics distance joint
  33587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33588. */
  33589. export class DistanceJoint extends PhysicsJoint {
  33590. /**
  33591. *
  33592. * @param jointData The data for the Distance-Joint
  33593. */
  33594. constructor(jointData: DistanceJointData);
  33595. /**
  33596. * Update the predefined distance.
  33597. * @param maxDistance The maximum preferred distance
  33598. * @param minDistance The minimum preferred distance
  33599. */
  33600. updateDistance(maxDistance: number, minDistance?: number): void;
  33601. }
  33602. /**
  33603. * Represents a Motor-Enabled Joint
  33604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33605. */
  33606. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33607. /**
  33608. * Initializes the Motor-Enabled Joint
  33609. * @param type The type of the joint
  33610. * @param jointData The physical joint data for the joint
  33611. */
  33612. constructor(type: number, jointData: PhysicsJointData);
  33613. /**
  33614. * Set the motor values.
  33615. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33616. * @param force the force to apply
  33617. * @param maxForce max force for this motor.
  33618. */
  33619. setMotor(force?: number, maxForce?: number): void;
  33620. /**
  33621. * Set the motor's limits.
  33622. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33623. * @param upperLimit The upper limit of the motor
  33624. * @param lowerLimit The lower limit of the motor
  33625. */
  33626. setLimit(upperLimit: number, lowerLimit?: number): void;
  33627. }
  33628. /**
  33629. * This class represents a single physics Hinge-Joint
  33630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33631. */
  33632. export class HingeJoint extends MotorEnabledJoint {
  33633. /**
  33634. * Initializes the Hinge-Joint
  33635. * @param jointData The joint data for the Hinge-Joint
  33636. */
  33637. constructor(jointData: PhysicsJointData);
  33638. /**
  33639. * Set the motor values.
  33640. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33641. * @param {number} force the force to apply
  33642. * @param {number} maxForce max force for this motor.
  33643. */
  33644. setMotor(force?: number, maxForce?: number): void;
  33645. /**
  33646. * Set the motor's limits.
  33647. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33648. * @param upperLimit The upper limit of the motor
  33649. * @param lowerLimit The lower limit of the motor
  33650. */
  33651. setLimit(upperLimit: number, lowerLimit?: number): void;
  33652. }
  33653. /**
  33654. * This class represents a dual hinge physics joint (same as wheel joint)
  33655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33656. */
  33657. export class Hinge2Joint extends MotorEnabledJoint {
  33658. /**
  33659. * Initializes the Hinge2-Joint
  33660. * @param jointData The joint data for the Hinge2-Joint
  33661. */
  33662. constructor(jointData: PhysicsJointData);
  33663. /**
  33664. * Set the motor values.
  33665. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33666. * @param {number} targetSpeed the speed the motor is to reach
  33667. * @param {number} maxForce max force for this motor.
  33668. * @param {motorIndex} the motor's index, 0 or 1.
  33669. */
  33670. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  33671. /**
  33672. * Set the motor limits.
  33673. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33674. * @param {number} upperLimit the upper limit
  33675. * @param {number} lowerLimit lower limit
  33676. * @param {motorIndex} the motor's index, 0 or 1.
  33677. */
  33678. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33679. }
  33680. /**
  33681. * Interface for a motor enabled joint
  33682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33683. */
  33684. export interface IMotorEnabledJoint {
  33685. /**
  33686. * Physics joint
  33687. */
  33688. physicsJoint: any;
  33689. /**
  33690. * Sets the motor of the motor-enabled joint
  33691. * @param force The force of the motor
  33692. * @param maxForce The maximum force of the motor
  33693. * @param motorIndex The index of the motor
  33694. */
  33695. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33696. /**
  33697. * Sets the limit of the motor
  33698. * @param upperLimit The upper limit of the motor
  33699. * @param lowerLimit The lower limit of the motor
  33700. * @param motorIndex The index of the motor
  33701. */
  33702. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33703. }
  33704. /**
  33705. * Joint data for a Distance-Joint
  33706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33707. */
  33708. export interface DistanceJointData extends PhysicsJointData {
  33709. /**
  33710. * Max distance the 2 joint objects can be apart
  33711. */
  33712. maxDistance: number;
  33713. }
  33714. /**
  33715. * Joint data from a spring joint
  33716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33717. */
  33718. export interface SpringJointData extends PhysicsJointData {
  33719. /**
  33720. * Length of the spring
  33721. */
  33722. length: number;
  33723. /**
  33724. * Stiffness of the spring
  33725. */
  33726. stiffness: number;
  33727. /**
  33728. * Damping of the spring
  33729. */
  33730. damping: number;
  33731. /** this callback will be called when applying the force to the impostors. */
  33732. forceApplicationCallback: () => void;
  33733. }
  33734. }
  33735. declare module "babylonjs/Physics/physicsRaycastResult" {
  33736. import { Vector3 } from "babylonjs/Maths/math.vector";
  33737. /**
  33738. * Holds the data for the raycast result
  33739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33740. */
  33741. export class PhysicsRaycastResult {
  33742. private _hasHit;
  33743. private _hitDistance;
  33744. private _hitNormalWorld;
  33745. private _hitPointWorld;
  33746. private _rayFromWorld;
  33747. private _rayToWorld;
  33748. /**
  33749. * Gets if there was a hit
  33750. */
  33751. get hasHit(): boolean;
  33752. /**
  33753. * Gets the distance from the hit
  33754. */
  33755. get hitDistance(): number;
  33756. /**
  33757. * Gets the hit normal/direction in the world
  33758. */
  33759. get hitNormalWorld(): Vector3;
  33760. /**
  33761. * Gets the hit point in the world
  33762. */
  33763. get hitPointWorld(): Vector3;
  33764. /**
  33765. * Gets the ray "start point" of the ray in the world
  33766. */
  33767. get rayFromWorld(): Vector3;
  33768. /**
  33769. * Gets the ray "end point" of the ray in the world
  33770. */
  33771. get rayToWorld(): Vector3;
  33772. /**
  33773. * Sets the hit data (normal & point in world space)
  33774. * @param hitNormalWorld defines the normal in world space
  33775. * @param hitPointWorld defines the point in world space
  33776. */
  33777. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33778. /**
  33779. * Sets the distance from the start point to the hit point
  33780. * @param distance
  33781. */
  33782. setHitDistance(distance: number): void;
  33783. /**
  33784. * Calculates the distance manually
  33785. */
  33786. calculateHitDistance(): void;
  33787. /**
  33788. * Resets all the values to default
  33789. * @param from The from point on world space
  33790. * @param to The to point on world space
  33791. */
  33792. reset(from?: Vector3, to?: Vector3): void;
  33793. }
  33794. /**
  33795. * Interface for the size containing width and height
  33796. */
  33797. interface IXYZ {
  33798. /**
  33799. * X
  33800. */
  33801. x: number;
  33802. /**
  33803. * Y
  33804. */
  33805. y: number;
  33806. /**
  33807. * Z
  33808. */
  33809. z: number;
  33810. }
  33811. }
  33812. declare module "babylonjs/Physics/IPhysicsEngine" {
  33813. import { Nullable } from "babylonjs/types";
  33814. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33816. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33817. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33818. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33819. /**
  33820. * Interface used to describe a physics joint
  33821. */
  33822. export interface PhysicsImpostorJoint {
  33823. /** Defines the main impostor to which the joint is linked */
  33824. mainImpostor: PhysicsImpostor;
  33825. /** Defines the impostor that is connected to the main impostor using this joint */
  33826. connectedImpostor: PhysicsImpostor;
  33827. /** Defines the joint itself */
  33828. joint: PhysicsJoint;
  33829. }
  33830. /** @hidden */
  33831. export interface IPhysicsEnginePlugin {
  33832. world: any;
  33833. name: string;
  33834. setGravity(gravity: Vector3): void;
  33835. setTimeStep(timeStep: number): void;
  33836. getTimeStep(): number;
  33837. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33838. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33839. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33840. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33841. removePhysicsBody(impostor: PhysicsImpostor): void;
  33842. generateJoint(joint: PhysicsImpostorJoint): void;
  33843. removeJoint(joint: PhysicsImpostorJoint): void;
  33844. isSupported(): boolean;
  33845. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33846. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33847. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33848. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33849. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33850. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33851. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33852. getBodyMass(impostor: PhysicsImpostor): number;
  33853. getBodyFriction(impostor: PhysicsImpostor): number;
  33854. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33855. getBodyRestitution(impostor: PhysicsImpostor): number;
  33856. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33857. getBodyPressure?(impostor: PhysicsImpostor): number;
  33858. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33859. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33860. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33861. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33862. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33863. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33864. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33865. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33866. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33867. sleepBody(impostor: PhysicsImpostor): void;
  33868. wakeUpBody(impostor: PhysicsImpostor): void;
  33869. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33870. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33871. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33872. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33873. getRadius(impostor: PhysicsImpostor): number;
  33874. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33875. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33876. dispose(): void;
  33877. }
  33878. /**
  33879. * Interface used to define a physics engine
  33880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33881. */
  33882. export interface IPhysicsEngine {
  33883. /**
  33884. * Gets the gravity vector used by the simulation
  33885. */
  33886. gravity: Vector3;
  33887. /**
  33888. * Sets the gravity vector used by the simulation
  33889. * @param gravity defines the gravity vector to use
  33890. */
  33891. setGravity(gravity: Vector3): void;
  33892. /**
  33893. * Set the time step of the physics engine.
  33894. * Default is 1/60.
  33895. * To slow it down, enter 1/600 for example.
  33896. * To speed it up, 1/30
  33897. * @param newTimeStep the new timestep to apply to this world.
  33898. */
  33899. setTimeStep(newTimeStep: number): void;
  33900. /**
  33901. * Get the time step of the physics engine.
  33902. * @returns the current time step
  33903. */
  33904. getTimeStep(): number;
  33905. /**
  33906. * Set the sub time step of the physics engine.
  33907. * Default is 0 meaning there is no sub steps
  33908. * To increase physics resolution precision, set a small value (like 1 ms)
  33909. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33910. */
  33911. setSubTimeStep(subTimeStep: number): void;
  33912. /**
  33913. * Get the sub time step of the physics engine.
  33914. * @returns the current sub time step
  33915. */
  33916. getSubTimeStep(): number;
  33917. /**
  33918. * Release all resources
  33919. */
  33920. dispose(): void;
  33921. /**
  33922. * Gets the name of the current physics plugin
  33923. * @returns the name of the plugin
  33924. */
  33925. getPhysicsPluginName(): string;
  33926. /**
  33927. * Adding a new impostor for the impostor tracking.
  33928. * This will be done by the impostor itself.
  33929. * @param impostor the impostor to add
  33930. */
  33931. addImpostor(impostor: PhysicsImpostor): void;
  33932. /**
  33933. * Remove an impostor from the engine.
  33934. * This impostor and its mesh will not longer be updated by the physics engine.
  33935. * @param impostor the impostor to remove
  33936. */
  33937. removeImpostor(impostor: PhysicsImpostor): void;
  33938. /**
  33939. * Add a joint to the physics engine
  33940. * @param mainImpostor defines the main impostor to which the joint is added.
  33941. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33942. * @param joint defines the joint that will connect both impostors.
  33943. */
  33944. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33945. /**
  33946. * Removes a joint from the simulation
  33947. * @param mainImpostor defines the impostor used with the joint
  33948. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33949. * @param joint defines the joint to remove
  33950. */
  33951. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33952. /**
  33953. * Gets the current plugin used to run the simulation
  33954. * @returns current plugin
  33955. */
  33956. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33957. /**
  33958. * Gets the list of physic impostors
  33959. * @returns an array of PhysicsImpostor
  33960. */
  33961. getImpostors(): Array<PhysicsImpostor>;
  33962. /**
  33963. * Gets the impostor for a physics enabled object
  33964. * @param object defines the object impersonated by the impostor
  33965. * @returns the PhysicsImpostor or null if not found
  33966. */
  33967. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33968. /**
  33969. * Gets the impostor for a physics body object
  33970. * @param body defines physics body used by the impostor
  33971. * @returns the PhysicsImpostor or null if not found
  33972. */
  33973. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33974. /**
  33975. * Does a raycast in the physics world
  33976. * @param from when should the ray start?
  33977. * @param to when should the ray end?
  33978. * @returns PhysicsRaycastResult
  33979. */
  33980. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33981. /**
  33982. * Called by the scene. No need to call it.
  33983. * @param delta defines the timespan between frames
  33984. */
  33985. _step(delta: number): void;
  33986. }
  33987. }
  33988. declare module "babylonjs/Physics/physicsImpostor" {
  33989. import { Nullable, IndicesArray } from "babylonjs/types";
  33990. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33991. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33993. import { Scene } from "babylonjs/scene";
  33994. import { Bone } from "babylonjs/Bones/bone";
  33995. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33996. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33997. import { Space } from "babylonjs/Maths/math.axis";
  33998. /**
  33999. * The interface for the physics imposter parameters
  34000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34001. */
  34002. export interface PhysicsImpostorParameters {
  34003. /**
  34004. * The mass of the physics imposter
  34005. */
  34006. mass: number;
  34007. /**
  34008. * The friction of the physics imposter
  34009. */
  34010. friction?: number;
  34011. /**
  34012. * The coefficient of restitution of the physics imposter
  34013. */
  34014. restitution?: number;
  34015. /**
  34016. * The native options of the physics imposter
  34017. */
  34018. nativeOptions?: any;
  34019. /**
  34020. * Specifies if the parent should be ignored
  34021. */
  34022. ignoreParent?: boolean;
  34023. /**
  34024. * Specifies if bi-directional transformations should be disabled
  34025. */
  34026. disableBidirectionalTransformation?: boolean;
  34027. /**
  34028. * The pressure inside the physics imposter, soft object only
  34029. */
  34030. pressure?: number;
  34031. /**
  34032. * The stiffness the physics imposter, soft object only
  34033. */
  34034. stiffness?: number;
  34035. /**
  34036. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  34037. */
  34038. velocityIterations?: number;
  34039. /**
  34040. * The number of iterations used in maintaining consistent vertex positions, soft object only
  34041. */
  34042. positionIterations?: number;
  34043. /**
  34044. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  34045. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  34046. * Add to fix multiple points
  34047. */
  34048. fixedPoints?: number;
  34049. /**
  34050. * The collision margin around a soft object
  34051. */
  34052. margin?: number;
  34053. /**
  34054. * The collision margin around a soft object
  34055. */
  34056. damping?: number;
  34057. /**
  34058. * The path for a rope based on an extrusion
  34059. */
  34060. path?: any;
  34061. /**
  34062. * The shape of an extrusion used for a rope based on an extrusion
  34063. */
  34064. shape?: any;
  34065. }
  34066. /**
  34067. * Interface for a physics-enabled object
  34068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34069. */
  34070. export interface IPhysicsEnabledObject {
  34071. /**
  34072. * The position of the physics-enabled object
  34073. */
  34074. position: Vector3;
  34075. /**
  34076. * The rotation of the physics-enabled object
  34077. */
  34078. rotationQuaternion: Nullable<Quaternion>;
  34079. /**
  34080. * The scale of the physics-enabled object
  34081. */
  34082. scaling: Vector3;
  34083. /**
  34084. * The rotation of the physics-enabled object
  34085. */
  34086. rotation?: Vector3;
  34087. /**
  34088. * The parent of the physics-enabled object
  34089. */
  34090. parent?: any;
  34091. /**
  34092. * The bounding info of the physics-enabled object
  34093. * @returns The bounding info of the physics-enabled object
  34094. */
  34095. getBoundingInfo(): BoundingInfo;
  34096. /**
  34097. * Computes the world matrix
  34098. * @param force Specifies if the world matrix should be computed by force
  34099. * @returns A world matrix
  34100. */
  34101. computeWorldMatrix(force: boolean): Matrix;
  34102. /**
  34103. * Gets the world matrix
  34104. * @returns A world matrix
  34105. */
  34106. getWorldMatrix?(): Matrix;
  34107. /**
  34108. * Gets the child meshes
  34109. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  34110. * @returns An array of abstract meshes
  34111. */
  34112. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  34113. /**
  34114. * Gets the vertex data
  34115. * @param kind The type of vertex data
  34116. * @returns A nullable array of numbers, or a float32 array
  34117. */
  34118. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  34119. /**
  34120. * Gets the indices from the mesh
  34121. * @returns A nullable array of index arrays
  34122. */
  34123. getIndices?(): Nullable<IndicesArray>;
  34124. /**
  34125. * Gets the scene from the mesh
  34126. * @returns the indices array or null
  34127. */
  34128. getScene?(): Scene;
  34129. /**
  34130. * Gets the absolute position from the mesh
  34131. * @returns the absolute position
  34132. */
  34133. getAbsolutePosition(): Vector3;
  34134. /**
  34135. * Gets the absolute pivot point from the mesh
  34136. * @returns the absolute pivot point
  34137. */
  34138. getAbsolutePivotPoint(): Vector3;
  34139. /**
  34140. * Rotates the mesh
  34141. * @param axis The axis of rotation
  34142. * @param amount The amount of rotation
  34143. * @param space The space of the rotation
  34144. * @returns The rotation transform node
  34145. */
  34146. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  34147. /**
  34148. * Translates the mesh
  34149. * @param axis The axis of translation
  34150. * @param distance The distance of translation
  34151. * @param space The space of the translation
  34152. * @returns The transform node
  34153. */
  34154. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  34155. /**
  34156. * Sets the absolute position of the mesh
  34157. * @param absolutePosition The absolute position of the mesh
  34158. * @returns The transform node
  34159. */
  34160. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  34161. /**
  34162. * Gets the class name of the mesh
  34163. * @returns The class name
  34164. */
  34165. getClassName(): string;
  34166. }
  34167. /**
  34168. * Represents a physics imposter
  34169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34170. */
  34171. export class PhysicsImpostor {
  34172. /**
  34173. * The physics-enabled object used as the physics imposter
  34174. */
  34175. object: IPhysicsEnabledObject;
  34176. /**
  34177. * The type of the physics imposter
  34178. */
  34179. type: number;
  34180. private _options;
  34181. private _scene?;
  34182. /**
  34183. * The default object size of the imposter
  34184. */
  34185. static DEFAULT_OBJECT_SIZE: Vector3;
  34186. /**
  34187. * The identity quaternion of the imposter
  34188. */
  34189. static IDENTITY_QUATERNION: Quaternion;
  34190. /** @hidden */
  34191. _pluginData: any;
  34192. private _physicsEngine;
  34193. private _physicsBody;
  34194. private _bodyUpdateRequired;
  34195. private _onBeforePhysicsStepCallbacks;
  34196. private _onAfterPhysicsStepCallbacks;
  34197. /** @hidden */
  34198. _onPhysicsCollideCallbacks: Array<{
  34199. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  34200. otherImpostors: Array<PhysicsImpostor>;
  34201. }>;
  34202. private _deltaPosition;
  34203. private _deltaRotation;
  34204. private _deltaRotationConjugated;
  34205. /** @hidden */
  34206. _isFromLine: boolean;
  34207. private _parent;
  34208. private _isDisposed;
  34209. private static _tmpVecs;
  34210. private static _tmpQuat;
  34211. /**
  34212. * Specifies if the physics imposter is disposed
  34213. */
  34214. get isDisposed(): boolean;
  34215. /**
  34216. * Gets the mass of the physics imposter
  34217. */
  34218. get mass(): number;
  34219. set mass(value: number);
  34220. /**
  34221. * Gets the coefficient of friction
  34222. */
  34223. get friction(): number;
  34224. /**
  34225. * Sets the coefficient of friction
  34226. */
  34227. set friction(value: number);
  34228. /**
  34229. * Gets the coefficient of restitution
  34230. */
  34231. get restitution(): number;
  34232. /**
  34233. * Sets the coefficient of restitution
  34234. */
  34235. set restitution(value: number);
  34236. /**
  34237. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  34238. */
  34239. get pressure(): number;
  34240. /**
  34241. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  34242. */
  34243. set pressure(value: number);
  34244. /**
  34245. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  34246. */
  34247. get stiffness(): number;
  34248. /**
  34249. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  34250. */
  34251. set stiffness(value: number);
  34252. /**
  34253. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  34254. */
  34255. get velocityIterations(): number;
  34256. /**
  34257. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  34258. */
  34259. set velocityIterations(value: number);
  34260. /**
  34261. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  34262. */
  34263. get positionIterations(): number;
  34264. /**
  34265. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  34266. */
  34267. set positionIterations(value: number);
  34268. /**
  34269. * The unique id of the physics imposter
  34270. * set by the physics engine when adding this impostor to the array
  34271. */
  34272. uniqueId: number;
  34273. /**
  34274. * @hidden
  34275. */
  34276. soft: boolean;
  34277. /**
  34278. * @hidden
  34279. */
  34280. segments: number;
  34281. private _joints;
  34282. /**
  34283. * Initializes the physics imposter
  34284. * @param object The physics-enabled object used as the physics imposter
  34285. * @param type The type of the physics imposter
  34286. * @param _options The options for the physics imposter
  34287. * @param _scene The Babylon scene
  34288. */
  34289. constructor(
  34290. /**
  34291. * The physics-enabled object used as the physics imposter
  34292. */
  34293. object: IPhysicsEnabledObject,
  34294. /**
  34295. * The type of the physics imposter
  34296. */
  34297. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  34298. /**
  34299. * This function will completely initialize this impostor.
  34300. * It will create a new body - but only if this mesh has no parent.
  34301. * If it has, this impostor will not be used other than to define the impostor
  34302. * of the child mesh.
  34303. * @hidden
  34304. */
  34305. _init(): void;
  34306. private _getPhysicsParent;
  34307. /**
  34308. * Should a new body be generated.
  34309. * @returns boolean specifying if body initialization is required
  34310. */
  34311. isBodyInitRequired(): boolean;
  34312. /**
  34313. * Sets the updated scaling
  34314. * @param updated Specifies if the scaling is updated
  34315. */
  34316. setScalingUpdated(): void;
  34317. /**
  34318. * Force a regeneration of this or the parent's impostor's body.
  34319. * Use under cautious - This will remove all joints already implemented.
  34320. */
  34321. forceUpdate(): void;
  34322. /**
  34323. * Gets the body that holds this impostor. Either its own, or its parent.
  34324. */
  34325. get physicsBody(): any;
  34326. /**
  34327. * Get the parent of the physics imposter
  34328. * @returns Physics imposter or null
  34329. */
  34330. get parent(): Nullable<PhysicsImpostor>;
  34331. /**
  34332. * Sets the parent of the physics imposter
  34333. */
  34334. set parent(value: Nullable<PhysicsImpostor>);
  34335. /**
  34336. * Set the physics body. Used mainly by the physics engine/plugin
  34337. */
  34338. set physicsBody(physicsBody: any);
  34339. /**
  34340. * Resets the update flags
  34341. */
  34342. resetUpdateFlags(): void;
  34343. /**
  34344. * Gets the object extend size
  34345. * @returns the object extend size
  34346. */
  34347. getObjectExtendSize(): Vector3;
  34348. /**
  34349. * Gets the object center
  34350. * @returns The object center
  34351. */
  34352. getObjectCenter(): Vector3;
  34353. /**
  34354. * Get a specific parameter from the options parameters
  34355. * @param paramName The object parameter name
  34356. * @returns The object parameter
  34357. */
  34358. getParam(paramName: string): any;
  34359. /**
  34360. * Sets a specific parameter in the options given to the physics plugin
  34361. * @param paramName The parameter name
  34362. * @param value The value of the parameter
  34363. */
  34364. setParam(paramName: string, value: number): void;
  34365. /**
  34366. * Specifically change the body's mass option. Won't recreate the physics body object
  34367. * @param mass The mass of the physics imposter
  34368. */
  34369. setMass(mass: number): void;
  34370. /**
  34371. * Gets the linear velocity
  34372. * @returns linear velocity or null
  34373. */
  34374. getLinearVelocity(): Nullable<Vector3>;
  34375. /**
  34376. * Sets the linear velocity
  34377. * @param velocity linear velocity or null
  34378. */
  34379. setLinearVelocity(velocity: Nullable<Vector3>): void;
  34380. /**
  34381. * Gets the angular velocity
  34382. * @returns angular velocity or null
  34383. */
  34384. getAngularVelocity(): Nullable<Vector3>;
  34385. /**
  34386. * Sets the angular velocity
  34387. * @param velocity The velocity or null
  34388. */
  34389. setAngularVelocity(velocity: Nullable<Vector3>): void;
  34390. /**
  34391. * Execute a function with the physics plugin native code
  34392. * Provide a function the will have two variables - the world object and the physics body object
  34393. * @param func The function to execute with the physics plugin native code
  34394. */
  34395. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  34396. /**
  34397. * Register a function that will be executed before the physics world is stepping forward
  34398. * @param func The function to execute before the physics world is stepped forward
  34399. */
  34400. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34401. /**
  34402. * Unregister a function that will be executed before the physics world is stepping forward
  34403. * @param func The function to execute before the physics world is stepped forward
  34404. */
  34405. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34406. /**
  34407. * Register a function that will be executed after the physics step
  34408. * @param func The function to execute after physics step
  34409. */
  34410. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34411. /**
  34412. * Unregisters a function that will be executed after the physics step
  34413. * @param func The function to execute after physics step
  34414. */
  34415. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34416. /**
  34417. * register a function that will be executed when this impostor collides against a different body
  34418. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34419. * @param func Callback that is executed on collision
  34420. */
  34421. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34422. /**
  34423. * Unregisters the physics imposter on contact
  34424. * @param collideAgainst The physics object to collide against
  34425. * @param func Callback to execute on collision
  34426. */
  34427. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34428. private _tmpQuat;
  34429. private _tmpQuat2;
  34430. /**
  34431. * Get the parent rotation
  34432. * @returns The parent rotation
  34433. */
  34434. getParentsRotation(): Quaternion;
  34435. /**
  34436. * this function is executed by the physics engine.
  34437. */
  34438. beforeStep: () => void;
  34439. /**
  34440. * this function is executed by the physics engine
  34441. */
  34442. afterStep: () => void;
  34443. /**
  34444. * Legacy collision detection event support
  34445. */
  34446. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34447. /**
  34448. * event and body object due to cannon's event-based architecture.
  34449. */
  34450. onCollide: (e: {
  34451. body: any;
  34452. point: Nullable<Vector3>;
  34453. }) => void;
  34454. /**
  34455. * Apply a force
  34456. * @param force The force to apply
  34457. * @param contactPoint The contact point for the force
  34458. * @returns The physics imposter
  34459. */
  34460. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34461. /**
  34462. * Apply an impulse
  34463. * @param force The impulse force
  34464. * @param contactPoint The contact point for the impulse force
  34465. * @returns The physics imposter
  34466. */
  34467. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34468. /**
  34469. * A help function to create a joint
  34470. * @param otherImpostor A physics imposter used to create a joint
  34471. * @param jointType The type of joint
  34472. * @param jointData The data for the joint
  34473. * @returns The physics imposter
  34474. */
  34475. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34476. /**
  34477. * Add a joint to this impostor with a different impostor
  34478. * @param otherImpostor A physics imposter used to add a joint
  34479. * @param joint The joint to add
  34480. * @returns The physics imposter
  34481. */
  34482. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34483. /**
  34484. * Add an anchor to a cloth impostor
  34485. * @param otherImpostor rigid impostor to anchor to
  34486. * @param width ratio across width from 0 to 1
  34487. * @param height ratio up height from 0 to 1
  34488. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  34489. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  34490. * @returns impostor the soft imposter
  34491. */
  34492. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34493. /**
  34494. * Add a hook to a rope impostor
  34495. * @param otherImpostor rigid impostor to anchor to
  34496. * @param length ratio across rope from 0 to 1
  34497. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  34498. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  34499. * @returns impostor the rope imposter
  34500. */
  34501. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34502. /**
  34503. * Will keep this body still, in a sleep mode.
  34504. * @returns the physics imposter
  34505. */
  34506. sleep(): PhysicsImpostor;
  34507. /**
  34508. * Wake the body up.
  34509. * @returns The physics imposter
  34510. */
  34511. wakeUp(): PhysicsImpostor;
  34512. /**
  34513. * Clones the physics imposter
  34514. * @param newObject The physics imposter clones to this physics-enabled object
  34515. * @returns A nullable physics imposter
  34516. */
  34517. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34518. /**
  34519. * Disposes the physics imposter
  34520. */
  34521. dispose(): void;
  34522. /**
  34523. * Sets the delta position
  34524. * @param position The delta position amount
  34525. */
  34526. setDeltaPosition(position: Vector3): void;
  34527. /**
  34528. * Sets the delta rotation
  34529. * @param rotation The delta rotation amount
  34530. */
  34531. setDeltaRotation(rotation: Quaternion): void;
  34532. /**
  34533. * Gets the box size of the physics imposter and stores the result in the input parameter
  34534. * @param result Stores the box size
  34535. * @returns The physics imposter
  34536. */
  34537. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34538. /**
  34539. * Gets the radius of the physics imposter
  34540. * @returns Radius of the physics imposter
  34541. */
  34542. getRadius(): number;
  34543. /**
  34544. * Sync a bone with this impostor
  34545. * @param bone The bone to sync to the impostor.
  34546. * @param boneMesh The mesh that the bone is influencing.
  34547. * @param jointPivot The pivot of the joint / bone in local space.
  34548. * @param distToJoint Optional distance from the impostor to the joint.
  34549. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34550. */
  34551. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34552. /**
  34553. * Sync impostor to a bone
  34554. * @param bone The bone that the impostor will be synced to.
  34555. * @param boneMesh The mesh that the bone is influencing.
  34556. * @param jointPivot The pivot of the joint / bone in local space.
  34557. * @param distToJoint Optional distance from the impostor to the joint.
  34558. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34559. * @param boneAxis Optional vector3 axis the bone is aligned with
  34560. */
  34561. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34562. /**
  34563. * No-Imposter type
  34564. */
  34565. static NoImpostor: number;
  34566. /**
  34567. * Sphere-Imposter type
  34568. */
  34569. static SphereImpostor: number;
  34570. /**
  34571. * Box-Imposter type
  34572. */
  34573. static BoxImpostor: number;
  34574. /**
  34575. * Plane-Imposter type
  34576. */
  34577. static PlaneImpostor: number;
  34578. /**
  34579. * Mesh-imposter type
  34580. */
  34581. static MeshImpostor: number;
  34582. /**
  34583. * Capsule-Impostor type (Ammo.js plugin only)
  34584. */
  34585. static CapsuleImpostor: number;
  34586. /**
  34587. * Cylinder-Imposter type
  34588. */
  34589. static CylinderImpostor: number;
  34590. /**
  34591. * Particle-Imposter type
  34592. */
  34593. static ParticleImpostor: number;
  34594. /**
  34595. * Heightmap-Imposter type
  34596. */
  34597. static HeightmapImpostor: number;
  34598. /**
  34599. * ConvexHull-Impostor type (Ammo.js plugin only)
  34600. */
  34601. static ConvexHullImpostor: number;
  34602. /**
  34603. * Custom-Imposter type (Ammo.js plugin only)
  34604. */
  34605. static CustomImpostor: number;
  34606. /**
  34607. * Rope-Imposter type
  34608. */
  34609. static RopeImpostor: number;
  34610. /**
  34611. * Cloth-Imposter type
  34612. */
  34613. static ClothImpostor: number;
  34614. /**
  34615. * Softbody-Imposter type
  34616. */
  34617. static SoftbodyImpostor: number;
  34618. }
  34619. }
  34620. declare module "babylonjs/Meshes/mesh" {
  34621. import { Observable } from "babylonjs/Misc/observable";
  34622. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34623. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34624. import { Camera } from "babylonjs/Cameras/camera";
  34625. import { Scene } from "babylonjs/scene";
  34626. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34627. import { Color4 } from "babylonjs/Maths/math.color";
  34628. import { Engine } from "babylonjs/Engines/engine";
  34629. import { Node } from "babylonjs/node";
  34630. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  34631. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  34632. import { Buffer } from "babylonjs/Meshes/buffer";
  34633. import { Geometry } from "babylonjs/Meshes/geometry";
  34634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34635. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34636. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  34637. import { Effect } from "babylonjs/Materials/effect";
  34638. import { Material } from "babylonjs/Materials/material";
  34639. import { Skeleton } from "babylonjs/Bones/skeleton";
  34640. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34641. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  34642. import { Path3D } from "babylonjs/Maths/math.path";
  34643. import { Plane } from "babylonjs/Maths/math.plane";
  34644. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34645. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34646. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  34647. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  34648. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  34649. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  34650. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  34651. /**
  34652. * @hidden
  34653. **/
  34654. export class _CreationDataStorage {
  34655. closePath?: boolean;
  34656. closeArray?: boolean;
  34657. idx: number[];
  34658. dashSize: number;
  34659. gapSize: number;
  34660. path3D: Path3D;
  34661. pathArray: Vector3[][];
  34662. arc: number;
  34663. radius: number;
  34664. cap: number;
  34665. tessellation: number;
  34666. }
  34667. /**
  34668. * @hidden
  34669. **/
  34670. class _InstanceDataStorage {
  34671. visibleInstances: any;
  34672. batchCache: _InstancesBatch;
  34673. instancesBufferSize: number;
  34674. instancesBuffer: Nullable<Buffer>;
  34675. instancesData: Float32Array;
  34676. overridenInstanceCount: number;
  34677. isFrozen: boolean;
  34678. previousBatch: Nullable<_InstancesBatch>;
  34679. hardwareInstancedRendering: boolean;
  34680. sideOrientation: number;
  34681. manualUpdate: boolean;
  34682. previousRenderId: number;
  34683. }
  34684. /**
  34685. * @hidden
  34686. **/
  34687. export class _InstancesBatch {
  34688. mustReturn: boolean;
  34689. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  34690. renderSelf: boolean[];
  34691. hardwareInstancedRendering: boolean[];
  34692. }
  34693. /**
  34694. * @hidden
  34695. **/
  34696. class _ThinInstanceDataStorage {
  34697. instancesCount: number;
  34698. matrixBuffer: Nullable<Buffer>;
  34699. matrixBufferSize: number;
  34700. matrixData: Nullable<Float32Array>;
  34701. boundingVectors: Array<Vector3>;
  34702. worldMatrices: Nullable<Matrix[]>;
  34703. }
  34704. /**
  34705. * Class used to represent renderable models
  34706. */
  34707. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  34708. /**
  34709. * Mesh side orientation : usually the external or front surface
  34710. */
  34711. static readonly FRONTSIDE: number;
  34712. /**
  34713. * Mesh side orientation : usually the internal or back surface
  34714. */
  34715. static readonly BACKSIDE: number;
  34716. /**
  34717. * Mesh side orientation : both internal and external or front and back surfaces
  34718. */
  34719. static readonly DOUBLESIDE: number;
  34720. /**
  34721. * Mesh side orientation : by default, `FRONTSIDE`
  34722. */
  34723. static readonly DEFAULTSIDE: number;
  34724. /**
  34725. * Mesh cap setting : no cap
  34726. */
  34727. static readonly NO_CAP: number;
  34728. /**
  34729. * Mesh cap setting : one cap at the beginning of the mesh
  34730. */
  34731. static readonly CAP_START: number;
  34732. /**
  34733. * Mesh cap setting : one cap at the end of the mesh
  34734. */
  34735. static readonly CAP_END: number;
  34736. /**
  34737. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34738. */
  34739. static readonly CAP_ALL: number;
  34740. /**
  34741. * Mesh pattern setting : no flip or rotate
  34742. */
  34743. static readonly NO_FLIP: number;
  34744. /**
  34745. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34746. */
  34747. static readonly FLIP_TILE: number;
  34748. /**
  34749. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34750. */
  34751. static readonly ROTATE_TILE: number;
  34752. /**
  34753. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34754. */
  34755. static readonly FLIP_ROW: number;
  34756. /**
  34757. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34758. */
  34759. static readonly ROTATE_ROW: number;
  34760. /**
  34761. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34762. */
  34763. static readonly FLIP_N_ROTATE_TILE: number;
  34764. /**
  34765. * Mesh pattern setting : rotate pattern and rotate
  34766. */
  34767. static readonly FLIP_N_ROTATE_ROW: number;
  34768. /**
  34769. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34770. */
  34771. static readonly CENTER: number;
  34772. /**
  34773. * Mesh tile positioning : part tiles on left
  34774. */
  34775. static readonly LEFT: number;
  34776. /**
  34777. * Mesh tile positioning : part tiles on right
  34778. */
  34779. static readonly RIGHT: number;
  34780. /**
  34781. * Mesh tile positioning : part tiles on top
  34782. */
  34783. static readonly TOP: number;
  34784. /**
  34785. * Mesh tile positioning : part tiles on bottom
  34786. */
  34787. static readonly BOTTOM: number;
  34788. /**
  34789. * Gets the default side orientation.
  34790. * @param orientation the orientation to value to attempt to get
  34791. * @returns the default orientation
  34792. * @hidden
  34793. */
  34794. static _GetDefaultSideOrientation(orientation?: number): number;
  34795. private _internalMeshDataInfo;
  34796. get computeBonesUsingShaders(): boolean;
  34797. set computeBonesUsingShaders(value: boolean);
  34798. /**
  34799. * An event triggered before rendering the mesh
  34800. */
  34801. get onBeforeRenderObservable(): Observable<Mesh>;
  34802. /**
  34803. * An event triggered before binding the mesh
  34804. */
  34805. get onBeforeBindObservable(): Observable<Mesh>;
  34806. /**
  34807. * An event triggered after rendering the mesh
  34808. */
  34809. get onAfterRenderObservable(): Observable<Mesh>;
  34810. /**
  34811. * An event triggered before drawing the mesh
  34812. */
  34813. get onBeforeDrawObservable(): Observable<Mesh>;
  34814. private _onBeforeDrawObserver;
  34815. /**
  34816. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34817. */
  34818. set onBeforeDraw(callback: () => void);
  34819. get hasInstances(): boolean;
  34820. get hasThinInstances(): boolean;
  34821. /**
  34822. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34823. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34824. */
  34825. delayLoadState: number;
  34826. /**
  34827. * Gets the list of instances created from this mesh
  34828. * it is not supposed to be modified manually.
  34829. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34830. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34831. */
  34832. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34833. /**
  34834. * Gets the file containing delay loading data for this mesh
  34835. */
  34836. delayLoadingFile: string;
  34837. /** @hidden */
  34838. _binaryInfo: any;
  34839. /**
  34840. * User defined function used to change how LOD level selection is done
  34841. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34842. */
  34843. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34844. /**
  34845. * Gets or sets the morph target manager
  34846. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34847. */
  34848. get morphTargetManager(): Nullable<MorphTargetManager>;
  34849. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34850. /** @hidden */
  34851. _creationDataStorage: Nullable<_CreationDataStorage>;
  34852. /** @hidden */
  34853. _geometry: Nullable<Geometry>;
  34854. /** @hidden */
  34855. _delayInfo: Array<string>;
  34856. /** @hidden */
  34857. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34858. /** @hidden */
  34859. _instanceDataStorage: _InstanceDataStorage;
  34860. /** @hidden */
  34861. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34862. private _effectiveMaterial;
  34863. /** @hidden */
  34864. _shouldGenerateFlatShading: boolean;
  34865. /** @hidden */
  34866. _originalBuilderSideOrientation: number;
  34867. /**
  34868. * Use this property to change the original side orientation defined at construction time
  34869. */
  34870. overrideMaterialSideOrientation: Nullable<number>;
  34871. /**
  34872. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  34873. * Note this will reduce performance when set to true.
  34874. */
  34875. ignoreCameraMaxZ: boolean;
  34876. /**
  34877. * Gets the source mesh (the one used to clone this one from)
  34878. */
  34879. get source(): Nullable<Mesh>;
  34880. /**
  34881. * Gets the list of clones of this mesh
  34882. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34883. * Note that useClonedMeshMap=true is the default setting
  34884. */
  34885. get cloneMeshMap(): Nullable<{
  34886. [id: string]: Mesh | undefined;
  34887. }>;
  34888. /**
  34889. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34890. */
  34891. get isUnIndexed(): boolean;
  34892. set isUnIndexed(value: boolean);
  34893. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34894. get worldMatrixInstancedBuffer(): Float32Array;
  34895. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34896. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34897. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34898. /**
  34899. * @constructor
  34900. * @param name The value used by scene.getMeshByName() to do a lookup.
  34901. * @param scene The scene to add this mesh to.
  34902. * @param parent The parent of this mesh, if it has one
  34903. * @param source An optional Mesh from which geometry is shared, cloned.
  34904. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34905. * When false, achieved by calling a clone(), also passing False.
  34906. * This will make creation of children, recursive.
  34907. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34908. */
  34909. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34910. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34911. doNotInstantiate: boolean;
  34912. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34913. /**
  34914. * Gets the class name
  34915. * @returns the string "Mesh".
  34916. */
  34917. getClassName(): string;
  34918. /** @hidden */
  34919. get _isMesh(): boolean;
  34920. /**
  34921. * Returns a description of this mesh
  34922. * @param fullDetails define if full details about this mesh must be used
  34923. * @returns a descriptive string representing this mesh
  34924. */
  34925. toString(fullDetails?: boolean): string;
  34926. /** @hidden */
  34927. _unBindEffect(): void;
  34928. /**
  34929. * Gets a boolean indicating if this mesh has LOD
  34930. */
  34931. get hasLODLevels(): boolean;
  34932. /**
  34933. * Gets the list of MeshLODLevel associated with the current mesh
  34934. * @returns an array of MeshLODLevel
  34935. */
  34936. getLODLevels(): MeshLODLevel[];
  34937. private _sortLODLevels;
  34938. /**
  34939. * Add a mesh as LOD level triggered at the given distance.
  34940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34941. * @param distance The distance from the center of the object to show this level
  34942. * @param mesh The mesh to be added as LOD level (can be null)
  34943. * @return This mesh (for chaining)
  34944. */
  34945. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34946. /**
  34947. * Returns the LOD level mesh at the passed distance or null if not found.
  34948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34949. * @param distance The distance from the center of the object to show this level
  34950. * @returns a Mesh or `null`
  34951. */
  34952. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34953. /**
  34954. * Remove a mesh from the LOD array
  34955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34956. * @param mesh defines the mesh to be removed
  34957. * @return This mesh (for chaining)
  34958. */
  34959. removeLODLevel(mesh: Mesh): Mesh;
  34960. /**
  34961. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34962. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34963. * @param camera defines the camera to use to compute distance
  34964. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34965. * @return This mesh (for chaining)
  34966. */
  34967. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34968. /**
  34969. * Gets the mesh internal Geometry object
  34970. */
  34971. get geometry(): Nullable<Geometry>;
  34972. /**
  34973. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34974. * @returns the total number of vertices
  34975. */
  34976. getTotalVertices(): number;
  34977. /**
  34978. * Returns the content of an associated vertex buffer
  34979. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34980. * - VertexBuffer.PositionKind
  34981. * - VertexBuffer.UVKind
  34982. * - VertexBuffer.UV2Kind
  34983. * - VertexBuffer.UV3Kind
  34984. * - VertexBuffer.UV4Kind
  34985. * - VertexBuffer.UV5Kind
  34986. * - VertexBuffer.UV6Kind
  34987. * - VertexBuffer.ColorKind
  34988. * - VertexBuffer.MatricesIndicesKind
  34989. * - VertexBuffer.MatricesIndicesExtraKind
  34990. * - VertexBuffer.MatricesWeightsKind
  34991. * - VertexBuffer.MatricesWeightsExtraKind
  34992. * @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
  34993. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34994. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34995. */
  34996. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34997. /**
  34998. * Returns the mesh VertexBuffer object from the requested `kind`
  34999. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  35000. * - VertexBuffer.PositionKind
  35001. * - VertexBuffer.NormalKind
  35002. * - VertexBuffer.UVKind
  35003. * - VertexBuffer.UV2Kind
  35004. * - VertexBuffer.UV3Kind
  35005. * - VertexBuffer.UV4Kind
  35006. * - VertexBuffer.UV5Kind
  35007. * - VertexBuffer.UV6Kind
  35008. * - VertexBuffer.ColorKind
  35009. * - VertexBuffer.MatricesIndicesKind
  35010. * - VertexBuffer.MatricesIndicesExtraKind
  35011. * - VertexBuffer.MatricesWeightsKind
  35012. * - VertexBuffer.MatricesWeightsExtraKind
  35013. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  35014. */
  35015. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  35016. /**
  35017. * Tests if a specific vertex buffer is associated with this mesh
  35018. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  35019. * - VertexBuffer.PositionKind
  35020. * - VertexBuffer.NormalKind
  35021. * - VertexBuffer.UVKind
  35022. * - VertexBuffer.UV2Kind
  35023. * - VertexBuffer.UV3Kind
  35024. * - VertexBuffer.UV4Kind
  35025. * - VertexBuffer.UV5Kind
  35026. * - VertexBuffer.UV6Kind
  35027. * - VertexBuffer.ColorKind
  35028. * - VertexBuffer.MatricesIndicesKind
  35029. * - VertexBuffer.MatricesIndicesExtraKind
  35030. * - VertexBuffer.MatricesWeightsKind
  35031. * - VertexBuffer.MatricesWeightsExtraKind
  35032. * @returns a boolean
  35033. */
  35034. isVerticesDataPresent(kind: string): boolean;
  35035. /**
  35036. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  35037. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  35038. * - VertexBuffer.PositionKind
  35039. * - VertexBuffer.UVKind
  35040. * - VertexBuffer.UV2Kind
  35041. * - VertexBuffer.UV3Kind
  35042. * - VertexBuffer.UV4Kind
  35043. * - VertexBuffer.UV5Kind
  35044. * - VertexBuffer.UV6Kind
  35045. * - VertexBuffer.ColorKind
  35046. * - VertexBuffer.MatricesIndicesKind
  35047. * - VertexBuffer.MatricesIndicesExtraKind
  35048. * - VertexBuffer.MatricesWeightsKind
  35049. * - VertexBuffer.MatricesWeightsExtraKind
  35050. * @returns a boolean
  35051. */
  35052. isVertexBufferUpdatable(kind: string): boolean;
  35053. /**
  35054. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  35055. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  35056. * - VertexBuffer.PositionKind
  35057. * - VertexBuffer.NormalKind
  35058. * - VertexBuffer.UVKind
  35059. * - VertexBuffer.UV2Kind
  35060. * - VertexBuffer.UV3Kind
  35061. * - VertexBuffer.UV4Kind
  35062. * - VertexBuffer.UV5Kind
  35063. * - VertexBuffer.UV6Kind
  35064. * - VertexBuffer.ColorKind
  35065. * - VertexBuffer.MatricesIndicesKind
  35066. * - VertexBuffer.MatricesIndicesExtraKind
  35067. * - VertexBuffer.MatricesWeightsKind
  35068. * - VertexBuffer.MatricesWeightsExtraKind
  35069. * @returns an array of strings
  35070. */
  35071. getVerticesDataKinds(): string[];
  35072. /**
  35073. * Returns a positive integer : the total number of indices in this mesh geometry.
  35074. * @returns the numner of indices or zero if the mesh has no geometry.
  35075. */
  35076. getTotalIndices(): number;
  35077. /**
  35078. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  35079. * @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.
  35080. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35081. * @returns the indices array or an empty array if the mesh has no geometry
  35082. */
  35083. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  35084. get isBlocked(): boolean;
  35085. /**
  35086. * Determine if the current mesh is ready to be rendered
  35087. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  35088. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  35089. * @returns true if all associated assets are ready (material, textures, shaders)
  35090. */
  35091. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  35092. /**
  35093. * 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.
  35094. */
  35095. get areNormalsFrozen(): boolean;
  35096. /**
  35097. * 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.
  35098. * @returns the current mesh
  35099. */
  35100. freezeNormals(): Mesh;
  35101. /**
  35102. * 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
  35103. * @returns the current mesh
  35104. */
  35105. unfreezeNormals(): Mesh;
  35106. /**
  35107. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  35108. */
  35109. set overridenInstanceCount(count: number);
  35110. /** @hidden */
  35111. _preActivate(): Mesh;
  35112. /** @hidden */
  35113. _preActivateForIntermediateRendering(renderId: number): Mesh;
  35114. /** @hidden */
  35115. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  35116. protected _afterComputeWorldMatrix(): void;
  35117. /** @hidden */
  35118. _postActivate(): void;
  35119. /**
  35120. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35121. * This means the mesh underlying bounding box and sphere are recomputed.
  35122. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35123. * @returns the current mesh
  35124. */
  35125. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  35126. /** @hidden */
  35127. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  35128. /**
  35129. * This function will subdivide the mesh into multiple submeshes
  35130. * @param count defines the expected number of submeshes
  35131. */
  35132. subdivide(count: number): void;
  35133. /**
  35134. * Copy a FloatArray into a specific associated vertex buffer
  35135. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  35136. * - VertexBuffer.PositionKind
  35137. * - VertexBuffer.UVKind
  35138. * - VertexBuffer.UV2Kind
  35139. * - VertexBuffer.UV3Kind
  35140. * - VertexBuffer.UV4Kind
  35141. * - VertexBuffer.UV5Kind
  35142. * - VertexBuffer.UV6Kind
  35143. * - VertexBuffer.ColorKind
  35144. * - VertexBuffer.MatricesIndicesKind
  35145. * - VertexBuffer.MatricesIndicesExtraKind
  35146. * - VertexBuffer.MatricesWeightsKind
  35147. * - VertexBuffer.MatricesWeightsExtraKind
  35148. * @param data defines the data source
  35149. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  35150. * @param stride defines the data stride size (can be null)
  35151. * @returns the current mesh
  35152. */
  35153. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35154. /**
  35155. * Delete a vertex buffer associated with this mesh
  35156. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  35157. * - VertexBuffer.PositionKind
  35158. * - VertexBuffer.UVKind
  35159. * - VertexBuffer.UV2Kind
  35160. * - VertexBuffer.UV3Kind
  35161. * - VertexBuffer.UV4Kind
  35162. * - VertexBuffer.UV5Kind
  35163. * - VertexBuffer.UV6Kind
  35164. * - VertexBuffer.ColorKind
  35165. * - VertexBuffer.MatricesIndicesKind
  35166. * - VertexBuffer.MatricesIndicesExtraKind
  35167. * - VertexBuffer.MatricesWeightsKind
  35168. * - VertexBuffer.MatricesWeightsExtraKind
  35169. */
  35170. removeVerticesData(kind: string): void;
  35171. /**
  35172. * Flags an associated vertex buffer as updatable
  35173. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  35174. * - VertexBuffer.PositionKind
  35175. * - VertexBuffer.UVKind
  35176. * - VertexBuffer.UV2Kind
  35177. * - VertexBuffer.UV3Kind
  35178. * - VertexBuffer.UV4Kind
  35179. * - VertexBuffer.UV5Kind
  35180. * - VertexBuffer.UV6Kind
  35181. * - VertexBuffer.ColorKind
  35182. * - VertexBuffer.MatricesIndicesKind
  35183. * - VertexBuffer.MatricesIndicesExtraKind
  35184. * - VertexBuffer.MatricesWeightsKind
  35185. * - VertexBuffer.MatricesWeightsExtraKind
  35186. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  35187. */
  35188. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  35189. /**
  35190. * Sets the mesh global Vertex Buffer
  35191. * @param buffer defines the buffer to use
  35192. * @returns the current mesh
  35193. */
  35194. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  35195. /**
  35196. * Update a specific associated vertex buffer
  35197. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  35198. * - VertexBuffer.PositionKind
  35199. * - VertexBuffer.UVKind
  35200. * - VertexBuffer.UV2Kind
  35201. * - VertexBuffer.UV3Kind
  35202. * - VertexBuffer.UV4Kind
  35203. * - VertexBuffer.UV5Kind
  35204. * - VertexBuffer.UV6Kind
  35205. * - VertexBuffer.ColorKind
  35206. * - VertexBuffer.MatricesIndicesKind
  35207. * - VertexBuffer.MatricesIndicesExtraKind
  35208. * - VertexBuffer.MatricesWeightsKind
  35209. * - VertexBuffer.MatricesWeightsExtraKind
  35210. * @param data defines the data source
  35211. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  35212. * @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)
  35213. * @returns the current mesh
  35214. */
  35215. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35216. /**
  35217. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  35218. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  35219. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  35220. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  35221. * @returns the current mesh
  35222. */
  35223. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  35224. /**
  35225. * Creates a un-shared specific occurence of the geometry for the mesh.
  35226. * @returns the current mesh
  35227. */
  35228. makeGeometryUnique(): Mesh;
  35229. /**
  35230. * Set the index buffer of this mesh
  35231. * @param indices defines the source data
  35232. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  35233. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  35234. * @returns the current mesh
  35235. */
  35236. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  35237. /**
  35238. * Update the current index buffer
  35239. * @param indices defines the source data
  35240. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35241. * @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)
  35242. * @returns the current mesh
  35243. */
  35244. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35245. /**
  35246. * Invert the geometry to move from a right handed system to a left handed one.
  35247. * @returns the current mesh
  35248. */
  35249. toLeftHanded(): Mesh;
  35250. /** @hidden */
  35251. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  35252. /** @hidden */
  35253. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  35254. /**
  35255. * Registers for this mesh a javascript function called just before the rendering process
  35256. * @param func defines the function to call before rendering this mesh
  35257. * @returns the current mesh
  35258. */
  35259. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  35260. /**
  35261. * Disposes a previously registered javascript function called before the rendering
  35262. * @param func defines the function to remove
  35263. * @returns the current mesh
  35264. */
  35265. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  35266. /**
  35267. * Registers for this mesh a javascript function called just after the rendering is complete
  35268. * @param func defines the function to call after rendering this mesh
  35269. * @returns the current mesh
  35270. */
  35271. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  35272. /**
  35273. * Disposes a previously registered javascript function called after the rendering.
  35274. * @param func defines the function to remove
  35275. * @returns the current mesh
  35276. */
  35277. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  35278. /** @hidden */
  35279. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  35280. /** @hidden */
  35281. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  35282. /** @hidden */
  35283. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  35284. /** @hidden */
  35285. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  35286. /** @hidden */
  35287. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  35288. /** @hidden */
  35289. _rebuild(): void;
  35290. /** @hidden */
  35291. _freeze(): void;
  35292. /** @hidden */
  35293. _unFreeze(): void;
  35294. /**
  35295. * 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
  35296. * @param subMesh defines the subMesh to render
  35297. * @param enableAlphaMode defines if alpha mode can be changed
  35298. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  35299. * @returns the current mesh
  35300. */
  35301. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  35302. private _onBeforeDraw;
  35303. /**
  35304. * Renormalize the mesh and patch it up if there are no weights
  35305. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  35306. * However in the case of zero weights then we set just a single influence to 1.
  35307. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  35308. */
  35309. cleanMatrixWeights(): void;
  35310. private normalizeSkinFourWeights;
  35311. private normalizeSkinWeightsAndExtra;
  35312. /**
  35313. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  35314. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  35315. * the user know there was an issue with importing the mesh
  35316. * @returns a validation object with skinned, valid and report string
  35317. */
  35318. validateSkinning(): {
  35319. skinned: boolean;
  35320. valid: boolean;
  35321. report: string;
  35322. };
  35323. /** @hidden */
  35324. _checkDelayState(): Mesh;
  35325. private _queueLoad;
  35326. /**
  35327. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35328. * A mesh is in the frustum if its bounding box intersects the frustum
  35329. * @param frustumPlanes defines the frustum to test
  35330. * @returns true if the mesh is in the frustum planes
  35331. */
  35332. isInFrustum(frustumPlanes: Plane[]): boolean;
  35333. /**
  35334. * Sets the mesh material by the material or multiMaterial `id` property
  35335. * @param id is a string identifying the material or the multiMaterial
  35336. * @returns the current mesh
  35337. */
  35338. setMaterialByID(id: string): Mesh;
  35339. /**
  35340. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  35341. * @returns an array of IAnimatable
  35342. */
  35343. getAnimatables(): IAnimatable[];
  35344. /**
  35345. * Modifies the mesh geometry according to the passed transformation matrix.
  35346. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  35347. * The mesh normals are modified using the same transformation.
  35348. * Note that, under the hood, this method sets a new VertexBuffer each call.
  35349. * @param transform defines the transform matrix to use
  35350. * @see https://doc.babylonjs.com/resources/baking_transformations
  35351. * @returns the current mesh
  35352. */
  35353. bakeTransformIntoVertices(transform: Matrix): Mesh;
  35354. /**
  35355. * Modifies the mesh geometry according to its own current World Matrix.
  35356. * The mesh World Matrix is then reset.
  35357. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  35358. * Note that, under the hood, this method sets a new VertexBuffer each call.
  35359. * @see https://doc.babylonjs.com/resources/baking_transformations
  35360. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  35361. * @returns the current mesh
  35362. */
  35363. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  35364. /** @hidden */
  35365. get _positions(): Nullable<Vector3[]>;
  35366. /** @hidden */
  35367. _resetPointsArrayCache(): Mesh;
  35368. /** @hidden */
  35369. _generatePointsArray(): boolean;
  35370. /**
  35371. * Returns a new Mesh object generated from the current mesh properties.
  35372. * This method must not get confused with createInstance()
  35373. * @param name is a string, the name given to the new mesh
  35374. * @param newParent can be any Node object (default `null`)
  35375. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  35376. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  35377. * @returns a new mesh
  35378. */
  35379. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  35380. /**
  35381. * Releases resources associated with this mesh.
  35382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35384. */
  35385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35386. /** @hidden */
  35387. _disposeInstanceSpecificData(): void;
  35388. /** @hidden */
  35389. _disposeThinInstanceSpecificData(): void;
  35390. /**
  35391. * Modifies the mesh geometry according to a displacement map.
  35392. * 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.
  35393. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  35394. * @param url is a string, the URL from the image file is to be downloaded.
  35395. * @param minHeight is the lower limit of the displacement.
  35396. * @param maxHeight is the upper limit of the displacement.
  35397. * @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.
  35398. * @param uvOffset is an optional vector2 used to offset UV.
  35399. * @param uvScale is an optional vector2 used to scale UV.
  35400. * @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.
  35401. * @returns the Mesh.
  35402. */
  35403. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  35404. /**
  35405. * Modifies the mesh geometry according to a displacementMap buffer.
  35406. * 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.
  35407. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  35408. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  35409. * @param heightMapWidth is the width of the buffer image.
  35410. * @param heightMapHeight is the height of the buffer image.
  35411. * @param minHeight is the lower limit of the displacement.
  35412. * @param maxHeight is the upper limit of the displacement.
  35413. * @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.
  35414. * @param uvOffset is an optional vector2 used to offset UV.
  35415. * @param uvScale is an optional vector2 used to scale UV.
  35416. * @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.
  35417. * @returns the Mesh.
  35418. */
  35419. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  35420. /**
  35421. * Modify the mesh to get a flat shading rendering.
  35422. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  35423. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  35424. * @returns current mesh
  35425. */
  35426. convertToFlatShadedMesh(): Mesh;
  35427. /**
  35428. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  35429. * In other words, more vertices, no more indices and a single bigger VBO.
  35430. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  35431. * @returns current mesh
  35432. */
  35433. convertToUnIndexedMesh(): Mesh;
  35434. /**
  35435. * Inverses facet orientations.
  35436. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35437. * @param flipNormals will also inverts the normals
  35438. * @returns current mesh
  35439. */
  35440. flipFaces(flipNormals?: boolean): Mesh;
  35441. /**
  35442. * Increase the number of facets and hence vertices in a mesh
  35443. * Vertex normals are interpolated from existing vertex normals
  35444. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35445. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  35446. */
  35447. increaseVertices(numberPerEdge: number): void;
  35448. /**
  35449. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  35450. * This will undo any application of covertToFlatShadedMesh
  35451. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35452. */
  35453. forceSharedVertices(): void;
  35454. /** @hidden */
  35455. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  35456. /** @hidden */
  35457. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  35458. /**
  35459. * Creates a new InstancedMesh object from the mesh model.
  35460. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  35461. * @param name defines the name of the new instance
  35462. * @returns a new InstancedMesh
  35463. */
  35464. createInstance(name: string): InstancedMesh;
  35465. /**
  35466. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  35467. * After this call, all the mesh instances have the same submeshes than the current mesh.
  35468. * @returns the current mesh
  35469. */
  35470. synchronizeInstances(): Mesh;
  35471. /**
  35472. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  35473. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  35474. * This should be used together with the simplification to avoid disappearing triangles.
  35475. * @param successCallback an optional success callback to be called after the optimization finished.
  35476. * @returns the current mesh
  35477. */
  35478. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  35479. /**
  35480. * Serialize current mesh
  35481. * @param serializationObject defines the object which will receive the serialization data
  35482. */
  35483. serialize(serializationObject: any): void;
  35484. /** @hidden */
  35485. _syncGeometryWithMorphTargetManager(): void;
  35486. /** @hidden */
  35487. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  35488. /**
  35489. * Returns a new Mesh object parsed from the source provided.
  35490. * @param parsedMesh is the source
  35491. * @param scene defines the hosting scene
  35492. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  35493. * @returns a new Mesh
  35494. */
  35495. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  35496. /**
  35497. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  35498. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35499. * @param name defines the name of the mesh to create
  35500. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  35501. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  35502. * @param closePath creates a seam between the first and the last points of each path of the path array
  35503. * @param offset is taken in account only if the `pathArray` is containing a single path
  35504. * @param scene defines the hosting scene
  35505. * @param updatable defines if the mesh must be flagged as updatable
  35506. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35507. * @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)
  35508. * @returns a new Mesh
  35509. */
  35510. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35511. /**
  35512. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  35513. * @param name defines the name of the mesh to create
  35514. * @param radius sets the radius size (float) of the polygon (default 0.5)
  35515. * @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
  35516. * @param scene defines the hosting scene
  35517. * @param updatable defines if the mesh must be flagged as updatable
  35518. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35519. * @returns a new Mesh
  35520. */
  35521. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35522. /**
  35523. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  35524. * @param name defines the name of the mesh to create
  35525. * @param size sets the size (float) of each box side (default 1)
  35526. * @param scene defines the hosting scene
  35527. * @param updatable defines if the mesh must be flagged as updatable
  35528. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35529. * @returns a new Mesh
  35530. */
  35531. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35532. /**
  35533. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  35534. * @param name defines the name of the mesh to create
  35535. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35536. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35537. * @param scene defines the hosting scene
  35538. * @param updatable defines if the mesh must be flagged as updatable
  35539. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35540. * @returns a new Mesh
  35541. */
  35542. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35543. /**
  35544. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  35545. * @param name defines the name of the mesh to create
  35546. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35547. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35548. * @param scene defines the hosting scene
  35549. * @returns a new Mesh
  35550. */
  35551. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  35552. /**
  35553. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  35554. * @param name defines the name of the mesh to create
  35555. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  35556. * @param diameterTop set the top cap diameter (floats, default 1)
  35557. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  35558. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  35559. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  35560. * @param scene defines the hosting scene
  35561. * @param updatable defines if the mesh must be flagged as updatable
  35562. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35563. * @returns a new Mesh
  35564. */
  35565. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  35566. /**
  35567. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  35568. * @param name defines the name of the mesh to create
  35569. * @param diameter sets the diameter size (float) of the torus (default 1)
  35570. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  35571. * @param tessellation sets the number of torus sides (positive integer, default 16)
  35572. * @param scene defines the hosting scene
  35573. * @param updatable defines if the mesh must be flagged as updatable
  35574. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35575. * @returns a new Mesh
  35576. */
  35577. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35578. /**
  35579. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  35580. * @param name defines the name of the mesh to create
  35581. * @param radius sets the global radius size (float) of the torus knot (default 2)
  35582. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  35583. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  35584. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  35585. * @param p the number of windings on X axis (positive integers, default 2)
  35586. * @param q the number of windings on Y axis (positive integers, default 3)
  35587. * @param scene defines the hosting scene
  35588. * @param updatable defines if the mesh must be flagged as updatable
  35589. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35590. * @returns a new Mesh
  35591. */
  35592. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35593. /**
  35594. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  35595. * @param name defines the name of the mesh to create
  35596. * @param points is an array successive Vector3
  35597. * @param scene defines the hosting scene
  35598. * @param updatable defines if the mesh must be flagged as updatable
  35599. * @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).
  35600. * @returns a new Mesh
  35601. */
  35602. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  35603. /**
  35604. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  35605. * @param name defines the name of the mesh to create
  35606. * @param points is an array successive Vector3
  35607. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  35608. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  35609. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  35610. * @param scene defines the hosting scene
  35611. * @param updatable defines if the mesh must be flagged as updatable
  35612. * @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)
  35613. * @returns a new Mesh
  35614. */
  35615. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  35616. /**
  35617. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  35618. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  35619. * 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.
  35620. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35621. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  35622. * Remember you can only change the shape positions, not their number when updating a polygon.
  35623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  35624. * @param name defines the name of the mesh to create
  35625. * @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
  35626. * @param scene defines the hosting scene
  35627. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35628. * @param updatable defines if the mesh must be flagged as updatable
  35629. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35630. * @param earcutInjection can be used to inject your own earcut reference
  35631. * @returns a new Mesh
  35632. */
  35633. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35634. /**
  35635. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  35636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  35637. * @param name defines the name of the mesh to create
  35638. * @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
  35639. * @param depth defines the height of extrusion
  35640. * @param scene defines the hosting scene
  35641. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35642. * @param updatable defines if the mesh must be flagged as updatable
  35643. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35644. * @param earcutInjection can be used to inject your own earcut reference
  35645. * @returns a new Mesh
  35646. */
  35647. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35648. /**
  35649. * Creates an extruded shape mesh.
  35650. * 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
  35651. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35653. * @param name defines the name of the mesh to create
  35654. * @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
  35655. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35656. * @param scale is the value to scale the shape
  35657. * @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
  35658. * @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
  35659. * @param scene defines the hosting scene
  35660. * @param updatable defines if the mesh must be flagged as updatable
  35661. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35662. * @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)
  35663. * @returns a new Mesh
  35664. */
  35665. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35666. /**
  35667. * Creates an custom extruded shape mesh.
  35668. * The custom extrusion is a parametric shape.
  35669. * It has no predefined shape. Its final shape will depend on the input parameters.
  35670. * Please consider using the same method from the MeshBuilder class instead
  35671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35672. * @param name defines the name of the mesh to create
  35673. * @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
  35674. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35675. * @param scaleFunction is a custom Javascript function called on each path point
  35676. * @param rotationFunction is a custom Javascript function called on each path point
  35677. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  35678. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  35679. * @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
  35680. * @param scene defines the hosting scene
  35681. * @param updatable defines if the mesh must be flagged as updatable
  35682. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35683. * @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)
  35684. * @returns a new Mesh
  35685. */
  35686. 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;
  35687. /**
  35688. * Creates lathe mesh.
  35689. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  35690. * Please consider using the same method from the MeshBuilder class instead
  35691. * @param name defines the name of the mesh to create
  35692. * @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
  35693. * @param radius is the radius value of the lathe
  35694. * @param tessellation is the side number of the lathe.
  35695. * @param scene defines the hosting scene
  35696. * @param updatable defines if the mesh must be flagged as updatable
  35697. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35698. * @returns a new Mesh
  35699. */
  35700. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35701. /**
  35702. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  35703. * @param name defines the name of the mesh to create
  35704. * @param size sets the size (float) of both sides of the plane at once (default 1)
  35705. * @param scene defines the hosting scene
  35706. * @param updatable defines if the mesh must be flagged as updatable
  35707. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35708. * @returns a new Mesh
  35709. */
  35710. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35711. /**
  35712. * Creates a ground mesh.
  35713. * Please consider using the same method from the MeshBuilder class instead
  35714. * @param name defines the name of the mesh to create
  35715. * @param width set the width of the ground
  35716. * @param height set the height of the ground
  35717. * @param subdivisions sets the number of subdivisions per side
  35718. * @param scene defines the hosting scene
  35719. * @param updatable defines if the mesh must be flagged as updatable
  35720. * @returns a new Mesh
  35721. */
  35722. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35723. /**
  35724. * Creates a tiled ground mesh.
  35725. * Please consider using the same method from the MeshBuilder class instead
  35726. * @param name defines the name of the mesh to create
  35727. * @param xmin set the ground minimum X coordinate
  35728. * @param zmin set the ground minimum Y coordinate
  35729. * @param xmax set the ground maximum X coordinate
  35730. * @param zmax set the ground maximum Z coordinate
  35731. * @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
  35732. * @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
  35733. * @param scene defines the hosting scene
  35734. * @param updatable defines if the mesh must be flagged as updatable
  35735. * @returns a new Mesh
  35736. */
  35737. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35738. w: number;
  35739. h: number;
  35740. }, precision: {
  35741. w: number;
  35742. h: number;
  35743. }, scene: Scene, updatable?: boolean): Mesh;
  35744. /**
  35745. * Creates a ground mesh from a height map.
  35746. * Please consider using the same method from the MeshBuilder class instead
  35747. * @see https://doc.babylonjs.com/babylon101/height_map
  35748. * @param name defines the name of the mesh to create
  35749. * @param url sets the URL of the height map image resource
  35750. * @param width set the ground width size
  35751. * @param height set the ground height size
  35752. * @param subdivisions sets the number of subdivision per side
  35753. * @param minHeight is the minimum altitude on the ground
  35754. * @param maxHeight is the maximum altitude on the ground
  35755. * @param scene defines the hosting scene
  35756. * @param updatable defines if the mesh must be flagged as updatable
  35757. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35758. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35759. * @returns a new Mesh
  35760. */
  35761. 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;
  35762. /**
  35763. * Creates a tube mesh.
  35764. * The tube is a parametric shape.
  35765. * It has no predefined shape. Its final shape will depend on the input parameters.
  35766. * Please consider using the same method from the MeshBuilder class instead
  35767. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35768. * @param name defines the name of the mesh to create
  35769. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35770. * @param radius sets the tube radius size
  35771. * @param tessellation is the number of sides on the tubular surface
  35772. * @param radiusFunction is a custom function. If it is not null, it overrides 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
  35773. * @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
  35774. * @param scene defines the hosting scene
  35775. * @param updatable defines if the mesh must be flagged as updatable
  35776. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35777. * @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)
  35778. * @returns a new Mesh
  35779. */
  35780. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35781. (i: number, distance: number): number;
  35782. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35783. /**
  35784. * Creates a polyhedron mesh.
  35785. * Please consider using the same method from the MeshBuilder class instead.
  35786. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embedded types. Please refer to the type sheet in the tutorial to choose the wanted type
  35787. * * The parameter `size` (positive float, default 1) sets the polygon size
  35788. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35789. * * 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`
  35790. * * 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
  35791. * * 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)`)
  35792. * * 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
  35793. * * 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
  35794. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35797. * @param name defines the name of the mesh to create
  35798. * @param options defines the options used to create the mesh
  35799. * @param scene defines the hosting scene
  35800. * @returns a new Mesh
  35801. */
  35802. static CreatePolyhedron(name: string, options: {
  35803. type?: number;
  35804. size?: number;
  35805. sizeX?: number;
  35806. sizeY?: number;
  35807. sizeZ?: number;
  35808. custom?: any;
  35809. faceUV?: Vector4[];
  35810. faceColors?: Color4[];
  35811. updatable?: boolean;
  35812. sideOrientation?: number;
  35813. }, scene: Scene): Mesh;
  35814. /**
  35815. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35816. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35817. * * 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`)
  35818. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35819. * * 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
  35820. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35823. * @param name defines the name of the mesh
  35824. * @param options defines the options used to create the mesh
  35825. * @param scene defines the hosting scene
  35826. * @returns a new Mesh
  35827. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35828. */
  35829. static CreateIcoSphere(name: string, options: {
  35830. radius?: number;
  35831. flat?: boolean;
  35832. subdivisions?: number;
  35833. sideOrientation?: number;
  35834. updatable?: boolean;
  35835. }, scene: Scene): Mesh;
  35836. /**
  35837. * Creates a decal mesh.
  35838. * Please consider using the same method from the MeshBuilder class instead.
  35839. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35840. * @param name defines the name of the mesh
  35841. * @param sourceMesh defines the mesh receiving the decal
  35842. * @param position sets the position of the decal in world coordinates
  35843. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35844. * @param size sets the decal scaling
  35845. * @param angle sets the angle to rotate the decal
  35846. * @returns a new Mesh
  35847. */
  35848. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35849. /** Creates a Capsule Mesh
  35850. * @param name defines the name of the mesh.
  35851. * @param options the constructors options used to shape the mesh.
  35852. * @param scene defines the scene the mesh is scoped to.
  35853. * @returns the capsule mesh
  35854. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35855. */
  35856. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35857. /**
  35858. * Prepare internal position array for software CPU skinning
  35859. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35860. */
  35861. setPositionsForCPUSkinning(): Float32Array;
  35862. /**
  35863. * Prepare internal normal array for software CPU skinning
  35864. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35865. */
  35866. setNormalsForCPUSkinning(): Float32Array;
  35867. /**
  35868. * Updates the vertex buffer by applying transformation from the bones
  35869. * @param skeleton defines the skeleton to apply to current mesh
  35870. * @returns the current mesh
  35871. */
  35872. applySkeleton(skeleton: Skeleton): Mesh;
  35873. /**
  35874. * 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
  35875. * @param meshes defines the list of meshes to scan
  35876. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35877. */
  35878. static MinMax(meshes: AbstractMesh[]): {
  35879. min: Vector3;
  35880. max: Vector3;
  35881. };
  35882. /**
  35883. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35884. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35885. * @returns a vector3
  35886. */
  35887. static Center(meshesOrMinMaxVector: {
  35888. min: Vector3;
  35889. max: Vector3;
  35890. } | AbstractMesh[]): Vector3;
  35891. /**
  35892. * Merge the array of meshes into a single mesh for performance reasons.
  35893. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35894. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35895. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35896. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35897. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35898. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35899. * @returns a new mesh
  35900. */
  35901. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35902. /** @hidden */
  35903. addInstance(instance: InstancedMesh): void;
  35904. /** @hidden */
  35905. removeInstance(instance: InstancedMesh): void;
  35906. }
  35907. }
  35908. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  35909. import { Vector3 } from "babylonjs/Maths/math.vector";
  35910. import { Mesh } from "babylonjs/Meshes/mesh";
  35911. import { Nullable } from "babylonjs/types";
  35912. import { Scene } from "babylonjs/scene";
  35913. /**
  35914. * The options Interface for creating a Capsule Mesh
  35915. */
  35916. export interface ICreateCapsuleOptions {
  35917. /** The Orientation of the capsule. Default : Vector3.Up() */
  35918. orientation?: Vector3;
  35919. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  35920. subdivisions: number;
  35921. /** Number of cylindrical segments on the capsule. */
  35922. tessellation: number;
  35923. /** Height or Length of the capsule. */
  35924. height: number;
  35925. /** Radius of the capsule. */
  35926. radius: number;
  35927. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  35928. capSubdivisions: number;
  35929. /** Overwrite for the top radius. */
  35930. radiusTop?: number;
  35931. /** Overwrite for the bottom radius. */
  35932. radiusBottom?: number;
  35933. /** Overwrite for the top capSubdivisions. */
  35934. topCapSubdivisions?: number;
  35935. /** Overwrite for the bottom capSubdivisions. */
  35936. bottomCapSubdivisions?: number;
  35937. /** Internal geometry is supposed to change once created. */
  35938. updatable?: boolean;
  35939. }
  35940. /**
  35941. * Class containing static functions to help procedurally build meshes
  35942. */
  35943. export class CapsuleBuilder {
  35944. /**
  35945. * Creates a capsule or a pill mesh
  35946. * @param name defines the name of the mesh
  35947. * @param options The constructors options.
  35948. * @param scene The scene the mesh is scoped to.
  35949. * @returns Capsule Mesh
  35950. */
  35951. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  35952. }
  35953. }
  35954. declare module "babylonjs/Meshes/mesh.vertexData" {
  35955. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  35956. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  35957. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35958. import { Geometry } from "babylonjs/Meshes/geometry";
  35959. import { Mesh } from "babylonjs/Meshes/mesh";
  35960. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  35961. /**
  35962. * Define an interface for all classes that will get and set the data on vertices
  35963. */
  35964. export interface IGetSetVerticesData {
  35965. /**
  35966. * Gets a boolean indicating if specific vertex data is present
  35967. * @param kind defines the vertex data kind to use
  35968. * @returns true is data kind is present
  35969. */
  35970. isVerticesDataPresent(kind: string): boolean;
  35971. /**
  35972. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  35973. * @param kind defines the data kind (Position, normal, etc...)
  35974. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  35975. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35976. * @returns a float array containing vertex data
  35977. */
  35978. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  35979. /**
  35980. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  35981. * @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.
  35982. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35983. * @returns the indices array or an empty array if the mesh has no geometry
  35984. */
  35985. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  35986. /**
  35987. * Set specific vertex data
  35988. * @param kind defines the data kind (Position, normal, etc...)
  35989. * @param data defines the vertex data to use
  35990. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  35991. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  35992. */
  35993. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  35994. /**
  35995. * Update a specific associated vertex buffer
  35996. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  35997. * - VertexBuffer.PositionKind
  35998. * - VertexBuffer.UVKind
  35999. * - VertexBuffer.UV2Kind
  36000. * - VertexBuffer.UV3Kind
  36001. * - VertexBuffer.UV4Kind
  36002. * - VertexBuffer.UV5Kind
  36003. * - VertexBuffer.UV6Kind
  36004. * - VertexBuffer.ColorKind
  36005. * - VertexBuffer.MatricesIndicesKind
  36006. * - VertexBuffer.MatricesIndicesExtraKind
  36007. * - VertexBuffer.MatricesWeightsKind
  36008. * - VertexBuffer.MatricesWeightsExtraKind
  36009. * @param data defines the data source
  36010. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  36011. * @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)
  36012. */
  36013. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  36014. /**
  36015. * Creates a new index buffer
  36016. * @param indices defines the indices to store in the index buffer
  36017. * @param totalVertices defines the total number of vertices (could be null)
  36018. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  36019. */
  36020. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  36021. }
  36022. /**
  36023. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  36024. */
  36025. export class VertexData {
  36026. /**
  36027. * Mesh side orientation : usually the external or front surface
  36028. */
  36029. static readonly FRONTSIDE: number;
  36030. /**
  36031. * Mesh side orientation : usually the internal or back surface
  36032. */
  36033. static readonly BACKSIDE: number;
  36034. /**
  36035. * Mesh side orientation : both internal and external or front and back surfaces
  36036. */
  36037. static readonly DOUBLESIDE: number;
  36038. /**
  36039. * Mesh side orientation : by default, `FRONTSIDE`
  36040. */
  36041. static readonly DEFAULTSIDE: number;
  36042. /**
  36043. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  36044. */
  36045. positions: Nullable<FloatArray>;
  36046. /**
  36047. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  36048. */
  36049. normals: Nullable<FloatArray>;
  36050. /**
  36051. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  36052. */
  36053. tangents: Nullable<FloatArray>;
  36054. /**
  36055. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  36056. */
  36057. uvs: Nullable<FloatArray>;
  36058. /**
  36059. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  36060. */
  36061. uvs2: Nullable<FloatArray>;
  36062. /**
  36063. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  36064. */
  36065. uvs3: Nullable<FloatArray>;
  36066. /**
  36067. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  36068. */
  36069. uvs4: Nullable<FloatArray>;
  36070. /**
  36071. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  36072. */
  36073. uvs5: Nullable<FloatArray>;
  36074. /**
  36075. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  36076. */
  36077. uvs6: Nullable<FloatArray>;
  36078. /**
  36079. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  36080. */
  36081. colors: Nullable<FloatArray>;
  36082. /**
  36083. * 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).
  36084. */
  36085. matricesIndices: Nullable<FloatArray>;
  36086. /**
  36087. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  36088. */
  36089. matricesWeights: Nullable<FloatArray>;
  36090. /**
  36091. * An array extending the number of possible indices
  36092. */
  36093. matricesIndicesExtra: Nullable<FloatArray>;
  36094. /**
  36095. * An array extending the number of possible weights when the number of indices is extended
  36096. */
  36097. matricesWeightsExtra: Nullable<FloatArray>;
  36098. /**
  36099. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  36100. */
  36101. indices: Nullable<IndicesArray>;
  36102. /**
  36103. * Uses the passed data array to set the set the values for the specified kind of data
  36104. * @param data a linear array of floating numbers
  36105. * @param kind the type of data that is being set, eg positions, colors etc
  36106. */
  36107. set(data: FloatArray, kind: string): void;
  36108. /**
  36109. * Associates the vertexData to the passed Mesh.
  36110. * Sets it as updatable or not (default `false`)
  36111. * @param mesh the mesh the vertexData is applied to
  36112. * @param updatable when used and having the value true allows new data to update the vertexData
  36113. * @returns the VertexData
  36114. */
  36115. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  36116. /**
  36117. * Associates the vertexData to the passed Geometry.
  36118. * Sets it as updatable or not (default `false`)
  36119. * @param geometry the geometry the vertexData is applied to
  36120. * @param updatable when used and having the value true allows new data to update the vertexData
  36121. * @returns VertexData
  36122. */
  36123. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  36124. /**
  36125. * Updates the associated mesh
  36126. * @param mesh the mesh to be updated
  36127. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  36128. * @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
  36129. * @returns VertexData
  36130. */
  36131. updateMesh(mesh: Mesh): VertexData;
  36132. /**
  36133. * Updates the associated geometry
  36134. * @param geometry the geometry to be updated
  36135. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  36136. * @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
  36137. * @returns VertexData.
  36138. */
  36139. updateGeometry(geometry: Geometry): VertexData;
  36140. private _applyTo;
  36141. private _update;
  36142. /**
  36143. * Transforms each position and each normal of the vertexData according to the passed Matrix
  36144. * @param matrix the transforming matrix
  36145. * @returns the VertexData
  36146. */
  36147. transform(matrix: Matrix): VertexData;
  36148. /**
  36149. * Merges the passed VertexData into the current one
  36150. * @param other the VertexData to be merged into the current one
  36151. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  36152. * @returns the modified VertexData
  36153. */
  36154. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  36155. private _mergeElement;
  36156. private _validate;
  36157. /**
  36158. * Serializes the VertexData
  36159. * @returns a serialized object
  36160. */
  36161. serialize(): any;
  36162. /**
  36163. * Extracts the vertexData from a mesh
  36164. * @param mesh the mesh from which to extract the VertexData
  36165. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  36166. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  36167. * @returns the object VertexData associated to the passed mesh
  36168. */
  36169. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  36170. /**
  36171. * Extracts the vertexData from the geometry
  36172. * @param geometry the geometry from which to extract the VertexData
  36173. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  36174. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  36175. * @returns the object VertexData associated to the passed mesh
  36176. */
  36177. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  36178. private static _ExtractFrom;
  36179. /**
  36180. * Creates the VertexData for a Ribbon
  36181. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  36182. * * pathArray array of paths, each of which an array of successive Vector3
  36183. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  36184. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  36185. * * 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
  36186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36187. * * 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)
  36188. * * 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)
  36189. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  36190. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  36191. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  36192. * @returns the VertexData of the ribbon
  36193. */
  36194. static CreateRibbon(options: {
  36195. pathArray: Vector3[][];
  36196. closeArray?: boolean;
  36197. closePath?: boolean;
  36198. offset?: number;
  36199. sideOrientation?: number;
  36200. frontUVs?: Vector4;
  36201. backUVs?: Vector4;
  36202. invertUV?: boolean;
  36203. uvs?: Vector2[];
  36204. colors?: Color4[];
  36205. }): VertexData;
  36206. /**
  36207. * Creates the VertexData for a box
  36208. * @param options an object used to set the following optional parameters for the box, required but can be empty
  36209. * * size sets the width, height and depth of the box to the value of size, optional default 1
  36210. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  36211. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  36212. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  36213. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  36214. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  36215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36216. * * 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)
  36217. * * 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)
  36218. * @returns the VertexData of the box
  36219. */
  36220. static CreateBox(options: {
  36221. size?: number;
  36222. width?: number;
  36223. height?: number;
  36224. depth?: number;
  36225. faceUV?: Vector4[];
  36226. faceColors?: Color4[];
  36227. sideOrientation?: number;
  36228. frontUVs?: Vector4;
  36229. backUVs?: Vector4;
  36230. }): VertexData;
  36231. /**
  36232. * Creates the VertexData for a tiled box
  36233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  36234. * * faceTiles sets the pattern, tile size and number of tiles for a face
  36235. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  36236. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  36237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36238. * @returns the VertexData of the box
  36239. */
  36240. static CreateTiledBox(options: {
  36241. pattern?: number;
  36242. width?: number;
  36243. height?: number;
  36244. depth?: number;
  36245. tileSize?: number;
  36246. tileWidth?: number;
  36247. tileHeight?: number;
  36248. alignHorizontal?: number;
  36249. alignVertical?: number;
  36250. faceUV?: Vector4[];
  36251. faceColors?: Color4[];
  36252. sideOrientation?: number;
  36253. }): VertexData;
  36254. /**
  36255. * Creates the VertexData for a tiled plane
  36256. * @param options an object used to set the following optional parameters for the box, required but can be empty
  36257. * * pattern a limited pattern arrangement depending on the number
  36258. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  36259. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  36260. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  36261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36262. * * 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)
  36263. * * 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)
  36264. * @returns the VertexData of the tiled plane
  36265. */
  36266. static CreateTiledPlane(options: {
  36267. pattern?: number;
  36268. tileSize?: number;
  36269. tileWidth?: number;
  36270. tileHeight?: number;
  36271. size?: number;
  36272. width?: number;
  36273. height?: number;
  36274. alignHorizontal?: number;
  36275. alignVertical?: number;
  36276. sideOrientation?: number;
  36277. frontUVs?: Vector4;
  36278. backUVs?: Vector4;
  36279. }): VertexData;
  36280. /**
  36281. * Creates the VertexData for an ellipsoid, defaults to a sphere
  36282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  36283. * * segments sets the number of horizontal strips optional, default 32
  36284. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  36285. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  36286. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  36287. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  36288. * * 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
  36289. * * 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
  36290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36291. * * 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)
  36292. * * 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)
  36293. * @returns the VertexData of the ellipsoid
  36294. */
  36295. static CreateSphere(options: {
  36296. segments?: number;
  36297. diameter?: number;
  36298. diameterX?: number;
  36299. diameterY?: number;
  36300. diameterZ?: number;
  36301. arc?: number;
  36302. slice?: number;
  36303. sideOrientation?: number;
  36304. frontUVs?: Vector4;
  36305. backUVs?: Vector4;
  36306. }): VertexData;
  36307. /**
  36308. * Creates the VertexData for a cylinder, cone or prism
  36309. * @param options an object used to set the following optional parameters for the box, required but can be empty
  36310. * * height sets the height (y direction) of the cylinder, optional, default 2
  36311. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  36312. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  36313. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  36314. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  36315. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  36316. * * 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
  36317. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36318. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36319. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  36320. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  36321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36322. * * 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)
  36323. * * 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)
  36324. * @returns the VertexData of the cylinder, cone or prism
  36325. */
  36326. static CreateCylinder(options: {
  36327. height?: number;
  36328. diameterTop?: number;
  36329. diameterBottom?: number;
  36330. diameter?: number;
  36331. tessellation?: number;
  36332. subdivisions?: number;
  36333. arc?: number;
  36334. faceColors?: Color4[];
  36335. faceUV?: Vector4[];
  36336. hasRings?: boolean;
  36337. enclose?: boolean;
  36338. sideOrientation?: number;
  36339. frontUVs?: Vector4;
  36340. backUVs?: Vector4;
  36341. }): VertexData;
  36342. /**
  36343. * Creates the VertexData for a torus
  36344. * @param options an object used to set the following optional parameters for the box, required but can be empty
  36345. * * diameter the diameter of the torus, optional default 1
  36346. * * thickness the diameter of the tube forming the torus, optional default 0.5
  36347. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  36348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36349. * * 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)
  36350. * * 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)
  36351. * @returns the VertexData of the torus
  36352. */
  36353. static CreateTorus(options: {
  36354. diameter?: number;
  36355. thickness?: number;
  36356. tessellation?: number;
  36357. sideOrientation?: number;
  36358. frontUVs?: Vector4;
  36359. backUVs?: Vector4;
  36360. }): VertexData;
  36361. /**
  36362. * Creates the VertexData of the LineSystem
  36363. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  36364. * - lines an array of lines, each line being an array of successive Vector3
  36365. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  36366. * @returns the VertexData of the LineSystem
  36367. */
  36368. static CreateLineSystem(options: {
  36369. lines: Vector3[][];
  36370. colors?: Nullable<Color4[][]>;
  36371. }): VertexData;
  36372. /**
  36373. * Create the VertexData for a DashedLines
  36374. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  36375. * - points an array successive Vector3
  36376. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  36377. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  36378. * - dashNb the intended total number of dashes, optional, default 200
  36379. * @returns the VertexData for the DashedLines
  36380. */
  36381. static CreateDashedLines(options: {
  36382. points: Vector3[];
  36383. dashSize?: number;
  36384. gapSize?: number;
  36385. dashNb?: number;
  36386. }): VertexData;
  36387. /**
  36388. * Creates the VertexData for a Ground
  36389. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  36390. * - width the width (x direction) of the ground, optional, default 1
  36391. * - height the height (z direction) of the ground, optional, default 1
  36392. * - subdivisions the number of subdivisions per side, optional, default 1
  36393. * @returns the VertexData of the Ground
  36394. */
  36395. static CreateGround(options: {
  36396. width?: number;
  36397. height?: number;
  36398. subdivisions?: number;
  36399. subdivisionsX?: number;
  36400. subdivisionsY?: number;
  36401. }): VertexData;
  36402. /**
  36403. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  36404. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  36405. * * xmin the ground minimum X coordinate, optional, default -1
  36406. * * zmin the ground minimum Z coordinate, optional, default -1
  36407. * * xmax the ground maximum X coordinate, optional, default 1
  36408. * * zmax the ground maximum Z coordinate, optional, default 1
  36409. * * 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}
  36410. * * 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}
  36411. * @returns the VertexData of the TiledGround
  36412. */
  36413. static CreateTiledGround(options: {
  36414. xmin: number;
  36415. zmin: number;
  36416. xmax: number;
  36417. zmax: number;
  36418. subdivisions?: {
  36419. w: number;
  36420. h: number;
  36421. };
  36422. precision?: {
  36423. w: number;
  36424. h: number;
  36425. };
  36426. }): VertexData;
  36427. /**
  36428. * Creates the VertexData of the Ground designed from a heightmap
  36429. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  36430. * * width the width (x direction) of the ground
  36431. * * height the height (z direction) of the ground
  36432. * * subdivisions the number of subdivisions per side
  36433. * * minHeight the minimum altitude on the ground, optional, default 0
  36434. * * maxHeight the maximum altitude on the ground, optional default 1
  36435. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  36436. * * buffer the array holding the image color data
  36437. * * bufferWidth the width of image
  36438. * * bufferHeight the height of image
  36439. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  36440. * @returns the VertexData of the Ground designed from a heightmap
  36441. */
  36442. static CreateGroundFromHeightMap(options: {
  36443. width: number;
  36444. height: number;
  36445. subdivisions: number;
  36446. minHeight: number;
  36447. maxHeight: number;
  36448. colorFilter: Color3;
  36449. buffer: Uint8Array;
  36450. bufferWidth: number;
  36451. bufferHeight: number;
  36452. alphaFilter: number;
  36453. }): VertexData;
  36454. /**
  36455. * Creates the VertexData for a Plane
  36456. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  36457. * * size sets the width and height of the plane to the value of size, optional default 1
  36458. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  36459. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  36460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36461. * * 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)
  36462. * * 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)
  36463. * @returns the VertexData of the box
  36464. */
  36465. static CreatePlane(options: {
  36466. size?: number;
  36467. width?: number;
  36468. height?: number;
  36469. sideOrientation?: number;
  36470. frontUVs?: Vector4;
  36471. backUVs?: Vector4;
  36472. }): VertexData;
  36473. /**
  36474. * Creates the VertexData of the Disc or regular Polygon
  36475. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  36476. * * radius the radius of the disc, optional default 0.5
  36477. * * tessellation the number of polygon sides, optional, default 64
  36478. * * 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
  36479. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36480. * * 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)
  36481. * * 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)
  36482. * @returns the VertexData of the box
  36483. */
  36484. static CreateDisc(options: {
  36485. radius?: number;
  36486. tessellation?: number;
  36487. arc?: number;
  36488. sideOrientation?: number;
  36489. frontUVs?: Vector4;
  36490. backUVs?: Vector4;
  36491. }): VertexData;
  36492. /**
  36493. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  36494. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  36495. * @param polygon a mesh built from polygonTriangulation.build()
  36496. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36497. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36498. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36499. * @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)
  36500. * @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)
  36501. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  36502. * @returns the VertexData of the Polygon
  36503. */
  36504. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  36505. /**
  36506. * Creates the VertexData of the IcoSphere
  36507. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  36508. * * radius the radius of the IcoSphere, optional default 1
  36509. * * radiusX allows stretching in the x direction, optional, default radius
  36510. * * radiusY allows stretching in the y direction, optional, default radius
  36511. * * radiusZ allows stretching in the z direction, optional, default radius
  36512. * * flat when true creates a flat shaded mesh, optional, default true
  36513. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36515. * * 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)
  36516. * * 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)
  36517. * @returns the VertexData of the IcoSphere
  36518. */
  36519. static CreateIcoSphere(options: {
  36520. radius?: number;
  36521. radiusX?: number;
  36522. radiusY?: number;
  36523. radiusZ?: number;
  36524. flat?: boolean;
  36525. subdivisions?: number;
  36526. sideOrientation?: number;
  36527. frontUVs?: Vector4;
  36528. backUVs?: Vector4;
  36529. }): VertexData;
  36530. /**
  36531. * Creates the VertexData for a Polyhedron
  36532. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  36533. * * type provided types are:
  36534. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  36535. * * 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)
  36536. * * size the size of the IcoSphere, optional default 1
  36537. * * sizeX allows stretching in the x direction, optional, default size
  36538. * * sizeY allows stretching in the y direction, optional, default size
  36539. * * sizeZ allows stretching in the z direction, optional, default size
  36540. * * 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
  36541. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36542. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36543. * * flat when true creates a flat shaded mesh, optional, default true
  36544. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36545. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36546. * * 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)
  36547. * * 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)
  36548. * @returns the VertexData of the Polyhedron
  36549. */
  36550. static CreatePolyhedron(options: {
  36551. type?: number;
  36552. size?: number;
  36553. sizeX?: number;
  36554. sizeY?: number;
  36555. sizeZ?: number;
  36556. custom?: any;
  36557. faceUV?: Vector4[];
  36558. faceColors?: Color4[];
  36559. flat?: boolean;
  36560. sideOrientation?: number;
  36561. frontUVs?: Vector4;
  36562. backUVs?: Vector4;
  36563. }): VertexData;
  36564. /**
  36565. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  36566. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  36567. * @returns the VertexData of the Capsule
  36568. */
  36569. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  36570. /**
  36571. * Creates the VertexData for a TorusKnot
  36572. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  36573. * * radius the radius of the torus knot, optional, default 2
  36574. * * tube the thickness of the tube, optional, default 0.5
  36575. * * radialSegments the number of sides on each tube segments, optional, default 32
  36576. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  36577. * * p the number of windings around the z axis, optional, default 2
  36578. * * q the number of windings around the x axis, optional, default 3
  36579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36580. * * 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)
  36581. * * 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)
  36582. * @returns the VertexData of the Torus Knot
  36583. */
  36584. static CreateTorusKnot(options: {
  36585. radius?: number;
  36586. tube?: number;
  36587. radialSegments?: number;
  36588. tubularSegments?: number;
  36589. p?: number;
  36590. q?: number;
  36591. sideOrientation?: number;
  36592. frontUVs?: Vector4;
  36593. backUVs?: Vector4;
  36594. }): VertexData;
  36595. /**
  36596. * Compute normals for given positions and indices
  36597. * @param positions an array of vertex positions, [...., x, y, z, ......]
  36598. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  36599. * @param normals an array of vertex normals, [...., x, y, z, ......]
  36600. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  36601. * * facetNormals : optional array of facet normals (vector3)
  36602. * * facetPositions : optional array of facet positions (vector3)
  36603. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  36604. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  36605. * * bInfo : optional bounding info, required for facetPartitioning computation
  36606. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  36607. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  36608. * * useRightHandedSystem: optional boolean to for right handed system computation
  36609. * * depthSort : optional boolean to enable the facet depth sort computation
  36610. * * distanceTo : optional Vector3 to compute the facet depth from this location
  36611. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  36612. */
  36613. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  36614. facetNormals?: any;
  36615. facetPositions?: any;
  36616. facetPartitioning?: any;
  36617. ratio?: number;
  36618. bInfo?: any;
  36619. bbSize?: Vector3;
  36620. subDiv?: any;
  36621. useRightHandedSystem?: boolean;
  36622. depthSort?: boolean;
  36623. distanceTo?: Vector3;
  36624. depthSortedFacets?: any;
  36625. }): void;
  36626. /** @hidden */
  36627. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  36628. /**
  36629. * Applies VertexData created from the imported parameters to the geometry
  36630. * @param parsedVertexData the parsed data from an imported file
  36631. * @param geometry the geometry to apply the VertexData to
  36632. */
  36633. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  36634. }
  36635. }
  36636. declare module "babylonjs/Meshes/Builders/discBuilder" {
  36637. import { Nullable } from "babylonjs/types";
  36638. import { Scene } from "babylonjs/scene";
  36639. import { Vector4 } from "babylonjs/Maths/math.vector";
  36640. import { Mesh } from "babylonjs/Meshes/mesh";
  36641. /**
  36642. * Class containing static functions to help procedurally build meshes
  36643. */
  36644. export class DiscBuilder {
  36645. /**
  36646. * Creates a plane polygonal mesh. By default, this is a disc
  36647. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  36648. * * 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
  36649. * * 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
  36650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36653. * @param name defines the name of the mesh
  36654. * @param options defines the options used to create the mesh
  36655. * @param scene defines the hosting scene
  36656. * @returns the plane polygonal mesh
  36657. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  36658. */
  36659. static CreateDisc(name: string, options: {
  36660. radius?: number;
  36661. tessellation?: number;
  36662. arc?: number;
  36663. updatable?: boolean;
  36664. sideOrientation?: number;
  36665. frontUVs?: Vector4;
  36666. backUVs?: Vector4;
  36667. }, scene?: Nullable<Scene>): Mesh;
  36668. }
  36669. }
  36670. declare module "babylonjs/Particles/solidParticleSystem" {
  36671. import { Nullable } from "babylonjs/types";
  36672. import { Mesh } from "babylonjs/Meshes/mesh";
  36673. import { Scene, IDisposable } from "babylonjs/scene";
  36674. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  36675. import { Material } from "babylonjs/Materials/material";
  36676. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36677. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36678. /**
  36679. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  36680. *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.
  36681. * The SPS is also a particle system. It provides some methods to manage the particles.
  36682. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  36683. *
  36684. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  36685. */
  36686. export class SolidParticleSystem implements IDisposable {
  36687. /**
  36688. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  36689. * Example : var p = SPS.particles[i];
  36690. */
  36691. particles: SolidParticle[];
  36692. /**
  36693. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  36694. */
  36695. nbParticles: number;
  36696. /**
  36697. * If the particles must ever face the camera (default false). Useful for planar particles.
  36698. */
  36699. billboard: boolean;
  36700. /**
  36701. * Recompute normals when adding a shape
  36702. */
  36703. recomputeNormals: boolean;
  36704. /**
  36705. * This a counter ofr your own usage. It's not set by any SPS functions.
  36706. */
  36707. counter: number;
  36708. /**
  36709. * The SPS name. This name is also given to the underlying mesh.
  36710. */
  36711. name: string;
  36712. /**
  36713. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  36714. */
  36715. mesh: Mesh;
  36716. /**
  36717. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  36718. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  36719. */
  36720. vars: any;
  36721. /**
  36722. * This array is populated when the SPS is set as 'pickable'.
  36723. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  36724. * Each element of this array is an object `{idx: int, faceId: int}`.
  36725. * `idx` is the picked particle index in the `SPS.particles` array
  36726. * `faceId` is the picked face index counted within this particle.
  36727. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  36728. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  36729. * Use the method SPS.pickedParticle(pickingInfo) instead.
  36730. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36731. */
  36732. pickedParticles: {
  36733. idx: number;
  36734. faceId: number;
  36735. }[];
  36736. /**
  36737. * This array is populated when the SPS is set as 'pickable'
  36738. * Each key of this array is a submesh index.
  36739. * Each element of this array is a second array defined like this :
  36740. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  36741. * Each element of this second array is an object `{idx: int, faceId: int}`.
  36742. * `idx` is the picked particle index in the `SPS.particles` array
  36743. * `faceId` is the picked face index counted within this particle.
  36744. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  36745. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36746. */
  36747. pickedBySubMesh: {
  36748. idx: number;
  36749. faceId: number;
  36750. }[][];
  36751. /**
  36752. * This array is populated when `enableDepthSort` is set to true.
  36753. * Each element of this array is an instance of the class DepthSortedParticle.
  36754. */
  36755. depthSortedParticles: DepthSortedParticle[];
  36756. /**
  36757. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  36758. * @hidden
  36759. */
  36760. _bSphereOnly: boolean;
  36761. /**
  36762. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  36763. * @hidden
  36764. */
  36765. _bSphereRadiusFactor: number;
  36766. private _scene;
  36767. private _positions;
  36768. private _indices;
  36769. private _normals;
  36770. private _colors;
  36771. private _uvs;
  36772. private _indices32;
  36773. private _positions32;
  36774. private _normals32;
  36775. private _fixedNormal32;
  36776. private _colors32;
  36777. private _uvs32;
  36778. private _index;
  36779. private _updatable;
  36780. private _pickable;
  36781. private _isVisibilityBoxLocked;
  36782. private _alwaysVisible;
  36783. private _depthSort;
  36784. private _expandable;
  36785. private _shapeCounter;
  36786. private _copy;
  36787. private _color;
  36788. private _computeParticleColor;
  36789. private _computeParticleTexture;
  36790. private _computeParticleRotation;
  36791. private _computeParticleVertex;
  36792. private _computeBoundingBox;
  36793. private _depthSortParticles;
  36794. private _camera;
  36795. private _mustUnrotateFixedNormals;
  36796. private _particlesIntersect;
  36797. private _needs32Bits;
  36798. private _isNotBuilt;
  36799. private _lastParticleId;
  36800. private _idxOfId;
  36801. private _multimaterialEnabled;
  36802. private _useModelMaterial;
  36803. private _indicesByMaterial;
  36804. private _materialIndexes;
  36805. private _depthSortFunction;
  36806. private _materialSortFunction;
  36807. private _materials;
  36808. private _multimaterial;
  36809. private _materialIndexesById;
  36810. private _defaultMaterial;
  36811. private _autoUpdateSubMeshes;
  36812. private _tmpVertex;
  36813. /**
  36814. * Creates a SPS (Solid Particle System) object.
  36815. * @param name (String) is the SPS name, this will be the underlying mesh name.
  36816. * @param scene (Scene) is the scene in which the SPS is added.
  36817. * @param options defines the options of the sps e.g.
  36818. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  36819. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  36820. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  36821. * * useModelMaterial (optional boolean, default false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  36822. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  36823. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  36824. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  36825. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  36826. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  36827. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  36828. */
  36829. constructor(name: string, scene: Scene, options?: {
  36830. updatable?: boolean;
  36831. isPickable?: boolean;
  36832. enableDepthSort?: boolean;
  36833. particleIntersection?: boolean;
  36834. boundingSphereOnly?: boolean;
  36835. bSphereRadiusFactor?: number;
  36836. expandable?: boolean;
  36837. useModelMaterial?: boolean;
  36838. enableMultiMaterial?: boolean;
  36839. });
  36840. /**
  36841. * Builds the SPS underlying mesh. Returns a standard Mesh.
  36842. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  36843. * @returns the created mesh
  36844. */
  36845. buildMesh(): Mesh;
  36846. /**
  36847. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  36848. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  36849. * Thus the particles generated from `digest()` have their property `position` set yet.
  36850. * @param mesh ( Mesh ) is the mesh to be digested
  36851. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overridden by the parameter `number` if any
  36852. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  36853. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  36854. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36855. * @returns the current SPS
  36856. */
  36857. digest(mesh: Mesh, options?: {
  36858. facetNb?: number;
  36859. number?: number;
  36860. delta?: number;
  36861. storage?: [];
  36862. }): SolidParticleSystem;
  36863. /**
  36864. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  36865. * @hidden
  36866. */
  36867. private _unrotateFixedNormals;
  36868. /**
  36869. * Resets the temporary working copy particle
  36870. * @hidden
  36871. */
  36872. private _resetCopy;
  36873. /**
  36874. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  36875. * @param p the current index in the positions array to be updated
  36876. * @param ind the current index in the indices array
  36877. * @param shape a Vector3 array, the shape geometry
  36878. * @param positions the positions array to be updated
  36879. * @param meshInd the shape indices array
  36880. * @param indices the indices array to be updated
  36881. * @param meshUV the shape uv array
  36882. * @param uvs the uv array to be updated
  36883. * @param meshCol the shape color array
  36884. * @param colors the color array to be updated
  36885. * @param meshNor the shape normals array
  36886. * @param normals the normals array to be updated
  36887. * @param idx the particle index
  36888. * @param idxInShape the particle index in its shape
  36889. * @param options the addShape() method passed options
  36890. * @model the particle model
  36891. * @hidden
  36892. */
  36893. private _meshBuilder;
  36894. /**
  36895. * Returns a shape Vector3 array from positions float array
  36896. * @param positions float array
  36897. * @returns a vector3 array
  36898. * @hidden
  36899. */
  36900. private _posToShape;
  36901. /**
  36902. * Returns a shapeUV array from a float uvs (array deep copy)
  36903. * @param uvs as a float array
  36904. * @returns a shapeUV array
  36905. * @hidden
  36906. */
  36907. private _uvsToShapeUV;
  36908. /**
  36909. * Adds a new particle object in the particles array
  36910. * @param idx particle index in particles array
  36911. * @param id particle id
  36912. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36913. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36914. * @param model particle ModelShape object
  36915. * @param shapeId model shape identifier
  36916. * @param idxInShape index of the particle in the current model
  36917. * @param bInfo model bounding info object
  36918. * @param storage target storage array, if any
  36919. * @hidden
  36920. */
  36921. private _addParticle;
  36922. /**
  36923. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36924. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36925. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36926. * @param nb (positive integer) the number of particles to be created from this model
  36927. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36928. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36929. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36930. * @returns the number of shapes in the system
  36931. */
  36932. addShape(mesh: Mesh, nb: number, options?: {
  36933. positionFunction?: any;
  36934. vertexFunction?: any;
  36935. storage?: [];
  36936. }): number;
  36937. /**
  36938. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36939. * @hidden
  36940. */
  36941. private _rebuildParticle;
  36942. /**
  36943. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36944. * @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.
  36945. * @returns the SPS.
  36946. */
  36947. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36948. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36949. * Returns an array with the removed particles.
  36950. * 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.
  36951. * The SPS can't be empty so at least one particle needs to remain in place.
  36952. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36953. * @param start index of the first particle to remove
  36954. * @param end index of the last particle to remove (included)
  36955. * @returns an array populated with the removed particles
  36956. */
  36957. removeParticles(start: number, end: number): SolidParticle[];
  36958. /**
  36959. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36960. * @param solidParticleArray an array populated with Solid Particles objects
  36961. * @returns the SPS
  36962. */
  36963. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36964. /**
  36965. * Creates a new particle and modifies the SPS mesh geometry :
  36966. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36967. * - calls _addParticle() to populate the particle array
  36968. * factorized code from addShape() and insertParticlesFromArray()
  36969. * @param idx particle index in the particles array
  36970. * @param i particle index in its shape
  36971. * @param modelShape particle ModelShape object
  36972. * @param shape shape vertex array
  36973. * @param meshInd shape indices array
  36974. * @param meshUV shape uv array
  36975. * @param meshCol shape color array
  36976. * @param meshNor shape normals array
  36977. * @param bbInfo shape bounding info
  36978. * @param storage target particle storage
  36979. * @options addShape() passed options
  36980. * @hidden
  36981. */
  36982. private _insertNewParticle;
  36983. /**
  36984. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36985. * This method calls `updateParticle()` for each particle of the SPS.
  36986. * For an animated SPS, it is usually called within the render loop.
  36987. * 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.
  36988. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36989. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36990. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36991. * @returns the SPS.
  36992. */
  36993. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36994. /**
  36995. * Disposes the SPS.
  36996. */
  36997. dispose(): void;
  36998. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  36999. * idx is the particle index in the SPS
  37000. * faceId is the picked face index counted within this particle.
  37001. * Returns null if the pickInfo can't identify a picked particle.
  37002. * @param pickingInfo (PickingInfo object)
  37003. * @returns {idx: number, faceId: number} or null
  37004. */
  37005. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  37006. idx: number;
  37007. faceId: number;
  37008. }>;
  37009. /**
  37010. * Returns a SolidParticle object from its identifier : particle.id
  37011. * @param id (integer) the particle Id
  37012. * @returns the searched particle or null if not found in the SPS.
  37013. */
  37014. getParticleById(id: number): Nullable<SolidParticle>;
  37015. /**
  37016. * Returns a new array populated with the particles having the passed shapeId.
  37017. * @param shapeId (integer) the shape identifier
  37018. * @returns a new solid particle array
  37019. */
  37020. getParticlesByShapeId(shapeId: number): SolidParticle[];
  37021. /**
  37022. * Populates the passed array "ref" with the particles having the passed shapeId.
  37023. * @param shapeId the shape identifier
  37024. * @returns the SPS
  37025. * @param ref
  37026. */
  37027. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  37028. /**
  37029. * Computes the required SubMeshes according the materials assigned to the particles.
  37030. * @returns the solid particle system.
  37031. * Does nothing if called before the SPS mesh is built.
  37032. */
  37033. computeSubMeshes(): SolidParticleSystem;
  37034. /**
  37035. * Sorts the solid particles by material when MultiMaterial is enabled.
  37036. * Updates the indices32 array.
  37037. * Updates the indicesByMaterial array.
  37038. * Updates the mesh indices array.
  37039. * @returns the SPS
  37040. * @hidden
  37041. */
  37042. private _sortParticlesByMaterial;
  37043. /**
  37044. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  37045. * @hidden
  37046. */
  37047. private _setMaterialIndexesById;
  37048. /**
  37049. * Returns an array with unique values of Materials from the passed array
  37050. * @param array the material array to be checked and filtered
  37051. * @hidden
  37052. */
  37053. private _filterUniqueMaterialId;
  37054. /**
  37055. * Sets a new Standard Material as _defaultMaterial if not already set.
  37056. * @hidden
  37057. */
  37058. private _setDefaultMaterial;
  37059. /**
  37060. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  37061. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  37062. * @returns the SPS.
  37063. */
  37064. refreshVisibleSize(): SolidParticleSystem;
  37065. /**
  37066. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  37067. * @param size the size (float) of the visibility box
  37068. * note : this doesn't lock the SPS mesh bounding box.
  37069. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  37070. */
  37071. setVisibilityBox(size: number): void;
  37072. /**
  37073. * Gets whether the SPS as always visible or not
  37074. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  37075. */
  37076. get isAlwaysVisible(): boolean;
  37077. /**
  37078. * Sets the SPS as always visible or not
  37079. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  37080. */
  37081. set isAlwaysVisible(val: boolean);
  37082. /**
  37083. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  37084. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  37085. */
  37086. set isVisibilityBoxLocked(val: boolean);
  37087. /**
  37088. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  37089. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  37090. */
  37091. get isVisibilityBoxLocked(): boolean;
  37092. /**
  37093. * Tells to `setParticles()` to compute the particle rotations or not.
  37094. * Default value : true. The SPS is faster when it's set to false.
  37095. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  37096. */
  37097. set computeParticleRotation(val: boolean);
  37098. /**
  37099. * Tells to `setParticles()` to compute the particle colors or not.
  37100. * Default value : true. The SPS is faster when it's set to false.
  37101. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  37102. */
  37103. set computeParticleColor(val: boolean);
  37104. set computeParticleTexture(val: boolean);
  37105. /**
  37106. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  37107. * Default value : false. The SPS is faster when it's set to false.
  37108. * Note : the particle custom vertex positions aren't stored values.
  37109. */
  37110. set computeParticleVertex(val: boolean);
  37111. /**
  37112. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  37113. */
  37114. set computeBoundingBox(val: boolean);
  37115. /**
  37116. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  37117. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  37118. * Default : `true`
  37119. */
  37120. set depthSortParticles(val: boolean);
  37121. /**
  37122. * Gets if `setParticles()` computes the particle rotations or not.
  37123. * Default value : true. The SPS is faster when it's set to false.
  37124. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  37125. */
  37126. get computeParticleRotation(): boolean;
  37127. /**
  37128. * Gets if `setParticles()` computes the particle colors or not.
  37129. * Default value : true. The SPS is faster when it's set to false.
  37130. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  37131. */
  37132. get computeParticleColor(): boolean;
  37133. /**
  37134. * Gets if `setParticles()` computes the particle textures or not.
  37135. * Default value : true. The SPS is faster when it's set to false.
  37136. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  37137. */
  37138. get computeParticleTexture(): boolean;
  37139. /**
  37140. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  37141. * Default value : false. The SPS is faster when it's set to false.
  37142. * Note : the particle custom vertex positions aren't stored values.
  37143. */
  37144. get computeParticleVertex(): boolean;
  37145. /**
  37146. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  37147. */
  37148. get computeBoundingBox(): boolean;
  37149. /**
  37150. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  37151. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  37152. * Default : `true`
  37153. */
  37154. get depthSortParticles(): boolean;
  37155. /**
  37156. * Gets if the SPS is created as expandable at construction time.
  37157. * Default : `false`
  37158. */
  37159. get expandable(): boolean;
  37160. /**
  37161. * Gets if the SPS supports the Multi Materials
  37162. */
  37163. get multimaterialEnabled(): boolean;
  37164. /**
  37165. * Gets if the SPS uses the model materials for its own multimaterial.
  37166. */
  37167. get useModelMaterial(): boolean;
  37168. /**
  37169. * The SPS used material array.
  37170. */
  37171. get materials(): Material[];
  37172. /**
  37173. * Sets the SPS MultiMaterial from the passed materials.
  37174. * Note : the passed array is internally copied and not used then by reference.
  37175. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  37176. */
  37177. setMultiMaterial(materials: Material[]): void;
  37178. /**
  37179. * The SPS computed multimaterial object
  37180. */
  37181. get multimaterial(): MultiMaterial;
  37182. set multimaterial(mm: MultiMaterial);
  37183. /**
  37184. * If the subMeshes must be updated on the next call to setParticles()
  37185. */
  37186. get autoUpdateSubMeshes(): boolean;
  37187. set autoUpdateSubMeshes(val: boolean);
  37188. /**
  37189. * This function does nothing. It may be overwritten to set all the particle first values.
  37190. * The SPS doesn't call this function, you may have to call it by your own.
  37191. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  37192. */
  37193. initParticles(): void;
  37194. /**
  37195. * This function does nothing. It may be overwritten to recycle a particle.
  37196. * The SPS doesn't call this function, you may have to call it by your own.
  37197. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  37198. * @param particle The particle to recycle
  37199. * @returns the recycled particle
  37200. */
  37201. recycleParticle(particle: SolidParticle): SolidParticle;
  37202. /**
  37203. * Updates a particle : this function should be overwritten by the user.
  37204. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  37205. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  37206. * @example : just set a particle position or velocity and recycle conditions
  37207. * @param particle The particle to update
  37208. * @returns the updated particle
  37209. */
  37210. updateParticle(particle: SolidParticle): SolidParticle;
  37211. /**
  37212. * Updates a vertex of a particle : it can be overwritten by the user.
  37213. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  37214. * @param particle the current particle
  37215. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  37216. * @param pt the index of the current vertex in the particle shape
  37217. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  37218. * @example : just set a vertex particle position or color
  37219. * @returns the sps
  37220. */
  37221. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  37222. /**
  37223. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  37224. * This does nothing and may be overwritten by the user.
  37225. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  37226. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  37227. * @param update the boolean update value actually passed to setParticles()
  37228. */
  37229. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  37230. /**
  37231. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  37232. * This will be passed three parameters.
  37233. * This does nothing and may be overwritten by the user.
  37234. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  37235. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  37236. * @param update the boolean update value actually passed to setParticles()
  37237. */
  37238. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  37239. }
  37240. }
  37241. declare module "babylonjs/Particles/solidParticle" {
  37242. import { Nullable } from "babylonjs/types";
  37243. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  37244. import { Color4 } from "babylonjs/Maths/math.color";
  37245. import { Mesh } from "babylonjs/Meshes/mesh";
  37246. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  37247. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  37248. import { Plane } from "babylonjs/Maths/math.plane";
  37249. import { Material } from "babylonjs/Materials/material";
  37250. /**
  37251. * Represents one particle of a solid particle system.
  37252. */
  37253. export class SolidParticle {
  37254. /**
  37255. * particle global index
  37256. */
  37257. idx: number;
  37258. /**
  37259. * particle identifier
  37260. */
  37261. id: number;
  37262. /**
  37263. * The color of the particle
  37264. */
  37265. color: Nullable<Color4>;
  37266. /**
  37267. * The world space position of the particle.
  37268. */
  37269. position: Vector3;
  37270. /**
  37271. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  37272. */
  37273. rotation: Vector3;
  37274. /**
  37275. * The world space rotation quaternion of the particle.
  37276. */
  37277. rotationQuaternion: Nullable<Quaternion>;
  37278. /**
  37279. * The scaling of the particle.
  37280. */
  37281. scaling: Vector3;
  37282. /**
  37283. * The uvs of the particle.
  37284. */
  37285. uvs: Vector4;
  37286. /**
  37287. * The current speed of the particle.
  37288. */
  37289. velocity: Vector3;
  37290. /**
  37291. * The pivot point in the particle local space.
  37292. */
  37293. pivot: Vector3;
  37294. /**
  37295. * Must the particle be translated from its pivot point in its local space ?
  37296. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  37297. * Default : false
  37298. */
  37299. translateFromPivot: boolean;
  37300. /**
  37301. * Is the particle active or not ?
  37302. */
  37303. alive: boolean;
  37304. /**
  37305. * Is the particle visible or not ?
  37306. */
  37307. isVisible: boolean;
  37308. /**
  37309. * Index of this particle in the global "positions" array (Internal use)
  37310. * @hidden
  37311. */
  37312. _pos: number;
  37313. /**
  37314. * @hidden Index of this particle in the global "indices" array (Internal use)
  37315. */
  37316. _ind: number;
  37317. /**
  37318. * @hidden ModelShape of this particle (Internal use)
  37319. */
  37320. _model: ModelShape;
  37321. /**
  37322. * ModelShape id of this particle
  37323. */
  37324. shapeId: number;
  37325. /**
  37326. * Index of the particle in its shape id
  37327. */
  37328. idxInShape: number;
  37329. /**
  37330. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  37331. */
  37332. _modelBoundingInfo: BoundingInfo;
  37333. /**
  37334. * @hidden Particle BoundingInfo object (Internal use)
  37335. */
  37336. _boundingInfo: BoundingInfo;
  37337. /**
  37338. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  37339. */
  37340. _sps: SolidParticleSystem;
  37341. /**
  37342. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  37343. */
  37344. _stillInvisible: boolean;
  37345. /**
  37346. * @hidden Last computed particle rotation matrix
  37347. */
  37348. _rotationMatrix: number[];
  37349. /**
  37350. * Parent particle Id, if any.
  37351. * Default null.
  37352. */
  37353. parentId: Nullable<number>;
  37354. /**
  37355. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  37356. */
  37357. materialIndex: Nullable<number>;
  37358. /**
  37359. * Custom object or properties.
  37360. */
  37361. props: Nullable<any>;
  37362. /**
  37363. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  37364. * The possible values are :
  37365. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  37366. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37367. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  37368. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  37369. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37370. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  37371. * */
  37372. cullingStrategy: number;
  37373. /**
  37374. * @hidden Internal global position in the SPS.
  37375. */
  37376. _globalPosition: Vector3;
  37377. /**
  37378. * Creates a Solid Particle object.
  37379. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  37380. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  37381. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  37382. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  37383. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  37384. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  37385. * @param shapeId (integer) is the model shape identifier in the SPS.
  37386. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  37387. * @param sps defines the sps it is associated to
  37388. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  37389. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  37390. */
  37391. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  37392. /**
  37393. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  37394. * @param target the particle target
  37395. * @returns the current particle
  37396. */
  37397. copyToRef(target: SolidParticle): SolidParticle;
  37398. /**
  37399. * Legacy support, changed scale to scaling
  37400. */
  37401. get scale(): Vector3;
  37402. /**
  37403. * Legacy support, changed scale to scaling
  37404. */
  37405. set scale(scale: Vector3);
  37406. /**
  37407. * Legacy support, changed quaternion to rotationQuaternion
  37408. */
  37409. get quaternion(): Nullable<Quaternion>;
  37410. /**
  37411. * Legacy support, changed quaternion to rotationQuaternion
  37412. */
  37413. set quaternion(q: Nullable<Quaternion>);
  37414. /**
  37415. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  37416. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  37417. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  37418. * @returns true if it intersects
  37419. */
  37420. intersectsMesh(target: Mesh | SolidParticle): boolean;
  37421. /**
  37422. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  37423. * A particle is in the frustum if its bounding box intersects the frustum
  37424. * @param frustumPlanes defines the frustum to test
  37425. * @returns true if the particle is in the frustum planes
  37426. */
  37427. isInFrustum(frustumPlanes: Plane[]): boolean;
  37428. /**
  37429. * get the rotation matrix of the particle
  37430. * @hidden
  37431. */
  37432. getRotationMatrix(m: Matrix): void;
  37433. }
  37434. /**
  37435. * Represents the shape of the model used by one particle of a solid particle system.
  37436. * SPS internal tool, don't use it manually.
  37437. */
  37438. export class ModelShape {
  37439. /**
  37440. * The shape id
  37441. * @hidden
  37442. */
  37443. shapeID: number;
  37444. /**
  37445. * flat array of model positions (internal use)
  37446. * @hidden
  37447. */
  37448. _shape: Vector3[];
  37449. /**
  37450. * flat array of model UVs (internal use)
  37451. * @hidden
  37452. */
  37453. _shapeUV: number[];
  37454. /**
  37455. * color array of the model
  37456. * @hidden
  37457. */
  37458. _shapeColors: number[];
  37459. /**
  37460. * indices array of the model
  37461. * @hidden
  37462. */
  37463. _indices: number[];
  37464. /**
  37465. * normals array of the model
  37466. * @hidden
  37467. */
  37468. _normals: number[];
  37469. /**
  37470. * length of the shape in the model indices array (internal use)
  37471. * @hidden
  37472. */
  37473. _indicesLength: number;
  37474. /**
  37475. * Custom position function (internal use)
  37476. * @hidden
  37477. */
  37478. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  37479. /**
  37480. * Custom vertex function (internal use)
  37481. * @hidden
  37482. */
  37483. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  37484. /**
  37485. * Model material (internal use)
  37486. * @hidden
  37487. */
  37488. _material: Nullable<Material>;
  37489. /**
  37490. * 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.
  37491. * SPS internal tool, don't use it manually.
  37492. * @hidden
  37493. */
  37494. 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>);
  37495. }
  37496. /**
  37497. * Represents a Depth Sorted Particle in the solid particle system.
  37498. * @hidden
  37499. */
  37500. export class DepthSortedParticle {
  37501. /**
  37502. * Particle index
  37503. */
  37504. idx: number;
  37505. /**
  37506. * Index of the particle in the "indices" array
  37507. */
  37508. ind: number;
  37509. /**
  37510. * Length of the particle shape in the "indices" array
  37511. */
  37512. indicesLength: number;
  37513. /**
  37514. * Squared distance from the particle to the camera
  37515. */
  37516. sqDistance: number;
  37517. /**
  37518. * Material index when used with MultiMaterials
  37519. */
  37520. materialIndex: number;
  37521. /**
  37522. * Creates a new sorted particle
  37523. * @param materialIndex
  37524. */
  37525. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  37526. }
  37527. /**
  37528. * Represents a solid particle vertex
  37529. */
  37530. export class SolidParticleVertex {
  37531. /**
  37532. * Vertex position
  37533. */
  37534. position: Vector3;
  37535. /**
  37536. * Vertex color
  37537. */
  37538. color: Color4;
  37539. /**
  37540. * Vertex UV
  37541. */
  37542. uv: Vector2;
  37543. /**
  37544. * Creates a new solid particle vertex
  37545. */
  37546. constructor();
  37547. /** Vertex x coordinate */
  37548. get x(): number;
  37549. set x(val: number);
  37550. /** Vertex y coordinate */
  37551. get y(): number;
  37552. set y(val: number);
  37553. /** Vertex z coordinate */
  37554. get z(): number;
  37555. set z(val: number);
  37556. }
  37557. }
  37558. declare module "babylonjs/Collisions/meshCollisionData" {
  37559. import { Collider } from "babylonjs/Collisions/collider";
  37560. import { Vector3 } from "babylonjs/Maths/math.vector";
  37561. import { Nullable } from "babylonjs/types";
  37562. import { Observer } from "babylonjs/Misc/observable";
  37563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37564. /**
  37565. * @hidden
  37566. */
  37567. export class _MeshCollisionData {
  37568. _checkCollisions: boolean;
  37569. _collisionMask: number;
  37570. _collisionGroup: number;
  37571. _surroundingMeshes: Nullable<AbstractMesh[]>;
  37572. _collider: Nullable<Collider>;
  37573. _oldPositionForCollisions: Vector3;
  37574. _diffPositionForCollisions: Vector3;
  37575. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  37576. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  37577. _collisionResponse: boolean;
  37578. }
  37579. }
  37580. declare module "babylonjs/Meshes/abstractMesh" {
  37581. import { Observable } from "babylonjs/Misc/observable";
  37582. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  37583. import { Camera } from "babylonjs/Cameras/camera";
  37584. import { Scene, IDisposable } from "babylonjs/scene";
  37585. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37586. import { Node } from "babylonjs/node";
  37587. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  37588. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37589. import { SubMesh } from "babylonjs/Meshes/subMesh";
  37590. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  37591. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  37592. import { Material } from "babylonjs/Materials/material";
  37593. import { Light } from "babylonjs/Lights/light";
  37594. import { Skeleton } from "babylonjs/Bones/skeleton";
  37595. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  37596. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  37597. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37598. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  37599. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  37600. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37601. import { Plane } from "babylonjs/Maths/math.plane";
  37602. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37603. import { Ray } from "babylonjs/Culling/ray";
  37604. import { Collider } from "babylonjs/Collisions/collider";
  37605. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  37606. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  37607. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  37608. /** @hidden */
  37609. class _FacetDataStorage {
  37610. facetPositions: Vector3[];
  37611. facetNormals: Vector3[];
  37612. facetPartitioning: number[][];
  37613. facetNb: number;
  37614. partitioningSubdivisions: number;
  37615. partitioningBBoxRatio: number;
  37616. facetDataEnabled: boolean;
  37617. facetParameters: any;
  37618. bbSize: Vector3;
  37619. subDiv: {
  37620. max: number;
  37621. X: number;
  37622. Y: number;
  37623. Z: number;
  37624. };
  37625. facetDepthSort: boolean;
  37626. facetDepthSortEnabled: boolean;
  37627. depthSortedIndices: IndicesArray;
  37628. depthSortedFacets: {
  37629. ind: number;
  37630. sqDistance: number;
  37631. }[];
  37632. facetDepthSortFunction: (f1: {
  37633. ind: number;
  37634. sqDistance: number;
  37635. }, f2: {
  37636. ind: number;
  37637. sqDistance: number;
  37638. }) => number;
  37639. facetDepthSortFrom: Vector3;
  37640. facetDepthSortOrigin: Vector3;
  37641. invertedMatrix: Matrix;
  37642. }
  37643. /**
  37644. * @hidden
  37645. **/
  37646. class _InternalAbstractMeshDataInfo {
  37647. _hasVertexAlpha: boolean;
  37648. _useVertexColors: boolean;
  37649. _numBoneInfluencers: number;
  37650. _applyFog: boolean;
  37651. _receiveShadows: boolean;
  37652. _facetData: _FacetDataStorage;
  37653. _visibility: number;
  37654. _skeleton: Nullable<Skeleton>;
  37655. _layerMask: number;
  37656. _computeBonesUsingShaders: boolean;
  37657. _isActive: boolean;
  37658. _onlyForInstances: boolean;
  37659. _isActiveIntermediate: boolean;
  37660. _onlyForInstancesIntermediate: boolean;
  37661. _actAsRegularMesh: boolean;
  37662. _currentLOD: Nullable<AbstractMesh>;
  37663. _currentLODIsUpToDate: boolean;
  37664. }
  37665. /**
  37666. * Class used to store all common mesh properties
  37667. */
  37668. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  37669. /** No occlusion */
  37670. static OCCLUSION_TYPE_NONE: number;
  37671. /** Occlusion set to optimistic */
  37672. static OCCLUSION_TYPE_OPTIMISTIC: number;
  37673. /** Occlusion set to strict */
  37674. static OCCLUSION_TYPE_STRICT: number;
  37675. /** Use an accurate occlusion algorithm */
  37676. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  37677. /** Use a conservative occlusion algorithm */
  37678. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  37679. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  37680. * Test order :
  37681. * Is the bounding sphere outside the frustum ?
  37682. * If not, are the bounding box vertices outside the frustum ?
  37683. * It not, then the cullable object is in the frustum.
  37684. */
  37685. static readonly CULLINGSTRATEGY_STANDARD: number;
  37686. /** Culling strategy : Bounding Sphere Only.
  37687. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  37688. * It's also less accurate than the standard because some not visible objects can still be selected.
  37689. * Test : is the bounding sphere outside the frustum ?
  37690. * If not, then the cullable object is in the frustum.
  37691. */
  37692. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  37693. /** Culling strategy : Optimistic Inclusion.
  37694. * This in an inclusion test first, then the standard exclusion test.
  37695. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  37696. * 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.
  37697. * Anyway, it's as accurate as the standard strategy.
  37698. * Test :
  37699. * Is the cullable object bounding sphere center in the frustum ?
  37700. * If not, apply the default culling strategy.
  37701. */
  37702. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  37703. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  37704. * This in an inclusion test first, then the bounding sphere only exclusion test.
  37705. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  37706. * 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.
  37707. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  37708. * Test :
  37709. * Is the cullable object bounding sphere center in the frustum ?
  37710. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  37711. */
  37712. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  37713. /**
  37714. * No billboard
  37715. */
  37716. static get BILLBOARDMODE_NONE(): number;
  37717. /** Billboard on X axis */
  37718. static get BILLBOARDMODE_X(): number;
  37719. /** Billboard on Y axis */
  37720. static get BILLBOARDMODE_Y(): number;
  37721. /** Billboard on Z axis */
  37722. static get BILLBOARDMODE_Z(): number;
  37723. /** Billboard on all axes */
  37724. static get BILLBOARDMODE_ALL(): number;
  37725. /** Billboard on using position instead of orientation */
  37726. static get BILLBOARDMODE_USE_POSITION(): number;
  37727. /** @hidden */
  37728. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  37729. /**
  37730. * The culling strategy to use to check whether the mesh must be rendered or not.
  37731. * This value can be changed at any time and will be used on the next render mesh selection.
  37732. * The possible values are :
  37733. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  37734. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37735. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  37736. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  37737. * Please read each static variable documentation to get details about the culling process.
  37738. * */
  37739. cullingStrategy: number;
  37740. /**
  37741. * Gets the number of facets in the mesh
  37742. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37743. */
  37744. get facetNb(): number;
  37745. /**
  37746. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  37747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37748. */
  37749. get partitioningSubdivisions(): number;
  37750. set partitioningSubdivisions(nb: number);
  37751. /**
  37752. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  37753. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  37754. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37755. */
  37756. get partitioningBBoxRatio(): number;
  37757. set partitioningBBoxRatio(ratio: number);
  37758. /**
  37759. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  37760. * Works only for updatable meshes.
  37761. * Doesn't work with multi-materials
  37762. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37763. */
  37764. get mustDepthSortFacets(): boolean;
  37765. set mustDepthSortFacets(sort: boolean);
  37766. /**
  37767. * The location (Vector3) where the facet depth sort must be computed from.
  37768. * By default, the active camera position.
  37769. * Used only when facet depth sort is enabled
  37770. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37771. */
  37772. get facetDepthSortFrom(): Vector3;
  37773. set facetDepthSortFrom(location: Vector3);
  37774. /**
  37775. * gets a boolean indicating if facetData is enabled
  37776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37777. */
  37778. get isFacetDataEnabled(): boolean;
  37779. /** @hidden */
  37780. _updateNonUniformScalingState(value: boolean): boolean;
  37781. /**
  37782. * An event triggered when this mesh collides with another one
  37783. */
  37784. onCollideObservable: Observable<AbstractMesh>;
  37785. /** Set a function to call when this mesh collides with another one */
  37786. set onCollide(callback: () => void);
  37787. /**
  37788. * An event triggered when the collision's position changes
  37789. */
  37790. onCollisionPositionChangeObservable: Observable<Vector3>;
  37791. /** Set a function to call when the collision's position changes */
  37792. set onCollisionPositionChange(callback: () => void);
  37793. /**
  37794. * An event triggered when material is changed
  37795. */
  37796. onMaterialChangedObservable: Observable<AbstractMesh>;
  37797. /**
  37798. * Gets or sets the orientation for POV movement & rotation
  37799. */
  37800. definedFacingForward: boolean;
  37801. /** @hidden */
  37802. _occlusionQuery: Nullable<WebGLQuery>;
  37803. /** @hidden */
  37804. _renderingGroup: Nullable<RenderingGroup>;
  37805. /**
  37806. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37807. */
  37808. get visibility(): number;
  37809. /**
  37810. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37811. */
  37812. set visibility(value: number);
  37813. /** Gets or sets the alpha index used to sort transparent meshes
  37814. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  37815. */
  37816. alphaIndex: number;
  37817. /**
  37818. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  37819. */
  37820. isVisible: boolean;
  37821. /**
  37822. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37823. */
  37824. isPickable: boolean;
  37825. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  37826. showSubMeshesBoundingBox: boolean;
  37827. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  37828. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  37829. */
  37830. isBlocker: boolean;
  37831. /**
  37832. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  37833. */
  37834. enablePointerMoveEvents: boolean;
  37835. private _renderingGroupId;
  37836. /**
  37837. * Specifies the rendering group id for this mesh (0 by default)
  37838. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37839. */
  37840. get renderingGroupId(): number;
  37841. set renderingGroupId(value: number);
  37842. private _material;
  37843. /** Gets or sets current material */
  37844. get material(): Nullable<Material>;
  37845. set material(value: Nullable<Material>);
  37846. /**
  37847. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  37848. * @see https://doc.babylonjs.com/babylon101/shadows
  37849. */
  37850. get receiveShadows(): boolean;
  37851. set receiveShadows(value: boolean);
  37852. /** Defines color to use when rendering outline */
  37853. outlineColor: Color3;
  37854. /** Define width to use when rendering outline */
  37855. outlineWidth: number;
  37856. /** Defines color to use when rendering overlay */
  37857. overlayColor: Color3;
  37858. /** Defines alpha to use when rendering overlay */
  37859. overlayAlpha: number;
  37860. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  37861. get hasVertexAlpha(): boolean;
  37862. set hasVertexAlpha(value: boolean);
  37863. /** 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) */
  37864. get useVertexColors(): boolean;
  37865. set useVertexColors(value: boolean);
  37866. /**
  37867. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  37868. */
  37869. get computeBonesUsingShaders(): boolean;
  37870. set computeBonesUsingShaders(value: boolean);
  37871. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  37872. get numBoneInfluencers(): number;
  37873. set numBoneInfluencers(value: number);
  37874. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  37875. get applyFog(): boolean;
  37876. set applyFog(value: boolean);
  37877. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  37878. useOctreeForRenderingSelection: boolean;
  37879. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  37880. useOctreeForPicking: boolean;
  37881. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  37882. useOctreeForCollisions: boolean;
  37883. /**
  37884. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  37885. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  37886. */
  37887. get layerMask(): number;
  37888. set layerMask(value: number);
  37889. /**
  37890. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  37891. */
  37892. alwaysSelectAsActiveMesh: boolean;
  37893. /**
  37894. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  37895. */
  37896. doNotSyncBoundingInfo: boolean;
  37897. /**
  37898. * Gets or sets the current action manager
  37899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37900. */
  37901. actionManager: Nullable<AbstractActionManager>;
  37902. private _meshCollisionData;
  37903. /**
  37904. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37905. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37906. */
  37907. ellipsoid: Vector3;
  37908. /**
  37909. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37910. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37911. */
  37912. ellipsoidOffset: Vector3;
  37913. /**
  37914. * Gets or sets a collision mask used to mask collisions (default is -1).
  37915. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37916. */
  37917. get collisionMask(): number;
  37918. set collisionMask(mask: number);
  37919. /**
  37920. * Gets or sets a collision response flag (default is true).
  37921. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37922. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37923. * to respond to the collision.
  37924. */
  37925. get collisionResponse(): boolean;
  37926. set collisionResponse(response: boolean);
  37927. /**
  37928. * Gets or sets the current collision group mask (-1 by default).
  37929. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37930. */
  37931. get collisionGroup(): number;
  37932. set collisionGroup(mask: number);
  37933. /**
  37934. * Gets or sets current surrounding meshes (null by default).
  37935. *
  37936. * By default collision detection is tested against every mesh in the scene.
  37937. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37938. * meshes will be tested for the collision.
  37939. *
  37940. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37941. */
  37942. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37943. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37944. /**
  37945. * Defines edge width used when edgesRenderer is enabled
  37946. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37947. */
  37948. edgesWidth: number;
  37949. /**
  37950. * Defines edge color used when edgesRenderer is enabled
  37951. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37952. */
  37953. edgesColor: Color4;
  37954. /** @hidden */
  37955. _edgesRenderer: Nullable<IEdgesRenderer>;
  37956. /** @hidden */
  37957. _masterMesh: Nullable<AbstractMesh>;
  37958. /** @hidden */
  37959. _boundingInfo: Nullable<BoundingInfo>;
  37960. /** @hidden */
  37961. _renderId: number;
  37962. /**
  37963. * Gets or sets the list of subMeshes
  37964. * @see https://doc.babylonjs.com/how_to/multi_materials
  37965. */
  37966. subMeshes: SubMesh[];
  37967. /** @hidden */
  37968. _intersectionsInProgress: AbstractMesh[];
  37969. /** @hidden */
  37970. _unIndexed: boolean;
  37971. /** @hidden */
  37972. _lightSources: Light[];
  37973. /** Gets the list of lights affecting that mesh */
  37974. get lightSources(): Light[];
  37975. /** @hidden */
  37976. get _positions(): Nullable<Vector3[]>;
  37977. /** @hidden */
  37978. _waitingData: {
  37979. lods: Nullable<any>;
  37980. actions: Nullable<any>;
  37981. freezeWorldMatrix: Nullable<boolean>;
  37982. };
  37983. /** @hidden */
  37984. _bonesTransformMatrices: Nullable<Float32Array>;
  37985. /** @hidden */
  37986. _transformMatrixTexture: Nullable<RawTexture>;
  37987. /**
  37988. * Gets or sets a skeleton to apply skinning transformations
  37989. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37990. */
  37991. set skeleton(value: Nullable<Skeleton>);
  37992. get skeleton(): Nullable<Skeleton>;
  37993. /**
  37994. * An event triggered when the mesh is rebuilt.
  37995. */
  37996. onRebuildObservable: Observable<AbstractMesh>;
  37997. /**
  37998. * The current mesh uniform buffer.
  37999. * @hidden Internal use only.
  38000. */
  38001. _uniformBuffer: UniformBuffer;
  38002. /**
  38003. * Creates a new AbstractMesh
  38004. * @param name defines the name of the mesh
  38005. * @param scene defines the hosting scene
  38006. */
  38007. constructor(name: string, scene?: Nullable<Scene>);
  38008. protected _buildUniformLayout(): void;
  38009. /**
  38010. * Transfer the mesh values to its UBO.
  38011. * @param world The world matrix associated with the mesh
  38012. */
  38013. transferToEffect(world: Matrix): void;
  38014. /**
  38015. * Gets the mesh uniform buffer.
  38016. * @return the uniform buffer of the mesh.
  38017. */
  38018. getMeshUniformBuffer(): UniformBuffer;
  38019. /**
  38020. * Returns the string "AbstractMesh"
  38021. * @returns "AbstractMesh"
  38022. */
  38023. getClassName(): string;
  38024. /**
  38025. * Gets a string representation of the current mesh
  38026. * @param fullDetails defines a boolean indicating if full details must be included
  38027. * @returns a string representation of the current mesh
  38028. */
  38029. toString(fullDetails?: boolean): string;
  38030. /**
  38031. * @hidden
  38032. */
  38033. protected _getEffectiveParent(): Nullable<Node>;
  38034. /** @hidden */
  38035. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38036. /** @hidden */
  38037. _rebuild(): void;
  38038. /** @hidden */
  38039. _resyncLightSources(): void;
  38040. /** @hidden */
  38041. _resyncLightSource(light: Light): void;
  38042. /** @hidden */
  38043. _unBindEffect(): void;
  38044. /** @hidden */
  38045. _removeLightSource(light: Light, dispose: boolean): void;
  38046. private _markSubMeshesAsDirty;
  38047. /** @hidden */
  38048. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  38049. /** @hidden */
  38050. _markSubMeshesAsAttributesDirty(): void;
  38051. /** @hidden */
  38052. _markSubMeshesAsMiscDirty(): void;
  38053. /**
  38054. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  38055. */
  38056. get scaling(): Vector3;
  38057. set scaling(newScaling: Vector3);
  38058. /**
  38059. * Returns true if the mesh is blocked. Implemented by child classes
  38060. */
  38061. get isBlocked(): boolean;
  38062. /**
  38063. * Returns the mesh itself by default. Implemented by child classes
  38064. * @param camera defines the camera to use to pick the right LOD level
  38065. * @returns the currentAbstractMesh
  38066. */
  38067. getLOD(camera: Camera): Nullable<AbstractMesh>;
  38068. /**
  38069. * Returns 0 by default. Implemented by child classes
  38070. * @returns an integer
  38071. */
  38072. getTotalVertices(): number;
  38073. /**
  38074. * Returns a positive integer : the total number of indices in this mesh geometry.
  38075. * @returns the number of indices or zero if the mesh has no geometry.
  38076. */
  38077. getTotalIndices(): number;
  38078. /**
  38079. * Returns null by default. Implemented by child classes
  38080. * @returns null
  38081. */
  38082. getIndices(): Nullable<IndicesArray>;
  38083. /**
  38084. * Returns the array of the requested vertex data kind. Implemented by child classes
  38085. * @param kind defines the vertex data kind to use
  38086. * @returns null
  38087. */
  38088. getVerticesData(kind: string): Nullable<FloatArray>;
  38089. /**
  38090. * Sets the vertex data of the mesh geometry for the requested `kind`.
  38091. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  38092. * Note that a new underlying VertexBuffer object is created each call.
  38093. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  38094. * @param kind defines vertex data kind:
  38095. * * VertexBuffer.PositionKind
  38096. * * VertexBuffer.UVKind
  38097. * * VertexBuffer.UV2Kind
  38098. * * VertexBuffer.UV3Kind
  38099. * * VertexBuffer.UV4Kind
  38100. * * VertexBuffer.UV5Kind
  38101. * * VertexBuffer.UV6Kind
  38102. * * VertexBuffer.ColorKind
  38103. * * VertexBuffer.MatricesIndicesKind
  38104. * * VertexBuffer.MatricesIndicesExtraKind
  38105. * * VertexBuffer.MatricesWeightsKind
  38106. * * VertexBuffer.MatricesWeightsExtraKind
  38107. * @param data defines the data source
  38108. * @param updatable defines if the data must be flagged as updatable (or static)
  38109. * @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
  38110. * @returns the current mesh
  38111. */
  38112. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  38113. /**
  38114. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  38115. * If the mesh has no geometry, it is simply returned as it is.
  38116. * @param kind defines vertex data kind:
  38117. * * VertexBuffer.PositionKind
  38118. * * VertexBuffer.UVKind
  38119. * * VertexBuffer.UV2Kind
  38120. * * VertexBuffer.UV3Kind
  38121. * * VertexBuffer.UV4Kind
  38122. * * VertexBuffer.UV5Kind
  38123. * * VertexBuffer.UV6Kind
  38124. * * VertexBuffer.ColorKind
  38125. * * VertexBuffer.MatricesIndicesKind
  38126. * * VertexBuffer.MatricesIndicesExtraKind
  38127. * * VertexBuffer.MatricesWeightsKind
  38128. * * VertexBuffer.MatricesWeightsExtraKind
  38129. * @param data defines the data source
  38130. * @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
  38131. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  38132. * @returns the current mesh
  38133. */
  38134. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  38135. /**
  38136. * Sets the mesh indices,
  38137. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  38138. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  38139. * @param totalVertices Defines the total number of vertices
  38140. * @returns the current mesh
  38141. */
  38142. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  38143. /**
  38144. * Gets a boolean indicating if specific vertex data is present
  38145. * @param kind defines the vertex data kind to use
  38146. * @returns true is data kind is present
  38147. */
  38148. isVerticesDataPresent(kind: string): boolean;
  38149. /**
  38150. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  38151. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  38152. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  38153. * @returns a BoundingInfo
  38154. */
  38155. getBoundingInfo(): BoundingInfo;
  38156. /**
  38157. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  38158. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  38159. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  38160. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  38161. * @returns the current mesh
  38162. */
  38163. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  38164. /**
  38165. * Overwrite the current bounding info
  38166. * @param boundingInfo defines the new bounding info
  38167. * @returns the current mesh
  38168. */
  38169. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  38170. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  38171. get useBones(): boolean;
  38172. /** @hidden */
  38173. _preActivate(): void;
  38174. /** @hidden */
  38175. _preActivateForIntermediateRendering(renderId: number): void;
  38176. /** @hidden */
  38177. _activate(renderId: number, intermediateRendering: boolean): boolean;
  38178. /** @hidden */
  38179. _postActivate(): void;
  38180. /** @hidden */
  38181. _freeze(): void;
  38182. /** @hidden */
  38183. _unFreeze(): void;
  38184. /**
  38185. * Gets the current world matrix
  38186. * @returns a Matrix
  38187. */
  38188. getWorldMatrix(): Matrix;
  38189. /** @hidden */
  38190. _getWorldMatrixDeterminant(): number;
  38191. /**
  38192. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  38193. */
  38194. get isAnInstance(): boolean;
  38195. /**
  38196. * Gets a boolean indicating if this mesh has instances
  38197. */
  38198. get hasInstances(): boolean;
  38199. /**
  38200. * Gets a boolean indicating if this mesh has thin instances
  38201. */
  38202. get hasThinInstances(): boolean;
  38203. /**
  38204. * Perform relative position change from the point of view of behind the front of the mesh.
  38205. * This is performed taking into account the meshes current rotation, so you do not have to care.
  38206. * Supports definition of mesh facing forward or backward
  38207. * @param amountRight defines the distance on the right axis
  38208. * @param amountUp defines the distance on the up axis
  38209. * @param amountForward defines the distance on the forward axis
  38210. * @returns the current mesh
  38211. */
  38212. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  38213. /**
  38214. * Calculate relative position change from the point of view of behind the front of the mesh.
  38215. * This is performed taking into account the meshes current rotation, so you do not have to care.
  38216. * Supports definition of mesh facing forward or backward
  38217. * @param amountRight defines the distance on the right axis
  38218. * @param amountUp defines the distance on the up axis
  38219. * @param amountForward defines the distance on the forward axis
  38220. * @returns the new displacement vector
  38221. */
  38222. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  38223. /**
  38224. * Perform relative rotation change from the point of view of behind the front of the mesh.
  38225. * Supports definition of mesh facing forward or backward
  38226. * @param flipBack defines the flip
  38227. * @param twirlClockwise defines the twirl
  38228. * @param tiltRight defines the tilt
  38229. * @returns the current mesh
  38230. */
  38231. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  38232. /**
  38233. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  38234. * Supports definition of mesh facing forward or backward.
  38235. * @param flipBack defines the flip
  38236. * @param twirlClockwise defines the twirl
  38237. * @param tiltRight defines the tilt
  38238. * @returns the new rotation vector
  38239. */
  38240. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  38241. /**
  38242. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  38243. * This means the mesh underlying bounding box and sphere are recomputed.
  38244. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  38245. * @returns the current mesh
  38246. */
  38247. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  38248. /** @hidden */
  38249. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  38250. /** @hidden */
  38251. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  38252. /** @hidden */
  38253. _updateBoundingInfo(): AbstractMesh;
  38254. /** @hidden */
  38255. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  38256. /** @hidden */
  38257. protected _afterComputeWorldMatrix(): void;
  38258. /** @hidden */
  38259. get _effectiveMesh(): AbstractMesh;
  38260. /**
  38261. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  38262. * A mesh is in the frustum if its bounding box intersects the frustum
  38263. * @param frustumPlanes defines the frustum to test
  38264. * @returns true if the mesh is in the frustum planes
  38265. */
  38266. isInFrustum(frustumPlanes: Plane[]): boolean;
  38267. /**
  38268. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  38269. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  38270. * @param frustumPlanes defines the frustum to test
  38271. * @returns true if the mesh is completely in the frustum planes
  38272. */
  38273. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  38274. /**
  38275. * True if the mesh intersects another mesh or a SolidParticle object
  38276. * @param mesh defines a target mesh or SolidParticle to test
  38277. * @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)
  38278. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  38279. * @returns true if there is an intersection
  38280. */
  38281. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  38282. /**
  38283. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  38284. * @param point defines the point to test
  38285. * @returns true if there is an intersection
  38286. */
  38287. intersectsPoint(point: Vector3): boolean;
  38288. /**
  38289. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  38290. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38291. */
  38292. get checkCollisions(): boolean;
  38293. set checkCollisions(collisionEnabled: boolean);
  38294. /**
  38295. * Gets Collider object used to compute collisions (not physics)
  38296. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38297. */
  38298. get collider(): Nullable<Collider>;
  38299. /**
  38300. * Move the mesh using collision engine
  38301. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38302. * @param displacement defines the requested displacement vector
  38303. * @returns the current mesh
  38304. */
  38305. moveWithCollisions(displacement: Vector3): AbstractMesh;
  38306. private _onCollisionPositionChange;
  38307. /** @hidden */
  38308. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  38309. /** @hidden */
  38310. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  38311. /** @hidden */
  38312. _checkCollision(collider: Collider): AbstractMesh;
  38313. /** @hidden */
  38314. _generatePointsArray(): boolean;
  38315. /**
  38316. * Checks if the passed Ray intersects with the mesh
  38317. * @param ray defines the ray to use
  38318. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  38319. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38320. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  38321. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  38322. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  38323. * @returns the picking info
  38324. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  38325. */
  38326. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  38327. /**
  38328. * Clones the current mesh
  38329. * @param name defines the mesh name
  38330. * @param newParent defines the new mesh parent
  38331. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  38332. * @returns the new mesh
  38333. */
  38334. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  38335. /**
  38336. * Disposes all the submeshes of the current meshnp
  38337. * @returns the current mesh
  38338. */
  38339. releaseSubMeshes(): AbstractMesh;
  38340. /**
  38341. * Releases resources associated with this abstract mesh.
  38342. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38343. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38344. */
  38345. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38346. /**
  38347. * Adds the passed mesh as a child to the current mesh
  38348. * @param mesh defines the child mesh
  38349. * @returns the current mesh
  38350. */
  38351. addChild(mesh: AbstractMesh): AbstractMesh;
  38352. /**
  38353. * Removes the passed mesh from the current mesh children list
  38354. * @param mesh defines the child mesh
  38355. * @returns the current mesh
  38356. */
  38357. removeChild(mesh: AbstractMesh): AbstractMesh;
  38358. /** @hidden */
  38359. private _initFacetData;
  38360. /**
  38361. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  38362. * This method can be called within the render loop.
  38363. * 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
  38364. * @returns the current mesh
  38365. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38366. */
  38367. updateFacetData(): AbstractMesh;
  38368. /**
  38369. * Returns the facetLocalNormals array.
  38370. * The normals are expressed in the mesh local spac
  38371. * @returns an array of Vector3
  38372. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38373. */
  38374. getFacetLocalNormals(): Vector3[];
  38375. /**
  38376. * Returns the facetLocalPositions array.
  38377. * The facet positions are expressed in the mesh local space
  38378. * @returns an array of Vector3
  38379. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38380. */
  38381. getFacetLocalPositions(): Vector3[];
  38382. /**
  38383. * Returns the facetLocalPartitioning array
  38384. * @returns an array of array of numbers
  38385. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38386. */
  38387. getFacetLocalPartitioning(): number[][];
  38388. /**
  38389. * Returns the i-th facet position in the world system.
  38390. * This method allocates a new Vector3 per call
  38391. * @param i defines the facet index
  38392. * @returns a new Vector3
  38393. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38394. */
  38395. getFacetPosition(i: number): Vector3;
  38396. /**
  38397. * Sets the reference Vector3 with the i-th facet position in the world system
  38398. * @param i defines the facet index
  38399. * @param ref defines the target vector
  38400. * @returns the current mesh
  38401. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38402. */
  38403. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  38404. /**
  38405. * Returns the i-th facet normal in the world system.
  38406. * This method allocates a new Vector3 per call
  38407. * @param i defines the facet index
  38408. * @returns a new Vector3
  38409. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38410. */
  38411. getFacetNormal(i: number): Vector3;
  38412. /**
  38413. * Sets the reference Vector3 with the i-th facet normal in the world system
  38414. * @param i defines the facet index
  38415. * @param ref defines the target vector
  38416. * @returns the current mesh
  38417. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38418. */
  38419. getFacetNormalToRef(i: number, ref: Vector3): this;
  38420. /**
  38421. * 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)
  38422. * @param x defines x coordinate
  38423. * @param y defines y coordinate
  38424. * @param z defines z coordinate
  38425. * @returns the array of facet indexes
  38426. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38427. */
  38428. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  38429. /**
  38430. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  38431. * @param projected sets as the (x,y,z) world projection on the facet
  38432. * @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
  38433. * @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
  38434. * @param x defines x coordinate
  38435. * @param y defines y coordinate
  38436. * @param z defines z coordinate
  38437. * @returns the face index if found (or null instead)
  38438. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38439. */
  38440. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38441. /**
  38442. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  38443. * @param projected sets as the (x,y,z) local projection on the facet
  38444. * @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
  38445. * @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
  38446. * @param x defines x coordinate
  38447. * @param y defines y coordinate
  38448. * @param z defines z coordinate
  38449. * @returns the face index if found (or null instead)
  38450. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38451. */
  38452. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38453. /**
  38454. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  38455. * @returns the parameters
  38456. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38457. */
  38458. getFacetDataParameters(): any;
  38459. /**
  38460. * Disables the feature FacetData and frees the related memory
  38461. * @returns the current mesh
  38462. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38463. */
  38464. disableFacetData(): AbstractMesh;
  38465. /**
  38466. * Updates the AbstractMesh indices array
  38467. * @param indices defines the data source
  38468. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  38469. * @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)
  38470. * @returns the current mesh
  38471. */
  38472. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  38473. /**
  38474. * Creates new normals data for the mesh
  38475. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  38476. * @returns the current mesh
  38477. */
  38478. createNormals(updatable: boolean): AbstractMesh;
  38479. /**
  38480. * Align the mesh with a normal
  38481. * @param normal defines the normal to use
  38482. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  38483. * @returns the current mesh
  38484. */
  38485. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  38486. /** @hidden */
  38487. _checkOcclusionQuery(): boolean;
  38488. /**
  38489. * Disables the mesh edge rendering mode
  38490. * @returns the currentAbstractMesh
  38491. */
  38492. disableEdgesRendering(): AbstractMesh;
  38493. /**
  38494. * Enables the edge rendering mode on the mesh.
  38495. * This mode makes the mesh edges visible
  38496. * @param epsilon defines the maximal distance between two angles to detect a face
  38497. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  38498. * @param options options to the edge renderer
  38499. * @returns the currentAbstractMesh
  38500. * @see https://www.babylonjs-playground.com/#19O9TU#0
  38501. */
  38502. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  38503. /**
  38504. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  38505. * @returns an array of particle systems in the scene that use the mesh as an emitter
  38506. */
  38507. getConnectedParticleSystems(): IParticleSystem[];
  38508. }
  38509. }
  38510. declare module "babylonjs/Actions/actionEvent" {
  38511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38512. import { Nullable } from "babylonjs/types";
  38513. import { Sprite } from "babylonjs/Sprites/sprite";
  38514. import { Scene } from "babylonjs/scene";
  38515. import { Vector2 } from "babylonjs/Maths/math.vector";
  38516. /**
  38517. * Interface used to define ActionEvent
  38518. */
  38519. export interface IActionEvent {
  38520. /** The mesh or sprite that triggered the action */
  38521. source: any;
  38522. /** The X mouse cursor position at the time of the event */
  38523. pointerX: number;
  38524. /** The Y mouse cursor position at the time of the event */
  38525. pointerY: number;
  38526. /** The mesh that is currently pointed at (can be null) */
  38527. meshUnderPointer: Nullable<AbstractMesh>;
  38528. /** the original (browser) event that triggered the ActionEvent */
  38529. sourceEvent?: any;
  38530. /** additional data for the event */
  38531. additionalData?: any;
  38532. }
  38533. /**
  38534. * ActionEvent is the event being sent when an action is triggered.
  38535. */
  38536. export class ActionEvent implements IActionEvent {
  38537. /** The mesh or sprite that triggered the action */
  38538. source: any;
  38539. /** The X mouse cursor position at the time of the event */
  38540. pointerX: number;
  38541. /** The Y mouse cursor position at the time of the event */
  38542. pointerY: number;
  38543. /** The mesh that is currently pointed at (can be null) */
  38544. meshUnderPointer: Nullable<AbstractMesh>;
  38545. /** the original (browser) event that triggered the ActionEvent */
  38546. sourceEvent?: any;
  38547. /** additional data for the event */
  38548. additionalData?: any;
  38549. /**
  38550. * Creates a new ActionEvent
  38551. * @param source The mesh or sprite that triggered the action
  38552. * @param pointerX The X mouse cursor position at the time of the event
  38553. * @param pointerY The Y mouse cursor position at the time of the event
  38554. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  38555. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  38556. * @param additionalData additional data for the event
  38557. */
  38558. constructor(
  38559. /** The mesh or sprite that triggered the action */
  38560. source: any,
  38561. /** The X mouse cursor position at the time of the event */
  38562. pointerX: number,
  38563. /** The Y mouse cursor position at the time of the event */
  38564. pointerY: number,
  38565. /** The mesh that is currently pointed at (can be null) */
  38566. meshUnderPointer: Nullable<AbstractMesh>,
  38567. /** the original (browser) event that triggered the ActionEvent */
  38568. sourceEvent?: any,
  38569. /** additional data for the event */
  38570. additionalData?: any);
  38571. /**
  38572. * Helper function to auto-create an ActionEvent from a source mesh.
  38573. * @param source The source mesh that triggered the event
  38574. * @param evt The original (browser) event
  38575. * @param additionalData additional data for the event
  38576. * @returns the new ActionEvent
  38577. */
  38578. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  38579. /**
  38580. * Helper function to auto-create an ActionEvent from a source sprite
  38581. * @param source The source sprite that triggered the event
  38582. * @param scene Scene associated with the sprite
  38583. * @param evt The original (browser) event
  38584. * @param additionalData additional data for the event
  38585. * @returns the new ActionEvent
  38586. */
  38587. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  38588. /**
  38589. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  38590. * @param scene the scene where the event occurred
  38591. * @param evt The original (browser) event
  38592. * @returns the new ActionEvent
  38593. */
  38594. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  38595. /**
  38596. * Helper function to auto-create an ActionEvent from a primitive
  38597. * @param prim defines the target primitive
  38598. * @param pointerPos defines the pointer position
  38599. * @param evt The original (browser) event
  38600. * @param additionalData additional data for the event
  38601. * @returns the new ActionEvent
  38602. */
  38603. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  38604. }
  38605. }
  38606. declare module "babylonjs/Actions/abstractActionManager" {
  38607. import { IDisposable } from "babylonjs/scene";
  38608. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  38609. import { IAction } from "babylonjs/Actions/action";
  38610. import { Nullable } from "babylonjs/types";
  38611. /**
  38612. * Abstract class used to decouple action Manager from scene and meshes.
  38613. * Do not instantiate.
  38614. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  38615. */
  38616. export abstract class AbstractActionManager implements IDisposable {
  38617. /** Gets the list of active triggers */
  38618. static Triggers: {
  38619. [key: string]: number;
  38620. };
  38621. /** Gets the cursor to use when hovering items */
  38622. hoverCursor: string;
  38623. /** Gets the list of actions */
  38624. actions: IAction[];
  38625. /**
  38626. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  38627. */
  38628. isRecursive: boolean;
  38629. /**
  38630. * Releases all associated resources
  38631. */
  38632. abstract dispose(): void;
  38633. /**
  38634. * Does this action manager has pointer triggers
  38635. */
  38636. abstract get hasPointerTriggers(): boolean;
  38637. /**
  38638. * Does this action manager has pick triggers
  38639. */
  38640. abstract get hasPickTriggers(): boolean;
  38641. /**
  38642. * Process a specific trigger
  38643. * @param trigger defines the trigger to process
  38644. * @param evt defines the event details to be processed
  38645. */
  38646. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  38647. /**
  38648. * Does this action manager handles actions of any of the given triggers
  38649. * @param triggers defines the triggers to be tested
  38650. * @return a boolean indicating whether one (or more) of the triggers is handled
  38651. */
  38652. abstract hasSpecificTriggers(triggers: number[]): boolean;
  38653. /**
  38654. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  38655. * speed.
  38656. * @param triggerA defines the trigger to be tested
  38657. * @param triggerB defines the trigger to be tested
  38658. * @return a boolean indicating whether one (or more) of the triggers is handled
  38659. */
  38660. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  38661. /**
  38662. * Does this action manager handles actions of a given trigger
  38663. * @param trigger defines the trigger to be tested
  38664. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  38665. * @return whether the trigger is handled
  38666. */
  38667. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  38668. /**
  38669. * Serialize this manager to a JSON object
  38670. * @param name defines the property name to store this manager
  38671. * @returns a JSON representation of this manager
  38672. */
  38673. abstract serialize(name: string): any;
  38674. /**
  38675. * Registers an action to this action manager
  38676. * @param action defines the action to be registered
  38677. * @return the action amended (prepared) after registration
  38678. */
  38679. abstract registerAction(action: IAction): Nullable<IAction>;
  38680. /**
  38681. * Unregisters an action to this action manager
  38682. * @param action defines the action to be unregistered
  38683. * @return a boolean indicating whether the action has been unregistered
  38684. */
  38685. abstract unregisterAction(action: IAction): Boolean;
  38686. /**
  38687. * Does exist one action manager with at least one trigger
  38688. **/
  38689. static get HasTriggers(): boolean;
  38690. /**
  38691. * Does exist one action manager with at least one pick trigger
  38692. **/
  38693. static get HasPickTriggers(): boolean;
  38694. /**
  38695. * Does exist one action manager that handles actions of a given trigger
  38696. * @param trigger defines the trigger to be tested
  38697. * @return a boolean indicating whether the trigger is handled by at least one action manager
  38698. **/
  38699. static HasSpecificTrigger(trigger: number): boolean;
  38700. }
  38701. }
  38702. declare module "babylonjs/node" {
  38703. import { Scene } from "babylonjs/scene";
  38704. import { Nullable } from "babylonjs/types";
  38705. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  38706. import { Engine } from "babylonjs/Engines/engine";
  38707. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  38708. import { Observable } from "babylonjs/Misc/observable";
  38709. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38710. import { IInspectable } from "babylonjs/Misc/iInspectable";
  38711. import { Animatable } from "babylonjs/Animations/animatable";
  38712. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  38713. import { Animation } from "babylonjs/Animations/animation";
  38714. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38716. /**
  38717. * Defines how a node can be built from a string name.
  38718. */
  38719. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  38720. /**
  38721. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  38722. */
  38723. export class Node implements IBehaviorAware<Node> {
  38724. /** @hidden */
  38725. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  38726. private static _NodeConstructors;
  38727. /**
  38728. * Add a new node constructor
  38729. * @param type defines the type name of the node to construct
  38730. * @param constructorFunc defines the constructor function
  38731. */
  38732. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  38733. /**
  38734. * Returns a node constructor based on type name
  38735. * @param type defines the type name
  38736. * @param name defines the new node name
  38737. * @param scene defines the hosting scene
  38738. * @param options defines optional options to transmit to constructors
  38739. * @returns the new constructor or null
  38740. */
  38741. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  38742. /**
  38743. * Gets or sets the name of the node
  38744. */
  38745. name: string;
  38746. /**
  38747. * Gets or sets the id of the node
  38748. */
  38749. id: string;
  38750. /**
  38751. * Gets or sets the unique id of the node
  38752. */
  38753. uniqueId: number;
  38754. /**
  38755. * Gets or sets a string used to store user defined state for the node
  38756. */
  38757. state: string;
  38758. /**
  38759. * Gets or sets an object used to store user defined information for the node
  38760. */
  38761. metadata: any;
  38762. /**
  38763. * For internal use only. Please do not use.
  38764. */
  38765. reservedDataStore: any;
  38766. /**
  38767. * List of inspectable custom properties (used by the Inspector)
  38768. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  38769. */
  38770. inspectableCustomProperties: IInspectable[];
  38771. private _doNotSerialize;
  38772. /**
  38773. * Gets or sets a boolean used to define if the node must be serialized
  38774. */
  38775. get doNotSerialize(): boolean;
  38776. set doNotSerialize(value: boolean);
  38777. /** @hidden */
  38778. _isDisposed: boolean;
  38779. /**
  38780. * Gets a list of Animations associated with the node
  38781. */
  38782. animations: import("babylonjs/Animations/animation").Animation[];
  38783. protected _ranges: {
  38784. [name: string]: Nullable<AnimationRange>;
  38785. };
  38786. /**
  38787. * Callback raised when the node is ready to be used
  38788. */
  38789. onReady: Nullable<(node: Node) => void>;
  38790. private _isEnabled;
  38791. private _isParentEnabled;
  38792. private _isReady;
  38793. /** @hidden */
  38794. _currentRenderId: number;
  38795. private _parentUpdateId;
  38796. /** @hidden */
  38797. _childUpdateId: number;
  38798. /** @hidden */
  38799. _waitingParentId: Nullable<string>;
  38800. /** @hidden */
  38801. _scene: Scene;
  38802. /** @hidden */
  38803. _cache: any;
  38804. private _parentNode;
  38805. private _children;
  38806. /** @hidden */
  38807. _worldMatrix: Matrix;
  38808. /** @hidden */
  38809. _worldMatrixDeterminant: number;
  38810. /** @hidden */
  38811. _worldMatrixDeterminantIsDirty: boolean;
  38812. /** @hidden */
  38813. private _sceneRootNodesIndex;
  38814. /**
  38815. * Gets a boolean indicating if the node has been disposed
  38816. * @returns true if the node was disposed
  38817. */
  38818. isDisposed(): boolean;
  38819. /**
  38820. * Gets or sets the parent of the node (without keeping the current position in the scene)
  38821. * @see https://doc.babylonjs.com/how_to/parenting
  38822. */
  38823. set parent(parent: Nullable<Node>);
  38824. get parent(): Nullable<Node>;
  38825. /** @hidden */
  38826. _addToSceneRootNodes(): void;
  38827. /** @hidden */
  38828. _removeFromSceneRootNodes(): void;
  38829. private _animationPropertiesOverride;
  38830. /**
  38831. * Gets or sets the animation properties override
  38832. */
  38833. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38834. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38835. /**
  38836. * Gets a string identifying the name of the class
  38837. * @returns "Node" string
  38838. */
  38839. getClassName(): string;
  38840. /** @hidden */
  38841. readonly _isNode: boolean;
  38842. /**
  38843. * An event triggered when the mesh is disposed
  38844. */
  38845. onDisposeObservable: Observable<Node>;
  38846. private _onDisposeObserver;
  38847. /**
  38848. * Sets a callback that will be raised when the node will be disposed
  38849. */
  38850. set onDispose(callback: () => void);
  38851. /**
  38852. * Creates a new Node
  38853. * @param name the name and id to be given to this node
  38854. * @param scene the scene this node will be added to
  38855. */
  38856. constructor(name: string, scene?: Nullable<Scene>);
  38857. /**
  38858. * Gets the scene of the node
  38859. * @returns a scene
  38860. */
  38861. getScene(): Scene;
  38862. /**
  38863. * Gets the engine of the node
  38864. * @returns a Engine
  38865. */
  38866. getEngine(): Engine;
  38867. private _behaviors;
  38868. /**
  38869. * Attach a behavior to the node
  38870. * @see https://doc.babylonjs.com/features/behaviour
  38871. * @param behavior defines the behavior to attach
  38872. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  38873. * @returns the current Node
  38874. */
  38875. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  38876. /**
  38877. * Remove an attached behavior
  38878. * @see https://doc.babylonjs.com/features/behaviour
  38879. * @param behavior defines the behavior to attach
  38880. * @returns the current Node
  38881. */
  38882. removeBehavior(behavior: Behavior<Node>): Node;
  38883. /**
  38884. * Gets the list of attached behaviors
  38885. * @see https://doc.babylonjs.com/features/behaviour
  38886. */
  38887. get behaviors(): Behavior<Node>[];
  38888. /**
  38889. * Gets an attached behavior by name
  38890. * @param name defines the name of the behavior to look for
  38891. * @see https://doc.babylonjs.com/features/behaviour
  38892. * @returns null if behavior was not found else the requested behavior
  38893. */
  38894. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  38895. /**
  38896. * Returns the latest update of the World matrix
  38897. * @returns a Matrix
  38898. */
  38899. getWorldMatrix(): Matrix;
  38900. /** @hidden */
  38901. _getWorldMatrixDeterminant(): number;
  38902. /**
  38903. * Returns directly the latest state of the mesh World matrix.
  38904. * A Matrix is returned.
  38905. */
  38906. get worldMatrixFromCache(): Matrix;
  38907. /** @hidden */
  38908. _initCache(): void;
  38909. /** @hidden */
  38910. updateCache(force?: boolean): void;
  38911. /** @hidden */
  38912. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38913. /** @hidden */
  38914. _updateCache(ignoreParentClass?: boolean): void;
  38915. /** @hidden */
  38916. _isSynchronized(): boolean;
  38917. /** @hidden */
  38918. _markSyncedWithParent(): void;
  38919. /** @hidden */
  38920. isSynchronizedWithParent(): boolean;
  38921. /** @hidden */
  38922. isSynchronized(): boolean;
  38923. /**
  38924. * Is this node ready to be used/rendered
  38925. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38926. * @return true if the node is ready
  38927. */
  38928. isReady(completeCheck?: boolean): boolean;
  38929. /**
  38930. * Is this node enabled?
  38931. * 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
  38932. * @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
  38933. * @return whether this node (and its parent) is enabled
  38934. */
  38935. isEnabled(checkAncestors?: boolean): boolean;
  38936. /** @hidden */
  38937. protected _syncParentEnabledState(): void;
  38938. /**
  38939. * Set the enabled state of this node
  38940. * @param value defines the new enabled state
  38941. */
  38942. setEnabled(value: boolean): void;
  38943. /**
  38944. * Is this node a descendant of the given node?
  38945. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38946. * @param ancestor defines the parent node to inspect
  38947. * @returns a boolean indicating if this node is a descendant of the given node
  38948. */
  38949. isDescendantOf(ancestor: Node): boolean;
  38950. /** @hidden */
  38951. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38952. /**
  38953. * Will return all nodes that have this node as ascendant
  38954. * @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
  38955. * @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
  38956. * @return all children nodes of all types
  38957. */
  38958. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38959. /**
  38960. * Get all child-meshes of this node
  38961. * @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)
  38962. * @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
  38963. * @returns an array of AbstractMesh
  38964. */
  38965. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38966. /**
  38967. * Get all direct children of this node
  38968. * @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
  38969. * @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)
  38970. * @returns an array of Node
  38971. */
  38972. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38973. /** @hidden */
  38974. _setReady(state: boolean): void;
  38975. /**
  38976. * Get an animation by name
  38977. * @param name defines the name of the animation to look for
  38978. * @returns null if not found else the requested animation
  38979. */
  38980. getAnimationByName(name: string): Nullable<Animation>;
  38981. /**
  38982. * Creates an animation range for this node
  38983. * @param name defines the name of the range
  38984. * @param from defines the starting key
  38985. * @param to defines the end key
  38986. */
  38987. createAnimationRange(name: string, from: number, to: number): void;
  38988. /**
  38989. * Delete a specific animation range
  38990. * @param name defines the name of the range to delete
  38991. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38992. */
  38993. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38994. /**
  38995. * Get an animation range by name
  38996. * @param name defines the name of the animation range to look for
  38997. * @returns null if not found else the requested animation range
  38998. */
  38999. getAnimationRange(name: string): Nullable<AnimationRange>;
  39000. /**
  39001. * Gets the list of all animation ranges defined on this node
  39002. * @returns an array
  39003. */
  39004. getAnimationRanges(): Nullable<AnimationRange>[];
  39005. /**
  39006. * Will start the animation sequence
  39007. * @param name defines the range frames for animation sequence
  39008. * @param loop defines if the animation should loop (false by default)
  39009. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  39010. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  39011. * @returns the object created for this animation. If range does not exist, it will return null
  39012. */
  39013. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  39014. /**
  39015. * Serialize animation ranges into a JSON compatible object
  39016. * @returns serialization object
  39017. */
  39018. serializeAnimationRanges(): any;
  39019. /**
  39020. * Computes the world matrix of the node
  39021. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  39022. * @returns the world matrix
  39023. */
  39024. computeWorldMatrix(force?: boolean): Matrix;
  39025. /**
  39026. * Releases resources associated with this node.
  39027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39029. */
  39030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  39031. /**
  39032. * Parse animation range data from a serialization object and store them into a given node
  39033. * @param node defines where to store the animation ranges
  39034. * @param parsedNode defines the serialization object to read data from
  39035. * @param scene defines the hosting scene
  39036. */
  39037. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  39038. /**
  39039. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  39040. * @param includeDescendants Include bounding info from descendants as well (true by default)
  39041. * @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
  39042. * @returns the new bounding vectors
  39043. */
  39044. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  39045. min: Vector3;
  39046. max: Vector3;
  39047. };
  39048. }
  39049. }
  39050. declare module "babylonjs/Animations/animation" {
  39051. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  39052. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  39053. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  39054. import { Nullable } from "babylonjs/types";
  39055. import { Scene } from "babylonjs/scene";
  39056. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  39057. import { AnimationRange } from "babylonjs/Animations/animationRange";
  39058. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  39059. import { Node } from "babylonjs/node";
  39060. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39061. import { Size } from "babylonjs/Maths/math.size";
  39062. import { Animatable } from "babylonjs/Animations/animatable";
  39063. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  39064. /**
  39065. * @hidden
  39066. */
  39067. export class _IAnimationState {
  39068. key: number;
  39069. repeatCount: number;
  39070. workValue?: any;
  39071. loopMode?: number;
  39072. offsetValue?: any;
  39073. highLimitValue?: any;
  39074. }
  39075. /**
  39076. * Class used to store any kind of animation
  39077. */
  39078. export class Animation {
  39079. /**Name of the animation */
  39080. name: string;
  39081. /**Property to animate */
  39082. targetProperty: string;
  39083. /**The frames per second of the animation */
  39084. framePerSecond: number;
  39085. /**The data type of the animation */
  39086. dataType: number;
  39087. /**The loop mode of the animation */
  39088. loopMode?: number | undefined;
  39089. /**Specifies if blending should be enabled */
  39090. enableBlending?: boolean | undefined;
  39091. /**
  39092. * Use matrix interpolation instead of using direct key value when animating matrices
  39093. */
  39094. static AllowMatricesInterpolation: boolean;
  39095. /**
  39096. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  39097. */
  39098. static AllowMatrixDecomposeForInterpolation: boolean;
  39099. /** Define the Url to load snippets */
  39100. static SnippetUrl: string;
  39101. /** Snippet ID if the animation was created from the snippet server */
  39102. snippetId: string;
  39103. /**
  39104. * Stores the key frames of the animation
  39105. */
  39106. private _keys;
  39107. /**
  39108. * Stores the easing function of the animation
  39109. */
  39110. private _easingFunction;
  39111. /**
  39112. * @hidden Internal use only
  39113. */
  39114. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  39115. /**
  39116. * The set of event that will be linked to this animation
  39117. */
  39118. private _events;
  39119. /**
  39120. * Stores an array of target property paths
  39121. */
  39122. targetPropertyPath: string[];
  39123. /**
  39124. * Stores the blending speed of the animation
  39125. */
  39126. blendingSpeed: number;
  39127. /**
  39128. * Stores the animation ranges for the animation
  39129. */
  39130. private _ranges;
  39131. /**
  39132. * @hidden Internal use
  39133. */
  39134. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  39135. /**
  39136. * Sets up an animation
  39137. * @param property The property to animate
  39138. * @param animationType The animation type to apply
  39139. * @param framePerSecond The frames per second of the animation
  39140. * @param easingFunction The easing function used in the animation
  39141. * @returns The created animation
  39142. */
  39143. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  39144. /**
  39145. * Create and start an animation on a node
  39146. * @param name defines the name of the global animation that will be run on all nodes
  39147. * @param node defines the root node where the animation will take place
  39148. * @param targetProperty defines property to animate
  39149. * @param framePerSecond defines the number of frame per second yo use
  39150. * @param totalFrame defines the number of frames in total
  39151. * @param from defines the initial value
  39152. * @param to defines the final value
  39153. * @param loopMode defines which loop mode you want to use (off by default)
  39154. * @param easingFunction defines the easing function to use (linear by default)
  39155. * @param onAnimationEnd defines the callback to call when animation end
  39156. * @returns the animatable created for this animation
  39157. */
  39158. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  39159. /**
  39160. * Create and start an animation on a node and its descendants
  39161. * @param name defines the name of the global animation that will be run on all nodes
  39162. * @param node defines the root node where the animation will take place
  39163. * @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
  39164. * @param targetProperty defines property to animate
  39165. * @param framePerSecond defines the number of frame per second to use
  39166. * @param totalFrame defines the number of frames in total
  39167. * @param from defines the initial value
  39168. * @param to defines the final value
  39169. * @param loopMode defines which loop mode you want to use (off by default)
  39170. * @param easingFunction defines the easing function to use (linear by default)
  39171. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  39172. * @returns the list of animatables created for all nodes
  39173. * @example https://www.babylonjs-playground.com/#MH0VLI
  39174. */
  39175. 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[]>;
  39176. /**
  39177. * Creates a new animation, merges it with the existing animations and starts it
  39178. * @param name Name of the animation
  39179. * @param node Node which contains the scene that begins the animations
  39180. * @param targetProperty Specifies which property to animate
  39181. * @param framePerSecond The frames per second of the animation
  39182. * @param totalFrame The total number of frames
  39183. * @param from The frame at the beginning of the animation
  39184. * @param to The frame at the end of the animation
  39185. * @param loopMode Specifies the loop mode of the animation
  39186. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  39187. * @param onAnimationEnd Callback to run once the animation is complete
  39188. * @returns Nullable animation
  39189. */
  39190. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  39191. /**
  39192. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39193. * @param sourceAnimation defines the Animation containing keyframes to convert
  39194. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39195. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  39196. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  39197. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  39198. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  39199. */
  39200. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  39201. /**
  39202. * Transition property of an host to the target Value
  39203. * @param property The property to transition
  39204. * @param targetValue The target Value of the property
  39205. * @param host The object where the property to animate belongs
  39206. * @param scene Scene used to run the animation
  39207. * @param frameRate Framerate (in frame/s) to use
  39208. * @param transition The transition type we want to use
  39209. * @param duration The duration of the animation, in milliseconds
  39210. * @param onAnimationEnd Callback trigger at the end of the animation
  39211. * @returns Nullable animation
  39212. */
  39213. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  39214. /**
  39215. * Return the array of runtime animations currently using this animation
  39216. */
  39217. get runtimeAnimations(): RuntimeAnimation[];
  39218. /**
  39219. * Specifies if any of the runtime animations are currently running
  39220. */
  39221. get hasRunningRuntimeAnimations(): boolean;
  39222. /**
  39223. * Initializes the animation
  39224. * @param name Name of the animation
  39225. * @param targetProperty Property to animate
  39226. * @param framePerSecond The frames per second of the animation
  39227. * @param dataType The data type of the animation
  39228. * @param loopMode The loop mode of the animation
  39229. * @param enableBlending Specifies if blending should be enabled
  39230. */
  39231. constructor(
  39232. /**Name of the animation */
  39233. name: string,
  39234. /**Property to animate */
  39235. targetProperty: string,
  39236. /**The frames per second of the animation */
  39237. framePerSecond: number,
  39238. /**The data type of the animation */
  39239. dataType: number,
  39240. /**The loop mode of the animation */
  39241. loopMode?: number | undefined,
  39242. /**Specifies if blending should be enabled */
  39243. enableBlending?: boolean | undefined);
  39244. /**
  39245. * Converts the animation to a string
  39246. * @param fullDetails support for multiple levels of logging within scene loading
  39247. * @returns String form of the animation
  39248. */
  39249. toString(fullDetails?: boolean): string;
  39250. /**
  39251. * Add an event to this animation
  39252. * @param event Event to add
  39253. */
  39254. addEvent(event: AnimationEvent): void;
  39255. /**
  39256. * Remove all events found at the given frame
  39257. * @param frame The frame to remove events from
  39258. */
  39259. removeEvents(frame: number): void;
  39260. /**
  39261. * Retrieves all the events from the animation
  39262. * @returns Events from the animation
  39263. */
  39264. getEvents(): AnimationEvent[];
  39265. /**
  39266. * Creates an animation range
  39267. * @param name Name of the animation range
  39268. * @param from Starting frame of the animation range
  39269. * @param to Ending frame of the animation
  39270. */
  39271. createRange(name: string, from: number, to: number): void;
  39272. /**
  39273. * Deletes an animation range by name
  39274. * @param name Name of the animation range to delete
  39275. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  39276. */
  39277. deleteRange(name: string, deleteFrames?: boolean): void;
  39278. /**
  39279. * Gets the animation range by name, or null if not defined
  39280. * @param name Name of the animation range
  39281. * @returns Nullable animation range
  39282. */
  39283. getRange(name: string): Nullable<AnimationRange>;
  39284. /**
  39285. * Gets the key frames from the animation
  39286. * @returns The key frames of the animation
  39287. */
  39288. getKeys(): Array<IAnimationKey>;
  39289. /**
  39290. * Gets the highest frame rate of the animation
  39291. * @returns Highest frame rate of the animation
  39292. */
  39293. getHighestFrame(): number;
  39294. /**
  39295. * Gets the easing function of the animation
  39296. * @returns Easing function of the animation
  39297. */
  39298. getEasingFunction(): IEasingFunction;
  39299. /**
  39300. * Sets the easing function of the animation
  39301. * @param easingFunction A custom mathematical formula for animation
  39302. */
  39303. setEasingFunction(easingFunction: EasingFunction): void;
  39304. /**
  39305. * Interpolates a scalar linearly
  39306. * @param startValue Start value of the animation curve
  39307. * @param endValue End value of the animation curve
  39308. * @param gradient Scalar amount to interpolate
  39309. * @returns Interpolated scalar value
  39310. */
  39311. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  39312. /**
  39313. * Interpolates a scalar cubically
  39314. * @param startValue Start value of the animation curve
  39315. * @param outTangent End tangent of the animation
  39316. * @param endValue End value of the animation curve
  39317. * @param inTangent Start tangent of the animation curve
  39318. * @param gradient Scalar amount to interpolate
  39319. * @returns Interpolated scalar value
  39320. */
  39321. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  39322. /**
  39323. * Interpolates a quaternion using a spherical linear interpolation
  39324. * @param startValue Start value of the animation curve
  39325. * @param endValue End value of the animation curve
  39326. * @param gradient Scalar amount to interpolate
  39327. * @returns Interpolated quaternion value
  39328. */
  39329. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  39330. /**
  39331. * Interpolates a quaternion cubically
  39332. * @param startValue Start value of the animation curve
  39333. * @param outTangent End tangent of the animation curve
  39334. * @param endValue End value of the animation curve
  39335. * @param inTangent Start tangent of the animation curve
  39336. * @param gradient Scalar amount to interpolate
  39337. * @returns Interpolated quaternion value
  39338. */
  39339. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  39340. /**
  39341. * Interpolates a Vector3 linearly
  39342. * @param startValue Start value of the animation curve
  39343. * @param endValue End value of the animation curve
  39344. * @param gradient Scalar amount to interpolate
  39345. * @returns Interpolated scalar value
  39346. */
  39347. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  39348. /**
  39349. * Interpolates a Vector3 cubically
  39350. * @param startValue Start value of the animation curve
  39351. * @param outTangent End tangent of the animation
  39352. * @param endValue End value of the animation curve
  39353. * @param inTangent Start tangent of the animation curve
  39354. * @param gradient Scalar amount to interpolate
  39355. * @returns InterpolatedVector3 value
  39356. */
  39357. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  39358. /**
  39359. * Interpolates a Vector2 linearly
  39360. * @param startValue Start value of the animation curve
  39361. * @param endValue End value of the animation curve
  39362. * @param gradient Scalar amount to interpolate
  39363. * @returns Interpolated Vector2 value
  39364. */
  39365. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  39366. /**
  39367. * Interpolates a Vector2 cubically
  39368. * @param startValue Start value of the animation curve
  39369. * @param outTangent End tangent of the animation
  39370. * @param endValue End value of the animation curve
  39371. * @param inTangent Start tangent of the animation curve
  39372. * @param gradient Scalar amount to interpolate
  39373. * @returns Interpolated Vector2 value
  39374. */
  39375. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  39376. /**
  39377. * Interpolates a size linearly
  39378. * @param startValue Start value of the animation curve
  39379. * @param endValue End value of the animation curve
  39380. * @param gradient Scalar amount to interpolate
  39381. * @returns Interpolated Size value
  39382. */
  39383. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  39384. /**
  39385. * Interpolates a Color3 linearly
  39386. * @param startValue Start value of the animation curve
  39387. * @param endValue End value of the animation curve
  39388. * @param gradient Scalar amount to interpolate
  39389. * @returns Interpolated Color3 value
  39390. */
  39391. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  39392. /**
  39393. * Interpolates a Color4 linearly
  39394. * @param startValue Start value of the animation curve
  39395. * @param endValue End value of the animation curve
  39396. * @param gradient Scalar amount to interpolate
  39397. * @returns Interpolated Color3 value
  39398. */
  39399. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  39400. /**
  39401. * @hidden Internal use only
  39402. */
  39403. _getKeyValue(value: any): any;
  39404. /**
  39405. * @hidden Internal use only
  39406. */
  39407. _interpolate(currentFrame: number, state: _IAnimationState): any;
  39408. /**
  39409. * Defines the function to use to interpolate matrices
  39410. * @param startValue defines the start matrix
  39411. * @param endValue defines the end matrix
  39412. * @param gradient defines the gradient between both matrices
  39413. * @param result defines an optional target matrix where to store the interpolation
  39414. * @returns the interpolated matrix
  39415. */
  39416. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  39417. /**
  39418. * Makes a copy of the animation
  39419. * @returns Cloned animation
  39420. */
  39421. clone(): Animation;
  39422. /**
  39423. * Sets the key frames of the animation
  39424. * @param values The animation key frames to set
  39425. */
  39426. setKeys(values: Array<IAnimationKey>): void;
  39427. /**
  39428. * Serializes the animation to an object
  39429. * @returns Serialized object
  39430. */
  39431. serialize(): any;
  39432. /**
  39433. * Float animation type
  39434. */
  39435. static readonly ANIMATIONTYPE_FLOAT: number;
  39436. /**
  39437. * Vector3 animation type
  39438. */
  39439. static readonly ANIMATIONTYPE_VECTOR3: number;
  39440. /**
  39441. * Quaternion animation type
  39442. */
  39443. static readonly ANIMATIONTYPE_QUATERNION: number;
  39444. /**
  39445. * Matrix animation type
  39446. */
  39447. static readonly ANIMATIONTYPE_MATRIX: number;
  39448. /**
  39449. * Color3 animation type
  39450. */
  39451. static readonly ANIMATIONTYPE_COLOR3: number;
  39452. /**
  39453. * Color3 animation type
  39454. */
  39455. static readonly ANIMATIONTYPE_COLOR4: number;
  39456. /**
  39457. * Vector2 animation type
  39458. */
  39459. static readonly ANIMATIONTYPE_VECTOR2: number;
  39460. /**
  39461. * Size animation type
  39462. */
  39463. static readonly ANIMATIONTYPE_SIZE: number;
  39464. /**
  39465. * Relative Loop Mode
  39466. */
  39467. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  39468. /**
  39469. * Cycle Loop Mode
  39470. */
  39471. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  39472. /**
  39473. * Constant Loop Mode
  39474. */
  39475. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  39476. /** @hidden */
  39477. static _UniversalLerp(left: any, right: any, amount: number): any;
  39478. /**
  39479. * Parses an animation object and creates an animation
  39480. * @param parsedAnimation Parsed animation object
  39481. * @returns Animation object
  39482. */
  39483. static Parse(parsedAnimation: any): Animation;
  39484. /**
  39485. * Appends the serialized animations from the source animations
  39486. * @param source Source containing the animations
  39487. * @param destination Target to store the animations
  39488. */
  39489. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39490. /**
  39491. * Creates a new animation or an array of animations from a snippet saved in a remote file
  39492. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  39493. * @param url defines the url to load from
  39494. * @returns a promise that will resolve to the new animation or an array of animations
  39495. */
  39496. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  39497. /**
  39498. * Creates an animation or an array of animations from a snippet saved by the Inspector
  39499. * @param snippetId defines the snippet to load
  39500. * @returns a promise that will resolve to the new animation or a new array of animations
  39501. */
  39502. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  39503. }
  39504. }
  39505. declare module "babylonjs/Animations/animatable.interface" {
  39506. import { Nullable } from "babylonjs/types";
  39507. import { Animation } from "babylonjs/Animations/animation";
  39508. /**
  39509. * Interface containing an array of animations
  39510. */
  39511. export interface IAnimatable {
  39512. /**
  39513. * Array of animations
  39514. */
  39515. animations: Nullable<Array<Animation>>;
  39516. }
  39517. }
  39518. declare module "babylonjs/Misc/decorators" {
  39519. import { Nullable } from "babylonjs/types";
  39520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39521. import { Scene } from "babylonjs/scene";
  39522. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39523. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39524. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39526. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  39527. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39528. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39529. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39530. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39531. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39532. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39533. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39534. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39535. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39536. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39537. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39538. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39539. /**
  39540. * Decorator used to define property that can be serialized as reference to a camera
  39541. * @param sourceName defines the name of the property to decorate
  39542. */
  39543. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39544. /**
  39545. * Class used to help serialization objects
  39546. */
  39547. export class SerializationHelper {
  39548. /** @hidden */
  39549. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  39550. /** @hidden */
  39551. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  39552. /** @hidden */
  39553. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  39554. /** @hidden */
  39555. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  39556. /**
  39557. * Appends the serialized animations from the source animations
  39558. * @param source Source containing the animations
  39559. * @param destination Target to store the animations
  39560. */
  39561. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39562. /**
  39563. * Static function used to serialized a specific entity
  39564. * @param entity defines the entity to serialize
  39565. * @param serializationObject defines the optional target object where serialization data will be stored
  39566. * @returns a JSON compatible object representing the serialization of the entity
  39567. */
  39568. static Serialize<T>(entity: T, serializationObject?: any): any;
  39569. /**
  39570. * Creates a new entity from a serialization data object
  39571. * @param creationFunction defines a function used to instanciated the new entity
  39572. * @param source defines the source serialization data
  39573. * @param scene defines the hosting scene
  39574. * @param rootUrl defines the root url for resources
  39575. * @returns a new entity
  39576. */
  39577. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  39578. /**
  39579. * Clones an object
  39580. * @param creationFunction defines the function used to instanciate the new object
  39581. * @param source defines the source object
  39582. * @returns the cloned object
  39583. */
  39584. static Clone<T>(creationFunction: () => T, source: T): T;
  39585. /**
  39586. * Instanciates a new object based on a source one (some data will be shared between both object)
  39587. * @param creationFunction defines the function used to instanciate the new object
  39588. * @param source defines the source object
  39589. * @returns the new object
  39590. */
  39591. static Instanciate<T>(creationFunction: () => T, source: T): T;
  39592. }
  39593. }
  39594. declare module "babylonjs/Cameras/camera" {
  39595. import { SmartArray } from "babylonjs/Misc/smartArray";
  39596. import { Observable } from "babylonjs/Misc/observable";
  39597. import { Nullable } from "babylonjs/types";
  39598. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39599. import { Scene } from "babylonjs/scene";
  39600. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39601. import { Node } from "babylonjs/node";
  39602. import { Mesh } from "babylonjs/Meshes/mesh";
  39603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39604. import { ICullable } from "babylonjs/Culling/boundingInfo";
  39605. import { Viewport } from "babylonjs/Maths/math.viewport";
  39606. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39608. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39609. import { Ray } from "babylonjs/Culling/ray";
  39610. /**
  39611. * This is the base class of all the camera used in the application.
  39612. * @see https://doc.babylonjs.com/features/cameras
  39613. */
  39614. export class Camera extends Node {
  39615. /** @hidden */
  39616. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  39617. /**
  39618. * This is the default projection mode used by the cameras.
  39619. * It helps recreating a feeling of perspective and better appreciate depth.
  39620. * This is the best way to simulate real life cameras.
  39621. */
  39622. static readonly PERSPECTIVE_CAMERA: number;
  39623. /**
  39624. * This helps creating camera with an orthographic mode.
  39625. * 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.
  39626. */
  39627. static readonly ORTHOGRAPHIC_CAMERA: number;
  39628. /**
  39629. * This is the default FOV mode for perspective cameras.
  39630. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  39631. */
  39632. static readonly FOVMODE_VERTICAL_FIXED: number;
  39633. /**
  39634. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  39635. */
  39636. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  39637. /**
  39638. * This specifies there is no need for a camera rig.
  39639. * Basically only one eye is rendered corresponding to the camera.
  39640. */
  39641. static readonly RIG_MODE_NONE: number;
  39642. /**
  39643. * Simulates a camera Rig with one blue eye and one red eye.
  39644. * This can be use with 3d blue and red glasses.
  39645. */
  39646. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  39647. /**
  39648. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  39649. */
  39650. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  39651. /**
  39652. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  39653. */
  39654. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  39655. /**
  39656. * Defines that both eyes of the camera will be rendered over under each other.
  39657. */
  39658. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  39659. /**
  39660. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  39661. */
  39662. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  39663. /**
  39664. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  39665. */
  39666. static readonly RIG_MODE_VR: number;
  39667. /**
  39668. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  39669. */
  39670. static readonly RIG_MODE_WEBVR: number;
  39671. /**
  39672. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  39673. */
  39674. static readonly RIG_MODE_CUSTOM: number;
  39675. /**
  39676. * Defines if by default attaching controls should prevent the default javascript event to continue.
  39677. */
  39678. static ForceAttachControlToAlwaysPreventDefault: boolean;
  39679. /**
  39680. * Define the input manager associated with the camera.
  39681. */
  39682. inputs: CameraInputsManager<Camera>;
  39683. /** @hidden */
  39684. _position: Vector3;
  39685. /**
  39686. * Define the current local position of the camera in the scene
  39687. */
  39688. get position(): Vector3;
  39689. set position(newPosition: Vector3);
  39690. protected _upVector: Vector3;
  39691. /**
  39692. * The vector the camera should consider as up.
  39693. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  39694. */
  39695. set upVector(vec: Vector3);
  39696. get upVector(): Vector3;
  39697. /**
  39698. * Define the current limit on the left side for an orthographic camera
  39699. * In scene unit
  39700. */
  39701. orthoLeft: Nullable<number>;
  39702. /**
  39703. * Define the current limit on the right side for an orthographic camera
  39704. * In scene unit
  39705. */
  39706. orthoRight: Nullable<number>;
  39707. /**
  39708. * Define the current limit on the bottom side for an orthographic camera
  39709. * In scene unit
  39710. */
  39711. orthoBottom: Nullable<number>;
  39712. /**
  39713. * Define the current limit on the top side for an orthographic camera
  39714. * In scene unit
  39715. */
  39716. orthoTop: Nullable<number>;
  39717. /**
  39718. * Field Of View is set in Radians. (default is 0.8)
  39719. */
  39720. fov: number;
  39721. /**
  39722. * Define the minimum distance the camera can see from.
  39723. * This is important to note that the depth buffer are not infinite and the closer it starts
  39724. * the more your scene might encounter depth fighting issue.
  39725. */
  39726. minZ: number;
  39727. /**
  39728. * Define the maximum distance the camera can see to.
  39729. * This is important to note that the depth buffer are not infinite and the further it end
  39730. * the more your scene might encounter depth fighting issue.
  39731. */
  39732. maxZ: number;
  39733. /**
  39734. * Define the default inertia of the camera.
  39735. * This helps giving a smooth feeling to the camera movement.
  39736. */
  39737. inertia: number;
  39738. /**
  39739. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  39740. */
  39741. mode: number;
  39742. /**
  39743. * Define whether the camera is intermediate.
  39744. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  39745. */
  39746. isIntermediate: boolean;
  39747. /**
  39748. * Define the viewport of the camera.
  39749. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  39750. */
  39751. viewport: Viewport;
  39752. /**
  39753. * Restricts the camera to viewing objects with the same layerMask.
  39754. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  39755. */
  39756. layerMask: number;
  39757. /**
  39758. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  39759. */
  39760. fovMode: number;
  39761. /**
  39762. * Rig mode of the camera.
  39763. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  39764. * This is normally controlled byt the camera themselves as internal use.
  39765. */
  39766. cameraRigMode: number;
  39767. /**
  39768. * Defines the distance between both "eyes" in case of a RIG
  39769. */
  39770. interaxialDistance: number;
  39771. /**
  39772. * Defines if stereoscopic rendering is done side by side or over under.
  39773. */
  39774. isStereoscopicSideBySide: boolean;
  39775. /**
  39776. * 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
  39777. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  39778. * else in the scene. (Eg. security camera)
  39779. *
  39780. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corresponding to an HMD)
  39781. */
  39782. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  39783. /**
  39784. * When set, the camera will render to this render target instead of the default canvas
  39785. *
  39786. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  39787. */
  39788. outputRenderTarget: Nullable<RenderTargetTexture>;
  39789. /**
  39790. * Observable triggered when the camera view matrix has changed.
  39791. */
  39792. onViewMatrixChangedObservable: Observable<Camera>;
  39793. /**
  39794. * Observable triggered when the camera Projection matrix has changed.
  39795. */
  39796. onProjectionMatrixChangedObservable: Observable<Camera>;
  39797. /**
  39798. * Observable triggered when the inputs have been processed.
  39799. */
  39800. onAfterCheckInputsObservable: Observable<Camera>;
  39801. /**
  39802. * Observable triggered when reset has been called and applied to the camera.
  39803. */
  39804. onRestoreStateObservable: Observable<Camera>;
  39805. /**
  39806. * Is this camera a part of a rig system?
  39807. */
  39808. isRigCamera: boolean;
  39809. /**
  39810. * If isRigCamera set to true this will be set with the parent camera.
  39811. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  39812. */
  39813. rigParent?: Camera;
  39814. /** @hidden */
  39815. _cameraRigParams: any;
  39816. /** @hidden */
  39817. _rigCameras: Camera[];
  39818. /** @hidden */
  39819. _rigPostProcess: Nullable<PostProcess>;
  39820. protected _webvrViewMatrix: Matrix;
  39821. /** @hidden */
  39822. _skipRendering: boolean;
  39823. /** @hidden */
  39824. _projectionMatrix: Matrix;
  39825. /** @hidden */
  39826. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  39827. /** @hidden */
  39828. _activeMeshes: SmartArray<AbstractMesh>;
  39829. protected _globalPosition: Vector3;
  39830. /** @hidden */
  39831. _computedViewMatrix: Matrix;
  39832. private _doNotComputeProjectionMatrix;
  39833. private _transformMatrix;
  39834. private _frustumPlanes;
  39835. private _refreshFrustumPlanes;
  39836. private _storedFov;
  39837. private _stateStored;
  39838. /**
  39839. * Instantiates a new camera object.
  39840. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  39841. * @see https://doc.babylonjs.com/features/cameras
  39842. * @param name Defines the name of the camera in the scene
  39843. * @param position Defines the position of the camera
  39844. * @param scene Defines the scene the camera belongs too
  39845. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  39846. */
  39847. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39848. /**
  39849. * Store current camera state (fov, position, etc..)
  39850. * @returns the camera
  39851. */
  39852. storeState(): Camera;
  39853. /**
  39854. * Restores the camera state values if it has been stored. You must call storeState() first
  39855. */
  39856. protected _restoreStateValues(): boolean;
  39857. /**
  39858. * Restored camera state. You must call storeState() first.
  39859. * @returns true if restored and false otherwise
  39860. */
  39861. restoreState(): boolean;
  39862. /**
  39863. * Gets the class name of the camera.
  39864. * @returns the class name
  39865. */
  39866. getClassName(): string;
  39867. /** @hidden */
  39868. readonly _isCamera: boolean;
  39869. /**
  39870. * Gets a string representation of the camera useful for debug purpose.
  39871. * @param fullDetails Defines that a more verboe level of logging is required
  39872. * @returns the string representation
  39873. */
  39874. toString(fullDetails?: boolean): string;
  39875. /**
  39876. * Gets the current world space position of the camera.
  39877. */
  39878. get globalPosition(): Vector3;
  39879. /**
  39880. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  39881. * @returns the active meshe list
  39882. */
  39883. getActiveMeshes(): SmartArray<AbstractMesh>;
  39884. /**
  39885. * Check whether a mesh is part of the current active mesh list of the camera
  39886. * @param mesh Defines the mesh to check
  39887. * @returns true if active, false otherwise
  39888. */
  39889. isActiveMesh(mesh: Mesh): boolean;
  39890. /**
  39891. * Is this camera ready to be used/rendered
  39892. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  39893. * @return true if the camera is ready
  39894. */
  39895. isReady(completeCheck?: boolean): boolean;
  39896. /** @hidden */
  39897. _initCache(): void;
  39898. /** @hidden */
  39899. _updateCache(ignoreParentClass?: boolean): void;
  39900. /** @hidden */
  39901. _isSynchronized(): boolean;
  39902. /** @hidden */
  39903. _isSynchronizedViewMatrix(): boolean;
  39904. /** @hidden */
  39905. _isSynchronizedProjectionMatrix(): boolean;
  39906. /**
  39907. * Attach the input controls to a specific dom element to get the input from.
  39908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39909. */
  39910. attachControl(noPreventDefault?: boolean): void;
  39911. /**
  39912. * Attach the input controls to a specific dom element to get the input from.
  39913. * @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
  39914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39915. * BACK COMPAT SIGNATURE ONLY.
  39916. */
  39917. attachControl(ignored: any, noPreventDefault?: boolean): void;
  39918. /**
  39919. * Detach the current controls from the specified dom element.
  39920. */
  39921. detachControl(): void;
  39922. /**
  39923. * Detach the current controls from the specified dom element.
  39924. * @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
  39925. */
  39926. detachControl(ignored: any): void;
  39927. /**
  39928. * Update the camera state according to the different inputs gathered during the frame.
  39929. */
  39930. update(): void;
  39931. /** @hidden */
  39932. _checkInputs(): void;
  39933. /** @hidden */
  39934. get rigCameras(): Camera[];
  39935. /**
  39936. * Gets the post process used by the rig cameras
  39937. */
  39938. get rigPostProcess(): Nullable<PostProcess>;
  39939. /**
  39940. * Internal, gets the first post process.
  39941. * @returns the first post process to be run on this camera.
  39942. */
  39943. _getFirstPostProcess(): Nullable<PostProcess>;
  39944. private _cascadePostProcessesToRigCams;
  39945. /**
  39946. * Attach a post process to the camera.
  39947. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39948. * @param postProcess The post process to attach to the camera
  39949. * @param insertAt The position of the post process in case several of them are in use in the scene
  39950. * @returns the position the post process has been inserted at
  39951. */
  39952. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  39953. /**
  39954. * Detach a post process to the camera.
  39955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39956. * @param postProcess The post process to detach from the camera
  39957. */
  39958. detachPostProcess(postProcess: PostProcess): void;
  39959. /**
  39960. * Gets the current world matrix of the camera
  39961. */
  39962. getWorldMatrix(): Matrix;
  39963. /** @hidden */
  39964. _getViewMatrix(): Matrix;
  39965. /**
  39966. * Gets the current view matrix of the camera.
  39967. * @param force forces the camera to recompute the matrix without looking at the cached state
  39968. * @returns the view matrix
  39969. */
  39970. getViewMatrix(force?: boolean): Matrix;
  39971. /**
  39972. * Freeze the projection matrix.
  39973. * It will prevent the cache check of the camera projection compute and can speed up perf
  39974. * if no parameter of the camera are meant to change
  39975. * @param projection Defines manually a projection if necessary
  39976. */
  39977. freezeProjectionMatrix(projection?: Matrix): void;
  39978. /**
  39979. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  39980. */
  39981. unfreezeProjectionMatrix(): void;
  39982. /**
  39983. * Gets the current projection matrix of the camera.
  39984. * @param force forces the camera to recompute the matrix without looking at the cached state
  39985. * @returns the projection matrix
  39986. */
  39987. getProjectionMatrix(force?: boolean): Matrix;
  39988. /**
  39989. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  39990. * @returns a Matrix
  39991. */
  39992. getTransformationMatrix(): Matrix;
  39993. private _updateFrustumPlanes;
  39994. /**
  39995. * Checks if a cullable object (mesh...) is in the camera frustum
  39996. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  39997. * @param target The object to check
  39998. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  39999. * @returns true if the object is in frustum otherwise false
  40000. */
  40001. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  40002. /**
  40003. * Checks if a cullable object (mesh...) is in the camera frustum
  40004. * Unlike isInFrustum this checks the full bounding box
  40005. * @param target The object to check
  40006. * @returns true if the object is in frustum otherwise false
  40007. */
  40008. isCompletelyInFrustum(target: ICullable): boolean;
  40009. /**
  40010. * Gets a ray in the forward direction from the camera.
  40011. * @param length Defines the length of the ray to create
  40012. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  40013. * @param origin Defines the start point of the ray which defaults to the camera position
  40014. * @returns the forward ray
  40015. */
  40016. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  40017. /**
  40018. * Gets a ray in the forward direction from the camera.
  40019. * @param refRay the ray to (re)use when setting the values
  40020. * @param length Defines the length of the ray to create
  40021. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  40022. * @param origin Defines the start point of the ray which defaults to the camera position
  40023. * @returns the forward ray
  40024. */
  40025. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  40026. /**
  40027. * Releases resources associated with this node.
  40028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40030. */
  40031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  40032. /** @hidden */
  40033. _isLeftCamera: boolean;
  40034. /**
  40035. * Gets the left camera of a rig setup in case of Rigged Camera
  40036. */
  40037. get isLeftCamera(): boolean;
  40038. /** @hidden */
  40039. _isRightCamera: boolean;
  40040. /**
  40041. * Gets the right camera of a rig setup in case of Rigged Camera
  40042. */
  40043. get isRightCamera(): boolean;
  40044. /**
  40045. * Gets the left camera of a rig setup in case of Rigged Camera
  40046. */
  40047. get leftCamera(): Nullable<FreeCamera>;
  40048. /**
  40049. * Gets the right camera of a rig setup in case of Rigged Camera
  40050. */
  40051. get rightCamera(): Nullable<FreeCamera>;
  40052. /**
  40053. * Gets the left camera target of a rig setup in case of Rigged Camera
  40054. * @returns the target position
  40055. */
  40056. getLeftTarget(): Nullable<Vector3>;
  40057. /**
  40058. * Gets the right camera target of a rig setup in case of Rigged Camera
  40059. * @returns the target position
  40060. */
  40061. getRightTarget(): Nullable<Vector3>;
  40062. /**
  40063. * @hidden
  40064. */
  40065. setCameraRigMode(mode: number, rigParams: any): void;
  40066. /** @hidden */
  40067. static _setStereoscopicRigMode(camera: Camera): void;
  40068. /** @hidden */
  40069. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  40070. /** @hidden */
  40071. static _setVRRigMode(camera: Camera, rigParams: any): void;
  40072. /** @hidden */
  40073. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  40074. /** @hidden */
  40075. _getVRProjectionMatrix(): Matrix;
  40076. protected _updateCameraRotationMatrix(): void;
  40077. protected _updateWebVRCameraRotationMatrix(): void;
  40078. /**
  40079. * This function MUST be overwritten by the different WebVR cameras available.
  40080. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  40081. * @hidden
  40082. */
  40083. _getWebVRProjectionMatrix(): Matrix;
  40084. /**
  40085. * This function MUST be overwritten by the different WebVR cameras available.
  40086. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  40087. * @hidden
  40088. */
  40089. _getWebVRViewMatrix(): Matrix;
  40090. /** @hidden */
  40091. setCameraRigParameter(name: string, value: any): void;
  40092. /**
  40093. * needs to be overridden by children so sub has required properties to be copied
  40094. * @hidden
  40095. */
  40096. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  40097. /**
  40098. * May need to be overridden by children
  40099. * @hidden
  40100. */
  40101. _updateRigCameras(): void;
  40102. /** @hidden */
  40103. _setupInputs(): void;
  40104. /**
  40105. * Serialiaze the camera setup to a json representation
  40106. * @returns the JSON representation
  40107. */
  40108. serialize(): any;
  40109. /**
  40110. * Clones the current camera.
  40111. * @param name The cloned camera name
  40112. * @returns the cloned camera
  40113. */
  40114. clone(name: string): Camera;
  40115. /**
  40116. * Gets the direction of the camera relative to a given local axis.
  40117. * @param localAxis Defines the reference axis to provide a relative direction.
  40118. * @return the direction
  40119. */
  40120. getDirection(localAxis: Vector3): Vector3;
  40121. /**
  40122. * Returns the current camera absolute rotation
  40123. */
  40124. get absoluteRotation(): Quaternion;
  40125. /**
  40126. * Gets the direction of the camera relative to a given local axis into a passed vector.
  40127. * @param localAxis Defines the reference axis to provide a relative direction.
  40128. * @param result Defines the vector to store the result in
  40129. */
  40130. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  40131. /**
  40132. * Gets a camera constructor for a given camera type
  40133. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  40134. * @param name The name of the camera the result will be able to instantiate
  40135. * @param scene The scene the result will construct the camera in
  40136. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  40137. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  40138. * @returns a factory method to construct the camera
  40139. */
  40140. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  40141. /**
  40142. * Compute the world matrix of the camera.
  40143. * @returns the camera world matrix
  40144. */
  40145. computeWorldMatrix(): Matrix;
  40146. /**
  40147. * Parse a JSON and creates the camera from the parsed information
  40148. * @param parsedCamera The JSON to parse
  40149. * @param scene The scene to instantiate the camera in
  40150. * @returns the newly constructed camera
  40151. */
  40152. static Parse(parsedCamera: any, scene: Scene): Camera;
  40153. }
  40154. }
  40155. declare module "babylonjs/PostProcesses/postProcessManager" {
  40156. import { Nullable } from "babylonjs/types";
  40157. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40158. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40159. import { Scene } from "babylonjs/scene";
  40160. /**
  40161. * PostProcessManager is used to manage one or more post processes or post process pipelines
  40162. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  40163. */
  40164. export class PostProcessManager {
  40165. private _scene;
  40166. private _indexBuffer;
  40167. private _vertexBuffers;
  40168. /**
  40169. * Creates a new instance PostProcess
  40170. * @param scene The scene that the post process is associated with.
  40171. */
  40172. constructor(scene: Scene);
  40173. private _prepareBuffers;
  40174. private _buildIndexBuffer;
  40175. /**
  40176. * Rebuilds the vertex buffers of the manager.
  40177. * @hidden
  40178. */
  40179. _rebuild(): void;
  40180. /**
  40181. * Prepares a frame to be run through a post process.
  40182. * @param sourceTexture The input texture to the post processes. (default: null)
  40183. * @param postProcesses An array of post processes to be run. (default: null)
  40184. * @returns True if the post processes were able to be run.
  40185. * @hidden
  40186. */
  40187. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  40188. /**
  40189. * Manually render a set of post processes to a texture.
  40190. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  40191. * @param postProcesses An array of post processes to be run.
  40192. * @param targetTexture The target texture to render to.
  40193. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  40194. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  40195. * @param lodLevel defines which lod of the texture to render to
  40196. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  40197. */
  40198. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  40199. /**
  40200. * Finalize the result of the output of the postprocesses.
  40201. * @param doNotPresent If true the result will not be displayed to the screen.
  40202. * @param targetTexture The target texture to render to.
  40203. * @param faceIndex The index of the face to bind the target texture to.
  40204. * @param postProcesses The array of post processes to render.
  40205. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  40206. * @hidden
  40207. */
  40208. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  40209. /**
  40210. * Disposes of the post process manager.
  40211. */
  40212. dispose(): void;
  40213. }
  40214. }
  40215. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  40216. import { Observable } from "babylonjs/Misc/observable";
  40217. import { SmartArray } from "babylonjs/Misc/smartArray";
  40218. import { Nullable, Immutable } from "babylonjs/types";
  40219. import { Camera } from "babylonjs/Cameras/camera";
  40220. import { Scene } from "babylonjs/scene";
  40221. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  40222. import { Color4 } from "babylonjs/Maths/math.color";
  40223. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  40224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40226. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40227. import { Texture } from "babylonjs/Materials/Textures/texture";
  40228. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40229. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  40230. import "babylonjs/Engines/Extensions/engine.renderTarget";
  40231. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  40232. import { Engine } from "babylonjs/Engines/engine";
  40233. /**
  40234. * This Helps creating a texture that will be created from a camera in your scene.
  40235. * It is basically a dynamic texture that could be used to create special effects for instance.
  40236. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  40237. */
  40238. export class RenderTargetTexture extends Texture {
  40239. /**
  40240. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  40241. */
  40242. static readonly REFRESHRATE_RENDER_ONCE: number;
  40243. /**
  40244. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  40245. */
  40246. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  40247. /**
  40248. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  40249. * the central point of your effect and can save a lot of performances.
  40250. */
  40251. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  40252. /**
  40253. * Use this predicate to dynamically define the list of mesh you want to render.
  40254. * If set, the renderList property will be overwritten.
  40255. */
  40256. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  40257. private _renderList;
  40258. /**
  40259. * Use this list to define the list of mesh you want to render.
  40260. */
  40261. get renderList(): Nullable<Array<AbstractMesh>>;
  40262. set renderList(value: Nullable<Array<AbstractMesh>>);
  40263. /**
  40264. * Use this function to overload the renderList array at rendering time.
  40265. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  40266. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  40267. * the cube (if the RTT is a cube, else layerOrFace=0).
  40268. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  40269. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  40270. * hold dummy elements!
  40271. */
  40272. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  40273. private _hookArray;
  40274. /**
  40275. * Define if particles should be rendered in your texture.
  40276. */
  40277. renderParticles: boolean;
  40278. /**
  40279. * Define if sprites should be rendered in your texture.
  40280. */
  40281. renderSprites: boolean;
  40282. /**
  40283. * Define the camera used to render the texture.
  40284. */
  40285. activeCamera: Nullable<Camera>;
  40286. /**
  40287. * Override the mesh isReady function with your own one.
  40288. */
  40289. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  40290. /**
  40291. * Override the render function of the texture with your own one.
  40292. */
  40293. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  40294. /**
  40295. * Define if camera post processes should be use while rendering the texture.
  40296. */
  40297. useCameraPostProcesses: boolean;
  40298. /**
  40299. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  40300. */
  40301. ignoreCameraViewport: boolean;
  40302. private _postProcessManager;
  40303. /**
  40304. * Post-processes for this render target
  40305. */
  40306. get postProcesses(): PostProcess[];
  40307. private _postProcesses;
  40308. private _resizeObserver;
  40309. private get _prePassEnabled();
  40310. /**
  40311. * An event triggered when the texture is unbind.
  40312. */
  40313. onBeforeBindObservable: Observable<RenderTargetTexture>;
  40314. /**
  40315. * An event triggered when the texture is unbind.
  40316. */
  40317. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  40318. private _onAfterUnbindObserver;
  40319. /**
  40320. * Set a after unbind callback in the texture.
  40321. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  40322. */
  40323. set onAfterUnbind(callback: () => void);
  40324. /**
  40325. * An event triggered before rendering the texture
  40326. */
  40327. onBeforeRenderObservable: Observable<number>;
  40328. private _onBeforeRenderObserver;
  40329. /**
  40330. * Set a before render callback in the texture.
  40331. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  40332. */
  40333. set onBeforeRender(callback: (faceIndex: number) => void);
  40334. /**
  40335. * An event triggered after rendering the texture
  40336. */
  40337. onAfterRenderObservable: Observable<number>;
  40338. private _onAfterRenderObserver;
  40339. /**
  40340. * Set a after render callback in the texture.
  40341. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  40342. */
  40343. set onAfterRender(callback: (faceIndex: number) => void);
  40344. /**
  40345. * An event triggered after the texture clear
  40346. */
  40347. onClearObservable: Observable<Engine>;
  40348. private _onClearObserver;
  40349. /**
  40350. * Set a clear callback in the texture.
  40351. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  40352. */
  40353. set onClear(callback: (Engine: Engine) => void);
  40354. /**
  40355. * An event triggered when the texture is resized.
  40356. */
  40357. onResizeObservable: Observable<RenderTargetTexture>;
  40358. /**
  40359. * Define the clear color of the Render Target if it should be different from the scene.
  40360. */
  40361. clearColor: Color4;
  40362. protected _size: number | {
  40363. width: number;
  40364. height: number;
  40365. layers?: number;
  40366. };
  40367. protected _initialSizeParameter: number | {
  40368. width: number;
  40369. height: number;
  40370. } | {
  40371. ratio: number;
  40372. };
  40373. protected _sizeRatio: Nullable<number>;
  40374. /** @hidden */
  40375. _generateMipMaps: boolean;
  40376. protected _renderingManager: RenderingManager;
  40377. /** @hidden */
  40378. _waitingRenderList?: string[];
  40379. protected _doNotChangeAspectRatio: boolean;
  40380. protected _currentRefreshId: number;
  40381. protected _refreshRate: number;
  40382. protected _textureMatrix: Matrix;
  40383. protected _samples: number;
  40384. protected _renderTargetOptions: RenderTargetCreationOptions;
  40385. /**
  40386. * Gets render target creation options that were used.
  40387. */
  40388. get renderTargetOptions(): RenderTargetCreationOptions;
  40389. protected _onRatioRescale(): void;
  40390. /**
  40391. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  40392. * It must define where the camera used to render the texture is set
  40393. */
  40394. boundingBoxPosition: Vector3;
  40395. private _boundingBoxSize;
  40396. /**
  40397. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  40398. * When defined, the cubemap will switch to local mode
  40399. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  40400. * @example https://www.babylonjs-playground.com/#RNASML
  40401. */
  40402. set boundingBoxSize(value: Vector3);
  40403. get boundingBoxSize(): Vector3;
  40404. /**
  40405. * In case the RTT has been created with a depth texture, get the associated
  40406. * depth texture.
  40407. * Otherwise, return null.
  40408. */
  40409. get depthStencilTexture(): Nullable<InternalTexture>;
  40410. /**
  40411. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  40412. * or used a shadow, depth texture...
  40413. * @param name The friendly name of the texture
  40414. * @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)
  40415. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  40416. * @param generateMipMaps True if mip maps need to be generated after render.
  40417. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  40418. * @param type The type of the buffer in the RTT (int, half float, float...)
  40419. * @param isCube True if a cube texture needs to be created
  40420. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  40421. * @param generateDepthBuffer True to generate a depth buffer
  40422. * @param generateStencilBuffer True to generate a stencil buffer
  40423. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  40424. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  40425. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40426. * @param samples sample count to use when creating the RTT
  40427. */
  40428. constructor(name: string, size: number | {
  40429. width: number;
  40430. height: number;
  40431. layers?: number;
  40432. } | {
  40433. ratio: number;
  40434. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean, samples?: number);
  40435. /**
  40436. * Creates a depth stencil texture.
  40437. * This is only available in WebGL 2 or with the depth texture extension available.
  40438. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  40439. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  40440. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  40441. * @param samples sample count of the depth/stencil texture
  40442. */
  40443. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  40444. private _processSizeParameter;
  40445. /**
  40446. * Define the number of samples to use in case of MSAA.
  40447. * It defaults to one meaning no MSAA has been enabled.
  40448. */
  40449. get samples(): number;
  40450. set samples(value: number);
  40451. /**
  40452. * Resets the refresh counter of the texture and start bak from scratch.
  40453. * Could be useful to regenerate the texture if it is setup to render only once.
  40454. */
  40455. resetRefreshCounter(): void;
  40456. /**
  40457. * Define the refresh rate of the texture or the rendering frequency.
  40458. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  40459. */
  40460. get refreshRate(): number;
  40461. set refreshRate(value: number);
  40462. /**
  40463. * Adds a post process to the render target rendering passes.
  40464. * @param postProcess define the post process to add
  40465. */
  40466. addPostProcess(postProcess: PostProcess): void;
  40467. /**
  40468. * Clear all the post processes attached to the render target
  40469. * @param dispose define if the cleared post processes should also be disposed (false by default)
  40470. */
  40471. clearPostProcesses(dispose?: boolean): void;
  40472. /**
  40473. * Remove one of the post process from the list of attached post processes to the texture
  40474. * @param postProcess define the post process to remove from the list
  40475. */
  40476. removePostProcess(postProcess: PostProcess): void;
  40477. /** @hidden */
  40478. _shouldRender(): boolean;
  40479. /**
  40480. * Gets the actual render size of the texture.
  40481. * @returns the width of the render size
  40482. */
  40483. getRenderSize(): number;
  40484. /**
  40485. * Gets the actual render width of the texture.
  40486. * @returns the width of the render size
  40487. */
  40488. getRenderWidth(): number;
  40489. /**
  40490. * Gets the actual render height of the texture.
  40491. * @returns the height of the render size
  40492. */
  40493. getRenderHeight(): number;
  40494. /**
  40495. * Gets the actual number of layers of the texture.
  40496. * @returns the number of layers
  40497. */
  40498. getRenderLayers(): number;
  40499. /**
  40500. * Get if the texture can be rescaled or not.
  40501. */
  40502. get canRescale(): boolean;
  40503. /**
  40504. * Resize the texture using a ratio.
  40505. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  40506. */
  40507. scale(ratio: number): void;
  40508. /**
  40509. * Get the texture reflection matrix used to rotate/transform the reflection.
  40510. * @returns the reflection matrix
  40511. */
  40512. getReflectionTextureMatrix(): Matrix;
  40513. /**
  40514. * Resize the texture to a new desired size.
  40515. * Be careful as it will recreate all the data in the new texture.
  40516. * @param size Define the new size. It can be:
  40517. * - a number for squared texture,
  40518. * - an object containing { width: number, height: number }
  40519. * - or an object containing a ratio { ratio: number }
  40520. */
  40521. resize(size: number | {
  40522. width: number;
  40523. height: number;
  40524. } | {
  40525. ratio: number;
  40526. }): void;
  40527. private _defaultRenderListPrepared;
  40528. /**
  40529. * Renders all the objects from the render list into the texture.
  40530. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  40531. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  40532. */
  40533. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  40534. private _bestReflectionRenderTargetDimension;
  40535. private _prepareRenderingManager;
  40536. /**
  40537. * @hidden
  40538. * @param faceIndex face index to bind to if this is a cubetexture
  40539. * @param layer defines the index of the texture to bind in the array
  40540. */
  40541. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  40542. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40543. /**
  40544. * @hidden
  40545. */
  40546. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  40547. private renderToTarget;
  40548. /**
  40549. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  40550. * This allowed control for front to back rendering or reversely depending of the special needs.
  40551. *
  40552. * @param renderingGroupId The rendering group id corresponding to its index
  40553. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40554. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40555. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40556. */
  40557. 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;
  40558. /**
  40559. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40560. *
  40561. * @param renderingGroupId The rendering group id corresponding to its index
  40562. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40563. */
  40564. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  40565. /**
  40566. * Clones the texture.
  40567. * @returns the cloned texture
  40568. */
  40569. clone(): RenderTargetTexture;
  40570. /**
  40571. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  40572. * @returns The JSON representation of the texture
  40573. */
  40574. serialize(): any;
  40575. /**
  40576. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  40577. */
  40578. disposeFramebufferObjects(): void;
  40579. /**
  40580. * Dispose the texture and release its associated resources.
  40581. */
  40582. dispose(): void;
  40583. /** @hidden */
  40584. _rebuild(): void;
  40585. /**
  40586. * Clear the info related to rendering groups preventing retention point in material dispose.
  40587. */
  40588. freeRenderingGroups(): void;
  40589. /**
  40590. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  40591. * @returns the view count
  40592. */
  40593. getViewCount(): number;
  40594. }
  40595. }
  40596. declare module "babylonjs/Materials/effect" {
  40597. import { Observable } from "babylonjs/Misc/observable";
  40598. import { FloatArray, Nullable } from "babylonjs/types";
  40599. import { IDisposable } from "babylonjs/scene";
  40600. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40601. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40602. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  40603. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40604. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40605. import { Engine } from "babylonjs/Engines/engine";
  40606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40607. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40609. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40610. /**
  40611. * Options to be used when creating an effect.
  40612. */
  40613. export interface IEffectCreationOptions {
  40614. /**
  40615. * Attributes that will be used in the shader.
  40616. */
  40617. attributes: string[];
  40618. /**
  40619. * Uniform variable names that will be set in the shader.
  40620. */
  40621. uniformsNames: string[];
  40622. /**
  40623. * Uniform buffer variable names that will be set in the shader.
  40624. */
  40625. uniformBuffersNames: string[];
  40626. /**
  40627. * Sampler texture variable names that will be set in the shader.
  40628. */
  40629. samplers: string[];
  40630. /**
  40631. * Define statements that will be set in the shader.
  40632. */
  40633. defines: any;
  40634. /**
  40635. * Possible fallbacks for this effect to improve performance when needed.
  40636. */
  40637. fallbacks: Nullable<IEffectFallbacks>;
  40638. /**
  40639. * Callback that will be called when the shader is compiled.
  40640. */
  40641. onCompiled: Nullable<(effect: Effect) => void>;
  40642. /**
  40643. * Callback that will be called if an error occurs during shader compilation.
  40644. */
  40645. onError: Nullable<(effect: Effect, errors: string) => void>;
  40646. /**
  40647. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40648. */
  40649. indexParameters?: any;
  40650. /**
  40651. * Max number of lights that can be used in the shader.
  40652. */
  40653. maxSimultaneousLights?: number;
  40654. /**
  40655. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  40656. */
  40657. transformFeedbackVaryings?: Nullable<string[]>;
  40658. /**
  40659. * 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
  40660. */
  40661. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  40662. /**
  40663. * Is this effect rendering to several color attachments ?
  40664. */
  40665. multiTarget?: boolean;
  40666. }
  40667. /**
  40668. * Effect containing vertex and fragment shader that can be executed on an object.
  40669. */
  40670. export class Effect implements IDisposable {
  40671. /**
  40672. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40673. */
  40674. static ShadersRepository: string;
  40675. /**
  40676. * Enable logging of the shader code when a compilation error occurs
  40677. */
  40678. static LogShaderCodeOnCompilationError: boolean;
  40679. /**
  40680. * Name of the effect.
  40681. */
  40682. name: any;
  40683. /**
  40684. * String container all the define statements that should be set on the shader.
  40685. */
  40686. defines: string;
  40687. /**
  40688. * Callback that will be called when the shader is compiled.
  40689. */
  40690. onCompiled: Nullable<(effect: Effect) => void>;
  40691. /**
  40692. * Callback that will be called if an error occurs during shader compilation.
  40693. */
  40694. onError: Nullable<(effect: Effect, errors: string) => void>;
  40695. /**
  40696. * Callback that will be called when effect is bound.
  40697. */
  40698. onBind: Nullable<(effect: Effect) => void>;
  40699. /**
  40700. * Unique ID of the effect.
  40701. */
  40702. uniqueId: number;
  40703. /**
  40704. * Observable that will be called when the shader is compiled.
  40705. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  40706. */
  40707. onCompileObservable: Observable<Effect>;
  40708. /**
  40709. * Observable that will be called if an error occurs during shader compilation.
  40710. */
  40711. onErrorObservable: Observable<Effect>;
  40712. /** @hidden */
  40713. _onBindObservable: Nullable<Observable<Effect>>;
  40714. /**
  40715. * @hidden
  40716. * Specifies if the effect was previously ready
  40717. */
  40718. _wasPreviouslyReady: boolean;
  40719. /**
  40720. * Observable that will be called when effect is bound.
  40721. */
  40722. get onBindObservable(): Observable<Effect>;
  40723. /** @hidden */
  40724. _bonesComputationForcedToCPU: boolean;
  40725. /** @hidden */
  40726. _uniformBuffersNames: {
  40727. [key: string]: number;
  40728. };
  40729. /** @hidden */
  40730. _samplerList: string[];
  40731. /** @hidden */
  40732. _multiTarget: boolean;
  40733. private static _uniqueIdSeed;
  40734. private _engine;
  40735. private _uniformBuffersNamesList;
  40736. private _uniformsNames;
  40737. private _samplers;
  40738. private _isReady;
  40739. private _compilationError;
  40740. private _allFallbacksProcessed;
  40741. private _attributesNames;
  40742. private _attributes;
  40743. private _attributeLocationByName;
  40744. private _uniforms;
  40745. /**
  40746. * Key for the effect.
  40747. * @hidden
  40748. */
  40749. _key: string;
  40750. private _indexParameters;
  40751. private _fallbacks;
  40752. private _vertexSourceCodeOverride;
  40753. private _fragmentSourceCodeOverride;
  40754. private _transformFeedbackVaryings;
  40755. /**
  40756. * Compiled shader to webGL program.
  40757. * @hidden
  40758. */
  40759. _pipelineContext: Nullable<IPipelineContext>;
  40760. /** @hidden */
  40761. _vertexSourceCode: string;
  40762. /** @hidden */
  40763. _fragmentSourceCode: string;
  40764. /** @hidden */
  40765. private _rawVertexSourceCode;
  40766. /** @hidden */
  40767. private _rawFragmentSourceCode;
  40768. private static _baseCache;
  40769. private _processingContext;
  40770. /**
  40771. * Instantiates an effect.
  40772. * An effect can be used to create/manage/execute vertex and fragment shaders.
  40773. * @param baseName Name of the effect.
  40774. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  40775. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  40776. * @param samplers List of sampler variables that will be passed to the shader.
  40777. * @param engine Engine to be used to render the effect
  40778. * @param defines Define statements to be added to the shader.
  40779. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  40780. * @param onCompiled Callback that will be called when the shader is compiled.
  40781. * @param onError Callback that will be called if an error occurs during shader compilation.
  40782. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40783. * @param key Effect Key identifying uniquely compiled shader variants
  40784. */
  40785. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any, key?: string);
  40786. private _useFinalCode;
  40787. /**
  40788. * Unique key for this effect
  40789. */
  40790. get key(): string;
  40791. /**
  40792. * If the effect has been compiled and prepared.
  40793. * @returns if the effect is compiled and prepared.
  40794. */
  40795. isReady(): boolean;
  40796. private _isReadyInternal;
  40797. /**
  40798. * The engine the effect was initialized with.
  40799. * @returns the engine.
  40800. */
  40801. getEngine(): Engine;
  40802. /**
  40803. * The pipeline context for this effect
  40804. * @returns the associated pipeline context
  40805. */
  40806. getPipelineContext(): Nullable<IPipelineContext>;
  40807. /**
  40808. * The set of names of attribute variables for the shader.
  40809. * @returns An array of attribute names.
  40810. */
  40811. getAttributesNames(): string[];
  40812. /**
  40813. * Returns the attribute at the given index.
  40814. * @param index The index of the attribute.
  40815. * @returns The location of the attribute.
  40816. */
  40817. getAttributeLocation(index: number): number;
  40818. /**
  40819. * Returns the attribute based on the name of the variable.
  40820. * @param name of the attribute to look up.
  40821. * @returns the attribute location.
  40822. */
  40823. getAttributeLocationByName(name: string): number;
  40824. /**
  40825. * The number of attributes.
  40826. * @returns the number of attributes.
  40827. */
  40828. getAttributesCount(): number;
  40829. /**
  40830. * Gets the index of a uniform variable.
  40831. * @param uniformName of the uniform to look up.
  40832. * @returns the index.
  40833. */
  40834. getUniformIndex(uniformName: string): number;
  40835. /**
  40836. * Returns the attribute based on the name of the variable.
  40837. * @param uniformName of the uniform to look up.
  40838. * @returns the location of the uniform.
  40839. */
  40840. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  40841. /**
  40842. * Returns an array of sampler variable names
  40843. * @returns The array of sampler variable names.
  40844. */
  40845. getSamplers(): string[];
  40846. /**
  40847. * Returns an array of uniform variable names
  40848. * @returns The array of uniform variable names.
  40849. */
  40850. getUniformNames(): string[];
  40851. /**
  40852. * Returns an array of uniform buffer variable names
  40853. * @returns The array of uniform buffer variable names.
  40854. */
  40855. getUniformBuffersNames(): string[];
  40856. /**
  40857. * Returns the index parameters used to create the effect
  40858. * @returns The index parameters object
  40859. */
  40860. getIndexParameters(): any;
  40861. /**
  40862. * The error from the last compilation.
  40863. * @returns the error string.
  40864. */
  40865. getCompilationError(): string;
  40866. /**
  40867. * Gets a boolean indicating that all fallbacks were used during compilation
  40868. * @returns true if all fallbacks were used
  40869. */
  40870. allFallbacksProcessed(): boolean;
  40871. /**
  40872. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  40873. * @param func The callback to be used.
  40874. */
  40875. executeWhenCompiled(func: (effect: Effect) => void): void;
  40876. private _checkIsReady;
  40877. private _loadShader;
  40878. /**
  40879. * Gets the vertex shader source code of this effect
  40880. */
  40881. get vertexSourceCode(): string;
  40882. /**
  40883. * Gets the fragment shader source code of this effect
  40884. */
  40885. get fragmentSourceCode(): string;
  40886. /**
  40887. * Gets the vertex shader source code before it has been processed by the preprocessor
  40888. */
  40889. get rawVertexSourceCode(): string;
  40890. /**
  40891. * Gets the fragment shader source code before it has been processed by the preprocessor
  40892. */
  40893. get rawFragmentSourceCode(): string;
  40894. /**
  40895. * Recompiles the webGL program
  40896. * @param vertexSourceCode The source code for the vertex shader.
  40897. * @param fragmentSourceCode The source code for the fragment shader.
  40898. * @param onCompiled Callback called when completed.
  40899. * @param onError Callback called on error.
  40900. * @hidden
  40901. */
  40902. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  40903. /**
  40904. * Prepares the effect
  40905. * @hidden
  40906. */
  40907. _prepareEffect(): void;
  40908. private _getShaderCodeAndErrorLine;
  40909. private _processCompilationErrors;
  40910. /**
  40911. * Checks if the effect is supported. (Must be called after compilation)
  40912. */
  40913. get isSupported(): boolean;
  40914. /**
  40915. * Binds a texture to the engine to be used as output of the shader.
  40916. * @param channel Name of the output variable.
  40917. * @param texture Texture to bind.
  40918. * @hidden
  40919. */
  40920. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  40921. /**
  40922. * Sets a texture on the engine to be used in the shader.
  40923. * @param channel Name of the sampler variable.
  40924. * @param texture Texture to set.
  40925. */
  40926. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  40927. /**
  40928. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  40929. * @param channel Name of the sampler variable.
  40930. * @param texture Texture to set.
  40931. */
  40932. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  40933. /**
  40934. * Sets an array of textures on the engine to be used in the shader.
  40935. * @param channel Name of the variable.
  40936. * @param textures Textures to set.
  40937. */
  40938. setTextureArray(channel: string, textures: ThinTexture[]): void;
  40939. /**
  40940. * 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)
  40941. * @param channel Name of the sampler variable.
  40942. * @param postProcess Post process to get the input texture from.
  40943. */
  40944. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  40945. /**
  40946. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  40947. * 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)
  40948. * @param channel Name of the sampler variable.
  40949. * @param postProcess Post process to get the output texture from.
  40950. */
  40951. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  40952. /**
  40953. * Binds a buffer to a uniform.
  40954. * @param buffer Buffer to bind.
  40955. * @param name Name of the uniform variable to bind to.
  40956. */
  40957. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  40958. /**
  40959. * Binds block to a uniform.
  40960. * @param blockName Name of the block to bind.
  40961. * @param index Index to bind.
  40962. */
  40963. bindUniformBlock(blockName: string, index: number): void;
  40964. /**
  40965. * Sets an integer value on a uniform variable.
  40966. * @param uniformName Name of the variable.
  40967. * @param value Value to be set.
  40968. * @returns this effect.
  40969. */
  40970. setInt(uniformName: string, value: number): Effect;
  40971. /**
  40972. * Sets an int2 value on a uniform variable.
  40973. * @param uniformName Name of the variable.
  40974. * @param x First int in int2.
  40975. * @param y Second int in int2.
  40976. * @returns this effect.
  40977. */
  40978. setInt2(uniformName: string, x: number, y: number): Effect;
  40979. /**
  40980. * Sets an int3 value on a uniform variable.
  40981. * @param uniformName Name of the variable.
  40982. * @param x First int in int3.
  40983. * @param y Second int in int3.
  40984. * @param z Third int in int3.
  40985. * @returns this effect.
  40986. */
  40987. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  40988. /**
  40989. * Sets an int4 value on a uniform variable.
  40990. * @param uniformName Name of the variable.
  40991. * @param x First int in int4.
  40992. * @param y Second int in int4.
  40993. * @param z Third int in int4.
  40994. * @param w Fourth int in int4.
  40995. * @returns this effect.
  40996. */
  40997. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40998. /**
  40999. * Sets an int array on a uniform variable.
  41000. * @param uniformName Name of the variable.
  41001. * @param array array to be set.
  41002. * @returns this effect.
  41003. */
  41004. setIntArray(uniformName: string, array: Int32Array): Effect;
  41005. /**
  41006. * 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)
  41007. * @param uniformName Name of the variable.
  41008. * @param array array to be set.
  41009. * @returns this effect.
  41010. */
  41011. setIntArray2(uniformName: string, array: Int32Array): Effect;
  41012. /**
  41013. * 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)
  41014. * @param uniformName Name of the variable.
  41015. * @param array array to be set.
  41016. * @returns this effect.
  41017. */
  41018. setIntArray3(uniformName: string, array: Int32Array): Effect;
  41019. /**
  41020. * 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)
  41021. * @param uniformName Name of the variable.
  41022. * @param array array to be set.
  41023. * @returns this effect.
  41024. */
  41025. setIntArray4(uniformName: string, array: Int32Array): Effect;
  41026. /**
  41027. * Sets an float array on a uniform variable.
  41028. * @param uniformName Name of the variable.
  41029. * @param array array to be set.
  41030. * @returns this effect.
  41031. */
  41032. setFloatArray(uniformName: string, array: FloatArray): Effect;
  41033. /**
  41034. * 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)
  41035. * @param uniformName Name of the variable.
  41036. * @param array array to be set.
  41037. * @returns this effect.
  41038. */
  41039. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  41040. /**
  41041. * 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)
  41042. * @param uniformName Name of the variable.
  41043. * @param array array to be set.
  41044. * @returns this effect.
  41045. */
  41046. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  41047. /**
  41048. * 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)
  41049. * @param uniformName Name of the variable.
  41050. * @param array array to be set.
  41051. * @returns this effect.
  41052. */
  41053. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  41054. /**
  41055. * Sets an array on a uniform variable.
  41056. * @param uniformName Name of the variable.
  41057. * @param array array to be set.
  41058. * @returns this effect.
  41059. */
  41060. setArray(uniformName: string, array: number[]): Effect;
  41061. /**
  41062. * 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)
  41063. * @param uniformName Name of the variable.
  41064. * @param array array to be set.
  41065. * @returns this effect.
  41066. */
  41067. setArray2(uniformName: string, array: number[]): Effect;
  41068. /**
  41069. * 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)
  41070. * @param uniformName Name of the variable.
  41071. * @param array array to be set.
  41072. * @returns this effect.
  41073. */
  41074. setArray3(uniformName: string, array: number[]): Effect;
  41075. /**
  41076. * 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)
  41077. * @param uniformName Name of the variable.
  41078. * @param array array to be set.
  41079. * @returns this effect.
  41080. */
  41081. setArray4(uniformName: string, array: number[]): Effect;
  41082. /**
  41083. * Sets matrices on a uniform variable.
  41084. * @param uniformName Name of the variable.
  41085. * @param matrices matrices to be set.
  41086. * @returns this effect.
  41087. */
  41088. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  41089. /**
  41090. * Sets matrix on a uniform variable.
  41091. * @param uniformName Name of the variable.
  41092. * @param matrix matrix to be set.
  41093. * @returns this effect.
  41094. */
  41095. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  41096. /**
  41097. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  41098. * @param uniformName Name of the variable.
  41099. * @param matrix matrix to be set.
  41100. * @returns this effect.
  41101. */
  41102. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  41103. /**
  41104. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  41105. * @param uniformName Name of the variable.
  41106. * @param matrix matrix to be set.
  41107. * @returns this effect.
  41108. */
  41109. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  41110. /**
  41111. * Sets a float on a uniform variable.
  41112. * @param uniformName Name of the variable.
  41113. * @param value value to be set.
  41114. * @returns this effect.
  41115. */
  41116. setFloat(uniformName: string, value: number): Effect;
  41117. /**
  41118. * Sets a boolean on a uniform variable.
  41119. * @param uniformName Name of the variable.
  41120. * @param bool value to be set.
  41121. * @returns this effect.
  41122. */
  41123. setBool(uniformName: string, bool: boolean): Effect;
  41124. /**
  41125. * Sets a Vector2 on a uniform variable.
  41126. * @param uniformName Name of the variable.
  41127. * @param vector2 vector2 to be set.
  41128. * @returns this effect.
  41129. */
  41130. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  41131. /**
  41132. * Sets a float2 on a uniform variable.
  41133. * @param uniformName Name of the variable.
  41134. * @param x First float in float2.
  41135. * @param y Second float in float2.
  41136. * @returns this effect.
  41137. */
  41138. setFloat2(uniformName: string, x: number, y: number): Effect;
  41139. /**
  41140. * Sets a Vector3 on a uniform variable.
  41141. * @param uniformName Name of the variable.
  41142. * @param vector3 Value to be set.
  41143. * @returns this effect.
  41144. */
  41145. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  41146. /**
  41147. * Sets a float3 on a uniform variable.
  41148. * @param uniformName Name of the variable.
  41149. * @param x First float in float3.
  41150. * @param y Second float in float3.
  41151. * @param z Third float in float3.
  41152. * @returns this effect.
  41153. */
  41154. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  41155. /**
  41156. * Sets a Vector4 on a uniform variable.
  41157. * @param uniformName Name of the variable.
  41158. * @param vector4 Value to be set.
  41159. * @returns this effect.
  41160. */
  41161. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  41162. /**
  41163. * Sets a float4 on a uniform variable.
  41164. * @param uniformName Name of the variable.
  41165. * @param x First float in float4.
  41166. * @param y Second float in float4.
  41167. * @param z Third float in float4.
  41168. * @param w Fourth float in float4.
  41169. * @returns this effect.
  41170. */
  41171. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  41172. /**
  41173. * Sets a Color3 on a uniform variable.
  41174. * @param uniformName Name of the variable.
  41175. * @param color3 Value to be set.
  41176. * @returns this effect.
  41177. */
  41178. setColor3(uniformName: string, color3: IColor3Like): Effect;
  41179. /**
  41180. * Sets a Color4 on a uniform variable.
  41181. * @param uniformName Name of the variable.
  41182. * @param color3 Value to be set.
  41183. * @param alpha Alpha value to be set.
  41184. * @returns this effect.
  41185. */
  41186. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  41187. /**
  41188. * Sets a Color4 on a uniform variable
  41189. * @param uniformName defines the name of the variable
  41190. * @param color4 defines the value to be set
  41191. * @returns this effect.
  41192. */
  41193. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  41194. /**
  41195. * Release all associated resources.
  41196. **/
  41197. dispose(): void;
  41198. /**
  41199. * This function will add a new shader to the shader store
  41200. * @param name the name of the shader
  41201. * @param pixelShader optional pixel shader content
  41202. * @param vertexShader optional vertex shader content
  41203. */
  41204. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  41205. /**
  41206. * Store of each shader (The can be looked up using effect.key)
  41207. */
  41208. static ShadersStore: {
  41209. [key: string]: string;
  41210. };
  41211. /**
  41212. * Store of each included file for a shader (The can be looked up using effect.key)
  41213. */
  41214. static IncludesShadersStore: {
  41215. [key: string]: string;
  41216. };
  41217. /**
  41218. * Resets the cache of effects.
  41219. */
  41220. static ResetCache(): void;
  41221. }
  41222. }
  41223. declare module "babylonjs/Engines/engineCapabilities" {
  41224. /**
  41225. * Interface used to describe the capabilities of the engine relatively to the current browser
  41226. */
  41227. export interface EngineCapabilities {
  41228. /** Maximum textures units per fragment shader */
  41229. maxTexturesImageUnits: number;
  41230. /** Maximum texture units per vertex shader */
  41231. maxVertexTextureImageUnits: number;
  41232. /** Maximum textures units in the entire pipeline */
  41233. maxCombinedTexturesImageUnits: number;
  41234. /** Maximum texture size */
  41235. maxTextureSize: number;
  41236. /** Maximum texture samples */
  41237. maxSamples?: number;
  41238. /** Maximum cube texture size */
  41239. maxCubemapTextureSize: number;
  41240. /** Maximum render texture size */
  41241. maxRenderTextureSize: number;
  41242. /** Maximum number of vertex attributes */
  41243. maxVertexAttribs: number;
  41244. /** Maximum number of varyings */
  41245. maxVaryingVectors: number;
  41246. /** Maximum number of uniforms per vertex shader */
  41247. maxVertexUniformVectors: number;
  41248. /** Maximum number of uniforms per fragment shader */
  41249. maxFragmentUniformVectors: number;
  41250. /** Defines if standard derivatives (dx/dy) are supported */
  41251. standardDerivatives: boolean;
  41252. /** Defines if s3tc texture compression is supported */
  41253. s3tc?: WEBGL_compressed_texture_s3tc;
  41254. /** Defines if pvrtc texture compression is supported */
  41255. pvrtc: any;
  41256. /** Defines if etc1 texture compression is supported */
  41257. etc1: any;
  41258. /** Defines if etc2 texture compression is supported */
  41259. etc2: any;
  41260. /** Defines if astc texture compression is supported */
  41261. astc: any;
  41262. /** Defines if bptc texture compression is supported */
  41263. bptc: any;
  41264. /** Defines if float textures are supported */
  41265. textureFloat: boolean;
  41266. /** Defines if vertex array objects are supported */
  41267. vertexArrayObject: boolean;
  41268. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  41269. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  41270. /** Gets the maximum level of anisotropy supported */
  41271. maxAnisotropy: number;
  41272. /** Defines if instancing is supported */
  41273. instancedArrays: boolean;
  41274. /** Defines if 32 bits indices are supported */
  41275. uintIndices: boolean;
  41276. /** Defines if high precision shaders are supported */
  41277. highPrecisionShaderSupported: boolean;
  41278. /** Defines if depth reading in the fragment shader is supported */
  41279. fragmentDepthSupported: boolean;
  41280. /** Defines if float texture linear filtering is supported*/
  41281. textureFloatLinearFiltering: boolean;
  41282. /** Defines if rendering to float textures is supported */
  41283. textureFloatRender: boolean;
  41284. /** Defines if half float textures are supported*/
  41285. textureHalfFloat: boolean;
  41286. /** Defines if half float texture linear filtering is supported*/
  41287. textureHalfFloatLinearFiltering: boolean;
  41288. /** Defines if rendering to half float textures is supported */
  41289. textureHalfFloatRender: boolean;
  41290. /** Defines if textureLOD shader command is supported */
  41291. textureLOD: boolean;
  41292. /** Defines if draw buffers extension is supported */
  41293. drawBuffersExtension: boolean;
  41294. /** Defines if depth textures are supported */
  41295. depthTextureExtension: boolean;
  41296. /** Defines if float color buffer are supported */
  41297. colorBufferFloat: boolean;
  41298. /** Gets disjoint timer query extension (null if not supported) */
  41299. timerQuery?: EXT_disjoint_timer_query;
  41300. /** Defines if timestamp can be used with timer query */
  41301. canUseTimestampForTimerQuery: boolean;
  41302. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  41303. multiview?: any;
  41304. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  41305. oculusMultiview?: any;
  41306. /** Function used to let the system compiles shaders in background */
  41307. parallelShaderCompile?: {
  41308. COMPLETION_STATUS_KHR: number;
  41309. };
  41310. /** Max number of texture samples for MSAA */
  41311. maxMSAASamples: number;
  41312. /** Defines if the blend min max extension is supported */
  41313. blendMinMax: boolean;
  41314. /** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
  41315. canUseGLInstanceID: boolean;
  41316. /** Defines if gl_vertexID is available */
  41317. canUseGLVertexID: boolean;
  41318. }
  41319. }
  41320. declare module "babylonjs/States/depthCullingState" {
  41321. import { Nullable } from "babylonjs/types";
  41322. /**
  41323. * @hidden
  41324. **/
  41325. export class DepthCullingState {
  41326. protected _isDepthTestDirty: boolean;
  41327. protected _isDepthMaskDirty: boolean;
  41328. protected _isDepthFuncDirty: boolean;
  41329. protected _isCullFaceDirty: boolean;
  41330. protected _isCullDirty: boolean;
  41331. protected _isZOffsetDirty: boolean;
  41332. protected _isFrontFaceDirty: boolean;
  41333. protected _depthTest: boolean;
  41334. protected _depthMask: boolean;
  41335. protected _depthFunc: Nullable<number>;
  41336. protected _cull: Nullable<boolean>;
  41337. protected _cullFace: Nullable<number>;
  41338. protected _zOffset: number;
  41339. protected _frontFace: Nullable<number>;
  41340. /**
  41341. * Initializes the state.
  41342. */
  41343. constructor(reset?: boolean);
  41344. get isDirty(): boolean;
  41345. get zOffset(): number;
  41346. set zOffset(value: number);
  41347. get cullFace(): Nullable<number>;
  41348. set cullFace(value: Nullable<number>);
  41349. get cull(): Nullable<boolean>;
  41350. set cull(value: Nullable<boolean>);
  41351. get depthFunc(): Nullable<number>;
  41352. set depthFunc(value: Nullable<number>);
  41353. get depthMask(): boolean;
  41354. set depthMask(value: boolean);
  41355. get depthTest(): boolean;
  41356. set depthTest(value: boolean);
  41357. get frontFace(): Nullable<number>;
  41358. set frontFace(value: Nullable<number>);
  41359. reset(): void;
  41360. apply(gl: WebGLRenderingContext): void;
  41361. }
  41362. }
  41363. declare module "babylonjs/States/stencilState" {
  41364. /**
  41365. * @hidden
  41366. **/
  41367. export class StencilState {
  41368. /** 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 */
  41369. static readonly ALWAYS: number;
  41370. /** Passed to stencilOperation to specify that stencil value must be kept */
  41371. static readonly KEEP: number;
  41372. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41373. static readonly REPLACE: number;
  41374. protected _isStencilTestDirty: boolean;
  41375. protected _isStencilMaskDirty: boolean;
  41376. protected _isStencilFuncDirty: boolean;
  41377. protected _isStencilOpDirty: boolean;
  41378. protected _stencilTest: boolean;
  41379. protected _stencilMask: number;
  41380. protected _stencilFunc: number;
  41381. protected _stencilFuncRef: number;
  41382. protected _stencilFuncMask: number;
  41383. protected _stencilOpStencilFail: number;
  41384. protected _stencilOpDepthFail: number;
  41385. protected _stencilOpStencilDepthPass: number;
  41386. get isDirty(): boolean;
  41387. get stencilFunc(): number;
  41388. set stencilFunc(value: number);
  41389. get stencilFuncRef(): number;
  41390. set stencilFuncRef(value: number);
  41391. get stencilFuncMask(): number;
  41392. set stencilFuncMask(value: number);
  41393. get stencilOpStencilFail(): number;
  41394. set stencilOpStencilFail(value: number);
  41395. get stencilOpDepthFail(): number;
  41396. set stencilOpDepthFail(value: number);
  41397. get stencilOpStencilDepthPass(): number;
  41398. set stencilOpStencilDepthPass(value: number);
  41399. get stencilMask(): number;
  41400. set stencilMask(value: number);
  41401. get stencilTest(): boolean;
  41402. set stencilTest(value: boolean);
  41403. constructor(reset?: boolean);
  41404. reset(): void;
  41405. apply(gl: WebGLRenderingContext): void;
  41406. }
  41407. }
  41408. declare module "babylonjs/States/alphaCullingState" {
  41409. import { Nullable } from "babylonjs/types";
  41410. /**
  41411. * @hidden
  41412. **/
  41413. export class AlphaState {
  41414. _blendFunctionParameters: Nullable<number>[];
  41415. _blendEquationParameters: Nullable<number>[];
  41416. _blendConstants: Nullable<number>[];
  41417. _isBlendConstantsDirty: boolean;
  41418. private _alphaBlend;
  41419. private _isAlphaBlendDirty;
  41420. private _isBlendFunctionParametersDirty;
  41421. private _isBlendEquationParametersDirty;
  41422. /**
  41423. * Initializes the state.
  41424. */
  41425. constructor();
  41426. get isDirty(): boolean;
  41427. get alphaBlend(): boolean;
  41428. set alphaBlend(value: boolean);
  41429. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  41430. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  41431. setAlphaEquationParameters(rgb: number, alpha: number): void;
  41432. reset(): void;
  41433. apply(gl: WebGLRenderingContext): void;
  41434. }
  41435. }
  41436. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  41437. import { Nullable } from "babylonjs/types";
  41438. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41439. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41440. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41441. /** @hidden */
  41442. export class WebGLShaderProcessor implements IShaderProcessor {
  41443. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41444. }
  41445. }
  41446. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  41447. import { Nullable } from "babylonjs/types";
  41448. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41449. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41450. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41451. /** @hidden */
  41452. export class WebGL2ShaderProcessor implements IShaderProcessor {
  41453. attributeProcessor(attribute: string): string;
  41454. varyingProcessor(varying: string, isFragment: boolean): string;
  41455. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41456. }
  41457. }
  41458. declare module "babylonjs/Engines/instancingAttributeInfo" {
  41459. /**
  41460. * Interface for attribute information associated with buffer instantiation
  41461. */
  41462. export interface InstancingAttributeInfo {
  41463. /**
  41464. * Name of the GLSL attribute
  41465. * if attribute index is not specified, this is used to retrieve the index from the effect
  41466. */
  41467. attributeName: string;
  41468. /**
  41469. * Index/offset of the attribute in the vertex shader
  41470. * if not specified, this will be computes from the name.
  41471. */
  41472. index?: number;
  41473. /**
  41474. * size of the attribute, 1, 2, 3 or 4
  41475. */
  41476. attributeSize: number;
  41477. /**
  41478. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  41479. */
  41480. offset: number;
  41481. /**
  41482. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  41483. * default to 1
  41484. */
  41485. divisor?: number;
  41486. /**
  41487. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  41488. * default is FLOAT
  41489. */
  41490. attributeType?: number;
  41491. /**
  41492. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  41493. */
  41494. normalized?: boolean;
  41495. }
  41496. }
  41497. declare module "babylonjs/Engines/engineFeatures" {
  41498. /** @hidden */
  41499. export interface EngineFeatures {
  41500. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  41501. forceBitmapOverHTMLImageElement: boolean;
  41502. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  41503. supportRenderAndCopyToLodForFloatTextures: boolean;
  41504. /** Indicates that the engine support handling depth/stencil textures */
  41505. supportDepthStencilTexture: boolean;
  41506. /** Indicates that the engine support shadow samplers */
  41507. supportShadowSamplers: boolean;
  41508. /** Indicates to check the matrix bytes per bytes to know if it has changed or not. If false, only the updateFlag of the matrix is checked */
  41509. uniformBufferHardCheckMatrix: boolean;
  41510. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  41511. allowTexturePrefiltering: boolean;
  41512. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  41513. trackUbosInFrame: boolean;
  41514. /** Indicates that the Cascaded Shadow Map technic is supported */
  41515. supportCSM: boolean;
  41516. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  41517. basisNeedsPOT: boolean;
  41518. /** Indicates that the engine supports 3D textures */
  41519. support3DTextures: boolean;
  41520. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  41521. needTypeSuffixInShaderConstants: boolean;
  41522. /** Indicates that MSAA is supported */
  41523. supportMSAA: boolean;
  41524. /** Indicates that SSAO2 is supported */
  41525. supportSSAO2: boolean;
  41526. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  41527. supportExtendedTextureFormats: boolean;
  41528. /** Indicates that the switch/case construct is supported in shaders */
  41529. supportSwitchCaseInShader: boolean;
  41530. /** Indicates that synchronous texture reading is supported */
  41531. supportSyncTextureRead: boolean;
  41532. /** @hidden */
  41533. _collectUbosUpdatedInFrame: boolean;
  41534. }
  41535. }
  41536. declare module "babylonjs/Engines/WebGL/webGLHardwareTexture" {
  41537. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41538. import { Nullable } from "babylonjs/types";
  41539. /** @hidden */
  41540. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  41541. private _webGLTexture;
  41542. private _context;
  41543. get underlyingResource(): Nullable<WebGLTexture>;
  41544. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  41545. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  41546. set(hardwareTexture: WebGLTexture): void;
  41547. reset(): void;
  41548. release(): void;
  41549. }
  41550. }
  41551. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  41552. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41553. import { Nullable } from "babylonjs/types";
  41554. module "babylonjs/Engines/thinEngine" {
  41555. interface ThinEngine {
  41556. /**
  41557. * Update a video texture
  41558. * @param texture defines the texture to update
  41559. * @param video defines the video element to use
  41560. * @param invertY defines if data must be stored with Y axis inverted
  41561. */
  41562. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  41563. }
  41564. }
  41565. }
  41566. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  41567. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41568. import { Nullable } from "babylonjs/types";
  41569. module "babylonjs/Engines/thinEngine" {
  41570. interface ThinEngine {
  41571. /**
  41572. * Creates a dynamic texture
  41573. * @param width defines the width of the texture
  41574. * @param height defines the height of the texture
  41575. * @param generateMipMaps defines if the engine should generate the mip levels
  41576. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  41577. * @returns the dynamic texture inside an InternalTexture
  41578. */
  41579. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  41580. /**
  41581. * Update the content of a dynamic texture
  41582. * @param texture defines the texture to update
  41583. * @param source defines the source containing the data
  41584. * @param invertY defines if data must be stored with Y axis inverted
  41585. * @param premulAlpha defines if alpha is stored as premultiplied
  41586. * @param format defines the format of the data
  41587. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  41588. */
  41589. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  41590. }
  41591. }
  41592. }
  41593. declare module "babylonjs/Materials/Textures/videoTexture" {
  41594. import { Observable } from "babylonjs/Misc/observable";
  41595. import { Nullable } from "babylonjs/types";
  41596. import { Scene } from "babylonjs/scene";
  41597. import { Texture } from "babylonjs/Materials/Textures/texture";
  41598. import "babylonjs/Engines/Extensions/engine.videoTexture";
  41599. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  41600. /**
  41601. * Settings for finer control over video usage
  41602. */
  41603. export interface VideoTextureSettings {
  41604. /**
  41605. * Applies `autoplay` to video, if specified
  41606. */
  41607. autoPlay?: boolean;
  41608. /**
  41609. * Applies `muted` to video, if specified
  41610. */
  41611. muted?: boolean;
  41612. /**
  41613. * Applies `loop` to video, if specified
  41614. */
  41615. loop?: boolean;
  41616. /**
  41617. * Automatically updates internal texture from video at every frame in the render loop
  41618. */
  41619. autoUpdateTexture: boolean;
  41620. /**
  41621. * Image src displayed during the video loading or until the user interacts with the video.
  41622. */
  41623. poster?: string;
  41624. }
  41625. /**
  41626. * If you want to display a video in your scene, this is the special texture for that.
  41627. * This special texture works similar to other textures, with the exception of a few parameters.
  41628. * @see https://doc.babylonjs.com/how_to/video_texture
  41629. */
  41630. export class VideoTexture extends Texture {
  41631. /**
  41632. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  41633. */
  41634. readonly autoUpdateTexture: boolean;
  41635. /**
  41636. * The video instance used by the texture internally
  41637. */
  41638. readonly video: HTMLVideoElement;
  41639. private _onUserActionRequestedObservable;
  41640. /**
  41641. * Event triggered when a dom action is required by the user to play the video.
  41642. * This happens due to recent changes in browser policies preventing video to auto start.
  41643. */
  41644. get onUserActionRequestedObservable(): Observable<Texture>;
  41645. private _generateMipMaps;
  41646. private _stillImageCaptured;
  41647. private _displayingPosterTexture;
  41648. private _settings;
  41649. private _createInternalTextureOnEvent;
  41650. private _frameId;
  41651. private _currentSrc;
  41652. /**
  41653. * Creates a video texture.
  41654. * If you want to display a video in your scene, this is the special texture for that.
  41655. * This special texture works similar to other textures, with the exception of a few parameters.
  41656. * @see https://doc.babylonjs.com/how_to/video_texture
  41657. * @param name optional name, will detect from video source, if not defined
  41658. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  41659. * @param scene is obviously the current scene.
  41660. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  41661. * @param invertY is false by default but can be used to invert video on Y axis
  41662. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  41663. * @param settings allows finer control over video usage
  41664. */
  41665. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  41666. private _getName;
  41667. private _getVideo;
  41668. private _createInternalTexture;
  41669. private reset;
  41670. /**
  41671. * @hidden Internal method to initiate `update`.
  41672. */
  41673. _rebuild(): void;
  41674. /**
  41675. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  41676. */
  41677. update(): void;
  41678. /**
  41679. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  41680. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  41681. */
  41682. updateTexture(isVisible: boolean): void;
  41683. protected _updateInternalTexture: () => void;
  41684. /**
  41685. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  41686. * @param url New url.
  41687. */
  41688. updateURL(url: string): void;
  41689. /**
  41690. * Clones the texture.
  41691. * @returns the cloned texture
  41692. */
  41693. clone(): VideoTexture;
  41694. /**
  41695. * Dispose the texture and release its associated resources.
  41696. */
  41697. dispose(): void;
  41698. /**
  41699. * Creates a video texture straight from a stream.
  41700. * @param scene Define the scene the texture should be created in
  41701. * @param stream Define the stream the texture should be created from
  41702. * @returns The created video texture as a promise
  41703. */
  41704. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  41705. /**
  41706. * Creates a video texture straight from your WebCam video feed.
  41707. * @param scene Define the scene the texture should be created in
  41708. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41709. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41710. * @returns The created video texture as a promise
  41711. */
  41712. static CreateFromWebCamAsync(scene: Scene, constraints: {
  41713. minWidth: number;
  41714. maxWidth: number;
  41715. minHeight: number;
  41716. maxHeight: number;
  41717. deviceId: string;
  41718. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  41719. /**
  41720. * Creates a video texture straight from your WebCam video feed.
  41721. * @param scene Define the scene the texture should be created in
  41722. * @param onReady Define a callback to triggered once the texture will be ready
  41723. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41724. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41725. */
  41726. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  41727. minWidth: number;
  41728. maxWidth: number;
  41729. minHeight: number;
  41730. maxHeight: number;
  41731. deviceId: string;
  41732. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  41733. }
  41734. }
  41735. declare module "babylonjs/Engines/thinEngine" {
  41736. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  41737. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  41738. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41739. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41740. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  41741. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  41742. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  41743. import { Observable } from "babylonjs/Misc/observable";
  41744. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  41745. import { StencilState } from "babylonjs/States/stencilState";
  41746. import { AlphaState } from "babylonjs/States/alphaCullingState";
  41747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41748. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41749. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41750. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  41751. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41752. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41753. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41754. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  41755. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  41756. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41757. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  41758. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  41759. import { EngineFeatures } from "babylonjs/Engines/engineFeatures";
  41760. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41761. import { WebRequest } from "babylonjs/Misc/webRequest";
  41762. import { LoadFileError } from "babylonjs/Misc/fileTools";
  41763. /**
  41764. * Defines the interface used by objects working like Scene
  41765. * @hidden
  41766. */
  41767. export interface ISceneLike {
  41768. _addPendingData(data: any): void;
  41769. _removePendingData(data: any): void;
  41770. offlineProvider: IOfflineProvider;
  41771. }
  41772. /**
  41773. * Information about the current host
  41774. */
  41775. export interface HostInformation {
  41776. /**
  41777. * Defines if the current host is a mobile
  41778. */
  41779. isMobile: boolean;
  41780. }
  41781. /** Interface defining initialization parameters for Engine class */
  41782. export interface EngineOptions extends WebGLContextAttributes {
  41783. /**
  41784. * Defines if the engine should no exceed a specified device ratio
  41785. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  41786. */
  41787. limitDeviceRatio?: number;
  41788. /**
  41789. * Defines if webvr should be enabled automatically
  41790. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41791. */
  41792. autoEnableWebVR?: boolean;
  41793. /**
  41794. * Defines if webgl2 should be turned off even if supported
  41795. * @see https://doc.babylonjs.com/features/webgl2
  41796. */
  41797. disableWebGL2Support?: boolean;
  41798. /**
  41799. * Defines if webaudio should be initialized as well
  41800. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41801. */
  41802. audioEngine?: boolean;
  41803. /**
  41804. * Defines if animations should run using a deterministic lock step
  41805. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41806. */
  41807. deterministicLockstep?: boolean;
  41808. /** Defines the maximum steps to use with deterministic lock step mode */
  41809. lockstepMaxSteps?: number;
  41810. /** Defines the seconds between each deterministic lock step */
  41811. timeStep?: number;
  41812. /**
  41813. * Defines that engine should ignore context lost events
  41814. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  41815. */
  41816. doNotHandleContextLost?: boolean;
  41817. /**
  41818. * Defines that engine should ignore modifying touch action attribute and style
  41819. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  41820. */
  41821. doNotHandleTouchAction?: boolean;
  41822. /**
  41823. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  41824. */
  41825. useHighPrecisionFloats?: boolean;
  41826. /**
  41827. * Make the canvas XR Compatible for XR sessions
  41828. */
  41829. xrCompatible?: boolean;
  41830. /**
  41831. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  41832. */
  41833. useHighPrecisionMatrix?: boolean;
  41834. /**
  41835. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  41836. */
  41837. failIfMajorPerformanceCaveat?: boolean;
  41838. /**
  41839. * Defines whether to adapt to the device's viewport characteristics (default: false)
  41840. */
  41841. adaptToDeviceRatio?: boolean;
  41842. }
  41843. /**
  41844. * The base engine class (root of all engines)
  41845. */
  41846. export class ThinEngine {
  41847. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  41848. static ExceptionList: ({
  41849. key: string;
  41850. capture: string;
  41851. captureConstraint: number;
  41852. targets: string[];
  41853. } | {
  41854. key: string;
  41855. capture: null;
  41856. captureConstraint: null;
  41857. targets: string[];
  41858. })[];
  41859. /** @hidden */
  41860. static _TextureLoaders: IInternalTextureLoader[];
  41861. /**
  41862. * Returns the current npm package of the sdk
  41863. */
  41864. static get NpmPackage(): string;
  41865. /**
  41866. * Returns the current version of the framework
  41867. */
  41868. static get Version(): string;
  41869. /**
  41870. * Returns a string describing the current engine
  41871. */
  41872. get description(): string;
  41873. /**
  41874. * Returns the name of the engine
  41875. */
  41876. get name(): string;
  41877. /**
  41878. * Returns the version of the engine
  41879. */
  41880. get version(): number;
  41881. /**
  41882. * Gets or sets the epsilon value used by collision engine
  41883. */
  41884. static CollisionsEpsilon: number;
  41885. /**
  41886. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  41887. */
  41888. static get ShadersRepository(): string;
  41889. static set ShadersRepository(value: string);
  41890. /** @hidden */
  41891. _shaderProcessor: Nullable<IShaderProcessor>;
  41892. /**
  41893. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  41894. */
  41895. forcePOTTextures: boolean;
  41896. /**
  41897. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  41898. */
  41899. isFullscreen: boolean;
  41900. /**
  41901. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  41902. */
  41903. cullBackFaces: boolean;
  41904. /**
  41905. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  41906. */
  41907. renderEvenInBackground: boolean;
  41908. /**
  41909. * Gets or sets a boolean indicating that cache can be kept between frames
  41910. */
  41911. preventCacheWipeBetweenFrames: boolean;
  41912. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  41913. validateShaderPrograms: boolean;
  41914. /**
  41915. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  41916. * This can provide greater z depth for distant objects.
  41917. */
  41918. useReverseDepthBuffer: boolean;
  41919. /**
  41920. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  41921. */
  41922. disableUniformBuffers: boolean;
  41923. private _frameId;
  41924. /**
  41925. * Gets the current frame id
  41926. */
  41927. get frameId(): number;
  41928. /** @hidden */
  41929. _uniformBuffers: UniformBuffer[];
  41930. /**
  41931. * Gets a boolean indicating that the engine supports uniform buffers
  41932. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  41933. */
  41934. get supportsUniformBuffers(): boolean;
  41935. /** @hidden */
  41936. _gl: WebGLRenderingContext;
  41937. /** @hidden */
  41938. _webGLVersion: number;
  41939. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  41940. protected _windowIsBackground: boolean;
  41941. protected _creationOptions: EngineOptions;
  41942. protected _highPrecisionShadersAllowed: boolean;
  41943. /** @hidden */
  41944. get _shouldUseHighPrecisionShader(): boolean;
  41945. /**
  41946. * Gets a boolean indicating that only power of 2 textures are supported
  41947. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  41948. */
  41949. get needPOTTextures(): boolean;
  41950. /** @hidden */
  41951. _badOS: boolean;
  41952. /** @hidden */
  41953. _badDesktopOS: boolean;
  41954. protected _hardwareScalingLevel: number;
  41955. /** @hidden */
  41956. _caps: EngineCapabilities;
  41957. /** @hidden */
  41958. _features: EngineFeatures;
  41959. protected _isStencilEnable: boolean;
  41960. private _glVersion;
  41961. private _glRenderer;
  41962. private _glVendor;
  41963. /** @hidden */
  41964. _videoTextureSupported: boolean;
  41965. protected _renderingQueueLaunched: boolean;
  41966. protected _activeRenderLoops: (() => void)[];
  41967. /**
  41968. * Observable signaled when a context lost event is raised
  41969. */
  41970. onContextLostObservable: Observable<ThinEngine>;
  41971. /**
  41972. * Observable signaled when a context restored event is raised
  41973. */
  41974. onContextRestoredObservable: Observable<ThinEngine>;
  41975. private _onContextLost;
  41976. private _onContextRestored;
  41977. protected _contextWasLost: boolean;
  41978. /** @hidden */
  41979. _doNotHandleContextLost: boolean;
  41980. /**
  41981. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  41982. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  41983. */
  41984. get doNotHandleContextLost(): boolean;
  41985. set doNotHandleContextLost(value: boolean);
  41986. /**
  41987. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  41988. */
  41989. disableVertexArrayObjects: boolean;
  41990. /** @hidden */
  41991. protected _colorWrite: boolean;
  41992. /** @hidden */
  41993. protected _colorWriteChanged: boolean;
  41994. /** @hidden */
  41995. protected _depthCullingState: DepthCullingState;
  41996. /** @hidden */
  41997. protected _stencilState: StencilState;
  41998. /** @hidden */
  41999. _alphaState: AlphaState;
  42000. /** @hidden */
  42001. _alphaMode: number;
  42002. /** @hidden */
  42003. _alphaEquation: number;
  42004. /** @hidden */
  42005. _internalTexturesCache: InternalTexture[];
  42006. /** @hidden */
  42007. protected _activeChannel: number;
  42008. private _currentTextureChannel;
  42009. /** @hidden */
  42010. protected _boundTexturesCache: {
  42011. [key: string]: Nullable<InternalTexture>;
  42012. };
  42013. /** @hidden */
  42014. protected _currentEffect: Nullable<Effect>;
  42015. /** @hidden */
  42016. protected _currentProgram: Nullable<WebGLProgram>;
  42017. protected _compiledEffects: {
  42018. [key: string]: Effect;
  42019. };
  42020. private _vertexAttribArraysEnabled;
  42021. /** @hidden */
  42022. protected _cachedViewport: Nullable<IViewportLike>;
  42023. private _cachedVertexArrayObject;
  42024. /** @hidden */
  42025. protected _cachedVertexBuffers: any;
  42026. /** @hidden */
  42027. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  42028. /** @hidden */
  42029. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  42030. /** @hidden */
  42031. _currentRenderTarget: Nullable<InternalTexture>;
  42032. private _uintIndicesCurrentlySet;
  42033. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  42034. /** @hidden */
  42035. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  42036. /** @hidden */
  42037. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  42038. private _currentBufferPointers;
  42039. private _currentInstanceLocations;
  42040. private _currentInstanceBuffers;
  42041. private _textureUnits;
  42042. /** @hidden */
  42043. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  42044. /** @hidden */
  42045. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  42046. /** @hidden */
  42047. _boundRenderFunction: any;
  42048. private _vaoRecordInProgress;
  42049. private _mustWipeVertexAttributes;
  42050. private _emptyTexture;
  42051. private _emptyCubeTexture;
  42052. private _emptyTexture3D;
  42053. private _emptyTexture2DArray;
  42054. /** @hidden */
  42055. _frameHandler: number;
  42056. private _nextFreeTextureSlots;
  42057. private _maxSimultaneousTextures;
  42058. private _activeRequests;
  42059. /** @hidden */
  42060. _transformTextureUrl: Nullable<(url: string) => string>;
  42061. /**
  42062. * Gets information about the current host
  42063. */
  42064. hostInformation: HostInformation;
  42065. protected get _supportsHardwareTextureRescaling(): boolean;
  42066. private _framebufferDimensionsObject;
  42067. /**
  42068. * sets the object from which width and height will be taken from when getting render width and height
  42069. * Will fallback to the gl object
  42070. * @param dimensions the framebuffer width and height that will be used.
  42071. */
  42072. set framebufferDimensionsObject(dimensions: Nullable<{
  42073. framebufferWidth: number;
  42074. framebufferHeight: number;
  42075. }>);
  42076. /**
  42077. * Gets the current viewport
  42078. */
  42079. get currentViewport(): Nullable<IViewportLike>;
  42080. /**
  42081. * Gets the default empty texture
  42082. */
  42083. get emptyTexture(): InternalTexture;
  42084. /**
  42085. * Gets the default empty 3D texture
  42086. */
  42087. get emptyTexture3D(): InternalTexture;
  42088. /**
  42089. * Gets the default empty 2D array texture
  42090. */
  42091. get emptyTexture2DArray(): InternalTexture;
  42092. /**
  42093. * Gets the default empty cube texture
  42094. */
  42095. get emptyCubeTexture(): InternalTexture;
  42096. /**
  42097. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  42098. */
  42099. premultipliedAlpha: boolean;
  42100. /**
  42101. * Observable event triggered before each texture is initialized
  42102. */
  42103. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  42104. /** @hidden */
  42105. protected _isWebGPU: boolean;
  42106. /**
  42107. * Gets a boolean indicating if the engine runs in WebGPU or not.
  42108. */
  42109. get isWebGPU(): boolean;
  42110. /** @hidden */
  42111. protected _shaderPlatformName: string;
  42112. /**
  42113. * Gets the shader platfrom name used by the effects.
  42114. */
  42115. get shaderPlatformName(): string;
  42116. /**
  42117. * Creates a new engine
  42118. * @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
  42119. * @param antialias defines enable antialiasing (default: false)
  42120. * @param options defines further options to be sent to the getContext() function
  42121. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42122. */
  42123. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42124. /**
  42125. * @hidden
  42126. */
  42127. _debugPushGroup(groupName: string, targetObject?: number): void;
  42128. /**
  42129. * @hidden
  42130. */
  42131. _debugPopGroup(targetObject?: number): void;
  42132. /**
  42133. * @hidden
  42134. */
  42135. _debugInsertMarker(text: string, targetObject?: number): void;
  42136. /**
  42137. * Shared initialization across engines types.
  42138. * @param canvas The canvas associated with this instance of the engine.
  42139. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42140. * @param audioEngine Defines if an audio engine should be created by default
  42141. */
  42142. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42143. /**
  42144. * Gets a shader processor implementation fitting with the current engine type.
  42145. * @returns The shader processor implementation.
  42146. */
  42147. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  42148. /** @hidden */
  42149. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  42150. private _rebuildInternalTextures;
  42151. private _rebuildEffects;
  42152. /**
  42153. * Gets a boolean indicating if all created effects are ready
  42154. * @returns true if all effects are ready
  42155. */
  42156. areAllEffectsReady(): boolean;
  42157. protected _rebuildBuffers(): void;
  42158. protected _initGLContext(): void;
  42159. protected _initFeatures(): void;
  42160. /**
  42161. * Gets version of the current webGL context
  42162. * Keep it for back compat - use version instead
  42163. */
  42164. get webGLVersion(): number;
  42165. /**
  42166. * Gets a string identifying the name of the class
  42167. * @returns "Engine" string
  42168. */
  42169. getClassName(): string;
  42170. /**
  42171. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  42172. */
  42173. get isStencilEnable(): boolean;
  42174. /** @hidden */
  42175. _prepareWorkingCanvas(): void;
  42176. /**
  42177. * Reset the texture cache to empty state
  42178. */
  42179. resetTextureCache(): void;
  42180. /**
  42181. * Gets an object containing information about the current webGL context
  42182. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  42183. */
  42184. getGlInfo(): {
  42185. vendor: string;
  42186. renderer: string;
  42187. version: string;
  42188. };
  42189. /**
  42190. * Defines the hardware scaling level.
  42191. * By default the hardware scaling level is computed from the window device ratio.
  42192. * 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.
  42193. * @param level defines the level to use
  42194. */
  42195. setHardwareScalingLevel(level: number): void;
  42196. /**
  42197. * Gets the current hardware scaling level.
  42198. * By default the hardware scaling level is computed from the window device ratio.
  42199. * 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.
  42200. * @returns a number indicating the current hardware scaling level
  42201. */
  42202. getHardwareScalingLevel(): number;
  42203. /**
  42204. * Gets the list of loaded textures
  42205. * @returns an array containing all loaded textures
  42206. */
  42207. getLoadedTexturesCache(): InternalTexture[];
  42208. /**
  42209. * Gets the object containing all engine capabilities
  42210. * @returns the EngineCapabilities object
  42211. */
  42212. getCaps(): EngineCapabilities;
  42213. /**
  42214. * stop executing a render loop function and remove it from the execution array
  42215. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  42216. */
  42217. stopRenderLoop(renderFunction?: () => void): void;
  42218. /** @hidden */
  42219. _renderLoop(): void;
  42220. /**
  42221. * Gets the HTML canvas attached with the current webGL context
  42222. * @returns a HTML canvas
  42223. */
  42224. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  42225. /**
  42226. * Gets host window
  42227. * @returns the host window object
  42228. */
  42229. getHostWindow(): Nullable<Window>;
  42230. /**
  42231. * Gets the current render width
  42232. * @param useScreen defines if screen size must be used (or the current render target if any)
  42233. * @returns a number defining the current render width
  42234. */
  42235. getRenderWidth(useScreen?: boolean): number;
  42236. /**
  42237. * Gets the current render height
  42238. * @param useScreen defines if screen size must be used (or the current render target if any)
  42239. * @returns a number defining the current render height
  42240. */
  42241. getRenderHeight(useScreen?: boolean): number;
  42242. /**
  42243. * Can be used to override the current requestAnimationFrame requester.
  42244. * @hidden
  42245. */
  42246. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  42247. /**
  42248. * Register and execute a render loop. The engine can have more than one render function
  42249. * @param renderFunction defines the function to continuously execute
  42250. */
  42251. runRenderLoop(renderFunction: () => void): void;
  42252. /**
  42253. * Clear the current render buffer or the current render target (if any is set up)
  42254. * @param color defines the color to use
  42255. * @param backBuffer defines if the back buffer must be cleared
  42256. * @param depth defines if the depth buffer must be cleared
  42257. * @param stencil defines if the stencil buffer must be cleared
  42258. */
  42259. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42260. protected _viewportCached: {
  42261. x: number;
  42262. y: number;
  42263. z: number;
  42264. w: number;
  42265. };
  42266. /** @hidden */
  42267. _viewport(x: number, y: number, width: number, height: number): void;
  42268. /**
  42269. * Set the WebGL's viewport
  42270. * @param viewport defines the viewport element to be used
  42271. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  42272. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  42273. */
  42274. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42275. /**
  42276. * Begin a new frame
  42277. */
  42278. beginFrame(): void;
  42279. /**
  42280. * Enf the current frame
  42281. */
  42282. endFrame(): void;
  42283. /**
  42284. * Resize the view according to the canvas' size
  42285. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42286. */
  42287. resize(forceSetSize?: boolean): void;
  42288. /**
  42289. * Force a specific size of the canvas
  42290. * @param width defines the new canvas' width
  42291. * @param height defines the new canvas' height
  42292. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42293. * @returns true if the size was changed
  42294. */
  42295. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42296. /**
  42297. * Binds the frame buffer to the specified texture.
  42298. * @param texture The texture to render to or null for the default canvas
  42299. * @param faceIndex The face of the texture to render to in case of cube texture
  42300. * @param requiredWidth The width of the target to render to
  42301. * @param requiredHeight The height of the target to render to
  42302. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  42303. * @param lodLevel defines the lod level to bind to the frame buffer
  42304. * @param layer defines the 2d array index to bind to frame buffer to
  42305. */
  42306. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  42307. /** @hidden */
  42308. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  42309. /**
  42310. * Unbind the current render target texture from the webGL context
  42311. * @param texture defines the render target texture to unbind
  42312. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42313. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42314. */
  42315. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42316. /**
  42317. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  42318. */
  42319. flushFramebuffer(): void;
  42320. /**
  42321. * Unbind the current render target and bind the default framebuffer
  42322. */
  42323. restoreDefaultFramebuffer(): void;
  42324. /** @hidden */
  42325. protected _resetVertexBufferBinding(): void;
  42326. /**
  42327. * Creates a vertex buffer
  42328. * @param data the data for the vertex buffer
  42329. * @returns the new WebGL static buffer
  42330. */
  42331. createVertexBuffer(data: DataArray): DataBuffer;
  42332. private _createVertexBuffer;
  42333. /**
  42334. * Creates a dynamic vertex buffer
  42335. * @param data the data for the dynamic vertex buffer
  42336. * @returns the new WebGL dynamic buffer
  42337. */
  42338. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  42339. protected _resetIndexBufferBinding(): void;
  42340. /**
  42341. * Creates a new index buffer
  42342. * @param indices defines the content of the index buffer
  42343. * @param updatable defines if the index buffer must be updatable
  42344. * @returns a new webGL buffer
  42345. */
  42346. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  42347. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  42348. /**
  42349. * Bind a webGL buffer to the webGL context
  42350. * @param buffer defines the buffer to bind
  42351. */
  42352. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  42353. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  42354. private bindBuffer;
  42355. /**
  42356. * update the bound buffer with the given data
  42357. * @param data defines the data to update
  42358. */
  42359. updateArrayBuffer(data: Float32Array): void;
  42360. private _vertexAttribPointer;
  42361. /** @hidden */
  42362. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  42363. private _bindVertexBuffersAttributes;
  42364. /**
  42365. * Records a vertex array object
  42366. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  42367. * @param vertexBuffers defines the list of vertex buffers to store
  42368. * @param indexBuffer defines the index buffer to store
  42369. * @param effect defines the effect to store
  42370. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  42371. * @returns the new vertex array object
  42372. */
  42373. recordVertexArrayObject(vertexBuffers: {
  42374. [key: string]: VertexBuffer;
  42375. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  42376. [kind: string]: Nullable<VertexBuffer>;
  42377. }): WebGLVertexArrayObject;
  42378. /**
  42379. * Bind a specific vertex array object
  42380. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  42381. * @param vertexArrayObject defines the vertex array object to bind
  42382. * @param indexBuffer defines the index buffer to bind
  42383. */
  42384. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  42385. /**
  42386. * Bind webGl buffers directly to the webGL context
  42387. * @param vertexBuffer defines the vertex buffer to bind
  42388. * @param indexBuffer defines the index buffer to bind
  42389. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  42390. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  42391. * @param effect defines the effect associated with the vertex buffer
  42392. */
  42393. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  42394. private _unbindVertexArrayObject;
  42395. /**
  42396. * Bind a list of vertex buffers to the webGL context
  42397. * @param vertexBuffers defines the list of vertex buffers to bind
  42398. * @param indexBuffer defines the index buffer to bind
  42399. * @param effect defines the effect associated with the vertex buffers
  42400. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  42401. */
  42402. bindBuffers(vertexBuffers: {
  42403. [key: string]: Nullable<VertexBuffer>;
  42404. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  42405. [kind: string]: Nullable<VertexBuffer>;
  42406. }): void;
  42407. /**
  42408. * Unbind all instance attributes
  42409. */
  42410. unbindInstanceAttributes(): void;
  42411. /**
  42412. * Release and free the memory of a vertex array object
  42413. * @param vao defines the vertex array object to delete
  42414. */
  42415. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  42416. /** @hidden */
  42417. _releaseBuffer(buffer: DataBuffer): boolean;
  42418. protected _deleteBuffer(buffer: DataBuffer): void;
  42419. /**
  42420. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  42421. * @param instancesBuffer defines the webGL buffer to update and bind
  42422. * @param data defines the data to store in the buffer
  42423. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  42424. */
  42425. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  42426. /**
  42427. * Bind the content of a webGL buffer used with instantiation
  42428. * @param instancesBuffer defines the webGL buffer to bind
  42429. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  42430. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  42431. */
  42432. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  42433. /**
  42434. * Disable the instance attribute corresponding to the name in parameter
  42435. * @param name defines the name of the attribute to disable
  42436. */
  42437. disableInstanceAttributeByName(name: string): void;
  42438. /**
  42439. * Disable the instance attribute corresponding to the location in parameter
  42440. * @param attributeLocation defines the attribute location of the attribute to disable
  42441. */
  42442. disableInstanceAttribute(attributeLocation: number): void;
  42443. /**
  42444. * Disable the attribute corresponding to the location in parameter
  42445. * @param attributeLocation defines the attribute location of the attribute to disable
  42446. */
  42447. disableAttributeByIndex(attributeLocation: number): void;
  42448. /**
  42449. * Send a draw order
  42450. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42451. * @param indexStart defines the starting index
  42452. * @param indexCount defines the number of index to draw
  42453. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  42454. */
  42455. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42456. /**
  42457. * Draw a list of points
  42458. * @param verticesStart defines the index of first vertex to draw
  42459. * @param verticesCount defines the count of vertices to draw
  42460. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  42461. */
  42462. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42463. /**
  42464. * Draw a list of unindexed primitives
  42465. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42466. * @param verticesStart defines the index of first vertex to draw
  42467. * @param verticesCount defines the count of vertices to draw
  42468. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  42469. */
  42470. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42471. /**
  42472. * Draw a list of indexed primitives
  42473. * @param fillMode defines the primitive to use
  42474. * @param indexStart defines the starting index
  42475. * @param indexCount defines the number of index to draw
  42476. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  42477. */
  42478. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42479. /**
  42480. * Draw a list of unindexed primitives
  42481. * @param fillMode defines the primitive to use
  42482. * @param verticesStart defines the index of first vertex to draw
  42483. * @param verticesCount defines the count of vertices to draw
  42484. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  42485. */
  42486. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42487. private _drawMode;
  42488. /** @hidden */
  42489. protected _reportDrawCall(): void;
  42490. /** @hidden */
  42491. _releaseEffect(effect: Effect): void;
  42492. /** @hidden */
  42493. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42494. /**
  42495. * Create a new effect (used to store vertex/fragment shaders)
  42496. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  42497. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  42498. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  42499. * @param samplers defines an array of string used to represent textures
  42500. * @param defines defines the string containing the defines to use to compile the shaders
  42501. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  42502. * @param onCompiled defines a function to call when the effect creation is successful
  42503. * @param onError defines a function to call when the effect creation has failed
  42504. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  42505. * @returns the new Effect
  42506. */
  42507. 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;
  42508. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  42509. private _compileShader;
  42510. private _compileRawShader;
  42511. /** @hidden */
  42512. _getShaderSource(shader: WebGLShader): Nullable<string>;
  42513. /**
  42514. * Directly creates a webGL program
  42515. * @param pipelineContext defines the pipeline context to attach to
  42516. * @param vertexCode defines the vertex shader code to use
  42517. * @param fragmentCode defines the fragment shader code to use
  42518. * @param context defines the webGL context to use (if not set, the current one will be used)
  42519. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42520. * @returns the new webGL program
  42521. */
  42522. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42523. /**
  42524. * Creates a webGL program
  42525. * @param pipelineContext defines the pipeline context to attach to
  42526. * @param vertexCode defines the vertex shader code to use
  42527. * @param fragmentCode defines the fragment shader code to use
  42528. * @param defines defines the string containing the defines to use to compile the shaders
  42529. * @param context defines the webGL context to use (if not set, the current one will be used)
  42530. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42531. * @returns the new webGL program
  42532. */
  42533. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42534. /**
  42535. * Creates a new pipeline context
  42536. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  42537. * @returns the new pipeline
  42538. */
  42539. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  42540. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42541. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  42542. /** @hidden */
  42543. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  42544. /** @hidden */
  42545. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  42546. /** @hidden */
  42547. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  42548. /**
  42549. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42550. * @param pipelineContext defines the pipeline context to use
  42551. * @param uniformsNames defines the list of uniform names
  42552. * @returns an array of webGL uniform locations
  42553. */
  42554. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42555. /**
  42556. * Gets the list of active attributes for a given webGL program
  42557. * @param pipelineContext defines the pipeline context to use
  42558. * @param attributesNames defines the list of attribute names to get
  42559. * @returns an array of indices indicating the offset of each attribute
  42560. */
  42561. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42562. /**
  42563. * Activates an effect, making it the current one (ie. the one used for rendering)
  42564. * @param effect defines the effect to activate
  42565. */
  42566. enableEffect(effect: Nullable<Effect>): void;
  42567. /**
  42568. * Set the value of an uniform to a number (int)
  42569. * @param uniform defines the webGL uniform location where to store the value
  42570. * @param value defines the int number to store
  42571. * @returns true if the value was set
  42572. */
  42573. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42574. /**
  42575. * Set the value of an uniform to a int2
  42576. * @param uniform defines the webGL uniform location where to store the value
  42577. * @param x defines the 1st component of the value
  42578. * @param y defines the 2nd component of the value
  42579. * @returns true if the value was set
  42580. */
  42581. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42582. /**
  42583. * Set the value of an uniform to a int3
  42584. * @param uniform defines the webGL uniform location where to store the value
  42585. * @param x defines the 1st component of the value
  42586. * @param y defines the 2nd component of the value
  42587. * @param z defines the 3rd component of the value
  42588. * @returns true if the value was set
  42589. */
  42590. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42591. /**
  42592. * Set the value of an uniform to a int4
  42593. * @param uniform defines the webGL uniform location where to store the value
  42594. * @param x defines the 1st component of the value
  42595. * @param y defines the 2nd component of the value
  42596. * @param z defines the 3rd component of the value
  42597. * @param w defines the 4th component of the value
  42598. * @returns true if the value was set
  42599. */
  42600. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42601. /**
  42602. * Set the value of an uniform to an array of int32
  42603. * @param uniform defines the webGL uniform location where to store the value
  42604. * @param array defines the array of int32 to store
  42605. * @returns true if the value was set
  42606. */
  42607. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42608. /**
  42609. * Set the value of an uniform to an array of int32 (stored as vec2)
  42610. * @param uniform defines the webGL uniform location where to store the value
  42611. * @param array defines the array of int32 to store
  42612. * @returns true if the value was set
  42613. */
  42614. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42615. /**
  42616. * Set the value of an uniform to an array of int32 (stored as vec3)
  42617. * @param uniform defines the webGL uniform location where to store the value
  42618. * @param array defines the array of int32 to store
  42619. * @returns true if the value was set
  42620. */
  42621. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42622. /**
  42623. * Set the value of an uniform to an array of int32 (stored as vec4)
  42624. * @param uniform defines the webGL uniform location where to store the value
  42625. * @param array defines the array of int32 to store
  42626. * @returns true if the value was set
  42627. */
  42628. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42629. /**
  42630. * Set the value of an uniform to an array of number
  42631. * @param uniform defines the webGL uniform location where to store the value
  42632. * @param array defines the array of number to store
  42633. * @returns true if the value was set
  42634. */
  42635. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42636. /**
  42637. * Set the value of an uniform to an array of number (stored as vec2)
  42638. * @param uniform defines the webGL uniform location where to store the value
  42639. * @param array defines the array of number to store
  42640. * @returns true if the value was set
  42641. */
  42642. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42643. /**
  42644. * Set the value of an uniform to an array of number (stored as vec3)
  42645. * @param uniform defines the webGL uniform location where to store the value
  42646. * @param array defines the array of number to store
  42647. * @returns true if the value was set
  42648. */
  42649. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42650. /**
  42651. * Set the value of an uniform to an array of number (stored as vec4)
  42652. * @param uniform defines the webGL uniform location where to store the value
  42653. * @param array defines the array of number to store
  42654. * @returns true if the value was set
  42655. */
  42656. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42657. /**
  42658. * Set the value of an uniform to an array of float32 (stored as matrices)
  42659. * @param uniform defines the webGL uniform location where to store the value
  42660. * @param matrices defines the array of float32 to store
  42661. * @returns true if the value was set
  42662. */
  42663. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  42664. /**
  42665. * Set the value of an uniform to a matrix (3x3)
  42666. * @param uniform defines the webGL uniform location where to store the value
  42667. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  42668. * @returns true if the value was set
  42669. */
  42670. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42671. /**
  42672. * Set the value of an uniform to a matrix (2x2)
  42673. * @param uniform defines the webGL uniform location where to store the value
  42674. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  42675. * @returns true if the value was set
  42676. */
  42677. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42678. /**
  42679. * Set the value of an uniform to a number (float)
  42680. * @param uniform defines the webGL uniform location where to store the value
  42681. * @param value defines the float number to store
  42682. * @returns true if the value was transferred
  42683. */
  42684. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42685. /**
  42686. * Set the value of an uniform to a vec2
  42687. * @param uniform defines the webGL uniform location where to store the value
  42688. * @param x defines the 1st component of the value
  42689. * @param y defines the 2nd component of the value
  42690. * @returns true if the value was set
  42691. */
  42692. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42693. /**
  42694. * Set the value of an uniform to a vec3
  42695. * @param uniform defines the webGL uniform location where to store the value
  42696. * @param x defines the 1st component of the value
  42697. * @param y defines the 2nd component of the value
  42698. * @param z defines the 3rd component of the value
  42699. * @returns true if the value was set
  42700. */
  42701. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42702. /**
  42703. * Set the value of an uniform to a vec4
  42704. * @param uniform defines the webGL uniform location where to store the value
  42705. * @param x defines the 1st component of the value
  42706. * @param y defines the 2nd component of the value
  42707. * @param z defines the 3rd component of the value
  42708. * @param w defines the 4th component of the value
  42709. * @returns true if the value was set
  42710. */
  42711. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42712. /**
  42713. * Apply all cached states (depth, culling, stencil and alpha)
  42714. */
  42715. applyStates(): void;
  42716. /**
  42717. * Enable or disable color writing
  42718. * @param enable defines the state to set
  42719. */
  42720. setColorWrite(enable: boolean): void;
  42721. /**
  42722. * Gets a boolean indicating if color writing is enabled
  42723. * @returns the current color writing state
  42724. */
  42725. getColorWrite(): boolean;
  42726. /**
  42727. * Gets the depth culling state manager
  42728. */
  42729. get depthCullingState(): DepthCullingState;
  42730. /**
  42731. * Gets the alpha state manager
  42732. */
  42733. get alphaState(): AlphaState;
  42734. /**
  42735. * Gets the stencil state manager
  42736. */
  42737. get stencilState(): StencilState;
  42738. /**
  42739. * Clears the list of texture accessible through engine.
  42740. * This can help preventing texture load conflict due to name collision.
  42741. */
  42742. clearInternalTexturesCache(): void;
  42743. /**
  42744. * Force the entire cache to be cleared
  42745. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  42746. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  42747. */
  42748. wipeCaches(bruteForce?: boolean): void;
  42749. /** @hidden */
  42750. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  42751. min: number;
  42752. mag: number;
  42753. };
  42754. /** @hidden */
  42755. protected _createTexture(): WebGLTexture;
  42756. /** @hidden */
  42757. _createHardwareTexture(): HardwareTextureWrapper;
  42758. protected _createTextureBase(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode: number | undefined, onLoad: (() => void) | null | undefined, onError: ((message: string, exception: any) => void) | null | undefined, prepareTexture: (texture: InternalTexture, extension: string, scene: Nullable<ISceneLike>, img: HTMLImageElement | ImageBitmap | {
  42759. width: number;
  42760. height: number;
  42761. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42762. width: number;
  42763. height: number;
  42764. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42765. width: number;
  42766. height: number;
  42767. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  42768. /**
  42769. * Usually called from Texture.ts.
  42770. * Passed information to create a WebGLTexture
  42771. * @param url defines a value which contains one of the following:
  42772. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  42773. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  42774. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  42775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  42776. * @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)
  42777. * @param scene needed for loading to the correct scene
  42778. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  42779. * @param onLoad optional callback to be called upon successful completion
  42780. * @param onError optional callback to be called upon failure
  42781. * @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
  42782. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  42783. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  42784. * @param forcedExtension defines the extension to use to pick the right loader
  42785. * @param mimeType defines an optional mime type
  42786. * @param loaderOptions options to be passed to the loader
  42787. * @returns a InternalTexture for assignment back into BABYLON.Texture
  42788. */
  42789. 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;
  42790. /**
  42791. * Loads an image as an HTMLImageElement.
  42792. * @param input url string, ArrayBuffer, or Blob to load
  42793. * @param onLoad callback called when the image successfully loads
  42794. * @param onError callback called when the image fails to load
  42795. * @param offlineProvider offline provider for caching
  42796. * @param mimeType optional mime type
  42797. * @returns the HTMLImageElement of the loaded image
  42798. * @hidden
  42799. */
  42800. 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>;
  42801. /**
  42802. * @hidden
  42803. */
  42804. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42805. private _unpackFlipYCached;
  42806. /**
  42807. * In case you are sharing the context with other applications, it might
  42808. * be interested to not cache the unpack flip y state to ensure a consistent
  42809. * value would be set.
  42810. */
  42811. enableUnpackFlipYCached: boolean;
  42812. /** @hidden */
  42813. _unpackFlipY(value: boolean): void;
  42814. /** @hidden */
  42815. _getUnpackAlignement(): number;
  42816. private _getTextureTarget;
  42817. /**
  42818. * Update the sampling mode of a given texture
  42819. * @param samplingMode defines the required sampling mode
  42820. * @param texture defines the texture to update
  42821. * @param generateMipMaps defines whether to generate mipmaps for the texture
  42822. */
  42823. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  42824. /**
  42825. * Update the dimensions of a texture
  42826. * @param texture texture to update
  42827. * @param width new width of the texture
  42828. * @param height new height of the texture
  42829. * @param depth new depth of the texture
  42830. */
  42831. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  42832. /**
  42833. * Update the sampling mode of a given texture
  42834. * @param texture defines the texture to update
  42835. * @param wrapU defines the texture wrap mode of the u coordinates
  42836. * @param wrapV defines the texture wrap mode of the v coordinates
  42837. * @param wrapR defines the texture wrap mode of the r coordinates
  42838. */
  42839. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  42840. /** @hidden */
  42841. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  42842. width: number;
  42843. height: number;
  42844. layers?: number;
  42845. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  42846. /** @hidden */
  42847. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42848. /** @hidden */
  42849. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  42850. /**
  42851. * Update a portion of an internal texture
  42852. * @param texture defines the texture to update
  42853. * @param imageData defines the data to store into the texture
  42854. * @param xOffset defines the x coordinates of the update rectangle
  42855. * @param yOffset defines the y coordinates of the update rectangle
  42856. * @param width defines the width of the update rectangle
  42857. * @param height defines the height of the update rectangle
  42858. * @param faceIndex defines the face index if texture is a cube (0 by default)
  42859. * @param lod defines the lod level to update (0 by default)
  42860. */
  42861. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  42862. /** @hidden */
  42863. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42864. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  42865. private _prepareWebGLTexture;
  42866. /** @hidden */
  42867. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  42868. private _getDepthStencilBuffer;
  42869. /** @hidden */
  42870. _releaseFramebufferObjects(texture: InternalTexture): void;
  42871. /** @hidden */
  42872. _releaseTexture(texture: InternalTexture): void;
  42873. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  42874. protected _setProgram(program: WebGLProgram): void;
  42875. protected _boundUniforms: {
  42876. [key: number]: WebGLUniformLocation;
  42877. };
  42878. /**
  42879. * Binds an effect to the webGL context
  42880. * @param effect defines the effect to bind
  42881. */
  42882. bindSamplers(effect: Effect): void;
  42883. private _activateCurrentTexture;
  42884. /** @hidden */
  42885. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  42886. /** @hidden */
  42887. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  42888. /**
  42889. * Unbind all textures from the webGL context
  42890. */
  42891. unbindAllTextures(): void;
  42892. /**
  42893. * Sets a texture to the according uniform.
  42894. * @param channel The texture channel
  42895. * @param uniform The uniform to set
  42896. * @param texture The texture to apply
  42897. * @param name The name of the uniform in the effect
  42898. */
  42899. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  42900. private _bindSamplerUniformToChannel;
  42901. private _getTextureWrapMode;
  42902. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  42903. /**
  42904. * Sets an array of texture to the webGL context
  42905. * @param channel defines the channel where the texture array must be set
  42906. * @param uniform defines the associated uniform location
  42907. * @param textures defines the array of textures to bind
  42908. * @param name name of the channel
  42909. */
  42910. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  42911. /** @hidden */
  42912. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  42913. private _setTextureParameterFloat;
  42914. private _setTextureParameterInteger;
  42915. /**
  42916. * Unbind all vertex attributes from the webGL context
  42917. */
  42918. unbindAllAttributes(): void;
  42919. /**
  42920. * 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
  42921. */
  42922. releaseEffects(): void;
  42923. /**
  42924. * Dispose and release all associated resources
  42925. */
  42926. dispose(): void;
  42927. /**
  42928. * Attach a new callback raised when context lost event is fired
  42929. * @param callback defines the callback to call
  42930. */
  42931. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42932. /**
  42933. * Attach a new callback raised when context restored event is fired
  42934. * @param callback defines the callback to call
  42935. */
  42936. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42937. /**
  42938. * Get the current error code of the webGL context
  42939. * @returns the error code
  42940. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42941. */
  42942. getError(): number;
  42943. private _canRenderToFloatFramebuffer;
  42944. private _canRenderToHalfFloatFramebuffer;
  42945. private _canRenderToFramebuffer;
  42946. /** @hidden */
  42947. _getWebGLTextureType(type: number): number;
  42948. /** @hidden */
  42949. _getInternalFormat(format: number): number;
  42950. /** @hidden */
  42951. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  42952. /** @hidden */
  42953. _getRGBAMultiSampleBufferFormat(type: number): number;
  42954. /** @hidden */
  42955. _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;
  42956. /**
  42957. * Loads a file from a url
  42958. * @param url url to load
  42959. * @param onSuccess callback called when the file successfully loads
  42960. * @param onProgress callback called while file is loading (if the server supports this mode)
  42961. * @param offlineProvider defines the offline provider for caching
  42962. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42963. * @param onError callback called when the file fails to load
  42964. * @returns a file request object
  42965. * @hidden
  42966. */
  42967. 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;
  42968. /**
  42969. * Reads pixels from the current frame buffer. Please note that this function can be slow
  42970. * @param x defines the x coordinate of the rectangle where pixels must be read
  42971. * @param y defines the y coordinate of the rectangle where pixels must be read
  42972. * @param width defines the width of the rectangle where pixels must be read
  42973. * @param height defines the height of the rectangle where pixels must be read
  42974. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  42975. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  42976. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  42977. */
  42978. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42979. private static _IsSupported;
  42980. private static _HasMajorPerformanceCaveat;
  42981. /**
  42982. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  42983. */
  42984. static get IsSupported(): boolean;
  42985. /**
  42986. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  42987. * @returns true if the engine can be created
  42988. * @ignorenaming
  42989. */
  42990. static isSupported(): boolean;
  42991. /**
  42992. * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  42993. */
  42994. static get HasMajorPerformanceCaveat(): boolean;
  42995. /**
  42996. * Find the next highest power of two.
  42997. * @param x Number to start search from.
  42998. * @return Next highest power of two.
  42999. */
  43000. static CeilingPOT(x: number): number;
  43001. /**
  43002. * Find the next lowest power of two.
  43003. * @param x Number to start search from.
  43004. * @return Next lowest power of two.
  43005. */
  43006. static FloorPOT(x: number): number;
  43007. /**
  43008. * Find the nearest power of two.
  43009. * @param x Number to start search from.
  43010. * @return Next nearest power of two.
  43011. */
  43012. static NearestPOT(x: number): number;
  43013. /**
  43014. * Get the closest exponent of two
  43015. * @param value defines the value to approximate
  43016. * @param max defines the maximum value to return
  43017. * @param mode defines how to define the closest value
  43018. * @returns closest exponent of two of the given value
  43019. */
  43020. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  43021. /**
  43022. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  43023. * @param func - the function to be called
  43024. * @param requester - the object that will request the next frame. Falls back to window.
  43025. * @returns frame number
  43026. */
  43027. static QueueNewFrame(func: () => void, requester?: any): number;
  43028. /**
  43029. * Gets host document
  43030. * @returns the host document object
  43031. */
  43032. getHostDocument(): Nullable<Document>;
  43033. }
  43034. }
  43035. declare module "babylonjs/Materials/Textures/internalTexture" {
  43036. import { Observable } from "babylonjs/Misc/observable";
  43037. import { Nullable, int } from "babylonjs/types";
  43038. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  43039. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43041. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  43042. /**
  43043. * Defines the source of the internal texture
  43044. */
  43045. export enum InternalTextureSource {
  43046. /**
  43047. * The source of the texture data is unknown
  43048. */
  43049. Unknown = 0,
  43050. /**
  43051. * Texture data comes from an URL
  43052. */
  43053. Url = 1,
  43054. /**
  43055. * Texture data is only used for temporary storage
  43056. */
  43057. Temp = 2,
  43058. /**
  43059. * Texture data comes from raw data (ArrayBuffer)
  43060. */
  43061. Raw = 3,
  43062. /**
  43063. * Texture content is dynamic (video or dynamic texture)
  43064. */
  43065. Dynamic = 4,
  43066. /**
  43067. * Texture content is generated by rendering to it
  43068. */
  43069. RenderTarget = 5,
  43070. /**
  43071. * Texture content is part of a multi render target process
  43072. */
  43073. MultiRenderTarget = 6,
  43074. /**
  43075. * Texture data comes from a cube data file
  43076. */
  43077. Cube = 7,
  43078. /**
  43079. * Texture data comes from a raw cube data
  43080. */
  43081. CubeRaw = 8,
  43082. /**
  43083. * Texture data come from a prefiltered cube data file
  43084. */
  43085. CubePrefiltered = 9,
  43086. /**
  43087. * Texture content is raw 3D data
  43088. */
  43089. Raw3D = 10,
  43090. /**
  43091. * Texture content is raw 2D array data
  43092. */
  43093. Raw2DArray = 11,
  43094. /**
  43095. * Texture content is a depth texture
  43096. */
  43097. Depth = 12,
  43098. /**
  43099. * Texture data comes from a raw cube data encoded with RGBD
  43100. */
  43101. CubeRawRGBD = 13
  43102. }
  43103. /**
  43104. * Class used to store data associated with WebGL texture data for the engine
  43105. * This class should not be used directly
  43106. */
  43107. export class InternalTexture {
  43108. /** @hidden */
  43109. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  43110. /**
  43111. * Defines if the texture is ready
  43112. */
  43113. isReady: boolean;
  43114. /**
  43115. * Defines if the texture is a cube texture
  43116. */
  43117. isCube: boolean;
  43118. /**
  43119. * Defines if the texture contains 3D data
  43120. */
  43121. is3D: boolean;
  43122. /**
  43123. * Defines if the texture contains 2D array data
  43124. */
  43125. is2DArray: boolean;
  43126. /**
  43127. * Defines if the texture contains multiview data
  43128. */
  43129. isMultiview: boolean;
  43130. /**
  43131. * Gets the URL used to load this texture
  43132. */
  43133. url: string;
  43134. /** @hidden */
  43135. _originalUrl: string;
  43136. /**
  43137. * Gets the sampling mode of the texture
  43138. */
  43139. samplingMode: number;
  43140. /**
  43141. * Gets a boolean indicating if the texture needs mipmaps generation
  43142. */
  43143. generateMipMaps: boolean;
  43144. /**
  43145. * Gets the number of samples used by the texture (WebGL2+ only)
  43146. */
  43147. samples: number;
  43148. /**
  43149. * Gets the type of the texture (int, float...)
  43150. */
  43151. type: number;
  43152. /**
  43153. * Gets the format of the texture (RGB, RGBA...)
  43154. */
  43155. format: number;
  43156. /**
  43157. * Observable called when the texture is loaded
  43158. */
  43159. onLoadedObservable: Observable<InternalTexture>;
  43160. /**
  43161. * Gets the width of the texture
  43162. */
  43163. width: number;
  43164. /**
  43165. * Gets the height of the texture
  43166. */
  43167. height: number;
  43168. /**
  43169. * Gets the depth of the texture
  43170. */
  43171. depth: number;
  43172. /**
  43173. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  43174. */
  43175. baseWidth: number;
  43176. /**
  43177. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  43178. */
  43179. baseHeight: number;
  43180. /**
  43181. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  43182. */
  43183. baseDepth: number;
  43184. /**
  43185. * Gets a boolean indicating if the texture is inverted on Y axis
  43186. */
  43187. invertY: boolean;
  43188. /** @hidden */
  43189. _invertVScale: boolean;
  43190. /** @hidden */
  43191. _associatedChannel: number;
  43192. /** @hidden */
  43193. _source: InternalTextureSource;
  43194. /** @hidden */
  43195. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  43196. /** @hidden */
  43197. _bufferView: Nullable<ArrayBufferView>;
  43198. /** @hidden */
  43199. _bufferViewArray: Nullable<ArrayBufferView[]>;
  43200. /** @hidden */
  43201. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  43202. /** @hidden */
  43203. _size: number;
  43204. /** @hidden */
  43205. _extension: string;
  43206. /** @hidden */
  43207. _files: Nullable<string[]>;
  43208. /** @hidden */
  43209. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  43210. /** @hidden */
  43211. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  43212. /** @hidden */
  43213. _framebuffer: Nullable<WebGLFramebuffer>;
  43214. /** @hidden */
  43215. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  43216. /** @hidden */
  43217. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  43218. /** @hidden */
  43219. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  43220. /** @hidden */
  43221. _attachments: Nullable<number[]>;
  43222. /** @hidden */
  43223. _textureArray: Nullable<InternalTexture[]>;
  43224. /** @hidden */
  43225. _cachedCoordinatesMode: Nullable<number>;
  43226. /** @hidden */
  43227. _cachedWrapU: Nullable<number>;
  43228. /** @hidden */
  43229. _cachedWrapV: Nullable<number>;
  43230. /** @hidden */
  43231. _cachedWrapR: Nullable<number>;
  43232. /** @hidden */
  43233. _cachedAnisotropicFilteringLevel: Nullable<number>;
  43234. /** @hidden */
  43235. _isDisabled: boolean;
  43236. /** @hidden */
  43237. _compression: Nullable<string>;
  43238. /** @hidden */
  43239. _generateStencilBuffer: boolean;
  43240. /** @hidden */
  43241. _generateDepthBuffer: boolean;
  43242. /** @hidden */
  43243. _comparisonFunction: number;
  43244. /** @hidden */
  43245. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  43246. /** @hidden */
  43247. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  43248. /** @hidden */
  43249. _sphericalPolynomialComputed: boolean;
  43250. /** @hidden */
  43251. _lodGenerationScale: number;
  43252. /** @hidden */
  43253. _lodGenerationOffset: number;
  43254. /** @hidden */
  43255. _depthStencilTexture: Nullable<InternalTexture>;
  43256. /** @hidden */
  43257. _colorTextureArray: Nullable<WebGLTexture>;
  43258. /** @hidden */
  43259. _depthStencilTextureArray: Nullable<WebGLTexture>;
  43260. /** @hidden */
  43261. _lodTextureHigh: Nullable<BaseTexture>;
  43262. /** @hidden */
  43263. _lodTextureMid: Nullable<BaseTexture>;
  43264. /** @hidden */
  43265. _lodTextureLow: Nullable<BaseTexture>;
  43266. /** @hidden */
  43267. _isRGBD: boolean;
  43268. /** @hidden */
  43269. _linearSpecularLOD: boolean;
  43270. /** @hidden */
  43271. _irradianceTexture: Nullable<BaseTexture>;
  43272. /** @hidden */
  43273. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  43274. /** @hidden */
  43275. _references: number;
  43276. /** @hidden */
  43277. _gammaSpace: Nullable<boolean>;
  43278. private _engine;
  43279. private _uniqueId;
  43280. private static _Counter;
  43281. /** Gets the unique id of the internal texture */
  43282. get uniqueId(): number;
  43283. /**
  43284. * Gets the Engine the texture belongs to.
  43285. * @returns The babylon engine
  43286. */
  43287. getEngine(): ThinEngine;
  43288. /**
  43289. * Gets the data source type of the texture
  43290. */
  43291. get source(): InternalTextureSource;
  43292. /**
  43293. * Creates a new InternalTexture
  43294. * @param engine defines the engine to use
  43295. * @param source defines the type of data that will be used
  43296. * @param delayAllocation if the texture allocation should be delayed (default: false)
  43297. */
  43298. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  43299. /**
  43300. * Increments the number of references (ie. the number of Texture that point to it)
  43301. */
  43302. incrementReferences(): void;
  43303. /**
  43304. * Change the size of the texture (not the size of the content)
  43305. * @param width defines the new width
  43306. * @param height defines the new height
  43307. * @param depth defines the new depth (1 by default)
  43308. */
  43309. updateSize(width: int, height: int, depth?: int): void;
  43310. /** @hidden */
  43311. _rebuild(): void;
  43312. /** @hidden */
  43313. _swapAndDie(target: InternalTexture): void;
  43314. /**
  43315. * Dispose the current allocated resources
  43316. */
  43317. dispose(): void;
  43318. }
  43319. }
  43320. declare module "babylonjs/Loading/loadingScreen" {
  43321. /**
  43322. * Interface used to present a loading screen while loading a scene
  43323. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43324. */
  43325. export interface ILoadingScreen {
  43326. /**
  43327. * Function called to display the loading screen
  43328. */
  43329. displayLoadingUI: () => void;
  43330. /**
  43331. * Function called to hide the loading screen
  43332. */
  43333. hideLoadingUI: () => void;
  43334. /**
  43335. * Gets or sets the color to use for the background
  43336. */
  43337. loadingUIBackgroundColor: string;
  43338. /**
  43339. * Gets or sets the text to display while loading
  43340. */
  43341. loadingUIText: string;
  43342. }
  43343. /**
  43344. * Class used for the default loading screen
  43345. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43346. */
  43347. export class DefaultLoadingScreen implements ILoadingScreen {
  43348. private _renderingCanvas;
  43349. private _loadingText;
  43350. private _loadingDivBackgroundColor;
  43351. private _loadingDiv;
  43352. private _loadingTextDiv;
  43353. /** Gets or sets the logo url to use for the default loading screen */
  43354. static DefaultLogoUrl: string;
  43355. /** Gets or sets the spinner url to use for the default loading screen */
  43356. static DefaultSpinnerUrl: string;
  43357. /**
  43358. * Creates a new default loading screen
  43359. * @param _renderingCanvas defines the canvas used to render the scene
  43360. * @param _loadingText defines the default text to display
  43361. * @param _loadingDivBackgroundColor defines the default background color
  43362. */
  43363. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  43364. /**
  43365. * Function called to display the loading screen
  43366. */
  43367. displayLoadingUI(): void;
  43368. /**
  43369. * Function called to hide the loading screen
  43370. */
  43371. hideLoadingUI(): void;
  43372. /**
  43373. * Gets or sets the text to display while loading
  43374. */
  43375. set loadingUIText(text: string);
  43376. get loadingUIText(): string;
  43377. /**
  43378. * Gets or sets the color to use for the background
  43379. */
  43380. get loadingUIBackgroundColor(): string;
  43381. set loadingUIBackgroundColor(color: string);
  43382. private _resizeLoadingUI;
  43383. }
  43384. }
  43385. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  43386. /**
  43387. * Interface for any object that can request an animation frame
  43388. */
  43389. export interface ICustomAnimationFrameRequester {
  43390. /**
  43391. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  43392. */
  43393. renderFunction?: Function;
  43394. /**
  43395. * Called to request the next frame to render to
  43396. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  43397. */
  43398. requestAnimationFrame: Function;
  43399. /**
  43400. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  43401. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  43402. */
  43403. requestID?: number;
  43404. }
  43405. }
  43406. declare module "babylonjs/Misc/performanceMonitor" {
  43407. /**
  43408. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  43409. */
  43410. export class PerformanceMonitor {
  43411. private _enabled;
  43412. private _rollingFrameTime;
  43413. private _lastFrameTimeMs;
  43414. /**
  43415. * constructor
  43416. * @param frameSampleSize The number of samples required to saturate the sliding window
  43417. */
  43418. constructor(frameSampleSize?: number);
  43419. /**
  43420. * Samples current frame
  43421. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  43422. */
  43423. sampleFrame(timeMs?: number): void;
  43424. /**
  43425. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  43426. */
  43427. get averageFrameTime(): number;
  43428. /**
  43429. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  43430. */
  43431. get averageFrameTimeVariance(): number;
  43432. /**
  43433. * Returns the frame time of the most recent frame
  43434. */
  43435. get instantaneousFrameTime(): number;
  43436. /**
  43437. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  43438. */
  43439. get averageFPS(): number;
  43440. /**
  43441. * Returns the average framerate in frames per second using the most recent frame time
  43442. */
  43443. get instantaneousFPS(): number;
  43444. /**
  43445. * Returns true if enough samples have been taken to completely fill the sliding window
  43446. */
  43447. get isSaturated(): boolean;
  43448. /**
  43449. * Enables contributions to the sliding window sample set
  43450. */
  43451. enable(): void;
  43452. /**
  43453. * Disables contributions to the sliding window sample set
  43454. * Samples will not be interpolated over the disabled period
  43455. */
  43456. disable(): void;
  43457. /**
  43458. * Returns true if sampling is enabled
  43459. */
  43460. get isEnabled(): boolean;
  43461. /**
  43462. * Resets performance monitor
  43463. */
  43464. reset(): void;
  43465. }
  43466. /**
  43467. * RollingAverage
  43468. *
  43469. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  43470. */
  43471. export class RollingAverage {
  43472. /**
  43473. * Current average
  43474. */
  43475. average: number;
  43476. /**
  43477. * Current variance
  43478. */
  43479. variance: number;
  43480. protected _samples: Array<number>;
  43481. protected _sampleCount: number;
  43482. protected _pos: number;
  43483. protected _m2: number;
  43484. /**
  43485. * constructor
  43486. * @param length The number of samples required to saturate the sliding window
  43487. */
  43488. constructor(length: number);
  43489. /**
  43490. * Adds a sample to the sample set
  43491. * @param v The sample value
  43492. */
  43493. add(v: number): void;
  43494. /**
  43495. * Returns previously added values or null if outside of history or outside the sliding window domain
  43496. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  43497. * @return Value previously recorded with add() or null if outside of range
  43498. */
  43499. history(i: number): number;
  43500. /**
  43501. * Returns true if enough samples have been taken to completely fill the sliding window
  43502. * @return true if sample-set saturated
  43503. */
  43504. isSaturated(): boolean;
  43505. /**
  43506. * Resets the rolling average (equivalent to 0 samples taken so far)
  43507. */
  43508. reset(): void;
  43509. /**
  43510. * Wraps a value around the sample range boundaries
  43511. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  43512. * @return Wrapped position in sample range
  43513. */
  43514. protected _wrapPosition(i: number): number;
  43515. }
  43516. }
  43517. declare module "babylonjs/Misc/perfCounter" {
  43518. /**
  43519. * This class is used to track a performance counter which is number based.
  43520. * The user has access to many properties which give statistics of different nature.
  43521. *
  43522. * The implementer can track two kinds of Performance Counter: time and count.
  43523. * 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.
  43524. * 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.
  43525. */
  43526. export class PerfCounter {
  43527. /**
  43528. * Gets or sets a global boolean to turn on and off all the counters
  43529. */
  43530. static Enabled: boolean;
  43531. /**
  43532. * Returns the smallest value ever
  43533. */
  43534. get min(): number;
  43535. /**
  43536. * Returns the biggest value ever
  43537. */
  43538. get max(): number;
  43539. /**
  43540. * Returns the average value since the performance counter is running
  43541. */
  43542. get average(): number;
  43543. /**
  43544. * Returns the average value of the last second the counter was monitored
  43545. */
  43546. get lastSecAverage(): number;
  43547. /**
  43548. * Returns the current value
  43549. */
  43550. get current(): number;
  43551. /**
  43552. * Gets the accumulated total
  43553. */
  43554. get total(): number;
  43555. /**
  43556. * Gets the total value count
  43557. */
  43558. get count(): number;
  43559. /**
  43560. * Creates a new counter
  43561. */
  43562. constructor();
  43563. /**
  43564. * Call this method to start monitoring a new frame.
  43565. * 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.
  43566. */
  43567. fetchNewFrame(): void;
  43568. /**
  43569. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  43570. * @param newCount the count value to add to the monitored count
  43571. * @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.
  43572. */
  43573. addCount(newCount: number, fetchResult: boolean): void;
  43574. /**
  43575. * Start monitoring this performance counter
  43576. */
  43577. beginMonitoring(): void;
  43578. /**
  43579. * Compute the time lapsed since the previous beginMonitoring() call.
  43580. * @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
  43581. */
  43582. endMonitoring(newFrame?: boolean): void;
  43583. private _fetchResult;
  43584. private _startMonitoringTime;
  43585. private _min;
  43586. private _max;
  43587. private _average;
  43588. private _current;
  43589. private _totalValueCount;
  43590. private _totalAccumulated;
  43591. private _lastSecAverage;
  43592. private _lastSecAccumulated;
  43593. private _lastSecTime;
  43594. private _lastSecValueCount;
  43595. }
  43596. }
  43597. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  43598. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43599. import { Nullable } from "babylonjs/types";
  43600. module "babylonjs/Engines/thinEngine" {
  43601. interface ThinEngine {
  43602. /** @hidden */
  43603. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  43604. /** @hidden */
  43605. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  43606. }
  43607. }
  43608. }
  43609. declare module "babylonjs/Audio/analyser" {
  43610. import { Scene } from "babylonjs/scene";
  43611. /**
  43612. * Class used to work with sound analyzer using fast fourier transform (FFT)
  43613. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43614. */
  43615. export class Analyser {
  43616. /**
  43617. * Gets or sets the smoothing
  43618. * @ignorenaming
  43619. */
  43620. SMOOTHING: number;
  43621. /**
  43622. * Gets or sets the FFT table size
  43623. * @ignorenaming
  43624. */
  43625. FFT_SIZE: number;
  43626. /**
  43627. * Gets or sets the bar graph amplitude
  43628. * @ignorenaming
  43629. */
  43630. BARGRAPHAMPLITUDE: number;
  43631. /**
  43632. * Gets or sets the position of the debug canvas
  43633. * @ignorenaming
  43634. */
  43635. DEBUGCANVASPOS: {
  43636. x: number;
  43637. y: number;
  43638. };
  43639. /**
  43640. * Gets or sets the debug canvas size
  43641. * @ignorenaming
  43642. */
  43643. DEBUGCANVASSIZE: {
  43644. width: number;
  43645. height: number;
  43646. };
  43647. private _byteFreqs;
  43648. private _byteTime;
  43649. private _floatFreqs;
  43650. private _webAudioAnalyser;
  43651. private _debugCanvas;
  43652. private _debugCanvasContext;
  43653. private _scene;
  43654. private _registerFunc;
  43655. private _audioEngine;
  43656. /**
  43657. * Creates a new analyser
  43658. * @param scene defines hosting scene
  43659. */
  43660. constructor(scene: Scene);
  43661. /**
  43662. * Get the number of data values you will have to play with for the visualization
  43663. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  43664. * @returns a number
  43665. */
  43666. getFrequencyBinCount(): number;
  43667. /**
  43668. * Gets the current frequency data as a byte array
  43669. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43670. * @returns a Uint8Array
  43671. */
  43672. getByteFrequencyData(): Uint8Array;
  43673. /**
  43674. * Gets the current waveform as a byte array
  43675. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  43676. * @returns a Uint8Array
  43677. */
  43678. getByteTimeDomainData(): Uint8Array;
  43679. /**
  43680. * Gets the current frequency data as a float array
  43681. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43682. * @returns a Float32Array
  43683. */
  43684. getFloatFrequencyData(): Float32Array;
  43685. /**
  43686. * Renders the debug canvas
  43687. */
  43688. drawDebugCanvas(): void;
  43689. /**
  43690. * Stops rendering the debug canvas and removes it
  43691. */
  43692. stopDebugCanvas(): void;
  43693. /**
  43694. * Connects two audio nodes
  43695. * @param inputAudioNode defines first node to connect
  43696. * @param outputAudioNode defines second node to connect
  43697. */
  43698. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  43699. /**
  43700. * Releases all associated resources
  43701. */
  43702. dispose(): void;
  43703. }
  43704. }
  43705. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  43706. import { Observable } from "babylonjs/Misc/observable";
  43707. import { IDisposable } from "babylonjs/scene";
  43708. import { Nullable } from "babylonjs/types";
  43709. import { Analyser } from "babylonjs/Audio/analyser";
  43710. /**
  43711. * This represents an audio engine and it is responsible
  43712. * to play, synchronize and analyse sounds throughout the application.
  43713. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43714. */
  43715. export interface IAudioEngine extends IDisposable {
  43716. /**
  43717. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  43718. */
  43719. readonly canUseWebAudio: boolean;
  43720. /**
  43721. * Gets the current AudioContext if available.
  43722. */
  43723. readonly audioContext: Nullable<AudioContext>;
  43724. /**
  43725. * The master gain node defines the global audio volume of your audio engine.
  43726. */
  43727. readonly masterGain: GainNode;
  43728. /**
  43729. * Gets whether or not mp3 are supported by your browser.
  43730. */
  43731. readonly isMP3supported: boolean;
  43732. /**
  43733. * Gets whether or not ogg are supported by your browser.
  43734. */
  43735. readonly isOGGsupported: boolean;
  43736. /**
  43737. * Defines if Babylon should emit a warning if WebAudio is not supported.
  43738. * @ignoreNaming
  43739. */
  43740. WarnedWebAudioUnsupported: boolean;
  43741. /**
  43742. * Defines if the audio engine relies on a custom unlocked button.
  43743. * In this case, the embedded button will not be displayed.
  43744. */
  43745. useCustomUnlockedButton: boolean;
  43746. /**
  43747. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  43748. */
  43749. readonly unlocked: boolean;
  43750. /**
  43751. * Event raised when audio has been unlocked on the browser.
  43752. */
  43753. onAudioUnlockedObservable: Observable<IAudioEngine>;
  43754. /**
  43755. * Event raised when audio has been locked on the browser.
  43756. */
  43757. onAudioLockedObservable: Observable<IAudioEngine>;
  43758. /**
  43759. * Flags the audio engine in Locked state.
  43760. * This happens due to new browser policies preventing audio to autoplay.
  43761. */
  43762. lock(): void;
  43763. /**
  43764. * Unlocks the audio engine once a user action has been done on the dom.
  43765. * This is helpful to resume play once browser policies have been satisfied.
  43766. */
  43767. unlock(): void;
  43768. /**
  43769. * Gets the global volume sets on the master gain.
  43770. * @returns the global volume if set or -1 otherwise
  43771. */
  43772. getGlobalVolume(): number;
  43773. /**
  43774. * Sets the global volume of your experience (sets on the master gain).
  43775. * @param newVolume Defines the new global volume of the application
  43776. */
  43777. setGlobalVolume(newVolume: number): void;
  43778. /**
  43779. * Connect the audio engine to an audio analyser allowing some amazing
  43780. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  43781. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43782. * @param analyser The analyser to connect to the engine
  43783. */
  43784. connectToAnalyser(analyser: Analyser): void;
  43785. }
  43786. }
  43787. declare module "babylonjs/Engines/engine" {
  43788. import { Observable } from "babylonjs/Misc/observable";
  43789. import { Nullable } from "babylonjs/types";
  43790. import { Scene } from "babylonjs/scene";
  43791. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43792. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43793. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  43794. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43795. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43796. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  43797. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  43798. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  43799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43800. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  43801. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43802. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43803. import "babylonjs/Engines/Extensions/engine.alpha";
  43804. import "babylonjs/Engines/Extensions/engine.readTexture";
  43805. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  43806. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  43807. import { Material } from "babylonjs/Materials/material";
  43808. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43809. /**
  43810. * Defines the interface used by display changed events
  43811. */
  43812. export interface IDisplayChangedEventArgs {
  43813. /** Gets the vrDisplay object (if any) */
  43814. vrDisplay: Nullable<any>;
  43815. /** Gets a boolean indicating if webVR is supported */
  43816. vrSupported: boolean;
  43817. }
  43818. /**
  43819. * Defines the interface used by objects containing a viewport (like a camera)
  43820. */
  43821. interface IViewportOwnerLike {
  43822. /**
  43823. * Gets or sets the viewport
  43824. */
  43825. viewport: IViewportLike;
  43826. }
  43827. /**
  43828. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  43829. */
  43830. export class Engine extends ThinEngine {
  43831. /** Defines that alpha blending is disabled */
  43832. static readonly ALPHA_DISABLE: number;
  43833. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  43834. static readonly ALPHA_ADD: number;
  43835. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  43836. static readonly ALPHA_COMBINE: number;
  43837. /** Defines that alpha blending to DEST - SRC * DEST */
  43838. static readonly ALPHA_SUBTRACT: number;
  43839. /** Defines that alpha blending to SRC * DEST */
  43840. static readonly ALPHA_MULTIPLY: number;
  43841. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  43842. static readonly ALPHA_MAXIMIZED: number;
  43843. /** Defines that alpha blending to SRC + DEST */
  43844. static readonly ALPHA_ONEONE: number;
  43845. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  43846. static readonly ALPHA_PREMULTIPLIED: number;
  43847. /**
  43848. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  43849. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  43850. */
  43851. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  43852. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  43853. static readonly ALPHA_INTERPOLATE: number;
  43854. /**
  43855. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  43856. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  43857. */
  43858. static readonly ALPHA_SCREENMODE: number;
  43859. /** Defines that the resource is not delayed*/
  43860. static readonly DELAYLOADSTATE_NONE: number;
  43861. /** Defines that the resource was successfully delay loaded */
  43862. static readonly DELAYLOADSTATE_LOADED: number;
  43863. /** Defines that the resource is currently delay loading */
  43864. static readonly DELAYLOADSTATE_LOADING: number;
  43865. /** Defines that the resource is delayed and has not started loading */
  43866. static readonly DELAYLOADSTATE_NOTLOADED: number;
  43867. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  43868. static readonly NEVER: number;
  43869. /** 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 */
  43870. static readonly ALWAYS: number;
  43871. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  43872. static readonly LESS: number;
  43873. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  43874. static readonly EQUAL: number;
  43875. /** 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 */
  43876. static readonly LEQUAL: number;
  43877. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  43878. static readonly GREATER: number;
  43879. /** 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 */
  43880. static readonly GEQUAL: number;
  43881. /** 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 */
  43882. static readonly NOTEQUAL: number;
  43883. /** Passed to stencilOperation to specify that stencil value must be kept */
  43884. static readonly KEEP: number;
  43885. /** Passed to stencilOperation to specify that stencil value must be replaced */
  43886. static readonly REPLACE: number;
  43887. /** Passed to stencilOperation to specify that stencil value must be incremented */
  43888. static readonly INCR: number;
  43889. /** Passed to stencilOperation to specify that stencil value must be decremented */
  43890. static readonly DECR: number;
  43891. /** Passed to stencilOperation to specify that stencil value must be inverted */
  43892. static readonly INVERT: number;
  43893. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  43894. static readonly INCR_WRAP: number;
  43895. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  43896. static readonly DECR_WRAP: number;
  43897. /** Texture is not repeating outside of 0..1 UVs */
  43898. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  43899. /** Texture is repeating outside of 0..1 UVs */
  43900. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  43901. /** Texture is repeating and mirrored */
  43902. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  43903. /** ALPHA */
  43904. static readonly TEXTUREFORMAT_ALPHA: number;
  43905. /** LUMINANCE */
  43906. static readonly TEXTUREFORMAT_LUMINANCE: number;
  43907. /** LUMINANCE_ALPHA */
  43908. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  43909. /** RGB */
  43910. static readonly TEXTUREFORMAT_RGB: number;
  43911. /** RGBA */
  43912. static readonly TEXTUREFORMAT_RGBA: number;
  43913. /** RED */
  43914. static readonly TEXTUREFORMAT_RED: number;
  43915. /** RED (2nd reference) */
  43916. static readonly TEXTUREFORMAT_R: number;
  43917. /** RG */
  43918. static readonly TEXTUREFORMAT_RG: number;
  43919. /** RED_INTEGER */
  43920. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  43921. /** RED_INTEGER (2nd reference) */
  43922. static readonly TEXTUREFORMAT_R_INTEGER: number;
  43923. /** RG_INTEGER */
  43924. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  43925. /** RGB_INTEGER */
  43926. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  43927. /** RGBA_INTEGER */
  43928. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  43929. /** UNSIGNED_BYTE */
  43930. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  43931. /** UNSIGNED_BYTE (2nd reference) */
  43932. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  43933. /** FLOAT */
  43934. static readonly TEXTURETYPE_FLOAT: number;
  43935. /** HALF_FLOAT */
  43936. static readonly TEXTURETYPE_HALF_FLOAT: number;
  43937. /** BYTE */
  43938. static readonly TEXTURETYPE_BYTE: number;
  43939. /** SHORT */
  43940. static readonly TEXTURETYPE_SHORT: number;
  43941. /** UNSIGNED_SHORT */
  43942. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  43943. /** INT */
  43944. static readonly TEXTURETYPE_INT: number;
  43945. /** UNSIGNED_INT */
  43946. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  43947. /** UNSIGNED_SHORT_4_4_4_4 */
  43948. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  43949. /** UNSIGNED_SHORT_5_5_5_1 */
  43950. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  43951. /** UNSIGNED_SHORT_5_6_5 */
  43952. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  43953. /** UNSIGNED_INT_2_10_10_10_REV */
  43954. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  43955. /** UNSIGNED_INT_24_8 */
  43956. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  43957. /** UNSIGNED_INT_10F_11F_11F_REV */
  43958. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  43959. /** UNSIGNED_INT_5_9_9_9_REV */
  43960. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  43961. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  43962. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  43963. /** nearest is mag = nearest and min = nearest and mip = none */
  43964. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  43965. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43966. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  43967. /** Trilinear is mag = linear and min = linear and mip = linear */
  43968. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  43969. /** nearest is mag = nearest and min = nearest and mip = linear */
  43970. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  43971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43972. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  43973. /** Trilinear is mag = linear and min = linear and mip = linear */
  43974. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  43975. /** mag = nearest and min = nearest and mip = nearest */
  43976. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  43977. /** mag = nearest and min = linear and mip = nearest */
  43978. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  43979. /** mag = nearest and min = linear and mip = linear */
  43980. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  43981. /** mag = nearest and min = linear and mip = none */
  43982. static readonly TEXTURE_NEAREST_LINEAR: number;
  43983. /** mag = nearest and min = nearest and mip = none */
  43984. static readonly TEXTURE_NEAREST_NEAREST: number;
  43985. /** mag = linear and min = nearest and mip = nearest */
  43986. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  43987. /** mag = linear and min = nearest and mip = linear */
  43988. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  43989. /** mag = linear and min = linear and mip = none */
  43990. static readonly TEXTURE_LINEAR_LINEAR: number;
  43991. /** mag = linear and min = nearest and mip = none */
  43992. static readonly TEXTURE_LINEAR_NEAREST: number;
  43993. /** Explicit coordinates mode */
  43994. static readonly TEXTURE_EXPLICIT_MODE: number;
  43995. /** Spherical coordinates mode */
  43996. static readonly TEXTURE_SPHERICAL_MODE: number;
  43997. /** Planar coordinates mode */
  43998. static readonly TEXTURE_PLANAR_MODE: number;
  43999. /** Cubic coordinates mode */
  44000. static readonly TEXTURE_CUBIC_MODE: number;
  44001. /** Projection coordinates mode */
  44002. static readonly TEXTURE_PROJECTION_MODE: number;
  44003. /** Skybox coordinates mode */
  44004. static readonly TEXTURE_SKYBOX_MODE: number;
  44005. /** Inverse Cubic coordinates mode */
  44006. static readonly TEXTURE_INVCUBIC_MODE: number;
  44007. /** Equirectangular coordinates mode */
  44008. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  44009. /** Equirectangular Fixed coordinates mode */
  44010. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  44011. /** Equirectangular Fixed Mirrored coordinates mode */
  44012. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  44013. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  44014. static readonly SCALEMODE_FLOOR: number;
  44015. /** Defines that texture rescaling will look for the nearest power of 2 size */
  44016. static readonly SCALEMODE_NEAREST: number;
  44017. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  44018. static readonly SCALEMODE_CEILING: number;
  44019. /**
  44020. * Returns the current npm package of the sdk
  44021. */
  44022. static get NpmPackage(): string;
  44023. /**
  44024. * Returns the current version of the framework
  44025. */
  44026. static get Version(): string;
  44027. /** Gets the list of created engines */
  44028. static get Instances(): Engine[];
  44029. /**
  44030. * Gets the latest created engine
  44031. */
  44032. static get LastCreatedEngine(): Nullable<Engine>;
  44033. /**
  44034. * Gets the latest created scene
  44035. */
  44036. static get LastCreatedScene(): Nullable<Scene>;
  44037. /**
  44038. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  44039. * @param flag defines which part of the materials must be marked as dirty
  44040. * @param predicate defines a predicate used to filter which materials should be affected
  44041. */
  44042. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44043. /**
  44044. * Method called to create the default loading screen.
  44045. * This can be overridden in your own app.
  44046. * @param canvas The rendering canvas element
  44047. * @returns The loading screen
  44048. */
  44049. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  44050. /**
  44051. * Method called to create the default rescale post process on each engine.
  44052. */
  44053. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  44054. /**
  44055. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  44056. **/
  44057. enableOfflineSupport: boolean;
  44058. /**
  44059. * 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)
  44060. **/
  44061. disableManifestCheck: boolean;
  44062. /**
  44063. * Gets the list of created scenes
  44064. */
  44065. scenes: Scene[];
  44066. /**
  44067. * Event raised when a new scene is created
  44068. */
  44069. onNewSceneAddedObservable: Observable<Scene>;
  44070. /**
  44071. * Gets the list of created postprocesses
  44072. */
  44073. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  44074. /**
  44075. * Gets a boolean indicating if the pointer is currently locked
  44076. */
  44077. isPointerLock: boolean;
  44078. /**
  44079. * Observable event triggered each time the rendering canvas is resized
  44080. */
  44081. onResizeObservable: Observable<Engine>;
  44082. /**
  44083. * Observable event triggered each time the canvas loses focus
  44084. */
  44085. onCanvasBlurObservable: Observable<Engine>;
  44086. /**
  44087. * Observable event triggered each time the canvas gains focus
  44088. */
  44089. onCanvasFocusObservable: Observable<Engine>;
  44090. /**
  44091. * Observable event triggered each time the canvas receives pointerout event
  44092. */
  44093. onCanvasPointerOutObservable: Observable<PointerEvent>;
  44094. /**
  44095. * Observable raised when the engine begins a new frame
  44096. */
  44097. onBeginFrameObservable: Observable<Engine>;
  44098. /**
  44099. * If set, will be used to request the next animation frame for the render loop
  44100. */
  44101. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  44102. /**
  44103. * Observable raised when the engine ends the current frame
  44104. */
  44105. onEndFrameObservable: Observable<Engine>;
  44106. /**
  44107. * Observable raised when the engine is about to compile a shader
  44108. */
  44109. onBeforeShaderCompilationObservable: Observable<Engine>;
  44110. /**
  44111. * Observable raised when the engine has just compiled a shader
  44112. */
  44113. onAfterShaderCompilationObservable: Observable<Engine>;
  44114. /**
  44115. * Gets the audio engine
  44116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44117. * @ignorenaming
  44118. */
  44119. static audioEngine: IAudioEngine;
  44120. /**
  44121. * Default AudioEngine factory responsible of creating the Audio Engine.
  44122. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  44123. */
  44124. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  44125. /**
  44126. * Default offline support factory responsible of creating a tool used to store data locally.
  44127. * By default, this will create a Database object if the workload has been embedded.
  44128. */
  44129. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  44130. private _loadingScreen;
  44131. private _pointerLockRequested;
  44132. private _rescalePostProcess;
  44133. protected _deterministicLockstep: boolean;
  44134. protected _lockstepMaxSteps: number;
  44135. protected _timeStep: number;
  44136. protected get _supportsHardwareTextureRescaling(): boolean;
  44137. private _fps;
  44138. private _deltaTime;
  44139. /** @hidden */
  44140. _drawCalls: PerfCounter;
  44141. /** 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 */
  44142. canvasTabIndex: number;
  44143. /**
  44144. * Turn this value on if you want to pause FPS computation when in background
  44145. */
  44146. disablePerformanceMonitorInBackground: boolean;
  44147. private _performanceMonitor;
  44148. /**
  44149. * Gets the performance monitor attached to this engine
  44150. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44151. */
  44152. get performanceMonitor(): PerformanceMonitor;
  44153. private _onFocus;
  44154. private _onBlur;
  44155. private _onCanvasPointerOut;
  44156. private _onCanvasBlur;
  44157. private _onCanvasFocus;
  44158. private _onFullscreenChange;
  44159. private _onPointerLockChange;
  44160. /**
  44161. * Gets the HTML element used to attach event listeners
  44162. * @returns a HTML element
  44163. */
  44164. getInputElement(): Nullable<HTMLElement>;
  44165. /**
  44166. * Creates a new engine
  44167. * @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 already used the WebGL context
  44168. * @param antialias defines enable antialiasing (default: false)
  44169. * @param options defines further options to be sent to the getContext() function
  44170. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  44171. */
  44172. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  44173. /**
  44174. * Shared initialization across engines types.
  44175. * @param canvas The canvas associated with this instance of the engine.
  44176. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  44177. * @param audioEngine Defines if an audio engine should be created by default
  44178. */
  44179. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  44180. /**
  44181. * Gets current aspect ratio
  44182. * @param viewportOwner defines the camera to use to get the aspect ratio
  44183. * @param useScreen defines if screen size must be used (or the current render target if any)
  44184. * @returns a number defining the aspect ratio
  44185. */
  44186. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  44187. /**
  44188. * Gets current screen aspect ratio
  44189. * @returns a number defining the aspect ratio
  44190. */
  44191. getScreenAspectRatio(): number;
  44192. /**
  44193. * Gets the client rect of the HTML canvas attached with the current webGL context
  44194. * @returns a client rectangle
  44195. */
  44196. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  44197. /**
  44198. * Gets the client rect of the HTML element used for events
  44199. * @returns a client rectangle
  44200. */
  44201. getInputElementClientRect(): Nullable<ClientRect>;
  44202. /**
  44203. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44204. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44205. * @returns true if engine is in deterministic lock step mode
  44206. */
  44207. isDeterministicLockStep(): boolean;
  44208. /**
  44209. * Gets the max steps when engine is running in deterministic lock step
  44210. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44211. * @returns the max steps
  44212. */
  44213. getLockstepMaxSteps(): number;
  44214. /**
  44215. * Returns the time in ms between steps when using deterministic lock step.
  44216. * @returns time step in (ms)
  44217. */
  44218. getTimeStep(): number;
  44219. /**
  44220. * Force the mipmap generation for the given render target texture
  44221. * @param texture defines the render target texture to use
  44222. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  44223. */
  44224. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  44225. /** States */
  44226. /**
  44227. * Set various states to the webGL context
  44228. * @param culling defines backface culling state
  44229. * @param zOffset defines the value to apply to zOffset (0 by default)
  44230. * @param force defines if states must be applied even if cache is up to date
  44231. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44232. */
  44233. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44234. /**
  44235. * Set the z offset to apply to current rendering
  44236. * @param value defines the offset to apply
  44237. */
  44238. setZOffset(value: number): void;
  44239. /**
  44240. * Gets the current value of the zOffset
  44241. * @returns the current zOffset state
  44242. */
  44243. getZOffset(): number;
  44244. /**
  44245. * Gets a boolean indicating if depth testing is enabled
  44246. * @returns the current state
  44247. */
  44248. getDepthBuffer(): boolean;
  44249. /**
  44250. * Enable or disable depth buffering
  44251. * @param enable defines the state to set
  44252. */
  44253. setDepthBuffer(enable: boolean): void;
  44254. /**
  44255. * Gets a boolean indicating if depth writing is enabled
  44256. * @returns the current depth writing state
  44257. */
  44258. getDepthWrite(): boolean;
  44259. /**
  44260. * Enable or disable depth writing
  44261. * @param enable defines the state to set
  44262. */
  44263. setDepthWrite(enable: boolean): void;
  44264. /**
  44265. * Gets a boolean indicating if stencil buffer is enabled
  44266. * @returns the current stencil buffer state
  44267. */
  44268. getStencilBuffer(): boolean;
  44269. /**
  44270. * Enable or disable the stencil buffer
  44271. * @param enable defines if the stencil buffer must be enabled or disabled
  44272. */
  44273. setStencilBuffer(enable: boolean): void;
  44274. /**
  44275. * Gets the current stencil mask
  44276. * @returns a number defining the new stencil mask to use
  44277. */
  44278. getStencilMask(): number;
  44279. /**
  44280. * Sets the current stencil mask
  44281. * @param mask defines the new stencil mask to use
  44282. */
  44283. setStencilMask(mask: number): void;
  44284. /**
  44285. * Gets the current stencil function
  44286. * @returns a number defining the stencil function to use
  44287. */
  44288. getStencilFunction(): number;
  44289. /**
  44290. * Gets the current stencil reference value
  44291. * @returns a number defining the stencil reference value to use
  44292. */
  44293. getStencilFunctionReference(): number;
  44294. /**
  44295. * Gets the current stencil mask
  44296. * @returns a number defining the stencil mask to use
  44297. */
  44298. getStencilFunctionMask(): number;
  44299. /**
  44300. * Sets the current stencil function
  44301. * @param stencilFunc defines the new stencil function to use
  44302. */
  44303. setStencilFunction(stencilFunc: number): void;
  44304. /**
  44305. * Sets the current stencil reference
  44306. * @param reference defines the new stencil reference to use
  44307. */
  44308. setStencilFunctionReference(reference: number): void;
  44309. /**
  44310. * Sets the current stencil mask
  44311. * @param mask defines the new stencil mask to use
  44312. */
  44313. setStencilFunctionMask(mask: number): void;
  44314. /**
  44315. * Gets the current stencil operation when stencil fails
  44316. * @returns a number defining stencil operation to use when stencil fails
  44317. */
  44318. getStencilOperationFail(): number;
  44319. /**
  44320. * Gets the current stencil operation when depth fails
  44321. * @returns a number defining stencil operation to use when depth fails
  44322. */
  44323. getStencilOperationDepthFail(): number;
  44324. /**
  44325. * Gets the current stencil operation when stencil passes
  44326. * @returns a number defining stencil operation to use when stencil passes
  44327. */
  44328. getStencilOperationPass(): number;
  44329. /**
  44330. * Sets the stencil operation to use when stencil fails
  44331. * @param operation defines the stencil operation to use when stencil fails
  44332. */
  44333. setStencilOperationFail(operation: number): void;
  44334. /**
  44335. * Sets the stencil operation to use when depth fails
  44336. * @param operation defines the stencil operation to use when depth fails
  44337. */
  44338. setStencilOperationDepthFail(operation: number): void;
  44339. /**
  44340. * Sets the stencil operation to use when stencil passes
  44341. * @param operation defines the stencil operation to use when stencil passes
  44342. */
  44343. setStencilOperationPass(operation: number): void;
  44344. /**
  44345. * Sets a boolean indicating if the dithering state is enabled or disabled
  44346. * @param value defines the dithering state
  44347. */
  44348. setDitheringState(value: boolean): void;
  44349. /**
  44350. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  44351. * @param value defines the rasterizer state
  44352. */
  44353. setRasterizerState(value: boolean): void;
  44354. /**
  44355. * Gets the current depth function
  44356. * @returns a number defining the depth function
  44357. */
  44358. getDepthFunction(): Nullable<number>;
  44359. /**
  44360. * Sets the current depth function
  44361. * @param depthFunc defines the function to use
  44362. */
  44363. setDepthFunction(depthFunc: number): void;
  44364. /**
  44365. * Sets the current depth function to GREATER
  44366. */
  44367. setDepthFunctionToGreater(): void;
  44368. /**
  44369. * Sets the current depth function to GEQUAL
  44370. */
  44371. setDepthFunctionToGreaterOrEqual(): void;
  44372. /**
  44373. * Sets the current depth function to LESS
  44374. */
  44375. setDepthFunctionToLess(): void;
  44376. /**
  44377. * Sets the current depth function to LEQUAL
  44378. */
  44379. setDepthFunctionToLessOrEqual(): void;
  44380. private _cachedStencilBuffer;
  44381. private _cachedStencilFunction;
  44382. private _cachedStencilMask;
  44383. private _cachedStencilOperationPass;
  44384. private _cachedStencilOperationFail;
  44385. private _cachedStencilOperationDepthFail;
  44386. private _cachedStencilReference;
  44387. /**
  44388. * Caches the the state of the stencil buffer
  44389. */
  44390. cacheStencilState(): void;
  44391. /**
  44392. * Restores the state of the stencil buffer
  44393. */
  44394. restoreStencilState(): void;
  44395. /**
  44396. * Directly set the WebGL Viewport
  44397. * @param x defines the x coordinate of the viewport (in screen space)
  44398. * @param y defines the y coordinate of the viewport (in screen space)
  44399. * @param width defines the width of the viewport (in screen space)
  44400. * @param height defines the height of the viewport (in screen space)
  44401. * @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
  44402. */
  44403. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  44404. /**
  44405. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  44406. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  44407. * @param y defines the y-coordinate of the corner of the clear rectangle
  44408. * @param width defines the width of the clear rectangle
  44409. * @param height defines the height of the clear rectangle
  44410. * @param clearColor defines the clear color
  44411. */
  44412. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  44413. /**
  44414. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  44415. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  44416. * @param y defines the y-coordinate of the corner of the clear rectangle
  44417. * @param width defines the width of the clear rectangle
  44418. * @param height defines the height of the clear rectangle
  44419. */
  44420. enableScissor(x: number, y: number, width: number, height: number): void;
  44421. /**
  44422. * Disable previously set scissor test rectangle
  44423. */
  44424. disableScissor(): void;
  44425. protected _reportDrawCall(): void;
  44426. /**
  44427. * Initializes a webVR display and starts listening to display change events
  44428. * The onVRDisplayChangedObservable will be notified upon these changes
  44429. * @returns The onVRDisplayChangedObservable
  44430. */
  44431. initWebVR(): Observable<IDisplayChangedEventArgs>;
  44432. /** @hidden */
  44433. _prepareVRComponent(): void;
  44434. /** @hidden */
  44435. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  44436. /** @hidden */
  44437. _submitVRFrame(): void;
  44438. /**
  44439. * Call this function to leave webVR mode
  44440. * Will do nothing if webVR is not supported or if there is no webVR device
  44441. * @see https://doc.babylonjs.com/how_to/webvr_camera
  44442. */
  44443. disableVR(): void;
  44444. /**
  44445. * Gets a boolean indicating that the system is in VR mode and is presenting
  44446. * @returns true if VR mode is engaged
  44447. */
  44448. isVRPresenting(): boolean;
  44449. /** @hidden */
  44450. _requestVRFrame(): void;
  44451. /** @hidden */
  44452. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44453. /**
  44454. * Gets the source code of the vertex shader associated with a specific webGL program
  44455. * @param program defines the program to use
  44456. * @returns a string containing the source code of the vertex shader associated with the program
  44457. */
  44458. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  44459. /**
  44460. * Gets the source code of the fragment shader associated with a specific webGL program
  44461. * @param program defines the program to use
  44462. * @returns a string containing the source code of the fragment shader associated with the program
  44463. */
  44464. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  44465. /**
  44466. * Sets a depth stencil texture from a render target to the according uniform.
  44467. * @param channel The texture channel
  44468. * @param uniform The uniform to set
  44469. * @param texture The render target texture containing the depth stencil texture to apply
  44470. * @param name The texture name
  44471. */
  44472. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  44473. /**
  44474. * Sets a texture to the webGL context from a postprocess
  44475. * @param channel defines the channel to use
  44476. * @param postProcess defines the source postprocess
  44477. * @param name name of the channel
  44478. */
  44479. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44480. /**
  44481. * Binds the output of the passed in post process to the texture channel specified
  44482. * @param channel The channel the texture should be bound to
  44483. * @param postProcess The post process which's output should be bound
  44484. * @param name name of the channel
  44485. */
  44486. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44487. protected _rebuildBuffers(): void;
  44488. /** @hidden */
  44489. _renderFrame(): void;
  44490. _renderLoop(): void;
  44491. /** @hidden */
  44492. _renderViews(): boolean;
  44493. /**
  44494. * Toggle full screen mode
  44495. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44496. */
  44497. switchFullscreen(requestPointerLock: boolean): void;
  44498. /**
  44499. * Enters full screen mode
  44500. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44501. */
  44502. enterFullscreen(requestPointerLock: boolean): void;
  44503. /**
  44504. * Exits full screen mode
  44505. */
  44506. exitFullscreen(): void;
  44507. /**
  44508. * Enters Pointerlock mode
  44509. */
  44510. enterPointerlock(): void;
  44511. /**
  44512. * Exits Pointerlock mode
  44513. */
  44514. exitPointerlock(): void;
  44515. /**
  44516. * Begin a new frame
  44517. */
  44518. beginFrame(): void;
  44519. /**
  44520. * End the current frame
  44521. */
  44522. endFrame(): void;
  44523. /**
  44524. * Resize the view according to the canvas' size
  44525. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44526. */
  44527. resize(forceSetSize?: boolean): void;
  44528. /**
  44529. * Force a specific size of the canvas
  44530. * @param width defines the new canvas' width
  44531. * @param height defines the new canvas' height
  44532. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44533. * @returns true if the size was changed
  44534. */
  44535. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44536. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44537. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44538. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44539. _releaseTexture(texture: InternalTexture): void;
  44540. /**
  44541. * @hidden
  44542. * Rescales a texture
  44543. * @param source input texture
  44544. * @param destination destination texture
  44545. * @param scene scene to use to render the resize
  44546. * @param internalFormat format to use when resizing
  44547. * @param onComplete callback to be called when resize has completed
  44548. */
  44549. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  44550. /**
  44551. * Gets the current framerate
  44552. * @returns a number representing the framerate
  44553. */
  44554. getFps(): number;
  44555. /**
  44556. * Gets the time spent between current and previous frame
  44557. * @returns a number representing the delta time in ms
  44558. */
  44559. getDeltaTime(): number;
  44560. private _measureFps;
  44561. /** @hidden */
  44562. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  44563. /**
  44564. * Updates the sample count of a render target texture
  44565. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44566. * @param texture defines the texture to update
  44567. * @param samples defines the sample count to set
  44568. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44569. */
  44570. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  44571. /**
  44572. * Updates a depth texture Comparison Mode and Function.
  44573. * If the comparison Function is equal to 0, the mode will be set to none.
  44574. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  44575. * @param texture The texture to set the comparison function for
  44576. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  44577. */
  44578. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  44579. /**
  44580. * Creates a webGL buffer to use with instantiation
  44581. * @param capacity defines the size of the buffer
  44582. * @returns the webGL buffer
  44583. */
  44584. createInstancesBuffer(capacity: number): DataBuffer;
  44585. /**
  44586. * Delete a webGL buffer used with instantiation
  44587. * @param buffer defines the webGL buffer to delete
  44588. */
  44589. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  44590. private _clientWaitAsync;
  44591. /** @hidden */
  44592. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  44593. dispose(): void;
  44594. private _disableTouchAction;
  44595. /**
  44596. * Display the loading screen
  44597. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44598. */
  44599. displayLoadingUI(): void;
  44600. /**
  44601. * Hide the loading screen
  44602. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44603. */
  44604. hideLoadingUI(): void;
  44605. /**
  44606. * Gets the current loading screen object
  44607. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44608. */
  44609. get loadingScreen(): ILoadingScreen;
  44610. /**
  44611. * Sets the current loading screen object
  44612. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44613. */
  44614. set loadingScreen(loadingScreen: ILoadingScreen);
  44615. /**
  44616. * Sets the current loading screen text
  44617. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44618. */
  44619. set loadingUIText(text: string);
  44620. /**
  44621. * Sets the current loading screen background color
  44622. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44623. */
  44624. set loadingUIBackgroundColor(color: string);
  44625. /** Pointerlock and fullscreen */
  44626. /**
  44627. * Ask the browser to promote the current element to pointerlock mode
  44628. * @param element defines the DOM element to promote
  44629. */
  44630. static _RequestPointerlock(element: HTMLElement): void;
  44631. /**
  44632. * Asks the browser to exit pointerlock mode
  44633. */
  44634. static _ExitPointerlock(): void;
  44635. /**
  44636. * Ask the browser to promote the current element to fullscreen rendering mode
  44637. * @param element defines the DOM element to promote
  44638. */
  44639. static _RequestFullscreen(element: HTMLElement): void;
  44640. /**
  44641. * Asks the browser to exit fullscreen mode
  44642. */
  44643. static _ExitFullscreen(): void;
  44644. }
  44645. }
  44646. declare module "babylonjs/Engines/engineStore" {
  44647. import { Nullable } from "babylonjs/types";
  44648. import { Engine } from "babylonjs/Engines/engine";
  44649. import { Scene } from "babylonjs/scene";
  44650. /**
  44651. * The engine store class is responsible to hold all the instances of Engine and Scene created
  44652. * during the life time of the application.
  44653. */
  44654. export class EngineStore {
  44655. /** Gets the list of created engines */
  44656. static Instances: import("babylonjs/Engines/engine").Engine[];
  44657. /** @hidden */
  44658. static _LastCreatedScene: Nullable<Scene>;
  44659. /**
  44660. * Gets the latest created engine
  44661. */
  44662. static get LastCreatedEngine(): Nullable<Engine>;
  44663. /**
  44664. * Gets the latest created scene
  44665. */
  44666. static get LastCreatedScene(): Nullable<Scene>;
  44667. /**
  44668. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44669. * @ignorenaming
  44670. */
  44671. static UseFallbackTexture: boolean;
  44672. /**
  44673. * Texture content used if a texture cannot loaded
  44674. * @ignorenaming
  44675. */
  44676. static FallbackTexture: string;
  44677. }
  44678. }
  44679. declare module "babylonjs/Misc/promise" {
  44680. /**
  44681. * Helper class that provides a small promise polyfill
  44682. */
  44683. export class PromisePolyfill {
  44684. /**
  44685. * Static function used to check if the polyfill is required
  44686. * If this is the case then the function will inject the polyfill to window.Promise
  44687. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  44688. */
  44689. static Apply(force?: boolean): void;
  44690. }
  44691. }
  44692. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  44693. /**
  44694. * Interface for screenshot methods with describe argument called `size` as object with options
  44695. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  44696. */
  44697. export interface IScreenshotSize {
  44698. /**
  44699. * number in pixels for canvas height
  44700. */
  44701. height?: number;
  44702. /**
  44703. * multiplier allowing render at a higher or lower resolution
  44704. * If value is defined then height and width will be ignored and taken from camera
  44705. */
  44706. precision?: number;
  44707. /**
  44708. * number in pixels for canvas width
  44709. */
  44710. width?: number;
  44711. }
  44712. }
  44713. declare module "babylonjs/Misc/tools" {
  44714. import { Nullable, float } from "babylonjs/types";
  44715. import { DomManagement } from "babylonjs/Misc/domManagement";
  44716. import { WebRequest } from "babylonjs/Misc/webRequest";
  44717. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44718. import { ReadFileError } from "babylonjs/Misc/fileTools";
  44719. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44720. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  44721. import { Camera } from "babylonjs/Cameras/camera";
  44722. import { Engine } from "babylonjs/Engines/engine";
  44723. interface IColor4Like {
  44724. r: float;
  44725. g: float;
  44726. b: float;
  44727. a: float;
  44728. }
  44729. /**
  44730. * Class containing a set of static utilities functions
  44731. */
  44732. export class Tools {
  44733. /**
  44734. * Gets or sets the base URL to use to load assets
  44735. */
  44736. static get BaseUrl(): string;
  44737. static set BaseUrl(value: string);
  44738. /**
  44739. * Enable/Disable Custom HTTP Request Headers globally.
  44740. * default = false
  44741. * @see CustomRequestHeaders
  44742. */
  44743. static UseCustomRequestHeaders: boolean;
  44744. /**
  44745. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  44746. * i.e. when loading files, where the server/service expects an Authorization header
  44747. */
  44748. static CustomRequestHeaders: {
  44749. [key: string]: string;
  44750. };
  44751. /**
  44752. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  44753. */
  44754. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  44755. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  44756. /**
  44757. * Default behaviour for cors in the application.
  44758. * It can be a string if the expected behavior is identical in the entire app.
  44759. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  44760. */
  44761. static get CorsBehavior(): string | ((url: string | string[]) => string);
  44762. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  44763. /**
  44764. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44765. * @ignorenaming
  44766. */
  44767. static get UseFallbackTexture(): boolean;
  44768. static set UseFallbackTexture(value: boolean);
  44769. /**
  44770. * Use this object to register external classes like custom textures or material
  44771. * to allow the loaders to instantiate them
  44772. */
  44773. static get RegisteredExternalClasses(): {
  44774. [key: string]: Object;
  44775. };
  44776. static set RegisteredExternalClasses(classes: {
  44777. [key: string]: Object;
  44778. });
  44779. /**
  44780. * Texture content used if a texture cannot loaded
  44781. * @ignorenaming
  44782. */
  44783. static get fallbackTexture(): string;
  44784. static set fallbackTexture(value: string);
  44785. /**
  44786. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  44787. * @param u defines the coordinate on X axis
  44788. * @param v defines the coordinate on Y axis
  44789. * @param width defines the width of the source data
  44790. * @param height defines the height of the source data
  44791. * @param pixels defines the source byte array
  44792. * @param color defines the output color
  44793. */
  44794. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  44795. /**
  44796. * Interpolates between a and b via alpha
  44797. * @param a The lower value (returned when alpha = 0)
  44798. * @param b The upper value (returned when alpha = 1)
  44799. * @param alpha The interpolation-factor
  44800. * @return The mixed value
  44801. */
  44802. static Mix(a: number, b: number, alpha: number): number;
  44803. /**
  44804. * Tries to instantiate a new object from a given class name
  44805. * @param className defines the class name to instantiate
  44806. * @returns the new object or null if the system was not able to do the instantiation
  44807. */
  44808. static Instantiate(className: string): any;
  44809. /**
  44810. * Provides a slice function that will work even on IE
  44811. * @param data defines the array to slice
  44812. * @param start defines the start of the data (optional)
  44813. * @param end defines the end of the data (optional)
  44814. * @returns the new sliced array
  44815. */
  44816. static Slice<T>(data: T, start?: number, end?: number): T;
  44817. /**
  44818. * Provides a slice function that will work even on IE
  44819. * The difference between this and Slice is that this will force-convert to array
  44820. * @param data defines the array to slice
  44821. * @param start defines the start of the data (optional)
  44822. * @param end defines the end of the data (optional)
  44823. * @returns the new sliced array
  44824. */
  44825. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  44826. /**
  44827. * Polyfill for setImmediate
  44828. * @param action defines the action to execute after the current execution block
  44829. */
  44830. static SetImmediate(action: () => void): void;
  44831. /**
  44832. * Function indicating if a number is an exponent of 2
  44833. * @param value defines the value to test
  44834. * @returns true if the value is an exponent of 2
  44835. */
  44836. static IsExponentOfTwo(value: number): boolean;
  44837. private static _tmpFloatArray;
  44838. /**
  44839. * Returns the nearest 32-bit single precision float representation of a Number
  44840. * @param value A Number. If the parameter is of a different type, it will get converted
  44841. * to a number or to NaN if it cannot be converted
  44842. * @returns number
  44843. */
  44844. static FloatRound(value: number): number;
  44845. /**
  44846. * Extracts the filename from a path
  44847. * @param path defines the path to use
  44848. * @returns the filename
  44849. */
  44850. static GetFilename(path: string): string;
  44851. /**
  44852. * Extracts the "folder" part of a path (everything before the filename).
  44853. * @param uri The URI to extract the info from
  44854. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  44855. * @returns The "folder" part of the path
  44856. */
  44857. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  44858. /**
  44859. * Extracts text content from a DOM element hierarchy
  44860. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  44861. */
  44862. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  44863. /**
  44864. * Convert an angle in radians to degrees
  44865. * @param angle defines the angle to convert
  44866. * @returns the angle in degrees
  44867. */
  44868. static ToDegrees(angle: number): number;
  44869. /**
  44870. * Convert an angle in degrees to radians
  44871. * @param angle defines the angle to convert
  44872. * @returns the angle in radians
  44873. */
  44874. static ToRadians(angle: number): number;
  44875. /**
  44876. * Returns an array if obj is not an array
  44877. * @param obj defines the object to evaluate as an array
  44878. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  44879. * @returns either obj directly if obj is an array or a new array containing obj
  44880. */
  44881. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  44882. /**
  44883. * Gets the pointer prefix to use
  44884. * @param engine defines the engine we are finding the prefix for
  44885. * @returns "pointer" if touch is enabled. Else returns "mouse"
  44886. */
  44887. static GetPointerPrefix(engine: Engine): string;
  44888. /**
  44889. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  44890. * @param url define the url we are trying
  44891. * @param element define the dom element where to configure the cors policy
  44892. */
  44893. static SetCorsBehavior(url: string | string[], element: {
  44894. crossOrigin: string | null;
  44895. }): void;
  44896. /**
  44897. * Removes unwanted characters from an url
  44898. * @param url defines the url to clean
  44899. * @returns the cleaned url
  44900. */
  44901. static CleanUrl(url: string): string;
  44902. /**
  44903. * Gets or sets a function used to pre-process url before using them to load assets
  44904. */
  44905. static get PreprocessUrl(): (url: string) => string;
  44906. static set PreprocessUrl(processor: (url: string) => string);
  44907. /**
  44908. * Loads an image as an HTMLImageElement.
  44909. * @param input url string, ArrayBuffer, or Blob to load
  44910. * @param onLoad callback called when the image successfully loads
  44911. * @param onError callback called when the image fails to load
  44912. * @param offlineProvider offline provider for caching
  44913. * @param mimeType optional mime type
  44914. * @returns the HTMLImageElement of the loaded image
  44915. */
  44916. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  44917. /**
  44918. * Loads a file from a url
  44919. * @param url url string, ArrayBuffer, or Blob to load
  44920. * @param onSuccess callback called when the file successfully loads
  44921. * @param onProgress callback called while file is loading (if the server supports this mode)
  44922. * @param offlineProvider defines the offline provider for caching
  44923. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44924. * @param onError callback called when the file fails to load
  44925. * @returns a file request object
  44926. */
  44927. 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;
  44928. /**
  44929. * Loads a file from a url
  44930. * @param url the file url to load
  44931. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44932. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  44933. */
  44934. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  44935. /**
  44936. * Load a script (identified by an url). When the url returns, the
  44937. * content of this file is added into a new script element, attached to the DOM (body element)
  44938. * @param scriptUrl defines the url of the script to laod
  44939. * @param onSuccess defines the callback called when the script is loaded
  44940. * @param onError defines the callback to call if an error occurs
  44941. * @param scriptId defines the id of the script element
  44942. */
  44943. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  44944. /**
  44945. * Load an asynchronous script (identified by an url). When the url returns, the
  44946. * content of this file is added into a new script element, attached to the DOM (body element)
  44947. * @param scriptUrl defines the url of the script to laod
  44948. * @param scriptId defines the id of the script element
  44949. * @returns a promise request object
  44950. */
  44951. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  44952. /**
  44953. * Loads a file from a blob
  44954. * @param fileToLoad defines the blob to use
  44955. * @param callback defines the callback to call when data is loaded
  44956. * @param progressCallback defines the callback to call during loading process
  44957. * @returns a file request object
  44958. */
  44959. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  44960. /**
  44961. * Reads a file from a File object
  44962. * @param file defines the file to load
  44963. * @param onSuccess defines the callback to call when data is loaded
  44964. * @param onProgress defines the callback to call during loading process
  44965. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44966. * @param onError defines the callback to call when an error occurs
  44967. * @returns a file request object
  44968. */
  44969. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44970. /**
  44971. * Creates a data url from a given string content
  44972. * @param content defines the content to convert
  44973. * @returns the new data url link
  44974. */
  44975. static FileAsURL(content: string): string;
  44976. /**
  44977. * Format the given number to a specific decimal format
  44978. * @param value defines the number to format
  44979. * @param decimals defines the number of decimals to use
  44980. * @returns the formatted string
  44981. */
  44982. static Format(value: number, decimals?: number): string;
  44983. /**
  44984. * Tries to copy an object by duplicating every property
  44985. * @param source defines the source object
  44986. * @param destination defines the target object
  44987. * @param doNotCopyList defines a list of properties to avoid
  44988. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  44989. */
  44990. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  44991. /**
  44992. * Gets a boolean indicating if the given object has no own property
  44993. * @param obj defines the object to test
  44994. * @returns true if object has no own property
  44995. */
  44996. static IsEmpty(obj: any): boolean;
  44997. /**
  44998. * Function used to register events at window level
  44999. * @param windowElement defines the Window object to use
  45000. * @param events defines the events to register
  45001. */
  45002. static RegisterTopRootEvents(windowElement: Window, events: {
  45003. name: string;
  45004. handler: Nullable<(e: FocusEvent) => any>;
  45005. }[]): void;
  45006. /**
  45007. * Function used to unregister events from window level
  45008. * @param windowElement defines the Window object to use
  45009. * @param events defines the events to unregister
  45010. */
  45011. static UnregisterTopRootEvents(windowElement: Window, events: {
  45012. name: string;
  45013. handler: Nullable<(e: FocusEvent) => any>;
  45014. }[]): void;
  45015. /**
  45016. * @ignore
  45017. */
  45018. static _ScreenshotCanvas: HTMLCanvasElement;
  45019. /**
  45020. * Dumps the current bound framebuffer
  45021. * @param width defines the rendering width
  45022. * @param height defines the rendering height
  45023. * @param engine defines the hosting engine
  45024. * @param successCallback defines the callback triggered once the data are available
  45025. * @param mimeType defines the mime type of the result
  45026. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  45027. * @return a void promise
  45028. */
  45029. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  45030. /**
  45031. * Dumps an array buffer
  45032. * @param width defines the rendering width
  45033. * @param height defines the rendering height
  45034. * @param data the data array
  45035. * @param successCallback defines the callback triggered once the data are available
  45036. * @param mimeType defines the mime type of the result
  45037. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  45038. * @param invertY true to invert the picture in the Y dimension
  45039. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  45040. */
  45041. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  45042. /**
  45043. * Dumps an array buffer
  45044. * @param width defines the rendering width
  45045. * @param height defines the rendering height
  45046. * @param data the data array
  45047. * @param successCallback defines the callback triggered once the data are available
  45048. * @param mimeType defines the mime type of the result
  45049. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  45050. * @param invertY true to invert the picture in the Y dimension
  45051. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  45052. * @return a promise that resolve to the final data
  45053. */
  45054. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45055. /**
  45056. * Converts the canvas data to blob.
  45057. * This acts as a polyfill for browsers not supporting the to blob function.
  45058. * @param canvas Defines the canvas to extract the data from
  45059. * @param successCallback Defines the callback triggered once the data are available
  45060. * @param mimeType Defines the mime type of the result
  45061. */
  45062. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  45063. /**
  45064. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  45065. * @param successCallback defines the callback triggered once the data are available
  45066. * @param mimeType defines the mime type of the result
  45067. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  45068. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  45069. */
  45070. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  45071. /**
  45072. * Downloads a blob in the browser
  45073. * @param blob defines the blob to download
  45074. * @param fileName defines the name of the downloaded file
  45075. */
  45076. static Download(blob: Blob, fileName: string): void;
  45077. /**
  45078. * Will return the right value of the noPreventDefault variable
  45079. * Needed to keep backwards compatibility to the old API.
  45080. *
  45081. * @param args arguments passed to the attachControl function
  45082. * @returns the correct value for noPreventDefault
  45083. */
  45084. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  45085. /**
  45086. * Captures a screenshot of the current rendering
  45087. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  45088. * @param engine defines the rendering engine
  45089. * @param camera defines the source camera
  45090. * @param size This parameter can be set to a single number or to an object with the
  45091. * following (optional) properties: precision, width, height. If a single number is passed,
  45092. * it will be used for both width and height. If an object is passed, the screenshot size
  45093. * will be derived from the parameters. The precision property is a multiplier allowing
  45094. * rendering at a higher or lower resolution
  45095. * @param successCallback defines the callback receives a single parameter which contains the
  45096. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  45097. * src parameter of an <img> to display it
  45098. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  45099. * Check your browser for supported MIME types
  45100. */
  45101. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  45102. /**
  45103. * Captures a screenshot of the current rendering
  45104. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  45105. * @param engine defines the rendering engine
  45106. * @param camera defines the source camera
  45107. * @param size This parameter can be set to a single number or to an object with the
  45108. * following (optional) properties: precision, width, height. If a single number is passed,
  45109. * it will be used for both width and height. If an object is passed, the screenshot size
  45110. * will be derived from the parameters. The precision property is a multiplier allowing
  45111. * rendering at a higher or lower resolution
  45112. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  45113. * Check your browser for supported MIME types
  45114. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  45115. * to the src parameter of an <img> to display it
  45116. */
  45117. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  45118. /**
  45119. * Generates an image screenshot from the specified camera.
  45120. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  45121. * @param engine The engine to use for rendering
  45122. * @param camera The camera to use for rendering
  45123. * @param size This parameter can be set to a single number or to an object with the
  45124. * following (optional) properties: precision, width, height. If a single number is passed,
  45125. * it will be used for both width and height. If an object is passed, the screenshot size
  45126. * will be derived from the parameters. The precision property is a multiplier allowing
  45127. * rendering at a higher or lower resolution
  45128. * @param successCallback The callback receives a single parameter which contains the
  45129. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  45130. * src parameter of an <img> to display it
  45131. * @param mimeType The MIME type of the screenshot image (default: image/png).
  45132. * Check your browser for supported MIME types
  45133. * @param samples Texture samples (default: 1)
  45134. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  45135. * @param fileName A name for for the downloaded file.
  45136. */
  45137. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  45138. /**
  45139. * Generates an image screenshot from the specified camera.
  45140. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  45141. * @param engine The engine to use for rendering
  45142. * @param camera The camera to use for rendering
  45143. * @param size This parameter can be set to a single number or to an object with the
  45144. * following (optional) properties: precision, width, height. If a single number is passed,
  45145. * it will be used for both width and height. If an object is passed, the screenshot size
  45146. * will be derived from the parameters. The precision property is a multiplier allowing
  45147. * rendering at a higher or lower resolution
  45148. * @param mimeType The MIME type of the screenshot image (default: image/png).
  45149. * Check your browser for supported MIME types
  45150. * @param samples Texture samples (default: 1)
  45151. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  45152. * @param fileName A name for for the downloaded file.
  45153. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  45154. * to the src parameter of an <img> to display it
  45155. */
  45156. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  45157. /**
  45158. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  45159. * Be aware Math.random() could cause collisions, but:
  45160. * "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"
  45161. * @returns a pseudo random id
  45162. */
  45163. static RandomId(): string;
  45164. /**
  45165. * Test if the given uri is a base64 string
  45166. * @param uri The uri to test
  45167. * @return True if the uri is a base64 string or false otherwise
  45168. */
  45169. static IsBase64(uri: string): boolean;
  45170. /**
  45171. * Decode the given base64 uri.
  45172. * @param uri The uri to decode
  45173. * @return The decoded base64 data.
  45174. */
  45175. static DecodeBase64(uri: string): ArrayBuffer;
  45176. /**
  45177. * Gets the absolute url.
  45178. * @param url the input url
  45179. * @return the absolute url
  45180. */
  45181. static GetAbsoluteUrl(url: string): string;
  45182. /**
  45183. * No log
  45184. */
  45185. static readonly NoneLogLevel: number;
  45186. /**
  45187. * Only message logs
  45188. */
  45189. static readonly MessageLogLevel: number;
  45190. /**
  45191. * Only warning logs
  45192. */
  45193. static readonly WarningLogLevel: number;
  45194. /**
  45195. * Only error logs
  45196. */
  45197. static readonly ErrorLogLevel: number;
  45198. /**
  45199. * All logs
  45200. */
  45201. static readonly AllLogLevel: number;
  45202. /**
  45203. * Gets a value indicating the number of loading errors
  45204. * @ignorenaming
  45205. */
  45206. static get errorsCount(): number;
  45207. /**
  45208. * Callback called when a new log is added
  45209. */
  45210. static OnNewCacheEntry: (entry: string) => void;
  45211. /**
  45212. * Log a message to the console
  45213. * @param message defines the message to log
  45214. */
  45215. static Log(message: string): void;
  45216. /**
  45217. * Write a warning message to the console
  45218. * @param message defines the message to log
  45219. */
  45220. static Warn(message: string): void;
  45221. /**
  45222. * Write an error message to the console
  45223. * @param message defines the message to log
  45224. */
  45225. static Error(message: string): void;
  45226. /**
  45227. * Gets current log cache (list of logs)
  45228. */
  45229. static get LogCache(): string;
  45230. /**
  45231. * Clears the log cache
  45232. */
  45233. static ClearLogCache(): void;
  45234. /**
  45235. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  45236. */
  45237. static set LogLevels(level: number);
  45238. /**
  45239. * Checks if the window object exists
  45240. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  45241. */
  45242. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  45243. /**
  45244. * No performance log
  45245. */
  45246. static readonly PerformanceNoneLogLevel: number;
  45247. /**
  45248. * Use user marks to log performance
  45249. */
  45250. static readonly PerformanceUserMarkLogLevel: number;
  45251. /**
  45252. * Log performance to the console
  45253. */
  45254. static readonly PerformanceConsoleLogLevel: number;
  45255. private static _performance;
  45256. /**
  45257. * Sets the current performance log level
  45258. */
  45259. static set PerformanceLogLevel(level: number);
  45260. private static _StartPerformanceCounterDisabled;
  45261. private static _EndPerformanceCounterDisabled;
  45262. private static _StartUserMark;
  45263. private static _EndUserMark;
  45264. private static _StartPerformanceConsole;
  45265. private static _EndPerformanceConsole;
  45266. /**
  45267. * Starts a performance counter
  45268. */
  45269. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  45270. /**
  45271. * Ends a specific performance counter
  45272. */
  45273. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  45274. /**
  45275. * Gets either window.performance.now() if supported or Date.now() else
  45276. */
  45277. static get Now(): number;
  45278. /**
  45279. * This method will return the name of the class used to create the instance of the given object.
  45280. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  45281. * @param object the object to get the class name from
  45282. * @param isType defines if the object is actually a type
  45283. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  45284. */
  45285. static GetClassName(object: any, isType?: boolean): string;
  45286. /**
  45287. * Gets the first element of an array satisfying a given predicate
  45288. * @param array defines the array to browse
  45289. * @param predicate defines the predicate to use
  45290. * @returns null if not found or the element
  45291. */
  45292. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  45293. /**
  45294. * This method will return the name of the full name of the class, including its owning module (if any).
  45295. * 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).
  45296. * @param object the object to get the class name from
  45297. * @param isType defines if the object is actually a type
  45298. * @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.
  45299. * @ignorenaming
  45300. */
  45301. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  45302. /**
  45303. * Returns a promise that resolves after the given amount of time.
  45304. * @param delay Number of milliseconds to delay
  45305. * @returns Promise that resolves after the given amount of time
  45306. */
  45307. static DelayAsync(delay: number): Promise<void>;
  45308. /**
  45309. * Utility function to detect if the current user agent is Safari
  45310. * @returns whether or not the current user agent is safari
  45311. */
  45312. static IsSafari(): boolean;
  45313. }
  45314. /**
  45315. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  45316. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  45317. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  45318. * @param name The name of the class, case should be preserved
  45319. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  45320. */
  45321. export function className(name: string, module?: string): (target: Object) => void;
  45322. /**
  45323. * An implementation of a loop for asynchronous functions.
  45324. */
  45325. export class AsyncLoop {
  45326. /**
  45327. * Defines the number of iterations for the loop
  45328. */
  45329. iterations: number;
  45330. /**
  45331. * Defines the current index of the loop.
  45332. */
  45333. index: number;
  45334. private _done;
  45335. private _fn;
  45336. private _successCallback;
  45337. /**
  45338. * Constructor.
  45339. * @param iterations the number of iterations.
  45340. * @param func the function to run each iteration
  45341. * @param successCallback the callback that will be called upon successful execution
  45342. * @param offset starting offset.
  45343. */
  45344. constructor(
  45345. /**
  45346. * Defines the number of iterations for the loop
  45347. */
  45348. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  45349. /**
  45350. * Execute the next iteration. Must be called after the last iteration was finished.
  45351. */
  45352. executeNext(): void;
  45353. /**
  45354. * Break the loop and run the success callback.
  45355. */
  45356. breakLoop(): void;
  45357. /**
  45358. * Create and run an async loop.
  45359. * @param iterations the number of iterations.
  45360. * @param fn the function to run each iteration
  45361. * @param successCallback the callback that will be called upon successful execution
  45362. * @param offset starting offset.
  45363. * @returns the created async loop object
  45364. */
  45365. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  45366. /**
  45367. * A for-loop that will run a given number of iterations synchronous and the rest async.
  45368. * @param iterations total number of iterations
  45369. * @param syncedIterations number of synchronous iterations in each async iteration.
  45370. * @param fn the function to call each iteration.
  45371. * @param callback a success call back that will be called when iterating stops.
  45372. * @param breakFunction a break condition (optional)
  45373. * @param timeout timeout settings for the setTimeout function. default - 0.
  45374. * @returns the created async loop object
  45375. */
  45376. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  45377. }
  45378. }
  45379. declare module "babylonjs/Misc/stringDictionary" {
  45380. import { Nullable } from "babylonjs/types";
  45381. /**
  45382. * This class implement a typical dictionary using a string as key and the generic type T as value.
  45383. * The underlying implementation relies on an associative array to ensure the best performances.
  45384. * The value can be anything including 'null' but except 'undefined'
  45385. */
  45386. export class StringDictionary<T> {
  45387. /**
  45388. * This will clear this dictionary and copy the content from the 'source' one.
  45389. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  45390. * @param source the dictionary to take the content from and copy to this dictionary
  45391. */
  45392. copyFrom(source: StringDictionary<T>): void;
  45393. /**
  45394. * Get a value based from its key
  45395. * @param key the given key to get the matching value from
  45396. * @return the value if found, otherwise undefined is returned
  45397. */
  45398. get(key: string): T | undefined;
  45399. /**
  45400. * Get a value from its key or add it if it doesn't exist.
  45401. * This method will ensure you that a given key/data will be present in the dictionary.
  45402. * @param key the given key to get the matching value from
  45403. * @param factory the factory that will create the value if the key is not present in the dictionary.
  45404. * The factory will only be invoked if there's no data for the given key.
  45405. * @return the value corresponding to the key.
  45406. */
  45407. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  45408. /**
  45409. * Get a value from its key if present in the dictionary otherwise add it
  45410. * @param key the key to get the value from
  45411. * @param val if there's no such key/value pair in the dictionary add it with this value
  45412. * @return the value corresponding to the key
  45413. */
  45414. getOrAdd(key: string, val: T): T;
  45415. /**
  45416. * Check if there's a given key in the dictionary
  45417. * @param key the key to check for
  45418. * @return true if the key is present, false otherwise
  45419. */
  45420. contains(key: string): boolean;
  45421. /**
  45422. * Add a new key and its corresponding value
  45423. * @param key the key to add
  45424. * @param value the value corresponding to the key
  45425. * @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
  45426. */
  45427. add(key: string, value: T): boolean;
  45428. /**
  45429. * Update a specific value associated to a key
  45430. * @param key defines the key to use
  45431. * @param value defines the value to store
  45432. * @returns true if the value was updated (or false if the key was not found)
  45433. */
  45434. set(key: string, value: T): boolean;
  45435. /**
  45436. * Get the element of the given key and remove it from the dictionary
  45437. * @param key defines the key to search
  45438. * @returns the value associated with the key or null if not found
  45439. */
  45440. getAndRemove(key: string): Nullable<T>;
  45441. /**
  45442. * Remove a key/value from the dictionary.
  45443. * @param key the key to remove
  45444. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  45445. */
  45446. remove(key: string): boolean;
  45447. /**
  45448. * Clear the whole content of the dictionary
  45449. */
  45450. clear(): void;
  45451. /**
  45452. * Gets the current count
  45453. */
  45454. get count(): number;
  45455. /**
  45456. * Execute a callback on each key/val of the dictionary.
  45457. * Note that you can remove any element in this dictionary in the callback implementation
  45458. * @param callback the callback to execute on a given key/value pair
  45459. */
  45460. forEach(callback: (key: string, val: T) => void): void;
  45461. /**
  45462. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  45463. * If the callback returns null or undefined the method will iterate to the next key/value pair
  45464. * Note that you can remove any element in this dictionary in the callback implementation
  45465. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  45466. * @returns the first item
  45467. */
  45468. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  45469. private _count;
  45470. private _data;
  45471. }
  45472. }
  45473. declare module "babylonjs/Collisions/collisionCoordinator" {
  45474. import { Nullable } from "babylonjs/types";
  45475. import { Scene } from "babylonjs/scene";
  45476. import { Vector3 } from "babylonjs/Maths/math.vector";
  45477. import { Collider } from "babylonjs/Collisions/collider";
  45478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45479. /** @hidden */
  45480. export interface ICollisionCoordinator {
  45481. createCollider(): Collider;
  45482. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45483. init(scene: Scene): void;
  45484. }
  45485. /** @hidden */
  45486. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  45487. private _scene;
  45488. private _scaledPosition;
  45489. private _scaledVelocity;
  45490. private _finalPosition;
  45491. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45492. createCollider(): Collider;
  45493. init(scene: Scene): void;
  45494. private _collideWithWorld;
  45495. }
  45496. }
  45497. declare module "babylonjs/Inputs/scene.inputManager" {
  45498. import { Nullable } from "babylonjs/types";
  45499. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45500. import { Vector2 } from "babylonjs/Maths/math.vector";
  45501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45502. import { Scene } from "babylonjs/scene";
  45503. /**
  45504. * Class used to manage all inputs for the scene.
  45505. */
  45506. export class InputManager {
  45507. /** The distance in pixel that you have to move to prevent some events */
  45508. static DragMovementThreshold: number;
  45509. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  45510. static LongPressDelay: number;
  45511. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  45512. static DoubleClickDelay: number;
  45513. /** If you need to check double click without raising a single click at first click, enable this flag */
  45514. static ExclusiveDoubleClickMode: boolean;
  45515. /** 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. */
  45516. private _alreadyAttached;
  45517. private _alreadyAttachedTo;
  45518. private _wheelEventName;
  45519. private _onPointerMove;
  45520. private _onPointerDown;
  45521. private _onPointerUp;
  45522. private _initClickEvent;
  45523. private _initActionManager;
  45524. private _delayedSimpleClick;
  45525. private _delayedSimpleClickTimeout;
  45526. private _previousDelayedSimpleClickTimeout;
  45527. private _meshPickProceed;
  45528. private _previousButtonPressed;
  45529. private _currentPickResult;
  45530. private _previousPickResult;
  45531. private _totalPointersPressed;
  45532. private _doubleClickOccured;
  45533. private _pointerOverMesh;
  45534. private _pickedDownMesh;
  45535. private _pickedUpMesh;
  45536. private _pointerX;
  45537. private _pointerY;
  45538. private _unTranslatedPointerX;
  45539. private _unTranslatedPointerY;
  45540. private _startingPointerPosition;
  45541. private _previousStartingPointerPosition;
  45542. private _startingPointerTime;
  45543. private _previousStartingPointerTime;
  45544. private _pointerCaptures;
  45545. private _meshUnderPointerId;
  45546. private _onKeyDown;
  45547. private _onKeyUp;
  45548. private _keyboardIsAttached;
  45549. private _onCanvasFocusObserver;
  45550. private _onCanvasBlurObserver;
  45551. private _scene;
  45552. /**
  45553. * Creates a new InputManager
  45554. * @param scene defines the hosting scene
  45555. */
  45556. constructor(scene: Scene);
  45557. /**
  45558. * Gets the mesh that is currently under the pointer
  45559. */
  45560. get meshUnderPointer(): Nullable<AbstractMesh>;
  45561. /**
  45562. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  45563. * @param pointerId the pointer id to use
  45564. * @returns The mesh under this pointer id or null if not found
  45565. */
  45566. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  45567. /**
  45568. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  45569. */
  45570. get unTranslatedPointer(): Vector2;
  45571. /**
  45572. * Gets or sets the current on-screen X position of the pointer
  45573. */
  45574. get pointerX(): number;
  45575. set pointerX(value: number);
  45576. /**
  45577. * Gets or sets the current on-screen Y position of the pointer
  45578. */
  45579. get pointerY(): number;
  45580. set pointerY(value: number);
  45581. private _updatePointerPosition;
  45582. private _processPointerMove;
  45583. private _setRayOnPointerInfo;
  45584. private _checkPrePointerObservable;
  45585. /**
  45586. * Use this method to simulate a pointer move on a mesh
  45587. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45588. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45589. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45590. */
  45591. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45592. /**
  45593. * Use this method to simulate a pointer down on a mesh
  45594. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45595. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45596. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45597. */
  45598. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45599. private _processPointerDown;
  45600. /** @hidden */
  45601. _isPointerSwiping(): boolean;
  45602. /**
  45603. * Use this method to simulate a pointer up on a mesh
  45604. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45605. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45606. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45607. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45608. */
  45609. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  45610. private _processPointerUp;
  45611. /**
  45612. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45613. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45614. * @returns true if the pointer was captured
  45615. */
  45616. isPointerCaptured(pointerId?: number): boolean;
  45617. /**
  45618. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45619. * @param attachUp defines if you want to attach events to pointerup
  45620. * @param attachDown defines if you want to attach events to pointerdown
  45621. * @param attachMove defines if you want to attach events to pointermove
  45622. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  45623. */
  45624. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  45625. /**
  45626. * Detaches all event handlers
  45627. */
  45628. detachControl(): void;
  45629. /**
  45630. * Force the value of meshUnderPointer
  45631. * @param mesh defines the mesh to use
  45632. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  45633. */
  45634. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45635. /**
  45636. * Gets the mesh under the pointer
  45637. * @returns a Mesh or null if no mesh is under the pointer
  45638. */
  45639. getPointerOverMesh(): Nullable<AbstractMesh>;
  45640. }
  45641. }
  45642. declare module "babylonjs/Animations/animationGroup" {
  45643. import { Animatable } from "babylonjs/Animations/animatable";
  45644. import { Animation } from "babylonjs/Animations/animation";
  45645. import { Scene, IDisposable } from "babylonjs/scene";
  45646. import { Observable } from "babylonjs/Misc/observable";
  45647. import { Nullable } from "babylonjs/types";
  45648. import "babylonjs/Animations/animatable";
  45649. /**
  45650. * This class defines the direct association between an animation and a target
  45651. */
  45652. export class TargetedAnimation {
  45653. /**
  45654. * Animation to perform
  45655. */
  45656. animation: Animation;
  45657. /**
  45658. * Target to animate
  45659. */
  45660. target: any;
  45661. /**
  45662. * Returns the string "TargetedAnimation"
  45663. * @returns "TargetedAnimation"
  45664. */
  45665. getClassName(): string;
  45666. /**
  45667. * Serialize the object
  45668. * @returns the JSON object representing the current entity
  45669. */
  45670. serialize(): any;
  45671. }
  45672. /**
  45673. * Use this class to create coordinated animations on multiple targets
  45674. */
  45675. export class AnimationGroup implements IDisposable {
  45676. /** The name of the animation group */
  45677. name: string;
  45678. private _scene;
  45679. private _targetedAnimations;
  45680. private _animatables;
  45681. private _from;
  45682. private _to;
  45683. private _isStarted;
  45684. private _isPaused;
  45685. private _speedRatio;
  45686. private _loopAnimation;
  45687. private _isAdditive;
  45688. /**
  45689. * Gets or sets the unique id of the node
  45690. */
  45691. uniqueId: number;
  45692. /**
  45693. * This observable will notify when one animation have ended
  45694. */
  45695. onAnimationEndObservable: Observable<TargetedAnimation>;
  45696. /**
  45697. * Observer raised when one animation loops
  45698. */
  45699. onAnimationLoopObservable: Observable<TargetedAnimation>;
  45700. /**
  45701. * Observer raised when all animations have looped
  45702. */
  45703. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  45704. /**
  45705. * This observable will notify when all animations have ended.
  45706. */
  45707. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  45708. /**
  45709. * This observable will notify when all animations have paused.
  45710. */
  45711. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  45712. /**
  45713. * This observable will notify when all animations are playing.
  45714. */
  45715. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  45716. /**
  45717. * Gets the first frame
  45718. */
  45719. get from(): number;
  45720. /**
  45721. * Gets the last frame
  45722. */
  45723. get to(): number;
  45724. /**
  45725. * Define if the animations are started
  45726. */
  45727. get isStarted(): boolean;
  45728. /**
  45729. * Gets a value indicating that the current group is playing
  45730. */
  45731. get isPlaying(): boolean;
  45732. /**
  45733. * Gets or sets the speed ratio to use for all animations
  45734. */
  45735. get speedRatio(): number;
  45736. /**
  45737. * Gets or sets the speed ratio to use for all animations
  45738. */
  45739. set speedRatio(value: number);
  45740. /**
  45741. * Gets or sets if all animations should loop or not
  45742. */
  45743. get loopAnimation(): boolean;
  45744. set loopAnimation(value: boolean);
  45745. /**
  45746. * Gets or sets if all animations should be evaluated additively
  45747. */
  45748. get isAdditive(): boolean;
  45749. set isAdditive(value: boolean);
  45750. /**
  45751. * Gets the targeted animations for this animation group
  45752. */
  45753. get targetedAnimations(): Array<TargetedAnimation>;
  45754. /**
  45755. * returning the list of animatables controlled by this animation group.
  45756. */
  45757. get animatables(): Array<Animatable>;
  45758. /**
  45759. * Gets the list of target animations
  45760. */
  45761. get children(): TargetedAnimation[];
  45762. /**
  45763. * Instantiates a new Animation Group.
  45764. * This helps managing several animations at once.
  45765. * @see https://doc.babylonjs.com/how_to/group
  45766. * @param name Defines the name of the group
  45767. * @param scene Defines the scene the group belongs to
  45768. */
  45769. constructor(
  45770. /** The name of the animation group */
  45771. name: string, scene?: Nullable<Scene>);
  45772. /**
  45773. * Add an animation (with its target) in the group
  45774. * @param animation defines the animation we want to add
  45775. * @param target defines the target of the animation
  45776. * @returns the TargetedAnimation object
  45777. */
  45778. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  45779. /**
  45780. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  45781. * It can add constant keys at begin or end
  45782. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  45783. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  45784. * @returns the animation group
  45785. */
  45786. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  45787. private _animationLoopCount;
  45788. private _animationLoopFlags;
  45789. private _processLoop;
  45790. /**
  45791. * Start all animations on given targets
  45792. * @param loop defines if animations must loop
  45793. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  45794. * @param from defines the from key (optional)
  45795. * @param to defines the to key (optional)
  45796. * @param isAdditive defines the additive state for the resulting animatables (optional)
  45797. * @returns the current animation group
  45798. */
  45799. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  45800. /**
  45801. * Pause all animations
  45802. * @returns the animation group
  45803. */
  45804. pause(): AnimationGroup;
  45805. /**
  45806. * Play all animations to initial state
  45807. * This function will start() the animations if they were not started or will restart() them if they were paused
  45808. * @param loop defines if animations must loop
  45809. * @returns the animation group
  45810. */
  45811. play(loop?: boolean): AnimationGroup;
  45812. /**
  45813. * Reset all animations to initial state
  45814. * @returns the animation group
  45815. */
  45816. reset(): AnimationGroup;
  45817. /**
  45818. * Restart animations from key 0
  45819. * @returns the animation group
  45820. */
  45821. restart(): AnimationGroup;
  45822. /**
  45823. * Stop all animations
  45824. * @returns the animation group
  45825. */
  45826. stop(): AnimationGroup;
  45827. /**
  45828. * Set animation weight for all animatables
  45829. * @param weight defines the weight to use
  45830. * @return the animationGroup
  45831. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45832. */
  45833. setWeightForAllAnimatables(weight: number): AnimationGroup;
  45834. /**
  45835. * Synchronize and normalize all animatables with a source animatable
  45836. * @param root defines the root animatable to synchronize with
  45837. * @return the animationGroup
  45838. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45839. */
  45840. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  45841. /**
  45842. * Goes to a specific frame in this animation group
  45843. * @param frame the frame number to go to
  45844. * @return the animationGroup
  45845. */
  45846. goToFrame(frame: number): AnimationGroup;
  45847. /**
  45848. * Dispose all associated resources
  45849. */
  45850. dispose(): void;
  45851. private _checkAnimationGroupEnded;
  45852. /**
  45853. * Clone the current animation group and returns a copy
  45854. * @param newName defines the name of the new group
  45855. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  45856. * @returns the new animation group
  45857. */
  45858. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  45859. /**
  45860. * Serializes the animationGroup to an object
  45861. * @returns Serialized object
  45862. */
  45863. serialize(): any;
  45864. /**
  45865. * Returns a new AnimationGroup object parsed from the source provided.
  45866. * @param parsedAnimationGroup defines the source
  45867. * @param scene defines the scene that will receive the animationGroup
  45868. * @returns a new AnimationGroup
  45869. */
  45870. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  45871. /**
  45872. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  45873. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  45874. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  45875. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  45876. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  45877. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  45878. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  45879. */
  45880. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  45881. /**
  45882. * Returns the string "AnimationGroup"
  45883. * @returns "AnimationGroup"
  45884. */
  45885. getClassName(): string;
  45886. /**
  45887. * Creates a detailed string about the object
  45888. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  45889. * @returns a string representing the object
  45890. */
  45891. toString(fullDetails?: boolean): string;
  45892. }
  45893. }
  45894. declare module "babylonjs/Instrumentation/timeToken" {
  45895. import { Nullable } from "babylonjs/types";
  45896. /**
  45897. * @hidden
  45898. **/
  45899. export class _TimeToken {
  45900. _startTimeQuery: Nullable<WebGLQuery>;
  45901. _endTimeQuery: Nullable<WebGLQuery>;
  45902. _timeElapsedQuery: Nullable<WebGLQuery>;
  45903. _timeElapsedQueryEnded: boolean;
  45904. }
  45905. }
  45906. declare module "babylonjs/Engines/WebGPU/webgpuConstants" {
  45907. /** @hidden */
  45908. export enum ExtensionName {
  45909. DepthClamping = "depth-clamping",
  45910. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45911. Depth32FloatStencil8 = "depth32float-stencil8",
  45912. PipelineStatisticsQuery = "pipeline-statistics-query",
  45913. TextureCompressionBC = "texture-compression-bc",
  45914. TimestampQuery = "timestamp-query"
  45915. }
  45916. /** @hidden */
  45917. export enum AddressMode {
  45918. ClampToEdge = "clamp-to-edge",
  45919. Repeat = "repeat",
  45920. MirrorRepeat = "mirror-repeat"
  45921. }
  45922. /** @hidden */
  45923. export enum BindingType {
  45924. UniformBuffer = "uniform-buffer",
  45925. StorageBuffer = "storage-buffer",
  45926. ReadonlyStorageBuffer = "readonly-storage-buffer",
  45927. Sampler = "sampler",
  45928. ComparisonSampler = "comparison-sampler",
  45929. SampledTexture = "sampled-texture",
  45930. ReadonlyStorageTexture = "readonly-storage-texture",
  45931. WriteonlyStorageTexture = "writeonly-storage-texture"
  45932. }
  45933. /** @hidden */
  45934. export enum BlendFactor {
  45935. Zero = "zero",
  45936. One = "one",
  45937. SrcColor = "src-color",
  45938. OneMinusSrcColor = "one-minus-src-color",
  45939. SrcAlpha = "src-alpha",
  45940. OneMinusSrcAlpha = "one-minus-src-alpha",
  45941. DstColor = "dst-color",
  45942. OneMinusDstColor = "one-minus-dst-color",
  45943. DstAlpha = "dst-alpha",
  45944. OneMinusDstAlpha = "one-minus-dst-alpha",
  45945. SrcAlphaSaturated = "src-alpha-saturated",
  45946. BlendColor = "blend-color",
  45947. OneMinusBlendColor = "one-minus-blend-color"
  45948. }
  45949. /** @hidden */
  45950. export enum BlendOperation {
  45951. Add = "add",
  45952. Subtract = "subtract",
  45953. ReverseSubtract = "reverse-subtract",
  45954. Min = "min",
  45955. Max = "max"
  45956. }
  45957. /** @hidden */
  45958. export enum CompareFunction {
  45959. Never = "never",
  45960. Less = "less",
  45961. Equal = "equal",
  45962. LessEqual = "less-equal",
  45963. Greater = "greater",
  45964. NotEqual = "not-equal",
  45965. GreaterEqual = "greater-equal",
  45966. Always = "always"
  45967. }
  45968. /** @hidden */
  45969. export enum CullMode {
  45970. None = "none",
  45971. Front = "front",
  45972. Back = "back"
  45973. }
  45974. /** @hidden */
  45975. export enum FilterMode {
  45976. Nearest = "nearest",
  45977. Linear = "linear"
  45978. }
  45979. /** @hidden */
  45980. export enum FrontFace {
  45981. CCW = "ccw",
  45982. CW = "cw"
  45983. }
  45984. /** @hidden */
  45985. export enum IndexFormat {
  45986. Uint16 = "uint16",
  45987. Uint32 = "uint32"
  45988. }
  45989. /** @hidden */
  45990. export enum InputStepMode {
  45991. Vertex = "vertex",
  45992. Instance = "instance"
  45993. }
  45994. /** @hidden */
  45995. export enum LoadOp {
  45996. Load = "load"
  45997. }
  45998. /** @hidden */
  45999. export enum PrimitiveTopology {
  46000. PointList = "point-list",
  46001. LineList = "line-list",
  46002. LineStrip = "line-strip",
  46003. TriangleList = "triangle-list",
  46004. TriangleStrip = "triangle-strip"
  46005. }
  46006. /** @hidden */
  46007. export enum StencilOperation {
  46008. Keep = "keep",
  46009. Zero = "zero",
  46010. Replace = "replace",
  46011. Invert = "invert",
  46012. IncrementClamp = "increment-clamp",
  46013. DecrementClamp = "decrement-clamp",
  46014. IncrementWrap = "increment-wrap",
  46015. DecrementWrap = "decrement-wrap"
  46016. }
  46017. /** @hidden */
  46018. export enum StoreOp {
  46019. Store = "store",
  46020. Clear = "clear"
  46021. }
  46022. /** @hidden */
  46023. export enum TextureDimension {
  46024. E1d = "1d",
  46025. E2d = "2d",
  46026. E3d = "3d"
  46027. }
  46028. /** @hidden */
  46029. export enum TextureFormat {
  46030. R8Unorm = "r8unorm",
  46031. R8Snorm = "r8snorm",
  46032. R8Uint = "r8uint",
  46033. R8Sint = "r8sint",
  46034. R16Uint = "r16uint",
  46035. R16Sint = "r16sint",
  46036. R16Float = "r16float",
  46037. RG8Unorm = "rg8unorm",
  46038. RG8Snorm = "rg8snorm",
  46039. RG8Uint = "rg8uint",
  46040. RG8Sint = "rg8sint",
  46041. R32Uint = "r32uint",
  46042. R32Sint = "r32sint",
  46043. R32Float = "r32float",
  46044. RG16Uint = "rg16uint",
  46045. RG16Sint = "rg16sint",
  46046. RG16Float = "rg16float",
  46047. RGBA8Unorm = "rgba8unorm",
  46048. RGBA8UnormSRGB = "rgba8unorm-srgb",
  46049. RGBA8Snorm = "rgba8snorm",
  46050. RGBA8Uint = "rgba8uint",
  46051. RGBA8Sint = "rgba8sint",
  46052. BGRA8Unorm = "bgra8unorm",
  46053. BGRA8UnormSRGB = "bgra8unorm-srgb",
  46054. RGB9E5UFloat = "rgb9e5ufloat",
  46055. RGB10A2Unorm = "rgb10a2unorm",
  46056. RG11B10UFloat = "rg11b10ufloat",
  46057. RG32Uint = "rg32uint",
  46058. RG32Sint = "rg32sint",
  46059. RG32Float = "rg32float",
  46060. RGBA16Uint = "rgba16uint",
  46061. RGBA16Sint = "rgba16sint",
  46062. RGBA16Float = "rgba16float",
  46063. RGBA32Uint = "rgba32uint",
  46064. RGBA32Sint = "rgba32sint",
  46065. RGBA32Float = "rgba32float",
  46066. Stencil8 = "stencil8",
  46067. Depth16Unorm = "depth16unorm",
  46068. Depth24Plus = "depth24plus",
  46069. Depth24PlusStencil8 = "depth24plus-stencil8",
  46070. Depth32Float = "depth32float",
  46071. BC1RGBAUNorm = "bc1-rgba-unorm",
  46072. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  46073. BC2RGBAUnorm = "bc2-rgba-unorm",
  46074. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  46075. BC3RGBAUnorm = "bc3-rgba-unorm",
  46076. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  46077. BC4RUnorm = "bc4-r-unorm",
  46078. BC4RSnorm = "bc4-r-snorm",
  46079. BC5RGUnorm = "bc5-rg-unorm",
  46080. BC5RGSnorm = "bc5-rg-snorm",
  46081. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  46082. BC6HRGBFloat = "bc6h-rgb-float",
  46083. BC7RGBAUnorm = "bc7-rgba-unorm",
  46084. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  46085. Depth24UnormStencil8 = "depth24unorm-stencil8",
  46086. Depth32FloatStencil8 = "depth32float-stencil8"
  46087. }
  46088. /** @hidden */
  46089. export enum TextureComponentType {
  46090. Float = "float",
  46091. Sint = "sint",
  46092. Uint = "uint",
  46093. DepthComparison = "depth-comparison"
  46094. }
  46095. /** @hidden */
  46096. export enum TextureViewDimension {
  46097. E1d = "1d",
  46098. E2d = "2d",
  46099. E2dArray = "2d-array",
  46100. Cube = "cube",
  46101. CubeArray = "cube-array",
  46102. E3d = "3d"
  46103. }
  46104. /** @hidden */
  46105. export enum VertexFormat {
  46106. Uchar2 = "uchar2",
  46107. Uchar4 = "uchar4",
  46108. Char2 = "char2",
  46109. Char4 = "char4",
  46110. Uchar2Norm = "uchar2norm",
  46111. Uchar4Norm = "uchar4norm",
  46112. Char2Norm = "char2norm",
  46113. Char4Norm = "char4norm",
  46114. Ushort2 = "ushort2",
  46115. Ushort4 = "ushort4",
  46116. Short2 = "short2",
  46117. Short4 = "short4",
  46118. Ushort2Norm = "ushort2norm",
  46119. Ushort4Norm = "ushort4norm",
  46120. Short2Norm = "short2norm",
  46121. Short4Norm = "short4norm",
  46122. Half2 = "half2",
  46123. Half4 = "half4",
  46124. Float = "float",
  46125. Float2 = "float2",
  46126. Float3 = "float3",
  46127. Float4 = "float4",
  46128. Uint = "uint",
  46129. Uint2 = "uint2",
  46130. Uint3 = "uint3",
  46131. Uint4 = "uint4",
  46132. Int = "int",
  46133. Int2 = "int2",
  46134. Int3 = "int3",
  46135. Int4 = "int4"
  46136. }
  46137. /** @hidden */
  46138. export enum TextureAspect {
  46139. All = "all",
  46140. StencilOnly = "stencil-only",
  46141. DepthOnly = "depth-only"
  46142. }
  46143. /** @hidden */
  46144. export enum CompilationMessageType {
  46145. Error = "error",
  46146. Warning = "warning",
  46147. Info = "info"
  46148. }
  46149. /** @hidden */
  46150. export enum QueryType {
  46151. Occlusion = "occlusion"
  46152. }
  46153. /** @hidden */
  46154. export enum BufferUsage {
  46155. MapRead = 1,
  46156. MapWrite = 2,
  46157. CopySrc = 4,
  46158. CopyDst = 8,
  46159. Index = 16,
  46160. Vertex = 32,
  46161. Uniform = 64,
  46162. Storage = 128,
  46163. Indirect = 256,
  46164. QueryResolve = 512
  46165. }
  46166. /** @hidden */
  46167. export enum ColorWrite {
  46168. Red = 1,
  46169. Green = 2,
  46170. Blue = 4,
  46171. Alpha = 8,
  46172. All = 15
  46173. }
  46174. /** @hidden */
  46175. export enum ShaderStage {
  46176. Vertex = 1,
  46177. Fragment = 2,
  46178. Compute = 4
  46179. }
  46180. /** @hidden */
  46181. export enum TextureUsage {
  46182. CopySrc = 1,
  46183. CopyDst = 2,
  46184. Sampled = 4,
  46185. Storage = 8,
  46186. OutputAttachment = 16
  46187. }
  46188. /** @hidden */
  46189. export enum MapMode {
  46190. Read = 1,
  46191. Write = 2
  46192. }
  46193. }
  46194. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext" {
  46195. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46196. /** @hidden */
  46197. export interface WebGPUBindingInfo {
  46198. setIndex: number;
  46199. bindingIndex: number;
  46200. }
  46201. /** @hidden */
  46202. export interface WebGPUTextureSamplerBindingDescription {
  46203. sampler: WebGPUBindingInfo;
  46204. isTextureArray: boolean;
  46205. textures: Array<WebGPUBindingInfo>;
  46206. }
  46207. /** @hidden
  46208. * If the binding is a UBO, isSampler=isTexture=false
  46209. */
  46210. export interface WebGPUBindingDescription {
  46211. name: string;
  46212. usedInVertex: boolean;
  46213. usedInFragment: boolean;
  46214. isSampler: boolean;
  46215. isComparisonSampler?: boolean;
  46216. isTexture: boolean;
  46217. componentType?: GPUTextureComponentType;
  46218. textureDimension?: GPUTextureViewDimension;
  46219. }
  46220. /**
  46221. * @hidden
  46222. */
  46223. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  46224. uboNextBindingIndex: number;
  46225. freeSetIndex: number;
  46226. freeBindingIndex: number;
  46227. availableVaryings: {
  46228. [key: string]: number;
  46229. };
  46230. availableAttributes: {
  46231. [key: string]: number;
  46232. };
  46233. availableUBOs: {
  46234. [key: string]: {
  46235. setIndex: number;
  46236. bindingIndex: number;
  46237. };
  46238. };
  46239. availableSamplers: {
  46240. [key: string]: WebGPUTextureSamplerBindingDescription;
  46241. };
  46242. leftOverUniforms: {
  46243. name: string;
  46244. type: string;
  46245. length: number;
  46246. }[];
  46247. orderedAttributes: string[];
  46248. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  46249. uniformBufferNames: string[];
  46250. attributeNamesFromEffect: string[];
  46251. attributeLocationsFromEffect: number[];
  46252. private _attributeNextLocation;
  46253. private _varyingNextLocation;
  46254. constructor();
  46255. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  46256. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  46257. getNextFreeUBOBinding(): {
  46258. setIndex: number;
  46259. bindingIndex: number;
  46260. };
  46261. private _getNextFreeBinding;
  46262. }
  46263. }
  46264. declare module "babylonjs/Engines/WebGPU/webgpuPipelineContext" {
  46265. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46266. import { Nullable } from "babylonjs/types";
  46267. import { WebGPUEngine } from "babylonjs/Engines/webgpuEngine";
  46268. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46269. import { Effect } from "babylonjs/Materials/effect";
  46270. import { WebGPUShaderProcessingContext } from "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext";
  46271. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46272. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  46273. /** @hidden */
  46274. export interface IWebGPUPipelineContextSamplerCache {
  46275. samplerBinding: number;
  46276. firstTextureName: string;
  46277. }
  46278. /** @hidden */
  46279. export interface IWebGPUPipelineContextTextureCache {
  46280. textureBinding: number;
  46281. texture: InternalTexture;
  46282. }
  46283. /** @hidden */
  46284. export interface IWebGPUPipelineContextVertexInputsCache {
  46285. indexBuffer: Nullable<GPUBuffer>;
  46286. indexOffset: number;
  46287. vertexStartSlot: number;
  46288. vertexBuffers: GPUBuffer[];
  46289. vertexOffsets: number[];
  46290. }
  46291. /** @hidden */
  46292. export interface IWebGPURenderPipelineStageDescriptor {
  46293. vertexStage: GPUProgrammableStageDescriptor;
  46294. fragmentStage?: GPUProgrammableStageDescriptor;
  46295. }
  46296. /** @hidden */
  46297. export class WebGPUBindGroupCacheNode {
  46298. values: {
  46299. [id: number]: WebGPUBindGroupCacheNode;
  46300. };
  46301. bindGroups: GPUBindGroup[];
  46302. constructor();
  46303. }
  46304. /** @hidden */
  46305. export class WebGPUPipelineContext implements IPipelineContext {
  46306. engine: WebGPUEngine;
  46307. shaderProcessingContext: WebGPUShaderProcessingContext;
  46308. leftOverUniformsByName: {
  46309. [name: string]: string;
  46310. };
  46311. sources: {
  46312. vertex: string;
  46313. fragment: string;
  46314. rawVertex: string;
  46315. rawFragment: string;
  46316. };
  46317. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  46318. samplers: {
  46319. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  46320. };
  46321. textures: {
  46322. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  46323. };
  46324. bindGroupLayouts: GPUBindGroupLayout[];
  46325. bindGroupsCache: WebGPUBindGroupCacheNode;
  46326. /**
  46327. * Stores the uniform buffer
  46328. */
  46329. uniformBuffer: Nullable<UniformBuffer>;
  46330. onCompiled?: () => void;
  46331. get isAsync(): boolean;
  46332. get isReady(): boolean;
  46333. /** @hidden */
  46334. _name: string;
  46335. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  46336. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  46337. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  46338. [key: string]: number;
  46339. }, uniformsNames: string[], uniforms: {
  46340. [key: string]: Nullable<WebGLUniformLocation>;
  46341. }, samplerList: string[], samplers: {
  46342. [key: string]: number;
  46343. }, attributesNames: string[], attributes: number[]): void;
  46344. /** @hidden */
  46345. /**
  46346. * Build the uniform buffer used in the material.
  46347. */
  46348. buildUniformLayout(): void;
  46349. /**
  46350. * Release all associated resources.
  46351. **/
  46352. dispose(): void;
  46353. /**
  46354. * Sets an integer value on a uniform variable.
  46355. * @param uniformName Name of the variable.
  46356. * @param value Value to be set.
  46357. */
  46358. setInt(uniformName: string, value: number): void;
  46359. /**
  46360. * Sets an int2 value on a uniform variable.
  46361. * @param uniformName Name of the variable.
  46362. * @param x First int in int2.
  46363. * @param y Second int in int2.
  46364. */
  46365. setInt2(uniformName: string, x: number, y: number): void;
  46366. /**
  46367. * Sets an int3 value on a uniform variable.
  46368. * @param uniformName Name of the variable.
  46369. * @param x First int in int3.
  46370. * @param y Second int in int3.
  46371. * @param z Third int in int3.
  46372. */
  46373. setInt3(uniformName: string, x: number, y: number, z: number): void;
  46374. /**
  46375. * Sets an int4 value on a uniform variable.
  46376. * @param uniformName Name of the variable.
  46377. * @param x First int in int4.
  46378. * @param y Second int in int4.
  46379. * @param z Third int in int4.
  46380. * @param w Fourth int in int4.
  46381. */
  46382. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  46383. /**
  46384. * Sets an int array on a uniform variable.
  46385. * @param uniformName Name of the variable.
  46386. * @param array array to be set.
  46387. */
  46388. setIntArray(uniformName: string, array: Int32Array): void;
  46389. /**
  46390. * 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)
  46391. * @param uniformName Name of the variable.
  46392. * @param array array to be set.
  46393. */
  46394. setIntArray2(uniformName: string, array: Int32Array): void;
  46395. /**
  46396. * 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)
  46397. * @param uniformName Name of the variable.
  46398. * @param array array to be set.
  46399. */
  46400. setIntArray3(uniformName: string, array: Int32Array): void;
  46401. /**
  46402. * 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)
  46403. * @param uniformName Name of the variable.
  46404. * @param array array to be set.
  46405. */
  46406. setIntArray4(uniformName: string, array: Int32Array): void;
  46407. /**
  46408. * Sets an array on a uniform variable.
  46409. * @param uniformName Name of the variable.
  46410. * @param array array to be set.
  46411. */
  46412. setArray(uniformName: string, array: number[]): void;
  46413. /**
  46414. * 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)
  46415. * @param uniformName Name of the variable.
  46416. * @param array array to be set.
  46417. */
  46418. setArray2(uniformName: string, array: number[]): void;
  46419. /**
  46420. * 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)
  46421. * @param uniformName Name of the variable.
  46422. * @param array array to be set.
  46423. * @returns this effect.
  46424. */
  46425. setArray3(uniformName: string, array: number[]): void;
  46426. /**
  46427. * 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)
  46428. * @param uniformName Name of the variable.
  46429. * @param array array to be set.
  46430. */
  46431. setArray4(uniformName: string, array: number[]): void;
  46432. /**
  46433. * Sets matrices on a uniform variable.
  46434. * @param uniformName Name of the variable.
  46435. * @param matrices matrices to be set.
  46436. */
  46437. setMatrices(uniformName: string, matrices: Float32Array): void;
  46438. /**
  46439. * Sets matrix on a uniform variable.
  46440. * @param uniformName Name of the variable.
  46441. * @param matrix matrix to be set.
  46442. */
  46443. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  46444. /**
  46445. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  46446. * @param uniformName Name of the variable.
  46447. * @param matrix matrix to be set.
  46448. */
  46449. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  46450. /**
  46451. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  46452. * @param uniformName Name of the variable.
  46453. * @param matrix matrix to be set.
  46454. */
  46455. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  46456. /**
  46457. * Sets a float on a uniform variable.
  46458. * @param uniformName Name of the variable.
  46459. * @param value value to be set.
  46460. * @returns this effect.
  46461. */
  46462. setFloat(uniformName: string, value: number): void;
  46463. /**
  46464. * Sets a Vector2 on a uniform variable.
  46465. * @param uniformName Name of the variable.
  46466. * @param vector2 vector2 to be set.
  46467. */
  46468. setVector2(uniformName: string, vector2: IVector2Like): void;
  46469. /**
  46470. * Sets a float2 on a uniform variable.
  46471. * @param uniformName Name of the variable.
  46472. * @param x First float in float2.
  46473. * @param y Second float in float2.
  46474. */
  46475. setFloat2(uniformName: string, x: number, y: number): void;
  46476. /**
  46477. * Sets a Vector3 on a uniform variable.
  46478. * @param uniformName Name of the variable.
  46479. * @param vector3 Value to be set.
  46480. */
  46481. setVector3(uniformName: string, vector3: IVector3Like): void;
  46482. /**
  46483. * Sets a float3 on a uniform variable.
  46484. * @param uniformName Name of the variable.
  46485. * @param x First float in float3.
  46486. * @param y Second float in float3.
  46487. * @param z Third float in float3.
  46488. */
  46489. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  46490. /**
  46491. * Sets a Vector4 on a uniform variable.
  46492. * @param uniformName Name of the variable.
  46493. * @param vector4 Value to be set.
  46494. */
  46495. setVector4(uniformName: string, vector4: IVector4Like): void;
  46496. /**
  46497. * Sets a float4 on a uniform variable.
  46498. * @param uniformName Name of the variable.
  46499. * @param x First float in float4.
  46500. * @param y Second float in float4.
  46501. * @param z Third float in float4.
  46502. * @param w Fourth float in float4.
  46503. * @returns this effect.
  46504. */
  46505. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  46506. /**
  46507. * Sets a Color3 on a uniform variable.
  46508. * @param uniformName Name of the variable.
  46509. * @param color3 Value to be set.
  46510. */
  46511. setColor3(uniformName: string, color3: IColor3Like): void;
  46512. /**
  46513. * Sets a Color4 on a uniform variable.
  46514. * @param uniformName Name of the variable.
  46515. * @param color3 Value to be set.
  46516. * @param alpha Alpha value to be set.
  46517. */
  46518. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  46519. /**
  46520. * Sets a Color4 on a uniform variable
  46521. * @param uniformName defines the name of the variable
  46522. * @param color4 defines the value to be set
  46523. */
  46524. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  46525. _getVertexShaderCode(): string | null;
  46526. _getFragmentShaderCode(): string | null;
  46527. }
  46528. }
  46529. declare module "babylonjs/Meshes/WebGPU/webgpuDataBuffer" {
  46530. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46531. /** @hidden */
  46532. export class WebGPUDataBuffer extends DataBuffer {
  46533. private _buffer;
  46534. constructor(resource: GPUBuffer);
  46535. get underlyingResource(): any;
  46536. }
  46537. }
  46538. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  46539. /**
  46540. * Class used to inline functions in shader code
  46541. */
  46542. export class ShaderCodeInliner {
  46543. private static readonly _RegexpFindFunctionNameAndType;
  46544. private _sourceCode;
  46545. private _functionDescr;
  46546. private _numMaxIterations;
  46547. /** Gets or sets the token used to mark the functions to inline */
  46548. inlineToken: string;
  46549. /** Gets or sets the debug mode */
  46550. debug: boolean;
  46551. /** Gets the code after the inlining process */
  46552. get code(): string;
  46553. /**
  46554. * Initializes the inliner
  46555. * @param sourceCode shader code source to inline
  46556. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  46557. */
  46558. constructor(sourceCode: string, numMaxIterations?: number);
  46559. /**
  46560. * Start the processing of the shader code
  46561. */
  46562. processCode(): void;
  46563. private _collectFunctions;
  46564. private _processInlining;
  46565. private _extractBetweenMarkers;
  46566. private _skipWhitespaces;
  46567. private _isIdentifierChar;
  46568. private _removeComments;
  46569. private _replaceFunctionCallsByCode;
  46570. private _findBackward;
  46571. private _escapeRegExp;
  46572. private _replaceNames;
  46573. }
  46574. }
  46575. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessors" {
  46576. import { Nullable } from "babylonjs/types";
  46577. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46578. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46579. /** @hidden */
  46580. export class WebGPUShaderProcessor implements IShaderProcessor {
  46581. protected _missingVaryings: Array<string>;
  46582. protected _textureArrayProcessing: Array<string>;
  46583. protected _preProcessors: {
  46584. [key: string]: string;
  46585. };
  46586. private _getArraySize;
  46587. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  46588. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  46589. [key: string]: string;
  46590. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46591. attributeProcessor(attribute: string, preProcessors: {
  46592. [key: string]: string;
  46593. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46594. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  46595. [key: string]: string;
  46596. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46597. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46598. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46599. private _applyTextureArrayProcessing;
  46600. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  46601. vertexCode: string;
  46602. fragmentCode: string;
  46603. };
  46604. }
  46605. }
  46606. declare module "babylonjs/Engines/WebGPU/webgpuBufferManager" {
  46607. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46608. import { WebGPUDataBuffer } from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  46609. import { Nullable } from "babylonjs/types";
  46610. /** @hidden */
  46611. export class WebGPUBufferManager {
  46612. private _device;
  46613. private _deferredReleaseBuffers;
  46614. private static _IsGPUBuffer;
  46615. constructor(device: GPUDevice);
  46616. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  46617. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  46618. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  46619. private _FromHalfFloat;
  46620. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  46621. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  46622. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  46623. destroyDeferredBuffers(): void;
  46624. }
  46625. }
  46626. declare module "babylonjs/Engines/WebGPU/webgpuHardwareTexture" {
  46627. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46628. import { Nullable } from "babylonjs/types";
  46629. /** @hidden */
  46630. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  46631. private _webgpuTexture;
  46632. private _webgpuMSAATexture;
  46633. get underlyingResource(): Nullable<GPUTexture>;
  46634. get msaaTexture(): Nullable<GPUTexture>;
  46635. set msaaTexture(texture: Nullable<GPUTexture>);
  46636. view: Nullable<GPUTextureView>;
  46637. format: GPUTextureFormat;
  46638. textureUsages: number;
  46639. constructor(existingTexture?: Nullable<GPUTexture>);
  46640. set(hardwareTexture: GPUTexture): void;
  46641. setMSAATexture(hardwareTexture: GPUTexture): void;
  46642. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  46643. createView(descriptor?: GPUTextureViewDescriptor): void;
  46644. reset(): void;
  46645. release(): void;
  46646. }
  46647. }
  46648. declare module "babylonjs/Engines/WebGPU/webgpuTextureHelper" {
  46649. import { WebGPUBufferManager } from "babylonjs/Engines/WebGPU/webgpuBufferManager";
  46650. import { Nullable } from "babylonjs/types";
  46651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46652. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46653. import { IColor4Like } from "babylonjs/Maths/math.like";
  46654. /** @hidden */
  46655. export class WebGPUTextureHelper {
  46656. private _device;
  46657. private _glslang;
  46658. private _bufferManager;
  46659. private _mipmapSampler;
  46660. private _invertYPreMultiplyAlphaSampler;
  46661. private _pipelines;
  46662. private _compiledShaders;
  46663. private _deferredReleaseTextures;
  46664. private _commandEncoderForCreation;
  46665. static ComputeNumMipmapLevels(width: number, height: number): number;
  46666. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  46667. private _getPipeline;
  46668. private static _GetTextureTypeFromFormat;
  46669. private static _GetBlockInformationFromFormat;
  46670. private static _IsHardwareTexture;
  46671. private static _IsInternalTexture;
  46672. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  46673. static IsImageBitmap(imageBitmap: ImageBitmap | {
  46674. width: number;
  46675. height: number;
  46676. }): imageBitmap is ImageBitmap;
  46677. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  46678. width: number;
  46679. height: number;
  46680. }): imageBitmap is ImageBitmap[];
  46681. setCommandEncoder(encoder: GPUCommandEncoder): void;
  46682. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  46683. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  46684. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46685. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  46686. createTexture(imageBitmap: ImageBitmap | {
  46687. width: number;
  46688. height: number;
  46689. layers: number;
  46690. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46691. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  46692. width: number;
  46693. height: number;
  46694. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46695. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  46696. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46697. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  46698. createMSAATexture(texture: InternalTexture, samples: number): void;
  46699. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  46700. updateTexture(imageBitmap: ImageBitmap | Uint8Array, gpuTexture: GPUTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  46701. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  46702. releaseTexture(texture: InternalTexture | GPUTexture): void;
  46703. destroyDeferredTextures(): void;
  46704. }
  46705. }
  46706. declare module "babylonjs/Engines/WebGPU/webgpuRenderPassWrapper" {
  46707. import { Nullable } from "babylonjs/types";
  46708. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46709. /** @hidden */
  46710. export class WebGPURenderPassWrapper {
  46711. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  46712. renderPass: Nullable<GPURenderPassEncoder>;
  46713. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46714. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46715. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  46716. depthTextureFormat: GPUTextureFormat | undefined;
  46717. constructor();
  46718. reset(fullReset?: boolean): void;
  46719. }
  46720. }
  46721. declare module "babylonjs/Engines/WebGPU/webgpuCacheSampler" {
  46722. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46723. /** @hidden */
  46724. export class WebGPUCacheSampler {
  46725. private _samplers;
  46726. private _device;
  46727. disabled: boolean;
  46728. constructor(device: GPUDevice);
  46729. private static _GetSamplerHashCode;
  46730. private static _GetSamplerFilterDescriptor;
  46731. private static _GetWrappingMode;
  46732. private static _GetSamplerWrappingDescriptor;
  46733. private static _GetSamplerDescriptor;
  46734. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  46735. }
  46736. }
  46737. declare module "babylonjs/Engines/WebGPU/webgpuShaderManager" {
  46738. import { IWebGPURenderPipelineStageDescriptor } from "babylonjs/Engines/WebGPU/webgpuPipelineContext";
  46739. /** @hidden */
  46740. export class WebGPUShaderManager {
  46741. private _shaders;
  46742. private _device;
  46743. constructor(device: GPUDevice);
  46744. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  46745. }
  46746. }
  46747. declare module "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline" {
  46748. import { Effect } from "babylonjs/Materials/effect";
  46749. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46750. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46751. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46752. import { Nullable } from "babylonjs/types";
  46753. /** @hidden */
  46754. export abstract class WebGPUCacheRenderPipeline {
  46755. static NumCacheHitWithoutHash: number;
  46756. static NumCacheHitWithHash: number;
  46757. static NumCacheMiss: number;
  46758. static NumPipelineCreationLastFrame: number;
  46759. disabled: boolean;
  46760. private static _NumPipelineCreationCurrentFrame;
  46761. protected _states: number[];
  46762. protected _stateDirtyLowestIndex: number;
  46763. lastStateDirtyLowestIndex: number;
  46764. private _device;
  46765. private _isDirty;
  46766. private _emptyVertexBuffer;
  46767. private _parameter;
  46768. private _shaderId;
  46769. private _alphaToCoverageEnabled;
  46770. private _frontFace;
  46771. private _cullEnabled;
  46772. private _cullFace;
  46773. private _clampDepth;
  46774. private _rasterizationState;
  46775. private _depthBias;
  46776. private _depthBiasClamp;
  46777. private _depthBiasSlopeScale;
  46778. private _colorFormat;
  46779. private _webgpuColorFormat;
  46780. private _mrtAttachments1;
  46781. private _mrtAttachments2;
  46782. private _mrtFormats;
  46783. private _alphaBlendEnabled;
  46784. private _alphaBlendFuncParams;
  46785. private _alphaBlendEqParams;
  46786. private _writeMask;
  46787. private _colorStates;
  46788. private _depthStencilFormat;
  46789. private _webgpuDepthStencilFormat;
  46790. private _depthTestEnabled;
  46791. private _depthWriteEnabled;
  46792. private _depthCompare;
  46793. private _stencilEnabled;
  46794. private _stencilFrontCompare;
  46795. private _stencilFrontDepthFailOp;
  46796. private _stencilFrontPassOp;
  46797. private _stencilFrontFailOp;
  46798. private _stencilReadMask;
  46799. private _stencilWriteMask;
  46800. private _depthStencilState;
  46801. private _vertexBuffers;
  46802. private _overrideVertexBuffers;
  46803. private _indexBuffer;
  46804. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  46805. reset(): void;
  46806. protected abstract _getRenderPipeline(param: {
  46807. token: any;
  46808. pipeline: Nullable<GPURenderPipeline>;
  46809. }): void;
  46810. protected abstract _setRenderPipeline(param: {
  46811. token: any;
  46812. pipeline: Nullable<GPURenderPipeline>;
  46813. }): void;
  46814. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  46815. endFrame(): void;
  46816. setAlphaToCoverage(enabled: boolean): void;
  46817. setFrontFace(frontFace: number): void;
  46818. setCullEnabled(enabled: boolean): void;
  46819. setCullFace(cullFace: number): void;
  46820. setClampDepth(clampDepth: boolean): void;
  46821. resetDepthCullingState(): void;
  46822. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  46823. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  46824. setColorFormat(format: GPUTextureFormat): void;
  46825. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  46826. setAlphaBlendEnabled(enabled: boolean): void;
  46827. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  46828. setWriteMask(mask: number): void;
  46829. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  46830. setDepthTestEnabled(enabled: boolean): void;
  46831. setDepthWriteEnabled(enabled: boolean): void;
  46832. setDepthCompare(func: Nullable<number>): void;
  46833. setStencilEnabled(enabled: boolean): void;
  46834. setStencilCompare(func: Nullable<number>): void;
  46835. setStencilDepthFailOp(op: Nullable<number>): void;
  46836. setStencilPassOp(op: Nullable<number>): void;
  46837. setStencilFailOp(op: Nullable<number>): void;
  46838. setStencilReadMask(mask: number): void;
  46839. setStencilWriteMask(mask: number): void;
  46840. resetStencilState(): void;
  46841. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  46842. setBuffers(vertexBuffers: Nullable<{
  46843. [key: string]: Nullable<VertexBuffer>;
  46844. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  46845. [key: string]: Nullable<VertexBuffer>;
  46846. }>): void;
  46847. private static _GetTopology;
  46848. private static _GetAphaBlendOperation;
  46849. private static _GetAphaBlendFactor;
  46850. private static _GetCompareFunction;
  46851. private static _GetStencilOpFunction;
  46852. private static _GetVertexInputDescriptorFormat;
  46853. private _getAphaBlendState;
  46854. private _getColorBlendState;
  46855. private _setShaderStage;
  46856. private _setRasterizationState;
  46857. private _setColorStates;
  46858. private _setDepthStencilState;
  46859. private _setVertexState;
  46860. private _createPipelineLayout;
  46861. private _getVertexInputDescriptor;
  46862. private _createRenderPipeline;
  46863. }
  46864. }
  46865. declare module "babylonjs/Engines/WebGPU/webgpuCacheRenderPipelineTree" {
  46866. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46867. import { Nullable } from "babylonjs/types";
  46868. import { WebGPUCacheRenderPipeline } from "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline";
  46869. /** @hidden */
  46870. class NodeState {
  46871. values: {
  46872. [name: number]: NodeState;
  46873. };
  46874. pipeline: GPURenderPipeline;
  46875. constructor();
  46876. count(): [number, number];
  46877. }
  46878. /** @hidden */
  46879. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  46880. private static _Cache;
  46881. private _nodeStack;
  46882. static GetNodeCounts(): {
  46883. nodeCount: number;
  46884. pipelineCount: number;
  46885. };
  46886. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  46887. protected _getRenderPipeline(param: {
  46888. token: any;
  46889. pipeline: Nullable<GPURenderPipeline>;
  46890. }): void;
  46891. protected _setRenderPipeline(param: {
  46892. token: NodeState;
  46893. pipeline: Nullable<GPURenderPipeline>;
  46894. }): void;
  46895. }
  46896. }
  46897. declare module "babylonjs/Engines/WebGPU/webgpuStencilState" {
  46898. import { WebGPUCacheRenderPipeline } from "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline";
  46899. import { StencilState } from "babylonjs/States/stencilState";
  46900. /**
  46901. * @hidden
  46902. **/
  46903. export class WebGPUStencilState extends StencilState {
  46904. private _cache;
  46905. constructor(cache: WebGPUCacheRenderPipeline);
  46906. get stencilFunc(): number;
  46907. set stencilFunc(value: number);
  46908. get stencilFuncRef(): number;
  46909. set stencilFuncRef(value: number);
  46910. get stencilFuncMask(): number;
  46911. set stencilFuncMask(value: number);
  46912. get stencilOpStencilFail(): number;
  46913. set stencilOpStencilFail(value: number);
  46914. get stencilOpDepthFail(): number;
  46915. set stencilOpDepthFail(value: number);
  46916. get stencilOpStencilDepthPass(): number;
  46917. set stencilOpStencilDepthPass(value: number);
  46918. get stencilMask(): number;
  46919. set stencilMask(value: number);
  46920. get stencilTest(): boolean;
  46921. set stencilTest(value: boolean);
  46922. reset(): void;
  46923. apply(gl: WebGLRenderingContext): void;
  46924. }
  46925. }
  46926. declare module "babylonjs/Engines/WebGPU/webgpuDepthCullingState" {
  46927. import { Nullable } from "babylonjs/types";
  46928. import { WebGPUCacheRenderPipeline } from "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline";
  46929. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  46930. /**
  46931. * @hidden
  46932. **/
  46933. export class WebGPUDepthCullingState extends DepthCullingState {
  46934. private _cache;
  46935. /**
  46936. * Initializes the state.
  46937. */
  46938. constructor(cache: WebGPUCacheRenderPipeline);
  46939. get zOffset(): number;
  46940. set zOffset(value: number);
  46941. get cullFace(): Nullable<number>;
  46942. set cullFace(value: Nullable<number>);
  46943. get cull(): Nullable<boolean>;
  46944. set cull(value: Nullable<boolean>);
  46945. get depthFunc(): Nullable<number>;
  46946. set depthFunc(value: Nullable<number>);
  46947. get depthMask(): boolean;
  46948. set depthMask(value: boolean);
  46949. get depthTest(): boolean;
  46950. set depthTest(value: boolean);
  46951. get frontFace(): Nullable<number>;
  46952. set frontFace(value: Nullable<number>);
  46953. reset(): void;
  46954. apply(gl: WebGLRenderingContext): void;
  46955. }
  46956. }
  46957. declare module "babylonjs/Shaders/clearQuad.vertex" {
  46958. /** @hidden */
  46959. export var clearQuadVertexShader: {
  46960. name: string;
  46961. shader: string;
  46962. };
  46963. }
  46964. declare module "babylonjs/Shaders/clearQuad.fragment" {
  46965. /** @hidden */
  46966. export var clearQuadPixelShader: {
  46967. name: string;
  46968. shader: string;
  46969. };
  46970. }
  46971. declare module "babylonjs/Engines/webgpuEngine" {
  46972. import { Nullable, DataArray, IndicesArray, FloatArray, Immutable } from "babylonjs/types";
  46973. import { Engine } from "babylonjs/Engines/engine";
  46974. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  46975. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46976. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46977. import { IEffectCreationOptions, Effect } from "babylonjs/Materials/effect";
  46978. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  46979. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46980. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46981. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46983. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46984. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46985. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  46986. import { Scene } from "babylonjs/scene";
  46987. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  46988. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46989. import { IColor4Like } from "babylonjs/Maths/math.like";
  46990. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46991. import "babylonjs/Shaders/clearQuad.vertex";
  46992. import "babylonjs/Shaders/clearQuad.fragment";
  46993. /**
  46994. * Options to load the associated Glslang library
  46995. */
  46996. export interface GlslangOptions {
  46997. /**
  46998. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  46999. */
  47000. glslang?: any;
  47001. /**
  47002. * Defines the URL of the glslang JS File.
  47003. */
  47004. jsPath?: string;
  47005. /**
  47006. * Defines the URL of the glslang WASM File.
  47007. */
  47008. wasmPath?: string;
  47009. }
  47010. /**
  47011. * Options to create the WebGPU engine
  47012. */
  47013. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  47014. /**
  47015. * If delta time between frames should be constant
  47016. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47017. */
  47018. deterministicLockstep?: boolean;
  47019. /**
  47020. * Maximum about of steps between frames (Default: 4)
  47021. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47022. */
  47023. lockstepMaxSteps?: number;
  47024. /**
  47025. * Defines the seconds between each deterministic lock step
  47026. */
  47027. timeStep?: number;
  47028. /**
  47029. * Defines that engine should ignore modifying touch action attribute and style
  47030. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  47031. */
  47032. doNotHandleTouchAction?: boolean;
  47033. /**
  47034. * Defines if webaudio should be initialized as well
  47035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  47036. */
  47037. audioEngine?: boolean;
  47038. /**
  47039. * Defines the category of adapter to use.
  47040. * Is it the discrete or integrated device.
  47041. */
  47042. powerPreference?: GPUPowerPreference;
  47043. /**
  47044. * Defines the device descriptor used to create a device.
  47045. */
  47046. deviceDescriptor?: GPUDeviceDescriptor;
  47047. /**
  47048. * Defines the requested Swap Chain Format.
  47049. */
  47050. swapChainFormat?: GPUTextureFormat;
  47051. /**
  47052. * Defines whether MSAA is enabled on the canvas.
  47053. */
  47054. antialiasing?: boolean;
  47055. /**
  47056. * Defines whether the stencil buffer should be enabled.
  47057. */
  47058. stencil?: boolean;
  47059. /**
  47060. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  47061. */
  47062. enableGPUDebugMarkers?: boolean;
  47063. /**
  47064. * Options to load the associated Glslang library
  47065. */
  47066. glslangOptions?: GlslangOptions;
  47067. }
  47068. /**
  47069. * The web GPU engine class provides support for WebGPU version of babylon.js.
  47070. */
  47071. export class WebGPUEngine extends Engine {
  47072. private static readonly _glslangDefaultOptions;
  47073. private readonly _uploadEncoderDescriptor;
  47074. private readonly _renderEncoderDescriptor;
  47075. private readonly _renderTargetEncoderDescriptor;
  47076. private readonly _clearDepthValue;
  47077. private readonly _clearReverseDepthValue;
  47078. private readonly _clearStencilValue;
  47079. private readonly _defaultSampleCount;
  47080. private _canvas;
  47081. private _options;
  47082. private _glslang;
  47083. private _adapter;
  47084. private _adapterSupportedExtensions;
  47085. private _device;
  47086. private _deviceEnabledExtensions;
  47087. private _context;
  47088. private _swapChain;
  47089. private _swapChainTexture;
  47090. private _mainPassSampleCount;
  47091. private _textureHelper;
  47092. private _bufferManager;
  47093. private _shaderManager;
  47094. private _cacheSampler;
  47095. private _cacheRenderPipeline;
  47096. private _emptyVertexBuffer;
  47097. private _lastCachedWrapU;
  47098. private _lastCachedWrapV;
  47099. private _lastCachedWrapR;
  47100. private _mrtAttachments;
  47101. private _counters;
  47102. private _mainTexture;
  47103. private _depthTexture;
  47104. private _mainTextureExtends;
  47105. private _depthTextureFormat;
  47106. private _colorFormat;
  47107. private _uploadEncoder;
  47108. private _renderEncoder;
  47109. private _renderTargetEncoder;
  47110. private _commandBuffers;
  47111. private _currentRenderPass;
  47112. private _mainRenderPassWrapper;
  47113. private _rttRenderPassWrapper;
  47114. private _pendingDebugCommands;
  47115. private _currentVertexBuffers;
  47116. private _currentOverrideVertexBuffers;
  47117. private _currentIndexBuffer;
  47118. private __colorWrite;
  47119. private _uniformsBuffers;
  47120. private _forceEnableEffect;
  47121. /** @hidden */
  47122. dbgShowShaderCode: boolean;
  47123. /** @hidden */
  47124. dbgSanityChecks: boolean;
  47125. /** @hidden */
  47126. dbgGenerateLogs: boolean;
  47127. /** @hidden */
  47128. dbgVerboseLogsForFirstFrames: boolean;
  47129. /** @hidden */
  47130. dbgVerboseLogsNumFrames: number;
  47131. /** @hidden */
  47132. dbgShowWarningsNotImplemented: boolean;
  47133. /**
  47134. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  47135. */
  47136. get disableCacheSamplers(): boolean;
  47137. set disableCacheSamplers(disable: boolean);
  47138. /**
  47139. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  47140. */
  47141. get disableCacheRenderPipelines(): boolean;
  47142. set disableCacheRenderPipelines(disable: boolean);
  47143. /**
  47144. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  47145. * @returns true if the engine can be created
  47146. */
  47147. static get IsSupported(): boolean;
  47148. /**
  47149. * Gets a boolean indicating that the engine supports uniform buffers
  47150. */
  47151. get supportsUniformBuffers(): boolean;
  47152. /** Gets the supported extensions by the WebGPU adapter */
  47153. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  47154. /** Gets the currently enabled extensions on the WebGPU device */
  47155. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  47156. /**
  47157. * Returns the name of the engine
  47158. */
  47159. get name(): string;
  47160. /**
  47161. * Returns a string describing the current engine
  47162. */
  47163. get description(): string;
  47164. /**
  47165. * Returns the version of the engine
  47166. */
  47167. get version(): number;
  47168. /**
  47169. * Create a new instance of the gpu engine asynchronously
  47170. * @param canvas Defines the canvas to use to display the result
  47171. * @param options Defines the options passed to the engine to create the GPU context dependencies
  47172. * @returns a promise that resolves with the created engine
  47173. */
  47174. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  47175. /**
  47176. * Create a new instance of the gpu engine.
  47177. * @param canvas Defines the canvas to use to display the result
  47178. * @param options Defines the options passed to the engine to create the GPU context dependencies
  47179. */
  47180. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  47181. /**
  47182. * Initializes the WebGPU context and dependencies.
  47183. * @param glslangOptions Defines the GLSLang compiler options if necessary
  47184. * @returns a promise notifying the readiness of the engine.
  47185. */
  47186. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  47187. private _initGlslang;
  47188. private _initializeLimits;
  47189. private _initializeContextAndSwapChain;
  47190. private _initializeMainAttachments;
  47191. /**
  47192. * Force a specific size of the canvas
  47193. * @param width defines the new canvas' width
  47194. * @param height defines the new canvas' height
  47195. * @param forceSetSize true to force setting the sizes of the underlying canvas
  47196. * @returns true if the size was changed
  47197. */
  47198. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  47199. /**
  47200. * Gets a shader processor implementation fitting with the current engine type.
  47201. * @returns The shader processor implementation.
  47202. */
  47203. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  47204. /** @hidden */
  47205. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  47206. /**
  47207. * Force the entire cache to be cleared
  47208. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  47209. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47210. */
  47211. wipeCaches(bruteForce?: boolean): void;
  47212. /**
  47213. * Enable or disable color writing
  47214. * @param enable defines the state to set
  47215. */
  47216. setColorWrite(enable: boolean): void;
  47217. /**
  47218. * Gets a boolean indicating if color writing is enabled
  47219. * @returns the current color writing state
  47220. */
  47221. getColorWrite(): boolean;
  47222. private _viewportsCurrent;
  47223. private _resetCurrentViewport;
  47224. private _applyViewport;
  47225. /** @hidden */
  47226. _viewport(x: number, y: number, width: number, height: number): void;
  47227. private _scissorsCurrent;
  47228. protected _scissorCached: {
  47229. x: number;
  47230. y: number;
  47231. z: number;
  47232. w: number;
  47233. };
  47234. private _resetCurrentScissor;
  47235. private _applyScissor;
  47236. private _scissorIsActive;
  47237. enableScissor(x: number, y: number, width: number, height: number): void;
  47238. disableScissor(): void;
  47239. /**
  47240. * Clear the current render buffer or the current render target (if any is set up)
  47241. * @param color defines the color to use
  47242. * @param backBuffer defines if the back buffer must be cleared
  47243. * @param depth defines if the depth buffer must be cleared
  47244. * @param stencil defines if the stencil buffer must be cleared
  47245. */
  47246. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47247. /**
  47248. * Clears a list of attachments
  47249. * @param attachments list of the attachments
  47250. * @param colorMain clear color for the main attachment (the first one)
  47251. * @param colorOthers clear color for the other attachments
  47252. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  47253. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  47254. */
  47255. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  47256. /**
  47257. * Creates a vertex buffer
  47258. * @param data the data for the vertex buffer
  47259. * @returns the new buffer
  47260. */
  47261. createVertexBuffer(data: DataArray): DataBuffer;
  47262. /**
  47263. * Creates a vertex buffer
  47264. * @param data the data for the dynamic vertex buffer
  47265. * @returns the new buffer
  47266. */
  47267. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47268. /**
  47269. * Updates a vertex buffer.
  47270. * @param vertexBuffer the vertex buffer to update
  47271. * @param data the data used to update the vertex buffer
  47272. * @param byteOffset the byte offset of the data
  47273. * @param byteLength the byte length of the data
  47274. */
  47275. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47276. /**
  47277. * Creates a new index buffer
  47278. * @param indices defines the content of the index buffer
  47279. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  47280. * @returns a new buffer
  47281. */
  47282. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  47283. /**
  47284. * Update an index buffer
  47285. * @param indexBuffer defines the target index buffer
  47286. * @param indices defines the data to update
  47287. * @param offset defines the offset in the target index buffer where update should start
  47288. */
  47289. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47290. /** @hidden */
  47291. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  47292. /** @hidden */
  47293. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  47294. /**
  47295. * Bind a list of vertex buffers with the engine
  47296. * @param vertexBuffers defines the list of vertex buffers to bind
  47297. * @param indexBuffer defines the index buffer to bind
  47298. * @param effect defines the effect associated with the vertex buffers
  47299. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  47300. */
  47301. bindBuffers(vertexBuffers: {
  47302. [key: string]: Nullable<VertexBuffer>;
  47303. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  47304. [kind: string]: Nullable<VertexBuffer>;
  47305. }): void;
  47306. /** @hidden */
  47307. _releaseBuffer(buffer: DataBuffer): boolean;
  47308. createUniformBuffer(elements: FloatArray): DataBuffer;
  47309. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  47310. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  47311. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  47312. /**
  47313. * Create a new effect (used to store vertex/fragment shaders)
  47314. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  47315. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  47316. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  47317. * @param samplers defines an array of string used to represent textures
  47318. * @param defines defines the string containing the defines to use to compile the shaders
  47319. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  47320. * @param onCompiled defines a function to call when the effect creation is successful
  47321. * @param onError defines a function to call when the effect creation has failed
  47322. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  47323. * @returns the new Effect
  47324. */
  47325. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  47326. private _compileRawShaderToSpirV;
  47327. private _compileShaderToSpirV;
  47328. private _createPipelineStageDescriptor;
  47329. private _compileRawPipelineStageDescriptor;
  47330. private _compilePipelineStageDescriptor;
  47331. /** @hidden */
  47332. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  47333. /** @hidden */
  47334. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  47335. /**
  47336. * Creates a new pipeline context
  47337. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  47338. * @returns the new pipeline
  47339. */
  47340. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  47341. /** @hidden */
  47342. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  47343. /**
  47344. * Gets the list of active attributes for a given WebGPU program
  47345. * @param pipelineContext defines the pipeline context to use
  47346. * @param attributesNames defines the list of attribute names to get
  47347. * @returns an array of indices indicating the offset of each attribute
  47348. */
  47349. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47350. /**
  47351. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47352. * @param effect defines the effect to activate
  47353. */
  47354. enableEffect(effect: Nullable<Effect>): void;
  47355. /** @hidden */
  47356. _releaseEffect(effect: Effect): void;
  47357. /**
  47358. * 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
  47359. */
  47360. releaseEffects(): void;
  47361. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47362. /**
  47363. * Gets a boolean indicating that only power of 2 textures are supported
  47364. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  47365. */
  47366. get needPOTTextures(): boolean;
  47367. /** @hidden */
  47368. _createHardwareTexture(): HardwareTextureWrapper;
  47369. /** @hidden */
  47370. _releaseTexture(texture: InternalTexture): void;
  47371. /** @hidden */
  47372. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  47373. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  47374. /**
  47375. * Usually called from Texture.ts.
  47376. * Passed information to create a hardware texture
  47377. * @param url defines a value which contains one of the following:
  47378. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47379. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47380. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47381. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47382. * @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)
  47383. * @param scene needed for loading to the correct scene
  47384. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47385. * @param onLoad optional callback to be called upon successful completion
  47386. * @param onError optional callback to be called upon failure
  47387. * @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
  47388. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47389. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47390. * @param forcedExtension defines the extension to use to pick the right loader
  47391. * @param mimeType defines an optional mime type
  47392. * @param loaderOptions options to be passed to the loader
  47393. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47394. */
  47395. 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;
  47396. /** @hidden */
  47397. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  47398. /**
  47399. * Creates a cube texture
  47400. * @param rootUrl defines the url where the files to load is located
  47401. * @param scene defines the current scene
  47402. * @param files defines the list of files to load (1 per face)
  47403. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47404. * @param onLoad defines an optional callback raised when the texture is loaded
  47405. * @param onError defines an optional callback raised if there is an issue to load the texture
  47406. * @param format defines the format of the data
  47407. * @param forcedExtension defines the extension to use to pick the right loader
  47408. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47409. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47410. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47411. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47412. * @param loaderOptions options to be passed to the loader
  47413. * @returns the cube texture as an InternalTexture
  47414. */
  47415. 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;
  47416. /**
  47417. * Creates a raw texture
  47418. * @param data defines the data to store in the texture
  47419. * @param width defines the width of the texture
  47420. * @param height defines the height of the texture
  47421. * @param format defines the format of the data
  47422. * @param generateMipMaps defines if the engine should generate the mip levels
  47423. * @param invertY defines if data must be stored with Y axis inverted
  47424. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  47425. * @param compression defines the compression used (null by default)
  47426. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47427. * @returns the raw texture inside an InternalTexture
  47428. */
  47429. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  47430. /**
  47431. * Creates a new raw cube texture
  47432. * @param data defines the array of data to use to create each face
  47433. * @param size defines the size of the textures
  47434. * @param format defines the format of the data
  47435. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  47436. * @param generateMipMaps defines if the engine should generate the mip levels
  47437. * @param invertY defines if data must be stored with Y axis inverted
  47438. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47439. * @param compression defines the compression used (null by default)
  47440. * @returns the cube texture as an InternalTexture
  47441. */
  47442. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  47443. /**
  47444. * Creates a new raw cube texture from a specified url
  47445. * @param url defines the url where the data is located
  47446. * @param scene defines the current scene
  47447. * @param size defines the size of the textures
  47448. * @param format defines the format of the data
  47449. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  47450. * @param noMipmap defines if the engine should avoid generating the mip levels
  47451. * @param callback defines a callback used to extract texture data from loaded data
  47452. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  47453. * @param onLoad defines a callback called when texture is loaded
  47454. * @param onError defines a callback called if there is an error
  47455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47456. * @param invertY defines if data must be stored with Y axis inverted
  47457. * @returns the cube texture as an InternalTexture
  47458. */
  47459. 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;
  47460. /**
  47461. * Creates a new raw 2D array texture
  47462. * @param data defines the data used to create the texture
  47463. * @param width defines the width of the texture
  47464. * @param height defines the height of the texture
  47465. * @param depth defines the number of layers of the texture
  47466. * @param format defines the format of the texture
  47467. * @param generateMipMaps defines if the engine must generate mip levels
  47468. * @param invertY defines if data must be stored with Y axis inverted
  47469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47470. * @param compression defines the compressed used (can be null)
  47471. * @param textureType defines the compressed used (can be null)
  47472. * @returns a new raw 2D array texture (stored in an InternalTexture)
  47473. */
  47474. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  47475. /**
  47476. * Creates a new raw 3D texture
  47477. * @param data defines the data used to create the texture
  47478. * @param width defines the width of the texture
  47479. * @param height defines the height of the texture
  47480. * @param depth defines the depth of the texture
  47481. * @param format defines the format of the texture
  47482. * @param generateMipMaps defines if the engine must generate mip levels
  47483. * @param invertY defines if data must be stored with Y axis inverted
  47484. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47485. * @param compression defines the compressed used (can be null)
  47486. * @param textureType defines the compressed used (can be null)
  47487. * @returns a new raw 3D texture (stored in an InternalTexture)
  47488. */
  47489. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  47490. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  47491. /**
  47492. * Update the sampling mode of a given texture
  47493. * @param samplingMode defines the required sampling mode
  47494. * @param texture defines the texture to update
  47495. * @param generateMipMaps defines whether to generate mipmaps for the texture
  47496. */
  47497. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  47498. /**
  47499. * Update the sampling mode of a given texture
  47500. * @param texture defines the texture to update
  47501. * @param wrapU defines the texture wrap mode of the u coordinates
  47502. * @param wrapV defines the texture wrap mode of the v coordinates
  47503. * @param wrapR defines the texture wrap mode of the r coordinates
  47504. */
  47505. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  47506. /**
  47507. * Update the dimensions of a texture
  47508. * @param texture texture to update
  47509. * @param width new width of the texture
  47510. * @param height new height of the texture
  47511. * @param depth new depth of the texture
  47512. */
  47513. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  47514. private _setInternalTexture;
  47515. /**
  47516. * Sets a texture to the according uniform.
  47517. * @param channel The texture channel
  47518. * @param unused unused parameter
  47519. * @param texture The texture to apply
  47520. * @param name The name of the uniform in the effect
  47521. */
  47522. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  47523. /**
  47524. * Sets an array of texture to the WebGPU context
  47525. * @param channel defines the channel where the texture array must be set
  47526. * @param unused unused parameter
  47527. * @param textures defines the array of textures to bind
  47528. * @param name name of the channel
  47529. */
  47530. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  47531. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  47532. /** @hidden */
  47533. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  47534. /** @hidden */
  47535. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  47536. private _generateMipmaps;
  47537. /**
  47538. * Update the content of a texture
  47539. * @param texture defines the texture to update
  47540. * @param canvas defines the source containing the data
  47541. * @param invertY defines if data must be stored with Y axis inverted
  47542. * @param premulAlpha defines if alpha is stored as premultiplied
  47543. * @param format defines the format of the data
  47544. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47545. */
  47546. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  47547. /**
  47548. * Update a portion of an internal texture
  47549. * @param texture defines the texture to update
  47550. * @param imageData defines the data to store into the texture
  47551. * @param xOffset defines the x coordinates of the update rectangle
  47552. * @param yOffset defines the y coordinates of the update rectangle
  47553. * @param width defines the width of the update rectangle
  47554. * @param height defines the height of the update rectangle
  47555. * @param faceIndex defines the face index if texture is a cube (0 by default)
  47556. * @param lod defines the lod level to update (0 by default)
  47557. */
  47558. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  47559. /**
  47560. * Update a video texture
  47561. * @param texture defines the texture to update
  47562. * @param video defines the video element to use
  47563. * @param invertY defines if data must be stored with Y axis inverted
  47564. */
  47565. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  47566. /** @hidden */
  47567. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47568. /** @hidden */
  47569. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  47570. /** @hidden */
  47571. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47572. /** @hidden */
  47573. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  47574. /**
  47575. * Update a raw texture
  47576. * @param texture defines the texture to update
  47577. * @param bufferView defines the data to store in the texture
  47578. * @param format defines the format of the data
  47579. * @param invertY defines if data must be stored with Y axis inverted
  47580. * @param compression defines the compression used (null by default)
  47581. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47582. */
  47583. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  47584. /**
  47585. * Update a raw cube texture
  47586. * @param texture defines the texture to update
  47587. * @param bufferView defines the data to store
  47588. * @param format defines the data format
  47589. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47590. * @param invertY defines if data must be stored with Y axis inverted
  47591. * @param compression defines the compression used (null by default)
  47592. * @param level defines which level of the texture to update
  47593. */
  47594. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47595. /**
  47596. * Update a raw 2D array texture
  47597. * @param texture defines the texture to update
  47598. * @param bufferView defines the data to store
  47599. * @param format defines the data format
  47600. * @param invertY defines if data must be stored with Y axis inverted
  47601. * @param compression defines the used compression (can be null)
  47602. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47603. */
  47604. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  47605. /**
  47606. * Update a raw 3D texture
  47607. * @param texture defines the texture to update
  47608. * @param bufferView defines the data to store
  47609. * @param format defines the data format
  47610. * @param invertY defines if data must be stored with Y axis inverted
  47611. * @param compression defines the used compression (can be null)
  47612. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47613. */
  47614. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  47615. /**
  47616. * Reads pixels from the current frame buffer. Please note that this function can be slow
  47617. * @param x defines the x coordinate of the rectangle where pixels must be read
  47618. * @param y defines the y coordinate of the rectangle where pixels must be read
  47619. * @param width defines the width of the rectangle where pixels must be read
  47620. * @param height defines the height of the rectangle where pixels must be read
  47621. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  47622. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  47623. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  47624. */
  47625. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  47626. /** @hidden */
  47627. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  47628. /** @hidden */
  47629. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  47630. /**
  47631. * Creates a new render target texture
  47632. * @param size defines the size of the texture
  47633. * @param options defines the options used to create the texture
  47634. * @returns a new render target texture stored in an InternalTexture
  47635. */
  47636. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47637. /**
  47638. * Create a multi render target texture
  47639. * @param size defines the size of the texture
  47640. * @param options defines the creation options
  47641. * @returns the cube texture as an InternalTexture
  47642. */
  47643. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47644. /**
  47645. * Creates a new render target cube texture
  47646. * @param size defines the size of the texture
  47647. * @param options defines the options used to create the texture
  47648. * @returns a new render target cube texture stored in an InternalTexture
  47649. */
  47650. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  47651. /** @hidden */
  47652. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  47653. width: number;
  47654. height: number;
  47655. layers?: number;
  47656. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  47657. /** @hidden */
  47658. _createDepthStencilTexture(size: number | {
  47659. width: number;
  47660. height: number;
  47661. layers?: number;
  47662. }, options: DepthTextureCreationOptions): InternalTexture;
  47663. /** @hidden */
  47664. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  47665. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  47666. /**
  47667. * Update the sample count for a given multiple render target texture
  47668. * @param textures defines the textures to update
  47669. * @param samples defines the sample count to set
  47670. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47671. */
  47672. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47673. /**
  47674. * Begin a new frame
  47675. */
  47676. beginFrame(): void;
  47677. /**
  47678. * End the current frame
  47679. */
  47680. endFrame(): void;
  47681. /**
  47682. * Force a WebGPU flush (ie. a flush of all waiting commands)
  47683. */
  47684. flushFramebuffer(): void;
  47685. private _startRenderTargetRenderPass;
  47686. private _endRenderTargetRenderPass;
  47687. private _getCurrentRenderPass;
  47688. private _startMainRenderPass;
  47689. private _endMainRenderPass;
  47690. /**
  47691. * Restores the WebGPU state to only draw on the main color attachment
  47692. */
  47693. restoreSingleAttachment(): void;
  47694. /**
  47695. * Creates a layout object to draw/clear on specific textures in a MRT
  47696. * @param textureStatus textureStatus[i] indicates if the i-th is active
  47697. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  47698. */
  47699. buildTextureLayout(textureStatus: boolean[]): number[];
  47700. /**
  47701. * Select a subsets of attachments to draw to.
  47702. * @param attachments index of attachments
  47703. */
  47704. bindAttachments(attachments: number[]): void;
  47705. /**
  47706. * Binds the frame buffer to the specified texture.
  47707. * @param texture The texture to render to or null for the default canvas
  47708. * @param faceIndex The face of the texture to render to in case of cube texture
  47709. * @param requiredWidth The width of the target to render to
  47710. * @param requiredHeight The height of the target to render to
  47711. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47712. * @param lodLevel defines the lod level to bind to the frame buffer
  47713. * @param layer defines the 2d array index to bind to frame buffer to
  47714. */
  47715. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  47716. /**
  47717. * Unbind the current render target texture from the WebGPU context
  47718. * @param texture defines the render target texture to unbind
  47719. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47720. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47721. */
  47722. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47723. /**
  47724. * Unbind a list of render target textures from the WebGPU context
  47725. * @param textures defines the render target textures to unbind
  47726. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47727. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47728. */
  47729. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47730. /**
  47731. * Unbind the current render target and bind the default framebuffer
  47732. */
  47733. restoreDefaultFramebuffer(): void;
  47734. private _setColorFormat;
  47735. private _setDepthTextureFormat;
  47736. setDitheringState(value: boolean): void;
  47737. setRasterizerState(value: boolean): void;
  47738. /**
  47739. * Set various states to the context
  47740. * @param culling defines backface culling state
  47741. * @param zOffset defines the value to apply to zOffset (0 by default)
  47742. * @param force defines if states must be applied even if cache is up to date
  47743. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47744. */
  47745. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47746. /**
  47747. * Sets the current alpha mode
  47748. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47749. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47750. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47751. */
  47752. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47753. /**
  47754. * Sets the current alpha equation
  47755. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  47756. */
  47757. setAlphaEquation(equation: number): void;
  47758. private _getBindGroupsToRender;
  47759. private _bindVertexInputs;
  47760. private _setRenderBindGroups;
  47761. private _setRenderPipeline;
  47762. /**
  47763. * Draw a list of indexed primitives
  47764. * @param fillMode defines the primitive to use
  47765. * @param indexStart defines the starting index
  47766. * @param indexCount defines the number of index to draw
  47767. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  47768. */
  47769. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47770. /**
  47771. * Draw a list of unindexed primitives
  47772. * @param fillMode defines the primitive to use
  47773. * @param verticesStart defines the index of first vertex to draw
  47774. * @param verticesCount defines the count of vertices to draw
  47775. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  47776. */
  47777. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47778. private _bundleEncoder;
  47779. /**
  47780. * Start recording all the gpu calls into a bundle.
  47781. */
  47782. startRecordBundle(): void;
  47783. /**
  47784. * Stops recording the bundle.
  47785. * @returns the recorded bundle
  47786. */
  47787. stopRecordBundle(): GPURenderBundle;
  47788. /**
  47789. * Execute the previously recorded bundle.
  47790. * @param bundles defines the bundle to replay
  47791. */
  47792. executeBundles(bundles: GPURenderBundle[]): void;
  47793. /**
  47794. * Dispose and release all associated resources
  47795. */
  47796. dispose(): void;
  47797. /**
  47798. * Gets the current render width
  47799. * @param useScreen defines if screen size must be used (or the current render target if any)
  47800. * @returns a number defining the current render width
  47801. */
  47802. getRenderWidth(useScreen?: boolean): number;
  47803. /**
  47804. * Gets the current render height
  47805. * @param useScreen defines if screen size must be used (or the current render target if any)
  47806. * @returns a number defining the current render height
  47807. */
  47808. getRenderHeight(useScreen?: boolean): number;
  47809. /**
  47810. * Gets the HTML canvas attached with the current WebGPU context
  47811. * @returns a HTML canvas
  47812. */
  47813. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  47814. /** @hidden */
  47815. _debugPushGroup(groupName: string, targetObject?: number): void;
  47816. /** @hidden */
  47817. _debugPopGroup(targetObject?: number): void;
  47818. /** @hidden */
  47819. _debugInsertMarker(text: string, targetObject?: number): void;
  47820. private _debugFlushPendingCommands;
  47821. /**
  47822. * Get the current error code of the WebGPU context
  47823. * @returns the error code
  47824. */
  47825. getError(): number;
  47826. /** @hidden */
  47827. bindSamplers(effect: Effect): void;
  47828. /** @hidden */
  47829. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  47830. /** @hidden */
  47831. _releaseFramebufferObjects(texture: InternalTexture): void;
  47832. /** @hidden */
  47833. applyStates(): void;
  47834. /**
  47835. * Gets a boolean indicating if all created effects are ready
  47836. * @returns always true - No parallel shader compilation
  47837. */
  47838. areAllEffectsReady(): boolean;
  47839. /** @hidden */
  47840. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47841. /** @hidden */
  47842. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47843. /** @hidden */
  47844. _getUnpackAlignement(): number;
  47845. /** @hidden */
  47846. _unpackFlipY(value: boolean): void;
  47847. /** @hidden */
  47848. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  47849. min: number;
  47850. mag: number;
  47851. };
  47852. /** @hidden */
  47853. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47854. /** @hidden */
  47855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47856. /** @hidden */
  47857. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47858. /** @hidden */
  47859. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47860. /** @hidden */
  47861. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47862. /** @hidden */
  47863. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47864. /** @hidden */
  47865. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  47866. /** @hidden */
  47867. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  47868. /** @hidden */
  47869. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  47870. /** @hidden */
  47871. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  47872. /** @hidden */
  47873. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  47874. /** @hidden */
  47875. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47876. /** @hidden */
  47877. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47878. /** @hidden */
  47879. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  47880. /** @hidden */
  47881. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  47882. /** @hidden */
  47883. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  47884. /** @hidden */
  47885. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  47886. }
  47887. }
  47888. declare module "babylonjs/scene" {
  47889. import { Nullable } from "babylonjs/types";
  47890. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47891. import { Observable } from "babylonjs/Misc/observable";
  47892. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47893. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  47894. import { Geometry } from "babylonjs/Meshes/geometry";
  47895. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47896. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47898. import { Mesh } from "babylonjs/Meshes/mesh";
  47899. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47900. import { Bone } from "babylonjs/Bones/bone";
  47901. import { Skeleton } from "babylonjs/Bones/skeleton";
  47902. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  47903. import { Camera } from "babylonjs/Cameras/camera";
  47904. import { AbstractScene } from "babylonjs/abstractScene";
  47905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47907. import { Material } from "babylonjs/Materials/material";
  47908. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47909. import { Effect } from "babylonjs/Materials/effect";
  47910. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47911. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  47912. import { Light } from "babylonjs/Lights/light";
  47913. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47914. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  47915. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  47916. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  47917. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  47918. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  47919. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  47920. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  47921. import { Engine } from "babylonjs/Engines/engine";
  47922. import { Node } from "babylonjs/node";
  47923. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  47924. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  47925. import { WebRequest } from "babylonjs/Misc/webRequest";
  47926. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  47927. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  47928. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47929. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  47930. import { Plane } from "babylonjs/Maths/math.plane";
  47931. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  47932. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  47933. import { Ray } from "babylonjs/Culling/ray";
  47934. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  47935. import { Animation } from "babylonjs/Animations/animation";
  47936. import { Animatable } from "babylonjs/Animations/animatable";
  47937. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47938. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  47939. import { Collider } from "babylonjs/Collisions/collider";
  47940. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47941. /**
  47942. * Define an interface for all classes that will hold resources
  47943. */
  47944. export interface IDisposable {
  47945. /**
  47946. * Releases all held resources
  47947. */
  47948. dispose(): void;
  47949. }
  47950. /** Interface defining initialization parameters for Scene class */
  47951. export interface SceneOptions {
  47952. /**
  47953. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  47954. * It will improve performance when the number of geometries becomes important.
  47955. */
  47956. useGeometryUniqueIdsMap?: boolean;
  47957. /**
  47958. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  47959. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47960. */
  47961. useMaterialMeshMap?: boolean;
  47962. /**
  47963. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  47964. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47965. */
  47966. useClonedMeshMap?: boolean;
  47967. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  47968. virtual?: boolean;
  47969. }
  47970. /**
  47971. * Represents a scene to be rendered by the engine.
  47972. * @see https://doc.babylonjs.com/features/scene
  47973. */
  47974. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  47975. /** The fog is deactivated */
  47976. static readonly FOGMODE_NONE: number;
  47977. /** The fog density is following an exponential function */
  47978. static readonly FOGMODE_EXP: number;
  47979. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  47980. static readonly FOGMODE_EXP2: number;
  47981. /** The fog density is following a linear function. */
  47982. static readonly FOGMODE_LINEAR: number;
  47983. /**
  47984. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  47985. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47986. */
  47987. static MinDeltaTime: number;
  47988. /**
  47989. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  47990. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47991. */
  47992. static MaxDeltaTime: number;
  47993. /**
  47994. * Factory used to create the default material.
  47995. * @param name The name of the material to create
  47996. * @param scene The scene to create the material for
  47997. * @returns The default material
  47998. */
  47999. static DefaultMaterialFactory(scene: Scene): Material;
  48000. /**
  48001. * Factory used to create the a collision coordinator.
  48002. * @returns The collision coordinator
  48003. */
  48004. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  48005. /** @hidden */
  48006. _inputManager: InputManager;
  48007. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  48008. cameraToUseForPointers: Nullable<Camera>;
  48009. /** @hidden */
  48010. readonly _isScene: boolean;
  48011. /** @hidden */
  48012. _blockEntityCollection: boolean;
  48013. /**
  48014. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  48015. */
  48016. autoClear: boolean;
  48017. /**
  48018. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  48019. */
  48020. autoClearDepthAndStencil: boolean;
  48021. /**
  48022. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  48023. */
  48024. clearColor: Color4;
  48025. /**
  48026. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  48027. */
  48028. ambientColor: Color3;
  48029. /**
  48030. * This is use to store the default BRDF lookup for PBR materials in your scene.
  48031. * It should only be one of the following (if not the default embedded one):
  48032. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48033. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  48034. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48035. * The material properties need to be setup according to the type of texture in use.
  48036. */
  48037. environmentBRDFTexture: BaseTexture;
  48038. /**
  48039. * Texture used in all pbr material as the reflection texture.
  48040. * As in the majority of the scene they are the same (exception for multi room and so on),
  48041. * this is easier to reference from here than from all the materials.
  48042. */
  48043. get environmentTexture(): Nullable<BaseTexture>;
  48044. /**
  48045. * Texture used in all pbr material as the reflection texture.
  48046. * As in the majority of the scene they are the same (exception for multi room and so on),
  48047. * this is easier to set here than in all the materials.
  48048. */
  48049. set environmentTexture(value: Nullable<BaseTexture>);
  48050. /** @hidden */
  48051. protected _environmentIntensity: number;
  48052. /**
  48053. * Intensity of the environment in all pbr material.
  48054. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  48055. * As in the majority of the scene they are the same (exception for multi room and so on),
  48056. * this is easier to reference from here than from all the materials.
  48057. */
  48058. get environmentIntensity(): number;
  48059. /**
  48060. * Intensity of the environment in all pbr material.
  48061. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  48062. * As in the majority of the scene they are the same (exception for multi room and so on),
  48063. * this is easier to set here than in all the materials.
  48064. */
  48065. set environmentIntensity(value: number);
  48066. /** @hidden */
  48067. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48068. /**
  48069. * Default image processing configuration used either in the rendering
  48070. * Forward main pass or through the imageProcessingPostProcess if present.
  48071. * As in the majority of the scene they are the same (exception for multi camera),
  48072. * this is easier to reference from here than from all the materials and post process.
  48073. *
  48074. * No setter as we it is a shared configuration, you can set the values instead.
  48075. */
  48076. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  48077. private _forceWireframe;
  48078. /**
  48079. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  48080. */
  48081. set forceWireframe(value: boolean);
  48082. get forceWireframe(): boolean;
  48083. private _skipFrustumClipping;
  48084. /**
  48085. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  48086. */
  48087. set skipFrustumClipping(value: boolean);
  48088. get skipFrustumClipping(): boolean;
  48089. private _forcePointsCloud;
  48090. /**
  48091. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  48092. */
  48093. set forcePointsCloud(value: boolean);
  48094. get forcePointsCloud(): boolean;
  48095. /**
  48096. * Gets or sets the active clipplane 1
  48097. */
  48098. clipPlane: Nullable<Plane>;
  48099. /**
  48100. * Gets or sets the active clipplane 2
  48101. */
  48102. clipPlane2: Nullable<Plane>;
  48103. /**
  48104. * Gets or sets the active clipplane 3
  48105. */
  48106. clipPlane3: Nullable<Plane>;
  48107. /**
  48108. * Gets or sets the active clipplane 4
  48109. */
  48110. clipPlane4: Nullable<Plane>;
  48111. /**
  48112. * Gets or sets the active clipplane 5
  48113. */
  48114. clipPlane5: Nullable<Plane>;
  48115. /**
  48116. * Gets or sets the active clipplane 6
  48117. */
  48118. clipPlane6: Nullable<Plane>;
  48119. /**
  48120. * Gets or sets a boolean indicating if animations are enabled
  48121. */
  48122. animationsEnabled: boolean;
  48123. private _animationPropertiesOverride;
  48124. /**
  48125. * Gets or sets the animation properties override
  48126. */
  48127. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  48128. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  48129. /**
  48130. * Gets or sets a boolean indicating if a constant deltatime has to be used
  48131. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  48132. */
  48133. useConstantAnimationDeltaTime: boolean;
  48134. /**
  48135. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  48136. * Please note that it requires to run a ray cast through the scene on every frame
  48137. */
  48138. constantlyUpdateMeshUnderPointer: boolean;
  48139. /**
  48140. * Defines the HTML cursor to use when hovering over interactive elements
  48141. */
  48142. hoverCursor: string;
  48143. /**
  48144. * Defines the HTML default cursor to use (empty by default)
  48145. */
  48146. defaultCursor: string;
  48147. /**
  48148. * Defines whether cursors are handled by the scene.
  48149. */
  48150. doNotHandleCursors: boolean;
  48151. /**
  48152. * This is used to call preventDefault() on pointer down
  48153. * in order to block unwanted artifacts like system double clicks
  48154. */
  48155. preventDefaultOnPointerDown: boolean;
  48156. /**
  48157. * This is used to call preventDefault() on pointer up
  48158. * in order to block unwanted artifacts like system double clicks
  48159. */
  48160. preventDefaultOnPointerUp: boolean;
  48161. /**
  48162. * Gets or sets user defined metadata
  48163. */
  48164. metadata: any;
  48165. /**
  48166. * For internal use only. Please do not use.
  48167. */
  48168. reservedDataStore: any;
  48169. /**
  48170. * Gets the name of the plugin used to load this scene (null by default)
  48171. */
  48172. loadingPluginName: string;
  48173. /**
  48174. * Use this array to add regular expressions used to disable offline support for specific urls
  48175. */
  48176. disableOfflineSupportExceptionRules: RegExp[];
  48177. /**
  48178. * An event triggered when the scene is disposed.
  48179. */
  48180. onDisposeObservable: Observable<Scene>;
  48181. private _onDisposeObserver;
  48182. /** Sets a function to be executed when this scene is disposed. */
  48183. set onDispose(callback: () => void);
  48184. /**
  48185. * An event triggered before rendering the scene (right after animations and physics)
  48186. */
  48187. onBeforeRenderObservable: Observable<Scene>;
  48188. private _onBeforeRenderObserver;
  48189. /** Sets a function to be executed before rendering this scene */
  48190. set beforeRender(callback: Nullable<() => void>);
  48191. /**
  48192. * An event triggered after rendering the scene
  48193. */
  48194. onAfterRenderObservable: Observable<Scene>;
  48195. /**
  48196. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  48197. */
  48198. onAfterRenderCameraObservable: Observable<Camera>;
  48199. private _onAfterRenderObserver;
  48200. /** Sets a function to be executed after rendering this scene */
  48201. set afterRender(callback: Nullable<() => void>);
  48202. /**
  48203. * An event triggered before animating the scene
  48204. */
  48205. onBeforeAnimationsObservable: Observable<Scene>;
  48206. /**
  48207. * An event triggered after animations processing
  48208. */
  48209. onAfterAnimationsObservable: Observable<Scene>;
  48210. /**
  48211. * An event triggered before draw calls are ready to be sent
  48212. */
  48213. onBeforeDrawPhaseObservable: Observable<Scene>;
  48214. /**
  48215. * An event triggered after draw calls have been sent
  48216. */
  48217. onAfterDrawPhaseObservable: Observable<Scene>;
  48218. /**
  48219. * An event triggered when the scene is ready
  48220. */
  48221. onReadyObservable: Observable<Scene>;
  48222. /**
  48223. * An event triggered before rendering a camera
  48224. */
  48225. onBeforeCameraRenderObservable: Observable<Camera>;
  48226. private _onBeforeCameraRenderObserver;
  48227. /** Sets a function to be executed before rendering a camera*/
  48228. set beforeCameraRender(callback: () => void);
  48229. /**
  48230. * An event triggered after rendering a camera
  48231. */
  48232. onAfterCameraRenderObservable: Observable<Camera>;
  48233. private _onAfterCameraRenderObserver;
  48234. /** Sets a function to be executed after rendering a camera*/
  48235. set afterCameraRender(callback: () => void);
  48236. /**
  48237. * An event triggered when active meshes evaluation is about to start
  48238. */
  48239. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  48240. /**
  48241. * An event triggered when active meshes evaluation is done
  48242. */
  48243. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  48244. /**
  48245. * An event triggered when particles rendering is about to start
  48246. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  48247. */
  48248. onBeforeParticlesRenderingObservable: Observable<Scene>;
  48249. /**
  48250. * An event triggered when particles rendering is done
  48251. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  48252. */
  48253. onAfterParticlesRenderingObservable: Observable<Scene>;
  48254. /**
  48255. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  48256. */
  48257. onDataLoadedObservable: Observable<Scene>;
  48258. /**
  48259. * An event triggered when a camera is created
  48260. */
  48261. onNewCameraAddedObservable: Observable<Camera>;
  48262. /**
  48263. * An event triggered when a camera is removed
  48264. */
  48265. onCameraRemovedObservable: Observable<Camera>;
  48266. /**
  48267. * An event triggered when a light is created
  48268. */
  48269. onNewLightAddedObservable: Observable<Light>;
  48270. /**
  48271. * An event triggered when a light is removed
  48272. */
  48273. onLightRemovedObservable: Observable<Light>;
  48274. /**
  48275. * An event triggered when a geometry is created
  48276. */
  48277. onNewGeometryAddedObservable: Observable<Geometry>;
  48278. /**
  48279. * An event triggered when a geometry is removed
  48280. */
  48281. onGeometryRemovedObservable: Observable<Geometry>;
  48282. /**
  48283. * An event triggered when a transform node is created
  48284. */
  48285. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  48286. /**
  48287. * An event triggered when a transform node is removed
  48288. */
  48289. onTransformNodeRemovedObservable: Observable<TransformNode>;
  48290. /**
  48291. * An event triggered when a mesh is created
  48292. */
  48293. onNewMeshAddedObservable: Observable<AbstractMesh>;
  48294. /**
  48295. * An event triggered when a mesh is removed
  48296. */
  48297. onMeshRemovedObservable: Observable<AbstractMesh>;
  48298. /**
  48299. * An event triggered when a skeleton is created
  48300. */
  48301. onNewSkeletonAddedObservable: Observable<Skeleton>;
  48302. /**
  48303. * An event triggered when a skeleton is removed
  48304. */
  48305. onSkeletonRemovedObservable: Observable<Skeleton>;
  48306. /**
  48307. * An event triggered when a material is created
  48308. */
  48309. onNewMaterialAddedObservable: Observable<Material>;
  48310. /**
  48311. * An event triggered when a multi material is created
  48312. */
  48313. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  48314. /**
  48315. * An event triggered when a material is removed
  48316. */
  48317. onMaterialRemovedObservable: Observable<Material>;
  48318. /**
  48319. * An event triggered when a multi material is removed
  48320. */
  48321. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  48322. /**
  48323. * An event triggered when a texture is created
  48324. */
  48325. onNewTextureAddedObservable: Observable<BaseTexture>;
  48326. /**
  48327. * An event triggered when a texture is removed
  48328. */
  48329. onTextureRemovedObservable: Observable<BaseTexture>;
  48330. /**
  48331. * An event triggered when render targets are about to be rendered
  48332. * Can happen multiple times per frame.
  48333. */
  48334. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  48335. /**
  48336. * An event triggered when render targets were rendered.
  48337. * Can happen multiple times per frame.
  48338. */
  48339. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  48340. /**
  48341. * An event triggered before calculating deterministic simulation step
  48342. */
  48343. onBeforeStepObservable: Observable<Scene>;
  48344. /**
  48345. * An event triggered after calculating deterministic simulation step
  48346. */
  48347. onAfterStepObservable: Observable<Scene>;
  48348. /**
  48349. * An event triggered when the activeCamera property is updated
  48350. */
  48351. onActiveCameraChanged: Observable<Scene>;
  48352. /**
  48353. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  48354. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  48355. * 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)
  48356. */
  48357. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  48358. /**
  48359. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  48360. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  48361. * 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)
  48362. */
  48363. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  48364. /**
  48365. * This Observable will when a mesh has been imported into the scene.
  48366. */
  48367. onMeshImportedObservable: Observable<AbstractMesh>;
  48368. /**
  48369. * This Observable will when an animation file has been imported into the scene.
  48370. */
  48371. onAnimationFileImportedObservable: Observable<Scene>;
  48372. /**
  48373. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  48374. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  48375. */
  48376. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  48377. /** @hidden */
  48378. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  48379. /**
  48380. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  48381. */
  48382. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  48383. /**
  48384. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  48385. */
  48386. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  48387. /**
  48388. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  48389. */
  48390. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  48391. /** Callback called when a pointer move is detected */
  48392. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  48393. /** Callback called when a pointer down is detected */
  48394. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  48395. /** Callback called when a pointer up is detected */
  48396. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  48397. /** Callback called when a pointer pick is detected */
  48398. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  48399. /**
  48400. * 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).
  48401. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  48402. */
  48403. onPrePointerObservable: Observable<PointerInfoPre>;
  48404. /**
  48405. * Observable event triggered each time an input event is received from the rendering canvas
  48406. */
  48407. onPointerObservable: Observable<PointerInfo>;
  48408. /**
  48409. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  48410. */
  48411. get unTranslatedPointer(): Vector2;
  48412. /**
  48413. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  48414. */
  48415. static get DragMovementThreshold(): number;
  48416. static set DragMovementThreshold(value: number);
  48417. /**
  48418. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  48419. */
  48420. static get LongPressDelay(): number;
  48421. static set LongPressDelay(value: number);
  48422. /**
  48423. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  48424. */
  48425. static get DoubleClickDelay(): number;
  48426. static set DoubleClickDelay(value: number);
  48427. /** If you need to check double click without raising a single click at first click, enable this flag */
  48428. static get ExclusiveDoubleClickMode(): boolean;
  48429. static set ExclusiveDoubleClickMode(value: boolean);
  48430. /** @hidden */
  48431. _mirroredCameraPosition: Nullable<Vector3>;
  48432. /**
  48433. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  48434. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  48435. */
  48436. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  48437. /**
  48438. * Observable event triggered each time an keyboard event is received from the hosting window
  48439. */
  48440. onKeyboardObservable: Observable<KeyboardInfo>;
  48441. private _useRightHandedSystem;
  48442. /**
  48443. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  48444. */
  48445. set useRightHandedSystem(value: boolean);
  48446. get useRightHandedSystem(): boolean;
  48447. private _timeAccumulator;
  48448. private _currentStepId;
  48449. private _currentInternalStep;
  48450. /**
  48451. * Sets the step Id used by deterministic lock step
  48452. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48453. * @param newStepId defines the step Id
  48454. */
  48455. setStepId(newStepId: number): void;
  48456. /**
  48457. * Gets the step Id used by deterministic lock step
  48458. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48459. * @returns the step Id
  48460. */
  48461. getStepId(): number;
  48462. /**
  48463. * Gets the internal step used by deterministic lock step
  48464. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48465. * @returns the internal step
  48466. */
  48467. getInternalStep(): number;
  48468. private _fogEnabled;
  48469. /**
  48470. * Gets or sets a boolean indicating if fog is enabled on this scene
  48471. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48472. * (Default is true)
  48473. */
  48474. set fogEnabled(value: boolean);
  48475. get fogEnabled(): boolean;
  48476. private _fogMode;
  48477. /**
  48478. * Gets or sets the fog mode to use
  48479. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48480. * | mode | value |
  48481. * | --- | --- |
  48482. * | FOGMODE_NONE | 0 |
  48483. * | FOGMODE_EXP | 1 |
  48484. * | FOGMODE_EXP2 | 2 |
  48485. * | FOGMODE_LINEAR | 3 |
  48486. */
  48487. set fogMode(value: number);
  48488. get fogMode(): number;
  48489. /**
  48490. * Gets or sets the fog color to use
  48491. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48492. * (Default is Color3(0.2, 0.2, 0.3))
  48493. */
  48494. fogColor: Color3;
  48495. /**
  48496. * Gets or sets the fog density to use
  48497. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48498. * (Default is 0.1)
  48499. */
  48500. fogDensity: number;
  48501. /**
  48502. * Gets or sets the fog start distance to use
  48503. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48504. * (Default is 0)
  48505. */
  48506. fogStart: number;
  48507. /**
  48508. * Gets or sets the fog end distance to use
  48509. * @see https://doc.babylonjs.com/babylon101/environment#fog
  48510. * (Default is 1000)
  48511. */
  48512. fogEnd: number;
  48513. /**
  48514. * Flag indicating that the frame buffer binding is handled by another component
  48515. */
  48516. get prePass(): boolean;
  48517. private _shadowsEnabled;
  48518. /**
  48519. * Gets or sets a boolean indicating if shadows are enabled on this scene
  48520. */
  48521. set shadowsEnabled(value: boolean);
  48522. get shadowsEnabled(): boolean;
  48523. private _lightsEnabled;
  48524. /**
  48525. * Gets or sets a boolean indicating if lights are enabled on this scene
  48526. */
  48527. set lightsEnabled(value: boolean);
  48528. get lightsEnabled(): boolean;
  48529. /** All of the active cameras added to this scene. */
  48530. activeCameras: Nullable<Camera[]>;
  48531. /** @hidden */
  48532. _activeCamera: Nullable<Camera>;
  48533. /** Gets or sets the current active camera */
  48534. get activeCamera(): Nullable<Camera>;
  48535. set activeCamera(value: Nullable<Camera>);
  48536. private _defaultMaterial;
  48537. /** The default material used on meshes when no material is affected */
  48538. get defaultMaterial(): Material;
  48539. /** The default material used on meshes when no material is affected */
  48540. set defaultMaterial(value: Material);
  48541. private _texturesEnabled;
  48542. /**
  48543. * Gets or sets a boolean indicating if textures are enabled on this scene
  48544. */
  48545. set texturesEnabled(value: boolean);
  48546. get texturesEnabled(): boolean;
  48547. /**
  48548. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  48549. */
  48550. physicsEnabled: boolean;
  48551. /**
  48552. * Gets or sets a boolean indicating if particles are enabled on this scene
  48553. */
  48554. particlesEnabled: boolean;
  48555. /**
  48556. * Gets or sets a boolean indicating if sprites are enabled on this scene
  48557. */
  48558. spritesEnabled: boolean;
  48559. private _skeletonsEnabled;
  48560. /**
  48561. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  48562. */
  48563. set skeletonsEnabled(value: boolean);
  48564. get skeletonsEnabled(): boolean;
  48565. /**
  48566. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  48567. */
  48568. lensFlaresEnabled: boolean;
  48569. /**
  48570. * Gets or sets a boolean indicating if collisions are enabled on this scene
  48571. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  48572. */
  48573. collisionsEnabled: boolean;
  48574. private _collisionCoordinator;
  48575. /** @hidden */
  48576. get collisionCoordinator(): ICollisionCoordinator;
  48577. /**
  48578. * Defines the gravity applied to this scene (used only for collisions)
  48579. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  48580. */
  48581. gravity: Vector3;
  48582. /**
  48583. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  48584. */
  48585. postProcessesEnabled: boolean;
  48586. /**
  48587. * Gets the current postprocess manager
  48588. */
  48589. postProcessManager: PostProcessManager;
  48590. /**
  48591. * Gets or sets a boolean indicating if render targets are enabled on this scene
  48592. */
  48593. renderTargetsEnabled: boolean;
  48594. /**
  48595. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  48596. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  48597. */
  48598. dumpNextRenderTargets: boolean;
  48599. /**
  48600. * The list of user defined render targets added to the scene
  48601. */
  48602. customRenderTargets: RenderTargetTexture[];
  48603. /**
  48604. * Defines if texture loading must be delayed
  48605. * If true, textures will only be loaded when they need to be rendered
  48606. */
  48607. useDelayedTextureLoading: boolean;
  48608. /**
  48609. * Gets the list of meshes imported to the scene through SceneLoader
  48610. */
  48611. importedMeshesFiles: String[];
  48612. /**
  48613. * Gets or sets a boolean indicating if probes are enabled on this scene
  48614. */
  48615. probesEnabled: boolean;
  48616. /**
  48617. * Gets or sets the current offline provider to use to store scene data
  48618. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  48619. */
  48620. offlineProvider: IOfflineProvider;
  48621. /**
  48622. * Gets or sets the action manager associated with the scene
  48623. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48624. */
  48625. actionManager: AbstractActionManager;
  48626. private _meshesForIntersections;
  48627. /**
  48628. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  48629. */
  48630. proceduralTexturesEnabled: boolean;
  48631. private _engine;
  48632. private _totalVertices;
  48633. /** @hidden */
  48634. _activeIndices: PerfCounter;
  48635. /** @hidden */
  48636. _activeParticles: PerfCounter;
  48637. /** @hidden */
  48638. _activeBones: PerfCounter;
  48639. private _animationRatio;
  48640. /** @hidden */
  48641. _animationTimeLast: number;
  48642. /** @hidden */
  48643. _animationTime: number;
  48644. /**
  48645. * Gets or sets a general scale for animation speed
  48646. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  48647. */
  48648. animationTimeScale: number;
  48649. /** @hidden */
  48650. _cachedMaterial: Nullable<Material>;
  48651. /** @hidden */
  48652. _cachedEffect: Nullable<Effect>;
  48653. /** @hidden */
  48654. _cachedVisibility: Nullable<number>;
  48655. private _renderId;
  48656. private _frameId;
  48657. private _executeWhenReadyTimeoutId;
  48658. private _intermediateRendering;
  48659. private _viewUpdateFlag;
  48660. private _projectionUpdateFlag;
  48661. /** @hidden */
  48662. _toBeDisposed: Nullable<IDisposable>[];
  48663. private _activeRequests;
  48664. /** @hidden */
  48665. _pendingData: any[];
  48666. private _isDisposed;
  48667. /**
  48668. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  48669. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  48670. */
  48671. dispatchAllSubMeshesOfActiveMeshes: boolean;
  48672. private _activeMeshes;
  48673. private _processedMaterials;
  48674. private _renderTargets;
  48675. /** @hidden */
  48676. _activeParticleSystems: SmartArray<IParticleSystem>;
  48677. private _activeSkeletons;
  48678. private _softwareSkinnedMeshes;
  48679. private _renderingManager;
  48680. /** @hidden */
  48681. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  48682. private _transformMatrix;
  48683. private _sceneUbo;
  48684. /** @hidden */
  48685. _viewMatrix: Matrix;
  48686. /** @hidden */
  48687. _projectionMatrix: Matrix;
  48688. /** @hidden */
  48689. _forcedViewPosition: Nullable<Vector3>;
  48690. /** @hidden */
  48691. _frustumPlanes: Plane[];
  48692. /**
  48693. * Gets the list of frustum planes (built from the active camera)
  48694. */
  48695. get frustumPlanes(): Plane[];
  48696. /**
  48697. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  48698. * This is useful if there are more lights that the maximum simulteanous authorized
  48699. */
  48700. requireLightSorting: boolean;
  48701. /** @hidden */
  48702. readonly useMaterialMeshMap: boolean;
  48703. /** @hidden */
  48704. readonly useClonedMeshMap: boolean;
  48705. private _externalData;
  48706. private _uid;
  48707. /**
  48708. * @hidden
  48709. * Backing store of defined scene components.
  48710. */
  48711. _components: ISceneComponent[];
  48712. /**
  48713. * @hidden
  48714. * Backing store of defined scene components.
  48715. */
  48716. _serializableComponents: ISceneSerializableComponent[];
  48717. /**
  48718. * List of components to register on the next registration step.
  48719. */
  48720. private _transientComponents;
  48721. /**
  48722. * Registers the transient components if needed.
  48723. */
  48724. private _registerTransientComponents;
  48725. /**
  48726. * @hidden
  48727. * Add a component to the scene.
  48728. * Note that the ccomponent could be registered on th next frame if this is called after
  48729. * the register component stage.
  48730. * @param component Defines the component to add to the scene
  48731. */
  48732. _addComponent(component: ISceneComponent): void;
  48733. /**
  48734. * @hidden
  48735. * Gets a component from the scene.
  48736. * @param name defines the name of the component to retrieve
  48737. * @returns the component or null if not present
  48738. */
  48739. _getComponent(name: string): Nullable<ISceneComponent>;
  48740. /**
  48741. * @hidden
  48742. * Defines the actions happening before camera updates.
  48743. */
  48744. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  48745. /**
  48746. * @hidden
  48747. * Defines the actions happening before clear the canvas.
  48748. */
  48749. _beforeClearStage: Stage<SimpleStageAction>;
  48750. /**
  48751. * @hidden
  48752. * Defines the actions happening before clear the canvas.
  48753. */
  48754. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  48755. /**
  48756. * @hidden
  48757. * Defines the actions when collecting render targets for the frame.
  48758. */
  48759. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48760. /**
  48761. * @hidden
  48762. * Defines the actions happening for one camera in the frame.
  48763. */
  48764. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48765. /**
  48766. * @hidden
  48767. * Defines the actions happening during the per mesh ready checks.
  48768. */
  48769. _isReadyForMeshStage: Stage<MeshStageAction>;
  48770. /**
  48771. * @hidden
  48772. * Defines the actions happening before evaluate active mesh checks.
  48773. */
  48774. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  48775. /**
  48776. * @hidden
  48777. * Defines the actions happening during the evaluate sub mesh checks.
  48778. */
  48779. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  48780. /**
  48781. * @hidden
  48782. * Defines the actions happening during the active mesh stage.
  48783. */
  48784. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  48785. /**
  48786. * @hidden
  48787. * Defines the actions happening during the per camera render target step.
  48788. */
  48789. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  48790. /**
  48791. * @hidden
  48792. * Defines the actions happening just before the active camera is drawing.
  48793. */
  48794. _beforeCameraDrawStage: Stage<CameraStageAction>;
  48795. /**
  48796. * @hidden
  48797. * Defines the actions happening just before a render target is drawing.
  48798. */
  48799. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48800. /**
  48801. * @hidden
  48802. * Defines the actions happening just before a rendering group is drawing.
  48803. */
  48804. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48805. /**
  48806. * @hidden
  48807. * Defines the actions happening just before a mesh is drawing.
  48808. */
  48809. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48810. /**
  48811. * @hidden
  48812. * Defines the actions happening just after a mesh has been drawn.
  48813. */
  48814. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48815. /**
  48816. * @hidden
  48817. * Defines the actions happening just after a rendering group has been drawn.
  48818. */
  48819. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48820. /**
  48821. * @hidden
  48822. * Defines the actions happening just after the active camera has been drawn.
  48823. */
  48824. _afterCameraDrawStage: Stage<CameraStageAction>;
  48825. /**
  48826. * @hidden
  48827. * Defines the actions happening just after a render target has been drawn.
  48828. */
  48829. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48830. /**
  48831. * @hidden
  48832. * Defines the actions happening just after rendering all cameras and computing intersections.
  48833. */
  48834. _afterRenderStage: Stage<SimpleStageAction>;
  48835. /**
  48836. * @hidden
  48837. * Defines the actions happening when a pointer move event happens.
  48838. */
  48839. _pointerMoveStage: Stage<PointerMoveStageAction>;
  48840. /**
  48841. * @hidden
  48842. * Defines the actions happening when a pointer down event happens.
  48843. */
  48844. _pointerDownStage: Stage<PointerUpDownStageAction>;
  48845. /**
  48846. * @hidden
  48847. * Defines the actions happening when a pointer up event happens.
  48848. */
  48849. _pointerUpStage: Stage<PointerUpDownStageAction>;
  48850. /**
  48851. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  48852. */
  48853. private geometriesByUniqueId;
  48854. private _renderBundles;
  48855. /**
  48856. * Creates a new Scene
  48857. * @param engine defines the engine to use to render this scene
  48858. * @param options defines the scene options
  48859. */
  48860. constructor(engine: Engine, options?: SceneOptions);
  48861. /**
  48862. * Gets a string identifying the name of the class
  48863. * @returns "Scene" string
  48864. */
  48865. getClassName(): string;
  48866. private _defaultMeshCandidates;
  48867. /**
  48868. * @hidden
  48869. */
  48870. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48871. private _defaultSubMeshCandidates;
  48872. /**
  48873. * @hidden
  48874. */
  48875. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48876. /**
  48877. * Sets the default candidate providers for the scene.
  48878. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  48879. * and getCollidingSubMeshCandidates to their default function
  48880. */
  48881. setDefaultCandidateProviders(): void;
  48882. /**
  48883. * Gets the mesh that is currently under the pointer
  48884. */
  48885. get meshUnderPointer(): Nullable<AbstractMesh>;
  48886. /**
  48887. * Gets or sets the current on-screen X position of the pointer
  48888. */
  48889. get pointerX(): number;
  48890. set pointerX(value: number);
  48891. /**
  48892. * Gets or sets the current on-screen Y position of the pointer
  48893. */
  48894. get pointerY(): number;
  48895. set pointerY(value: number);
  48896. /**
  48897. * Gets the cached material (ie. the latest rendered one)
  48898. * @returns the cached material
  48899. */
  48900. getCachedMaterial(): Nullable<Material>;
  48901. /**
  48902. * Gets the cached effect (ie. the latest rendered one)
  48903. * @returns the cached effect
  48904. */
  48905. getCachedEffect(): Nullable<Effect>;
  48906. /**
  48907. * Gets the cached visibility state (ie. the latest rendered one)
  48908. * @returns the cached visibility state
  48909. */
  48910. getCachedVisibility(): Nullable<number>;
  48911. /**
  48912. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  48913. * @param material defines the current material
  48914. * @param effect defines the current effect
  48915. * @param visibility defines the current visibility state
  48916. * @returns true if one parameter is not cached
  48917. */
  48918. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  48919. /**
  48920. * Gets the engine associated with the scene
  48921. * @returns an Engine
  48922. */
  48923. getEngine(): Engine;
  48924. /**
  48925. * Gets the total number of vertices rendered per frame
  48926. * @returns the total number of vertices rendered per frame
  48927. */
  48928. getTotalVertices(): number;
  48929. /**
  48930. * Gets the performance counter for total vertices
  48931. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48932. */
  48933. get totalVerticesPerfCounter(): PerfCounter;
  48934. /**
  48935. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  48936. * @returns the total number of active indices rendered per frame
  48937. */
  48938. getActiveIndices(): number;
  48939. /**
  48940. * Gets the performance counter for active indices
  48941. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48942. */
  48943. get totalActiveIndicesPerfCounter(): PerfCounter;
  48944. /**
  48945. * Gets the total number of active particles rendered per frame
  48946. * @returns the total number of active particles rendered per frame
  48947. */
  48948. getActiveParticles(): number;
  48949. /**
  48950. * Gets the performance counter for active particles
  48951. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48952. */
  48953. get activeParticlesPerfCounter(): PerfCounter;
  48954. /**
  48955. * Gets the total number of active bones rendered per frame
  48956. * @returns the total number of active bones rendered per frame
  48957. */
  48958. getActiveBones(): number;
  48959. /**
  48960. * Gets the performance counter for active bones
  48961. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48962. */
  48963. get activeBonesPerfCounter(): PerfCounter;
  48964. /**
  48965. * Gets the array of active meshes
  48966. * @returns an array of AbstractMesh
  48967. */
  48968. getActiveMeshes(): SmartArray<AbstractMesh>;
  48969. /**
  48970. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  48971. * @returns a number
  48972. */
  48973. getAnimationRatio(): number;
  48974. /**
  48975. * Gets an unique Id for the current render phase
  48976. * @returns a number
  48977. */
  48978. getRenderId(): number;
  48979. /**
  48980. * Gets an unique Id for the current frame
  48981. * @returns a number
  48982. */
  48983. getFrameId(): number;
  48984. /** Call this function if you want to manually increment the render Id*/
  48985. incrementRenderId(): void;
  48986. private _createUbo;
  48987. /**
  48988. * Use this method to simulate a pointer move on a mesh
  48989. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48990. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48991. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48992. * @returns the current scene
  48993. */
  48994. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48995. /**
  48996. * Use this method to simulate a pointer down on a mesh
  48997. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48998. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48999. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  49000. * @returns the current scene
  49001. */
  49002. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  49003. /**
  49004. * Use this method to simulate a pointer up on a mesh
  49005. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  49006. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  49007. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  49008. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  49009. * @returns the current scene
  49010. */
  49011. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  49012. /**
  49013. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  49014. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  49015. * @returns true if the pointer was captured
  49016. */
  49017. isPointerCaptured(pointerId?: number): boolean;
  49018. /**
  49019. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  49020. * @param attachUp defines if you want to attach events to pointerup
  49021. * @param attachDown defines if you want to attach events to pointerdown
  49022. * @param attachMove defines if you want to attach events to pointermove
  49023. */
  49024. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  49025. /** Detaches all event handlers*/
  49026. detachControl(): void;
  49027. /**
  49028. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  49029. * Delay loaded resources are not taking in account
  49030. * @return true if all required resources are ready
  49031. */
  49032. isReady(): boolean;
  49033. /** Resets all cached information relative to material (including effect and visibility) */
  49034. resetCachedMaterial(): void;
  49035. /**
  49036. * Registers a function to be called before every frame render
  49037. * @param func defines the function to register
  49038. */
  49039. registerBeforeRender(func: () => void): void;
  49040. /**
  49041. * Unregisters a function called before every frame render
  49042. * @param func defines the function to unregister
  49043. */
  49044. unregisterBeforeRender(func: () => void): void;
  49045. /**
  49046. * Registers a function to be called after every frame render
  49047. * @param func defines the function to register
  49048. */
  49049. registerAfterRender(func: () => void): void;
  49050. /**
  49051. * Unregisters a function called after every frame render
  49052. * @param func defines the function to unregister
  49053. */
  49054. unregisterAfterRender(func: () => void): void;
  49055. private _executeOnceBeforeRender;
  49056. /**
  49057. * The provided function will run before render once and will be disposed afterwards.
  49058. * A timeout delay can be provided so that the function will be executed in N ms.
  49059. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  49060. * @param func The function to be executed.
  49061. * @param timeout optional delay in ms
  49062. */
  49063. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  49064. /** @hidden */
  49065. _addPendingData(data: any): void;
  49066. /** @hidden */
  49067. _removePendingData(data: any): void;
  49068. /**
  49069. * Returns the number of items waiting to be loaded
  49070. * @returns the number of items waiting to be loaded
  49071. */
  49072. getWaitingItemsCount(): number;
  49073. /**
  49074. * Returns a boolean indicating if the scene is still loading data
  49075. */
  49076. get isLoading(): boolean;
  49077. /**
  49078. * Registers a function to be executed when the scene is ready
  49079. * @param {Function} func - the function to be executed
  49080. */
  49081. executeWhenReady(func: () => void): void;
  49082. /**
  49083. * Returns a promise that resolves when the scene is ready
  49084. * @returns A promise that resolves when the scene is ready
  49085. */
  49086. whenReadyAsync(): Promise<void>;
  49087. /** @hidden */
  49088. _checkIsReady(): void;
  49089. /**
  49090. * Gets all animatable attached to the scene
  49091. */
  49092. get animatables(): Animatable[];
  49093. /**
  49094. * Resets the last animation time frame.
  49095. * Useful to override when animations start running when loading a scene for the first time.
  49096. */
  49097. resetLastAnimationTimeFrame(): void;
  49098. /**
  49099. * Gets the current view matrix
  49100. * @returns a Matrix
  49101. */
  49102. getViewMatrix(): Matrix;
  49103. /**
  49104. * Gets the current projection matrix
  49105. * @returns a Matrix
  49106. */
  49107. getProjectionMatrix(): Matrix;
  49108. /**
  49109. * Gets the current transform matrix
  49110. * @returns a Matrix made of View * Projection
  49111. */
  49112. getTransformMatrix(): Matrix;
  49113. /**
  49114. * Sets the current transform matrix
  49115. * @param viewL defines the View matrix to use
  49116. * @param projectionL defines the Projection matrix to use
  49117. * @param viewR defines the right View matrix to use (if provided)
  49118. * @param projectionR defines the right Projection matrix to use (if provided)
  49119. */
  49120. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  49121. /**
  49122. * Gets the uniform buffer used to store scene data
  49123. * @returns a UniformBuffer
  49124. */
  49125. getSceneUniformBuffer(): UniformBuffer;
  49126. /**
  49127. * Gets an unique (relatively to the current scene) Id
  49128. * @returns an unique number for the scene
  49129. */
  49130. getUniqueId(): number;
  49131. /**
  49132. * Add a mesh to the list of scene's meshes
  49133. * @param newMesh defines the mesh to add
  49134. * @param recursive if all child meshes should also be added to the scene
  49135. */
  49136. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  49137. /**
  49138. * Remove a mesh for the list of scene's meshes
  49139. * @param toRemove defines the mesh to remove
  49140. * @param recursive if all child meshes should also be removed from the scene
  49141. * @returns the index where the mesh was in the mesh list
  49142. */
  49143. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  49144. /**
  49145. * Add a transform node to the list of scene's transform nodes
  49146. * @param newTransformNode defines the transform node to add
  49147. */
  49148. addTransformNode(newTransformNode: TransformNode): void;
  49149. /**
  49150. * Remove a transform node for the list of scene's transform nodes
  49151. * @param toRemove defines the transform node to remove
  49152. * @returns the index where the transform node was in the transform node list
  49153. */
  49154. removeTransformNode(toRemove: TransformNode): number;
  49155. /**
  49156. * Remove a skeleton for the list of scene's skeletons
  49157. * @param toRemove defines the skeleton to remove
  49158. * @returns the index where the skeleton was in the skeleton list
  49159. */
  49160. removeSkeleton(toRemove: Skeleton): number;
  49161. /**
  49162. * Remove a morph target for the list of scene's morph targets
  49163. * @param toRemove defines the morph target to remove
  49164. * @returns the index where the morph target was in the morph target list
  49165. */
  49166. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  49167. /**
  49168. * Remove a light for the list of scene's lights
  49169. * @param toRemove defines the light to remove
  49170. * @returns the index where the light was in the light list
  49171. */
  49172. removeLight(toRemove: Light): number;
  49173. /**
  49174. * Remove a camera for the list of scene's cameras
  49175. * @param toRemove defines the camera to remove
  49176. * @returns the index where the camera was in the camera list
  49177. */
  49178. removeCamera(toRemove: Camera): number;
  49179. /**
  49180. * Remove a particle system for the list of scene's particle systems
  49181. * @param toRemove defines the particle system to remove
  49182. * @returns the index where the particle system was in the particle system list
  49183. */
  49184. removeParticleSystem(toRemove: IParticleSystem): number;
  49185. /**
  49186. * Remove a animation for the list of scene's animations
  49187. * @param toRemove defines the animation to remove
  49188. * @returns the index where the animation was in the animation list
  49189. */
  49190. removeAnimation(toRemove: Animation): number;
  49191. /**
  49192. * Will stop the animation of the given target
  49193. * @param target - the target
  49194. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  49195. * @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)
  49196. */
  49197. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  49198. /**
  49199. * Removes the given animation group from this scene.
  49200. * @param toRemove The animation group to remove
  49201. * @returns The index of the removed animation group
  49202. */
  49203. removeAnimationGroup(toRemove: AnimationGroup): number;
  49204. /**
  49205. * Removes the given multi-material from this scene.
  49206. * @param toRemove The multi-material to remove
  49207. * @returns The index of the removed multi-material
  49208. */
  49209. removeMultiMaterial(toRemove: MultiMaterial): number;
  49210. /**
  49211. * Removes the given material from this scene.
  49212. * @param toRemove The material to remove
  49213. * @returns The index of the removed material
  49214. */
  49215. removeMaterial(toRemove: Material): number;
  49216. /**
  49217. * Removes the given action manager from this scene.
  49218. * @param toRemove The action manager to remove
  49219. * @returns The index of the removed action manager
  49220. */
  49221. removeActionManager(toRemove: AbstractActionManager): number;
  49222. /**
  49223. * Removes the given texture from this scene.
  49224. * @param toRemove The texture to remove
  49225. * @returns The index of the removed texture
  49226. */
  49227. removeTexture(toRemove: BaseTexture): number;
  49228. /**
  49229. * Adds the given light to this scene
  49230. * @param newLight The light to add
  49231. */
  49232. addLight(newLight: Light): void;
  49233. /**
  49234. * Sorts the list list based on light priorities
  49235. */
  49236. sortLightsByPriority(): void;
  49237. /**
  49238. * Adds the given camera to this scene
  49239. * @param newCamera The camera to add
  49240. */
  49241. addCamera(newCamera: Camera): void;
  49242. /**
  49243. * Adds the given skeleton to this scene
  49244. * @param newSkeleton The skeleton to add
  49245. */
  49246. addSkeleton(newSkeleton: Skeleton): void;
  49247. /**
  49248. * Adds the given particle system to this scene
  49249. * @param newParticleSystem The particle system to add
  49250. */
  49251. addParticleSystem(newParticleSystem: IParticleSystem): void;
  49252. /**
  49253. * Adds the given animation to this scene
  49254. * @param newAnimation The animation to add
  49255. */
  49256. addAnimation(newAnimation: Animation): void;
  49257. /**
  49258. * Adds the given animation group to this scene.
  49259. * @param newAnimationGroup The animation group to add
  49260. */
  49261. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  49262. /**
  49263. * Adds the given multi-material to this scene
  49264. * @param newMultiMaterial The multi-material to add
  49265. */
  49266. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  49267. /**
  49268. * Adds the given material to this scene
  49269. * @param newMaterial The material to add
  49270. */
  49271. addMaterial(newMaterial: Material): void;
  49272. /**
  49273. * Adds the given morph target to this scene
  49274. * @param newMorphTargetManager The morph target to add
  49275. */
  49276. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  49277. /**
  49278. * Adds the given geometry to this scene
  49279. * @param newGeometry The geometry to add
  49280. */
  49281. addGeometry(newGeometry: Geometry): void;
  49282. /**
  49283. * Adds the given action manager to this scene
  49284. * @param newActionManager The action manager to add
  49285. */
  49286. addActionManager(newActionManager: AbstractActionManager): void;
  49287. /**
  49288. * Adds the given texture to this scene.
  49289. * @param newTexture The texture to add
  49290. */
  49291. addTexture(newTexture: BaseTexture): void;
  49292. /**
  49293. * Switch active camera
  49294. * @param newCamera defines the new active camera
  49295. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  49296. */
  49297. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  49298. /**
  49299. * sets the active camera of the scene using its ID
  49300. * @param id defines the camera's ID
  49301. * @return the new active camera or null if none found.
  49302. */
  49303. setActiveCameraByID(id: string): Nullable<Camera>;
  49304. /**
  49305. * sets the active camera of the scene using its name
  49306. * @param name defines the camera's name
  49307. * @returns the new active camera or null if none found.
  49308. */
  49309. setActiveCameraByName(name: string): Nullable<Camera>;
  49310. /**
  49311. * get an animation group using its name
  49312. * @param name defines the material's name
  49313. * @return the animation group or null if none found.
  49314. */
  49315. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  49316. /**
  49317. * Get a material using its unique id
  49318. * @param uniqueId defines the material's unique id
  49319. * @return the material or null if none found.
  49320. */
  49321. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  49322. /**
  49323. * get a material using its id
  49324. * @param id defines the material's ID
  49325. * @return the material or null if none found.
  49326. */
  49327. getMaterialByID(id: string): Nullable<Material>;
  49328. /**
  49329. * Gets a the last added material using a given id
  49330. * @param id defines the material's ID
  49331. * @return the last material with the given id or null if none found.
  49332. */
  49333. getLastMaterialByID(id: string): Nullable<Material>;
  49334. /**
  49335. * Gets a material using its name
  49336. * @param name defines the material's name
  49337. * @return the material or null if none found.
  49338. */
  49339. getMaterialByName(name: string): Nullable<Material>;
  49340. /**
  49341. * Get a texture using its unique id
  49342. * @param uniqueId defines the texture's unique id
  49343. * @return the texture or null if none found.
  49344. */
  49345. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  49346. /**
  49347. * Gets a camera using its id
  49348. * @param id defines the id to look for
  49349. * @returns the camera or null if not found
  49350. */
  49351. getCameraByID(id: string): Nullable<Camera>;
  49352. /**
  49353. * Gets a camera using its unique id
  49354. * @param uniqueId defines the unique id to look for
  49355. * @returns the camera or null if not found
  49356. */
  49357. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  49358. /**
  49359. * Gets a camera using its name
  49360. * @param name defines the camera's name
  49361. * @return the camera or null if none found.
  49362. */
  49363. getCameraByName(name: string): Nullable<Camera>;
  49364. /**
  49365. * Gets a bone using its id
  49366. * @param id defines the bone's id
  49367. * @return the bone or null if not found
  49368. */
  49369. getBoneByID(id: string): Nullable<Bone>;
  49370. /**
  49371. * Gets a bone using its id
  49372. * @param name defines the bone's name
  49373. * @return the bone or null if not found
  49374. */
  49375. getBoneByName(name: string): Nullable<Bone>;
  49376. /**
  49377. * Gets a light node using its name
  49378. * @param name defines the the light's name
  49379. * @return the light or null if none found.
  49380. */
  49381. getLightByName(name: string): Nullable<Light>;
  49382. /**
  49383. * Gets a light node using its id
  49384. * @param id defines the light's id
  49385. * @return the light or null if none found.
  49386. */
  49387. getLightByID(id: string): Nullable<Light>;
  49388. /**
  49389. * Gets a light node using its scene-generated unique ID
  49390. * @param uniqueId defines the light's unique id
  49391. * @return the light or null if none found.
  49392. */
  49393. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  49394. /**
  49395. * Gets a particle system by id
  49396. * @param id defines the particle system id
  49397. * @return the corresponding system or null if none found
  49398. */
  49399. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  49400. /**
  49401. * Gets a geometry using its ID
  49402. * @param id defines the geometry's id
  49403. * @return the geometry or null if none found.
  49404. */
  49405. getGeometryByID(id: string): Nullable<Geometry>;
  49406. private _getGeometryByUniqueID;
  49407. /**
  49408. * Add a new geometry to this scene
  49409. * @param geometry defines the geometry to be added to the scene.
  49410. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  49411. * @return a boolean defining if the geometry was added or not
  49412. */
  49413. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  49414. /**
  49415. * Removes an existing geometry
  49416. * @param geometry defines the geometry to be removed from the scene
  49417. * @return a boolean defining if the geometry was removed or not
  49418. */
  49419. removeGeometry(geometry: Geometry): boolean;
  49420. /**
  49421. * Gets the list of geometries attached to the scene
  49422. * @returns an array of Geometry
  49423. */
  49424. getGeometries(): Geometry[];
  49425. /**
  49426. * Gets the first added mesh found of a given ID
  49427. * @param id defines the id to search for
  49428. * @return the mesh found or null if not found at all
  49429. */
  49430. getMeshByID(id: string): Nullable<AbstractMesh>;
  49431. /**
  49432. * Gets a list of meshes using their id
  49433. * @param id defines the id to search for
  49434. * @returns a list of meshes
  49435. */
  49436. getMeshesByID(id: string): Array<AbstractMesh>;
  49437. /**
  49438. * Gets the first added transform node found of a given ID
  49439. * @param id defines the id to search for
  49440. * @return the found transform node or null if not found at all.
  49441. */
  49442. getTransformNodeByID(id: string): Nullable<TransformNode>;
  49443. /**
  49444. * Gets a transform node with its auto-generated unique id
  49445. * @param uniqueId efines the unique id to search for
  49446. * @return the found transform node or null if not found at all.
  49447. */
  49448. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  49449. /**
  49450. * Gets a list of transform nodes using their id
  49451. * @param id defines the id to search for
  49452. * @returns a list of transform nodes
  49453. */
  49454. getTransformNodesByID(id: string): Array<TransformNode>;
  49455. /**
  49456. * Gets a mesh with its auto-generated unique id
  49457. * @param uniqueId defines the unique id to search for
  49458. * @return the found mesh or null if not found at all.
  49459. */
  49460. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  49461. /**
  49462. * Gets a the last added mesh using a given id
  49463. * @param id defines the id to search for
  49464. * @return the found mesh or null if not found at all.
  49465. */
  49466. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  49467. /**
  49468. * Gets a the last added node (Mesh, Camera, Light) using a given id
  49469. * @param id defines the id to search for
  49470. * @return the found node or null if not found at all
  49471. */
  49472. getLastEntryByID(id: string): Nullable<Node>;
  49473. /**
  49474. * Gets a node (Mesh, Camera, Light) using a given id
  49475. * @param id defines the id to search for
  49476. * @return the found node or null if not found at all
  49477. */
  49478. getNodeByID(id: string): Nullable<Node>;
  49479. /**
  49480. * Gets a node (Mesh, Camera, Light) using a given name
  49481. * @param name defines the name to search for
  49482. * @return the found node or null if not found at all.
  49483. */
  49484. getNodeByName(name: string): Nullable<Node>;
  49485. /**
  49486. * Gets a mesh using a given name
  49487. * @param name defines the name to search for
  49488. * @return the found mesh or null if not found at all.
  49489. */
  49490. getMeshByName(name: string): Nullable<AbstractMesh>;
  49491. /**
  49492. * Gets a transform node using a given name
  49493. * @param name defines the name to search for
  49494. * @return the found transform node or null if not found at all.
  49495. */
  49496. getTransformNodeByName(name: string): Nullable<TransformNode>;
  49497. /**
  49498. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  49499. * @param id defines the id to search for
  49500. * @return the found skeleton or null if not found at all.
  49501. */
  49502. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  49503. /**
  49504. * Gets a skeleton using a given auto generated unique id
  49505. * @param uniqueId defines the unique id to search for
  49506. * @return the found skeleton or null if not found at all.
  49507. */
  49508. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  49509. /**
  49510. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  49511. * @param id defines the id to search for
  49512. * @return the found skeleton or null if not found at all.
  49513. */
  49514. getSkeletonById(id: string): Nullable<Skeleton>;
  49515. /**
  49516. * Gets a skeleton using a given name
  49517. * @param name defines the name to search for
  49518. * @return the found skeleton or null if not found at all.
  49519. */
  49520. getSkeletonByName(name: string): Nullable<Skeleton>;
  49521. /**
  49522. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  49523. * @param id defines the id to search for
  49524. * @return the found morph target manager or null if not found at all.
  49525. */
  49526. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  49527. /**
  49528. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  49529. * @param id defines the id to search for
  49530. * @return the found morph target or null if not found at all.
  49531. */
  49532. getMorphTargetById(id: string): Nullable<MorphTarget>;
  49533. /**
  49534. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  49535. * @param name defines the name to search for
  49536. * @return the found morph target or null if not found at all.
  49537. */
  49538. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  49539. /**
  49540. * Gets a post process using a given name (if many are found, this function will pick the first one)
  49541. * @param name defines the name to search for
  49542. * @return the found post process or null if not found at all.
  49543. */
  49544. getPostProcessByName(name: string): Nullable<PostProcess>;
  49545. /**
  49546. * Gets a boolean indicating if the given mesh is active
  49547. * @param mesh defines the mesh to look for
  49548. * @returns true if the mesh is in the active list
  49549. */
  49550. isActiveMesh(mesh: AbstractMesh): boolean;
  49551. /**
  49552. * Return a unique id as a string which can serve as an identifier for the scene
  49553. */
  49554. get uid(): string;
  49555. /**
  49556. * Add an externaly attached data from its key.
  49557. * This method call will fail and return false, if such key already exists.
  49558. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  49559. * @param key the unique key that identifies the data
  49560. * @param data the data object to associate to the key for this Engine instance
  49561. * @return true if no such key were already present and the data was added successfully, false otherwise
  49562. */
  49563. addExternalData<T>(key: string, data: T): boolean;
  49564. /**
  49565. * Get an externaly attached data from its key
  49566. * @param key the unique key that identifies the data
  49567. * @return the associated data, if present (can be null), or undefined if not present
  49568. */
  49569. getExternalData<T>(key: string): Nullable<T>;
  49570. /**
  49571. * Get an externaly attached data from its key, create it using a factory if it's not already present
  49572. * @param key the unique key that identifies the data
  49573. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  49574. * @return the associated data, can be null if the factory returned null.
  49575. */
  49576. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  49577. /**
  49578. * Remove an externaly attached data from the Engine instance
  49579. * @param key the unique key that identifies the data
  49580. * @return true if the data was successfully removed, false if it doesn't exist
  49581. */
  49582. removeExternalData(key: string): boolean;
  49583. private _evaluateSubMesh;
  49584. /**
  49585. * Clear the processed materials smart array preventing retention point in material dispose.
  49586. */
  49587. freeProcessedMaterials(): void;
  49588. private _preventFreeActiveMeshesAndRenderingGroups;
  49589. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  49590. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  49591. * when disposing several meshes in a row or a hierarchy of meshes.
  49592. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  49593. */
  49594. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  49595. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  49596. /**
  49597. * Clear the active meshes smart array preventing retention point in mesh dispose.
  49598. */
  49599. freeActiveMeshes(): void;
  49600. /**
  49601. * Clear the info related to rendering groups preventing retention points during dispose.
  49602. */
  49603. freeRenderingGroups(): void;
  49604. /** @hidden */
  49605. _isInIntermediateRendering(): boolean;
  49606. /**
  49607. * Lambda returning the list of potentially active meshes.
  49608. */
  49609. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  49610. /**
  49611. * Lambda returning the list of potentially active sub meshes.
  49612. */
  49613. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  49614. /**
  49615. * Lambda returning the list of potentially intersecting sub meshes.
  49616. */
  49617. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  49618. /**
  49619. * Lambda returning the list of potentially colliding sub meshes.
  49620. */
  49621. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  49622. /** @hidden */
  49623. _activeMeshesFrozen: boolean;
  49624. private _skipEvaluateActiveMeshesCompletely;
  49625. /**
  49626. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  49627. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  49628. * @param onSuccess optional success callback
  49629. * @param onError optional error callback
  49630. * @returns the current scene
  49631. */
  49632. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  49633. /**
  49634. * Use this function to restart evaluating active meshes on every frame
  49635. * @returns the current scene
  49636. */
  49637. unfreezeActiveMeshes(): Scene;
  49638. private _evaluateActiveMeshes;
  49639. private _activeMesh;
  49640. /**
  49641. * Update the transform matrix to update from the current active camera
  49642. * @param force defines a boolean used to force the update even if cache is up to date
  49643. */
  49644. updateTransformMatrix(force?: boolean): void;
  49645. private _bindFrameBuffer;
  49646. /** @hidden */
  49647. _allowPostProcessClearColor: boolean;
  49648. /** @hidden */
  49649. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  49650. private _processSubCameras;
  49651. private _checkIntersections;
  49652. /** @hidden */
  49653. _advancePhysicsEngineStep(step: number): void;
  49654. /**
  49655. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  49656. */
  49657. getDeterministicFrameTime: () => number;
  49658. /** @hidden */
  49659. _animate(): void;
  49660. /** Execute all animations (for a frame) */
  49661. animate(): void;
  49662. /**
  49663. * Render the scene
  49664. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  49665. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  49666. */
  49667. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  49668. /**
  49669. * Freeze all materials
  49670. * A frozen material will not be updatable but should be faster to render
  49671. */
  49672. freezeMaterials(): void;
  49673. /**
  49674. * Unfreeze all materials
  49675. * A frozen material will not be updatable but should be faster to render
  49676. */
  49677. unfreezeMaterials(): void;
  49678. /**
  49679. * Releases all held ressources
  49680. */
  49681. dispose(): void;
  49682. /**
  49683. * Gets if the scene is already disposed
  49684. */
  49685. get isDisposed(): boolean;
  49686. /**
  49687. * Call this function to reduce memory footprint of the scene.
  49688. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  49689. */
  49690. clearCachedVertexData(): void;
  49691. /**
  49692. * This function will remove the local cached buffer data from texture.
  49693. * It will save memory but will prevent the texture from being rebuilt
  49694. */
  49695. cleanCachedTextureBuffer(): void;
  49696. /**
  49697. * Get the world extend vectors with an optional filter
  49698. *
  49699. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  49700. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  49701. */
  49702. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  49703. min: Vector3;
  49704. max: Vector3;
  49705. };
  49706. /**
  49707. * Creates a ray that can be used to pick in the scene
  49708. * @param x defines the x coordinate of the origin (on-screen)
  49709. * @param y defines the y coordinate of the origin (on-screen)
  49710. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49711. * @param camera defines the camera to use for the picking
  49712. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49713. * @returns a Ray
  49714. */
  49715. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  49716. /**
  49717. * Creates a ray that can be used to pick in the scene
  49718. * @param x defines the x coordinate of the origin (on-screen)
  49719. * @param y defines the y coordinate of the origin (on-screen)
  49720. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49721. * @param result defines the ray where to store the picking ray
  49722. * @param camera defines the camera to use for the picking
  49723. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49724. * @returns the current scene
  49725. */
  49726. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  49727. /**
  49728. * Creates a ray that can be used to pick in the scene
  49729. * @param x defines the x coordinate of the origin (on-screen)
  49730. * @param y defines the y coordinate of the origin (on-screen)
  49731. * @param camera defines the camera to use for the picking
  49732. * @returns a Ray
  49733. */
  49734. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  49735. /**
  49736. * Creates a ray that can be used to pick in the scene
  49737. * @param x defines the x coordinate of the origin (on-screen)
  49738. * @param y defines the y coordinate of the origin (on-screen)
  49739. * @param result defines the ray where to store the picking ray
  49740. * @param camera defines the camera to use for the picking
  49741. * @returns the current scene
  49742. */
  49743. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  49744. /** Launch a ray to try to pick a mesh in the scene
  49745. * @param x position on screen
  49746. * @param y position on screen
  49747. * @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
  49748. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49749. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49750. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49751. * @returns a PickingInfo
  49752. */
  49753. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49754. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  49755. * @param x position on screen
  49756. * @param y position on screen
  49757. * @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
  49758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49759. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49760. * @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)
  49761. */
  49762. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  49763. /** Use the given ray to pick a mesh in the scene
  49764. * @param ray The ray to use to pick meshes
  49765. * @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
  49766. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49767. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49768. * @returns a PickingInfo
  49769. */
  49770. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49771. /**
  49772. * Launch a ray to try to pick a mesh in the scene
  49773. * @param x X position on screen
  49774. * @param y Y position on screen
  49775. * @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
  49776. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49777. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49778. * @returns an array of PickingInfo
  49779. */
  49780. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49781. /**
  49782. * Launch a ray to try to pick a mesh in the scene
  49783. * @param ray Ray to use
  49784. * @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
  49785. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49786. * @returns an array of PickingInfo
  49787. */
  49788. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49789. /**
  49790. * Force the value of meshUnderPointer
  49791. * @param mesh defines the mesh to use
  49792. * @param pointerId optional pointer id when using more than one pointer
  49793. */
  49794. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  49795. /**
  49796. * Gets the mesh under the pointer
  49797. * @returns a Mesh or null if no mesh is under the pointer
  49798. */
  49799. getPointerOverMesh(): Nullable<AbstractMesh>;
  49800. /** @hidden */
  49801. _rebuildGeometries(): void;
  49802. /** @hidden */
  49803. _rebuildTextures(): void;
  49804. private _getByTags;
  49805. /**
  49806. * Get a list of meshes by tags
  49807. * @param tagsQuery defines the tags query to use
  49808. * @param forEach defines a predicate used to filter results
  49809. * @returns an array of Mesh
  49810. */
  49811. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  49812. /**
  49813. * Get a list of cameras by tags
  49814. * @param tagsQuery defines the tags query to use
  49815. * @param forEach defines a predicate used to filter results
  49816. * @returns an array of Camera
  49817. */
  49818. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  49819. /**
  49820. * Get a list of lights by tags
  49821. * @param tagsQuery defines the tags query to use
  49822. * @param forEach defines a predicate used to filter results
  49823. * @returns an array of Light
  49824. */
  49825. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  49826. /**
  49827. * Get a list of materials by tags
  49828. * @param tagsQuery defines the tags query to use
  49829. * @param forEach defines a predicate used to filter results
  49830. * @returns an array of Material
  49831. */
  49832. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  49833. /**
  49834. * Get a list of transform nodes by tags
  49835. * @param tagsQuery defines the tags query to use
  49836. * @param forEach defines a predicate used to filter results
  49837. * @returns an array of TransformNode
  49838. */
  49839. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  49840. /**
  49841. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  49842. * This allowed control for front to back rendering or reversly depending of the special needs.
  49843. *
  49844. * @param renderingGroupId The rendering group id corresponding to its index
  49845. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  49846. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  49847. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  49848. */
  49849. 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;
  49850. /**
  49851. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  49852. *
  49853. * @param renderingGroupId The rendering group id corresponding to its index
  49854. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49855. * @param depth Automatically clears depth between groups if true and autoClear is true.
  49856. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  49857. */
  49858. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  49859. /**
  49860. * Gets the current auto clear configuration for one rendering group of the rendering
  49861. * manager.
  49862. * @param index the rendering group index to get the information for
  49863. * @returns The auto clear setup for the requested rendering group
  49864. */
  49865. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  49866. private _blockMaterialDirtyMechanism;
  49867. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  49868. get blockMaterialDirtyMechanism(): boolean;
  49869. set blockMaterialDirtyMechanism(value: boolean);
  49870. /**
  49871. * Will flag all materials as dirty to trigger new shader compilation
  49872. * @param flag defines the flag used to specify which material part must be marked as dirty
  49873. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  49874. */
  49875. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  49876. /** @hidden */
  49877. _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;
  49878. /** @hidden */
  49879. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49880. /** @hidden */
  49881. _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;
  49882. /** @hidden */
  49883. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  49884. /** @hidden */
  49885. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  49886. /** @hidden */
  49887. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49888. }
  49889. }
  49890. declare module "babylonjs/assetContainer" {
  49891. import { AbstractScene } from "babylonjs/abstractScene";
  49892. import { Scene } from "babylonjs/scene";
  49893. import { Mesh } from "babylonjs/Meshes/mesh";
  49894. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49895. import { Skeleton } from "babylonjs/Bones/skeleton";
  49896. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49897. import { Animatable } from "babylonjs/Animations/animatable";
  49898. import { Nullable } from "babylonjs/types";
  49899. import { Node } from "babylonjs/node";
  49900. /**
  49901. * Set of assets to keep when moving a scene into an asset container.
  49902. */
  49903. export class KeepAssets extends AbstractScene {
  49904. }
  49905. /**
  49906. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  49907. */
  49908. export class InstantiatedEntries {
  49909. /**
  49910. * List of new root nodes (eg. nodes with no parent)
  49911. */
  49912. rootNodes: TransformNode[];
  49913. /**
  49914. * List of new skeletons
  49915. */
  49916. skeletons: Skeleton[];
  49917. /**
  49918. * List of new animation groups
  49919. */
  49920. animationGroups: AnimationGroup[];
  49921. }
  49922. /**
  49923. * Container with a set of assets that can be added or removed from a scene.
  49924. */
  49925. export class AssetContainer extends AbstractScene {
  49926. private _wasAddedToScene;
  49927. /**
  49928. * The scene the AssetContainer belongs to.
  49929. */
  49930. scene: Scene;
  49931. /**
  49932. * Instantiates an AssetContainer.
  49933. * @param scene The scene the AssetContainer belongs to.
  49934. */
  49935. constructor(scene: Scene);
  49936. /**
  49937. * Instantiate or clone all meshes and add the new ones to the scene.
  49938. * Skeletons and animation groups will all be cloned
  49939. * @param nameFunction defines an optional function used to get new names for clones
  49940. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  49941. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  49942. */
  49943. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  49944. /**
  49945. * Adds all the assets from the container to the scene.
  49946. */
  49947. addAllToScene(): void;
  49948. /**
  49949. * Removes all the assets in the container from the scene
  49950. */
  49951. removeAllFromScene(): void;
  49952. /**
  49953. * Disposes all the assets in the container
  49954. */
  49955. dispose(): void;
  49956. private _moveAssets;
  49957. /**
  49958. * Removes all the assets contained in the scene and adds them to the container.
  49959. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  49960. */
  49961. moveAllFromScene(keepAssets?: KeepAssets): void;
  49962. /**
  49963. * 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.
  49964. * @returns the root mesh
  49965. */
  49966. createRootMesh(): Mesh;
  49967. /**
  49968. * Merge animations (direct and animation groups) from this asset container into a scene
  49969. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49970. * @param animatables set of animatables to retarget to a node from the scene
  49971. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  49972. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  49973. */
  49974. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  49975. }
  49976. }
  49977. declare module "babylonjs/abstractScene" {
  49978. import { Scene } from "babylonjs/scene";
  49979. import { Nullable } from "babylonjs/types";
  49980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49981. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49982. import { Geometry } from "babylonjs/Meshes/geometry";
  49983. import { Skeleton } from "babylonjs/Bones/skeleton";
  49984. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  49985. import { AssetContainer } from "babylonjs/assetContainer";
  49986. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49987. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49989. import { Material } from "babylonjs/Materials/material";
  49990. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  49991. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  49992. import { Camera } from "babylonjs/Cameras/camera";
  49993. import { Light } from "babylonjs/Lights/light";
  49994. import { Node } from "babylonjs/node";
  49995. import { Animation } from "babylonjs/Animations/animation";
  49996. /**
  49997. * Defines how the parser contract is defined.
  49998. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  49999. */
  50000. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  50001. /**
  50002. * Defines how the individual parser contract is defined.
  50003. * These parser can parse an individual asset
  50004. */
  50005. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  50006. /**
  50007. * Base class of the scene acting as a container for the different elements composing a scene.
  50008. * This class is dynamically extended by the different components of the scene increasing
  50009. * flexibility and reducing coupling
  50010. */
  50011. export abstract class AbstractScene {
  50012. /**
  50013. * Stores the list of available parsers in the application.
  50014. */
  50015. private static _BabylonFileParsers;
  50016. /**
  50017. * Stores the list of available individual parsers in the application.
  50018. */
  50019. private static _IndividualBabylonFileParsers;
  50020. /**
  50021. * Adds a parser in the list of available ones
  50022. * @param name Defines the name of the parser
  50023. * @param parser Defines the parser to add
  50024. */
  50025. static AddParser(name: string, parser: BabylonFileParser): void;
  50026. /**
  50027. * Gets a general parser from the list of avaialble ones
  50028. * @param name Defines the name of the parser
  50029. * @returns the requested parser or null
  50030. */
  50031. static GetParser(name: string): Nullable<BabylonFileParser>;
  50032. /**
  50033. * Adds n individual parser in the list of available ones
  50034. * @param name Defines the name of the parser
  50035. * @param parser Defines the parser to add
  50036. */
  50037. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  50038. /**
  50039. * Gets an individual parser from the list of avaialble ones
  50040. * @param name Defines the name of the parser
  50041. * @returns the requested parser or null
  50042. */
  50043. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  50044. /**
  50045. * Parser json data and populate both a scene and its associated container object
  50046. * @param jsonData Defines the data to parse
  50047. * @param scene Defines the scene to parse the data for
  50048. * @param container Defines the container attached to the parsing sequence
  50049. * @param rootUrl Defines the root url of the data
  50050. */
  50051. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  50052. /**
  50053. * Gets the list of root nodes (ie. nodes with no parent)
  50054. */
  50055. rootNodes: Node[];
  50056. /** All of the cameras added to this scene
  50057. * @see https://doc.babylonjs.com/babylon101/cameras
  50058. */
  50059. cameras: Camera[];
  50060. /**
  50061. * All of the lights added to this scene
  50062. * @see https://doc.babylonjs.com/babylon101/lights
  50063. */
  50064. lights: Light[];
  50065. /**
  50066. * All of the (abstract) meshes added to this scene
  50067. */
  50068. meshes: AbstractMesh[];
  50069. /**
  50070. * The list of skeletons added to the scene
  50071. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  50072. */
  50073. skeletons: Skeleton[];
  50074. /**
  50075. * All of the particle systems added to this scene
  50076. * @see https://doc.babylonjs.com/babylon101/particles
  50077. */
  50078. particleSystems: IParticleSystem[];
  50079. /**
  50080. * Gets a list of Animations associated with the scene
  50081. */
  50082. animations: Animation[];
  50083. /**
  50084. * All of the animation groups added to this scene
  50085. * @see https://doc.babylonjs.com/how_to/group
  50086. */
  50087. animationGroups: AnimationGroup[];
  50088. /**
  50089. * All of the multi-materials added to this scene
  50090. * @see https://doc.babylonjs.com/how_to/multi_materials
  50091. */
  50092. multiMaterials: MultiMaterial[];
  50093. /**
  50094. * All of the materials added to this scene
  50095. * In the context of a Scene, it is not supposed to be modified manually.
  50096. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  50097. * Note also that the order of the Material within the array is not significant and might change.
  50098. * @see https://doc.babylonjs.com/babylon101/materials
  50099. */
  50100. materials: Material[];
  50101. /**
  50102. * The list of morph target managers added to the scene
  50103. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  50104. */
  50105. morphTargetManagers: MorphTargetManager[];
  50106. /**
  50107. * The list of geometries used in the scene.
  50108. */
  50109. geometries: Geometry[];
  50110. /**
  50111. * All of the tranform nodes added to this scene
  50112. * In the context of a Scene, it is not supposed to be modified manually.
  50113. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  50114. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  50115. * @see https://doc.babylonjs.com/how_to/transformnode
  50116. */
  50117. transformNodes: TransformNode[];
  50118. /**
  50119. * ActionManagers available on the scene.
  50120. */
  50121. actionManagers: AbstractActionManager[];
  50122. /**
  50123. * Textures to keep.
  50124. */
  50125. textures: BaseTexture[];
  50126. /** @hidden */
  50127. protected _environmentTexture: Nullable<BaseTexture>;
  50128. /**
  50129. * Texture used in all pbr material as the reflection texture.
  50130. * As in the majority of the scene they are the same (exception for multi room and so on),
  50131. * this is easier to reference from here than from all the materials.
  50132. */
  50133. get environmentTexture(): Nullable<BaseTexture>;
  50134. set environmentTexture(value: Nullable<BaseTexture>);
  50135. /**
  50136. * The list of postprocesses added to the scene
  50137. */
  50138. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  50139. /**
  50140. * @returns all meshes, lights, cameras, transformNodes and bones
  50141. */
  50142. getNodes(): Array<Node>;
  50143. }
  50144. }
  50145. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  50146. /**
  50147. * Interface used to define options for Sound class
  50148. */
  50149. export interface ISoundOptions {
  50150. /**
  50151. * Does the sound autoplay once loaded.
  50152. */
  50153. autoplay?: boolean;
  50154. /**
  50155. * Does the sound loop after it finishes playing once.
  50156. */
  50157. loop?: boolean;
  50158. /**
  50159. * Sound's volume
  50160. */
  50161. volume?: number;
  50162. /**
  50163. * Is it a spatial sound?
  50164. */
  50165. spatialSound?: boolean;
  50166. /**
  50167. * Maximum distance to hear that sound
  50168. */
  50169. maxDistance?: number;
  50170. /**
  50171. * Uses user defined attenuation function
  50172. */
  50173. useCustomAttenuation?: boolean;
  50174. /**
  50175. * Define the roll off factor of spatial sounds.
  50176. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50177. */
  50178. rolloffFactor?: number;
  50179. /**
  50180. * Define the reference distance the sound should be heard perfectly.
  50181. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50182. */
  50183. refDistance?: number;
  50184. /**
  50185. * Define the distance attenuation model the sound will follow.
  50186. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50187. */
  50188. distanceModel?: string;
  50189. /**
  50190. * Defines the playback speed (1 by default)
  50191. */
  50192. playbackRate?: number;
  50193. /**
  50194. * Defines if the sound is from a streaming source
  50195. */
  50196. streaming?: boolean;
  50197. /**
  50198. * Defines an optional length (in seconds) inside the sound file
  50199. */
  50200. length?: number;
  50201. /**
  50202. * Defines an optional offset (in seconds) inside the sound file
  50203. */
  50204. offset?: number;
  50205. /**
  50206. * If true, URLs will not be required to state the audio file codec to use.
  50207. */
  50208. skipCodecCheck?: boolean;
  50209. }
  50210. }
  50211. declare module "babylonjs/Audio/sound" {
  50212. import { Observable } from "babylonjs/Misc/observable";
  50213. import { Vector3 } from "babylonjs/Maths/math.vector";
  50214. import { Nullable } from "babylonjs/types";
  50215. import { Scene } from "babylonjs/scene";
  50216. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50217. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  50218. /**
  50219. * Defines a sound that can be played in the application.
  50220. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  50221. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50222. */
  50223. export class Sound {
  50224. /**
  50225. * The name of the sound in the scene.
  50226. */
  50227. name: string;
  50228. /**
  50229. * Does the sound autoplay once loaded.
  50230. */
  50231. autoplay: boolean;
  50232. private _loop;
  50233. /**
  50234. * Does the sound loop after it finishes playing once.
  50235. */
  50236. get loop(): boolean;
  50237. set loop(value: boolean);
  50238. /**
  50239. * Does the sound use a custom attenuation curve to simulate the falloff
  50240. * happening when the source gets further away from the camera.
  50241. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  50242. */
  50243. useCustomAttenuation: boolean;
  50244. /**
  50245. * The sound track id this sound belongs to.
  50246. */
  50247. soundTrackId: number;
  50248. /**
  50249. * Is this sound currently played.
  50250. */
  50251. isPlaying: boolean;
  50252. /**
  50253. * Is this sound currently paused.
  50254. */
  50255. isPaused: boolean;
  50256. /**
  50257. * Does this sound enables spatial sound.
  50258. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50259. */
  50260. spatialSound: boolean;
  50261. /**
  50262. * Define the reference distance the sound should be heard perfectly.
  50263. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50264. */
  50265. refDistance: number;
  50266. /**
  50267. * Define the roll off factor of spatial sounds.
  50268. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50269. */
  50270. rolloffFactor: number;
  50271. /**
  50272. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  50273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50274. */
  50275. maxDistance: number;
  50276. /**
  50277. * Define the distance attenuation model the sound will follow.
  50278. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50279. */
  50280. distanceModel: string;
  50281. /**
  50282. * @hidden
  50283. * Back Compat
  50284. **/
  50285. onended: () => any;
  50286. /**
  50287. * Gets or sets an object used to store user defined information for the sound.
  50288. */
  50289. metadata: any;
  50290. /**
  50291. * Observable event when the current playing sound finishes.
  50292. */
  50293. onEndedObservable: Observable<Sound>;
  50294. /**
  50295. * Gets the current time for the sound.
  50296. */
  50297. get currentTime(): number;
  50298. private _panningModel;
  50299. private _playbackRate;
  50300. private _streaming;
  50301. private _startTime;
  50302. private _startOffset;
  50303. private _position;
  50304. /** @hidden */
  50305. _positionInEmitterSpace: boolean;
  50306. private _localDirection;
  50307. private _volume;
  50308. private _isReadyToPlay;
  50309. private _isDirectional;
  50310. private _readyToPlayCallback;
  50311. private _audioBuffer;
  50312. private _soundSource;
  50313. private _streamingSource;
  50314. private _soundPanner;
  50315. private _soundGain;
  50316. private _inputAudioNode;
  50317. private _outputAudioNode;
  50318. private _coneInnerAngle;
  50319. private _coneOuterAngle;
  50320. private _coneOuterGain;
  50321. private _scene;
  50322. private _connectedTransformNode;
  50323. private _customAttenuationFunction;
  50324. private _registerFunc;
  50325. private _isOutputConnected;
  50326. private _htmlAudioElement;
  50327. private _urlType;
  50328. private _length?;
  50329. private _offset?;
  50330. /** @hidden */
  50331. static _SceneComponentInitialization: (scene: Scene) => void;
  50332. /**
  50333. * Create a sound and attach it to a scene
  50334. * @param name Name of your sound
  50335. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  50336. * @param scene defines the scene the sound belongs to
  50337. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  50338. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  50339. */
  50340. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  50341. /**
  50342. * Release the sound and its associated resources
  50343. */
  50344. dispose(): void;
  50345. /**
  50346. * Gets if the sounds is ready to be played or not.
  50347. * @returns true if ready, otherwise false
  50348. */
  50349. isReady(): boolean;
  50350. /**
  50351. * Get the current class name.
  50352. * @returns current class name
  50353. */
  50354. getClassName(): string;
  50355. private _soundLoaded;
  50356. /**
  50357. * Sets the data of the sound from an audiobuffer
  50358. * @param audioBuffer The audioBuffer containing the data
  50359. */
  50360. setAudioBuffer(audioBuffer: AudioBuffer): void;
  50361. /**
  50362. * Updates the current sounds options such as maxdistance, loop...
  50363. * @param options A JSON object containing values named as the object properties
  50364. */
  50365. updateOptions(options: ISoundOptions): void;
  50366. private _createSpatialParameters;
  50367. private _updateSpatialParameters;
  50368. /**
  50369. * Switch the panning model to HRTF:
  50370. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  50371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50372. */
  50373. switchPanningModelToHRTF(): void;
  50374. /**
  50375. * Switch the panning model to Equal Power:
  50376. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  50377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50378. */
  50379. switchPanningModelToEqualPower(): void;
  50380. private _switchPanningModel;
  50381. /**
  50382. * Connect this sound to a sound track audio node like gain...
  50383. * @param soundTrackAudioNode the sound track audio node to connect to
  50384. */
  50385. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  50386. /**
  50387. * Transform this sound into a directional source
  50388. * @param coneInnerAngle Size of the inner cone in degree
  50389. * @param coneOuterAngle Size of the outer cone in degree
  50390. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  50391. */
  50392. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  50393. /**
  50394. * Gets or sets the inner angle for the directional cone.
  50395. */
  50396. get directionalConeInnerAngle(): number;
  50397. /**
  50398. * Gets or sets the inner angle for the directional cone.
  50399. */
  50400. set directionalConeInnerAngle(value: number);
  50401. /**
  50402. * Gets or sets the outer angle for the directional cone.
  50403. */
  50404. get directionalConeOuterAngle(): number;
  50405. /**
  50406. * Gets or sets the outer angle for the directional cone.
  50407. */
  50408. set directionalConeOuterAngle(value: number);
  50409. /**
  50410. * Sets the position of the emitter if spatial sound is enabled
  50411. * @param newPosition Defines the new position
  50412. */
  50413. setPosition(newPosition: Vector3): void;
  50414. /**
  50415. * Sets the local direction of the emitter if spatial sound is enabled
  50416. * @param newLocalDirection Defines the new local direction
  50417. */
  50418. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  50419. private _updateDirection;
  50420. /** @hidden */
  50421. updateDistanceFromListener(): void;
  50422. /**
  50423. * Sets a new custom attenuation function for the sound.
  50424. * @param callback Defines the function used for the attenuation
  50425. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  50426. */
  50427. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  50428. /**
  50429. * Play the sound
  50430. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  50431. * @param offset (optional) Start the sound at a specific time in seconds
  50432. * @param length (optional) Sound duration (in seconds)
  50433. */
  50434. play(time?: number, offset?: number, length?: number): void;
  50435. private _onended;
  50436. /**
  50437. * Stop the sound
  50438. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  50439. */
  50440. stop(time?: number): void;
  50441. /**
  50442. * Put the sound in pause
  50443. */
  50444. pause(): void;
  50445. /**
  50446. * Sets a dedicated volume for this sounds
  50447. * @param newVolume Define the new volume of the sound
  50448. * @param time Define time for gradual change to new volume
  50449. */
  50450. setVolume(newVolume: number, time?: number): void;
  50451. /**
  50452. * Set the sound play back rate
  50453. * @param newPlaybackRate Define the playback rate the sound should be played at
  50454. */
  50455. setPlaybackRate(newPlaybackRate: number): void;
  50456. /**
  50457. * Gets the volume of the sound.
  50458. * @returns the volume of the sound
  50459. */
  50460. getVolume(): number;
  50461. /**
  50462. * Attach the sound to a dedicated mesh
  50463. * @param transformNode The transform node to connect the sound with
  50464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  50465. */
  50466. attachToMesh(transformNode: TransformNode): void;
  50467. /**
  50468. * Detach the sound from the previously attached mesh
  50469. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  50470. */
  50471. detachFromMesh(): void;
  50472. private _onRegisterAfterWorldMatrixUpdate;
  50473. /**
  50474. * Clone the current sound in the scene.
  50475. * @returns the new sound clone
  50476. */
  50477. clone(): Nullable<Sound>;
  50478. /**
  50479. * Gets the current underlying audio buffer containing the data
  50480. * @returns the audio buffer
  50481. */
  50482. getAudioBuffer(): Nullable<AudioBuffer>;
  50483. /**
  50484. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  50485. * @returns the source node
  50486. */
  50487. getSoundSource(): Nullable<AudioBufferSourceNode>;
  50488. /**
  50489. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  50490. * @returns the gain node
  50491. */
  50492. getSoundGain(): Nullable<GainNode>;
  50493. /**
  50494. * Serializes the Sound in a JSON representation
  50495. * @returns the JSON representation of the sound
  50496. */
  50497. serialize(): any;
  50498. /**
  50499. * Parse a JSON representation of a sound to instantiate in a given scene
  50500. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  50501. * @param scene Define the scene the new parsed sound should be created in
  50502. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  50503. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  50504. * @returns the newly parsed sound
  50505. */
  50506. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  50507. }
  50508. }
  50509. declare module "babylonjs/Actions/directAudioActions" {
  50510. import { Action } from "babylonjs/Actions/action";
  50511. import { Condition } from "babylonjs/Actions/condition";
  50512. import { Sound } from "babylonjs/Audio/sound";
  50513. /**
  50514. * This defines an action helpful to play a defined sound on a triggered action.
  50515. */
  50516. export class PlaySoundAction extends Action {
  50517. private _sound;
  50518. /**
  50519. * Instantiate the action
  50520. * @param triggerOptions defines the trigger options
  50521. * @param sound defines the sound to play
  50522. * @param condition defines the trigger related conditions
  50523. */
  50524. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  50525. /** @hidden */
  50526. _prepare(): void;
  50527. /**
  50528. * Execute the action and play the sound.
  50529. */
  50530. execute(): void;
  50531. /**
  50532. * Serializes the actions and its related information.
  50533. * @param parent defines the object to serialize in
  50534. * @returns the serialized object
  50535. */
  50536. serialize(parent: any): any;
  50537. }
  50538. /**
  50539. * This defines an action helpful to stop a defined sound on a triggered action.
  50540. */
  50541. export class StopSoundAction extends Action {
  50542. private _sound;
  50543. /**
  50544. * Instantiate the action
  50545. * @param triggerOptions defines the trigger options
  50546. * @param sound defines the sound to stop
  50547. * @param condition defines the trigger related conditions
  50548. */
  50549. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  50550. /** @hidden */
  50551. _prepare(): void;
  50552. /**
  50553. * Execute the action and stop the sound.
  50554. */
  50555. execute(): void;
  50556. /**
  50557. * Serializes the actions and its related information.
  50558. * @param parent defines the object to serialize in
  50559. * @returns the serialized object
  50560. */
  50561. serialize(parent: any): any;
  50562. }
  50563. }
  50564. declare module "babylonjs/Actions/interpolateValueAction" {
  50565. import { Action } from "babylonjs/Actions/action";
  50566. import { Condition } from "babylonjs/Actions/condition";
  50567. import { Observable } from "babylonjs/Misc/observable";
  50568. /**
  50569. * This defines an action responsible to change the value of a property
  50570. * by interpolating between its current value and the newly set one once triggered.
  50571. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  50572. */
  50573. export class InterpolateValueAction extends Action {
  50574. /**
  50575. * Defines the path of the property where the value should be interpolated
  50576. */
  50577. propertyPath: string;
  50578. /**
  50579. * Defines the target value at the end of the interpolation.
  50580. */
  50581. value: any;
  50582. /**
  50583. * Defines the time it will take for the property to interpolate to the value.
  50584. */
  50585. duration: number;
  50586. /**
  50587. * Defines if the other scene animations should be stopped when the action has been triggered
  50588. */
  50589. stopOtherAnimations?: boolean;
  50590. /**
  50591. * Defines a callback raised once the interpolation animation has been done.
  50592. */
  50593. onInterpolationDone?: () => void;
  50594. /**
  50595. * Observable triggered once the interpolation animation has been done.
  50596. */
  50597. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  50598. private _target;
  50599. private _effectiveTarget;
  50600. private _property;
  50601. /**
  50602. * Instantiate the action
  50603. * @param triggerOptions defines the trigger options
  50604. * @param target defines the object containing the value to interpolate
  50605. * @param propertyPath defines the path to the property in the target object
  50606. * @param value defines the target value at the end of the interpolation
  50607. * @param duration defines the time it will take for the property to interpolate to the value.
  50608. * @param condition defines the trigger related conditions
  50609. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  50610. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  50611. */
  50612. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  50613. /** @hidden */
  50614. _prepare(): void;
  50615. /**
  50616. * Execute the action starts the value interpolation.
  50617. */
  50618. execute(): void;
  50619. /**
  50620. * Serializes the actions and its related information.
  50621. * @param parent defines the object to serialize in
  50622. * @returns the serialized object
  50623. */
  50624. serialize(parent: any): any;
  50625. }
  50626. }
  50627. declare module "babylonjs/Actions/index" {
  50628. export * from "babylonjs/Actions/abstractActionManager";
  50629. export * from "babylonjs/Actions/action";
  50630. export * from "babylonjs/Actions/actionEvent";
  50631. export * from "babylonjs/Actions/actionManager";
  50632. export * from "babylonjs/Actions/condition";
  50633. export * from "babylonjs/Actions/directActions";
  50634. export * from "babylonjs/Actions/directAudioActions";
  50635. export * from "babylonjs/Actions/interpolateValueAction";
  50636. }
  50637. declare module "babylonjs/Animations/pathCursor" {
  50638. import { Vector3 } from "babylonjs/Maths/math.vector";
  50639. import { Path2 } from "babylonjs/Maths/math.path";
  50640. /**
  50641. * A cursor which tracks a point on a path
  50642. */
  50643. export class PathCursor {
  50644. private path;
  50645. /**
  50646. * Stores path cursor callbacks for when an onchange event is triggered
  50647. */
  50648. private _onchange;
  50649. /**
  50650. * The value of the path cursor
  50651. */
  50652. value: number;
  50653. /**
  50654. * The animation array of the path cursor
  50655. */
  50656. animations: Animation[];
  50657. /**
  50658. * Initializes the path cursor
  50659. * @param path The path to track
  50660. */
  50661. constructor(path: Path2);
  50662. /**
  50663. * Gets the cursor point on the path
  50664. * @returns A point on the path cursor at the cursor location
  50665. */
  50666. getPoint(): Vector3;
  50667. /**
  50668. * Moves the cursor ahead by the step amount
  50669. * @param step The amount to move the cursor forward
  50670. * @returns This path cursor
  50671. */
  50672. moveAhead(step?: number): PathCursor;
  50673. /**
  50674. * Moves the cursor behind by the step amount
  50675. * @param step The amount to move the cursor back
  50676. * @returns This path cursor
  50677. */
  50678. moveBack(step?: number): PathCursor;
  50679. /**
  50680. * Moves the cursor by the step amount
  50681. * If the step amount is greater than one, an exception is thrown
  50682. * @param step The amount to move the cursor
  50683. * @returns This path cursor
  50684. */
  50685. move(step: number): PathCursor;
  50686. /**
  50687. * Ensures that the value is limited between zero and one
  50688. * @returns This path cursor
  50689. */
  50690. private ensureLimits;
  50691. /**
  50692. * Runs onchange callbacks on change (used by the animation engine)
  50693. * @returns This path cursor
  50694. */
  50695. private raiseOnChange;
  50696. /**
  50697. * Executes a function on change
  50698. * @param f A path cursor onchange callback
  50699. * @returns This path cursor
  50700. */
  50701. onchange(f: (cursor: PathCursor) => void): PathCursor;
  50702. }
  50703. }
  50704. declare module "babylonjs/Animations/index" {
  50705. export * from "babylonjs/Animations/animatable";
  50706. export * from "babylonjs/Animations/animation";
  50707. export * from "babylonjs/Animations/animationGroup";
  50708. export * from "babylonjs/Animations/animationPropertiesOverride";
  50709. export * from "babylonjs/Animations/easing";
  50710. export * from "babylonjs/Animations/runtimeAnimation";
  50711. export * from "babylonjs/Animations/animationEvent";
  50712. export * from "babylonjs/Animations/animationGroup";
  50713. export * from "babylonjs/Animations/animationKey";
  50714. export * from "babylonjs/Animations/animationRange";
  50715. export * from "babylonjs/Animations/animatable.interface";
  50716. export * from "babylonjs/Animations/pathCursor";
  50717. }
  50718. declare module "babylonjs/Audio/audioEngine" {
  50719. import { Analyser } from "babylonjs/Audio/analyser";
  50720. import { Nullable } from "babylonjs/types";
  50721. import { Observable } from "babylonjs/Misc/observable";
  50722. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  50723. /**
  50724. * This represents the default audio engine used in babylon.
  50725. * It is responsible to play, synchronize and analyse sounds throughout the application.
  50726. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50727. */
  50728. export class AudioEngine implements IAudioEngine {
  50729. private _audioContext;
  50730. private _audioContextInitialized;
  50731. private _muteButton;
  50732. private _hostElement;
  50733. /**
  50734. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  50735. */
  50736. canUseWebAudio: boolean;
  50737. /**
  50738. * The master gain node defines the global audio volume of your audio engine.
  50739. */
  50740. masterGain: GainNode;
  50741. /**
  50742. * Defines if Babylon should emit a warning if WebAudio is not supported.
  50743. * @ignoreNaming
  50744. */
  50745. WarnedWebAudioUnsupported: boolean;
  50746. /**
  50747. * Gets whether or not mp3 are supported by your browser.
  50748. */
  50749. isMP3supported: boolean;
  50750. /**
  50751. * Gets whether or not ogg are supported by your browser.
  50752. */
  50753. isOGGsupported: boolean;
  50754. /**
  50755. * Gets whether audio has been unlocked on the device.
  50756. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  50757. * a user interaction has happened.
  50758. */
  50759. unlocked: boolean;
  50760. /**
  50761. * Defines if the audio engine relies on a custom unlocked button.
  50762. * In this case, the embedded button will not be displayed.
  50763. */
  50764. useCustomUnlockedButton: boolean;
  50765. /**
  50766. * Event raised when audio has been unlocked on the browser.
  50767. */
  50768. onAudioUnlockedObservable: Observable<IAudioEngine>;
  50769. /**
  50770. * Event raised when audio has been locked on the browser.
  50771. */
  50772. onAudioLockedObservable: Observable<IAudioEngine>;
  50773. /**
  50774. * Gets the current AudioContext if available.
  50775. */
  50776. get audioContext(): Nullable<AudioContext>;
  50777. private _connectedAnalyser;
  50778. /**
  50779. * Instantiates a new audio engine.
  50780. *
  50781. * There should be only one per page as some browsers restrict the number
  50782. * of audio contexts you can create.
  50783. * @param hostElement defines the host element where to display the mute icon if necessary
  50784. */
  50785. constructor(hostElement?: Nullable<HTMLElement>);
  50786. /**
  50787. * Flags the audio engine in Locked state.
  50788. * This happens due to new browser policies preventing audio to autoplay.
  50789. */
  50790. lock(): void;
  50791. /**
  50792. * Unlocks the audio engine once a user action has been done on the dom.
  50793. * This is helpful to resume play once browser policies have been satisfied.
  50794. */
  50795. unlock(): void;
  50796. private _resumeAudioContext;
  50797. private _initializeAudioContext;
  50798. private _tryToRun;
  50799. private _triggerRunningState;
  50800. private _triggerSuspendedState;
  50801. private _displayMuteButton;
  50802. private _moveButtonToTopLeft;
  50803. private _onResize;
  50804. private _hideMuteButton;
  50805. /**
  50806. * Destroy and release the resources associated with the audio context.
  50807. */
  50808. dispose(): void;
  50809. /**
  50810. * Gets the global volume sets on the master gain.
  50811. * @returns the global volume if set or -1 otherwise
  50812. */
  50813. getGlobalVolume(): number;
  50814. /**
  50815. * Sets the global volume of your experience (sets on the master gain).
  50816. * @param newVolume Defines the new global volume of the application
  50817. */
  50818. setGlobalVolume(newVolume: number): void;
  50819. /**
  50820. * Connect the audio engine to an audio analyser allowing some amazing
  50821. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  50822. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50823. * @param analyser The analyser to connect to the engine
  50824. */
  50825. connectToAnalyser(analyser: Analyser): void;
  50826. }
  50827. }
  50828. declare module "babylonjs/Audio/soundTrack" {
  50829. import { Sound } from "babylonjs/Audio/sound";
  50830. import { Analyser } from "babylonjs/Audio/analyser";
  50831. import { Scene } from "babylonjs/scene";
  50832. /**
  50833. * Options allowed during the creation of a sound track.
  50834. */
  50835. export interface ISoundTrackOptions {
  50836. /**
  50837. * The volume the sound track should take during creation
  50838. */
  50839. volume?: number;
  50840. /**
  50841. * Define if the sound track is the main sound track of the scene
  50842. */
  50843. mainTrack?: boolean;
  50844. }
  50845. /**
  50846. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  50847. * It will be also used in a future release to apply effects on a specific track.
  50848. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50849. */
  50850. export class SoundTrack {
  50851. /**
  50852. * The unique identifier of the sound track in the scene.
  50853. */
  50854. id: number;
  50855. /**
  50856. * The list of sounds included in the sound track.
  50857. */
  50858. soundCollection: Array<Sound>;
  50859. private _outputAudioNode;
  50860. private _scene;
  50861. private _connectedAnalyser;
  50862. private _options;
  50863. private _isInitialized;
  50864. /**
  50865. * Creates a new sound track.
  50866. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50867. * @param scene Define the scene the sound track belongs to
  50868. * @param options
  50869. */
  50870. constructor(scene: Scene, options?: ISoundTrackOptions);
  50871. private _initializeSoundTrackAudioGraph;
  50872. /**
  50873. * Release the sound track and its associated resources
  50874. */
  50875. dispose(): void;
  50876. /**
  50877. * Adds a sound to this sound track
  50878. * @param sound define the sound to add
  50879. * @ignoreNaming
  50880. */
  50881. addSound(sound: Sound): void;
  50882. /**
  50883. * Removes a sound to this sound track
  50884. * @param sound define the sound to remove
  50885. * @ignoreNaming
  50886. */
  50887. removeSound(sound: Sound): void;
  50888. /**
  50889. * Set a global volume for the full sound track.
  50890. * @param newVolume Define the new volume of the sound track
  50891. */
  50892. setVolume(newVolume: number): void;
  50893. /**
  50894. * Switch the panning model to HRTF:
  50895. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  50896. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50897. */
  50898. switchPanningModelToHRTF(): void;
  50899. /**
  50900. * Switch the panning model to Equal Power:
  50901. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  50902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50903. */
  50904. switchPanningModelToEqualPower(): void;
  50905. /**
  50906. * Connect the sound track to an audio analyser allowing some amazing
  50907. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  50908. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50909. * @param analyser The analyser to connect to the engine
  50910. */
  50911. connectToAnalyser(analyser: Analyser): void;
  50912. }
  50913. }
  50914. declare module "babylonjs/Audio/audioSceneComponent" {
  50915. import { Sound } from "babylonjs/Audio/sound";
  50916. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  50917. import { Nullable } from "babylonjs/types";
  50918. import { Vector3 } from "babylonjs/Maths/math.vector";
  50919. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50920. import { Scene } from "babylonjs/scene";
  50921. import { AbstractScene } from "babylonjs/abstractScene";
  50922. import "babylonjs/Audio/audioEngine";
  50923. module "babylonjs/abstractScene" {
  50924. interface AbstractScene {
  50925. /**
  50926. * The list of sounds used in the scene.
  50927. */
  50928. sounds: Nullable<Array<Sound>>;
  50929. }
  50930. }
  50931. module "babylonjs/scene" {
  50932. interface Scene {
  50933. /**
  50934. * @hidden
  50935. * Backing field
  50936. */
  50937. _mainSoundTrack: SoundTrack;
  50938. /**
  50939. * The main sound track played by the scene.
  50940. * It contains your primary collection of sounds.
  50941. */
  50942. mainSoundTrack: SoundTrack;
  50943. /**
  50944. * The list of sound tracks added to the scene
  50945. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50946. */
  50947. soundTracks: Nullable<Array<SoundTrack>>;
  50948. /**
  50949. * Gets a sound using a given name
  50950. * @param name defines the name to search for
  50951. * @return the found sound or null if not found at all.
  50952. */
  50953. getSoundByName(name: string): Nullable<Sound>;
  50954. /**
  50955. * Gets or sets if audio support is enabled
  50956. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50957. */
  50958. audioEnabled: boolean;
  50959. /**
  50960. * Gets or sets if audio will be output to headphones
  50961. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50962. */
  50963. headphone: boolean;
  50964. /**
  50965. * Gets or sets custom audio listener position provider
  50966. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50967. */
  50968. audioListenerPositionProvider: Nullable<() => Vector3>;
  50969. /**
  50970. * Gets or sets a refresh rate when using 3D audio positioning
  50971. */
  50972. audioPositioningRefreshRate: number;
  50973. }
  50974. }
  50975. /**
  50976. * Defines the sound scene component responsible to manage any sounds
  50977. * in a given scene.
  50978. */
  50979. export class AudioSceneComponent implements ISceneSerializableComponent {
  50980. private static _CameraDirectionLH;
  50981. private static _CameraDirectionRH;
  50982. /**
  50983. * The component name helpful to identify the component in the list of scene components.
  50984. */
  50985. readonly name: string;
  50986. /**
  50987. * The scene the component belongs to.
  50988. */
  50989. scene: Scene;
  50990. private _audioEnabled;
  50991. /**
  50992. * Gets whether audio is enabled or not.
  50993. * Please use related enable/disable method to switch state.
  50994. */
  50995. get audioEnabled(): boolean;
  50996. private _headphone;
  50997. /**
  50998. * Gets whether audio is outputting to headphone or not.
  50999. * Please use the according Switch methods to change output.
  51000. */
  51001. get headphone(): boolean;
  51002. /**
  51003. * Gets or sets a refresh rate when using 3D audio positioning
  51004. */
  51005. audioPositioningRefreshRate: number;
  51006. private _audioListenerPositionProvider;
  51007. /**
  51008. * Gets the current audio listener position provider
  51009. */
  51010. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  51011. /**
  51012. * Sets a custom listener position for all sounds in the scene
  51013. * By default, this is the position of the first active camera
  51014. */
  51015. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  51016. /**
  51017. * Creates a new instance of the component for the given scene
  51018. * @param scene Defines the scene to register the component in
  51019. */
  51020. constructor(scene: Scene);
  51021. /**
  51022. * Registers the component in a given scene
  51023. */
  51024. register(): void;
  51025. /**
  51026. * Rebuilds the elements related to this component in case of
  51027. * context lost for instance.
  51028. */
  51029. rebuild(): void;
  51030. /**
  51031. * Serializes the component data to the specified json object
  51032. * @param serializationObject The object to serialize to
  51033. */
  51034. serialize(serializationObject: any): void;
  51035. /**
  51036. * Adds all the elements from the container to the scene
  51037. * @param container the container holding the elements
  51038. */
  51039. addFromContainer(container: AbstractScene): void;
  51040. /**
  51041. * Removes all the elements in the container from the scene
  51042. * @param container contains the elements to remove
  51043. * @param dispose if the removed element should be disposed (default: false)
  51044. */
  51045. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51046. /**
  51047. * Disposes the component and the associated resources.
  51048. */
  51049. dispose(): void;
  51050. /**
  51051. * Disables audio in the associated scene.
  51052. */
  51053. disableAudio(): void;
  51054. /**
  51055. * Enables audio in the associated scene.
  51056. */
  51057. enableAudio(): void;
  51058. /**
  51059. * Switch audio to headphone output.
  51060. */
  51061. switchAudioModeForHeadphones(): void;
  51062. /**
  51063. * Switch audio to normal speakers.
  51064. */
  51065. switchAudioModeForNormalSpeakers(): void;
  51066. private _cachedCameraDirection;
  51067. private _cachedCameraPosition;
  51068. private _lastCheck;
  51069. private _afterRender;
  51070. }
  51071. }
  51072. declare module "babylonjs/Audio/weightedsound" {
  51073. import { Sound } from "babylonjs/Audio/sound";
  51074. /**
  51075. * Wraps one or more Sound objects and selects one with random weight for playback.
  51076. */
  51077. export class WeightedSound {
  51078. /** When true a Sound will be selected and played when the current playing Sound completes. */
  51079. loop: boolean;
  51080. private _coneInnerAngle;
  51081. private _coneOuterAngle;
  51082. private _volume;
  51083. /** A Sound is currently playing. */
  51084. isPlaying: boolean;
  51085. /** A Sound is currently paused. */
  51086. isPaused: boolean;
  51087. private _sounds;
  51088. private _weights;
  51089. private _currentIndex?;
  51090. /**
  51091. * Creates a new WeightedSound from the list of sounds given.
  51092. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  51093. * @param sounds Array of Sounds that will be selected from.
  51094. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  51095. */
  51096. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  51097. /**
  51098. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  51099. */
  51100. get directionalConeInnerAngle(): number;
  51101. /**
  51102. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  51103. */
  51104. set directionalConeInnerAngle(value: number);
  51105. /**
  51106. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  51107. * Listener angles between innerAngle and outerAngle will falloff linearly.
  51108. */
  51109. get directionalConeOuterAngle(): number;
  51110. /**
  51111. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  51112. * Listener angles between innerAngle and outerAngle will falloff linearly.
  51113. */
  51114. set directionalConeOuterAngle(value: number);
  51115. /**
  51116. * Playback volume.
  51117. */
  51118. get volume(): number;
  51119. /**
  51120. * Playback volume.
  51121. */
  51122. set volume(value: number);
  51123. private _onended;
  51124. /**
  51125. * Suspend playback
  51126. */
  51127. pause(): void;
  51128. /**
  51129. * Stop playback
  51130. */
  51131. stop(): void;
  51132. /**
  51133. * Start playback.
  51134. * @param startOffset Position the clip head at a specific time in seconds.
  51135. */
  51136. play(startOffset?: number): void;
  51137. }
  51138. }
  51139. declare module "babylonjs/Audio/index" {
  51140. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  51141. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  51142. export * from "babylonjs/Audio/analyser";
  51143. export * from "babylonjs/Audio/audioEngine";
  51144. export * from "babylonjs/Audio/audioSceneComponent";
  51145. export * from "babylonjs/Audio/sound";
  51146. export * from "babylonjs/Audio/soundTrack";
  51147. export * from "babylonjs/Audio/weightedsound";
  51148. }
  51149. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  51150. import { Behavior } from "babylonjs/Behaviors/behavior";
  51151. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51152. import { BackEase } from "babylonjs/Animations/easing";
  51153. /**
  51154. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  51155. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51156. */
  51157. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  51158. /**
  51159. * Gets the name of the behavior.
  51160. */
  51161. get name(): string;
  51162. /**
  51163. * The easing function used by animations
  51164. */
  51165. static EasingFunction: BackEase;
  51166. /**
  51167. * The easing mode used by animations
  51168. */
  51169. static EasingMode: number;
  51170. /**
  51171. * The duration of the animation, in milliseconds
  51172. */
  51173. transitionDuration: number;
  51174. /**
  51175. * Length of the distance animated by the transition when lower radius is reached
  51176. */
  51177. lowerRadiusTransitionRange: number;
  51178. /**
  51179. * Length of the distance animated by the transition when upper radius is reached
  51180. */
  51181. upperRadiusTransitionRange: number;
  51182. private _autoTransitionRange;
  51183. /**
  51184. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  51185. */
  51186. get autoTransitionRange(): boolean;
  51187. /**
  51188. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  51189. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  51190. */
  51191. set autoTransitionRange(value: boolean);
  51192. private _attachedCamera;
  51193. private _onAfterCheckInputsObserver;
  51194. private _onMeshTargetChangedObserver;
  51195. /**
  51196. * Initializes the behavior.
  51197. */
  51198. init(): void;
  51199. /**
  51200. * Attaches the behavior to its arc rotate camera.
  51201. * @param camera Defines the camera to attach the behavior to
  51202. */
  51203. attach(camera: ArcRotateCamera): void;
  51204. /**
  51205. * Detaches the behavior from its current arc rotate camera.
  51206. */
  51207. detach(): void;
  51208. private _radiusIsAnimating;
  51209. private _radiusBounceTransition;
  51210. private _animatables;
  51211. private _cachedWheelPrecision;
  51212. /**
  51213. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  51214. * @param radiusLimit The limit to check against.
  51215. * @return Bool to indicate if at limit.
  51216. */
  51217. private _isRadiusAtLimit;
  51218. /**
  51219. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  51220. * @param radiusDelta The delta by which to animate to. Can be negative.
  51221. */
  51222. private _applyBoundRadiusAnimation;
  51223. /**
  51224. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  51225. */
  51226. protected _clearAnimationLocks(): void;
  51227. /**
  51228. * Stops and removes all animations that have been applied to the camera
  51229. */
  51230. stopAllAnimations(): void;
  51231. }
  51232. }
  51233. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  51234. import { Behavior } from "babylonjs/Behaviors/behavior";
  51235. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51236. import { ExponentialEase } from "babylonjs/Animations/easing";
  51237. import { Nullable } from "babylonjs/types";
  51238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51239. import { Vector3 } from "babylonjs/Maths/math.vector";
  51240. /**
  51241. * 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.
  51242. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51243. */
  51244. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  51245. /**
  51246. * Gets the name of the behavior.
  51247. */
  51248. get name(): string;
  51249. private _mode;
  51250. private _radiusScale;
  51251. private _positionScale;
  51252. private _defaultElevation;
  51253. private _elevationReturnTime;
  51254. private _elevationReturnWaitTime;
  51255. private _zoomStopsAnimation;
  51256. private _framingTime;
  51257. /**
  51258. * The easing function used by animations
  51259. */
  51260. static EasingFunction: ExponentialEase;
  51261. /**
  51262. * The easing mode used by animations
  51263. */
  51264. static EasingMode: number;
  51265. /**
  51266. * Sets the current mode used by the behavior
  51267. */
  51268. set mode(mode: number);
  51269. /**
  51270. * Gets current mode used by the behavior.
  51271. */
  51272. get mode(): number;
  51273. /**
  51274. * Sets the scale applied to the radius (1 by default)
  51275. */
  51276. set radiusScale(radius: number);
  51277. /**
  51278. * Gets the scale applied to the radius
  51279. */
  51280. get radiusScale(): number;
  51281. /**
  51282. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  51283. */
  51284. set positionScale(scale: number);
  51285. /**
  51286. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  51287. */
  51288. get positionScale(): number;
  51289. /**
  51290. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  51291. * behaviour is triggered, in radians.
  51292. */
  51293. set defaultElevation(elevation: number);
  51294. /**
  51295. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  51296. * behaviour is triggered, in radians.
  51297. */
  51298. get defaultElevation(): number;
  51299. /**
  51300. * Sets the time (in milliseconds) taken to return to the default beta position.
  51301. * Negative value indicates camera should not return to default.
  51302. */
  51303. set elevationReturnTime(speed: number);
  51304. /**
  51305. * Gets the time (in milliseconds) taken to return to the default beta position.
  51306. * Negative value indicates camera should not return to default.
  51307. */
  51308. get elevationReturnTime(): number;
  51309. /**
  51310. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  51311. */
  51312. set elevationReturnWaitTime(time: number);
  51313. /**
  51314. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  51315. */
  51316. get elevationReturnWaitTime(): number;
  51317. /**
  51318. * Sets the flag that indicates if user zooming should stop animation.
  51319. */
  51320. set zoomStopsAnimation(flag: boolean);
  51321. /**
  51322. * Gets the flag that indicates if user zooming should stop animation.
  51323. */
  51324. get zoomStopsAnimation(): boolean;
  51325. /**
  51326. * Sets the transition time when framing the mesh, in milliseconds
  51327. */
  51328. set framingTime(time: number);
  51329. /**
  51330. * Gets the transition time when framing the mesh, in milliseconds
  51331. */
  51332. get framingTime(): number;
  51333. /**
  51334. * Define if the behavior should automatically change the configured
  51335. * camera limits and sensibilities.
  51336. */
  51337. autoCorrectCameraLimitsAndSensibility: boolean;
  51338. private _onPrePointerObservableObserver;
  51339. private _onAfterCheckInputsObserver;
  51340. private _onMeshTargetChangedObserver;
  51341. private _attachedCamera;
  51342. private _isPointerDown;
  51343. private _lastInteractionTime;
  51344. /**
  51345. * Initializes the behavior.
  51346. */
  51347. init(): void;
  51348. /**
  51349. * Attaches the behavior to its arc rotate camera.
  51350. * @param camera Defines the camera to attach the behavior to
  51351. */
  51352. attach(camera: ArcRotateCamera): void;
  51353. /**
  51354. * Detaches the behavior from its current arc rotate camera.
  51355. */
  51356. detach(): void;
  51357. private _animatables;
  51358. private _betaIsAnimating;
  51359. private _betaTransition;
  51360. private _radiusTransition;
  51361. private _vectorTransition;
  51362. /**
  51363. * Targets the given mesh and updates zoom level accordingly.
  51364. * @param mesh The mesh to target.
  51365. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  51366. * @param onAnimationEnd Callback triggered at the end of the framing animation
  51367. */
  51368. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  51369. /**
  51370. * Targets the given mesh with its children and updates zoom level accordingly.
  51371. * @param mesh The mesh to target.
  51372. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  51373. * @param onAnimationEnd Callback triggered at the end of the framing animation
  51374. */
  51375. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  51376. /**
  51377. * Targets the given meshes with their children and updates zoom level accordingly.
  51378. * @param meshes The mesh to target.
  51379. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  51380. * @param onAnimationEnd Callback triggered at the end of the framing animation
  51381. */
  51382. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  51383. /**
  51384. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  51385. * @param minimumWorld Determines the smaller position of the bounding box extend
  51386. * @param maximumWorld Determines the bigger position of the bounding box extend
  51387. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  51388. * @param onAnimationEnd Callback triggered at the end of the framing animation
  51389. */
  51390. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  51391. /**
  51392. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  51393. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  51394. * frustum width.
  51395. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  51396. * to fully enclose the mesh in the viewing frustum.
  51397. */
  51398. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  51399. /**
  51400. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  51401. * is automatically returned to its default position (expected to be above ground plane).
  51402. */
  51403. private _maintainCameraAboveGround;
  51404. /**
  51405. * Returns the frustum slope based on the canvas ratio and camera FOV
  51406. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  51407. */
  51408. private _getFrustumSlope;
  51409. /**
  51410. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  51411. */
  51412. private _clearAnimationLocks;
  51413. /**
  51414. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  51415. */
  51416. private _applyUserInteraction;
  51417. /**
  51418. * Stops and removes all animations that have been applied to the camera
  51419. */
  51420. stopAllAnimations(): void;
  51421. /**
  51422. * Gets a value indicating if the user is moving the camera
  51423. */
  51424. get isUserIsMoving(): boolean;
  51425. /**
  51426. * The camera can move all the way towards the mesh.
  51427. */
  51428. static IgnoreBoundsSizeMode: number;
  51429. /**
  51430. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  51431. */
  51432. static FitFrustumSidesMode: number;
  51433. }
  51434. }
  51435. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  51436. import { Nullable } from "babylonjs/types";
  51437. import { Camera } from "babylonjs/Cameras/camera";
  51438. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  51439. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  51440. /**
  51441. * Base class for Camera Pointer Inputs.
  51442. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  51443. * for example usage.
  51444. */
  51445. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  51446. /**
  51447. * Defines the camera the input is attached to.
  51448. */
  51449. abstract camera: Camera;
  51450. /**
  51451. * Whether keyboard modifier keys are pressed at time of last mouse event.
  51452. */
  51453. protected _altKey: boolean;
  51454. protected _ctrlKey: boolean;
  51455. protected _metaKey: boolean;
  51456. protected _shiftKey: boolean;
  51457. /**
  51458. * Which mouse buttons were pressed at time of last mouse event.
  51459. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  51460. */
  51461. protected _buttonsPressed: number;
  51462. /**
  51463. * Defines the buttons associated with the input to handle camera move.
  51464. */
  51465. buttons: number[];
  51466. /**
  51467. * Attach the input controls to a specific dom element to get the input from.
  51468. * @param element Defines the element the controls should be listened from
  51469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51470. */
  51471. attachControl(noPreventDefault?: boolean): void;
  51472. /**
  51473. * Detach the current controls from the specified dom element.
  51474. */
  51475. detachControl(): void;
  51476. /**
  51477. * Gets the class name of the current input.
  51478. * @returns the class name
  51479. */
  51480. getClassName(): string;
  51481. /**
  51482. * Get the friendly name associated with the input class.
  51483. * @returns the input friendly name
  51484. */
  51485. getSimpleName(): string;
  51486. /**
  51487. * Called on pointer POINTERDOUBLETAP event.
  51488. * Override this method to provide functionality on POINTERDOUBLETAP event.
  51489. */
  51490. protected onDoubleTap(type: string): void;
  51491. /**
  51492. * Called on pointer POINTERMOVE event if only a single touch is active.
  51493. * Override this method to provide functionality.
  51494. */
  51495. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51496. /**
  51497. * Called on pointer POINTERMOVE event if multiple touches are active.
  51498. * Override this method to provide functionality.
  51499. */
  51500. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51501. /**
  51502. * Called on JS contextmenu event.
  51503. * Override this method to provide functionality.
  51504. */
  51505. protected onContextMenu(evt: PointerEvent): void;
  51506. /**
  51507. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  51508. * press.
  51509. * Override this method to provide functionality.
  51510. */
  51511. protected onButtonDown(evt: PointerEvent): void;
  51512. /**
  51513. * Called each time a new POINTERUP event occurs. Ie, for each button
  51514. * release.
  51515. * Override this method to provide functionality.
  51516. */
  51517. protected onButtonUp(evt: PointerEvent): void;
  51518. /**
  51519. * Called when window becomes inactive.
  51520. * Override this method to provide functionality.
  51521. */
  51522. protected onLostFocus(): void;
  51523. private _pointerInput;
  51524. private _observer;
  51525. private _onLostFocus;
  51526. private pointA;
  51527. private pointB;
  51528. }
  51529. }
  51530. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  51531. import { Nullable } from "babylonjs/types";
  51532. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51533. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  51534. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  51535. /**
  51536. * Manage the pointers inputs to control an arc rotate camera.
  51537. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51538. */
  51539. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  51540. /**
  51541. * Defines the camera the input is attached to.
  51542. */
  51543. camera: ArcRotateCamera;
  51544. /**
  51545. * Gets the class name of the current input.
  51546. * @returns the class name
  51547. */
  51548. getClassName(): string;
  51549. /**
  51550. * Defines the buttons associated with the input to handle camera move.
  51551. */
  51552. buttons: number[];
  51553. /**
  51554. * Defines the pointer angular sensibility along the X axis or how fast is
  51555. * the camera rotating.
  51556. */
  51557. angularSensibilityX: number;
  51558. /**
  51559. * Defines the pointer angular sensibility along the Y axis or how fast is
  51560. * the camera rotating.
  51561. */
  51562. angularSensibilityY: number;
  51563. /**
  51564. * Defines the pointer pinch precision or how fast is the camera zooming.
  51565. */
  51566. pinchPrecision: number;
  51567. /**
  51568. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51569. * from 0.
  51570. * It defines the percentage of current camera.radius to use as delta when
  51571. * pinch zoom is used.
  51572. */
  51573. pinchDeltaPercentage: number;
  51574. /**
  51575. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  51576. * that any object in the plane at the camera's target point will scale
  51577. * perfectly with finger motion.
  51578. * Overrides pinchDeltaPercentage and pinchPrecision.
  51579. */
  51580. useNaturalPinchZoom: boolean;
  51581. /**
  51582. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  51583. */
  51584. pinchZoom: boolean;
  51585. /**
  51586. * Defines the pointer panning sensibility or how fast is the camera moving.
  51587. */
  51588. panningSensibility: number;
  51589. /**
  51590. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  51591. */
  51592. multiTouchPanning: boolean;
  51593. /**
  51594. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  51595. * zoom (pinch) through multitouch.
  51596. */
  51597. multiTouchPanAndZoom: boolean;
  51598. /**
  51599. * Revers pinch action direction.
  51600. */
  51601. pinchInwards: boolean;
  51602. private _isPanClick;
  51603. private _twoFingerActivityCount;
  51604. private _isPinching;
  51605. /**
  51606. * Move camera from multi touch panning positions.
  51607. */
  51608. private _computeMultiTouchPanning;
  51609. /**
  51610. * Move camera from pinch zoom distances.
  51611. */
  51612. private _computePinchZoom;
  51613. /**
  51614. * Called on pointer POINTERMOVE event if only a single touch is active.
  51615. */
  51616. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51617. /**
  51618. * Called on pointer POINTERDOUBLETAP event.
  51619. */
  51620. protected onDoubleTap(type: string): void;
  51621. /**
  51622. * Called on pointer POINTERMOVE event if multiple touches are active.
  51623. */
  51624. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51625. /**
  51626. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  51627. * press.
  51628. */
  51629. protected onButtonDown(evt: PointerEvent): void;
  51630. /**
  51631. * Called each time a new POINTERUP event occurs. Ie, for each button
  51632. * release.
  51633. */
  51634. protected onButtonUp(evt: PointerEvent): void;
  51635. /**
  51636. * Called when window becomes inactive.
  51637. */
  51638. protected onLostFocus(): void;
  51639. }
  51640. }
  51641. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  51642. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51643. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  51644. /**
  51645. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  51646. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51647. */
  51648. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  51649. /**
  51650. * Defines the camera the input is attached to.
  51651. */
  51652. camera: ArcRotateCamera;
  51653. /**
  51654. * Defines the list of key codes associated with the up action (increase alpha)
  51655. */
  51656. keysUp: number[];
  51657. /**
  51658. * Defines the list of key codes associated with the down action (decrease alpha)
  51659. */
  51660. keysDown: number[];
  51661. /**
  51662. * Defines the list of key codes associated with the left action (increase beta)
  51663. */
  51664. keysLeft: number[];
  51665. /**
  51666. * Defines the list of key codes associated with the right action (decrease beta)
  51667. */
  51668. keysRight: number[];
  51669. /**
  51670. * Defines the list of key codes associated with the reset action.
  51671. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  51672. */
  51673. keysReset: number[];
  51674. /**
  51675. * Defines the panning sensibility of the inputs.
  51676. * (How fast is the camera panning)
  51677. */
  51678. panningSensibility: number;
  51679. /**
  51680. * Defines the zooming sensibility of the inputs.
  51681. * (How fast is the camera zooming)
  51682. */
  51683. zoomingSensibility: number;
  51684. /**
  51685. * Defines whether maintaining the alt key down switch the movement mode from
  51686. * orientation to zoom.
  51687. */
  51688. useAltToZoom: boolean;
  51689. /**
  51690. * Rotation speed of the camera
  51691. */
  51692. angularSpeed: number;
  51693. private _keys;
  51694. private _ctrlPressed;
  51695. private _altPressed;
  51696. private _onCanvasBlurObserver;
  51697. private _onKeyboardObserver;
  51698. private _engine;
  51699. private _scene;
  51700. /**
  51701. * Attach the input controls to a specific dom element to get the input from.
  51702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51703. */
  51704. attachControl(noPreventDefault?: boolean): void;
  51705. /**
  51706. * Detach the current controls from the specified dom element.
  51707. */
  51708. detachControl(): void;
  51709. /**
  51710. * Update the current camera state depending on the inputs that have been used this frame.
  51711. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51712. */
  51713. checkInputs(): void;
  51714. /**
  51715. * Gets the class name of the current input.
  51716. * @returns the class name
  51717. */
  51718. getClassName(): string;
  51719. /**
  51720. * Get the friendly name associated with the input class.
  51721. * @returns the input friendly name
  51722. */
  51723. getSimpleName(): string;
  51724. }
  51725. }
  51726. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  51727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  51729. /**
  51730. * Manage the mouse wheel inputs to control an arc rotate camera.
  51731. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51732. */
  51733. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  51734. /**
  51735. * Defines the camera the input is attached to.
  51736. */
  51737. camera: ArcRotateCamera;
  51738. /**
  51739. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  51740. */
  51741. wheelPrecision: number;
  51742. /**
  51743. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51744. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51745. */
  51746. wheelDeltaPercentage: number;
  51747. private _wheel;
  51748. private _observer;
  51749. private computeDeltaFromMouseWheelLegacyEvent;
  51750. /**
  51751. * Attach the input controls to a specific dom element to get the input from.
  51752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51753. */
  51754. attachControl(noPreventDefault?: boolean): void;
  51755. /**
  51756. * Detach the current controls from the specified dom element.
  51757. */
  51758. detachControl(): void;
  51759. /**
  51760. * Gets the class name of the current input.
  51761. * @returns the class name
  51762. */
  51763. getClassName(): string;
  51764. /**
  51765. * Get the friendly name associated with the input class.
  51766. * @returns the input friendly name
  51767. */
  51768. getSimpleName(): string;
  51769. }
  51770. }
  51771. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51772. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51773. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  51774. /**
  51775. * Default Inputs manager for the ArcRotateCamera.
  51776. * It groups all the default supported inputs for ease of use.
  51777. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51778. */
  51779. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  51780. /**
  51781. * Instantiates a new ArcRotateCameraInputsManager.
  51782. * @param camera Defines the camera the inputs belong to
  51783. */
  51784. constructor(camera: ArcRotateCamera);
  51785. /**
  51786. * Add mouse wheel input support to the input manager.
  51787. * @returns the current input manager
  51788. */
  51789. addMouseWheel(): ArcRotateCameraInputsManager;
  51790. /**
  51791. * Add pointers input support to the input manager.
  51792. * @returns the current input manager
  51793. */
  51794. addPointers(): ArcRotateCameraInputsManager;
  51795. /**
  51796. * Add keyboard input support to the input manager.
  51797. * @returns the current input manager
  51798. */
  51799. addKeyboard(): ArcRotateCameraInputsManager;
  51800. }
  51801. }
  51802. declare module "babylonjs/Cameras/arcRotateCamera" {
  51803. import { Observable } from "babylonjs/Misc/observable";
  51804. import { Nullable } from "babylonjs/types";
  51805. import { Scene } from "babylonjs/scene";
  51806. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  51807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51808. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51809. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51810. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  51811. import { Camera } from "babylonjs/Cameras/camera";
  51812. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  51813. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51814. import { Collider } from "babylonjs/Collisions/collider";
  51815. /**
  51816. * This represents an orbital type of camera.
  51817. *
  51818. * 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.
  51819. * 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.
  51820. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  51821. */
  51822. export class ArcRotateCamera extends TargetCamera {
  51823. /**
  51824. * Defines the rotation angle of the camera along the longitudinal axis.
  51825. */
  51826. alpha: number;
  51827. /**
  51828. * Defines the rotation angle of the camera along the latitudinal axis.
  51829. */
  51830. beta: number;
  51831. /**
  51832. * Defines the radius of the camera from it s target point.
  51833. */
  51834. radius: number;
  51835. protected _target: Vector3;
  51836. protected _targetHost: Nullable<AbstractMesh>;
  51837. /**
  51838. * Defines the target point of the camera.
  51839. * The camera looks towards it form the radius distance.
  51840. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  51841. */
  51842. get target(): Vector3;
  51843. set target(value: Vector3);
  51844. /**
  51845. * Define the current local position of the camera in the scene
  51846. */
  51847. get position(): Vector3;
  51848. set position(newPosition: Vector3);
  51849. protected _upToYMatrix: Matrix;
  51850. protected _YToUpMatrix: Matrix;
  51851. /**
  51852. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  51853. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  51854. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  51855. */
  51856. set upVector(vec: Vector3);
  51857. get upVector(): Vector3;
  51858. /**
  51859. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  51860. */
  51861. setMatUp(): void;
  51862. /**
  51863. * Current inertia value on the longitudinal axis.
  51864. * The bigger this number the longer it will take for the camera to stop.
  51865. */
  51866. inertialAlphaOffset: number;
  51867. /**
  51868. * Current inertia value on the latitudinal axis.
  51869. * The bigger this number the longer it will take for the camera to stop.
  51870. */
  51871. inertialBetaOffset: number;
  51872. /**
  51873. * Current inertia value on the radius axis.
  51874. * The bigger this number the longer it will take for the camera to stop.
  51875. */
  51876. inertialRadiusOffset: number;
  51877. /**
  51878. * Minimum allowed angle on the longitudinal axis.
  51879. * This can help limiting how the Camera is able to move in the scene.
  51880. */
  51881. lowerAlphaLimit: Nullable<number>;
  51882. /**
  51883. * Maximum allowed angle on the longitudinal axis.
  51884. * This can help limiting how the Camera is able to move in the scene.
  51885. */
  51886. upperAlphaLimit: Nullable<number>;
  51887. /**
  51888. * Minimum allowed angle on the latitudinal axis.
  51889. * This can help limiting how the Camera is able to move in the scene.
  51890. */
  51891. lowerBetaLimit: number;
  51892. /**
  51893. * Maximum allowed angle on the latitudinal axis.
  51894. * This can help limiting how the Camera is able to move in the scene.
  51895. */
  51896. upperBetaLimit: number;
  51897. /**
  51898. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  51899. * This can help limiting how the Camera is able to move in the scene.
  51900. */
  51901. lowerRadiusLimit: Nullable<number>;
  51902. /**
  51903. * Maximum allowed distance of the camera to the target (The camera can not get further).
  51904. * This can help limiting how the Camera is able to move in the scene.
  51905. */
  51906. upperRadiusLimit: Nullable<number>;
  51907. /**
  51908. * Defines the current inertia value used during panning of the camera along the X axis.
  51909. */
  51910. inertialPanningX: number;
  51911. /**
  51912. * Defines the current inertia value used during panning of the camera along the Y axis.
  51913. */
  51914. inertialPanningY: number;
  51915. /**
  51916. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  51917. * Basically if your fingers moves away from more than this distance you will be considered
  51918. * in pinch mode.
  51919. */
  51920. pinchToPanMaxDistance: number;
  51921. /**
  51922. * Defines the maximum distance the camera can pan.
  51923. * This could help keeping the camera always in your scene.
  51924. */
  51925. panningDistanceLimit: Nullable<number>;
  51926. /**
  51927. * Defines the target of the camera before panning.
  51928. */
  51929. panningOriginTarget: Vector3;
  51930. /**
  51931. * Defines the value of the inertia used during panning.
  51932. * 0 would mean stop inertia and one would mean no decelleration at all.
  51933. */
  51934. panningInertia: number;
  51935. /**
  51936. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  51937. */
  51938. get angularSensibilityX(): number;
  51939. set angularSensibilityX(value: number);
  51940. /**
  51941. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  51942. */
  51943. get angularSensibilityY(): number;
  51944. set angularSensibilityY(value: number);
  51945. /**
  51946. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  51947. */
  51948. get pinchPrecision(): number;
  51949. set pinchPrecision(value: number);
  51950. /**
  51951. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  51952. * It will be used instead of pinchDeltaPrecision if different from 0.
  51953. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51954. */
  51955. get pinchDeltaPercentage(): number;
  51956. set pinchDeltaPercentage(value: number);
  51957. /**
  51958. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  51959. * and pinch delta percentage.
  51960. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  51961. * that any object in the plane at the camera's target point will scale
  51962. * perfectly with finger motion.
  51963. */
  51964. get useNaturalPinchZoom(): boolean;
  51965. set useNaturalPinchZoom(value: boolean);
  51966. /**
  51967. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  51968. */
  51969. get panningSensibility(): number;
  51970. set panningSensibility(value: number);
  51971. /**
  51972. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  51973. */
  51974. get keysUp(): number[];
  51975. set keysUp(value: number[]);
  51976. /**
  51977. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  51978. */
  51979. get keysDown(): number[];
  51980. set keysDown(value: number[]);
  51981. /**
  51982. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  51983. */
  51984. get keysLeft(): number[];
  51985. set keysLeft(value: number[]);
  51986. /**
  51987. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  51988. */
  51989. get keysRight(): number[];
  51990. set keysRight(value: number[]);
  51991. /**
  51992. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  51993. */
  51994. get wheelPrecision(): number;
  51995. set wheelPrecision(value: number);
  51996. /**
  51997. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  51998. * It will be used instead of pinchDeltaPrecision if different from 0.
  51999. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  52000. */
  52001. get wheelDeltaPercentage(): number;
  52002. set wheelDeltaPercentage(value: number);
  52003. /**
  52004. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  52005. */
  52006. zoomOnFactor: number;
  52007. /**
  52008. * Defines a screen offset for the camera position.
  52009. */
  52010. targetScreenOffset: Vector2;
  52011. /**
  52012. * Allows the camera to be completely reversed.
  52013. * If false the camera can not arrive upside down.
  52014. */
  52015. allowUpsideDown: boolean;
  52016. /**
  52017. * Define if double tap/click is used to restore the previously saved state of the camera.
  52018. */
  52019. useInputToRestoreState: boolean;
  52020. /** @hidden */
  52021. _viewMatrix: Matrix;
  52022. /** @hidden */
  52023. _useCtrlForPanning: boolean;
  52024. /** @hidden */
  52025. _panningMouseButton: number;
  52026. /**
  52027. * Defines the input associated to the camera.
  52028. */
  52029. inputs: ArcRotateCameraInputsManager;
  52030. /** @hidden */
  52031. _reset: () => void;
  52032. /**
  52033. * Defines the allowed panning axis.
  52034. */
  52035. panningAxis: Vector3;
  52036. protected _transformedDirection: Vector3;
  52037. private _bouncingBehavior;
  52038. /**
  52039. * Gets the bouncing behavior of the camera if it has been enabled.
  52040. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  52041. */
  52042. get bouncingBehavior(): Nullable<BouncingBehavior>;
  52043. /**
  52044. * Defines if the bouncing behavior of the camera is enabled on the camera.
  52045. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  52046. */
  52047. get useBouncingBehavior(): boolean;
  52048. set useBouncingBehavior(value: boolean);
  52049. private _framingBehavior;
  52050. /**
  52051. * Gets the framing behavior of the camera if it has been enabled.
  52052. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  52053. */
  52054. get framingBehavior(): Nullable<FramingBehavior>;
  52055. /**
  52056. * Defines if the framing behavior of the camera is enabled on the camera.
  52057. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  52058. */
  52059. get useFramingBehavior(): boolean;
  52060. set useFramingBehavior(value: boolean);
  52061. private _autoRotationBehavior;
  52062. /**
  52063. * Gets the auto rotation behavior of the camera if it has been enabled.
  52064. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  52065. */
  52066. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  52067. /**
  52068. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  52069. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  52070. */
  52071. get useAutoRotationBehavior(): boolean;
  52072. set useAutoRotationBehavior(value: boolean);
  52073. /**
  52074. * Observable triggered when the mesh target has been changed on the camera.
  52075. */
  52076. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  52077. /**
  52078. * Event raised when the camera is colliding with a mesh.
  52079. */
  52080. onCollide: (collidedMesh: AbstractMesh) => void;
  52081. /**
  52082. * Defines whether the camera should check collision with the objects oh the scene.
  52083. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  52084. */
  52085. checkCollisions: boolean;
  52086. /**
  52087. * Defines the collision radius of the camera.
  52088. * This simulates a sphere around the camera.
  52089. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  52090. */
  52091. collisionRadius: Vector3;
  52092. protected _collider: Collider;
  52093. protected _previousPosition: Vector3;
  52094. protected _collisionVelocity: Vector3;
  52095. protected _newPosition: Vector3;
  52096. protected _previousAlpha: number;
  52097. protected _previousBeta: number;
  52098. protected _previousRadius: number;
  52099. protected _collisionTriggered: boolean;
  52100. protected _targetBoundingCenter: Nullable<Vector3>;
  52101. private _computationVector;
  52102. /**
  52103. * Instantiates a new ArcRotateCamera in a given scene
  52104. * @param name Defines the name of the camera
  52105. * @param alpha Defines the camera rotation along the longitudinal axis
  52106. * @param beta Defines the camera rotation along the latitudinal axis
  52107. * @param radius Defines the camera distance from its target
  52108. * @param target Defines the camera target
  52109. * @param scene Defines the scene the camera belongs to
  52110. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  52111. */
  52112. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  52113. /** @hidden */
  52114. _initCache(): void;
  52115. /** @hidden */
  52116. _updateCache(ignoreParentClass?: boolean): void;
  52117. protected _getTargetPosition(): Vector3;
  52118. private _storedAlpha;
  52119. private _storedBeta;
  52120. private _storedRadius;
  52121. private _storedTarget;
  52122. private _storedTargetScreenOffset;
  52123. /**
  52124. * Stores the current state of the camera (alpha, beta, radius and target)
  52125. * @returns the camera itself
  52126. */
  52127. storeState(): Camera;
  52128. /**
  52129. * @hidden
  52130. * Restored camera state. You must call storeState() first
  52131. */
  52132. _restoreStateValues(): boolean;
  52133. /** @hidden */
  52134. _isSynchronizedViewMatrix(): boolean;
  52135. /**
  52136. * Attach the input controls to a specific dom element to get the input from.
  52137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52138. */
  52139. attachControl(noPreventDefault?: boolean): void;
  52140. /**
  52141. * Attach the input controls to a specific dom element to get the input from.
  52142. * @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
  52143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52144. */
  52145. attachControl(ignored: any, noPreventDefault?: boolean): void;
  52146. /**
  52147. * Attached controls to the current camera.
  52148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52149. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  52150. */
  52151. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  52152. /**
  52153. * Attached controls to the current camera.
  52154. * @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
  52155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52156. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  52157. */
  52158. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  52159. /**
  52160. * Attached controls to the current camera.
  52161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52162. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  52163. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  52164. */
  52165. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  52166. /**
  52167. * Detach the current controls from the specified dom element.
  52168. */
  52169. detachControl(): void;
  52170. /**
  52171. * Detach the current controls from the specified dom element.
  52172. * @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
  52173. */
  52174. detachControl(ignored: any): void;
  52175. /** @hidden */
  52176. _checkInputs(): void;
  52177. protected _checkLimits(): void;
  52178. /**
  52179. * Rebuilds angles (alpha, beta) and radius from the give position and target
  52180. */
  52181. rebuildAnglesAndRadius(): void;
  52182. /**
  52183. * Use a position to define the current camera related information like alpha, beta and radius
  52184. * @param position Defines the position to set the camera at
  52185. */
  52186. setPosition(position: Vector3): void;
  52187. /**
  52188. * Defines the target the camera should look at.
  52189. * This will automatically adapt alpha beta and radius to fit within the new target.
  52190. * @param target Defines the new target as a Vector or a mesh
  52191. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  52192. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  52193. */
  52194. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  52195. /** @hidden */
  52196. _getViewMatrix(): Matrix;
  52197. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  52198. /**
  52199. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  52200. * @param meshes Defines the mesh to zoom on
  52201. * @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)
  52202. */
  52203. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  52204. /**
  52205. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  52206. * The target will be changed but the radius
  52207. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  52208. * @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)
  52209. */
  52210. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  52211. min: Vector3;
  52212. max: Vector3;
  52213. distance: number;
  52214. }, doNotUpdateMaxZ?: boolean): void;
  52215. /**
  52216. * @override
  52217. * Override Camera.createRigCamera
  52218. */
  52219. createRigCamera(name: string, cameraIndex: number): Camera;
  52220. /**
  52221. * @hidden
  52222. * @override
  52223. * Override Camera._updateRigCameras
  52224. */
  52225. _updateRigCameras(): void;
  52226. /**
  52227. * Destroy the camera and release the current resources hold by it.
  52228. */
  52229. dispose(): void;
  52230. /**
  52231. * Gets the current object class name.
  52232. * @return the class name
  52233. */
  52234. getClassName(): string;
  52235. }
  52236. }
  52237. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  52238. import { Behavior } from "babylonjs/Behaviors/behavior";
  52239. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52240. /**
  52241. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  52242. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  52243. */
  52244. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  52245. /**
  52246. * Gets the name of the behavior.
  52247. */
  52248. get name(): string;
  52249. private _zoomStopsAnimation;
  52250. private _idleRotationSpeed;
  52251. private _idleRotationWaitTime;
  52252. private _idleRotationSpinupTime;
  52253. /**
  52254. * Sets the flag that indicates if user zooming should stop animation.
  52255. */
  52256. set zoomStopsAnimation(flag: boolean);
  52257. /**
  52258. * Gets the flag that indicates if user zooming should stop animation.
  52259. */
  52260. get zoomStopsAnimation(): boolean;
  52261. /**
  52262. * Sets the default speed at which the camera rotates around the model.
  52263. */
  52264. set idleRotationSpeed(speed: number);
  52265. /**
  52266. * Gets the default speed at which the camera rotates around the model.
  52267. */
  52268. get idleRotationSpeed(): number;
  52269. /**
  52270. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  52271. */
  52272. set idleRotationWaitTime(time: number);
  52273. /**
  52274. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  52275. */
  52276. get idleRotationWaitTime(): number;
  52277. /**
  52278. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  52279. */
  52280. set idleRotationSpinupTime(time: number);
  52281. /**
  52282. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  52283. */
  52284. get idleRotationSpinupTime(): number;
  52285. /**
  52286. * Gets a value indicating if the camera is currently rotating because of this behavior
  52287. */
  52288. get rotationInProgress(): boolean;
  52289. private _onPrePointerObservableObserver;
  52290. private _onAfterCheckInputsObserver;
  52291. private _attachedCamera;
  52292. private _isPointerDown;
  52293. private _lastFrameTime;
  52294. private _lastInteractionTime;
  52295. private _cameraRotationSpeed;
  52296. /**
  52297. * Initializes the behavior.
  52298. */
  52299. init(): void;
  52300. /**
  52301. * Attaches the behavior to its arc rotate camera.
  52302. * @param camera Defines the camera to attach the behavior to
  52303. */
  52304. attach(camera: ArcRotateCamera): void;
  52305. /**
  52306. * Detaches the behavior from its current arc rotate camera.
  52307. */
  52308. detach(): void;
  52309. /**
  52310. * Returns true if user is scrolling.
  52311. * @return true if user is scrolling.
  52312. */
  52313. private _userIsZooming;
  52314. private _lastFrameRadius;
  52315. private _shouldAnimationStopForInteraction;
  52316. /**
  52317. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  52318. */
  52319. private _applyUserInteraction;
  52320. private _userIsMoving;
  52321. }
  52322. }
  52323. declare module "babylonjs/Behaviors/Cameras/index" {
  52324. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  52325. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  52326. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  52327. }
  52328. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  52329. import { Mesh } from "babylonjs/Meshes/mesh";
  52330. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52331. import { Behavior } from "babylonjs/Behaviors/behavior";
  52332. /**
  52333. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  52334. */
  52335. export class AttachToBoxBehavior implements Behavior<Mesh> {
  52336. private ui;
  52337. /**
  52338. * The name of the behavior
  52339. */
  52340. name: string;
  52341. /**
  52342. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  52343. */
  52344. distanceAwayFromFace: number;
  52345. /**
  52346. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  52347. */
  52348. distanceAwayFromBottomOfFace: number;
  52349. private _faceVectors;
  52350. private _target;
  52351. private _scene;
  52352. private _onRenderObserver;
  52353. private _tmpMatrix;
  52354. private _tmpVector;
  52355. /**
  52356. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  52357. * @param ui The transform node that should be attached to the mesh
  52358. */
  52359. constructor(ui: TransformNode);
  52360. /**
  52361. * Initializes the behavior
  52362. */
  52363. init(): void;
  52364. private _closestFace;
  52365. private _zeroVector;
  52366. private _lookAtTmpMatrix;
  52367. private _lookAtToRef;
  52368. /**
  52369. * Attaches the AttachToBoxBehavior to the passed in mesh
  52370. * @param target The mesh that the specified node will be attached to
  52371. */
  52372. attach(target: Mesh): void;
  52373. /**
  52374. * Detaches the behavior from the mesh
  52375. */
  52376. detach(): void;
  52377. }
  52378. }
  52379. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  52380. import { Behavior } from "babylonjs/Behaviors/behavior";
  52381. import { Mesh } from "babylonjs/Meshes/mesh";
  52382. /**
  52383. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  52384. */
  52385. export class FadeInOutBehavior implements Behavior<Mesh> {
  52386. /**
  52387. * Time in milliseconds to delay before fading in (Default: 0)
  52388. */
  52389. delay: number;
  52390. /**
  52391. * Time in milliseconds for the mesh to fade in (Default: 300)
  52392. */
  52393. fadeInTime: number;
  52394. private _millisecondsPerFrame;
  52395. private _hovered;
  52396. private _hoverValue;
  52397. private _ownerNode;
  52398. /**
  52399. * Instantiates the FadeInOutBehavior
  52400. */
  52401. constructor();
  52402. /**
  52403. * The name of the behavior
  52404. */
  52405. get name(): string;
  52406. /**
  52407. * Initializes the behavior
  52408. */
  52409. init(): void;
  52410. /**
  52411. * Attaches the fade behavior on the passed in mesh
  52412. * @param ownerNode The mesh that will be faded in/out once attached
  52413. */
  52414. attach(ownerNode: Mesh): void;
  52415. /**
  52416. * Detaches the behavior from the mesh
  52417. */
  52418. detach(): void;
  52419. /**
  52420. * Triggers the mesh to begin fading in or out
  52421. * @param value if the object should fade in or out (true to fade in)
  52422. */
  52423. fadeIn(value: boolean): void;
  52424. private _update;
  52425. private _setAllVisibility;
  52426. }
  52427. }
  52428. declare module "babylonjs/Misc/pivotTools" {
  52429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52430. /**
  52431. * Class containing a set of static utilities functions for managing Pivots
  52432. * @hidden
  52433. */
  52434. export class PivotTools {
  52435. private static _PivotCached;
  52436. private static _OldPivotPoint;
  52437. private static _PivotTranslation;
  52438. private static _PivotTmpVector;
  52439. private static _PivotPostMultiplyPivotMatrix;
  52440. /** @hidden */
  52441. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  52442. /** @hidden */
  52443. static _RestorePivotPoint(mesh: AbstractMesh): void;
  52444. }
  52445. }
  52446. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  52447. import { Scene } from "babylonjs/scene";
  52448. import { Vector4 } from "babylonjs/Maths/math.vector";
  52449. import { Mesh } from "babylonjs/Meshes/mesh";
  52450. import { Nullable } from "babylonjs/types";
  52451. import { Plane } from "babylonjs/Maths/math.plane";
  52452. /**
  52453. * Class containing static functions to help procedurally build meshes
  52454. */
  52455. export class PlaneBuilder {
  52456. /**
  52457. * Creates a plane mesh
  52458. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52459. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52460. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52464. * @param name defines the name of the mesh
  52465. * @param options defines the options used to create the mesh
  52466. * @param scene defines the hosting scene
  52467. * @returns the plane mesh
  52468. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52469. */
  52470. static CreatePlane(name: string, options: {
  52471. size?: number;
  52472. width?: number;
  52473. height?: number;
  52474. sideOrientation?: number;
  52475. frontUVs?: Vector4;
  52476. backUVs?: Vector4;
  52477. updatable?: boolean;
  52478. sourcePlane?: Plane;
  52479. }, scene?: Nullable<Scene>): Mesh;
  52480. }
  52481. }
  52482. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  52483. import { Behavior } from "babylonjs/Behaviors/behavior";
  52484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52485. import { Observable } from "babylonjs/Misc/observable";
  52486. import { Vector3 } from "babylonjs/Maths/math.vector";
  52487. import { Ray } from "babylonjs/Culling/ray";
  52488. import "babylonjs/Meshes/Builders/planeBuilder";
  52489. /**
  52490. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  52491. */
  52492. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  52493. private static _AnyMouseID;
  52494. /**
  52495. * Abstract mesh the behavior is set on
  52496. */
  52497. attachedNode: AbstractMesh;
  52498. private _dragPlane;
  52499. private _scene;
  52500. private _pointerObserver;
  52501. private _beforeRenderObserver;
  52502. private static _planeScene;
  52503. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  52504. /**
  52505. * 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)
  52506. */
  52507. maxDragAngle: number;
  52508. /**
  52509. * @hidden
  52510. */
  52511. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  52512. /**
  52513. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  52514. */
  52515. currentDraggingPointerID: number;
  52516. /**
  52517. * The last position where the pointer hit the drag plane in world space
  52518. */
  52519. lastDragPosition: Vector3;
  52520. /**
  52521. * If the behavior is currently in a dragging state
  52522. */
  52523. dragging: boolean;
  52524. /**
  52525. * 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)
  52526. */
  52527. dragDeltaRatio: number;
  52528. /**
  52529. * If the drag plane orientation should be updated during the dragging (Default: true)
  52530. */
  52531. updateDragPlane: boolean;
  52532. private _debugMode;
  52533. private _moving;
  52534. /**
  52535. * Fires each time the attached mesh is dragged with the pointer
  52536. * * delta between last drag position and current drag position in world space
  52537. * * dragDistance along the drag axis
  52538. * * dragPlaneNormal normal of the current drag plane used during the drag
  52539. * * dragPlanePoint in world space where the drag intersects the drag plane
  52540. */
  52541. onDragObservable: Observable<{
  52542. delta: Vector3;
  52543. dragPlanePoint: Vector3;
  52544. dragPlaneNormal: Vector3;
  52545. dragDistance: number;
  52546. pointerId: number;
  52547. }>;
  52548. /**
  52549. * Fires each time a drag begins (eg. mouse down on mesh)
  52550. */
  52551. onDragStartObservable: Observable<{
  52552. dragPlanePoint: Vector3;
  52553. pointerId: number;
  52554. }>;
  52555. /**
  52556. * Fires each time a drag ends (eg. mouse release after drag)
  52557. */
  52558. onDragEndObservable: Observable<{
  52559. dragPlanePoint: Vector3;
  52560. pointerId: number;
  52561. }>;
  52562. /**
  52563. * If the attached mesh should be moved when dragged
  52564. */
  52565. moveAttached: boolean;
  52566. /**
  52567. * If the drag behavior will react to drag events (Default: true)
  52568. */
  52569. enabled: boolean;
  52570. /**
  52571. * If pointer events should start and release the drag (Default: true)
  52572. */
  52573. startAndReleaseDragOnPointerEvents: boolean;
  52574. /**
  52575. * If camera controls should be detached during the drag
  52576. */
  52577. detachCameraControls: boolean;
  52578. /**
  52579. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  52580. */
  52581. useObjectOrientationForDragging: boolean;
  52582. private _options;
  52583. /**
  52584. * Gets the options used by the behavior
  52585. */
  52586. get options(): {
  52587. dragAxis?: Vector3;
  52588. dragPlaneNormal?: Vector3;
  52589. };
  52590. /**
  52591. * Sets the options used by the behavior
  52592. */
  52593. set options(options: {
  52594. dragAxis?: Vector3;
  52595. dragPlaneNormal?: Vector3;
  52596. });
  52597. /**
  52598. * Creates a pointer drag behavior that can be attached to a mesh
  52599. * @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)
  52600. */
  52601. constructor(options?: {
  52602. dragAxis?: Vector3;
  52603. dragPlaneNormal?: Vector3;
  52604. });
  52605. /**
  52606. * Predicate to determine if it is valid to move the object to a new position when it is moved
  52607. */
  52608. validateDrag: (targetPosition: Vector3) => boolean;
  52609. /**
  52610. * The name of the behavior
  52611. */
  52612. get name(): string;
  52613. /**
  52614. * Initializes the behavior
  52615. */
  52616. init(): void;
  52617. private _tmpVector;
  52618. private _alternatePickedPoint;
  52619. private _worldDragAxis;
  52620. private _targetPosition;
  52621. private _attachedToElement;
  52622. /**
  52623. * Attaches the drag behavior the passed in mesh
  52624. * @param ownerNode The mesh that will be dragged around once attached
  52625. * @param predicate Predicate to use for pick filtering
  52626. */
  52627. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  52628. /**
  52629. * Force release the drag action by code.
  52630. */
  52631. releaseDrag(): void;
  52632. private _startDragRay;
  52633. private _lastPointerRay;
  52634. /**
  52635. * Simulates the start of a pointer drag event on the behavior
  52636. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  52637. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  52638. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  52639. */
  52640. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  52641. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  52642. private _dragDelta;
  52643. protected _moveDrag(ray: Ray): void;
  52644. private _pickWithRayOnDragPlane;
  52645. private _pointA;
  52646. private _pointC;
  52647. private _localAxis;
  52648. private _lookAt;
  52649. private _updateDragPlanePosition;
  52650. /**
  52651. * Detaches the behavior from the mesh
  52652. */
  52653. detach(): void;
  52654. }
  52655. }
  52656. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  52657. import { Mesh } from "babylonjs/Meshes/mesh";
  52658. import { Behavior } from "babylonjs/Behaviors/behavior";
  52659. /**
  52660. * A behavior that when attached to a mesh will allow the mesh to be scaled
  52661. */
  52662. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  52663. private _dragBehaviorA;
  52664. private _dragBehaviorB;
  52665. private _startDistance;
  52666. private _initialScale;
  52667. private _targetScale;
  52668. private _ownerNode;
  52669. private _sceneRenderObserver;
  52670. /**
  52671. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  52672. */
  52673. constructor();
  52674. /**
  52675. * The name of the behavior
  52676. */
  52677. get name(): string;
  52678. /**
  52679. * Initializes the behavior
  52680. */
  52681. init(): void;
  52682. private _getCurrentDistance;
  52683. /**
  52684. * Attaches the scale behavior the passed in mesh
  52685. * @param ownerNode The mesh that will be scaled around once attached
  52686. */
  52687. attach(ownerNode: Mesh): void;
  52688. /**
  52689. * Detaches the behavior from the mesh
  52690. */
  52691. detach(): void;
  52692. }
  52693. }
  52694. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  52695. import { Behavior } from "babylonjs/Behaviors/behavior";
  52696. import { Mesh } from "babylonjs/Meshes/mesh";
  52697. import { Observable } from "babylonjs/Misc/observable";
  52698. /**
  52699. * 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
  52700. */
  52701. export class SixDofDragBehavior implements Behavior<Mesh> {
  52702. private static _virtualScene;
  52703. private _ownerNode;
  52704. private _sceneRenderObserver;
  52705. private _scene;
  52706. private _targetPosition;
  52707. private _virtualOriginMesh;
  52708. private _virtualDragMesh;
  52709. private _pointerObserver;
  52710. private _moving;
  52711. private _startingOrientation;
  52712. private _attachedToElement;
  52713. /**
  52714. * 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)
  52715. */
  52716. private zDragFactor;
  52717. /**
  52718. * If the object should rotate to face the drag origin
  52719. */
  52720. rotateDraggedObject: boolean;
  52721. /**
  52722. * If the behavior is currently in a dragging state
  52723. */
  52724. dragging: boolean;
  52725. /**
  52726. * 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)
  52727. */
  52728. dragDeltaRatio: number;
  52729. /**
  52730. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  52731. */
  52732. currentDraggingPointerID: number;
  52733. /**
  52734. * If camera controls should be detached during the drag
  52735. */
  52736. detachCameraControls: boolean;
  52737. /**
  52738. * Fires each time a drag starts
  52739. */
  52740. onDragStartObservable: Observable<{}>;
  52741. /**
  52742. * Fires each time a drag happens
  52743. */
  52744. onDragObservable: Observable<void>;
  52745. /**
  52746. * Fires each time a drag ends (eg. mouse release after drag)
  52747. */
  52748. onDragEndObservable: Observable<{}>;
  52749. /**
  52750. * 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
  52751. */
  52752. constructor();
  52753. /**
  52754. * The name of the behavior
  52755. */
  52756. get name(): string;
  52757. /**
  52758. * Initializes the behavior
  52759. */
  52760. init(): void;
  52761. /**
  52762. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  52763. */
  52764. private get _pointerCamera();
  52765. /**
  52766. * Attaches the scale behavior the passed in mesh
  52767. * @param ownerNode The mesh that will be scaled around once attached
  52768. */
  52769. attach(ownerNode: Mesh): void;
  52770. /**
  52771. * Detaches the behavior from the mesh
  52772. */
  52773. detach(): void;
  52774. }
  52775. }
  52776. declare module "babylonjs/Behaviors/Meshes/index" {
  52777. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  52778. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  52779. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  52780. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52781. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  52782. }
  52783. declare module "babylonjs/Behaviors/index" {
  52784. export * from "babylonjs/Behaviors/behavior";
  52785. export * from "babylonjs/Behaviors/Cameras/index";
  52786. export * from "babylonjs/Behaviors/Meshes/index";
  52787. }
  52788. declare module "babylonjs/Bones/boneIKController" {
  52789. import { Bone } from "babylonjs/Bones/bone";
  52790. import { Vector3 } from "babylonjs/Maths/math.vector";
  52791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52792. import { Nullable } from "babylonjs/types";
  52793. /**
  52794. * Class used to apply inverse kinematics to bones
  52795. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  52796. */
  52797. export class BoneIKController {
  52798. private static _tmpVecs;
  52799. private static _tmpQuat;
  52800. private static _tmpMats;
  52801. /**
  52802. * Gets or sets the target mesh
  52803. */
  52804. targetMesh: AbstractMesh;
  52805. /** Gets or sets the mesh used as pole */
  52806. poleTargetMesh: AbstractMesh;
  52807. /**
  52808. * Gets or sets the bone used as pole
  52809. */
  52810. poleTargetBone: Nullable<Bone>;
  52811. /**
  52812. * Gets or sets the target position
  52813. */
  52814. targetPosition: Vector3;
  52815. /**
  52816. * Gets or sets the pole target position
  52817. */
  52818. poleTargetPosition: Vector3;
  52819. /**
  52820. * Gets or sets the pole target local offset
  52821. */
  52822. poleTargetLocalOffset: Vector3;
  52823. /**
  52824. * Gets or sets the pole angle
  52825. */
  52826. poleAngle: number;
  52827. /**
  52828. * Gets or sets the mesh associated with the controller
  52829. */
  52830. mesh: AbstractMesh;
  52831. /**
  52832. * 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)
  52833. */
  52834. slerpAmount: number;
  52835. private _bone1Quat;
  52836. private _bone1Mat;
  52837. private _bone2Ang;
  52838. private _bone1;
  52839. private _bone2;
  52840. private _bone1Length;
  52841. private _bone2Length;
  52842. private _maxAngle;
  52843. private _maxReach;
  52844. private _rightHandedSystem;
  52845. private _bendAxis;
  52846. private _slerping;
  52847. private _adjustRoll;
  52848. /**
  52849. * Gets or sets maximum allowed angle
  52850. */
  52851. get maxAngle(): number;
  52852. set maxAngle(value: number);
  52853. /**
  52854. * Creates a new BoneIKController
  52855. * @param mesh defines the mesh to control
  52856. * @param bone defines the bone to control
  52857. * @param options defines options to set up the controller
  52858. */
  52859. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  52860. targetMesh?: AbstractMesh;
  52861. poleTargetMesh?: AbstractMesh;
  52862. poleTargetBone?: Bone;
  52863. poleTargetLocalOffset?: Vector3;
  52864. poleAngle?: number;
  52865. bendAxis?: Vector3;
  52866. maxAngle?: number;
  52867. slerpAmount?: number;
  52868. });
  52869. private _setMaxAngle;
  52870. /**
  52871. * Force the controller to update the bones
  52872. */
  52873. update(): void;
  52874. }
  52875. }
  52876. declare module "babylonjs/Bones/boneLookController" {
  52877. import { Vector3 } from "babylonjs/Maths/math.vector";
  52878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52879. import { Bone } from "babylonjs/Bones/bone";
  52880. import { Space } from "babylonjs/Maths/math.axis";
  52881. /**
  52882. * Class used to make a bone look toward a point in space
  52883. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  52884. */
  52885. export class BoneLookController {
  52886. private static _tmpVecs;
  52887. private static _tmpQuat;
  52888. private static _tmpMats;
  52889. /**
  52890. * The target Vector3 that the bone will look at
  52891. */
  52892. target: Vector3;
  52893. /**
  52894. * The mesh that the bone is attached to
  52895. */
  52896. mesh: AbstractMesh;
  52897. /**
  52898. * The bone that will be looking to the target
  52899. */
  52900. bone: Bone;
  52901. /**
  52902. * The up axis of the coordinate system that is used when the bone is rotated
  52903. */
  52904. upAxis: Vector3;
  52905. /**
  52906. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  52907. */
  52908. upAxisSpace: Space;
  52909. /**
  52910. * Used to make an adjustment to the yaw of the bone
  52911. */
  52912. adjustYaw: number;
  52913. /**
  52914. * Used to make an adjustment to the pitch of the bone
  52915. */
  52916. adjustPitch: number;
  52917. /**
  52918. * Used to make an adjustment to the roll of the bone
  52919. */
  52920. adjustRoll: number;
  52921. /**
  52922. * 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)
  52923. */
  52924. slerpAmount: number;
  52925. private _minYaw;
  52926. private _maxYaw;
  52927. private _minPitch;
  52928. private _maxPitch;
  52929. private _minYawSin;
  52930. private _minYawCos;
  52931. private _maxYawSin;
  52932. private _maxYawCos;
  52933. private _midYawConstraint;
  52934. private _minPitchTan;
  52935. private _maxPitchTan;
  52936. private _boneQuat;
  52937. private _slerping;
  52938. private _transformYawPitch;
  52939. private _transformYawPitchInv;
  52940. private _firstFrameSkipped;
  52941. private _yawRange;
  52942. private _fowardAxis;
  52943. /**
  52944. * Gets or sets the minimum yaw angle that the bone can look to
  52945. */
  52946. get minYaw(): number;
  52947. set minYaw(value: number);
  52948. /**
  52949. * Gets or sets the maximum yaw angle that the bone can look to
  52950. */
  52951. get maxYaw(): number;
  52952. set maxYaw(value: number);
  52953. /**
  52954. * Gets or sets the minimum pitch angle that the bone can look to
  52955. */
  52956. get minPitch(): number;
  52957. set minPitch(value: number);
  52958. /**
  52959. * Gets or sets the maximum pitch angle that the bone can look to
  52960. */
  52961. get maxPitch(): number;
  52962. set maxPitch(value: number);
  52963. /**
  52964. * Create a BoneLookController
  52965. * @param mesh the mesh that the bone belongs to
  52966. * @param bone the bone that will be looking to the target
  52967. * @param target the target Vector3 to look at
  52968. * @param options optional settings:
  52969. * * maxYaw: the maximum angle the bone will yaw to
  52970. * * minYaw: the minimum angle the bone will yaw to
  52971. * * maxPitch: the maximum angle the bone will pitch to
  52972. * * minPitch: the minimum angle the bone will yaw to
  52973. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  52974. * * upAxis: the up axis of the coordinate system
  52975. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  52976. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  52977. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  52978. * * adjustYaw: used to make an adjustment to the yaw of the bone
  52979. * * adjustPitch: used to make an adjustment to the pitch of the bone
  52980. * * adjustRoll: used to make an adjustment to the roll of the bone
  52981. **/
  52982. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  52983. maxYaw?: number;
  52984. minYaw?: number;
  52985. maxPitch?: number;
  52986. minPitch?: number;
  52987. slerpAmount?: number;
  52988. upAxis?: Vector3;
  52989. upAxisSpace?: Space;
  52990. yawAxis?: Vector3;
  52991. pitchAxis?: Vector3;
  52992. adjustYaw?: number;
  52993. adjustPitch?: number;
  52994. adjustRoll?: number;
  52995. });
  52996. /**
  52997. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  52998. */
  52999. update(): void;
  53000. private _getAngleDiff;
  53001. private _getAngleBetween;
  53002. private _isAngleBetween;
  53003. }
  53004. }
  53005. declare module "babylonjs/Bones/index" {
  53006. export * from "babylonjs/Bones/bone";
  53007. export * from "babylonjs/Bones/boneIKController";
  53008. export * from "babylonjs/Bones/boneLookController";
  53009. export * from "babylonjs/Bones/skeleton";
  53010. }
  53011. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  53012. import { Nullable } from "babylonjs/types";
  53013. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  53014. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53015. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53016. /**
  53017. * Manage the gamepad inputs to control an arc rotate camera.
  53018. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53019. */
  53020. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  53021. /**
  53022. * Defines the camera the input is attached to.
  53023. */
  53024. camera: ArcRotateCamera;
  53025. /**
  53026. * Defines the gamepad the input is gathering event from.
  53027. */
  53028. gamepad: Nullable<Gamepad>;
  53029. /**
  53030. * Defines the gamepad rotation sensiblity.
  53031. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53032. */
  53033. gamepadRotationSensibility: number;
  53034. /**
  53035. * Defines the gamepad move sensiblity.
  53036. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53037. */
  53038. gamepadMoveSensibility: number;
  53039. private _yAxisScale;
  53040. /**
  53041. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  53042. */
  53043. get invertYAxis(): boolean;
  53044. set invertYAxis(value: boolean);
  53045. private _onGamepadConnectedObserver;
  53046. private _onGamepadDisconnectedObserver;
  53047. /**
  53048. * Attach the input controls to a specific dom element to get the input from.
  53049. */
  53050. attachControl(): void;
  53051. /**
  53052. * Detach the current controls from the specified dom element.
  53053. */
  53054. detachControl(): void;
  53055. /**
  53056. * Update the current camera state depending on the inputs that have been used this frame.
  53057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53058. */
  53059. checkInputs(): void;
  53060. /**
  53061. * Gets the class name of the current intput.
  53062. * @returns the class name
  53063. */
  53064. getClassName(): string;
  53065. /**
  53066. * Get the friendly name associated with the input class.
  53067. * @returns the input friendly name
  53068. */
  53069. getSimpleName(): string;
  53070. }
  53071. }
  53072. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  53073. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  53074. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53075. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  53076. interface ArcRotateCameraInputsManager {
  53077. /**
  53078. * Add orientation input support to the input manager.
  53079. * @returns the current input manager
  53080. */
  53081. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  53082. }
  53083. }
  53084. /**
  53085. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  53086. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53087. */
  53088. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  53089. /**
  53090. * Defines the camera the input is attached to.
  53091. */
  53092. camera: ArcRotateCamera;
  53093. /**
  53094. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  53095. */
  53096. alphaCorrection: number;
  53097. /**
  53098. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  53099. */
  53100. gammaCorrection: number;
  53101. private _alpha;
  53102. private _gamma;
  53103. private _dirty;
  53104. private _deviceOrientationHandler;
  53105. /**
  53106. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  53107. */
  53108. constructor();
  53109. /**
  53110. * Attach the input controls to a specific dom element to get the input from.
  53111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53112. */
  53113. attachControl(noPreventDefault?: boolean): void;
  53114. /** @hidden */
  53115. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  53116. /**
  53117. * Update the current camera state depending on the inputs that have been used this frame.
  53118. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53119. */
  53120. checkInputs(): void;
  53121. /**
  53122. * Detach the current controls from the specified dom element.
  53123. */
  53124. detachControl(): void;
  53125. /**
  53126. * Gets the class name of the current input.
  53127. * @returns the class name
  53128. */
  53129. getClassName(): string;
  53130. /**
  53131. * Get the friendly name associated with the input class.
  53132. * @returns the input friendly name
  53133. */
  53134. getSimpleName(): string;
  53135. }
  53136. }
  53137. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  53138. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53139. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  53140. /**
  53141. * Listen to mouse events to control the camera.
  53142. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53143. */
  53144. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  53145. /**
  53146. * Defines the camera the input is attached to.
  53147. */
  53148. camera: FlyCamera;
  53149. /**
  53150. * Defines if touch is enabled. (Default is true.)
  53151. */
  53152. touchEnabled: boolean;
  53153. /**
  53154. * Defines the buttons associated with the input to handle camera rotation.
  53155. */
  53156. buttons: number[];
  53157. /**
  53158. * Assign buttons for Yaw control.
  53159. */
  53160. buttonsYaw: number[];
  53161. /**
  53162. * Assign buttons for Pitch control.
  53163. */
  53164. buttonsPitch: number[];
  53165. /**
  53166. * Assign buttons for Roll control.
  53167. */
  53168. buttonsRoll: number[];
  53169. /**
  53170. * Detect if any button is being pressed while mouse is moved.
  53171. * -1 = Mouse locked.
  53172. * 0 = Left button.
  53173. * 1 = Middle Button.
  53174. * 2 = Right Button.
  53175. */
  53176. activeButton: number;
  53177. /**
  53178. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  53179. * Higher values reduce its sensitivity.
  53180. */
  53181. angularSensibility: number;
  53182. private _observer;
  53183. private _rollObserver;
  53184. private previousPosition;
  53185. private noPreventDefault;
  53186. private element;
  53187. /**
  53188. * Listen to mouse events to control the camera.
  53189. * @param touchEnabled Define if touch is enabled. (Default is true.)
  53190. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53191. */
  53192. constructor(touchEnabled?: boolean);
  53193. /**
  53194. * Attach the mouse control to the HTML DOM element.
  53195. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  53196. */
  53197. attachControl(noPreventDefault?: boolean): void;
  53198. /**
  53199. * Detach the current controls from the specified dom element.
  53200. */
  53201. detachControl(): void;
  53202. /**
  53203. * Gets the class name of the current input.
  53204. * @returns the class name.
  53205. */
  53206. getClassName(): string;
  53207. /**
  53208. * Get the friendly name associated with the input class.
  53209. * @returns the input's friendly name.
  53210. */
  53211. getSimpleName(): string;
  53212. private _pointerInput;
  53213. private _onMouseMove;
  53214. /**
  53215. * Rotate camera by mouse offset.
  53216. */
  53217. private rotateCamera;
  53218. }
  53219. }
  53220. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  53221. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  53222. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  53223. /**
  53224. * Default Inputs manager for the FlyCamera.
  53225. * It groups all the default supported inputs for ease of use.
  53226. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53227. */
  53228. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  53229. /**
  53230. * Instantiates a new FlyCameraInputsManager.
  53231. * @param camera Defines the camera the inputs belong to.
  53232. */
  53233. constructor(camera: FlyCamera);
  53234. /**
  53235. * Add keyboard input support to the input manager.
  53236. * @returns the new FlyCameraKeyboardMoveInput().
  53237. */
  53238. addKeyboard(): FlyCameraInputsManager;
  53239. /**
  53240. * Add mouse input support to the input manager.
  53241. * @param touchEnabled Enable touch screen support.
  53242. * @returns the new FlyCameraMouseInput().
  53243. */
  53244. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  53245. }
  53246. }
  53247. declare module "babylonjs/Cameras/flyCamera" {
  53248. import { Scene } from "babylonjs/scene";
  53249. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53251. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  53252. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  53253. /**
  53254. * This is a flying camera, designed for 3D movement and rotation in all directions,
  53255. * such as in a 3D Space Shooter or a Flight Simulator.
  53256. */
  53257. export class FlyCamera extends TargetCamera {
  53258. /**
  53259. * Define the collision ellipsoid of the camera.
  53260. * This is helpful for simulating a camera body, like a player's body.
  53261. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  53262. */
  53263. ellipsoid: Vector3;
  53264. /**
  53265. * Define an offset for the position of the ellipsoid around the camera.
  53266. * This can be helpful if the camera is attached away from the player's body center,
  53267. * such as at its head.
  53268. */
  53269. ellipsoidOffset: Vector3;
  53270. /**
  53271. * Enable or disable collisions of the camera with the rest of the scene objects.
  53272. */
  53273. checkCollisions: boolean;
  53274. /**
  53275. * Enable or disable gravity on the camera.
  53276. */
  53277. applyGravity: boolean;
  53278. /**
  53279. * Define the current direction the camera is moving to.
  53280. */
  53281. cameraDirection: Vector3;
  53282. /**
  53283. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  53284. * This overrides and empties cameraRotation.
  53285. */
  53286. rotationQuaternion: Quaternion;
  53287. /**
  53288. * Track Roll to maintain the wanted Rolling when looking around.
  53289. */
  53290. _trackRoll: number;
  53291. /**
  53292. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  53293. */
  53294. rollCorrect: number;
  53295. /**
  53296. * Mimic a banked turn, Rolling the camera when Yawing.
  53297. * It's recommended to use rollCorrect = 10 for faster banking correction.
  53298. */
  53299. bankedTurn: boolean;
  53300. /**
  53301. * Limit in radians for how much Roll banking will add. (Default: 90°)
  53302. */
  53303. bankedTurnLimit: number;
  53304. /**
  53305. * Value of 0 disables the banked Roll.
  53306. * Value of 1 is equal to the Yaw angle in radians.
  53307. */
  53308. bankedTurnMultiplier: number;
  53309. /**
  53310. * The inputs manager loads all the input sources, such as keyboard and mouse.
  53311. */
  53312. inputs: FlyCameraInputsManager;
  53313. /**
  53314. * Gets the input sensibility for mouse input.
  53315. * Higher values reduce sensitivity.
  53316. */
  53317. get angularSensibility(): number;
  53318. /**
  53319. * Sets the input sensibility for a mouse input.
  53320. * Higher values reduce sensitivity.
  53321. */
  53322. set angularSensibility(value: number);
  53323. /**
  53324. * Get the keys for camera movement forward.
  53325. */
  53326. get keysForward(): number[];
  53327. /**
  53328. * Set the keys for camera movement forward.
  53329. */
  53330. set keysForward(value: number[]);
  53331. /**
  53332. * Get the keys for camera movement backward.
  53333. */
  53334. get keysBackward(): number[];
  53335. set keysBackward(value: number[]);
  53336. /**
  53337. * Get the keys for camera movement up.
  53338. */
  53339. get keysUp(): number[];
  53340. /**
  53341. * Set the keys for camera movement up.
  53342. */
  53343. set keysUp(value: number[]);
  53344. /**
  53345. * Get the keys for camera movement down.
  53346. */
  53347. get keysDown(): number[];
  53348. /**
  53349. * Set the keys for camera movement down.
  53350. */
  53351. set keysDown(value: number[]);
  53352. /**
  53353. * Get the keys for camera movement left.
  53354. */
  53355. get keysLeft(): number[];
  53356. /**
  53357. * Set the keys for camera movement left.
  53358. */
  53359. set keysLeft(value: number[]);
  53360. /**
  53361. * Set the keys for camera movement right.
  53362. */
  53363. get keysRight(): number[];
  53364. /**
  53365. * Set the keys for camera movement right.
  53366. */
  53367. set keysRight(value: number[]);
  53368. /**
  53369. * Event raised when the camera collides with a mesh in the scene.
  53370. */
  53371. onCollide: (collidedMesh: AbstractMesh) => void;
  53372. private _collider;
  53373. private _needMoveForGravity;
  53374. private _oldPosition;
  53375. private _diffPosition;
  53376. private _newPosition;
  53377. /** @hidden */
  53378. _localDirection: Vector3;
  53379. /** @hidden */
  53380. _transformedDirection: Vector3;
  53381. /**
  53382. * Instantiates a FlyCamera.
  53383. * This is a flying camera, designed for 3D movement and rotation in all directions,
  53384. * such as in a 3D Space Shooter or a Flight Simulator.
  53385. * @param name Define the name of the camera in the scene.
  53386. * @param position Define the starting position of the camera in the scene.
  53387. * @param scene Define the scene the camera belongs to.
  53388. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  53389. */
  53390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  53391. /**
  53392. * Attach the input controls to a specific dom element to get the input from.
  53393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53394. */
  53395. attachControl(noPreventDefault?: boolean): void;
  53396. /**
  53397. * Detach a control from the HTML DOM element.
  53398. * The camera will stop reacting to that input.
  53399. */
  53400. detachControl(): void;
  53401. private _collisionMask;
  53402. /**
  53403. * Get the mask that the camera ignores in collision events.
  53404. */
  53405. get collisionMask(): number;
  53406. /**
  53407. * Set the mask that the camera ignores in collision events.
  53408. */
  53409. set collisionMask(mask: number);
  53410. /** @hidden */
  53411. _collideWithWorld(displacement: Vector3): void;
  53412. /** @hidden */
  53413. private _onCollisionPositionChange;
  53414. /** @hidden */
  53415. _checkInputs(): void;
  53416. /** @hidden */
  53417. _decideIfNeedsToMove(): boolean;
  53418. /** @hidden */
  53419. _updatePosition(): void;
  53420. /**
  53421. * Restore the Roll to its target value at the rate specified.
  53422. * @param rate - Higher means slower restoring.
  53423. * @hidden
  53424. */
  53425. restoreRoll(rate: number): void;
  53426. /**
  53427. * Destroy the camera and release the current resources held by it.
  53428. */
  53429. dispose(): void;
  53430. /**
  53431. * Get the current object class name.
  53432. * @returns the class name.
  53433. */
  53434. getClassName(): string;
  53435. }
  53436. }
  53437. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  53438. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53439. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  53440. /**
  53441. * Listen to keyboard events to control the camera.
  53442. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53443. */
  53444. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  53445. /**
  53446. * Defines the camera the input is attached to.
  53447. */
  53448. camera: FlyCamera;
  53449. /**
  53450. * The list of keyboard keys used to control the forward move of the camera.
  53451. */
  53452. keysForward: number[];
  53453. /**
  53454. * The list of keyboard keys used to control the backward move of the camera.
  53455. */
  53456. keysBackward: number[];
  53457. /**
  53458. * The list of keyboard keys used to control the forward move of the camera.
  53459. */
  53460. keysUp: number[];
  53461. /**
  53462. * The list of keyboard keys used to control the backward move of the camera.
  53463. */
  53464. keysDown: number[];
  53465. /**
  53466. * The list of keyboard keys used to control the right strafe move of the camera.
  53467. */
  53468. keysRight: number[];
  53469. /**
  53470. * The list of keyboard keys used to control the left strafe move of the camera.
  53471. */
  53472. keysLeft: number[];
  53473. private _keys;
  53474. private _onCanvasBlurObserver;
  53475. private _onKeyboardObserver;
  53476. private _engine;
  53477. private _scene;
  53478. /**
  53479. * Attach the input controls to a specific dom element to get the input from.
  53480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53481. */
  53482. attachControl(noPreventDefault?: boolean): void;
  53483. /**
  53484. * Detach the current controls from the specified dom element.
  53485. */
  53486. detachControl(): void;
  53487. /**
  53488. * Gets the class name of the current intput.
  53489. * @returns the class name
  53490. */
  53491. getClassName(): string;
  53492. /** @hidden */
  53493. _onLostFocus(e: FocusEvent): void;
  53494. /**
  53495. * Get the friendly name associated with the input class.
  53496. * @returns the input friendly name
  53497. */
  53498. getSimpleName(): string;
  53499. /**
  53500. * Update the current camera state depending on the inputs that have been used this frame.
  53501. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53502. */
  53503. checkInputs(): void;
  53504. }
  53505. }
  53506. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  53507. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53508. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53509. /**
  53510. * Manage the mouse wheel inputs to control a follow camera.
  53511. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53512. */
  53513. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  53514. /**
  53515. * Defines the camera the input is attached to.
  53516. */
  53517. camera: FollowCamera;
  53518. /**
  53519. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  53520. */
  53521. axisControlRadius: boolean;
  53522. /**
  53523. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  53524. */
  53525. axisControlHeight: boolean;
  53526. /**
  53527. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  53528. */
  53529. axisControlRotation: boolean;
  53530. /**
  53531. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  53532. * relation to mouseWheel events.
  53533. */
  53534. wheelPrecision: number;
  53535. /**
  53536. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  53537. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  53538. */
  53539. wheelDeltaPercentage: number;
  53540. private _wheel;
  53541. private _observer;
  53542. /**
  53543. * Attach the input controls to a specific dom element to get the input from.
  53544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53545. */
  53546. attachControl(noPreventDefault?: boolean): void;
  53547. /**
  53548. * Detach the current controls from the specified dom element.
  53549. */
  53550. detachControl(): void;
  53551. /**
  53552. * Gets the class name of the current input.
  53553. * @returns the class name
  53554. */
  53555. getClassName(): string;
  53556. /**
  53557. * Get the friendly name associated with the input class.
  53558. * @returns the input friendly name
  53559. */
  53560. getSimpleName(): string;
  53561. }
  53562. }
  53563. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  53564. import { Nullable } from "babylonjs/types";
  53565. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53566. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  53567. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  53568. /**
  53569. * Manage the pointers inputs to control an follow camera.
  53570. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53571. */
  53572. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  53573. /**
  53574. * Defines the camera the input is attached to.
  53575. */
  53576. camera: FollowCamera;
  53577. /**
  53578. * Gets the class name of the current input.
  53579. * @returns the class name
  53580. */
  53581. getClassName(): string;
  53582. /**
  53583. * Defines the pointer angular sensibility along the X axis or how fast is
  53584. * the camera rotating.
  53585. * A negative number will reverse the axis direction.
  53586. */
  53587. angularSensibilityX: number;
  53588. /**
  53589. * Defines the pointer angular sensibility along the Y axis or how fast is
  53590. * the camera rotating.
  53591. * A negative number will reverse the axis direction.
  53592. */
  53593. angularSensibilityY: number;
  53594. /**
  53595. * Defines the pointer pinch precision or how fast is the camera zooming.
  53596. * A negative number will reverse the axis direction.
  53597. */
  53598. pinchPrecision: number;
  53599. /**
  53600. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  53601. * from 0.
  53602. * It defines the percentage of current camera.radius to use as delta when
  53603. * pinch zoom is used.
  53604. */
  53605. pinchDeltaPercentage: number;
  53606. /**
  53607. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  53608. */
  53609. axisXControlRadius: boolean;
  53610. /**
  53611. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  53612. */
  53613. axisXControlHeight: boolean;
  53614. /**
  53615. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  53616. */
  53617. axisXControlRotation: boolean;
  53618. /**
  53619. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  53620. */
  53621. axisYControlRadius: boolean;
  53622. /**
  53623. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  53624. */
  53625. axisYControlHeight: boolean;
  53626. /**
  53627. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  53628. */
  53629. axisYControlRotation: boolean;
  53630. /**
  53631. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  53632. */
  53633. axisPinchControlRadius: boolean;
  53634. /**
  53635. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  53636. */
  53637. axisPinchControlHeight: boolean;
  53638. /**
  53639. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  53640. */
  53641. axisPinchControlRotation: boolean;
  53642. /**
  53643. * Log error messages if basic misconfiguration has occurred.
  53644. */
  53645. warningEnable: boolean;
  53646. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  53647. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  53648. private _warningCounter;
  53649. private _warning;
  53650. }
  53651. }
  53652. declare module "babylonjs/Cameras/followCameraInputsManager" {
  53653. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  53654. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53655. /**
  53656. * Default Inputs manager for the FollowCamera.
  53657. * It groups all the default supported inputs for ease of use.
  53658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53659. */
  53660. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  53661. /**
  53662. * Instantiates a new FollowCameraInputsManager.
  53663. * @param camera Defines the camera the inputs belong to
  53664. */
  53665. constructor(camera: FollowCamera);
  53666. /**
  53667. * Add keyboard input support to the input manager.
  53668. * @returns the current input manager
  53669. */
  53670. addKeyboard(): FollowCameraInputsManager;
  53671. /**
  53672. * Add mouse wheel input support to the input manager.
  53673. * @returns the current input manager
  53674. */
  53675. addMouseWheel(): FollowCameraInputsManager;
  53676. /**
  53677. * Add pointers input support to the input manager.
  53678. * @returns the current input manager
  53679. */
  53680. addPointers(): FollowCameraInputsManager;
  53681. /**
  53682. * Add orientation input support to the input manager.
  53683. * @returns the current input manager
  53684. */
  53685. addVRDeviceOrientation(): FollowCameraInputsManager;
  53686. }
  53687. }
  53688. declare module "babylonjs/Cameras/followCamera" {
  53689. import { Nullable } from "babylonjs/types";
  53690. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  53691. import { Scene } from "babylonjs/scene";
  53692. import { Vector3 } from "babylonjs/Maths/math.vector";
  53693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53694. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  53695. /**
  53696. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  53697. * an arc rotate version arcFollowCamera are available.
  53698. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53699. */
  53700. export class FollowCamera extends TargetCamera {
  53701. /**
  53702. * Distance the follow camera should follow an object at
  53703. */
  53704. radius: number;
  53705. /**
  53706. * Minimum allowed distance of the camera to the axis of rotation
  53707. * (The camera can not get closer).
  53708. * This can help limiting how the Camera is able to move in the scene.
  53709. */
  53710. lowerRadiusLimit: Nullable<number>;
  53711. /**
  53712. * Maximum allowed distance of the camera to the axis of rotation
  53713. * (The camera can not get further).
  53714. * This can help limiting how the Camera is able to move in the scene.
  53715. */
  53716. upperRadiusLimit: Nullable<number>;
  53717. /**
  53718. * Define a rotation offset between the camera and the object it follows
  53719. */
  53720. rotationOffset: number;
  53721. /**
  53722. * Minimum allowed angle to camera position relative to target object.
  53723. * This can help limiting how the Camera is able to move in the scene.
  53724. */
  53725. lowerRotationOffsetLimit: Nullable<number>;
  53726. /**
  53727. * Maximum allowed angle to camera position relative to target object.
  53728. * This can help limiting how the Camera is able to move in the scene.
  53729. */
  53730. upperRotationOffsetLimit: Nullable<number>;
  53731. /**
  53732. * Define a height offset between the camera and the object it follows.
  53733. * It can help following an object from the top (like a car chasing a plane)
  53734. */
  53735. heightOffset: number;
  53736. /**
  53737. * Minimum allowed height of camera position relative to target object.
  53738. * This can help limiting how the Camera is able to move in the scene.
  53739. */
  53740. lowerHeightOffsetLimit: Nullable<number>;
  53741. /**
  53742. * Maximum allowed height of camera position relative to target object.
  53743. * This can help limiting how the Camera is able to move in the scene.
  53744. */
  53745. upperHeightOffsetLimit: Nullable<number>;
  53746. /**
  53747. * Define how fast the camera can accelerate to follow it s target.
  53748. */
  53749. cameraAcceleration: number;
  53750. /**
  53751. * Define the speed limit of the camera following an object.
  53752. */
  53753. maxCameraSpeed: number;
  53754. /**
  53755. * Define the target of the camera.
  53756. */
  53757. lockedTarget: Nullable<AbstractMesh>;
  53758. /**
  53759. * Defines the input associated with the camera.
  53760. */
  53761. inputs: FollowCameraInputsManager;
  53762. /**
  53763. * Instantiates the follow camera.
  53764. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53765. * @param name Define the name of the camera in the scene
  53766. * @param position Define the position of the camera
  53767. * @param scene Define the scene the camera belong to
  53768. * @param lockedTarget Define the target of the camera
  53769. */
  53770. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  53771. private _follow;
  53772. /**
  53773. * Attach the input controls to a specific dom element to get the input from.
  53774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53775. */
  53776. attachControl(noPreventDefault?: boolean): void;
  53777. /**
  53778. * Detach the current controls from the specified dom element.
  53779. */
  53780. detachControl(): void;
  53781. /** @hidden */
  53782. _checkInputs(): void;
  53783. private _checkLimits;
  53784. /**
  53785. * Gets the camera class name.
  53786. * @returns the class name
  53787. */
  53788. getClassName(): string;
  53789. }
  53790. /**
  53791. * Arc Rotate version of the follow camera.
  53792. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  53793. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53794. */
  53795. export class ArcFollowCamera extends TargetCamera {
  53796. /** The longitudinal angle of the camera */
  53797. alpha: number;
  53798. /** The latitudinal angle of the camera */
  53799. beta: number;
  53800. /** The radius of the camera from its target */
  53801. radius: number;
  53802. private _cartesianCoordinates;
  53803. /** Define the camera target (the mesh it should follow) */
  53804. private _meshTarget;
  53805. /**
  53806. * Instantiates a new ArcFollowCamera
  53807. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53808. * @param name Define the name of the camera
  53809. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  53810. * @param beta Define the rotation angle of the camera around the elevation axis
  53811. * @param radius Define the radius of the camera from its target point
  53812. * @param target Define the target of the camera
  53813. * @param scene Define the scene the camera belongs to
  53814. */
  53815. constructor(name: string,
  53816. /** The longitudinal angle of the camera */
  53817. alpha: number,
  53818. /** The latitudinal angle of the camera */
  53819. beta: number,
  53820. /** The radius of the camera from its target */
  53821. radius: number,
  53822. /** Define the camera target (the mesh it should follow) */
  53823. target: Nullable<AbstractMesh>, scene: Scene);
  53824. private _follow;
  53825. /** @hidden */
  53826. _checkInputs(): void;
  53827. /**
  53828. * Returns the class name of the object.
  53829. * It is mostly used internally for serialization purposes.
  53830. */
  53831. getClassName(): string;
  53832. }
  53833. }
  53834. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  53835. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53836. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53837. /**
  53838. * Manage the keyboard inputs to control the movement of a follow camera.
  53839. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53840. */
  53841. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  53842. /**
  53843. * Defines the camera the input is attached to.
  53844. */
  53845. camera: FollowCamera;
  53846. /**
  53847. * Defines the list of key codes associated with the up action (increase heightOffset)
  53848. */
  53849. keysHeightOffsetIncr: number[];
  53850. /**
  53851. * Defines the list of key codes associated with the down action (decrease heightOffset)
  53852. */
  53853. keysHeightOffsetDecr: number[];
  53854. /**
  53855. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  53856. */
  53857. keysHeightOffsetModifierAlt: boolean;
  53858. /**
  53859. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  53860. */
  53861. keysHeightOffsetModifierCtrl: boolean;
  53862. /**
  53863. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  53864. */
  53865. keysHeightOffsetModifierShift: boolean;
  53866. /**
  53867. * Defines the list of key codes associated with the left action (increase rotationOffset)
  53868. */
  53869. keysRotationOffsetIncr: number[];
  53870. /**
  53871. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  53872. */
  53873. keysRotationOffsetDecr: number[];
  53874. /**
  53875. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  53876. */
  53877. keysRotationOffsetModifierAlt: boolean;
  53878. /**
  53879. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  53880. */
  53881. keysRotationOffsetModifierCtrl: boolean;
  53882. /**
  53883. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  53884. */
  53885. keysRotationOffsetModifierShift: boolean;
  53886. /**
  53887. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  53888. */
  53889. keysRadiusIncr: number[];
  53890. /**
  53891. * Defines the list of key codes associated with the zoom-out action (increase radius)
  53892. */
  53893. keysRadiusDecr: number[];
  53894. /**
  53895. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  53896. */
  53897. keysRadiusModifierAlt: boolean;
  53898. /**
  53899. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  53900. */
  53901. keysRadiusModifierCtrl: boolean;
  53902. /**
  53903. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  53904. */
  53905. keysRadiusModifierShift: boolean;
  53906. /**
  53907. * Defines the rate of change of heightOffset.
  53908. */
  53909. heightSensibility: number;
  53910. /**
  53911. * Defines the rate of change of rotationOffset.
  53912. */
  53913. rotationSensibility: number;
  53914. /**
  53915. * Defines the rate of change of radius.
  53916. */
  53917. radiusSensibility: number;
  53918. private _keys;
  53919. private _ctrlPressed;
  53920. private _altPressed;
  53921. private _shiftPressed;
  53922. private _onCanvasBlurObserver;
  53923. private _onKeyboardObserver;
  53924. private _engine;
  53925. private _scene;
  53926. /**
  53927. * Attach the input controls to a specific dom element to get the input from.
  53928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53929. */
  53930. attachControl(noPreventDefault?: boolean): void;
  53931. /**
  53932. * Detach the current controls from the specified dom element.
  53933. */
  53934. detachControl(): void;
  53935. /**
  53936. * Update the current camera state depending on the inputs that have been used this frame.
  53937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53938. */
  53939. checkInputs(): void;
  53940. /**
  53941. * Gets the class name of the current input.
  53942. * @returns the class name
  53943. */
  53944. getClassName(): string;
  53945. /**
  53946. * Get the friendly name associated with the input class.
  53947. * @returns the input friendly name
  53948. */
  53949. getSimpleName(): string;
  53950. /**
  53951. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53952. * allow modification of the heightOffset value.
  53953. */
  53954. private _modifierHeightOffset;
  53955. /**
  53956. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53957. * allow modification of the rotationOffset value.
  53958. */
  53959. private _modifierRotationOffset;
  53960. /**
  53961. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53962. * allow modification of the radius value.
  53963. */
  53964. private _modifierRadius;
  53965. }
  53966. }
  53967. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  53968. import { Nullable } from "babylonjs/types";
  53969. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53970. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53971. import { Observable } from "babylonjs/Misc/observable";
  53972. module "babylonjs/Cameras/freeCameraInputsManager" {
  53973. interface FreeCameraInputsManager {
  53974. /**
  53975. * @hidden
  53976. */
  53977. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  53978. /**
  53979. * Add orientation input support to the input manager.
  53980. * @returns the current input manager
  53981. */
  53982. addDeviceOrientation(): FreeCameraInputsManager;
  53983. }
  53984. }
  53985. /**
  53986. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  53987. * Screen rotation is taken into account.
  53988. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53989. */
  53990. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  53991. private _camera;
  53992. private _screenOrientationAngle;
  53993. private _constantTranform;
  53994. private _screenQuaternion;
  53995. private _alpha;
  53996. private _beta;
  53997. private _gamma;
  53998. /**
  53999. * Can be used to detect if a device orientation sensor is available on a device
  54000. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  54001. * @returns a promise that will resolve on orientation change
  54002. */
  54003. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  54004. /**
  54005. * @hidden
  54006. */
  54007. _onDeviceOrientationChangedObservable: Observable<void>;
  54008. /**
  54009. * Instantiates a new input
  54010. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  54011. */
  54012. constructor();
  54013. /**
  54014. * Define the camera controlled by the input.
  54015. */
  54016. get camera(): FreeCamera;
  54017. set camera(camera: FreeCamera);
  54018. /**
  54019. * Attach the input controls to a specific dom element to get the input from.
  54020. */
  54021. attachControl(): void;
  54022. private _orientationChanged;
  54023. private _deviceOrientation;
  54024. /**
  54025. * Detach the current controls from the specified dom element.
  54026. */
  54027. detachControl(): void;
  54028. /**
  54029. * Update the current camera state depending on the inputs that have been used this frame.
  54030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  54031. */
  54032. checkInputs(): void;
  54033. /**
  54034. * Gets the class name of the current input.
  54035. * @returns the class name
  54036. */
  54037. getClassName(): string;
  54038. /**
  54039. * Get the friendly name associated with the input class.
  54040. * @returns the input friendly name
  54041. */
  54042. getSimpleName(): string;
  54043. }
  54044. }
  54045. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  54046. import { Nullable } from "babylonjs/types";
  54047. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  54048. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54049. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54050. /**
  54051. * Manage the gamepad inputs to control a free camera.
  54052. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  54053. */
  54054. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  54055. /**
  54056. * Define the camera the input is attached to.
  54057. */
  54058. camera: FreeCamera;
  54059. /**
  54060. * Define the Gamepad controlling the input
  54061. */
  54062. gamepad: Nullable<Gamepad>;
  54063. /**
  54064. * Defines the gamepad rotation sensiblity.
  54065. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  54066. */
  54067. gamepadAngularSensibility: number;
  54068. /**
  54069. * Defines the gamepad move sensiblity.
  54070. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  54071. */
  54072. gamepadMoveSensibility: number;
  54073. private _yAxisScale;
  54074. /**
  54075. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  54076. */
  54077. get invertYAxis(): boolean;
  54078. set invertYAxis(value: boolean);
  54079. private _onGamepadConnectedObserver;
  54080. private _onGamepadDisconnectedObserver;
  54081. private _cameraTransform;
  54082. private _deltaTransform;
  54083. private _vector3;
  54084. private _vector2;
  54085. /**
  54086. * Attach the input controls to a specific dom element to get the input from.
  54087. */
  54088. attachControl(): void;
  54089. /**
  54090. * Detach the current controls from the specified dom element.
  54091. */
  54092. detachControl(): void;
  54093. /**
  54094. * Update the current camera state depending on the inputs that have been used this frame.
  54095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  54096. */
  54097. checkInputs(): void;
  54098. /**
  54099. * Gets the class name of the current input.
  54100. * @returns the class name
  54101. */
  54102. getClassName(): string;
  54103. /**
  54104. * Get the friendly name associated with the input class.
  54105. * @returns the input friendly name
  54106. */
  54107. getSimpleName(): string;
  54108. }
  54109. }
  54110. declare module "babylonjs/Misc/virtualJoystick" {
  54111. import { Nullable } from "babylonjs/types";
  54112. import { Vector3 } from "babylonjs/Maths/math.vector";
  54113. /**
  54114. * Defines the potential axis of a Joystick
  54115. */
  54116. export enum JoystickAxis {
  54117. /** X axis */
  54118. X = 0,
  54119. /** Y axis */
  54120. Y = 1,
  54121. /** Z axis */
  54122. Z = 2
  54123. }
  54124. /**
  54125. * Represents the different customization options available
  54126. * for VirtualJoystick
  54127. */
  54128. interface VirtualJoystickCustomizations {
  54129. /**
  54130. * Size of the joystick's puck
  54131. */
  54132. puckSize: number;
  54133. /**
  54134. * Size of the joystick's container
  54135. */
  54136. containerSize: number;
  54137. /**
  54138. * Color of the joystick && puck
  54139. */
  54140. color: string;
  54141. /**
  54142. * Image URL for the joystick's puck
  54143. */
  54144. puckImage?: string;
  54145. /**
  54146. * Image URL for the joystick's container
  54147. */
  54148. containerImage?: string;
  54149. /**
  54150. * Defines the unmoving position of the joystick container
  54151. */
  54152. position?: {
  54153. x: number;
  54154. y: number;
  54155. };
  54156. /**
  54157. * Defines whether or not the joystick container is always visible
  54158. */
  54159. alwaysVisible: boolean;
  54160. /**
  54161. * Defines whether or not to limit the movement of the puck to the joystick's container
  54162. */
  54163. limitToContainer: boolean;
  54164. }
  54165. /**
  54166. * Class used to define virtual joystick (used in touch mode)
  54167. */
  54168. export class VirtualJoystick {
  54169. /**
  54170. * Gets or sets a boolean indicating that left and right values must be inverted
  54171. */
  54172. reverseLeftRight: boolean;
  54173. /**
  54174. * Gets or sets a boolean indicating that up and down values must be inverted
  54175. */
  54176. reverseUpDown: boolean;
  54177. /**
  54178. * Gets the offset value for the position (ie. the change of the position value)
  54179. */
  54180. deltaPosition: Vector3;
  54181. /**
  54182. * Gets a boolean indicating if the virtual joystick was pressed
  54183. */
  54184. pressed: boolean;
  54185. /**
  54186. * Canvas the virtual joystick will render onto, default z-index of this is 5
  54187. */
  54188. static Canvas: Nullable<HTMLCanvasElement>;
  54189. /**
  54190. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  54191. */
  54192. limitToContainer: boolean;
  54193. private static _globalJoystickIndex;
  54194. private static _alwaysVisibleSticks;
  54195. private static vjCanvasContext;
  54196. private static vjCanvasWidth;
  54197. private static vjCanvasHeight;
  54198. private static halfWidth;
  54199. private static _GetDefaultOptions;
  54200. private _action;
  54201. private _axisTargetedByLeftAndRight;
  54202. private _axisTargetedByUpAndDown;
  54203. private _joystickSensibility;
  54204. private _inversedSensibility;
  54205. private _joystickPointerID;
  54206. private _joystickColor;
  54207. private _joystickPointerPos;
  54208. private _joystickPreviousPointerPos;
  54209. private _joystickPointerStartPos;
  54210. private _deltaJoystickVector;
  54211. private _leftJoystick;
  54212. private _touches;
  54213. private _joystickPosition;
  54214. private _alwaysVisible;
  54215. private _puckImage;
  54216. private _containerImage;
  54217. private _joystickPuckSize;
  54218. private _joystickContainerSize;
  54219. private _clearPuckSize;
  54220. private _clearContainerSize;
  54221. private _clearPuckSizeOffset;
  54222. private _clearContainerSizeOffset;
  54223. private _onPointerDownHandlerRef;
  54224. private _onPointerMoveHandlerRef;
  54225. private _onPointerUpHandlerRef;
  54226. private _onResize;
  54227. /**
  54228. * Creates a new virtual joystick
  54229. * @param leftJoystick defines that the joystick is for left hand (false by default)
  54230. * @param customizations Defines the options we want to customize the VirtualJoystick
  54231. */
  54232. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  54233. /**
  54234. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  54235. * @param newJoystickSensibility defines the new sensibility
  54236. */
  54237. setJoystickSensibility(newJoystickSensibility: number): void;
  54238. private _onPointerDown;
  54239. private _onPointerMove;
  54240. private _onPointerUp;
  54241. /**
  54242. * Change the color of the virtual joystick
  54243. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  54244. */
  54245. setJoystickColor(newColor: string): void;
  54246. /**
  54247. * Size of the joystick's container
  54248. */
  54249. set containerSize(newSize: number);
  54250. get containerSize(): number;
  54251. /**
  54252. * Size of the joystick's puck
  54253. */
  54254. set puckSize(newSize: number);
  54255. get puckSize(): number;
  54256. /**
  54257. * Clears the set position of the joystick
  54258. */
  54259. clearPosition(): void;
  54260. /**
  54261. * Defines whether or not the joystick container is always visible
  54262. */
  54263. set alwaysVisible(value: boolean);
  54264. get alwaysVisible(): boolean;
  54265. /**
  54266. * Sets the constant position of the Joystick container
  54267. * @param x X axis coordinate
  54268. * @param y Y axis coordinate
  54269. */
  54270. setPosition(x: number, y: number): void;
  54271. /**
  54272. * Defines a callback to call when the joystick is touched
  54273. * @param action defines the callback
  54274. */
  54275. setActionOnTouch(action: () => any): void;
  54276. /**
  54277. * Defines which axis you'd like to control for left & right
  54278. * @param axis defines the axis to use
  54279. */
  54280. setAxisForLeftRight(axis: JoystickAxis): void;
  54281. /**
  54282. * Defines which axis you'd like to control for up & down
  54283. * @param axis defines the axis to use
  54284. */
  54285. setAxisForUpDown(axis: JoystickAxis): void;
  54286. /**
  54287. * Clears the canvas from the previous puck / container draw
  54288. */
  54289. private _clearPreviousDraw;
  54290. /**
  54291. * Loads `urlPath` to be used for the container's image
  54292. * @param urlPath defines the urlPath of an image to use
  54293. */
  54294. setContainerImage(urlPath: string): void;
  54295. /**
  54296. * Loads `urlPath` to be used for the puck's image
  54297. * @param urlPath defines the urlPath of an image to use
  54298. */
  54299. setPuckImage(urlPath: string): void;
  54300. /**
  54301. * Draws the Virtual Joystick's container
  54302. */
  54303. private _drawContainer;
  54304. /**
  54305. * Draws the Virtual Joystick's puck
  54306. */
  54307. private _drawPuck;
  54308. private _drawVirtualJoystick;
  54309. /**
  54310. * Release internal HTML canvas
  54311. */
  54312. releaseCanvas(): void;
  54313. }
  54314. }
  54315. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  54316. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  54317. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  54318. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54319. module "babylonjs/Cameras/freeCameraInputsManager" {
  54320. interface FreeCameraInputsManager {
  54321. /**
  54322. * Add virtual joystick input support to the input manager.
  54323. * @returns the current input manager
  54324. */
  54325. addVirtualJoystick(): FreeCameraInputsManager;
  54326. }
  54327. }
  54328. /**
  54329. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  54330. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  54331. */
  54332. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  54333. /**
  54334. * Defines the camera the input is attached to.
  54335. */
  54336. camera: FreeCamera;
  54337. private _leftjoystick;
  54338. private _rightjoystick;
  54339. /**
  54340. * Gets the left stick of the virtual joystick.
  54341. * @returns The virtual Joystick
  54342. */
  54343. getLeftJoystick(): VirtualJoystick;
  54344. /**
  54345. * Gets the right stick of the virtual joystick.
  54346. * @returns The virtual Joystick
  54347. */
  54348. getRightJoystick(): VirtualJoystick;
  54349. /**
  54350. * Update the current camera state depending on the inputs that have been used this frame.
  54351. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  54352. */
  54353. checkInputs(): void;
  54354. /**
  54355. * Attach the input controls to a specific dom element to get the input from.
  54356. */
  54357. attachControl(): void;
  54358. /**
  54359. * Detach the current controls from the specified dom element.
  54360. */
  54361. detachControl(): void;
  54362. /**
  54363. * Gets the class name of the current input.
  54364. * @returns the class name
  54365. */
  54366. getClassName(): string;
  54367. /**
  54368. * Get the friendly name associated with the input class.
  54369. * @returns the input friendly name
  54370. */
  54371. getSimpleName(): string;
  54372. }
  54373. }
  54374. declare module "babylonjs/Cameras/Inputs/index" {
  54375. export * from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  54376. export * from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  54377. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  54378. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  54379. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  54380. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  54381. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  54382. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  54383. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  54384. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  54385. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  54386. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  54387. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  54388. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  54389. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  54390. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  54391. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  54392. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  54393. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  54394. }
  54395. declare module "babylonjs/Cameras/touchCamera" {
  54396. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54397. import { Scene } from "babylonjs/scene";
  54398. import { Vector3 } from "babylonjs/Maths/math.vector";
  54399. /**
  54400. * This represents a FPS type of camera controlled by touch.
  54401. * This is like a universal camera minus the Gamepad controls.
  54402. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54403. */
  54404. export class TouchCamera extends FreeCamera {
  54405. /**
  54406. * Defines the touch sensibility for rotation.
  54407. * The higher the faster.
  54408. */
  54409. get touchAngularSensibility(): number;
  54410. set touchAngularSensibility(value: number);
  54411. /**
  54412. * Defines the touch sensibility for move.
  54413. * The higher the faster.
  54414. */
  54415. get touchMoveSensibility(): number;
  54416. set touchMoveSensibility(value: number);
  54417. /**
  54418. * Instantiates a new touch camera.
  54419. * This represents a FPS type of camera controlled by touch.
  54420. * This is like a universal camera minus the Gamepad controls.
  54421. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54422. * @param name Define the name of the camera in the scene
  54423. * @param position Define the start position of the camera in the scene
  54424. * @param scene Define the scene the camera belongs to
  54425. */
  54426. constructor(name: string, position: Vector3, scene: Scene);
  54427. /**
  54428. * Gets the current object class name.
  54429. * @return the class name
  54430. */
  54431. getClassName(): string;
  54432. /** @hidden */
  54433. _setupInputs(): void;
  54434. }
  54435. }
  54436. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  54437. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54438. import { Scene } from "babylonjs/scene";
  54439. import { Vector3 } from "babylonjs/Maths/math.vector";
  54440. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  54441. import { Axis } from "babylonjs/Maths/math.axis";
  54442. /**
  54443. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  54444. * being tilted forward or back and left or right.
  54445. */
  54446. export class DeviceOrientationCamera extends FreeCamera {
  54447. private _initialQuaternion;
  54448. private _quaternionCache;
  54449. private _tmpDragQuaternion;
  54450. private _disablePointerInputWhenUsingDeviceOrientation;
  54451. /**
  54452. * Creates a new device orientation camera
  54453. * @param name The name of the camera
  54454. * @param position The start position camera
  54455. * @param scene The scene the camera belongs to
  54456. */
  54457. constructor(name: string, position: Vector3, scene: Scene);
  54458. /**
  54459. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  54460. */
  54461. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  54462. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  54463. private _dragFactor;
  54464. /**
  54465. * Enabled turning on the y axis when the orientation sensor is active
  54466. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  54467. */
  54468. enableHorizontalDragging(dragFactor?: number): void;
  54469. /**
  54470. * Gets the current instance class name ("DeviceOrientationCamera").
  54471. * This helps avoiding instanceof at run time.
  54472. * @returns the class name
  54473. */
  54474. getClassName(): string;
  54475. /**
  54476. * @hidden
  54477. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  54478. */
  54479. _checkInputs(): void;
  54480. /**
  54481. * Reset the camera to its default orientation on the specified axis only.
  54482. * @param axis The axis to reset
  54483. */
  54484. resetToCurrentRotation(axis?: Axis): void;
  54485. }
  54486. }
  54487. declare module "babylonjs/Gamepads/xboxGamepad" {
  54488. import { Observable } from "babylonjs/Misc/observable";
  54489. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54490. /**
  54491. * Defines supported buttons for XBox360 compatible gamepads
  54492. */
  54493. export enum Xbox360Button {
  54494. /** A */
  54495. A = 0,
  54496. /** B */
  54497. B = 1,
  54498. /** X */
  54499. X = 2,
  54500. /** Y */
  54501. Y = 3,
  54502. /** Left button */
  54503. LB = 4,
  54504. /** Right button */
  54505. RB = 5,
  54506. /** Back */
  54507. Back = 8,
  54508. /** Start */
  54509. Start = 9,
  54510. /** Left stick */
  54511. LeftStick = 10,
  54512. /** Right stick */
  54513. RightStick = 11
  54514. }
  54515. /** Defines values for XBox360 DPad */
  54516. export enum Xbox360Dpad {
  54517. /** Up */
  54518. Up = 12,
  54519. /** Down */
  54520. Down = 13,
  54521. /** Left */
  54522. Left = 14,
  54523. /** Right */
  54524. Right = 15
  54525. }
  54526. /**
  54527. * Defines a XBox360 gamepad
  54528. */
  54529. export class Xbox360Pad extends Gamepad {
  54530. private _leftTrigger;
  54531. private _rightTrigger;
  54532. private _onlefttriggerchanged;
  54533. private _onrighttriggerchanged;
  54534. private _onbuttondown;
  54535. private _onbuttonup;
  54536. private _ondpaddown;
  54537. private _ondpadup;
  54538. /** Observable raised when a button is pressed */
  54539. onButtonDownObservable: Observable<Xbox360Button>;
  54540. /** Observable raised when a button is released */
  54541. onButtonUpObservable: Observable<Xbox360Button>;
  54542. /** Observable raised when a pad is pressed */
  54543. onPadDownObservable: Observable<Xbox360Dpad>;
  54544. /** Observable raised when a pad is released */
  54545. onPadUpObservable: Observable<Xbox360Dpad>;
  54546. private _buttonA;
  54547. private _buttonB;
  54548. private _buttonX;
  54549. private _buttonY;
  54550. private _buttonBack;
  54551. private _buttonStart;
  54552. private _buttonLB;
  54553. private _buttonRB;
  54554. private _buttonLeftStick;
  54555. private _buttonRightStick;
  54556. private _dPadUp;
  54557. private _dPadDown;
  54558. private _dPadLeft;
  54559. private _dPadRight;
  54560. private _isXboxOnePad;
  54561. /**
  54562. * Creates a new XBox360 gamepad object
  54563. * @param id defines the id of this gamepad
  54564. * @param index defines its index
  54565. * @param gamepad defines the internal HTML gamepad object
  54566. * @param xboxOne defines if it is a XBox One gamepad
  54567. */
  54568. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  54569. /**
  54570. * Defines the callback to call when left trigger is pressed
  54571. * @param callback defines the callback to use
  54572. */
  54573. onlefttriggerchanged(callback: (value: number) => void): void;
  54574. /**
  54575. * Defines the callback to call when right trigger is pressed
  54576. * @param callback defines the callback to use
  54577. */
  54578. onrighttriggerchanged(callback: (value: number) => void): void;
  54579. /**
  54580. * Gets the left trigger value
  54581. */
  54582. get leftTrigger(): number;
  54583. /**
  54584. * Sets the left trigger value
  54585. */
  54586. set leftTrigger(newValue: number);
  54587. /**
  54588. * Gets the right trigger value
  54589. */
  54590. get rightTrigger(): number;
  54591. /**
  54592. * Sets the right trigger value
  54593. */
  54594. set rightTrigger(newValue: number);
  54595. /**
  54596. * Defines the callback to call when a button is pressed
  54597. * @param callback defines the callback to use
  54598. */
  54599. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  54600. /**
  54601. * Defines the callback to call when a button is released
  54602. * @param callback defines the callback to use
  54603. */
  54604. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  54605. /**
  54606. * Defines the callback to call when a pad is pressed
  54607. * @param callback defines the callback to use
  54608. */
  54609. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  54610. /**
  54611. * Defines the callback to call when a pad is released
  54612. * @param callback defines the callback to use
  54613. */
  54614. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  54615. private _setButtonValue;
  54616. private _setDPadValue;
  54617. /**
  54618. * Gets the value of the `A` button
  54619. */
  54620. get buttonA(): number;
  54621. /**
  54622. * Sets the value of the `A` button
  54623. */
  54624. set buttonA(value: number);
  54625. /**
  54626. * Gets the value of the `B` button
  54627. */
  54628. get buttonB(): number;
  54629. /**
  54630. * Sets the value of the `B` button
  54631. */
  54632. set buttonB(value: number);
  54633. /**
  54634. * Gets the value of the `X` button
  54635. */
  54636. get buttonX(): number;
  54637. /**
  54638. * Sets the value of the `X` button
  54639. */
  54640. set buttonX(value: number);
  54641. /**
  54642. * Gets the value of the `Y` button
  54643. */
  54644. get buttonY(): number;
  54645. /**
  54646. * Sets the value of the `Y` button
  54647. */
  54648. set buttonY(value: number);
  54649. /**
  54650. * Gets the value of the `Start` button
  54651. */
  54652. get buttonStart(): number;
  54653. /**
  54654. * Sets the value of the `Start` button
  54655. */
  54656. set buttonStart(value: number);
  54657. /**
  54658. * Gets the value of the `Back` button
  54659. */
  54660. get buttonBack(): number;
  54661. /**
  54662. * Sets the value of the `Back` button
  54663. */
  54664. set buttonBack(value: number);
  54665. /**
  54666. * Gets the value of the `Left` button
  54667. */
  54668. get buttonLB(): number;
  54669. /**
  54670. * Sets the value of the `Left` button
  54671. */
  54672. set buttonLB(value: number);
  54673. /**
  54674. * Gets the value of the `Right` button
  54675. */
  54676. get buttonRB(): number;
  54677. /**
  54678. * Sets the value of the `Right` button
  54679. */
  54680. set buttonRB(value: number);
  54681. /**
  54682. * Gets the value of the Left joystick
  54683. */
  54684. get buttonLeftStick(): number;
  54685. /**
  54686. * Sets the value of the Left joystick
  54687. */
  54688. set buttonLeftStick(value: number);
  54689. /**
  54690. * Gets the value of the Right joystick
  54691. */
  54692. get buttonRightStick(): number;
  54693. /**
  54694. * Sets the value of the Right joystick
  54695. */
  54696. set buttonRightStick(value: number);
  54697. /**
  54698. * Gets the value of D-pad up
  54699. */
  54700. get dPadUp(): number;
  54701. /**
  54702. * Sets the value of D-pad up
  54703. */
  54704. set dPadUp(value: number);
  54705. /**
  54706. * Gets the value of D-pad down
  54707. */
  54708. get dPadDown(): number;
  54709. /**
  54710. * Sets the value of D-pad down
  54711. */
  54712. set dPadDown(value: number);
  54713. /**
  54714. * Gets the value of D-pad left
  54715. */
  54716. get dPadLeft(): number;
  54717. /**
  54718. * Sets the value of D-pad left
  54719. */
  54720. set dPadLeft(value: number);
  54721. /**
  54722. * Gets the value of D-pad right
  54723. */
  54724. get dPadRight(): number;
  54725. /**
  54726. * Sets the value of D-pad right
  54727. */
  54728. set dPadRight(value: number);
  54729. /**
  54730. * Force the gamepad to synchronize with device values
  54731. */
  54732. update(): void;
  54733. /**
  54734. * Disposes the gamepad
  54735. */
  54736. dispose(): void;
  54737. }
  54738. }
  54739. declare module "babylonjs/Gamepads/dualShockGamepad" {
  54740. import { Observable } from "babylonjs/Misc/observable";
  54741. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54742. /**
  54743. * Defines supported buttons for DualShock compatible gamepads
  54744. */
  54745. export enum DualShockButton {
  54746. /** Cross */
  54747. Cross = 0,
  54748. /** Circle */
  54749. Circle = 1,
  54750. /** Square */
  54751. Square = 2,
  54752. /** Triangle */
  54753. Triangle = 3,
  54754. /** L1 */
  54755. L1 = 4,
  54756. /** R1 */
  54757. R1 = 5,
  54758. /** Share */
  54759. Share = 8,
  54760. /** Options */
  54761. Options = 9,
  54762. /** Left stick */
  54763. LeftStick = 10,
  54764. /** Right stick */
  54765. RightStick = 11
  54766. }
  54767. /** Defines values for DualShock DPad */
  54768. export enum DualShockDpad {
  54769. /** Up */
  54770. Up = 12,
  54771. /** Down */
  54772. Down = 13,
  54773. /** Left */
  54774. Left = 14,
  54775. /** Right */
  54776. Right = 15
  54777. }
  54778. /**
  54779. * Defines a DualShock gamepad
  54780. */
  54781. export class DualShockPad extends Gamepad {
  54782. private _leftTrigger;
  54783. private _rightTrigger;
  54784. private _onlefttriggerchanged;
  54785. private _onrighttriggerchanged;
  54786. private _onbuttondown;
  54787. private _onbuttonup;
  54788. private _ondpaddown;
  54789. private _ondpadup;
  54790. /** Observable raised when a button is pressed */
  54791. onButtonDownObservable: Observable<DualShockButton>;
  54792. /** Observable raised when a button is released */
  54793. onButtonUpObservable: Observable<DualShockButton>;
  54794. /** Observable raised when a pad is pressed */
  54795. onPadDownObservable: Observable<DualShockDpad>;
  54796. /** Observable raised when a pad is released */
  54797. onPadUpObservable: Observable<DualShockDpad>;
  54798. private _buttonCross;
  54799. private _buttonCircle;
  54800. private _buttonSquare;
  54801. private _buttonTriangle;
  54802. private _buttonShare;
  54803. private _buttonOptions;
  54804. private _buttonL1;
  54805. private _buttonR1;
  54806. private _buttonLeftStick;
  54807. private _buttonRightStick;
  54808. private _dPadUp;
  54809. private _dPadDown;
  54810. private _dPadLeft;
  54811. private _dPadRight;
  54812. /**
  54813. * Creates a new DualShock gamepad object
  54814. * @param id defines the id of this gamepad
  54815. * @param index defines its index
  54816. * @param gamepad defines the internal HTML gamepad object
  54817. */
  54818. constructor(id: string, index: number, gamepad: any);
  54819. /**
  54820. * Defines the callback to call when left trigger is pressed
  54821. * @param callback defines the callback to use
  54822. */
  54823. onlefttriggerchanged(callback: (value: number) => void): void;
  54824. /**
  54825. * Defines the callback to call when right trigger is pressed
  54826. * @param callback defines the callback to use
  54827. */
  54828. onrighttriggerchanged(callback: (value: number) => void): void;
  54829. /**
  54830. * Gets the left trigger value
  54831. */
  54832. get leftTrigger(): number;
  54833. /**
  54834. * Sets the left trigger value
  54835. */
  54836. set leftTrigger(newValue: number);
  54837. /**
  54838. * Gets the right trigger value
  54839. */
  54840. get rightTrigger(): number;
  54841. /**
  54842. * Sets the right trigger value
  54843. */
  54844. set rightTrigger(newValue: number);
  54845. /**
  54846. * Defines the callback to call when a button is pressed
  54847. * @param callback defines the callback to use
  54848. */
  54849. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  54850. /**
  54851. * Defines the callback to call when a button is released
  54852. * @param callback defines the callback to use
  54853. */
  54854. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  54855. /**
  54856. * Defines the callback to call when a pad is pressed
  54857. * @param callback defines the callback to use
  54858. */
  54859. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  54860. /**
  54861. * Defines the callback to call when a pad is released
  54862. * @param callback defines the callback to use
  54863. */
  54864. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  54865. private _setButtonValue;
  54866. private _setDPadValue;
  54867. /**
  54868. * Gets the value of the `Cross` button
  54869. */
  54870. get buttonCross(): number;
  54871. /**
  54872. * Sets the value of the `Cross` button
  54873. */
  54874. set buttonCross(value: number);
  54875. /**
  54876. * Gets the value of the `Circle` button
  54877. */
  54878. get buttonCircle(): number;
  54879. /**
  54880. * Sets the value of the `Circle` button
  54881. */
  54882. set buttonCircle(value: number);
  54883. /**
  54884. * Gets the value of the `Square` button
  54885. */
  54886. get buttonSquare(): number;
  54887. /**
  54888. * Sets the value of the `Square` button
  54889. */
  54890. set buttonSquare(value: number);
  54891. /**
  54892. * Gets the value of the `Triangle` button
  54893. */
  54894. get buttonTriangle(): number;
  54895. /**
  54896. * Sets the value of the `Triangle` button
  54897. */
  54898. set buttonTriangle(value: number);
  54899. /**
  54900. * Gets the value of the `Options` button
  54901. */
  54902. get buttonOptions(): number;
  54903. /**
  54904. * Sets the value of the `Options` button
  54905. */
  54906. set buttonOptions(value: number);
  54907. /**
  54908. * Gets the value of the `Share` button
  54909. */
  54910. get buttonShare(): number;
  54911. /**
  54912. * Sets the value of the `Share` button
  54913. */
  54914. set buttonShare(value: number);
  54915. /**
  54916. * Gets the value of the `L1` button
  54917. */
  54918. get buttonL1(): number;
  54919. /**
  54920. * Sets the value of the `L1` button
  54921. */
  54922. set buttonL1(value: number);
  54923. /**
  54924. * Gets the value of the `R1` button
  54925. */
  54926. get buttonR1(): number;
  54927. /**
  54928. * Sets the value of the `R1` button
  54929. */
  54930. set buttonR1(value: number);
  54931. /**
  54932. * Gets the value of the Left joystick
  54933. */
  54934. get buttonLeftStick(): number;
  54935. /**
  54936. * Sets the value of the Left joystick
  54937. */
  54938. set buttonLeftStick(value: number);
  54939. /**
  54940. * Gets the value of the Right joystick
  54941. */
  54942. get buttonRightStick(): number;
  54943. /**
  54944. * Sets the value of the Right joystick
  54945. */
  54946. set buttonRightStick(value: number);
  54947. /**
  54948. * Gets the value of D-pad up
  54949. */
  54950. get dPadUp(): number;
  54951. /**
  54952. * Sets the value of D-pad up
  54953. */
  54954. set dPadUp(value: number);
  54955. /**
  54956. * Gets the value of D-pad down
  54957. */
  54958. get dPadDown(): number;
  54959. /**
  54960. * Sets the value of D-pad down
  54961. */
  54962. set dPadDown(value: number);
  54963. /**
  54964. * Gets the value of D-pad left
  54965. */
  54966. get dPadLeft(): number;
  54967. /**
  54968. * Sets the value of D-pad left
  54969. */
  54970. set dPadLeft(value: number);
  54971. /**
  54972. * Gets the value of D-pad right
  54973. */
  54974. get dPadRight(): number;
  54975. /**
  54976. * Sets the value of D-pad right
  54977. */
  54978. set dPadRight(value: number);
  54979. /**
  54980. * Force the gamepad to synchronize with device values
  54981. */
  54982. update(): void;
  54983. /**
  54984. * Disposes the gamepad
  54985. */
  54986. dispose(): void;
  54987. }
  54988. }
  54989. declare module "babylonjs/Gamepads/gamepadManager" {
  54990. import { Observable } from "babylonjs/Misc/observable";
  54991. import { Nullable } from "babylonjs/types";
  54992. import { Scene } from "babylonjs/scene";
  54993. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54994. /**
  54995. * Manager for handling gamepads
  54996. */
  54997. export class GamepadManager {
  54998. private _scene?;
  54999. private _babylonGamepads;
  55000. private _oneGamepadConnected;
  55001. /** @hidden */
  55002. _isMonitoring: boolean;
  55003. private _gamepadEventSupported;
  55004. private _gamepadSupport?;
  55005. /**
  55006. * observable to be triggered when the gamepad controller has been connected
  55007. */
  55008. onGamepadConnectedObservable: Observable<Gamepad>;
  55009. /**
  55010. * observable to be triggered when the gamepad controller has been disconnected
  55011. */
  55012. onGamepadDisconnectedObservable: Observable<Gamepad>;
  55013. private _onGamepadConnectedEvent;
  55014. private _onGamepadDisconnectedEvent;
  55015. /**
  55016. * Initializes the gamepad manager
  55017. * @param _scene BabylonJS scene
  55018. */
  55019. constructor(_scene?: Scene | undefined);
  55020. /**
  55021. * The gamepads in the game pad manager
  55022. */
  55023. get gamepads(): Gamepad[];
  55024. /**
  55025. * Get the gamepad controllers based on type
  55026. * @param type The type of gamepad controller
  55027. * @returns Nullable gamepad
  55028. */
  55029. getGamepadByType(type?: number): Nullable<Gamepad>;
  55030. /**
  55031. * Disposes the gamepad manager
  55032. */
  55033. dispose(): void;
  55034. private _addNewGamepad;
  55035. private _startMonitoringGamepads;
  55036. private _stopMonitoringGamepads;
  55037. /** @hidden */
  55038. _checkGamepadsStatus(): void;
  55039. private _updateGamepadObjects;
  55040. }
  55041. }
  55042. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  55043. import { Nullable } from "babylonjs/types";
  55044. import { Scene } from "babylonjs/scene";
  55045. import { ISceneComponent } from "babylonjs/sceneComponent";
  55046. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  55047. module "babylonjs/scene" {
  55048. interface Scene {
  55049. /** @hidden */
  55050. _gamepadManager: Nullable<GamepadManager>;
  55051. /**
  55052. * Gets the gamepad manager associated with the scene
  55053. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  55054. */
  55055. gamepadManager: GamepadManager;
  55056. }
  55057. }
  55058. module "babylonjs/Cameras/freeCameraInputsManager" {
  55059. /**
  55060. * Interface representing a free camera inputs manager
  55061. */
  55062. interface FreeCameraInputsManager {
  55063. /**
  55064. * Adds gamepad input support to the FreeCameraInputsManager.
  55065. * @returns the FreeCameraInputsManager
  55066. */
  55067. addGamepad(): FreeCameraInputsManager;
  55068. }
  55069. }
  55070. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  55071. /**
  55072. * Interface representing an arc rotate camera inputs manager
  55073. */
  55074. interface ArcRotateCameraInputsManager {
  55075. /**
  55076. * Adds gamepad input support to the ArcRotateCamera InputManager.
  55077. * @returns the camera inputs manager
  55078. */
  55079. addGamepad(): ArcRotateCameraInputsManager;
  55080. }
  55081. }
  55082. /**
  55083. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  55084. */
  55085. export class GamepadSystemSceneComponent implements ISceneComponent {
  55086. /**
  55087. * The component name helpfull to identify the component in the list of scene components.
  55088. */
  55089. readonly name: string;
  55090. /**
  55091. * The scene the component belongs to.
  55092. */
  55093. scene: Scene;
  55094. /**
  55095. * Creates a new instance of the component for the given scene
  55096. * @param scene Defines the scene to register the component in
  55097. */
  55098. constructor(scene: Scene);
  55099. /**
  55100. * Registers the component in a given scene
  55101. */
  55102. register(): void;
  55103. /**
  55104. * Rebuilds the elements related to this component in case of
  55105. * context lost for instance.
  55106. */
  55107. rebuild(): void;
  55108. /**
  55109. * Disposes the component and the associated ressources
  55110. */
  55111. dispose(): void;
  55112. private _beforeCameraUpdate;
  55113. }
  55114. }
  55115. declare module "babylonjs/Cameras/universalCamera" {
  55116. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  55117. import { Scene } from "babylonjs/scene";
  55118. import { Vector3 } from "babylonjs/Maths/math.vector";
  55119. import "babylonjs/Gamepads/gamepadSceneComponent";
  55120. /**
  55121. * 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,
  55122. * which still works and will still be found in many Playgrounds.
  55123. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  55124. */
  55125. export class UniversalCamera extends TouchCamera {
  55126. /**
  55127. * Defines the gamepad rotation sensiblity.
  55128. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  55129. */
  55130. get gamepadAngularSensibility(): number;
  55131. set gamepadAngularSensibility(value: number);
  55132. /**
  55133. * Defines the gamepad move sensiblity.
  55134. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  55135. */
  55136. get gamepadMoveSensibility(): number;
  55137. set gamepadMoveSensibility(value: number);
  55138. /**
  55139. * 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,
  55140. * which still works and will still be found in many Playgrounds.
  55141. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  55142. * @param name Define the name of the camera in the scene
  55143. * @param position Define the start position of the camera in the scene
  55144. * @param scene Define the scene the camera belongs to
  55145. */
  55146. constructor(name: string, position: Vector3, scene: Scene);
  55147. /**
  55148. * Gets the current object class name.
  55149. * @return the class name
  55150. */
  55151. getClassName(): string;
  55152. }
  55153. }
  55154. declare module "babylonjs/Cameras/gamepadCamera" {
  55155. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  55156. import { Scene } from "babylonjs/scene";
  55157. import { Vector3 } from "babylonjs/Maths/math.vector";
  55158. /**
  55159. * This represents a FPS type of camera. This is only here for back compat purpose.
  55160. * Please use the UniversalCamera instead as both are identical.
  55161. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  55162. */
  55163. export class GamepadCamera extends UniversalCamera {
  55164. /**
  55165. * Instantiates a new Gamepad Camera
  55166. * This represents a FPS type of camera. This is only here for back compat purpose.
  55167. * Please use the UniversalCamera instead as both are identical.
  55168. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  55169. * @param name Define the name of the camera in the scene
  55170. * @param position Define the start position of the camera in the scene
  55171. * @param scene Define the scene the camera belongs to
  55172. */
  55173. constructor(name: string, position: Vector3, scene: Scene);
  55174. /**
  55175. * Gets the current object class name.
  55176. * @return the class name
  55177. */
  55178. getClassName(): string;
  55179. }
  55180. }
  55181. declare module "babylonjs/Shaders/anaglyph.fragment" {
  55182. /** @hidden */
  55183. export var anaglyphPixelShader: {
  55184. name: string;
  55185. shader: string;
  55186. };
  55187. }
  55188. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  55189. import { Engine } from "babylonjs/Engines/engine";
  55190. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55191. import { Camera } from "babylonjs/Cameras/camera";
  55192. import "babylonjs/Shaders/anaglyph.fragment";
  55193. /**
  55194. * Postprocess used to generate anaglyphic rendering
  55195. */
  55196. export class AnaglyphPostProcess extends PostProcess {
  55197. private _passedProcess;
  55198. /**
  55199. * Gets a string identifying the name of the class
  55200. * @returns "AnaglyphPostProcess" string
  55201. */
  55202. getClassName(): string;
  55203. /**
  55204. * Creates a new AnaglyphPostProcess
  55205. * @param name defines postprocess name
  55206. * @param options defines creation options or target ratio scale
  55207. * @param rigCameras defines cameras using this postprocess
  55208. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  55209. * @param engine defines hosting engine
  55210. * @param reusable defines if the postprocess will be reused multiple times per frame
  55211. */
  55212. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  55213. }
  55214. }
  55215. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  55216. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  55217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  55218. import { Scene } from "babylonjs/scene";
  55219. import { Vector3 } from "babylonjs/Maths/math.vector";
  55220. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55221. /**
  55222. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  55223. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  55224. */
  55225. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  55226. /**
  55227. * Creates a new AnaglyphArcRotateCamera
  55228. * @param name defines camera name
  55229. * @param alpha defines alpha angle (in radians)
  55230. * @param beta defines beta angle (in radians)
  55231. * @param radius defines radius
  55232. * @param target defines camera target
  55233. * @param interaxialDistance defines distance between each color axis
  55234. * @param scene defines the hosting scene
  55235. */
  55236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  55237. /**
  55238. * Gets camera class name
  55239. * @returns AnaglyphArcRotateCamera
  55240. */
  55241. getClassName(): string;
  55242. }
  55243. }
  55244. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  55245. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  55246. import { Scene } from "babylonjs/scene";
  55247. import { Vector3 } from "babylonjs/Maths/math.vector";
  55248. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55249. /**
  55250. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  55251. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  55252. */
  55253. export class AnaglyphFreeCamera extends FreeCamera {
  55254. /**
  55255. * Creates a new AnaglyphFreeCamera
  55256. * @param name defines camera name
  55257. * @param position defines initial position
  55258. * @param interaxialDistance defines distance between each color axis
  55259. * @param scene defines the hosting scene
  55260. */
  55261. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  55262. /**
  55263. * Gets camera class name
  55264. * @returns AnaglyphFreeCamera
  55265. */
  55266. getClassName(): string;
  55267. }
  55268. }
  55269. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  55270. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  55271. import { Scene } from "babylonjs/scene";
  55272. import { Vector3 } from "babylonjs/Maths/math.vector";
  55273. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55274. /**
  55275. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  55276. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  55277. */
  55278. export class AnaglyphGamepadCamera extends GamepadCamera {
  55279. /**
  55280. * Creates a new AnaglyphGamepadCamera
  55281. * @param name defines camera name
  55282. * @param position defines initial position
  55283. * @param interaxialDistance defines distance between each color axis
  55284. * @param scene defines the hosting scene
  55285. */
  55286. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  55287. /**
  55288. * Gets camera class name
  55289. * @returns AnaglyphGamepadCamera
  55290. */
  55291. getClassName(): string;
  55292. }
  55293. }
  55294. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  55295. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  55296. import { Scene } from "babylonjs/scene";
  55297. import { Vector3 } from "babylonjs/Maths/math.vector";
  55298. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55299. /**
  55300. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  55301. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  55302. */
  55303. export class AnaglyphUniversalCamera extends UniversalCamera {
  55304. /**
  55305. * Creates a new AnaglyphUniversalCamera
  55306. * @param name defines camera name
  55307. * @param position defines initial position
  55308. * @param interaxialDistance defines distance between each color axis
  55309. * @param scene defines the hosting scene
  55310. */
  55311. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  55312. /**
  55313. * Gets camera class name
  55314. * @returns AnaglyphUniversalCamera
  55315. */
  55316. getClassName(): string;
  55317. }
  55318. }
  55319. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  55320. /** @hidden */
  55321. export var stereoscopicInterlacePixelShader: {
  55322. name: string;
  55323. shader: string;
  55324. };
  55325. }
  55326. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  55327. import { Camera } from "babylonjs/Cameras/camera";
  55328. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55329. import { Engine } from "babylonjs/Engines/engine";
  55330. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  55331. /**
  55332. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  55333. */
  55334. export class StereoscopicInterlacePostProcessI extends PostProcess {
  55335. private _stepSize;
  55336. private _passedProcess;
  55337. /**
  55338. * Gets a string identifying the name of the class
  55339. * @returns "StereoscopicInterlacePostProcessI" string
  55340. */
  55341. getClassName(): string;
  55342. /**
  55343. * Initializes a StereoscopicInterlacePostProcessI
  55344. * @param name The name of the effect.
  55345. * @param rigCameras The rig cameras to be applied to the post process
  55346. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  55347. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  55348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55349. * @param engine The engine which the post process will be applied. (default: current engine)
  55350. * @param reusable If the post process can be reused on the same frame. (default: false)
  55351. */
  55352. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55353. }
  55354. /**
  55355. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  55356. */
  55357. export class StereoscopicInterlacePostProcess extends PostProcess {
  55358. private _stepSize;
  55359. private _passedProcess;
  55360. /**
  55361. * Gets a string identifying the name of the class
  55362. * @returns "StereoscopicInterlacePostProcess" string
  55363. */
  55364. getClassName(): string;
  55365. /**
  55366. * Initializes a StereoscopicInterlacePostProcess
  55367. * @param name The name of the effect.
  55368. * @param rigCameras The rig cameras to be applied to the post process
  55369. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  55370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55371. * @param engine The engine which the post process will be applied. (default: current engine)
  55372. * @param reusable If the post process can be reused on the same frame. (default: false)
  55373. */
  55374. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55375. }
  55376. }
  55377. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  55378. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  55379. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  55380. import { Scene } from "babylonjs/scene";
  55381. import { Vector3 } from "babylonjs/Maths/math.vector";
  55382. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55383. /**
  55384. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  55385. * @see https://doc.babylonjs.com/features/cameras
  55386. */
  55387. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  55388. /**
  55389. * Creates a new StereoscopicArcRotateCamera
  55390. * @param name defines camera name
  55391. * @param alpha defines alpha angle (in radians)
  55392. * @param beta defines beta angle (in radians)
  55393. * @param radius defines radius
  55394. * @param target defines camera target
  55395. * @param interaxialDistance defines distance between each color axis
  55396. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  55397. * @param scene defines the hosting scene
  55398. */
  55399. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  55400. /**
  55401. * Gets camera class name
  55402. * @returns StereoscopicArcRotateCamera
  55403. */
  55404. getClassName(): string;
  55405. }
  55406. }
  55407. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  55408. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  55409. import { Scene } from "babylonjs/scene";
  55410. import { Vector3 } from "babylonjs/Maths/math.vector";
  55411. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55412. /**
  55413. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  55414. * @see https://doc.babylonjs.com/features/cameras
  55415. */
  55416. export class StereoscopicFreeCamera extends FreeCamera {
  55417. /**
  55418. * Creates a new StereoscopicFreeCamera
  55419. * @param name defines camera name
  55420. * @param position defines initial position
  55421. * @param interaxialDistance defines distance between each color axis
  55422. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  55423. * @param scene defines the hosting scene
  55424. */
  55425. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  55426. /**
  55427. * Gets camera class name
  55428. * @returns StereoscopicFreeCamera
  55429. */
  55430. getClassName(): string;
  55431. }
  55432. }
  55433. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  55434. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  55435. import { Scene } from "babylonjs/scene";
  55436. import { Vector3 } from "babylonjs/Maths/math.vector";
  55437. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55438. /**
  55439. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  55440. * @see https://doc.babylonjs.com/features/cameras
  55441. */
  55442. export class StereoscopicGamepadCamera extends GamepadCamera {
  55443. /**
  55444. * Creates a new StereoscopicGamepadCamera
  55445. * @param name defines camera name
  55446. * @param position defines initial position
  55447. * @param interaxialDistance defines distance between each color axis
  55448. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  55449. * @param scene defines the hosting scene
  55450. */
  55451. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  55452. /**
  55453. * Gets camera class name
  55454. * @returns StereoscopicGamepadCamera
  55455. */
  55456. getClassName(): string;
  55457. }
  55458. }
  55459. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  55460. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  55461. import { Scene } from "babylonjs/scene";
  55462. import { Vector3 } from "babylonjs/Maths/math.vector";
  55463. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55464. /**
  55465. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  55466. * @see https://doc.babylonjs.com/features/cameras
  55467. */
  55468. export class StereoscopicUniversalCamera extends UniversalCamera {
  55469. /**
  55470. * Creates a new StereoscopicUniversalCamera
  55471. * @param name defines camera name
  55472. * @param position defines initial position
  55473. * @param interaxialDistance defines distance between each color axis
  55474. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  55475. * @param scene defines the hosting scene
  55476. */
  55477. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  55478. /**
  55479. * Gets camera class name
  55480. * @returns StereoscopicUniversalCamera
  55481. */
  55482. getClassName(): string;
  55483. }
  55484. }
  55485. declare module "babylonjs/Cameras/Stereoscopic/index" {
  55486. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  55487. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  55488. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  55489. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  55490. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  55491. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  55492. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  55493. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  55494. }
  55495. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  55496. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  55497. import { Scene } from "babylonjs/scene";
  55498. import { Vector3 } from "babylonjs/Maths/math.vector";
  55499. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  55500. /**
  55501. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  55502. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  55503. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  55504. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  55505. */
  55506. export class VirtualJoysticksCamera extends FreeCamera {
  55507. /**
  55508. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  55509. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  55510. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  55511. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  55512. * @param name Define the name of the camera in the scene
  55513. * @param position Define the start position of the camera in the scene
  55514. * @param scene Define the scene the camera belongs to
  55515. */
  55516. constructor(name: string, position: Vector3, scene: Scene);
  55517. /**
  55518. * Gets the current object class name.
  55519. * @return the class name
  55520. */
  55521. getClassName(): string;
  55522. }
  55523. }
  55524. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  55525. import { Matrix } from "babylonjs/Maths/math.vector";
  55526. /**
  55527. * This represents all the required metrics to create a VR camera.
  55528. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  55529. */
  55530. export class VRCameraMetrics {
  55531. /**
  55532. * Define the horizontal resolution off the screen.
  55533. */
  55534. hResolution: number;
  55535. /**
  55536. * Define the vertical resolution off the screen.
  55537. */
  55538. vResolution: number;
  55539. /**
  55540. * Define the horizontal screen size.
  55541. */
  55542. hScreenSize: number;
  55543. /**
  55544. * Define the vertical screen size.
  55545. */
  55546. vScreenSize: number;
  55547. /**
  55548. * Define the vertical screen center position.
  55549. */
  55550. vScreenCenter: number;
  55551. /**
  55552. * Define the distance of the eyes to the screen.
  55553. */
  55554. eyeToScreenDistance: number;
  55555. /**
  55556. * Define the distance between both lenses
  55557. */
  55558. lensSeparationDistance: number;
  55559. /**
  55560. * Define the distance between both viewer's eyes.
  55561. */
  55562. interpupillaryDistance: number;
  55563. /**
  55564. * Define the distortion factor of the VR postprocess.
  55565. * Please, touch with care.
  55566. */
  55567. distortionK: number[];
  55568. /**
  55569. * Define the chromatic aberration correction factors for the VR post process.
  55570. */
  55571. chromaAbCorrection: number[];
  55572. /**
  55573. * Define the scale factor of the post process.
  55574. * The smaller the better but the slower.
  55575. */
  55576. postProcessScaleFactor: number;
  55577. /**
  55578. * Define an offset for the lens center.
  55579. */
  55580. lensCenterOffset: number;
  55581. /**
  55582. * Define if the current vr camera should compensate the distortion of the lens or not.
  55583. */
  55584. compensateDistortion: boolean;
  55585. /**
  55586. * Defines if multiview should be enabled when rendering (Default: false)
  55587. */
  55588. multiviewEnabled: boolean;
  55589. /**
  55590. * Gets the rendering aspect ratio based on the provided resolutions.
  55591. */
  55592. get aspectRatio(): number;
  55593. /**
  55594. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  55595. */
  55596. get aspectRatioFov(): number;
  55597. /**
  55598. * @hidden
  55599. */
  55600. get leftHMatrix(): Matrix;
  55601. /**
  55602. * @hidden
  55603. */
  55604. get rightHMatrix(): Matrix;
  55605. /**
  55606. * @hidden
  55607. */
  55608. get leftPreViewMatrix(): Matrix;
  55609. /**
  55610. * @hidden
  55611. */
  55612. get rightPreViewMatrix(): Matrix;
  55613. /**
  55614. * Get the default VRMetrics based on the most generic setup.
  55615. * @returns the default vr metrics
  55616. */
  55617. static GetDefault(): VRCameraMetrics;
  55618. }
  55619. }
  55620. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  55621. /** @hidden */
  55622. export var vrDistortionCorrectionPixelShader: {
  55623. name: string;
  55624. shader: string;
  55625. };
  55626. }
  55627. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  55628. import { Camera } from "babylonjs/Cameras/camera";
  55629. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55630. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55631. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  55632. /**
  55633. * VRDistortionCorrectionPostProcess used for mobile VR
  55634. */
  55635. export class VRDistortionCorrectionPostProcess extends PostProcess {
  55636. private _isRightEye;
  55637. private _distortionFactors;
  55638. private _postProcessScaleFactor;
  55639. private _lensCenterOffset;
  55640. private _scaleIn;
  55641. private _scaleFactor;
  55642. private _lensCenter;
  55643. /**
  55644. * Gets a string identifying the name of the class
  55645. * @returns "VRDistortionCorrectionPostProcess" string
  55646. */
  55647. getClassName(): string;
  55648. /**
  55649. * Initializes the VRDistortionCorrectionPostProcess
  55650. * @param name The name of the effect.
  55651. * @param camera The camera to apply the render pass to.
  55652. * @param isRightEye If this is for the right eye distortion
  55653. * @param vrMetrics All the required metrics for the VR camera
  55654. */
  55655. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  55656. }
  55657. }
  55658. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  55659. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  55660. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  55661. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55662. import { Scene } from "babylonjs/scene";
  55663. import { Vector3 } from "babylonjs/Maths/math.vector";
  55664. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  55665. import "babylonjs/Cameras/RigModes/vrRigMode";
  55666. /**
  55667. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  55668. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55669. */
  55670. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  55671. /**
  55672. * Creates a new VRDeviceOrientationArcRotateCamera
  55673. * @param name defines camera name
  55674. * @param alpha defines the camera rotation along the longitudinal axis
  55675. * @param beta defines the camera rotation along the latitudinal axis
  55676. * @param radius defines the camera distance from its target
  55677. * @param target defines the camera target
  55678. * @param scene defines the scene the camera belongs to
  55679. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  55680. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55681. */
  55682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55683. /**
  55684. * Gets camera class name
  55685. * @returns VRDeviceOrientationArcRotateCamera
  55686. */
  55687. getClassName(): string;
  55688. }
  55689. }
  55690. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  55691. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55692. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55693. import { Scene } from "babylonjs/scene";
  55694. import { Vector3 } from "babylonjs/Maths/math.vector";
  55695. import "babylonjs/Cameras/RigModes/vrRigMode";
  55696. /**
  55697. * Camera used to simulate VR rendering (based on FreeCamera)
  55698. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55699. */
  55700. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  55701. /**
  55702. * Creates a new VRDeviceOrientationFreeCamera
  55703. * @param name defines camera name
  55704. * @param position defines the start position of the camera
  55705. * @param scene defines the scene the camera belongs to
  55706. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  55707. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55708. */
  55709. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55710. /**
  55711. * Gets camera class name
  55712. * @returns VRDeviceOrientationFreeCamera
  55713. */
  55714. getClassName(): string;
  55715. }
  55716. }
  55717. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  55718. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55719. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55720. import { Scene } from "babylonjs/scene";
  55721. import { Vector3 } from "babylonjs/Maths/math.vector";
  55722. import "babylonjs/Gamepads/gamepadSceneComponent";
  55723. /**
  55724. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  55725. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  55726. */
  55727. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  55728. /**
  55729. * Creates a new VRDeviceOrientationGamepadCamera
  55730. * @param name defines camera name
  55731. * @param position defines the start position of the camera
  55732. * @param scene defines the scene the camera belongs to
  55733. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  55734. * @param vrCameraMetrics defines the vr metrics associated to the camera
  55735. */
  55736. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  55737. /**
  55738. * Gets camera class name
  55739. * @returns VRDeviceOrientationGamepadCamera
  55740. */
  55741. getClassName(): string;
  55742. }
  55743. }
  55744. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  55745. import { Scene } from "babylonjs/scene";
  55746. import { Texture } from "babylonjs/Materials/Textures/texture";
  55747. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55748. /**
  55749. * A class extending Texture allowing drawing on a texture
  55750. * @see https://doc.babylonjs.com/how_to/dynamictexture
  55751. */
  55752. export class DynamicTexture extends Texture {
  55753. private _generateMipMaps;
  55754. private _canvas;
  55755. private _context;
  55756. /**
  55757. * Creates a DynamicTexture
  55758. * @param name defines the name of the texture
  55759. * @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
  55760. * @param scene defines the scene where you want the texture
  55761. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55762. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55763. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55764. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  55765. */
  55766. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  55767. /**
  55768. * Get the current class name of the texture useful for serialization or dynamic coding.
  55769. * @returns "DynamicTexture"
  55770. */
  55771. getClassName(): string;
  55772. /**
  55773. * Gets the current state of canRescale
  55774. */
  55775. get canRescale(): boolean;
  55776. private _recreate;
  55777. /**
  55778. * Scales the texture
  55779. * @param ratio the scale factor to apply to both width and height
  55780. */
  55781. scale(ratio: number): void;
  55782. /**
  55783. * Resizes the texture
  55784. * @param width the new width
  55785. * @param height the new height
  55786. */
  55787. scaleTo(width: number, height: number): void;
  55788. /**
  55789. * Gets the context of the canvas used by the texture
  55790. * @returns the canvas context of the dynamic texture
  55791. */
  55792. getContext(): CanvasRenderingContext2D;
  55793. /**
  55794. * Clears the texture
  55795. */
  55796. clear(): void;
  55797. /**
  55798. * Updates the texture
  55799. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55800. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55801. */
  55802. update(invertY?: boolean, premulAlpha?: boolean): void;
  55803. /**
  55804. * Draws text onto the texture
  55805. * @param text defines the text to be drawn
  55806. * @param x defines the placement of the text from the left
  55807. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55808. * @param font defines the font to be used with font-style, font-size, font-name
  55809. * @param color defines the color used for the text
  55810. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55811. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55812. * @param update defines whether texture is immediately update (default is true)
  55813. */
  55814. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  55815. /**
  55816. * Clones the texture
  55817. * @returns the clone of the texture.
  55818. */
  55819. clone(): DynamicTexture;
  55820. /**
  55821. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55822. * @returns a serialized dynamic texture object
  55823. */
  55824. serialize(): any;
  55825. private _IsCanvasElement;
  55826. /** @hidden */
  55827. _rebuild(): void;
  55828. }
  55829. }
  55830. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  55831. import { Scene } from "babylonjs/scene";
  55832. import { Color3 } from "babylonjs/Maths/math.color";
  55833. import { Mesh } from "babylonjs/Meshes/mesh";
  55834. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55835. import { Nullable } from "babylonjs/types";
  55836. /**
  55837. * Class containing static functions to help procedurally build meshes
  55838. */
  55839. export class GroundBuilder {
  55840. /**
  55841. * Creates a ground mesh
  55842. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55843. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55845. * @param name defines the name of the mesh
  55846. * @param options defines the options used to create the mesh
  55847. * @param scene defines the hosting scene
  55848. * @returns the ground mesh
  55849. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55850. */
  55851. static CreateGround(name: string, options: {
  55852. width?: number;
  55853. height?: number;
  55854. subdivisions?: number;
  55855. subdivisionsX?: number;
  55856. subdivisionsY?: number;
  55857. updatable?: boolean;
  55858. }, scene: any): Mesh;
  55859. /**
  55860. * Creates a tiled ground mesh
  55861. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55862. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55863. * * 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
  55864. * * 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
  55865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55866. * @param name defines the name of the mesh
  55867. * @param options defines the options used to create the mesh
  55868. * @param scene defines the hosting scene
  55869. * @returns the tiled ground mesh
  55870. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55871. */
  55872. static CreateTiledGround(name: string, options: {
  55873. xmin: number;
  55874. zmin: number;
  55875. xmax: number;
  55876. zmax: number;
  55877. subdivisions?: {
  55878. w: number;
  55879. h: number;
  55880. };
  55881. precision?: {
  55882. w: number;
  55883. h: number;
  55884. };
  55885. updatable?: boolean;
  55886. }, scene?: Nullable<Scene>): Mesh;
  55887. /**
  55888. * Creates a ground mesh from a height map
  55889. * * The parameter `url` sets the URL of the height map image resource.
  55890. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55891. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55892. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55893. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55894. * * 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.
  55895. * * 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).
  55896. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55898. * @param name defines the name of the mesh
  55899. * @param url defines the url to the height map
  55900. * @param options defines the options used to create the mesh
  55901. * @param scene defines the hosting scene
  55902. * @returns the ground mesh
  55903. * @see https://doc.babylonjs.com/babylon101/height_map
  55904. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55905. */
  55906. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55907. width?: number;
  55908. height?: number;
  55909. subdivisions?: number;
  55910. minHeight?: number;
  55911. maxHeight?: number;
  55912. colorFilter?: Color3;
  55913. alphaFilter?: number;
  55914. updatable?: boolean;
  55915. onReady?: (mesh: GroundMesh) => void;
  55916. }, scene?: Nullable<Scene>): GroundMesh;
  55917. }
  55918. }
  55919. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  55920. import { Vector4 } from "babylonjs/Maths/math.vector";
  55921. import { Mesh } from "babylonjs/Meshes/mesh";
  55922. /**
  55923. * Class containing static functions to help procedurally build meshes
  55924. */
  55925. export class TorusBuilder {
  55926. /**
  55927. * Creates a torus mesh
  55928. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55929. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55930. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  55931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55934. * @param name defines the name of the mesh
  55935. * @param options defines the options used to create the mesh
  55936. * @param scene defines the hosting scene
  55937. * @returns the torus mesh
  55938. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55939. */
  55940. static CreateTorus(name: string, options: {
  55941. diameter?: number;
  55942. thickness?: number;
  55943. tessellation?: number;
  55944. updatable?: boolean;
  55945. sideOrientation?: number;
  55946. frontUVs?: Vector4;
  55947. backUVs?: Vector4;
  55948. }, scene: any): Mesh;
  55949. }
  55950. }
  55951. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  55952. import { Vector4 } from "babylonjs/Maths/math.vector";
  55953. import { Color4 } from "babylonjs/Maths/math.color";
  55954. import { Mesh } from "babylonjs/Meshes/mesh";
  55955. /**
  55956. * Class containing static functions to help procedurally build meshes
  55957. */
  55958. export class CylinderBuilder {
  55959. /**
  55960. * Creates a cylinder or a cone mesh
  55961. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55962. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55963. * * 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.
  55964. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55965. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55966. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55967. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55968. * * 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).
  55969. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55970. * * 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).
  55971. * * 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
  55972. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55973. * * 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
  55974. * * 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.
  55975. * * If `enclose` is false, a ring surface is one element.
  55976. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55977. * * 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
  55978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55981. * @param name defines the name of the mesh
  55982. * @param options defines the options used to create the mesh
  55983. * @param scene defines the hosting scene
  55984. * @returns the cylinder mesh
  55985. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55986. */
  55987. static CreateCylinder(name: string, options: {
  55988. height?: number;
  55989. diameterTop?: number;
  55990. diameterBottom?: number;
  55991. diameter?: number;
  55992. tessellation?: number;
  55993. subdivisions?: number;
  55994. arc?: number;
  55995. faceColors?: Color4[];
  55996. faceUV?: Vector4[];
  55997. updatable?: boolean;
  55998. hasRings?: boolean;
  55999. enclose?: boolean;
  56000. cap?: number;
  56001. sideOrientation?: number;
  56002. frontUVs?: Vector4;
  56003. backUVs?: Vector4;
  56004. }, scene: any): Mesh;
  56005. }
  56006. }
  56007. declare module "babylonjs/XR/webXRTypes" {
  56008. import { Nullable } from "babylonjs/types";
  56009. import { IDisposable } from "babylonjs/scene";
  56010. /**
  56011. * States of the webXR experience
  56012. */
  56013. export enum WebXRState {
  56014. /**
  56015. * Transitioning to being in XR mode
  56016. */
  56017. ENTERING_XR = 0,
  56018. /**
  56019. * Transitioning to non XR mode
  56020. */
  56021. EXITING_XR = 1,
  56022. /**
  56023. * In XR mode and presenting
  56024. */
  56025. IN_XR = 2,
  56026. /**
  56027. * Not entered XR mode
  56028. */
  56029. NOT_IN_XR = 3
  56030. }
  56031. /**
  56032. * The state of the XR camera's tracking
  56033. */
  56034. export enum WebXRTrackingState {
  56035. /**
  56036. * No transformation received, device is not being tracked
  56037. */
  56038. NOT_TRACKING = 0,
  56039. /**
  56040. * Tracking lost - using emulated position
  56041. */
  56042. TRACKING_LOST = 1,
  56043. /**
  56044. * Transformation tracking works normally
  56045. */
  56046. TRACKING = 2
  56047. }
  56048. /**
  56049. * Abstraction of the XR render target
  56050. */
  56051. export interface WebXRRenderTarget extends IDisposable {
  56052. /**
  56053. * xrpresent context of the canvas which can be used to display/mirror xr content
  56054. */
  56055. canvasContext: WebGLRenderingContext;
  56056. /**
  56057. * xr layer for the canvas
  56058. */
  56059. xrLayer: Nullable<XRWebGLLayer>;
  56060. /**
  56061. * Initializes the xr layer for the session
  56062. * @param xrSession xr session
  56063. * @returns a promise that will resolve once the XR Layer has been created
  56064. */
  56065. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  56066. }
  56067. }
  56068. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  56069. import { Nullable } from "babylonjs/types";
  56070. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56071. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  56072. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  56073. import { Observable } from "babylonjs/Misc/observable";
  56074. /**
  56075. * Configuration object for WebXR output canvas
  56076. */
  56077. export class WebXRManagedOutputCanvasOptions {
  56078. /**
  56079. * An optional canvas in case you wish to create it yourself and provide it here.
  56080. * If not provided, a new canvas will be created
  56081. */
  56082. canvasElement?: HTMLCanvasElement;
  56083. /**
  56084. * Options for this XR Layer output
  56085. */
  56086. canvasOptions?: XRWebGLLayerInit;
  56087. /**
  56088. * CSS styling for a newly created canvas (if not provided)
  56089. */
  56090. newCanvasCssStyle?: string;
  56091. /**
  56092. * Get the default values of the configuration object
  56093. * @param engine defines the engine to use (can be null)
  56094. * @returns default values of this configuration object
  56095. */
  56096. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  56097. }
  56098. /**
  56099. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  56100. */
  56101. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  56102. private _options;
  56103. private _canvas;
  56104. private _engine;
  56105. private _originalCanvasSize;
  56106. /**
  56107. * Rendering context of the canvas which can be used to display/mirror xr content
  56108. */
  56109. canvasContext: WebGLRenderingContext;
  56110. /**
  56111. * xr layer for the canvas
  56112. */
  56113. xrLayer: Nullable<XRWebGLLayer>;
  56114. /**
  56115. * Observers registered here will be triggered when the xr layer was initialized
  56116. */
  56117. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  56118. /**
  56119. * Initializes the canvas to be added/removed upon entering/exiting xr
  56120. * @param _xrSessionManager The XR Session manager
  56121. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  56122. */
  56123. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  56124. /**
  56125. * Disposes of the object
  56126. */
  56127. dispose(): void;
  56128. /**
  56129. * Initializes the xr layer for the session
  56130. * @param xrSession xr session
  56131. * @returns a promise that will resolve once the XR Layer has been created
  56132. */
  56133. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  56134. private _addCanvas;
  56135. private _removeCanvas;
  56136. private _setCanvasSize;
  56137. private _setManagedOutputCanvas;
  56138. }
  56139. }
  56140. declare module "babylonjs/XR/webXRSessionManager" {
  56141. import { Observable } from "babylonjs/Misc/observable";
  56142. import { Nullable } from "babylonjs/types";
  56143. import { IDisposable, Scene } from "babylonjs/scene";
  56144. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56145. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  56146. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  56147. /**
  56148. * Manages an XRSession to work with Babylon's engine
  56149. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  56150. */
  56151. export class WebXRSessionManager implements IDisposable {
  56152. /** The scene which the session should be created for */
  56153. scene: Scene;
  56154. private _referenceSpace;
  56155. private _rttProvider;
  56156. private _sessionEnded;
  56157. private _xrNavigator;
  56158. private baseLayer;
  56159. /**
  56160. * The base reference space from which the session started. good if you want to reset your
  56161. * reference space
  56162. */
  56163. baseReferenceSpace: XRReferenceSpace;
  56164. /**
  56165. * Current XR frame
  56166. */
  56167. currentFrame: Nullable<XRFrame>;
  56168. /** WebXR timestamp updated every frame */
  56169. currentTimestamp: number;
  56170. /**
  56171. * Used just in case of a failure to initialize an immersive session.
  56172. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  56173. */
  56174. defaultHeightCompensation: number;
  56175. /**
  56176. * Fires every time a new xrFrame arrives which can be used to update the camera
  56177. */
  56178. onXRFrameObservable: Observable<XRFrame>;
  56179. /**
  56180. * Fires when the reference space changed
  56181. */
  56182. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  56183. /**
  56184. * Fires when the xr session is ended either by the device or manually done
  56185. */
  56186. onXRSessionEnded: Observable<any>;
  56187. /**
  56188. * Fires when the xr session is ended either by the device or manually done
  56189. */
  56190. onXRSessionInit: Observable<XRSession>;
  56191. /**
  56192. * Underlying xr session
  56193. */
  56194. session: XRSession;
  56195. /**
  56196. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  56197. * or get the offset the player is currently at.
  56198. */
  56199. viewerReferenceSpace: XRReferenceSpace;
  56200. /**
  56201. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  56202. * @param scene The scene which the session should be created for
  56203. */
  56204. constructor(
  56205. /** The scene which the session should be created for */
  56206. scene: Scene);
  56207. /**
  56208. * The current reference space used in this session. This reference space can constantly change!
  56209. * It is mainly used to offset the camera's position.
  56210. */
  56211. get referenceSpace(): XRReferenceSpace;
  56212. /**
  56213. * Set a new reference space and triggers the observable
  56214. */
  56215. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  56216. /**
  56217. * Disposes of the session manager
  56218. */
  56219. dispose(): void;
  56220. /**
  56221. * Stops the xrSession and restores the render loop
  56222. * @returns Promise which resolves after it exits XR
  56223. */
  56224. exitXRAsync(): Promise<void>;
  56225. /**
  56226. * Gets the correct render target texture to be rendered this frame for this eye
  56227. * @param eye the eye for which to get the render target
  56228. * @returns the render target for the specified eye
  56229. */
  56230. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  56231. /**
  56232. * Creates a WebXRRenderTarget object for the XR session
  56233. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  56234. * @param options optional options to provide when creating a new render target
  56235. * @returns a WebXR render target to which the session can render
  56236. */
  56237. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  56238. /**
  56239. * Initializes the manager
  56240. * After initialization enterXR can be called to start an XR session
  56241. * @returns Promise which resolves after it is initialized
  56242. */
  56243. initializeAsync(): Promise<void>;
  56244. /**
  56245. * Initializes an xr session
  56246. * @param xrSessionMode mode to initialize
  56247. * @param xrSessionInit defines optional and required values to pass to the session builder
  56248. * @returns a promise which will resolve once the session has been initialized
  56249. */
  56250. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  56251. /**
  56252. * Checks if a session would be supported for the creation options specified
  56253. * @param sessionMode session mode to check if supported eg. immersive-vr
  56254. * @returns A Promise that resolves to true if supported and false if not
  56255. */
  56256. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  56257. /**
  56258. * Resets the reference space to the one started the session
  56259. */
  56260. resetReferenceSpace(): void;
  56261. /**
  56262. * Starts rendering to the xr layer
  56263. */
  56264. runXRRenderLoop(): void;
  56265. /**
  56266. * Sets the reference space on the xr session
  56267. * @param referenceSpaceType space to set
  56268. * @returns a promise that will resolve once the reference space has been set
  56269. */
  56270. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  56271. /**
  56272. * Updates the render state of the session
  56273. * @param state state to set
  56274. * @returns a promise that resolves once the render state has been updated
  56275. */
  56276. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  56277. /**
  56278. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  56279. * @param sessionMode defines the session to test
  56280. * @returns a promise with boolean as final value
  56281. */
  56282. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  56283. /**
  56284. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  56285. */
  56286. get isNative(): boolean;
  56287. private _createRenderTargetTexture;
  56288. }
  56289. }
  56290. declare module "babylonjs/XR/webXRCamera" {
  56291. import { Vector3 } from "babylonjs/Maths/math.vector";
  56292. import { Scene } from "babylonjs/scene";
  56293. import { Camera } from "babylonjs/Cameras/camera";
  56294. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  56295. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  56296. import { Observable } from "babylonjs/Misc/observable";
  56297. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  56298. /**
  56299. * WebXR Camera which holds the views for the xrSession
  56300. * @see https://doc.babylonjs.com/how_to/webxr_camera
  56301. */
  56302. export class WebXRCamera extends FreeCamera {
  56303. private _xrSessionManager;
  56304. private _firstFrame;
  56305. private _referenceQuaternion;
  56306. private _referencedPosition;
  56307. private _xrInvPositionCache;
  56308. private _xrInvQuaternionCache;
  56309. private _trackingState;
  56310. /**
  56311. * Observable raised before camera teleportation
  56312. */
  56313. onBeforeCameraTeleport: Observable<Vector3>;
  56314. /**
  56315. * Observable raised after camera teleportation
  56316. */
  56317. onAfterCameraTeleport: Observable<Vector3>;
  56318. /**
  56319. * Notifies when the camera's tracking state has changed.
  56320. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  56321. */
  56322. onTrackingStateChanged: Observable<WebXRTrackingState>;
  56323. /**
  56324. * Should position compensation execute on first frame.
  56325. * This is used when copying the position from a native (non XR) camera
  56326. */
  56327. compensateOnFirstFrame: boolean;
  56328. /**
  56329. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  56330. * @param name the name of the camera
  56331. * @param scene the scene to add the camera to
  56332. * @param _xrSessionManager a constructed xr session manager
  56333. */
  56334. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  56335. /**
  56336. * Get the current XR tracking state of the camera
  56337. */
  56338. get trackingState(): WebXRTrackingState;
  56339. private _setTrackingState;
  56340. /**
  56341. * Return the user's height, unrelated to the current ground.
  56342. * This will be the y position of this camera, when ground level is 0.
  56343. */
  56344. get realWorldHeight(): number;
  56345. /** @hidden */
  56346. _updateForDualEyeDebugging(): void;
  56347. /**
  56348. * Sets this camera's transformation based on a non-vr camera
  56349. * @param otherCamera the non-vr camera to copy the transformation from
  56350. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  56351. */
  56352. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  56353. /**
  56354. * Gets the current instance class name ("WebXRCamera").
  56355. * @returns the class name
  56356. */
  56357. getClassName(): string;
  56358. private _rotate180;
  56359. private _updateFromXRSession;
  56360. private _updateNumberOfRigCameras;
  56361. private _updateReferenceSpace;
  56362. private _updateReferenceSpaceOffset;
  56363. }
  56364. }
  56365. declare module "babylonjs/XR/webXRFeaturesManager" {
  56366. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  56367. import { IDisposable } from "babylonjs/scene";
  56368. /**
  56369. * Defining the interface required for a (webxr) feature
  56370. */
  56371. export interface IWebXRFeature extends IDisposable {
  56372. /**
  56373. * Is this feature attached
  56374. */
  56375. attached: boolean;
  56376. /**
  56377. * Should auto-attach be disabled?
  56378. */
  56379. disableAutoAttach: boolean;
  56380. /**
  56381. * Attach the feature to the session
  56382. * Will usually be called by the features manager
  56383. *
  56384. * @param force should attachment be forced (even when already attached)
  56385. * @returns true if successful.
  56386. */
  56387. attach(force?: boolean): boolean;
  56388. /**
  56389. * Detach the feature from the session
  56390. * Will usually be called by the features manager
  56391. *
  56392. * @returns true if successful.
  56393. */
  56394. detach(): boolean;
  56395. /**
  56396. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  56397. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  56398. *
  56399. * @returns whether or not the feature is compatible in this environment
  56400. */
  56401. isCompatible(): boolean;
  56402. /**
  56403. * Was this feature disposed;
  56404. */
  56405. isDisposed: boolean;
  56406. /**
  56407. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  56408. */
  56409. xrNativeFeatureName?: string;
  56410. /**
  56411. * A list of (Babylon WebXR) features this feature depends on
  56412. */
  56413. dependsOn?: string[];
  56414. /**
  56415. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  56416. */
  56417. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  56418. }
  56419. /**
  56420. * A list of the currently available features without referencing them
  56421. */
  56422. export class WebXRFeatureName {
  56423. /**
  56424. * The name of the anchor system feature
  56425. */
  56426. static readonly ANCHOR_SYSTEM: string;
  56427. /**
  56428. * The name of the background remover feature
  56429. */
  56430. static readonly BACKGROUND_REMOVER: string;
  56431. /**
  56432. * The name of the hit test feature
  56433. */
  56434. static readonly HIT_TEST: string;
  56435. /**
  56436. * The name of the mesh detection feature
  56437. */
  56438. static readonly MESH_DETECTION: string;
  56439. /**
  56440. * physics impostors for xr controllers feature
  56441. */
  56442. static readonly PHYSICS_CONTROLLERS: string;
  56443. /**
  56444. * The name of the plane detection feature
  56445. */
  56446. static readonly PLANE_DETECTION: string;
  56447. /**
  56448. * The name of the pointer selection feature
  56449. */
  56450. static readonly POINTER_SELECTION: string;
  56451. /**
  56452. * The name of the teleportation feature
  56453. */
  56454. static readonly TELEPORTATION: string;
  56455. /**
  56456. * The name of the feature points feature.
  56457. */
  56458. static readonly FEATURE_POINTS: string;
  56459. /**
  56460. * The name of the hand tracking feature.
  56461. */
  56462. static readonly HAND_TRACKING: string;
  56463. /**
  56464. * The name of the image tracking feature
  56465. */
  56466. static readonly IMAGE_TRACKING: string;
  56467. }
  56468. /**
  56469. * Defining the constructor of a feature. Used to register the modules.
  56470. */
  56471. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  56472. /**
  56473. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  56474. * It is mainly used in AR sessions.
  56475. *
  56476. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  56477. */
  56478. export class WebXRFeaturesManager implements IDisposable {
  56479. private _xrSessionManager;
  56480. private static readonly _AvailableFeatures;
  56481. private _features;
  56482. /**
  56483. * constructs a new features manages.
  56484. *
  56485. * @param _xrSessionManager an instance of WebXRSessionManager
  56486. */
  56487. constructor(_xrSessionManager: WebXRSessionManager);
  56488. /**
  56489. * Used to register a module. After calling this function a developer can use this feature in the scene.
  56490. * Mainly used internally.
  56491. *
  56492. * @param featureName the name of the feature to register
  56493. * @param constructorFunction the function used to construct the module
  56494. * @param version the (babylon) version of the module
  56495. * @param stable is that a stable version of this module
  56496. */
  56497. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  56498. /**
  56499. * Returns a constructor of a specific feature.
  56500. *
  56501. * @param featureName the name of the feature to construct
  56502. * @param version the version of the feature to load
  56503. * @param xrSessionManager the xrSessionManager. Used to construct the module
  56504. * @param options optional options provided to the module.
  56505. * @returns a function that, when called, will return a new instance of this feature
  56506. */
  56507. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  56508. /**
  56509. * Can be used to return the list of features currently registered
  56510. *
  56511. * @returns an Array of available features
  56512. */
  56513. static GetAvailableFeatures(): string[];
  56514. /**
  56515. * Gets the versions available for a specific feature
  56516. * @param featureName the name of the feature
  56517. * @returns an array with the available versions
  56518. */
  56519. static GetAvailableVersions(featureName: string): string[];
  56520. /**
  56521. * Return the latest unstable version of this feature
  56522. * @param featureName the name of the feature to search
  56523. * @returns the version number. if not found will return -1
  56524. */
  56525. static GetLatestVersionOfFeature(featureName: string): number;
  56526. /**
  56527. * Return the latest stable version of this feature
  56528. * @param featureName the name of the feature to search
  56529. * @returns the version number. if not found will return -1
  56530. */
  56531. static GetStableVersionOfFeature(featureName: string): number;
  56532. /**
  56533. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  56534. * Can be used during a session to start a feature
  56535. * @param featureName the name of feature to attach
  56536. */
  56537. attachFeature(featureName: string): void;
  56538. /**
  56539. * Can be used inside a session or when the session ends to detach a specific feature
  56540. * @param featureName the name of the feature to detach
  56541. */
  56542. detachFeature(featureName: string): void;
  56543. /**
  56544. * Used to disable an already-enabled feature
  56545. * The feature will be disposed and will be recreated once enabled.
  56546. * @param featureName the feature to disable
  56547. * @returns true if disable was successful
  56548. */
  56549. disableFeature(featureName: string | {
  56550. Name: string;
  56551. }): boolean;
  56552. /**
  56553. * dispose this features manager
  56554. */
  56555. dispose(): void;
  56556. /**
  56557. * 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.
  56558. * 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.
  56559. *
  56560. * @param featureName the name of the feature to load or the class of the feature
  56561. * @param version optional version to load. if not provided the latest version will be enabled
  56562. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  56563. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  56564. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  56565. * @returns a new constructed feature or throws an error if feature not found.
  56566. */
  56567. enableFeature(featureName: string | {
  56568. Name: string;
  56569. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  56570. /**
  56571. * get the implementation of an enabled feature.
  56572. * @param featureName the name of the feature to load
  56573. * @returns the feature class, if found
  56574. */
  56575. getEnabledFeature(featureName: string): IWebXRFeature;
  56576. /**
  56577. * Get the list of enabled features
  56578. * @returns an array of enabled features
  56579. */
  56580. getEnabledFeatures(): string[];
  56581. /**
  56582. * This function will extend the session creation configuration object with enabled features.
  56583. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  56584. * according to the defined "required" variable, provided during enableFeature call
  56585. * @param xrSessionInit the xr Session init object to extend
  56586. *
  56587. * @returns an extended XRSessionInit object
  56588. */
  56589. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  56590. }
  56591. }
  56592. declare module "babylonjs/XR/webXRExperienceHelper" {
  56593. import { Observable } from "babylonjs/Misc/observable";
  56594. import { IDisposable, Scene } from "babylonjs/scene";
  56595. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  56596. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  56597. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  56598. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  56599. /**
  56600. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  56601. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  56602. */
  56603. export class WebXRExperienceHelper implements IDisposable {
  56604. private scene;
  56605. private _nonVRCamera;
  56606. private _originalSceneAutoClear;
  56607. private _supported;
  56608. /**
  56609. * Camera used to render xr content
  56610. */
  56611. camera: WebXRCamera;
  56612. /** A features manager for this xr session */
  56613. featuresManager: WebXRFeaturesManager;
  56614. /**
  56615. * Observers registered here will be triggered after the camera's initial transformation is set
  56616. * This can be used to set a different ground level or an extra rotation.
  56617. *
  56618. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  56619. * to the position set after this observable is done executing.
  56620. */
  56621. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  56622. /**
  56623. * Fires when the state of the experience helper has changed
  56624. */
  56625. onStateChangedObservable: Observable<WebXRState>;
  56626. /** Session manager used to keep track of xr session */
  56627. sessionManager: WebXRSessionManager;
  56628. /**
  56629. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  56630. */
  56631. state: WebXRState;
  56632. /**
  56633. * Creates a WebXRExperienceHelper
  56634. * @param scene The scene the helper should be created in
  56635. */
  56636. private constructor();
  56637. /**
  56638. * Creates the experience helper
  56639. * @param scene the scene to attach the experience helper to
  56640. * @returns a promise for the experience helper
  56641. */
  56642. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  56643. /**
  56644. * Disposes of the experience helper
  56645. */
  56646. dispose(): void;
  56647. /**
  56648. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  56649. * @param sessionMode options for the XR session
  56650. * @param referenceSpaceType frame of reference of the XR session
  56651. * @param renderTarget the output canvas that will be used to enter XR mode
  56652. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  56653. * @returns promise that resolves after xr mode has entered
  56654. */
  56655. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  56656. /**
  56657. * Exits XR mode and returns the scene to its original state
  56658. * @returns promise that resolves after xr mode has exited
  56659. */
  56660. exitXRAsync(): Promise<void>;
  56661. private _nonXRToXRCamera;
  56662. private _setState;
  56663. }
  56664. }
  56665. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  56666. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56667. import { Observable } from "babylonjs/Misc/observable";
  56668. import { IDisposable } from "babylonjs/scene";
  56669. /**
  56670. * X-Y values for axes in WebXR
  56671. */
  56672. export interface IWebXRMotionControllerAxesValue {
  56673. /**
  56674. * The value of the x axis
  56675. */
  56676. x: number;
  56677. /**
  56678. * The value of the y-axis
  56679. */
  56680. y: number;
  56681. }
  56682. /**
  56683. * changed / previous values for the values of this component
  56684. */
  56685. export interface IWebXRMotionControllerComponentChangesValues<T> {
  56686. /**
  56687. * current (this frame) value
  56688. */
  56689. current: T;
  56690. /**
  56691. * previous (last change) value
  56692. */
  56693. previous: T;
  56694. }
  56695. /**
  56696. * Represents changes in the component between current frame and last values recorded
  56697. */
  56698. export interface IWebXRMotionControllerComponentChanges {
  56699. /**
  56700. * will be populated with previous and current values if axes changed
  56701. */
  56702. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  56703. /**
  56704. * will be populated with previous and current values if pressed changed
  56705. */
  56706. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  56707. /**
  56708. * will be populated with previous and current values if touched changed
  56709. */
  56710. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  56711. /**
  56712. * will be populated with previous and current values if value changed
  56713. */
  56714. value?: IWebXRMotionControllerComponentChangesValues<number>;
  56715. }
  56716. /**
  56717. * This class represents a single component (for example button or thumbstick) of a motion controller
  56718. */
  56719. export class WebXRControllerComponent implements IDisposable {
  56720. /**
  56721. * the id of this component
  56722. */
  56723. id: string;
  56724. /**
  56725. * the type of the component
  56726. */
  56727. type: MotionControllerComponentType;
  56728. private _buttonIndex;
  56729. private _axesIndices;
  56730. private _axes;
  56731. private _changes;
  56732. private _currentValue;
  56733. private _hasChanges;
  56734. private _pressed;
  56735. private _touched;
  56736. /**
  56737. * button component type
  56738. */
  56739. static BUTTON_TYPE: MotionControllerComponentType;
  56740. /**
  56741. * squeeze component type
  56742. */
  56743. static SQUEEZE_TYPE: MotionControllerComponentType;
  56744. /**
  56745. * Thumbstick component type
  56746. */
  56747. static THUMBSTICK_TYPE: MotionControllerComponentType;
  56748. /**
  56749. * Touchpad component type
  56750. */
  56751. static TOUCHPAD_TYPE: MotionControllerComponentType;
  56752. /**
  56753. * trigger component type
  56754. */
  56755. static TRIGGER_TYPE: MotionControllerComponentType;
  56756. /**
  56757. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  56758. * the axes data changes
  56759. */
  56760. onAxisValueChangedObservable: Observable<{
  56761. x: number;
  56762. y: number;
  56763. }>;
  56764. /**
  56765. * Observers registered here will be triggered when the state of a button changes
  56766. * State change is either pressed / touched / value
  56767. */
  56768. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  56769. /**
  56770. * Creates a new component for a motion controller.
  56771. * It is created by the motion controller itself
  56772. *
  56773. * @param id the id of this component
  56774. * @param type the type of the component
  56775. * @param _buttonIndex index in the buttons array of the gamepad
  56776. * @param _axesIndices indices of the values in the axes array of the gamepad
  56777. */
  56778. constructor(
  56779. /**
  56780. * the id of this component
  56781. */
  56782. id: string,
  56783. /**
  56784. * the type of the component
  56785. */
  56786. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  56787. /**
  56788. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  56789. */
  56790. get axes(): IWebXRMotionControllerAxesValue;
  56791. /**
  56792. * Get the changes. Elements will be populated only if they changed with their previous and current value
  56793. */
  56794. get changes(): IWebXRMotionControllerComponentChanges;
  56795. /**
  56796. * Return whether or not the component changed the last frame
  56797. */
  56798. get hasChanges(): boolean;
  56799. /**
  56800. * is the button currently pressed
  56801. */
  56802. get pressed(): boolean;
  56803. /**
  56804. * is the button currently touched
  56805. */
  56806. get touched(): boolean;
  56807. /**
  56808. * Get the current value of this component
  56809. */
  56810. get value(): number;
  56811. /**
  56812. * Dispose this component
  56813. */
  56814. dispose(): void;
  56815. /**
  56816. * Are there axes correlating to this component
  56817. * @return true is axes data is available
  56818. */
  56819. isAxes(): boolean;
  56820. /**
  56821. * Is this component a button (hence - pressable)
  56822. * @returns true if can be pressed
  56823. */
  56824. isButton(): boolean;
  56825. /**
  56826. * update this component using the gamepad object it is in. Called on every frame
  56827. * @param nativeController the native gamepad controller object
  56828. */
  56829. update(nativeController: IMinimalMotionControllerObject): void;
  56830. }
  56831. }
  56832. declare module "babylonjs/Loading/sceneLoader" {
  56833. import { Observable } from "babylonjs/Misc/observable";
  56834. import { Nullable } from "babylonjs/types";
  56835. import { Scene } from "babylonjs/scene";
  56836. import { Engine } from "babylonjs/Engines/engine";
  56837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56838. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56839. import { AssetContainer } from "babylonjs/assetContainer";
  56840. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56841. import { Skeleton } from "babylonjs/Bones/skeleton";
  56842. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  56843. import { WebRequest } from "babylonjs/Misc/webRequest";
  56844. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56845. import { Geometry } from "babylonjs/Meshes/geometry";
  56846. import { Light } from "babylonjs/Lights/light";
  56847. /**
  56848. * Type used for the success callback of ImportMesh
  56849. */
  56850. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  56851. /**
  56852. * Interface used for the result of ImportMeshAsync
  56853. */
  56854. export interface ISceneLoaderAsyncResult {
  56855. /**
  56856. * The array of loaded meshes
  56857. */
  56858. readonly meshes: AbstractMesh[];
  56859. /**
  56860. * The array of loaded particle systems
  56861. */
  56862. readonly particleSystems: IParticleSystem[];
  56863. /**
  56864. * The array of loaded skeletons
  56865. */
  56866. readonly skeletons: Skeleton[];
  56867. /**
  56868. * The array of loaded animation groups
  56869. */
  56870. readonly animationGroups: AnimationGroup[];
  56871. /**
  56872. * The array of loaded transform nodes
  56873. */
  56874. readonly transformNodes: TransformNode[];
  56875. /**
  56876. * The array of loaded geometries
  56877. */
  56878. readonly geometries: Geometry[];
  56879. /**
  56880. * The array of loaded lights
  56881. */
  56882. readonly lights: Light[];
  56883. }
  56884. /**
  56885. * Interface used to represent data loading progression
  56886. */
  56887. export interface ISceneLoaderProgressEvent {
  56888. /**
  56889. * Defines if data length to load can be evaluated
  56890. */
  56891. readonly lengthComputable: boolean;
  56892. /**
  56893. * Defines the loaded data length
  56894. */
  56895. readonly loaded: number;
  56896. /**
  56897. * Defines the data length to load
  56898. */
  56899. readonly total: number;
  56900. }
  56901. /**
  56902. * Interface used by SceneLoader plugins to define supported file extensions
  56903. */
  56904. export interface ISceneLoaderPluginExtensions {
  56905. /**
  56906. * Defines the list of supported extensions
  56907. */
  56908. [extension: string]: {
  56909. isBinary: boolean;
  56910. };
  56911. }
  56912. /**
  56913. * Interface used by SceneLoader plugin factory
  56914. */
  56915. export interface ISceneLoaderPluginFactory {
  56916. /**
  56917. * Defines the name of the factory
  56918. */
  56919. name: string;
  56920. /**
  56921. * Function called to create a new plugin
  56922. * @return the new plugin
  56923. */
  56924. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  56925. /**
  56926. * The callback that returns true if the data can be directly loaded.
  56927. * @param data string containing the file data
  56928. * @returns if the data can be loaded directly
  56929. */
  56930. canDirectLoad?(data: string): boolean;
  56931. }
  56932. /**
  56933. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  56934. */
  56935. export interface ISceneLoaderPluginBase {
  56936. /**
  56937. * The friendly name of this plugin.
  56938. */
  56939. name: string;
  56940. /**
  56941. * The file extensions supported by this plugin.
  56942. */
  56943. extensions: string | ISceneLoaderPluginExtensions;
  56944. /**
  56945. * The callback called when loading from a url.
  56946. * @param scene scene loading this url
  56947. * @param url url to load
  56948. * @param onSuccess callback called when the file successfully loads
  56949. * @param onProgress callback called while file is loading (if the server supports this mode)
  56950. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  56951. * @param onError callback called when the file fails to load
  56952. * @returns a file request object
  56953. */
  56954. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56955. /**
  56956. * The callback called when loading from a file object.
  56957. * @param scene scene loading this file
  56958. * @param file defines the file to load
  56959. * @param onSuccess defines the callback to call when data is loaded
  56960. * @param onProgress defines the callback to call during loading process
  56961. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  56962. * @param onError defines the callback to call when an error occurs
  56963. * @returns a file request object
  56964. */
  56965. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56966. /**
  56967. * The callback that returns true if the data can be directly loaded.
  56968. * @param data string containing the file data
  56969. * @returns if the data can be loaded directly
  56970. */
  56971. canDirectLoad?(data: string): boolean;
  56972. /**
  56973. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  56974. * @param scene scene loading this data
  56975. * @param data string containing the data
  56976. * @returns data to pass to the plugin
  56977. */
  56978. directLoad?(scene: Scene, data: string): any;
  56979. /**
  56980. * The callback that allows custom handling of the root url based on the response url.
  56981. * @param rootUrl the original root url
  56982. * @param responseURL the response url if available
  56983. * @returns the new root url
  56984. */
  56985. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  56986. }
  56987. /**
  56988. * Interface used to define a SceneLoader plugin
  56989. */
  56990. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  56991. /**
  56992. * Import meshes into a scene.
  56993. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56994. * @param scene The scene to import into
  56995. * @param data The data to import
  56996. * @param rootUrl The root url for scene and resources
  56997. * @param meshes The meshes array to import into
  56998. * @param particleSystems The particle systems array to import into
  56999. * @param skeletons The skeletons array to import into
  57000. * @param onError The callback when import fails
  57001. * @returns True if successful or false otherwise
  57002. */
  57003. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  57004. /**
  57005. * Load into a scene.
  57006. * @param scene The scene to load into
  57007. * @param data The data to import
  57008. * @param rootUrl The root url for scene and resources
  57009. * @param onError The callback when import fails
  57010. * @returns True if successful or false otherwise
  57011. */
  57012. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  57013. /**
  57014. * Load into an asset container.
  57015. * @param scene The scene to load into
  57016. * @param data The data to import
  57017. * @param rootUrl The root url for scene and resources
  57018. * @param onError The callback when import fails
  57019. * @returns The loaded asset container
  57020. */
  57021. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  57022. }
  57023. /**
  57024. * Interface used to define an async SceneLoader plugin
  57025. */
  57026. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  57027. /**
  57028. * Import meshes into a scene.
  57029. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  57030. * @param scene The scene to import into
  57031. * @param data The data to import
  57032. * @param rootUrl The root url for scene and resources
  57033. * @param onProgress The callback when the load progresses
  57034. * @param fileName Defines the name of the file to load
  57035. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  57036. */
  57037. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  57038. /**
  57039. * Load into a scene.
  57040. * @param scene The scene to load into
  57041. * @param data The data to import
  57042. * @param rootUrl The root url for scene and resources
  57043. * @param onProgress The callback when the load progresses
  57044. * @param fileName Defines the name of the file to load
  57045. * @returns Nothing
  57046. */
  57047. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  57048. /**
  57049. * Load into an asset container.
  57050. * @param scene The scene to load into
  57051. * @param data The data to import
  57052. * @param rootUrl The root url for scene and resources
  57053. * @param onProgress The callback when the load progresses
  57054. * @param fileName Defines the name of the file to load
  57055. * @returns The loaded asset container
  57056. */
  57057. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  57058. }
  57059. /**
  57060. * Mode that determines how to handle old animation groups before loading new ones.
  57061. */
  57062. export enum SceneLoaderAnimationGroupLoadingMode {
  57063. /**
  57064. * Reset all old animations to initial state then dispose them.
  57065. */
  57066. Clean = 0,
  57067. /**
  57068. * Stop all old animations.
  57069. */
  57070. Stop = 1,
  57071. /**
  57072. * Restart old animations from first frame.
  57073. */
  57074. Sync = 2,
  57075. /**
  57076. * Old animations remains untouched.
  57077. */
  57078. NoSync = 3
  57079. }
  57080. /**
  57081. * Defines a plugin registered by the SceneLoader
  57082. */
  57083. interface IRegisteredPlugin {
  57084. /**
  57085. * Defines the plugin to use
  57086. */
  57087. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  57088. /**
  57089. * Defines if the plugin supports binary data
  57090. */
  57091. isBinary: boolean;
  57092. }
  57093. /**
  57094. * Class used to load scene from various file formats using registered plugins
  57095. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  57096. */
  57097. export class SceneLoader {
  57098. /**
  57099. * No logging while loading
  57100. */
  57101. static readonly NO_LOGGING: number;
  57102. /**
  57103. * Minimal logging while loading
  57104. */
  57105. static readonly MINIMAL_LOGGING: number;
  57106. /**
  57107. * Summary logging while loading
  57108. */
  57109. static readonly SUMMARY_LOGGING: number;
  57110. /**
  57111. * Detailed logging while loading
  57112. */
  57113. static readonly DETAILED_LOGGING: number;
  57114. /**
  57115. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  57116. */
  57117. static get ForceFullSceneLoadingForIncremental(): boolean;
  57118. static set ForceFullSceneLoadingForIncremental(value: boolean);
  57119. /**
  57120. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  57121. */
  57122. static get ShowLoadingScreen(): boolean;
  57123. static set ShowLoadingScreen(value: boolean);
  57124. /**
  57125. * Defines the current logging level (while loading the scene)
  57126. * @ignorenaming
  57127. */
  57128. static get loggingLevel(): number;
  57129. static set loggingLevel(value: number);
  57130. /**
  57131. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  57132. */
  57133. static get CleanBoneMatrixWeights(): boolean;
  57134. static set CleanBoneMatrixWeights(value: boolean);
  57135. /**
  57136. * Event raised when a plugin is used to load a scene
  57137. */
  57138. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  57139. private static _registeredPlugins;
  57140. private static _showingLoadingScreen;
  57141. /**
  57142. * Gets the default plugin (used to load Babylon files)
  57143. * @returns the .babylon plugin
  57144. */
  57145. static GetDefaultPlugin(): IRegisteredPlugin;
  57146. private static _GetPluginForExtension;
  57147. private static _GetPluginForDirectLoad;
  57148. private static _GetPluginForFilename;
  57149. private static _GetDirectLoad;
  57150. private static _LoadData;
  57151. private static _GetFileInfo;
  57152. /**
  57153. * Gets a plugin that can load the given extension
  57154. * @param extension defines the extension to load
  57155. * @returns a plugin or null if none works
  57156. */
  57157. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  57158. /**
  57159. * Gets a boolean indicating that the given extension can be loaded
  57160. * @param extension defines the extension to load
  57161. * @returns true if the extension is supported
  57162. */
  57163. static IsPluginForExtensionAvailable(extension: string): boolean;
  57164. /**
  57165. * Adds a new plugin to the list of registered plugins
  57166. * @param plugin defines the plugin to add
  57167. */
  57168. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  57169. /**
  57170. * Import meshes into a scene
  57171. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  57172. * @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)
  57173. * @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)
  57174. * @param scene the instance of BABYLON.Scene to append to
  57175. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  57176. * @param onProgress a callback with a progress event for each file being loaded
  57177. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  57178. * @param pluginExtension the extension used to determine the plugin
  57179. * @returns The loaded plugin
  57180. */
  57181. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  57182. /**
  57183. * Import meshes into a scene
  57184. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  57185. * @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)
  57186. * @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)
  57187. * @param scene the instance of BABYLON.Scene to append to
  57188. * @param onProgress a callback with a progress event for each file being loaded
  57189. * @param pluginExtension the extension used to determine the plugin
  57190. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  57191. */
  57192. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  57193. /**
  57194. * Load a scene
  57195. * @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)
  57196. * @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)
  57197. * @param engine is the instance of BABYLON.Engine to use to create the scene
  57198. * @param onSuccess a callback with the scene when import succeeds
  57199. * @param onProgress a callback with a progress event for each file being loaded
  57200. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  57201. * @param pluginExtension the extension used to determine the plugin
  57202. * @returns The loaded plugin
  57203. */
  57204. 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>;
  57205. /**
  57206. * Load a scene
  57207. * @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)
  57208. * @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)
  57209. * @param engine is the instance of BABYLON.Engine to use to create the scene
  57210. * @param onProgress a callback with a progress event for each file being loaded
  57211. * @param pluginExtension the extension used to determine the plugin
  57212. * @returns The loaded scene
  57213. */
  57214. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  57215. /**
  57216. * Append a scene
  57217. * @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)
  57218. * @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)
  57219. * @param scene is the instance of BABYLON.Scene to append to
  57220. * @param onSuccess a callback with the scene when import succeeds
  57221. * @param onProgress a callback with a progress event for each file being loaded
  57222. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  57223. * @param pluginExtension the extension used to determine the plugin
  57224. * @returns The loaded plugin
  57225. */
  57226. 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>;
  57227. /**
  57228. * Append a scene
  57229. * @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)
  57230. * @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)
  57231. * @param scene is the instance of BABYLON.Scene to append to
  57232. * @param onProgress a callback with a progress event for each file being loaded
  57233. * @param pluginExtension the extension used to determine the plugin
  57234. * @returns The given scene
  57235. */
  57236. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  57237. /**
  57238. * Load a scene into an asset container
  57239. * @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)
  57240. * @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)
  57241. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  57242. * @param onSuccess a callback with the scene when import succeeds
  57243. * @param onProgress a callback with a progress event for each file being loaded
  57244. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  57245. * @param pluginExtension the extension used to determine the plugin
  57246. * @returns The loaded plugin
  57247. */
  57248. 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>;
  57249. /**
  57250. * Load a scene into an asset container
  57251. * @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)
  57252. * @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)
  57253. * @param scene is the instance of Scene to append to
  57254. * @param onProgress a callback with a progress event for each file being loaded
  57255. * @param pluginExtension the extension used to determine the plugin
  57256. * @returns The loaded asset container
  57257. */
  57258. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  57259. /**
  57260. * Import animations from a file into a scene
  57261. * @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)
  57262. * @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)
  57263. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  57264. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  57265. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  57266. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  57267. * @param onSuccess a callback with the scene when import succeeds
  57268. * @param onProgress a callback with a progress event for each file being loaded
  57269. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  57270. * @param pluginExtension the extension used to determine the plugin
  57271. */
  57272. 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;
  57273. /**
  57274. * Import animations from a file into a scene
  57275. * @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)
  57276. * @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)
  57277. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  57278. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  57279. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  57280. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  57281. * @param onSuccess a callback with the scene when import succeeds
  57282. * @param onProgress a callback with a progress event for each file being loaded
  57283. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  57284. * @param pluginExtension the extension used to determine the plugin
  57285. * @returns the updated scene with imported animations
  57286. */
  57287. 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>;
  57288. }
  57289. }
  57290. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  57291. import { IDisposable, Scene } from "babylonjs/scene";
  57292. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  57293. import { Observable } from "babylonjs/Misc/observable";
  57294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57295. import { Nullable } from "babylonjs/types";
  57296. /**
  57297. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  57298. */
  57299. export type MotionControllerHandedness = "none" | "left" | "right";
  57300. /**
  57301. * The type of components available in motion controllers.
  57302. * This is not the name of the component.
  57303. */
  57304. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  57305. /**
  57306. * The state of a controller component
  57307. */
  57308. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  57309. /**
  57310. * The schema of motion controller layout.
  57311. * No object will be initialized using this interface
  57312. * This is used just to define the profile.
  57313. */
  57314. export interface IMotionControllerLayout {
  57315. /**
  57316. * Path to load the assets. Usually relative to the base path
  57317. */
  57318. assetPath: string;
  57319. /**
  57320. * Available components (unsorted)
  57321. */
  57322. components: {
  57323. /**
  57324. * A map of component Ids
  57325. */
  57326. [componentId: string]: {
  57327. /**
  57328. * The type of input the component outputs
  57329. */
  57330. type: MotionControllerComponentType;
  57331. /**
  57332. * The indices of this component in the gamepad object
  57333. */
  57334. gamepadIndices: {
  57335. /**
  57336. * Index of button
  57337. */
  57338. button?: number;
  57339. /**
  57340. * If available, index of x-axis
  57341. */
  57342. xAxis?: number;
  57343. /**
  57344. * If available, index of y-axis
  57345. */
  57346. yAxis?: number;
  57347. };
  57348. /**
  57349. * The mesh's root node name
  57350. */
  57351. rootNodeName: string;
  57352. /**
  57353. * Animation definitions for this model
  57354. */
  57355. visualResponses: {
  57356. [stateKey: string]: {
  57357. /**
  57358. * What property will be animated
  57359. */
  57360. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  57361. /**
  57362. * What states influence this visual response
  57363. */
  57364. states: MotionControllerComponentStateType[];
  57365. /**
  57366. * Type of animation - movement or visibility
  57367. */
  57368. valueNodeProperty: "transform" | "visibility";
  57369. /**
  57370. * Base node name to move. Its position will be calculated according to the min and max nodes
  57371. */
  57372. valueNodeName?: string;
  57373. /**
  57374. * Minimum movement node
  57375. */
  57376. minNodeName?: string;
  57377. /**
  57378. * Max movement node
  57379. */
  57380. maxNodeName?: string;
  57381. };
  57382. };
  57383. /**
  57384. * If touch enabled, what is the name of node to display user feedback
  57385. */
  57386. touchPointNodeName?: string;
  57387. };
  57388. };
  57389. /**
  57390. * Is it xr standard mapping or not
  57391. */
  57392. gamepadMapping: "" | "xr-standard";
  57393. /**
  57394. * Base root node of this entire model
  57395. */
  57396. rootNodeName: string;
  57397. /**
  57398. * Defines the main button component id
  57399. */
  57400. selectComponentId: string;
  57401. }
  57402. /**
  57403. * A definition for the layout map in the input profile
  57404. */
  57405. export interface IMotionControllerLayoutMap {
  57406. /**
  57407. * Layouts with handedness type as a key
  57408. */
  57409. [handedness: string]: IMotionControllerLayout;
  57410. }
  57411. /**
  57412. * The XR Input profile schema
  57413. * Profiles can be found here:
  57414. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  57415. */
  57416. export interface IMotionControllerProfile {
  57417. /**
  57418. * fallback profiles for this profileId
  57419. */
  57420. fallbackProfileIds: string[];
  57421. /**
  57422. * The layout map, with handedness as key
  57423. */
  57424. layouts: IMotionControllerLayoutMap;
  57425. /**
  57426. * The id of this profile
  57427. * correlates to the profile(s) in the xrInput.profiles array
  57428. */
  57429. profileId: string;
  57430. }
  57431. /**
  57432. * A helper-interface for the 3 meshes needed for controller button animation
  57433. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  57434. */
  57435. export interface IMotionControllerButtonMeshMap {
  57436. /**
  57437. * the mesh that defines the pressed value mesh position.
  57438. * This is used to find the max-position of this button
  57439. */
  57440. pressedMesh: AbstractMesh;
  57441. /**
  57442. * the mesh that defines the unpressed value mesh position.
  57443. * This is used to find the min (or initial) position of this button
  57444. */
  57445. unpressedMesh: AbstractMesh;
  57446. /**
  57447. * The mesh that will be changed when value changes
  57448. */
  57449. valueMesh: AbstractMesh;
  57450. }
  57451. /**
  57452. * A helper-interface for the 3 meshes needed for controller axis animation.
  57453. * This will be expanded when touchpad animations are fully supported
  57454. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  57455. */
  57456. export interface IMotionControllerMeshMap {
  57457. /**
  57458. * the mesh that defines the maximum value mesh position.
  57459. */
  57460. maxMesh?: AbstractMesh;
  57461. /**
  57462. * the mesh that defines the minimum value mesh position.
  57463. */
  57464. minMesh?: AbstractMesh;
  57465. /**
  57466. * The mesh that will be changed when axis value changes
  57467. */
  57468. valueMesh?: AbstractMesh;
  57469. }
  57470. /**
  57471. * The elements needed for change-detection of the gamepad objects in motion controllers
  57472. */
  57473. export interface IMinimalMotionControllerObject {
  57474. /**
  57475. * Available axes of this controller
  57476. */
  57477. axes: number[];
  57478. /**
  57479. * An array of available buttons
  57480. */
  57481. buttons: Array<{
  57482. /**
  57483. * Value of the button/trigger
  57484. */
  57485. value: number;
  57486. /**
  57487. * If the button/trigger is currently touched
  57488. */
  57489. touched: boolean;
  57490. /**
  57491. * If the button/trigger is currently pressed
  57492. */
  57493. pressed: boolean;
  57494. }>;
  57495. /**
  57496. * EXPERIMENTAL haptic support.
  57497. */
  57498. hapticActuators?: Array<{
  57499. pulse: (value: number, duration: number) => Promise<boolean>;
  57500. }>;
  57501. }
  57502. /**
  57503. * An Abstract Motion controller
  57504. * This class receives an xrInput and a profile layout and uses those to initialize the components
  57505. * Each component has an observable to check for changes in value and state
  57506. */
  57507. export abstract class WebXRAbstractMotionController implements IDisposable {
  57508. protected scene: Scene;
  57509. protected layout: IMotionControllerLayout;
  57510. /**
  57511. * The gamepad object correlating to this controller
  57512. */
  57513. gamepadObject: IMinimalMotionControllerObject;
  57514. /**
  57515. * handedness (left/right/none) of this controller
  57516. */
  57517. handedness: MotionControllerHandedness;
  57518. private _initComponent;
  57519. private _modelReady;
  57520. /**
  57521. * A map of components (WebXRControllerComponent) in this motion controller
  57522. * Components have a ComponentType and can also have both button and axis definitions
  57523. */
  57524. readonly components: {
  57525. [id: string]: WebXRControllerComponent;
  57526. };
  57527. /**
  57528. * Disable the model's animation. Can be set at any time.
  57529. */
  57530. disableAnimation: boolean;
  57531. /**
  57532. * Observers registered here will be triggered when the model of this controller is done loading
  57533. */
  57534. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  57535. /**
  57536. * The profile id of this motion controller
  57537. */
  57538. abstract profileId: string;
  57539. /**
  57540. * The root mesh of the model. It is null if the model was not yet initialized
  57541. */
  57542. rootMesh: Nullable<AbstractMesh>;
  57543. /**
  57544. * constructs a new abstract motion controller
  57545. * @param scene the scene to which the model of the controller will be added
  57546. * @param layout The profile layout to load
  57547. * @param gamepadObject The gamepad object correlating to this controller
  57548. * @param handedness handedness (left/right/none) of this controller
  57549. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  57550. */
  57551. constructor(scene: Scene, layout: IMotionControllerLayout,
  57552. /**
  57553. * The gamepad object correlating to this controller
  57554. */
  57555. gamepadObject: IMinimalMotionControllerObject,
  57556. /**
  57557. * handedness (left/right/none) of this controller
  57558. */
  57559. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  57560. /**
  57561. * Dispose this controller, the model mesh and all its components
  57562. */
  57563. dispose(): void;
  57564. /**
  57565. * Returns all components of specific type
  57566. * @param type the type to search for
  57567. * @return an array of components with this type
  57568. */
  57569. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  57570. /**
  57571. * get a component based an its component id as defined in layout.components
  57572. * @param id the id of the component
  57573. * @returns the component correlates to the id or undefined if not found
  57574. */
  57575. getComponent(id: string): WebXRControllerComponent;
  57576. /**
  57577. * Get the list of components available in this motion controller
  57578. * @returns an array of strings correlating to available components
  57579. */
  57580. getComponentIds(): string[];
  57581. /**
  57582. * Get the first component of specific type
  57583. * @param type type of component to find
  57584. * @return a controller component or null if not found
  57585. */
  57586. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  57587. /**
  57588. * Get the main (Select) component of this controller as defined in the layout
  57589. * @returns the main component of this controller
  57590. */
  57591. getMainComponent(): WebXRControllerComponent;
  57592. /**
  57593. * Loads the model correlating to this controller
  57594. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  57595. * @returns A promise fulfilled with the result of the model loading
  57596. */
  57597. loadModel(): Promise<boolean>;
  57598. /**
  57599. * Update this model using the current XRFrame
  57600. * @param xrFrame the current xr frame to use and update the model
  57601. */
  57602. updateFromXRFrame(xrFrame: XRFrame): void;
  57603. /**
  57604. * Backwards compatibility due to a deeply-integrated typo
  57605. */
  57606. get handness(): XREye;
  57607. /**
  57608. * Pulse (vibrate) this controller
  57609. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  57610. * Consecutive calls to this function will cancel the last pulse call
  57611. *
  57612. * @param value the strength of the pulse in 0.0...1.0 range
  57613. * @param duration Duration of the pulse in milliseconds
  57614. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  57615. * @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
  57616. */
  57617. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  57618. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  57619. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  57620. /**
  57621. * Moves the axis on the controller mesh based on its current state
  57622. * @param axis the index of the axis
  57623. * @param axisValue the value of the axis which determines the meshes new position
  57624. * @hidden
  57625. */
  57626. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  57627. /**
  57628. * Update the model itself with the current frame data
  57629. * @param xrFrame the frame to use for updating the model mesh
  57630. */
  57631. protected updateModel(xrFrame: XRFrame): void;
  57632. /**
  57633. * Get the filename and path for this controller's model
  57634. * @returns a map of filename and path
  57635. */
  57636. protected abstract _getFilenameAndPath(): {
  57637. filename: string;
  57638. path: string;
  57639. };
  57640. /**
  57641. * This function is called before the mesh is loaded. It checks for loading constraints.
  57642. * For example, this function can check if the GLB loader is available
  57643. * If this function returns false, the generic controller will be loaded instead
  57644. * @returns Is the client ready to load the mesh
  57645. */
  57646. protected abstract _getModelLoadingConstraints(): boolean;
  57647. /**
  57648. * This function will be called after the model was successfully loaded and can be used
  57649. * for mesh transformations before it is available for the user
  57650. * @param meshes the loaded meshes
  57651. */
  57652. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  57653. /**
  57654. * Set the root mesh for this controller. Important for the WebXR controller class
  57655. * @param meshes the loaded meshes
  57656. */
  57657. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  57658. /**
  57659. * A function executed each frame that updates the mesh (if needed)
  57660. * @param xrFrame the current xrFrame
  57661. */
  57662. protected abstract _updateModel(xrFrame: XRFrame): void;
  57663. private _getGenericFilenameAndPath;
  57664. private _getGenericParentMesh;
  57665. }
  57666. }
  57667. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  57668. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57670. import { Scene } from "babylonjs/scene";
  57671. /**
  57672. * A generic trigger-only motion controller for WebXR
  57673. */
  57674. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  57675. /**
  57676. * Static version of the profile id of this controller
  57677. */
  57678. static ProfileId: string;
  57679. profileId: string;
  57680. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  57681. protected _getFilenameAndPath(): {
  57682. filename: string;
  57683. path: string;
  57684. };
  57685. protected _getModelLoadingConstraints(): boolean;
  57686. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  57687. protected _setRootMesh(meshes: AbstractMesh[]): void;
  57688. protected _updateModel(): void;
  57689. }
  57690. }
  57691. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  57692. import { Vector4 } from "babylonjs/Maths/math.vector";
  57693. import { Mesh } from "babylonjs/Meshes/mesh";
  57694. import { Scene } from "babylonjs/scene";
  57695. import { Nullable } from "babylonjs/types";
  57696. /**
  57697. * Class containing static functions to help procedurally build meshes
  57698. */
  57699. export class SphereBuilder {
  57700. /**
  57701. * Creates a sphere mesh
  57702. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57703. * * 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`)
  57704. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57705. * * 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
  57706. * * 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)
  57707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57710. * @param name defines the name of the mesh
  57711. * @param options defines the options used to create the mesh
  57712. * @param scene defines the hosting scene
  57713. * @returns the sphere mesh
  57714. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57715. */
  57716. static CreateSphere(name: string, options: {
  57717. segments?: number;
  57718. diameter?: number;
  57719. diameterX?: number;
  57720. diameterY?: number;
  57721. diameterZ?: number;
  57722. arc?: number;
  57723. slice?: number;
  57724. sideOrientation?: number;
  57725. frontUVs?: Vector4;
  57726. backUVs?: Vector4;
  57727. updatable?: boolean;
  57728. }, scene?: Nullable<Scene>): Mesh;
  57729. }
  57730. }
  57731. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  57732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57733. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57734. import { Scene } from "babylonjs/scene";
  57735. /**
  57736. * A profiled motion controller has its profile loaded from an online repository.
  57737. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  57738. */
  57739. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  57740. private _repositoryUrl;
  57741. private _buttonMeshMapping;
  57742. private _touchDots;
  57743. /**
  57744. * The profile ID of this controller. Will be populated when the controller initializes.
  57745. */
  57746. profileId: string;
  57747. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  57748. dispose(): void;
  57749. protected _getFilenameAndPath(): {
  57750. filename: string;
  57751. path: string;
  57752. };
  57753. protected _getModelLoadingConstraints(): boolean;
  57754. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  57755. protected _setRootMesh(meshes: AbstractMesh[]): void;
  57756. protected _updateModel(_xrFrame: XRFrame): void;
  57757. }
  57758. }
  57759. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  57760. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57761. import { Scene } from "babylonjs/scene";
  57762. /**
  57763. * A construction function type to create a new controller based on an xrInput object
  57764. */
  57765. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  57766. /**
  57767. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  57768. *
  57769. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  57770. * it should be replaced with auto-loaded controllers.
  57771. *
  57772. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  57773. */
  57774. export class WebXRMotionControllerManager {
  57775. private static _AvailableControllers;
  57776. private static _Fallbacks;
  57777. private static _ProfileLoadingPromises;
  57778. private static _ProfilesList;
  57779. /**
  57780. * The base URL of the online controller repository. Can be changed at any time.
  57781. */
  57782. static BaseRepositoryUrl: string;
  57783. /**
  57784. * Which repository gets priority - local or online
  57785. */
  57786. static PrioritizeOnlineRepository: boolean;
  57787. /**
  57788. * Use the online repository, or use only locally-defined controllers
  57789. */
  57790. static UseOnlineRepository: boolean;
  57791. /**
  57792. * Clear the cache used for profile loading and reload when requested again
  57793. */
  57794. static ClearProfilesCache(): void;
  57795. /**
  57796. * Register the default fallbacks.
  57797. * This function is called automatically when this file is imported.
  57798. */
  57799. static DefaultFallbacks(): void;
  57800. /**
  57801. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  57802. * @param profileId the profile to which a fallback needs to be found
  57803. * @return an array with corresponding fallback profiles
  57804. */
  57805. static FindFallbackWithProfileId(profileId: string): string[];
  57806. /**
  57807. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  57808. * The order of search:
  57809. *
  57810. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  57811. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  57812. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  57813. * 4) return the generic trigger controller if none were found
  57814. *
  57815. * @param xrInput the xrInput to which a new controller is initialized
  57816. * @param scene the scene to which the model will be added
  57817. * @param forceProfile force a certain profile for this controller
  57818. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  57819. */
  57820. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  57821. /**
  57822. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  57823. *
  57824. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  57825. *
  57826. * @param type the profile type to register
  57827. * @param constructFunction the function to be called when loading this profile
  57828. */
  57829. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  57830. /**
  57831. * Register a fallback to a specific profile.
  57832. * @param profileId the profileId that will receive the fallbacks
  57833. * @param fallbacks A list of fallback profiles
  57834. */
  57835. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  57836. /**
  57837. * Will update the list of profiles available in the repository
  57838. * @return a promise that resolves to a map of profiles available online
  57839. */
  57840. static UpdateProfilesList(): Promise<{
  57841. [profile: string]: string;
  57842. }>;
  57843. private static _LoadProfileFromRepository;
  57844. private static _LoadProfilesFromAvailableControllers;
  57845. }
  57846. }
  57847. declare module "babylonjs/XR/webXRInputSource" {
  57848. import { Observable } from "babylonjs/Misc/observable";
  57849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57850. import { Ray } from "babylonjs/Culling/ray";
  57851. import { Scene } from "babylonjs/scene";
  57852. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57853. /**
  57854. * Configuration options for the WebXR controller creation
  57855. */
  57856. export interface IWebXRControllerOptions {
  57857. /**
  57858. * Should the controller mesh be animated when a user interacts with it
  57859. * The pressed buttons / thumbstick and touchpad animations will be disabled
  57860. */
  57861. disableMotionControllerAnimation?: boolean;
  57862. /**
  57863. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  57864. */
  57865. doNotLoadControllerMesh?: boolean;
  57866. /**
  57867. * Force a specific controller type for this controller.
  57868. * This can be used when creating your own profile or when testing different controllers
  57869. */
  57870. forceControllerProfile?: string;
  57871. /**
  57872. * Defines a rendering group ID for meshes that will be loaded.
  57873. * This is for the default controllers only.
  57874. */
  57875. renderingGroupId?: number;
  57876. }
  57877. /**
  57878. * Represents an XR controller
  57879. */
  57880. export class WebXRInputSource {
  57881. private _scene;
  57882. /** The underlying input source for the controller */
  57883. inputSource: XRInputSource;
  57884. private _options;
  57885. private _tmpVector;
  57886. private _uniqueId;
  57887. private _disposed;
  57888. /**
  57889. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if that's the case only the pointer from the head will be available
  57890. */
  57891. grip?: AbstractMesh;
  57892. /**
  57893. * If available, this is the gamepad object related to this controller.
  57894. * Using this object it is possible to get click events and trackpad changes of the
  57895. * webxr controller that is currently being used.
  57896. */
  57897. motionController?: WebXRAbstractMotionController;
  57898. /**
  57899. * Event that fires when the controller is removed/disposed.
  57900. * The object provided as event data is this controller, after associated assets were disposed.
  57901. * uniqueId is still available.
  57902. */
  57903. onDisposeObservable: Observable<WebXRInputSource>;
  57904. /**
  57905. * Will be triggered when the mesh associated with the motion controller is done loading.
  57906. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  57907. * A shortened version of controller -> motion controller -> on mesh loaded.
  57908. */
  57909. onMeshLoadedObservable: Observable<AbstractMesh>;
  57910. /**
  57911. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  57912. */
  57913. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  57914. /**
  57915. * Pointer which can be used to select objects or attach a visible laser to
  57916. */
  57917. pointer: AbstractMesh;
  57918. /**
  57919. * Creates the input source object
  57920. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  57921. * @param _scene the scene which the controller should be associated to
  57922. * @param inputSource the underlying input source for the controller
  57923. * @param _options options for this controller creation
  57924. */
  57925. constructor(_scene: Scene,
  57926. /** The underlying input source for the controller */
  57927. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  57928. /**
  57929. * Get this controllers unique id
  57930. */
  57931. get uniqueId(): string;
  57932. /**
  57933. * Disposes of the object
  57934. */
  57935. dispose(): void;
  57936. /**
  57937. * Gets a world space ray coming from the pointer or grip
  57938. * @param result the resulting ray
  57939. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  57940. */
  57941. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  57942. /**
  57943. * Updates the controller pose based on the given XRFrame
  57944. * @param xrFrame xr frame to update the pose with
  57945. * @param referenceSpace reference space to use
  57946. */
  57947. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  57948. }
  57949. }
  57950. declare module "babylonjs/XR/webXRInput" {
  57951. import { Observable } from "babylonjs/Misc/observable";
  57952. import { IDisposable } from "babylonjs/scene";
  57953. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  57954. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57955. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57956. /**
  57957. * The schema for initialization options of the XR Input class
  57958. */
  57959. export interface IWebXRInputOptions {
  57960. /**
  57961. * If set to true no model will be automatically loaded
  57962. */
  57963. doNotLoadControllerMeshes?: boolean;
  57964. /**
  57965. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  57966. * If not found, the xr input profile data will be used.
  57967. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  57968. */
  57969. forceInputProfile?: string;
  57970. /**
  57971. * Do not send a request to the controller repository to load the profile.
  57972. *
  57973. * Instead, use the controllers available in babylon itself.
  57974. */
  57975. disableOnlineControllerRepository?: boolean;
  57976. /**
  57977. * A custom URL for the controllers repository
  57978. */
  57979. customControllersRepositoryURL?: string;
  57980. /**
  57981. * Should the controller model's components not move according to the user input
  57982. */
  57983. disableControllerAnimation?: boolean;
  57984. /**
  57985. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  57986. */
  57987. controllerOptions?: IWebXRControllerOptions;
  57988. }
  57989. /**
  57990. * XR input used to track XR inputs such as controllers/rays
  57991. */
  57992. export class WebXRInput implements IDisposable {
  57993. /**
  57994. * the xr session manager for this session
  57995. */
  57996. xrSessionManager: WebXRSessionManager;
  57997. /**
  57998. * the WebXR camera for this session. Mainly used for teleportation
  57999. */
  58000. xrCamera: WebXRCamera;
  58001. private readonly options;
  58002. /**
  58003. * XR controllers being tracked
  58004. */
  58005. controllers: Array<WebXRInputSource>;
  58006. private _frameObserver;
  58007. private _sessionEndedObserver;
  58008. private _sessionInitObserver;
  58009. /**
  58010. * Event when a controller has been connected/added
  58011. */
  58012. onControllerAddedObservable: Observable<WebXRInputSource>;
  58013. /**
  58014. * Event when a controller has been removed/disconnected
  58015. */
  58016. onControllerRemovedObservable: Observable<WebXRInputSource>;
  58017. /**
  58018. * Initializes the WebXRInput
  58019. * @param xrSessionManager the xr session manager for this session
  58020. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  58021. * @param options = initialization options for this xr input
  58022. */
  58023. constructor(
  58024. /**
  58025. * the xr session manager for this session
  58026. */
  58027. xrSessionManager: WebXRSessionManager,
  58028. /**
  58029. * the WebXR camera for this session. Mainly used for teleportation
  58030. */
  58031. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  58032. private _onInputSourcesChange;
  58033. private _addAndRemoveControllers;
  58034. /**
  58035. * Disposes of the object
  58036. */
  58037. dispose(): void;
  58038. }
  58039. }
  58040. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  58041. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  58042. import { Observable, EventState } from "babylonjs/Misc/observable";
  58043. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  58044. /**
  58045. * This is the base class for all WebXR features.
  58046. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  58047. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  58048. */
  58049. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  58050. protected _xrSessionManager: WebXRSessionManager;
  58051. private _attached;
  58052. private _removeOnDetach;
  58053. /**
  58054. * Is this feature disposed?
  58055. */
  58056. isDisposed: boolean;
  58057. /**
  58058. * Should auto-attach be disabled?
  58059. */
  58060. disableAutoAttach: boolean;
  58061. /**
  58062. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  58063. */
  58064. xrNativeFeatureName: string;
  58065. /**
  58066. * Construct a new (abstract) WebXR feature
  58067. * @param _xrSessionManager the xr session manager for this feature
  58068. */
  58069. constructor(_xrSessionManager: WebXRSessionManager);
  58070. /**
  58071. * Is this feature attached
  58072. */
  58073. get attached(): boolean;
  58074. /**
  58075. * attach this feature
  58076. *
  58077. * @param force should attachment be forced (even when already attached)
  58078. * @returns true if successful, false is failed or already attached
  58079. */
  58080. attach(force?: boolean): boolean;
  58081. /**
  58082. * detach this feature.
  58083. *
  58084. * @returns true if successful, false if failed or already detached
  58085. */
  58086. detach(): boolean;
  58087. /**
  58088. * Dispose this feature and all of the resources attached
  58089. */
  58090. dispose(): void;
  58091. /**
  58092. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  58093. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  58094. *
  58095. * @returns whether or not the feature is compatible in this environment
  58096. */
  58097. isCompatible(): boolean;
  58098. /**
  58099. * This is used to register callbacks that will automatically be removed when detach is called.
  58100. * @param observable the observable to which the observer will be attached
  58101. * @param callback the callback to register
  58102. */
  58103. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  58104. /**
  58105. * Code in this function will be executed on each xrFrame received from the browser.
  58106. * This function will not execute after the feature is detached.
  58107. * @param _xrFrame the current frame
  58108. */
  58109. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  58110. }
  58111. }
  58112. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  58113. import { IDisposable, Scene } from "babylonjs/scene";
  58114. import { Nullable } from "babylonjs/types";
  58115. import { Observable } from "babylonjs/Misc/observable";
  58116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58117. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  58118. import { Camera } from "babylonjs/Cameras/camera";
  58119. /**
  58120. * Renders a layer on top of an existing scene
  58121. */
  58122. export class UtilityLayerRenderer implements IDisposable {
  58123. /** the original scene that will be rendered on top of */
  58124. originalScene: Scene;
  58125. private _pointerCaptures;
  58126. private _lastPointerEvents;
  58127. private static _DefaultUtilityLayer;
  58128. private static _DefaultKeepDepthUtilityLayer;
  58129. private _sharedGizmoLight;
  58130. private _renderCamera;
  58131. /**
  58132. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  58133. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  58134. * @returns the camera that is used when rendering the utility layer
  58135. */
  58136. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  58137. /**
  58138. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  58139. * @param cam the camera that should be used when rendering the utility layer
  58140. */
  58141. setRenderCamera(cam: Nullable<Camera>): void;
  58142. /**
  58143. * @hidden
  58144. * Light which used by gizmos to get light shading
  58145. */
  58146. _getSharedGizmoLight(): HemisphericLight;
  58147. /**
  58148. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  58149. */
  58150. pickUtilitySceneFirst: boolean;
  58151. /**
  58152. * 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)
  58153. */
  58154. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  58155. /**
  58156. * 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)
  58157. */
  58158. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  58159. /**
  58160. * The scene that is rendered on top of the original scene
  58161. */
  58162. utilityLayerScene: Scene;
  58163. /**
  58164. * If the utility layer should automatically be rendered on top of existing scene
  58165. */
  58166. shouldRender: boolean;
  58167. /**
  58168. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  58169. */
  58170. onlyCheckPointerDownEvents: boolean;
  58171. /**
  58172. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  58173. */
  58174. processAllEvents: boolean;
  58175. /**
  58176. * Observable raised when the pointer move from the utility layer scene to the main scene
  58177. */
  58178. onPointerOutObservable: Observable<number>;
  58179. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  58180. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  58181. private _afterRenderObserver;
  58182. private _sceneDisposeObserver;
  58183. private _originalPointerObserver;
  58184. /**
  58185. * Instantiates a UtilityLayerRenderer
  58186. * @param originalScene the original scene that will be rendered on top of
  58187. * @param handleEvents boolean indicating if the utility layer should handle events
  58188. */
  58189. constructor(
  58190. /** the original scene that will be rendered on top of */
  58191. originalScene: Scene, handleEvents?: boolean);
  58192. private _notifyObservers;
  58193. /**
  58194. * Renders the utility layers scene on top of the original scene
  58195. */
  58196. render(): void;
  58197. /**
  58198. * Disposes of the renderer
  58199. */
  58200. dispose(): void;
  58201. private _updateCamera;
  58202. }
  58203. }
  58204. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  58205. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  58206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58207. import { WebXRInput } from "babylonjs/XR/webXRInput";
  58208. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  58209. import { Scene } from "babylonjs/scene";
  58210. import { Nullable } from "babylonjs/types";
  58211. import { Color3 } from "babylonjs/Maths/math.color";
  58212. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  58213. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  58214. /**
  58215. * Options interface for the pointer selection module
  58216. */
  58217. export interface IWebXRControllerPointerSelectionOptions {
  58218. /**
  58219. * if provided, this scene will be used to render meshes.
  58220. */
  58221. customUtilityLayerScene?: Scene;
  58222. /**
  58223. * 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)
  58224. * If not disabled, the last picked point will be used to execute a pointer up event
  58225. * If disabled, pointer up event will be triggered right after the pointer down event.
  58226. * Used in screen and gaze target ray mode only
  58227. */
  58228. disablePointerUpOnTouchOut: boolean;
  58229. /**
  58230. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  58231. */
  58232. forceGazeMode: boolean;
  58233. /**
  58234. * 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
  58235. * to start a new countdown to the pointer down event.
  58236. * Defaults to 1.
  58237. */
  58238. gazeModePointerMovedFactor?: number;
  58239. /**
  58240. * Different button type to use instead of the main component
  58241. */
  58242. overrideButtonId?: string;
  58243. /**
  58244. * use this rendering group id for the meshes (optional)
  58245. */
  58246. renderingGroupId?: number;
  58247. /**
  58248. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  58249. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  58250. * 3000 means 3 seconds between pointing at something and selecting it
  58251. */
  58252. timeToSelect?: number;
  58253. /**
  58254. * Should meshes created here be added to a utility layer or the main scene
  58255. */
  58256. useUtilityLayer?: boolean;
  58257. /**
  58258. * Optional WebXR camera to be used for gaze selection
  58259. */
  58260. gazeCamera?: WebXRCamera;
  58261. /**
  58262. * the xr input to use with this pointer selection
  58263. */
  58264. xrInput: WebXRInput;
  58265. /**
  58266. * Should the scene pointerX and pointerY update be disabled
  58267. * This is required for fullscreen AR GUI, but might slow down other experiences.
  58268. * Disable in VR, if not needed.
  58269. * The first rig camera (left eye) will be used to calculate the projection
  58270. */
  58271. disableScenePointerVectorUpdate: boolean;
  58272. /**
  58273. * Enable pointer selection on all controllers instead of switching between them
  58274. */
  58275. enablePointerSelectionOnAllControllers?: boolean;
  58276. /**
  58277. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  58278. * If switch is enabled, it will still allow the user to switch between the different controllers
  58279. */
  58280. preferredHandedness?: XRHandedness;
  58281. /**
  58282. * Disable switching the pointer selection from one controller to the other.
  58283. * 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
  58284. */
  58285. disableSwitchOnClick?: boolean;
  58286. /**
  58287. * The maximum distance of the pointer selection feature. Defaults to 100.
  58288. */
  58289. maxPointerDistance?: number;
  58290. }
  58291. /**
  58292. * A module that will enable pointer selection for motion controllers of XR Input Sources
  58293. */
  58294. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  58295. private readonly _options;
  58296. private static _idCounter;
  58297. private _attachController;
  58298. private _controllers;
  58299. private _scene;
  58300. private _tmpVectorForPickCompare;
  58301. private _attachedController;
  58302. /**
  58303. * The module's name
  58304. */
  58305. static readonly Name: string;
  58306. /**
  58307. * The (Babylon) version of this module.
  58308. * This is an integer representing the implementation version.
  58309. * This number does not correspond to the WebXR specs version
  58310. */
  58311. static readonly Version: number;
  58312. /**
  58313. * Disable lighting on the laser pointer (so it will always be visible)
  58314. */
  58315. disablePointerLighting: boolean;
  58316. /**
  58317. * Disable lighting on the selection mesh (so it will always be visible)
  58318. */
  58319. disableSelectionMeshLighting: boolean;
  58320. /**
  58321. * Should the laser pointer be displayed
  58322. */
  58323. displayLaserPointer: boolean;
  58324. /**
  58325. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  58326. */
  58327. displaySelectionMesh: boolean;
  58328. /**
  58329. * This color will be set to the laser pointer when selection is triggered
  58330. */
  58331. laserPointerPickedColor: Color3;
  58332. /**
  58333. * Default color of the laser pointer
  58334. */
  58335. laserPointerDefaultColor: Color3;
  58336. /**
  58337. * default color of the selection ring
  58338. */
  58339. selectionMeshDefaultColor: Color3;
  58340. /**
  58341. * This color will be applied to the selection ring when selection is triggered
  58342. */
  58343. selectionMeshPickedColor: Color3;
  58344. /**
  58345. * Optional filter to be used for ray selection. This predicate shares behavior with
  58346. * scene.pointerMovePredicate which takes priority if it is also assigned.
  58347. */
  58348. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  58349. /**
  58350. * constructs a new background remover module
  58351. * @param _xrSessionManager the session manager for this module
  58352. * @param _options read-only options to be used in this module
  58353. */
  58354. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  58355. /**
  58356. * attach this feature
  58357. * Will usually be called by the features manager
  58358. *
  58359. * @returns true if successful.
  58360. */
  58361. attach(): boolean;
  58362. /**
  58363. * detach this feature.
  58364. * Will usually be called by the features manager
  58365. *
  58366. * @returns true if successful.
  58367. */
  58368. detach(): boolean;
  58369. /**
  58370. * Will get the mesh under a specific pointer.
  58371. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  58372. * @param controllerId the controllerId to check
  58373. * @returns The mesh under pointer or null if no mesh is under the pointer
  58374. */
  58375. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  58376. /**
  58377. * Get the xr controller that correlates to the pointer id in the pointer event
  58378. *
  58379. * @param id the pointer id to search for
  58380. * @returns the controller that correlates to this id or null if not found
  58381. */
  58382. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  58383. private _identityMatrix;
  58384. private _screenCoordinatesRef;
  58385. private _viewportRef;
  58386. protected _onXRFrame(_xrFrame: XRFrame): void;
  58387. private _attachGazeMode;
  58388. private _attachScreenRayMode;
  58389. private _attachTrackedPointerRayMode;
  58390. private _convertNormalToDirectionOfRay;
  58391. private _detachController;
  58392. private _generateNewMeshPair;
  58393. private _pickingMoved;
  58394. private _updatePointerDistance;
  58395. /** @hidden */
  58396. get lasterPointerDefaultColor(): Color3;
  58397. }
  58398. }
  58399. declare module "babylonjs/XR/webXREnterExitUI" {
  58400. import { Nullable } from "babylonjs/types";
  58401. import { Observable } from "babylonjs/Misc/observable";
  58402. import { IDisposable, Scene } from "babylonjs/scene";
  58403. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  58404. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  58405. /**
  58406. * Button which can be used to enter a different mode of XR
  58407. */
  58408. export class WebXREnterExitUIButton {
  58409. /** button element */
  58410. element: HTMLElement;
  58411. /** XR initialization options for the button */
  58412. sessionMode: XRSessionMode;
  58413. /** Reference space type */
  58414. referenceSpaceType: XRReferenceSpaceType;
  58415. /**
  58416. * Creates a WebXREnterExitUIButton
  58417. * @param element button element
  58418. * @param sessionMode XR initialization session mode
  58419. * @param referenceSpaceType the type of reference space to be used
  58420. */
  58421. constructor(
  58422. /** button element */
  58423. element: HTMLElement,
  58424. /** XR initialization options for the button */
  58425. sessionMode: XRSessionMode,
  58426. /** Reference space type */
  58427. referenceSpaceType: XRReferenceSpaceType);
  58428. /**
  58429. * Extendable function which can be used to update the button's visuals when the state changes
  58430. * @param activeButton the current active button in the UI
  58431. */
  58432. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  58433. }
  58434. /**
  58435. * Options to create the webXR UI
  58436. */
  58437. export class WebXREnterExitUIOptions {
  58438. /**
  58439. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  58440. */
  58441. customButtons?: Array<WebXREnterExitUIButton>;
  58442. /**
  58443. * A reference space type to use when creating the default button.
  58444. * Default is local-floor
  58445. */
  58446. referenceSpaceType?: XRReferenceSpaceType;
  58447. /**
  58448. * Context to enter xr with
  58449. */
  58450. renderTarget?: Nullable<WebXRRenderTarget>;
  58451. /**
  58452. * A session mode to use when creating the default button.
  58453. * Default is immersive-vr
  58454. */
  58455. sessionMode?: XRSessionMode;
  58456. /**
  58457. * A list of optional features to init the session with
  58458. */
  58459. optionalFeatures?: string[];
  58460. /**
  58461. * A list of optional features to init the session with
  58462. */
  58463. requiredFeatures?: string[];
  58464. /**
  58465. * If defined, this function will be executed if the UI encounters an error when entering XR
  58466. */
  58467. onError?: (error: any) => void;
  58468. }
  58469. /**
  58470. * UI to allow the user to enter/exit XR mode
  58471. */
  58472. export class WebXREnterExitUI implements IDisposable {
  58473. private scene;
  58474. /** version of the options passed to this UI */
  58475. options: WebXREnterExitUIOptions;
  58476. private _activeButton;
  58477. private _buttons;
  58478. /**
  58479. * The HTML Div Element to which buttons are added.
  58480. */
  58481. readonly overlay: HTMLDivElement;
  58482. /**
  58483. * Fired every time the active button is changed.
  58484. *
  58485. * When xr is entered via a button that launches xr that button will be the callback parameter
  58486. *
  58487. * When exiting xr the callback parameter will be null)
  58488. */
  58489. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  58490. /**
  58491. *
  58492. * @param scene babylon scene object to use
  58493. * @param options (read-only) version of the options passed to this UI
  58494. */
  58495. private constructor();
  58496. /**
  58497. * Creates UI to allow the user to enter/exit XR mode
  58498. * @param scene the scene to add the ui to
  58499. * @param helper the xr experience helper to enter/exit xr with
  58500. * @param options options to configure the UI
  58501. * @returns the created ui
  58502. */
  58503. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  58504. /**
  58505. * Disposes of the XR UI component
  58506. */
  58507. dispose(): void;
  58508. private _updateButtons;
  58509. }
  58510. }
  58511. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  58512. import { Vector3 } from "babylonjs/Maths/math.vector";
  58513. import { Color4 } from "babylonjs/Maths/math.color";
  58514. import { Nullable } from "babylonjs/types";
  58515. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58516. import { Scene } from "babylonjs/scene";
  58517. /**
  58518. * Class containing static functions to help procedurally build meshes
  58519. */
  58520. export class LinesBuilder {
  58521. /**
  58522. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58523. * * 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
  58524. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58525. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58526. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58527. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58528. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58529. * * 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
  58530. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58533. * @param name defines the name of the new line system
  58534. * @param options defines the options used to create the line system
  58535. * @param scene defines the hosting scene
  58536. * @returns a new line system mesh
  58537. */
  58538. static CreateLineSystem(name: string, options: {
  58539. lines: Vector3[][];
  58540. updatable?: boolean;
  58541. instance?: Nullable<LinesMesh>;
  58542. colors?: Nullable<Color4[][]>;
  58543. useVertexAlpha?: boolean;
  58544. }, scene: Nullable<Scene>): LinesMesh;
  58545. /**
  58546. * Creates a line mesh
  58547. * 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
  58548. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58549. * * The parameter `points` is an array successive Vector3
  58550. * * 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
  58551. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58552. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58553. * * When updating an instance, remember that only point positions can change, not the number of points
  58554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58556. * @param name defines the name of the new line system
  58557. * @param options defines the options used to create the line system
  58558. * @param scene defines the hosting scene
  58559. * @returns a new line mesh
  58560. */
  58561. static CreateLines(name: string, options: {
  58562. points: Vector3[];
  58563. updatable?: boolean;
  58564. instance?: Nullable<LinesMesh>;
  58565. colors?: Color4[];
  58566. useVertexAlpha?: boolean;
  58567. }, scene?: Nullable<Scene>): LinesMesh;
  58568. /**
  58569. * Creates a dashed line mesh
  58570. * * 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
  58571. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58572. * * The parameter `points` is an array successive Vector3
  58573. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58574. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58575. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58576. * * 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
  58577. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58578. * * When updating an instance, remember that only point positions can change, not the number of points
  58579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58580. * @param name defines the name of the mesh
  58581. * @param options defines the options used to create the mesh
  58582. * @param scene defines the hosting scene
  58583. * @returns the dashed line mesh
  58584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58585. */
  58586. static CreateDashedLines(name: string, options: {
  58587. points: Vector3[];
  58588. dashSize?: number;
  58589. gapSize?: number;
  58590. dashNb?: number;
  58591. updatable?: boolean;
  58592. instance?: LinesMesh;
  58593. useVertexAlpha?: boolean;
  58594. }, scene?: Nullable<Scene>): LinesMesh;
  58595. }
  58596. }
  58597. declare module "babylonjs/Misc/timer" {
  58598. import { Observable, Observer } from "babylonjs/Misc/observable";
  58599. import { Nullable } from "babylonjs/types";
  58600. import { IDisposable } from "babylonjs/scene";
  58601. /**
  58602. * Construction options for a timer
  58603. */
  58604. export interface ITimerOptions<T> {
  58605. /**
  58606. * Time-to-end
  58607. */
  58608. timeout: number;
  58609. /**
  58610. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  58611. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  58612. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  58613. */
  58614. contextObservable: Observable<T>;
  58615. /**
  58616. * Optional parameters when adding an observer to the observable
  58617. */
  58618. observableParameters?: {
  58619. mask?: number;
  58620. insertFirst?: boolean;
  58621. scope?: any;
  58622. };
  58623. /**
  58624. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  58625. */
  58626. breakCondition?: (data?: ITimerData<T>) => boolean;
  58627. /**
  58628. * Will be triggered when the time condition has met
  58629. */
  58630. onEnded?: (data: ITimerData<any>) => void;
  58631. /**
  58632. * Will be triggered when the break condition has met (prematurely ended)
  58633. */
  58634. onAborted?: (data: ITimerData<any>) => void;
  58635. /**
  58636. * Optional function to execute on each tick (or count)
  58637. */
  58638. onTick?: (data: ITimerData<any>) => void;
  58639. }
  58640. /**
  58641. * An interface defining the data sent by the timer
  58642. */
  58643. export interface ITimerData<T> {
  58644. /**
  58645. * When did it start
  58646. */
  58647. startTime: number;
  58648. /**
  58649. * Time now
  58650. */
  58651. currentTime: number;
  58652. /**
  58653. * Time passed since started
  58654. */
  58655. deltaTime: number;
  58656. /**
  58657. * How much is completed, in [0.0...1.0].
  58658. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  58659. */
  58660. completeRate: number;
  58661. /**
  58662. * What the registered observable sent in the last count
  58663. */
  58664. payload: T;
  58665. }
  58666. /**
  58667. * The current state of the timer
  58668. */
  58669. export enum TimerState {
  58670. /**
  58671. * Timer initialized, not yet started
  58672. */
  58673. INIT = 0,
  58674. /**
  58675. * Timer started and counting
  58676. */
  58677. STARTED = 1,
  58678. /**
  58679. * Timer ended (whether aborted or time reached)
  58680. */
  58681. ENDED = 2
  58682. }
  58683. /**
  58684. * A simple version of the timer. Will take options and start the timer immediately after calling it
  58685. *
  58686. * @param options options with which to initialize this timer
  58687. */
  58688. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  58689. /**
  58690. * An advanced implementation of a timer class
  58691. */
  58692. export class AdvancedTimer<T = any> implements IDisposable {
  58693. /**
  58694. * Will notify each time the timer calculates the remaining time
  58695. */
  58696. onEachCountObservable: Observable<ITimerData<T>>;
  58697. /**
  58698. * Will trigger when the timer was aborted due to the break condition
  58699. */
  58700. onTimerAbortedObservable: Observable<ITimerData<T>>;
  58701. /**
  58702. * Will trigger when the timer ended successfully
  58703. */
  58704. onTimerEndedObservable: Observable<ITimerData<T>>;
  58705. /**
  58706. * Will trigger when the timer state has changed
  58707. */
  58708. onStateChangedObservable: Observable<TimerState>;
  58709. private _observer;
  58710. private _contextObservable;
  58711. private _observableParameters;
  58712. private _startTime;
  58713. private _timer;
  58714. private _state;
  58715. private _breakCondition;
  58716. private _timeToEnd;
  58717. private _breakOnNextTick;
  58718. /**
  58719. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  58720. * @param options construction options for this advanced timer
  58721. */
  58722. constructor(options: ITimerOptions<T>);
  58723. /**
  58724. * set a breaking condition for this timer. Default is to never break during count
  58725. * @param predicate the new break condition. Returns true to break, false otherwise
  58726. */
  58727. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  58728. /**
  58729. * Reset ALL associated observables in this advanced timer
  58730. */
  58731. clearObservables(): void;
  58732. /**
  58733. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  58734. *
  58735. * @param timeToEnd how much time to measure until timer ended
  58736. */
  58737. start(timeToEnd?: number): void;
  58738. /**
  58739. * Will force a stop on the next tick.
  58740. */
  58741. stop(): void;
  58742. /**
  58743. * Dispose this timer, clearing all resources
  58744. */
  58745. dispose(): void;
  58746. private _setState;
  58747. private _tick;
  58748. private _stop;
  58749. }
  58750. }
  58751. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  58752. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  58753. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  58754. import { Nullable } from "babylonjs/types";
  58755. import { WebXRInput } from "babylonjs/XR/webXRInput";
  58756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58757. import { Vector3 } from "babylonjs/Maths/math.vector";
  58758. import { Material } from "babylonjs/Materials/material";
  58759. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  58760. import { Scene } from "babylonjs/scene";
  58761. /**
  58762. * The options container for the teleportation module
  58763. */
  58764. export interface IWebXRTeleportationOptions {
  58765. /**
  58766. * if provided, this scene will be used to render meshes.
  58767. */
  58768. customUtilityLayerScene?: Scene;
  58769. /**
  58770. * Values to configure the default target mesh
  58771. */
  58772. defaultTargetMeshOptions?: {
  58773. /**
  58774. * Fill color of the teleportation area
  58775. */
  58776. teleportationFillColor?: string;
  58777. /**
  58778. * Border color for the teleportation area
  58779. */
  58780. teleportationBorderColor?: string;
  58781. /**
  58782. * Disable the mesh's animation sequence
  58783. */
  58784. disableAnimation?: boolean;
  58785. /**
  58786. * Disable lighting on the material or the ring and arrow
  58787. */
  58788. disableLighting?: boolean;
  58789. /**
  58790. * Override the default material of the torus and arrow
  58791. */
  58792. torusArrowMaterial?: Material;
  58793. };
  58794. /**
  58795. * A list of meshes to use as floor meshes.
  58796. * Meshes can be added and removed after initializing the feature using the
  58797. * addFloorMesh and removeFloorMesh functions
  58798. * If empty, rotation will still work
  58799. */
  58800. floorMeshes?: AbstractMesh[];
  58801. /**
  58802. * use this rendering group id for the meshes (optional)
  58803. */
  58804. renderingGroupId?: number;
  58805. /**
  58806. * Should teleportation move only to snap points
  58807. */
  58808. snapPointsOnly?: boolean;
  58809. /**
  58810. * An array of points to which the teleportation will snap to.
  58811. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  58812. */
  58813. snapPositions?: Vector3[];
  58814. /**
  58815. * How close should the teleportation ray be in order to snap to position.
  58816. * Default to 0.8 units (meters)
  58817. */
  58818. snapToPositionRadius?: number;
  58819. /**
  58820. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  58821. * If you want to support rotation, make sure your mesh has a direction indicator.
  58822. *
  58823. * When left untouched, the default mesh will be initialized.
  58824. */
  58825. teleportationTargetMesh?: AbstractMesh;
  58826. /**
  58827. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  58828. */
  58829. timeToTeleport?: number;
  58830. /**
  58831. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  58832. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  58833. */
  58834. useMainComponentOnly?: boolean;
  58835. /**
  58836. * Should meshes created here be added to a utility layer or the main scene
  58837. */
  58838. useUtilityLayer?: boolean;
  58839. /**
  58840. * Babylon XR Input class for controller
  58841. */
  58842. xrInput: WebXRInput;
  58843. /**
  58844. * Meshes that the teleportation ray cannot go through
  58845. */
  58846. pickBlockerMeshes?: AbstractMesh[];
  58847. /**
  58848. * Should teleport work only on a specific hand?
  58849. */
  58850. forceHandedness?: XRHandedness;
  58851. /**
  58852. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  58853. */
  58854. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  58855. }
  58856. /**
  58857. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  58858. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  58859. * the input of the attached controllers.
  58860. */
  58861. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  58862. private _options;
  58863. private _controllers;
  58864. private _currentTeleportationControllerId;
  58865. private _floorMeshes;
  58866. private _quadraticBezierCurve;
  58867. private _selectionFeature;
  58868. private _snapToPositions;
  58869. private _snappedToPoint;
  58870. private _teleportationRingMaterial?;
  58871. private _tmpRay;
  58872. private _tmpVector;
  58873. private _tmpQuaternion;
  58874. /**
  58875. * The module's name
  58876. */
  58877. static readonly Name: string;
  58878. /**
  58879. * The (Babylon) version of this module.
  58880. * This is an integer representing the implementation version.
  58881. * This number does not correspond to the webxr specs version
  58882. */
  58883. static readonly Version: number;
  58884. /**
  58885. * Is movement backwards enabled
  58886. */
  58887. backwardsMovementEnabled: boolean;
  58888. /**
  58889. * Distance to travel when moving backwards
  58890. */
  58891. backwardsTeleportationDistance: number;
  58892. /**
  58893. * The distance from the user to the inspection point in the direction of the controller
  58894. * A higher number will allow the user to move further
  58895. * defaults to 5 (meters, in xr units)
  58896. */
  58897. parabolicCheckRadius: number;
  58898. /**
  58899. * Should the module support parabolic ray on top of direct ray
  58900. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  58901. * Very helpful when moving between floors / different heights
  58902. */
  58903. parabolicRayEnabled: boolean;
  58904. /**
  58905. * The second type of ray - straight line.
  58906. * Should it be enabled or should the parabolic line be the only one.
  58907. */
  58908. straightRayEnabled: boolean;
  58909. /**
  58910. * How much rotation should be applied when rotating right and left
  58911. */
  58912. rotationAngle: number;
  58913. private _rotationEnabled;
  58914. /**
  58915. * Is rotation enabled when moving forward?
  58916. * Disabling this feature will prevent the user from deciding the direction when teleporting
  58917. */
  58918. get rotationEnabled(): boolean;
  58919. /**
  58920. * Sets whether rotation is enabled or not
  58921. * @param enabled is rotation enabled when teleportation is shown
  58922. */
  58923. set rotationEnabled(enabled: boolean);
  58924. /**
  58925. * Exposes the currently set teleportation target mesh.
  58926. */
  58927. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  58928. /**
  58929. * constructs a new anchor system
  58930. * @param _xrSessionManager an instance of WebXRSessionManager
  58931. * @param _options configuration object for this feature
  58932. */
  58933. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  58934. /**
  58935. * Get the snapPointsOnly flag
  58936. */
  58937. get snapPointsOnly(): boolean;
  58938. /**
  58939. * Sets the snapPointsOnly flag
  58940. * @param snapToPoints should teleportation be exclusively to snap points
  58941. */
  58942. set snapPointsOnly(snapToPoints: boolean);
  58943. /**
  58944. * Add a new mesh to the floor meshes array
  58945. * @param mesh the mesh to use as floor mesh
  58946. */
  58947. addFloorMesh(mesh: AbstractMesh): void;
  58948. /**
  58949. * Add a new snap-to point to fix teleportation to this position
  58950. * @param newSnapPoint The new Snap-To point
  58951. */
  58952. addSnapPoint(newSnapPoint: Vector3): void;
  58953. attach(): boolean;
  58954. detach(): boolean;
  58955. dispose(): void;
  58956. /**
  58957. * Remove a mesh from the floor meshes array
  58958. * @param mesh the mesh to remove
  58959. */
  58960. removeFloorMesh(mesh: AbstractMesh): void;
  58961. /**
  58962. * Remove a mesh from the floor meshes array using its name
  58963. * @param name the mesh name to remove
  58964. */
  58965. removeFloorMeshByName(name: string): void;
  58966. /**
  58967. * 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
  58968. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  58969. * @returns was the point found and removed or not
  58970. */
  58971. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  58972. /**
  58973. * This function sets a selection feature that will be disabled when
  58974. * the forward ray is shown and will be reattached when hidden.
  58975. * This is used to remove the selection rays when moving.
  58976. * @param selectionFeature the feature to disable when forward movement is enabled
  58977. */
  58978. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  58979. protected _onXRFrame(_xrFrame: XRFrame): void;
  58980. private _attachController;
  58981. private _createDefaultTargetMesh;
  58982. private _detachController;
  58983. private _findClosestSnapPointWithRadius;
  58984. private _setTargetMeshPosition;
  58985. private _setTargetMeshVisibility;
  58986. private _showParabolicPath;
  58987. private _teleportForward;
  58988. }
  58989. }
  58990. declare module "babylonjs/XR/webXRDefaultExperience" {
  58991. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  58992. import { Scene } from "babylonjs/scene";
  58993. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  58994. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  58995. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  58996. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  58997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58998. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  58999. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  59000. /**
  59001. * Options for the default xr helper
  59002. */
  59003. export class WebXRDefaultExperienceOptions {
  59004. /**
  59005. * Enable or disable default UI to enter XR
  59006. */
  59007. disableDefaultUI?: boolean;
  59008. /**
  59009. * Should teleportation not initialize. defaults to false.
  59010. */
  59011. disableTeleportation?: boolean;
  59012. /**
  59013. * Floor meshes that will be used for teleport
  59014. */
  59015. floorMeshes?: Array<AbstractMesh>;
  59016. /**
  59017. * If set to true, the first frame will not be used to reset position
  59018. * The first frame is mainly used when copying transformation from the old camera
  59019. * Mainly used in AR
  59020. */
  59021. ignoreNativeCameraTransformation?: boolean;
  59022. /**
  59023. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  59024. */
  59025. inputOptions?: IWebXRInputOptions;
  59026. /**
  59027. * optional configuration for the output canvas
  59028. */
  59029. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  59030. /**
  59031. * optional UI options. This can be used among other to change session mode and reference space type
  59032. */
  59033. uiOptions?: WebXREnterExitUIOptions;
  59034. /**
  59035. * When loading teleportation and pointer select, use stable versions instead of latest.
  59036. */
  59037. useStablePlugins?: boolean;
  59038. /**
  59039. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  59040. */
  59041. renderingGroupId?: number;
  59042. /**
  59043. * A list of optional features to init the session with
  59044. * If set to true, all features we support will be added
  59045. */
  59046. optionalFeatures?: boolean | string[];
  59047. }
  59048. /**
  59049. * Default experience which provides a similar setup to the previous webVRExperience
  59050. */
  59051. export class WebXRDefaultExperience {
  59052. /**
  59053. * Base experience
  59054. */
  59055. baseExperience: WebXRExperienceHelper;
  59056. /**
  59057. * Enables ui for entering/exiting xr
  59058. */
  59059. enterExitUI: WebXREnterExitUI;
  59060. /**
  59061. * Input experience extension
  59062. */
  59063. input: WebXRInput;
  59064. /**
  59065. * Enables laser pointer and selection
  59066. */
  59067. pointerSelection: WebXRControllerPointerSelection;
  59068. /**
  59069. * Default target xr should render to
  59070. */
  59071. renderTarget: WebXRRenderTarget;
  59072. /**
  59073. * Enables teleportation
  59074. */
  59075. teleportation: WebXRMotionControllerTeleportation;
  59076. private constructor();
  59077. /**
  59078. * Creates the default xr experience
  59079. * @param scene scene
  59080. * @param options options for basic configuration
  59081. * @returns resulting WebXRDefaultExperience
  59082. */
  59083. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59084. /**
  59085. * Disposes of the experience helper
  59086. */
  59087. dispose(): void;
  59088. }
  59089. }
  59090. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  59091. import { Observable } from "babylonjs/Misc/observable";
  59092. import { Nullable } from "babylonjs/types";
  59093. import { Camera } from "babylonjs/Cameras/camera";
  59094. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  59095. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  59096. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  59097. import { Scene } from "babylonjs/scene";
  59098. import { Vector3 } from "babylonjs/Maths/math.vector";
  59099. import { Color3 } from "babylonjs/Maths/math.color";
  59100. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59102. import { Mesh } from "babylonjs/Meshes/mesh";
  59103. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  59104. import { EasingFunction } from "babylonjs/Animations/easing";
  59105. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  59106. import "babylonjs/Meshes/Builders/groundBuilder";
  59107. import "babylonjs/Meshes/Builders/torusBuilder";
  59108. import "babylonjs/Meshes/Builders/cylinderBuilder";
  59109. import "babylonjs/Gamepads/gamepadSceneComponent";
  59110. import "babylonjs/Animations/animatable";
  59111. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  59112. /**
  59113. * Options to modify the vr teleportation behavior.
  59114. */
  59115. export interface VRTeleportationOptions {
  59116. /**
  59117. * The name of the mesh which should be used as the teleportation floor. (default: null)
  59118. */
  59119. floorMeshName?: string;
  59120. /**
  59121. * A list of meshes to be used as the teleportation floor. (default: empty)
  59122. */
  59123. floorMeshes?: Mesh[];
  59124. /**
  59125. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  59126. */
  59127. teleportationMode?: number;
  59128. /**
  59129. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  59130. */
  59131. teleportationTime?: number;
  59132. /**
  59133. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  59134. */
  59135. teleportationSpeed?: number;
  59136. /**
  59137. * The easing function used in the animation or null for Linear. (default CircleEase)
  59138. */
  59139. easingFunction?: EasingFunction;
  59140. }
  59141. /**
  59142. * Options to modify the vr experience helper's behavior.
  59143. */
  59144. export interface VRExperienceHelperOptions extends WebVROptions {
  59145. /**
  59146. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  59147. */
  59148. createDeviceOrientationCamera?: boolean;
  59149. /**
  59150. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  59151. */
  59152. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  59153. /**
  59154. * Uses the main button on the controller to toggle the laser casted. (default: true)
  59155. */
  59156. laserToggle?: boolean;
  59157. /**
  59158. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  59159. */
  59160. floorMeshes?: Mesh[];
  59161. /**
  59162. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  59163. */
  59164. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  59165. /**
  59166. * Defines if WebXR should be used instead of WebVR (if available)
  59167. */
  59168. useXR?: boolean;
  59169. }
  59170. /**
  59171. * Event containing information after VR has been entered
  59172. */
  59173. export class OnAfterEnteringVRObservableEvent {
  59174. /**
  59175. * If entering vr was successful
  59176. */
  59177. success: boolean;
  59178. }
  59179. /**
  59180. * Helps to quickly add VR support to an existing scene.
  59181. * See https://doc.babylonjs.com/how_to/webvr_helper
  59182. */
  59183. export class VRExperienceHelper {
  59184. /** Options to modify the vr experience helper's behavior. */
  59185. webVROptions: VRExperienceHelperOptions;
  59186. private _scene;
  59187. private _position;
  59188. private _btnVR;
  59189. private _btnVRDisplayed;
  59190. private _webVRsupported;
  59191. private _webVRready;
  59192. private _webVRrequesting;
  59193. private _webVRpresenting;
  59194. private _hasEnteredVR;
  59195. private _fullscreenVRpresenting;
  59196. private _inputElement;
  59197. private _webVRCamera;
  59198. private _vrDeviceOrientationCamera;
  59199. private _deviceOrientationCamera;
  59200. private _existingCamera;
  59201. private _onKeyDown;
  59202. private _onVrDisplayPresentChange;
  59203. private _onVRDisplayChanged;
  59204. private _onVRRequestPresentStart;
  59205. private _onVRRequestPresentComplete;
  59206. /**
  59207. * 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)
  59208. */
  59209. enableGazeEvenWhenNoPointerLock: boolean;
  59210. /**
  59211. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  59212. */
  59213. exitVROnDoubleTap: boolean;
  59214. /**
  59215. * Observable raised right before entering VR.
  59216. */
  59217. onEnteringVRObservable: Observable<VRExperienceHelper>;
  59218. /**
  59219. * Observable raised when entering VR has completed.
  59220. */
  59221. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  59222. /**
  59223. * Observable raised when exiting VR.
  59224. */
  59225. onExitingVRObservable: Observable<VRExperienceHelper>;
  59226. /**
  59227. * Observable raised when controller mesh is loaded.
  59228. */
  59229. onControllerMeshLoadedObservable: Observable<WebVRController>;
  59230. /** Return this.onEnteringVRObservable
  59231. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  59232. */
  59233. get onEnteringVR(): Observable<VRExperienceHelper>;
  59234. /** Return this.onExitingVRObservable
  59235. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  59236. */
  59237. get onExitingVR(): Observable<VRExperienceHelper>;
  59238. /** Return this.onControllerMeshLoadedObservable
  59239. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  59240. */
  59241. get onControllerMeshLoaded(): Observable<WebVRController>;
  59242. private _rayLength;
  59243. private _useCustomVRButton;
  59244. private _teleportationRequested;
  59245. private _teleportActive;
  59246. private _floorMeshName;
  59247. private _floorMeshesCollection;
  59248. private _teleportationMode;
  59249. private _teleportationTime;
  59250. private _teleportationSpeed;
  59251. private _teleportationEasing;
  59252. private _rotationAllowed;
  59253. private _teleportBackwardsVector;
  59254. private _teleportationTarget;
  59255. private _isDefaultTeleportationTarget;
  59256. private _postProcessMove;
  59257. private _teleportationFillColor;
  59258. private _teleportationBorderColor;
  59259. private _rotationAngle;
  59260. private _haloCenter;
  59261. private _cameraGazer;
  59262. private _padSensibilityUp;
  59263. private _padSensibilityDown;
  59264. private _leftController;
  59265. private _rightController;
  59266. private _gazeColor;
  59267. private _laserColor;
  59268. private _pickedLaserColor;
  59269. private _pickedGazeColor;
  59270. /**
  59271. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  59272. */
  59273. onNewMeshSelected: Observable<AbstractMesh>;
  59274. /**
  59275. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  59276. * This observable will provide the mesh and the controller used to select the mesh
  59277. */
  59278. onMeshSelectedWithController: Observable<{
  59279. mesh: AbstractMesh;
  59280. controller: WebVRController;
  59281. }>;
  59282. /**
  59283. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  59284. */
  59285. onNewMeshPicked: Observable<PickingInfo>;
  59286. private _circleEase;
  59287. /**
  59288. * Observable raised before camera teleportation
  59289. */
  59290. onBeforeCameraTeleport: Observable<Vector3>;
  59291. /**
  59292. * Observable raised after camera teleportation
  59293. */
  59294. onAfterCameraTeleport: Observable<Vector3>;
  59295. /**
  59296. * Observable raised when current selected mesh gets unselected
  59297. */
  59298. onSelectedMeshUnselected: Observable<AbstractMesh>;
  59299. private _raySelectionPredicate;
  59300. /**
  59301. * To be optionally changed by user to define custom ray selection
  59302. */
  59303. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  59304. /**
  59305. * To be optionally changed by user to define custom selection logic (after ray selection)
  59306. */
  59307. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59308. /**
  59309. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  59310. */
  59311. teleportationEnabled: boolean;
  59312. private _defaultHeight;
  59313. private _teleportationInitialized;
  59314. private _interactionsEnabled;
  59315. private _interactionsRequested;
  59316. private _displayGaze;
  59317. private _displayLaserPointer;
  59318. /**
  59319. * The mesh used to display where the user is going to teleport.
  59320. */
  59321. get teleportationTarget(): Mesh;
  59322. /**
  59323. * Sets the mesh to be used to display where the user is going to teleport.
  59324. */
  59325. set teleportationTarget(value: Mesh);
  59326. /**
  59327. * 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
  59328. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  59329. * See https://doc.babylonjs.com/resources/baking_transformations
  59330. */
  59331. get gazeTrackerMesh(): Mesh;
  59332. set gazeTrackerMesh(value: Mesh);
  59333. /**
  59334. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  59335. */
  59336. updateGazeTrackerScale: boolean;
  59337. /**
  59338. * If the gaze trackers color should be updated when selecting meshes
  59339. */
  59340. updateGazeTrackerColor: boolean;
  59341. /**
  59342. * If the controller laser color should be updated when selecting meshes
  59343. */
  59344. updateControllerLaserColor: boolean;
  59345. /**
  59346. * The gaze tracking mesh corresponding to the left controller
  59347. */
  59348. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  59349. /**
  59350. * The gaze tracking mesh corresponding to the right controller
  59351. */
  59352. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  59353. /**
  59354. * If the ray of the gaze should be displayed.
  59355. */
  59356. get displayGaze(): boolean;
  59357. /**
  59358. * Sets if the ray of the gaze should be displayed.
  59359. */
  59360. set displayGaze(value: boolean);
  59361. /**
  59362. * If the ray of the LaserPointer should be displayed.
  59363. */
  59364. get displayLaserPointer(): boolean;
  59365. /**
  59366. * Sets if the ray of the LaserPointer should be displayed.
  59367. */
  59368. set displayLaserPointer(value: boolean);
  59369. /**
  59370. * The deviceOrientationCamera used as the camera when not in VR.
  59371. */
  59372. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  59373. /**
  59374. * Based on the current WebVR support, returns the current VR camera used.
  59375. */
  59376. get currentVRCamera(): Nullable<Camera>;
  59377. /**
  59378. * The webVRCamera which is used when in VR.
  59379. */
  59380. get webVRCamera(): WebVRFreeCamera;
  59381. /**
  59382. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  59383. */
  59384. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  59385. /**
  59386. * The html button that is used to trigger entering into VR.
  59387. */
  59388. get vrButton(): Nullable<HTMLButtonElement>;
  59389. private get _teleportationRequestInitiated();
  59390. /**
  59391. * Defines whether or not Pointer lock should be requested when switching to
  59392. * full screen.
  59393. */
  59394. requestPointerLockOnFullScreen: boolean;
  59395. /**
  59396. * If asking to force XR, this will be populated with the default xr experience
  59397. */
  59398. xr: WebXRDefaultExperience;
  59399. /**
  59400. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  59401. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  59402. */
  59403. xrTestDone: boolean;
  59404. /**
  59405. * Instantiates a VRExperienceHelper.
  59406. * Helps to quickly add VR support to an existing scene.
  59407. * @param scene The scene the VRExperienceHelper belongs to.
  59408. * @param webVROptions Options to modify the vr experience helper's behavior.
  59409. */
  59410. constructor(scene: Scene,
  59411. /** Options to modify the vr experience helper's behavior. */
  59412. webVROptions?: VRExperienceHelperOptions);
  59413. private completeVRInit;
  59414. private _onDefaultMeshLoaded;
  59415. private _onResize;
  59416. private _onFullscreenChange;
  59417. /**
  59418. * Gets a value indicating if we are currently in VR mode.
  59419. */
  59420. get isInVRMode(): boolean;
  59421. private onVrDisplayPresentChange;
  59422. private onVRDisplayChanged;
  59423. private moveButtonToBottomRight;
  59424. private displayVRButton;
  59425. private updateButtonVisibility;
  59426. private _cachedAngularSensibility;
  59427. /**
  59428. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  59429. * Otherwise, will use the fullscreen API.
  59430. */
  59431. enterVR(): void;
  59432. /**
  59433. * Attempt to exit VR, or fullscreen.
  59434. */
  59435. exitVR(): void;
  59436. /**
  59437. * The position of the vr experience helper.
  59438. */
  59439. get position(): Vector3;
  59440. /**
  59441. * Sets the position of the vr experience helper.
  59442. */
  59443. set position(value: Vector3);
  59444. /**
  59445. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  59446. */
  59447. enableInteractions(): void;
  59448. private get _noControllerIsActive();
  59449. private beforeRender;
  59450. private _isTeleportationFloor;
  59451. /**
  59452. * Adds a floor mesh to be used for teleportation.
  59453. * @param floorMesh the mesh to be used for teleportation.
  59454. */
  59455. addFloorMesh(floorMesh: Mesh): void;
  59456. /**
  59457. * Removes a floor mesh from being used for teleportation.
  59458. * @param floorMesh the mesh to be removed.
  59459. */
  59460. removeFloorMesh(floorMesh: Mesh): void;
  59461. /**
  59462. * Enables interactions and teleportation using the VR controllers and gaze.
  59463. * @param vrTeleportationOptions options to modify teleportation behavior.
  59464. */
  59465. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  59466. private _onNewGamepadConnected;
  59467. private _tryEnableInteractionOnController;
  59468. private _onNewGamepadDisconnected;
  59469. private _enableInteractionOnController;
  59470. private _checkTeleportWithRay;
  59471. private _checkRotate;
  59472. private _checkTeleportBackwards;
  59473. private _enableTeleportationOnController;
  59474. private _createTeleportationCircles;
  59475. private _displayTeleportationTarget;
  59476. private _hideTeleportationTarget;
  59477. private _rotateCamera;
  59478. private _moveTeleportationSelectorTo;
  59479. private _workingVector;
  59480. private _workingQuaternion;
  59481. private _workingMatrix;
  59482. /**
  59483. * Time Constant Teleportation Mode
  59484. */
  59485. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  59486. /**
  59487. * Speed Constant Teleportation Mode
  59488. */
  59489. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  59490. /**
  59491. * Teleports the users feet to the desired location
  59492. * @param location The location where the user's feet should be placed
  59493. */
  59494. teleportCamera(location: Vector3): void;
  59495. private _convertNormalToDirectionOfRay;
  59496. private _castRayAndSelectObject;
  59497. private _notifySelectedMeshUnselected;
  59498. /**
  59499. * Permanently set new colors for the laser pointer
  59500. * @param color the new laser color
  59501. * @param pickedColor the new laser color when picked mesh detected
  59502. */
  59503. setLaserColor(color: Color3, pickedColor?: Color3): void;
  59504. /**
  59505. * Set lighting enabled / disabled on the laser pointer of both controllers
  59506. * @param enabled should the lighting be enabled on the laser pointer
  59507. */
  59508. setLaserLightingState(enabled?: boolean): void;
  59509. /**
  59510. * Permanently set new colors for the gaze pointer
  59511. * @param color the new gaze color
  59512. * @param pickedColor the new gaze color when picked mesh detected
  59513. */
  59514. setGazeColor(color: Color3, pickedColor?: Color3): void;
  59515. /**
  59516. * Sets the color of the laser ray from the vr controllers.
  59517. * @param color new color for the ray.
  59518. */
  59519. changeLaserColor(color: Color3): void;
  59520. /**
  59521. * Sets the color of the ray from the vr headsets gaze.
  59522. * @param color new color for the ray.
  59523. */
  59524. changeGazeColor(color: Color3): void;
  59525. /**
  59526. * Exits VR and disposes of the vr experience helper
  59527. */
  59528. dispose(): void;
  59529. /**
  59530. * Gets the name of the VRExperienceHelper class
  59531. * @returns "VRExperienceHelper"
  59532. */
  59533. getClassName(): string;
  59534. }
  59535. }
  59536. declare module "babylonjs/Cameras/VR/index" {
  59537. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  59538. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  59539. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  59540. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  59541. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  59542. export * from "babylonjs/Cameras/VR/webVRCamera";
  59543. }
  59544. declare module "babylonjs/Cameras/RigModes/index" {
  59545. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  59546. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  59547. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  59548. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  59549. }
  59550. declare module "babylonjs/Cameras/index" {
  59551. export * from "babylonjs/Cameras/Inputs/index";
  59552. export * from "babylonjs/Cameras/cameraInputsManager";
  59553. export * from "babylonjs/Cameras/camera";
  59554. export * from "babylonjs/Cameras/targetCamera";
  59555. export * from "babylonjs/Cameras/freeCamera";
  59556. export * from "babylonjs/Cameras/freeCameraInputsManager";
  59557. export * from "babylonjs/Cameras/touchCamera";
  59558. export * from "babylonjs/Cameras/arcRotateCamera";
  59559. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  59560. export * from "babylonjs/Cameras/deviceOrientationCamera";
  59561. export * from "babylonjs/Cameras/flyCamera";
  59562. export * from "babylonjs/Cameras/flyCameraInputsManager";
  59563. export * from "babylonjs/Cameras/followCamera";
  59564. export * from "babylonjs/Cameras/followCameraInputsManager";
  59565. export * from "babylonjs/Cameras/gamepadCamera";
  59566. export * from "babylonjs/Cameras/Stereoscopic/index";
  59567. export * from "babylonjs/Cameras/universalCamera";
  59568. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  59569. export * from "babylonjs/Cameras/VR/index";
  59570. export * from "babylonjs/Cameras/RigModes/index";
  59571. }
  59572. declare module "babylonjs/Collisions/index" {
  59573. export * from "babylonjs/Collisions/collider";
  59574. export * from "babylonjs/Collisions/collisionCoordinator";
  59575. export * from "babylonjs/Collisions/pickingInfo";
  59576. export * from "babylonjs/Collisions/intersectionInfo";
  59577. export * from "babylonjs/Collisions/meshCollisionData";
  59578. }
  59579. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  59580. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  59581. import { Vector3 } from "babylonjs/Maths/math.vector";
  59582. import { Ray } from "babylonjs/Culling/ray";
  59583. import { Plane } from "babylonjs/Maths/math.plane";
  59584. /**
  59585. * Contains an array of blocks representing the octree
  59586. */
  59587. export interface IOctreeContainer<T> {
  59588. /**
  59589. * Blocks within the octree
  59590. */
  59591. blocks: Array<OctreeBlock<T>>;
  59592. }
  59593. /**
  59594. * Class used to store a cell in an octree
  59595. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59596. */
  59597. export class OctreeBlock<T> {
  59598. /**
  59599. * Gets the content of the current block
  59600. */
  59601. entries: T[];
  59602. /**
  59603. * Gets the list of block children
  59604. */
  59605. blocks: Array<OctreeBlock<T>>;
  59606. private _depth;
  59607. private _maxDepth;
  59608. private _capacity;
  59609. private _minPoint;
  59610. private _maxPoint;
  59611. private _boundingVectors;
  59612. private _creationFunc;
  59613. /**
  59614. * Creates a new block
  59615. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  59616. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  59617. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  59618. * @param depth defines the current depth of this block in the octree
  59619. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  59620. * @param creationFunc defines a callback to call when an element is added to the block
  59621. */
  59622. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  59623. /**
  59624. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  59625. */
  59626. get capacity(): number;
  59627. /**
  59628. * Gets the minimum vector (in world space) of the block's bounding box
  59629. */
  59630. get minPoint(): Vector3;
  59631. /**
  59632. * Gets the maximum vector (in world space) of the block's bounding box
  59633. */
  59634. get maxPoint(): Vector3;
  59635. /**
  59636. * Add a new element to this block
  59637. * @param entry defines the element to add
  59638. */
  59639. addEntry(entry: T): void;
  59640. /**
  59641. * Remove an element from this block
  59642. * @param entry defines the element to remove
  59643. */
  59644. removeEntry(entry: T): void;
  59645. /**
  59646. * Add an array of elements to this block
  59647. * @param entries defines the array of elements to add
  59648. */
  59649. addEntries(entries: T[]): void;
  59650. /**
  59651. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  59652. * @param frustumPlanes defines the frustum planes to test
  59653. * @param selection defines the array to store current content if selection is positive
  59654. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59655. */
  59656. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  59657. /**
  59658. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  59659. * @param sphereCenter defines the bounding sphere center
  59660. * @param sphereRadius defines the bounding sphere radius
  59661. * @param selection defines the array to store current content if selection is positive
  59662. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59663. */
  59664. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  59665. /**
  59666. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  59667. * @param ray defines the ray to test with
  59668. * @param selection defines the array to store current content if selection is positive
  59669. */
  59670. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  59671. /**
  59672. * Subdivide the content into child blocks (this block will then be empty)
  59673. */
  59674. createInnerBlocks(): void;
  59675. /**
  59676. * @hidden
  59677. */
  59678. 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;
  59679. }
  59680. }
  59681. declare module "babylonjs/Culling/Octrees/octree" {
  59682. import { SmartArray } from "babylonjs/Misc/smartArray";
  59683. import { Vector3 } from "babylonjs/Maths/math.vector";
  59684. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59686. import { Ray } from "babylonjs/Culling/ray";
  59687. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  59688. import { Plane } from "babylonjs/Maths/math.plane";
  59689. /**
  59690. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  59691. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59692. */
  59693. export class Octree<T> {
  59694. /** 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.) */
  59695. maxDepth: number;
  59696. /**
  59697. * Blocks within the octree containing objects
  59698. */
  59699. blocks: Array<OctreeBlock<T>>;
  59700. /**
  59701. * Content stored in the octree
  59702. */
  59703. dynamicContent: T[];
  59704. private _maxBlockCapacity;
  59705. private _selectionContent;
  59706. private _creationFunc;
  59707. /**
  59708. * Creates a octree
  59709. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59710. * @param creationFunc function to be used to instantiate the octree
  59711. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  59712. * @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.)
  59713. */
  59714. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  59715. /** 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.) */
  59716. maxDepth?: number);
  59717. /**
  59718. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  59719. * @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);
  59720. * @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);
  59721. * @param entries meshes to be added to the octree blocks
  59722. */
  59723. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  59724. /**
  59725. * Adds a mesh to the octree
  59726. * @param entry Mesh to add to the octree
  59727. */
  59728. addMesh(entry: T): void;
  59729. /**
  59730. * Remove an element from the octree
  59731. * @param entry defines the element to remove
  59732. */
  59733. removeMesh(entry: T): void;
  59734. /**
  59735. * Selects an array of meshes within the frustum
  59736. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  59737. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  59738. * @returns array of meshes within the frustum
  59739. */
  59740. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  59741. /**
  59742. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  59743. * @param sphereCenter defines the bounding sphere center
  59744. * @param sphereRadius defines the bounding sphere radius
  59745. * @param allowDuplicate defines if the selection array can contains duplicated entries
  59746. * @returns an array of objects that intersect the sphere
  59747. */
  59748. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  59749. /**
  59750. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  59751. * @param ray defines the ray to test with
  59752. * @returns array of intersected objects
  59753. */
  59754. intersectsRay(ray: Ray): SmartArray<T>;
  59755. /**
  59756. * Adds a mesh into the octree block if it intersects the block
  59757. */
  59758. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  59759. /**
  59760. * Adds a submesh into the octree block if it intersects the block
  59761. */
  59762. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  59763. }
  59764. }
  59765. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  59766. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  59767. import { Scene } from "babylonjs/scene";
  59768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59770. import { Ray } from "babylonjs/Culling/ray";
  59771. import { Octree } from "babylonjs/Culling/Octrees/octree";
  59772. import { Collider } from "babylonjs/Collisions/collider";
  59773. module "babylonjs/scene" {
  59774. interface Scene {
  59775. /**
  59776. * @hidden
  59777. * Backing Filed
  59778. */
  59779. _selectionOctree: Octree<AbstractMesh>;
  59780. /**
  59781. * Gets the octree used to boost mesh selection (picking)
  59782. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59783. */
  59784. selectionOctree: Octree<AbstractMesh>;
  59785. /**
  59786. * Creates or updates the octree used to boost selection (picking)
  59787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59788. * @param maxCapacity defines the maximum capacity per leaf
  59789. * @param maxDepth defines the maximum depth of the octree
  59790. * @returns an octree of AbstractMesh
  59791. */
  59792. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  59793. }
  59794. }
  59795. module "babylonjs/Meshes/abstractMesh" {
  59796. interface AbstractMesh {
  59797. /**
  59798. * @hidden
  59799. * Backing Field
  59800. */
  59801. _submeshesOctree: Octree<SubMesh>;
  59802. /**
  59803. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  59804. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  59805. * @param maxCapacity defines the maximum size of each block (64 by default)
  59806. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  59807. * @returns the new octree
  59808. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  59809. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  59810. */
  59811. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  59812. }
  59813. }
  59814. /**
  59815. * Defines the octree scene component responsible to manage any octrees
  59816. * in a given scene.
  59817. */
  59818. export class OctreeSceneComponent {
  59819. /**
  59820. * The component name help to identify the component in the list of scene components.
  59821. */
  59822. readonly name: string;
  59823. /**
  59824. * The scene the component belongs to.
  59825. */
  59826. scene: Scene;
  59827. /**
  59828. * Indicates if the meshes have been checked to make sure they are isEnabled()
  59829. */
  59830. readonly checksIsEnabled: boolean;
  59831. /**
  59832. * Creates a new instance of the component for the given scene
  59833. * @param scene Defines the scene to register the component in
  59834. */
  59835. constructor(scene: Scene);
  59836. /**
  59837. * Registers the component in a given scene
  59838. */
  59839. register(): void;
  59840. /**
  59841. * Return the list of active meshes
  59842. * @returns the list of active meshes
  59843. */
  59844. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  59845. /**
  59846. * Return the list of active sub meshes
  59847. * @param mesh The mesh to get the candidates sub meshes from
  59848. * @returns the list of active sub meshes
  59849. */
  59850. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  59851. private _tempRay;
  59852. /**
  59853. * Return the list of sub meshes intersecting with a given local ray
  59854. * @param mesh defines the mesh to find the submesh for
  59855. * @param localRay defines the ray in local space
  59856. * @returns the list of intersecting sub meshes
  59857. */
  59858. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  59859. /**
  59860. * Return the list of sub meshes colliding with a collider
  59861. * @param mesh defines the mesh to find the submesh for
  59862. * @param collider defines the collider to evaluate the collision against
  59863. * @returns the list of colliding sub meshes
  59864. */
  59865. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  59866. /**
  59867. * Rebuilds the elements related to this component in case of
  59868. * context lost for instance.
  59869. */
  59870. rebuild(): void;
  59871. /**
  59872. * Disposes the component and the associated resources.
  59873. */
  59874. dispose(): void;
  59875. }
  59876. }
  59877. declare module "babylonjs/Culling/Octrees/index" {
  59878. export * from "babylonjs/Culling/Octrees/octree";
  59879. export * from "babylonjs/Culling/Octrees/octreeBlock";
  59880. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  59881. }
  59882. declare module "babylonjs/Culling/index" {
  59883. export * from "babylonjs/Culling/boundingBox";
  59884. export * from "babylonjs/Culling/boundingInfo";
  59885. export * from "babylonjs/Culling/boundingSphere";
  59886. export * from "babylonjs/Culling/Octrees/index";
  59887. export * from "babylonjs/Culling/ray";
  59888. }
  59889. declare module "babylonjs/Gizmos/gizmo" {
  59890. import { Observer } from "babylonjs/Misc/observable";
  59891. import { Nullable } from "babylonjs/types";
  59892. import { IDisposable } from "babylonjs/scene";
  59893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59894. import { Mesh } from "babylonjs/Meshes/mesh";
  59895. import { Node } from "babylonjs/node";
  59896. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59897. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59898. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  59899. /**
  59900. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  59901. */
  59902. export interface GizmoAxisCache {
  59903. /** Mesh used to render the Gizmo */
  59904. gizmoMeshes: Mesh[];
  59905. /** Mesh used to detect user interaction with Gizmo */
  59906. colliderMeshes: Mesh[];
  59907. /** Material used to indicate color of gizmo mesh */
  59908. material: StandardMaterial;
  59909. /** Material used to indicate hover state of the Gizmo */
  59910. hoverMaterial: StandardMaterial;
  59911. /** Material used to indicate disabled state of the Gizmo */
  59912. disableMaterial: StandardMaterial;
  59913. /** Used to indicate Active state of the Gizmo */
  59914. active: boolean;
  59915. }
  59916. /**
  59917. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  59918. */
  59919. export class Gizmo implements IDisposable {
  59920. /** The utility layer the gizmo will be added to */
  59921. gizmoLayer: UtilityLayerRenderer;
  59922. /**
  59923. * The root mesh of the gizmo
  59924. */
  59925. _rootMesh: Mesh;
  59926. private _attachedMesh;
  59927. private _attachedNode;
  59928. /**
  59929. * Ratio for the scale of the gizmo (Default: 1)
  59930. */
  59931. protected _scaleRatio: number;
  59932. /**
  59933. * boolean updated by pointermove when a gizmo mesh is hovered
  59934. */
  59935. protected _isHovered: boolean;
  59936. /**
  59937. * Ratio for the scale of the gizmo (Default: 1)
  59938. */
  59939. set scaleRatio(value: number);
  59940. get scaleRatio(): number;
  59941. /**
  59942. * True when the mouse pointer is hovered a gizmo mesh
  59943. */
  59944. get isHovered(): boolean;
  59945. /**
  59946. * If a custom mesh has been set (Default: false)
  59947. */
  59948. protected _customMeshSet: boolean;
  59949. /**
  59950. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  59951. * * When set, interactions will be enabled
  59952. */
  59953. get attachedMesh(): Nullable<AbstractMesh>;
  59954. set attachedMesh(value: Nullable<AbstractMesh>);
  59955. /**
  59956. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  59957. * * When set, interactions will be enabled
  59958. */
  59959. get attachedNode(): Nullable<Node>;
  59960. set attachedNode(value: Nullable<Node>);
  59961. /**
  59962. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59963. * @param mesh The mesh to replace the default mesh of the gizmo
  59964. */
  59965. setCustomMesh(mesh: Mesh): void;
  59966. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  59967. /**
  59968. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  59969. */
  59970. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59971. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59972. /**
  59973. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  59974. */
  59975. updateGizmoPositionToMatchAttachedMesh: boolean;
  59976. /**
  59977. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  59978. */
  59979. updateScale: boolean;
  59980. protected _interactionsEnabled: boolean;
  59981. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59982. private _beforeRenderObserver;
  59983. private _tempQuaternion;
  59984. private _tempVector;
  59985. private _tempVector2;
  59986. private _tempMatrix1;
  59987. private _tempMatrix2;
  59988. private _rightHandtoLeftHandMatrix;
  59989. /**
  59990. * Creates a gizmo
  59991. * @param gizmoLayer The utility layer the gizmo will be added to
  59992. */
  59993. constructor(
  59994. /** The utility layer the gizmo will be added to */
  59995. gizmoLayer?: UtilityLayerRenderer);
  59996. /**
  59997. * Updates the gizmo to match the attached mesh's position/rotation
  59998. */
  59999. protected _update(): void;
  60000. /**
  60001. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  60002. * @param value Node, TransformNode or mesh
  60003. */
  60004. protected _matrixChanged(): void;
  60005. /**
  60006. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  60007. * @param gizmoLayer The utility layer the gizmo will be added to
  60008. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  60009. * @returns {Observer<PointerInfo>} pointerObserver
  60010. */
  60011. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  60012. /**
  60013. * Disposes of the gizmo
  60014. */
  60015. dispose(): void;
  60016. }
  60017. }
  60018. declare module "babylonjs/Gizmos/planeDragGizmo" {
  60019. import { Observable } from "babylonjs/Misc/observable";
  60020. import { Nullable } from "babylonjs/types";
  60021. import { Vector3 } from "babylonjs/Maths/math.vector";
  60022. import { Color3 } from "babylonjs/Maths/math.color";
  60023. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60024. import { Node } from "babylonjs/node";
  60025. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  60026. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60027. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60028. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60029. import { Scene } from "babylonjs/scene";
  60030. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60031. /**
  60032. * Single plane drag gizmo
  60033. */
  60034. export class PlaneDragGizmo extends Gizmo {
  60035. /**
  60036. * Drag behavior responsible for the gizmos dragging interactions
  60037. */
  60038. dragBehavior: PointerDragBehavior;
  60039. private _pointerObserver;
  60040. /**
  60041. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60042. */
  60043. snapDistance: number;
  60044. /**
  60045. * Event that fires each time the gizmo snaps to a new location.
  60046. * * snapDistance is the the change in distance
  60047. */
  60048. onSnapObservable: Observable<{
  60049. snapDistance: number;
  60050. }>;
  60051. private _gizmoMesh;
  60052. private _coloredMaterial;
  60053. private _hoverMaterial;
  60054. private _disableMaterial;
  60055. private _isEnabled;
  60056. private _parent;
  60057. private _dragging;
  60058. /** @hidden */
  60059. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  60060. /**
  60061. * Creates a PlaneDragGizmo
  60062. * @param gizmoLayer The utility layer the gizmo will be added to
  60063. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  60064. * @param color The color of the gizmo
  60065. */
  60066. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  60067. protected _attachedNodeChanged(value: Nullable<Node>): void;
  60068. /**
  60069. * If the gizmo is enabled
  60070. */
  60071. set isEnabled(value: boolean);
  60072. get isEnabled(): boolean;
  60073. /**
  60074. * Disposes of the gizmo
  60075. */
  60076. dispose(): void;
  60077. }
  60078. }
  60079. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  60080. import { Observable } from "babylonjs/Misc/observable";
  60081. import { Nullable } from "babylonjs/types";
  60082. import { Vector3 } from "babylonjs/Maths/math.vector";
  60083. import { Color3 } from "babylonjs/Maths/math.color";
  60084. import "babylonjs/Meshes/Builders/linesBuilder";
  60085. import { Node } from "babylonjs/node";
  60086. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  60087. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60088. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60089. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  60090. /**
  60091. * Single plane rotation gizmo
  60092. */
  60093. export class PlaneRotationGizmo extends Gizmo {
  60094. /**
  60095. * Drag behavior responsible for the gizmos dragging interactions
  60096. */
  60097. dragBehavior: PointerDragBehavior;
  60098. private _pointerObserver;
  60099. /**
  60100. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  60101. */
  60102. snapDistance: number;
  60103. /**
  60104. * Event that fires each time the gizmo snaps to a new location.
  60105. * * snapDistance is the the change in distance
  60106. */
  60107. onSnapObservable: Observable<{
  60108. snapDistance: number;
  60109. }>;
  60110. private _isEnabled;
  60111. private _parent;
  60112. private _coloredMaterial;
  60113. private _hoverMaterial;
  60114. private _disableMaterial;
  60115. private _gizmoMesh;
  60116. private _rotationCircle;
  60117. private _dragging;
  60118. private static _CircleConstants;
  60119. /**
  60120. * Creates a PlaneRotationGizmo
  60121. * @param gizmoLayer The utility layer the gizmo will be added to
  60122. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  60123. * @param color The color of the gizmo
  60124. * @param tessellation Amount of tessellation to be used when creating rotation circles
  60125. * @param useEulerRotation Use and update Euler angle instead of quaternion
  60126. * @param thickness display gizmo axis thickness
  60127. */
  60128. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  60129. /** Create Geometry for Gizmo */
  60130. private _createGizmoMesh;
  60131. protected _attachedNodeChanged(value: Nullable<Node>): void;
  60132. private setupRotationCircle;
  60133. private updateRotationPath;
  60134. private updateRotationCircle;
  60135. /**
  60136. * If the gizmo is enabled
  60137. */
  60138. set isEnabled(value: boolean);
  60139. get isEnabled(): boolean;
  60140. /**
  60141. * Disposes of the gizmo
  60142. */
  60143. dispose(): void;
  60144. }
  60145. }
  60146. declare module "babylonjs/Gizmos/rotationGizmo" {
  60147. import { Observable } from "babylonjs/Misc/observable";
  60148. import { Nullable } from "babylonjs/types";
  60149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60150. import { Mesh } from "babylonjs/Meshes/mesh";
  60151. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  60152. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  60153. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60154. import { Node } from "babylonjs/node";
  60155. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  60156. /**
  60157. * Gizmo that enables rotating a mesh along 3 axis
  60158. */
  60159. export class RotationGizmo extends Gizmo {
  60160. /**
  60161. * Internal gizmo used for interactions on the x axis
  60162. */
  60163. xGizmo: PlaneRotationGizmo;
  60164. /**
  60165. * Internal gizmo used for interactions on the y axis
  60166. */
  60167. yGizmo: PlaneRotationGizmo;
  60168. /**
  60169. * Internal gizmo used for interactions on the z axis
  60170. */
  60171. zGizmo: PlaneRotationGizmo;
  60172. /** Fires an event when any of it's sub gizmos are dragged */
  60173. onDragStartObservable: Observable<unknown>;
  60174. /** Fires an event when any of it's sub gizmos are released from dragging */
  60175. onDragEndObservable: Observable<unknown>;
  60176. private _meshAttached;
  60177. private _nodeAttached;
  60178. private _observables;
  60179. /** Node Caching for quick lookup */
  60180. private _gizmoAxisCache;
  60181. get attachedMesh(): Nullable<AbstractMesh>;
  60182. set attachedMesh(mesh: Nullable<AbstractMesh>);
  60183. get attachedNode(): Nullable<Node>;
  60184. set attachedNode(node: Nullable<Node>);
  60185. protected _checkBillboardTransform(): void;
  60186. /**
  60187. * True when the mouse pointer is hovering a gizmo mesh
  60188. */
  60189. get isHovered(): boolean;
  60190. /**
  60191. * Creates a RotationGizmo
  60192. * @param gizmoLayer The utility layer the gizmo will be added to
  60193. * @param tessellation Amount of tessellation to be used when creating rotation circles
  60194. * @param useEulerRotation Use and update Euler angle instead of quaternion
  60195. * @param thickness display gizmo axis thickness
  60196. */
  60197. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  60198. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  60199. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  60200. /**
  60201. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60202. */
  60203. set snapDistance(value: number);
  60204. get snapDistance(): number;
  60205. /**
  60206. * Ratio for the scale of the gizmo (Default: 1)
  60207. */
  60208. set scaleRatio(value: number);
  60209. get scaleRatio(): number;
  60210. /**
  60211. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60212. * @param mesh Axis gizmo mesh
  60213. * @param cache Gizmo axis definition used for reactive gizmo UI
  60214. */
  60215. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  60216. /**
  60217. * Disposes of the gizmo
  60218. */
  60219. dispose(): void;
  60220. /**
  60221. * CustomMeshes are not supported by this gizmo
  60222. * @param mesh The mesh to replace the default mesh of the gizmo
  60223. */
  60224. setCustomMesh(mesh: Mesh): void;
  60225. }
  60226. }
  60227. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  60228. import { Scene } from "babylonjs/scene";
  60229. import { Vector4 } from "babylonjs/Maths/math.vector";
  60230. import { Color4 } from "babylonjs/Maths/math.color";
  60231. import { Mesh } from "babylonjs/Meshes/mesh";
  60232. import { Nullable } from "babylonjs/types";
  60233. /**
  60234. * Class containing static functions to help procedurally build meshes
  60235. */
  60236. export class PolyhedronBuilder {
  60237. /**
  60238. * Creates a polyhedron mesh
  60239. * * 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
  60240. * * The parameter `size` (positive float, default 1) sets the polygon size
  60241. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60242. * * 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 overrides the parameter `type`
  60243. * * 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
  60244. * * 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)`)
  60245. * * 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
  60246. * * 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
  60247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60250. * @param name defines the name of the mesh
  60251. * @param options defines the options used to create the mesh
  60252. * @param scene defines the hosting scene
  60253. * @returns the polyhedron mesh
  60254. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60255. */
  60256. static CreatePolyhedron(name: string, options: {
  60257. type?: number;
  60258. size?: number;
  60259. sizeX?: number;
  60260. sizeY?: number;
  60261. sizeZ?: number;
  60262. custom?: any;
  60263. faceUV?: Vector4[];
  60264. faceColors?: Color4[];
  60265. flat?: boolean;
  60266. updatable?: boolean;
  60267. sideOrientation?: number;
  60268. frontUVs?: Vector4;
  60269. backUVs?: Vector4;
  60270. }, scene?: Nullable<Scene>): Mesh;
  60271. }
  60272. }
  60273. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  60274. import { Nullable } from "babylonjs/types";
  60275. import { Scene } from "babylonjs/scene";
  60276. import { Vector4 } from "babylonjs/Maths/math.vector";
  60277. import { Color4 } from "babylonjs/Maths/math.color";
  60278. import { Mesh } from "babylonjs/Meshes/mesh";
  60279. /**
  60280. * Class containing static functions to help procedurally build meshes
  60281. */
  60282. export class BoxBuilder {
  60283. /**
  60284. * Creates a box mesh
  60285. * * The parameter `size` sets the size (float) of each box side (default 1)
  60286. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60287. * * 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)
  60288. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60292. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60293. * @param name defines the name of the mesh
  60294. * @param options defines the options used to create the mesh
  60295. * @param scene defines the hosting scene
  60296. * @returns the box mesh
  60297. */
  60298. static CreateBox(name: string, options: {
  60299. size?: number;
  60300. width?: number;
  60301. height?: number;
  60302. depth?: number;
  60303. faceUV?: Vector4[];
  60304. faceColors?: Color4[];
  60305. sideOrientation?: number;
  60306. frontUVs?: Vector4;
  60307. backUVs?: Vector4;
  60308. wrap?: boolean;
  60309. topBaseAt?: number;
  60310. bottomBaseAt?: number;
  60311. updatable?: boolean;
  60312. }, scene?: Nullable<Scene>): Mesh;
  60313. }
  60314. }
  60315. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  60316. import { Observable } from "babylonjs/Misc/observable";
  60317. import { Nullable } from "babylonjs/types";
  60318. import { Vector3 } from "babylonjs/Maths/math.vector";
  60319. import { Node } from "babylonjs/node";
  60320. import { Mesh } from "babylonjs/Meshes/mesh";
  60321. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  60322. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60323. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60324. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  60325. import { Color3 } from "babylonjs/Maths/math.color";
  60326. /**
  60327. * Single axis scale gizmo
  60328. */
  60329. export class AxisScaleGizmo extends Gizmo {
  60330. /**
  60331. * Drag behavior responsible for the gizmos dragging interactions
  60332. */
  60333. dragBehavior: PointerDragBehavior;
  60334. private _pointerObserver;
  60335. /**
  60336. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60337. */
  60338. snapDistance: number;
  60339. /**
  60340. * Event that fires each time the gizmo snaps to a new location.
  60341. * * snapDistance is the the change in distance
  60342. */
  60343. onSnapObservable: Observable<{
  60344. snapDistance: number;
  60345. }>;
  60346. /**
  60347. * If the scaling operation should be done on all axis (default: false)
  60348. */
  60349. uniformScaling: boolean;
  60350. /**
  60351. * Custom sensitivity value for the drag strength
  60352. */
  60353. sensitivity: number;
  60354. private _isEnabled;
  60355. private _parent;
  60356. private _gizmoMesh;
  60357. private _coloredMaterial;
  60358. private _hoverMaterial;
  60359. private _disableMaterial;
  60360. private _dragging;
  60361. private _tmpVector;
  60362. private _tmpMatrix;
  60363. private _tmpMatrix2;
  60364. /**
  60365. * Creates an AxisScaleGizmo
  60366. * @param gizmoLayer The utility layer the gizmo will be added to
  60367. * @param dragAxis The axis which the gizmo will be able to scale on
  60368. * @param color The color of the gizmo
  60369. * @param thickness display gizmo axis thickness
  60370. */
  60371. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  60372. /** Create Geometry for Gizmo */
  60373. private _createGizmoMesh;
  60374. protected _attachedNodeChanged(value: Nullable<Node>): void;
  60375. /**
  60376. * If the gizmo is enabled
  60377. */
  60378. set isEnabled(value: boolean);
  60379. get isEnabled(): boolean;
  60380. /**
  60381. * Disposes of the gizmo
  60382. */
  60383. dispose(): void;
  60384. /**
  60385. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  60386. * @param mesh The mesh to replace the default mesh of the gizmo
  60387. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  60388. */
  60389. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  60390. }
  60391. }
  60392. declare module "babylonjs/Gizmos/scaleGizmo" {
  60393. import { Observable } from "babylonjs/Misc/observable";
  60394. import { Nullable } from "babylonjs/types";
  60395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60396. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  60397. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  60398. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60399. import { Mesh } from "babylonjs/Meshes/mesh";
  60400. import { Node } from "babylonjs/node";
  60401. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  60402. /**
  60403. * Gizmo that enables scaling a mesh along 3 axis
  60404. */
  60405. export class ScaleGizmo extends Gizmo {
  60406. /**
  60407. * Internal gizmo used for interactions on the x axis
  60408. */
  60409. xGizmo: AxisScaleGizmo;
  60410. /**
  60411. * Internal gizmo used for interactions on the y axis
  60412. */
  60413. yGizmo: AxisScaleGizmo;
  60414. /**
  60415. * Internal gizmo used for interactions on the z axis
  60416. */
  60417. zGizmo: AxisScaleGizmo;
  60418. /**
  60419. * Internal gizmo used to scale all axis equally
  60420. */
  60421. uniformScaleGizmo: AxisScaleGizmo;
  60422. private _meshAttached;
  60423. private _nodeAttached;
  60424. private _snapDistance;
  60425. private _uniformScalingMesh;
  60426. private _octahedron;
  60427. private _sensitivity;
  60428. private _coloredMaterial;
  60429. private _hoverMaterial;
  60430. private _disableMaterial;
  60431. private _observables;
  60432. /** Node Caching for quick lookup */
  60433. private _gizmoAxisCache;
  60434. /** Fires an event when any of it's sub gizmos are dragged */
  60435. onDragStartObservable: Observable<unknown>;
  60436. /** Fires an event when any of it's sub gizmos are released from dragging */
  60437. onDragEndObservable: Observable<unknown>;
  60438. get attachedMesh(): Nullable<AbstractMesh>;
  60439. set attachedMesh(mesh: Nullable<AbstractMesh>);
  60440. get attachedNode(): Nullable<Node>;
  60441. set attachedNode(node: Nullable<Node>);
  60442. /**
  60443. * True when the mouse pointer is hovering a gizmo mesh
  60444. */
  60445. get isHovered(): boolean;
  60446. /**
  60447. * Creates a ScaleGizmo
  60448. * @param gizmoLayer The utility layer the gizmo will be added to
  60449. * @param thickness display gizmo axis thickness
  60450. */
  60451. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  60452. /** Create Geometry for Gizmo */
  60453. private _createUniformScaleMesh;
  60454. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  60455. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  60456. /**
  60457. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60458. */
  60459. set snapDistance(value: number);
  60460. get snapDistance(): number;
  60461. /**
  60462. * Ratio for the scale of the gizmo (Default: 1)
  60463. */
  60464. set scaleRatio(value: number);
  60465. get scaleRatio(): number;
  60466. /**
  60467. * Sensitivity factor for dragging (Default: 1)
  60468. */
  60469. set sensitivity(value: number);
  60470. get sensitivity(): number;
  60471. /**
  60472. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60473. * @param mesh Axis gizmo mesh
  60474. * @param cache Gizmo axis definition used for reactive gizmo UI
  60475. */
  60476. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  60477. /**
  60478. * Disposes of the gizmo
  60479. */
  60480. dispose(): void;
  60481. }
  60482. }
  60483. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  60484. import { Observable } from "babylonjs/Misc/observable";
  60485. import { Nullable } from "babylonjs/types";
  60486. import { Vector3 } from "babylonjs/Maths/math.vector";
  60487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60488. import { Mesh } from "babylonjs/Meshes/mesh";
  60489. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60490. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60491. import { Color3 } from "babylonjs/Maths/math.color";
  60492. import "babylonjs/Meshes/Builders/boxBuilder";
  60493. /**
  60494. * Bounding box gizmo
  60495. */
  60496. export class BoundingBoxGizmo extends Gizmo {
  60497. private _lineBoundingBox;
  60498. private _rotateSpheresParent;
  60499. private _scaleBoxesParent;
  60500. private _boundingDimensions;
  60501. private _renderObserver;
  60502. private _pointerObserver;
  60503. private _scaleDragSpeed;
  60504. private _tmpQuaternion;
  60505. private _tmpVector;
  60506. private _tmpRotationMatrix;
  60507. /**
  60508. * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  60509. */
  60510. ignoreChildren: boolean;
  60511. /**
  60512. * 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)
  60513. */
  60514. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  60515. /**
  60516. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  60517. */
  60518. rotationSphereSize: number;
  60519. /**
  60520. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  60521. */
  60522. scaleBoxSize: number;
  60523. /**
  60524. * 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)
  60525. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  60526. */
  60527. fixedDragMeshScreenSize: boolean;
  60528. /**
  60529. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  60530. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  60531. */
  60532. fixedDragMeshBoundsSize: boolean;
  60533. /**
  60534. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  60535. */
  60536. fixedDragMeshScreenSizeDistanceFactor: number;
  60537. /**
  60538. * Fired when a rotation sphere or scale box is dragged
  60539. */
  60540. onDragStartObservable: Observable<{}>;
  60541. /**
  60542. * Fired when a scale box is dragged
  60543. */
  60544. onScaleBoxDragObservable: Observable<{}>;
  60545. /**
  60546. * Fired when a scale box drag is ended
  60547. */
  60548. onScaleBoxDragEndObservable: Observable<{}>;
  60549. /**
  60550. * Fired when a rotation sphere is dragged
  60551. */
  60552. onRotationSphereDragObservable: Observable<{}>;
  60553. /**
  60554. * Fired when a rotation sphere drag is ended
  60555. */
  60556. onRotationSphereDragEndObservable: Observable<{}>;
  60557. /**
  60558. * 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)
  60559. */
  60560. scalePivot: Nullable<Vector3>;
  60561. /**
  60562. * Mesh used as a pivot to rotate the attached node
  60563. */
  60564. private _anchorMesh;
  60565. private _existingMeshScale;
  60566. private _dragMesh;
  60567. private pointerDragBehavior;
  60568. private coloredMaterial;
  60569. private hoverColoredMaterial;
  60570. /**
  60571. * Sets the color of the bounding box gizmo
  60572. * @param color the color to set
  60573. */
  60574. setColor(color: Color3): void;
  60575. /**
  60576. * Creates an BoundingBoxGizmo
  60577. * @param gizmoLayer The utility layer the gizmo will be added to
  60578. * @param color The color of the gizmo
  60579. */
  60580. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  60581. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  60582. private _selectNode;
  60583. /**
  60584. * Updates the bounding box information for the Gizmo
  60585. */
  60586. updateBoundingBox(): void;
  60587. private _updateRotationSpheres;
  60588. private _updateScaleBoxes;
  60589. /**
  60590. * Enables rotation on the specified axis and disables rotation on the others
  60591. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  60592. */
  60593. setEnabledRotationAxis(axis: string): void;
  60594. /**
  60595. * Enables/disables scaling
  60596. * @param enable if scaling should be enabled
  60597. * @param homogeneousScaling defines if scaling should only be homogeneous
  60598. */
  60599. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  60600. private _updateDummy;
  60601. /**
  60602. * Enables a pointer drag behavior on the bounding box of the gizmo
  60603. */
  60604. enableDragBehavior(): void;
  60605. /**
  60606. * Disposes of the gizmo
  60607. */
  60608. dispose(): void;
  60609. /**
  60610. * 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)
  60611. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  60612. * @returns the bounding box mesh with the passed in mesh as a child
  60613. */
  60614. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  60615. /**
  60616. * CustomMeshes are not supported by this gizmo
  60617. * @param mesh The mesh to replace the default mesh of the gizmo
  60618. */
  60619. setCustomMesh(mesh: Mesh): void;
  60620. }
  60621. }
  60622. declare module "babylonjs/Gizmos/gizmoManager" {
  60623. import { Observable } from "babylonjs/Misc/observable";
  60624. import { Nullable } from "babylonjs/types";
  60625. import { Scene, IDisposable } from "babylonjs/scene";
  60626. import { Node } from "babylonjs/node";
  60627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60628. import { Mesh } from "babylonjs/Meshes/mesh";
  60629. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60630. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  60631. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  60632. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  60633. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60634. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  60635. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  60636. /**
  60637. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  60638. */
  60639. export class GizmoManager implements IDisposable {
  60640. private scene;
  60641. /**
  60642. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  60643. */
  60644. gizmos: {
  60645. positionGizmo: Nullable<PositionGizmo>;
  60646. rotationGizmo: Nullable<RotationGizmo>;
  60647. scaleGizmo: Nullable<ScaleGizmo>;
  60648. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  60649. };
  60650. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  60651. clearGizmoOnEmptyPointerEvent: boolean;
  60652. /** Fires an event when the manager is attached to a mesh */
  60653. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  60654. /** Fires an event when the manager is attached to a node */
  60655. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  60656. private _gizmosEnabled;
  60657. private _pointerObservers;
  60658. private _attachedMesh;
  60659. private _attachedNode;
  60660. private _boundingBoxColor;
  60661. private _defaultUtilityLayer;
  60662. private _defaultKeepDepthUtilityLayer;
  60663. private _thickness;
  60664. /** Node Caching for quick lookup */
  60665. private _gizmoAxisCache;
  60666. /**
  60667. * When bounding box gizmo is enabled, this can be used to track drag/end events
  60668. */
  60669. boundingBoxDragBehavior: SixDofDragBehavior;
  60670. /**
  60671. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  60672. */
  60673. attachableMeshes: Nullable<Array<AbstractMesh>>;
  60674. /**
  60675. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  60676. */
  60677. attachableNodes: Nullable<Array<Node>>;
  60678. /**
  60679. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  60680. */
  60681. usePointerToAttachGizmos: boolean;
  60682. /**
  60683. * Utility layer that the bounding box gizmo belongs to
  60684. */
  60685. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  60686. /**
  60687. * Utility layer that all gizmos besides bounding box belong to
  60688. */
  60689. get utilityLayer(): UtilityLayerRenderer;
  60690. /**
  60691. * True when the mouse pointer is hovering a gizmo mesh
  60692. */
  60693. get isHovered(): boolean;
  60694. /**
  60695. * Instantiates a gizmo manager
  60696. * @param scene the scene to overlay the gizmos on top of
  60697. * @param thickness display gizmo axis thickness
  60698. * @param utilityLayer the layer where gizmos are rendered
  60699. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  60700. */
  60701. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  60702. /**
  60703. * Subscribes to pointer down events, for attaching and detaching mesh
  60704. * @param scene The scene layer the observer will be added to
  60705. */
  60706. private _attachToMeshPointerObserver;
  60707. /**
  60708. * Attaches a set of gizmos to the specified mesh
  60709. * @param mesh The mesh the gizmo's should be attached to
  60710. */
  60711. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60712. /**
  60713. * Attaches a set of gizmos to the specified node
  60714. * @param node The node the gizmo's should be attached to
  60715. */
  60716. attachToNode(node: Nullable<Node>): void;
  60717. /**
  60718. * If the position gizmo is enabled
  60719. */
  60720. set positionGizmoEnabled(value: boolean);
  60721. get positionGizmoEnabled(): boolean;
  60722. /**
  60723. * If the rotation gizmo is enabled
  60724. */
  60725. set rotationGizmoEnabled(value: boolean);
  60726. get rotationGizmoEnabled(): boolean;
  60727. /**
  60728. * If the scale gizmo is enabled
  60729. */
  60730. set scaleGizmoEnabled(value: boolean);
  60731. get scaleGizmoEnabled(): boolean;
  60732. /**
  60733. * If the boundingBox gizmo is enabled
  60734. */
  60735. set boundingBoxGizmoEnabled(value: boolean);
  60736. get boundingBoxGizmoEnabled(): boolean;
  60737. /**
  60738. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60739. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  60740. */
  60741. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  60742. /**
  60743. * Disposes of the gizmo manager
  60744. */
  60745. dispose(): void;
  60746. }
  60747. }
  60748. declare module "babylonjs/Gizmos/positionGizmo" {
  60749. import { Observable } from "babylonjs/Misc/observable";
  60750. import { Nullable } from "babylonjs/types";
  60751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60752. import { Node } from "babylonjs/node";
  60753. import { Mesh } from "babylonjs/Meshes/mesh";
  60754. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  60755. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  60756. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  60757. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60758. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  60759. /**
  60760. * Gizmo that enables dragging a mesh along 3 axis
  60761. */
  60762. export class PositionGizmo extends Gizmo {
  60763. /**
  60764. * Internal gizmo used for interactions on the x axis
  60765. */
  60766. xGizmo: AxisDragGizmo;
  60767. /**
  60768. * Internal gizmo used for interactions on the y axis
  60769. */
  60770. yGizmo: AxisDragGizmo;
  60771. /**
  60772. * Internal gizmo used for interactions on the z axis
  60773. */
  60774. zGizmo: AxisDragGizmo;
  60775. /**
  60776. * Internal gizmo used for interactions on the yz plane
  60777. */
  60778. xPlaneGizmo: PlaneDragGizmo;
  60779. /**
  60780. * Internal gizmo used for interactions on the xz plane
  60781. */
  60782. yPlaneGizmo: PlaneDragGizmo;
  60783. /**
  60784. * Internal gizmo used for interactions on the xy plane
  60785. */
  60786. zPlaneGizmo: PlaneDragGizmo;
  60787. /**
  60788. * private variables
  60789. */
  60790. private _meshAttached;
  60791. private _nodeAttached;
  60792. private _snapDistance;
  60793. private _observables;
  60794. /** Node Caching for quick lookup */
  60795. private _gizmoAxisCache;
  60796. /** Fires an event when any of it's sub gizmos are dragged */
  60797. onDragStartObservable: Observable<unknown>;
  60798. /** Fires an event when any of it's sub gizmos are released from dragging */
  60799. onDragEndObservable: Observable<unknown>;
  60800. /**
  60801. * If set to true, planar drag is enabled
  60802. */
  60803. private _planarGizmoEnabled;
  60804. get attachedMesh(): Nullable<AbstractMesh>;
  60805. set attachedMesh(mesh: Nullable<AbstractMesh>);
  60806. get attachedNode(): Nullable<Node>;
  60807. set attachedNode(node: Nullable<Node>);
  60808. /**
  60809. * True when the mouse pointer is hovering a gizmo mesh
  60810. */
  60811. get isHovered(): boolean;
  60812. /**
  60813. * Creates a PositionGizmo
  60814. * @param gizmoLayer The utility layer the gizmo will be added to
  60815. @param thickness display gizmo axis thickness
  60816. */
  60817. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  60818. /**
  60819. * If the planar drag gizmo is enabled
  60820. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  60821. */
  60822. set planarGizmoEnabled(value: boolean);
  60823. get planarGizmoEnabled(): boolean;
  60824. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  60825. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  60826. /**
  60827. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60828. */
  60829. set snapDistance(value: number);
  60830. get snapDistance(): number;
  60831. /**
  60832. * Ratio for the scale of the gizmo (Default: 1)
  60833. */
  60834. set scaleRatio(value: number);
  60835. get scaleRatio(): number;
  60836. /**
  60837. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60838. * @param mesh Axis gizmo mesh
  60839. * @param cache Gizmo axis definition used for reactive gizmo UI
  60840. */
  60841. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  60842. /**
  60843. * Disposes of the gizmo
  60844. */
  60845. dispose(): void;
  60846. /**
  60847. * CustomMeshes are not supported by this gizmo
  60848. * @param mesh The mesh to replace the default mesh of the gizmo
  60849. */
  60850. setCustomMesh(mesh: Mesh): void;
  60851. }
  60852. }
  60853. declare module "babylonjs/Gizmos/axisDragGizmo" {
  60854. import { Observable } from "babylonjs/Misc/observable";
  60855. import { Nullable } from "babylonjs/types";
  60856. import { Vector3 } from "babylonjs/Maths/math.vector";
  60857. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60858. import { Node } from "babylonjs/node";
  60859. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  60860. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60861. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60862. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60863. import { Scene } from "babylonjs/scene";
  60864. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60865. import { Color3 } from "babylonjs/Maths/math.color";
  60866. /**
  60867. * Single axis drag gizmo
  60868. */
  60869. export class AxisDragGizmo extends Gizmo {
  60870. /**
  60871. * Drag behavior responsible for the gizmos dragging interactions
  60872. */
  60873. dragBehavior: PointerDragBehavior;
  60874. private _pointerObserver;
  60875. /**
  60876. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60877. */
  60878. snapDistance: number;
  60879. /**
  60880. * Event that fires each time the gizmo snaps to a new location.
  60881. * * snapDistance is the the change in distance
  60882. */
  60883. onSnapObservable: Observable<{
  60884. snapDistance: number;
  60885. }>;
  60886. private _isEnabled;
  60887. private _parent;
  60888. private _gizmoMesh;
  60889. private _coloredMaterial;
  60890. private _hoverMaterial;
  60891. private _disableMaterial;
  60892. private _dragging;
  60893. /** @hidden */
  60894. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  60895. /** @hidden */
  60896. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  60897. /**
  60898. * Creates an AxisDragGizmo
  60899. * @param gizmoLayer The utility layer the gizmo will be added to
  60900. * @param dragAxis The axis which the gizmo will be able to drag on
  60901. * @param color The color of the gizmo
  60902. * @param thickness display gizmo axis thickness
  60903. */
  60904. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  60905. protected _attachedNodeChanged(value: Nullable<Node>): void;
  60906. /**
  60907. * If the gizmo is enabled
  60908. */
  60909. set isEnabled(value: boolean);
  60910. get isEnabled(): boolean;
  60911. /**
  60912. * Disposes of the gizmo
  60913. */
  60914. dispose(): void;
  60915. }
  60916. }
  60917. declare module "babylonjs/Debug/axesViewer" {
  60918. import { Vector3 } from "babylonjs/Maths/math.vector";
  60919. import { Nullable } from "babylonjs/types";
  60920. import { Scene } from "babylonjs/scene";
  60921. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60922. /**
  60923. * The Axes viewer will show 3 axes in a specific point in space
  60924. */
  60925. export class AxesViewer {
  60926. private _xAxis;
  60927. private _yAxis;
  60928. private _zAxis;
  60929. private _scaleLinesFactor;
  60930. private _instanced;
  60931. /**
  60932. * Gets the hosting scene
  60933. */
  60934. scene: Nullable<Scene>;
  60935. /**
  60936. * Gets or sets a number used to scale line length
  60937. */
  60938. scaleLines: number;
  60939. /** Gets the node hierarchy used to render x-axis */
  60940. get xAxis(): TransformNode;
  60941. /** Gets the node hierarchy used to render y-axis */
  60942. get yAxis(): TransformNode;
  60943. /** Gets the node hierarchy used to render z-axis */
  60944. get zAxis(): TransformNode;
  60945. /**
  60946. * Creates a new AxesViewer
  60947. * @param scene defines the hosting scene
  60948. * @param scaleLines defines a number used to scale line length (1 by default)
  60949. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  60950. * @param xAxis defines the node hierarchy used to render the x-axis
  60951. * @param yAxis defines the node hierarchy used to render the y-axis
  60952. * @param zAxis defines the node hierarchy used to render the z-axis
  60953. */
  60954. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  60955. /**
  60956. * Force the viewer to update
  60957. * @param position defines the position of the viewer
  60958. * @param xaxis defines the x axis of the viewer
  60959. * @param yaxis defines the y axis of the viewer
  60960. * @param zaxis defines the z axis of the viewer
  60961. */
  60962. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  60963. /**
  60964. * Creates an instance of this axes viewer.
  60965. * @returns a new axes viewer with instanced meshes
  60966. */
  60967. createInstance(): AxesViewer;
  60968. /** Releases resources */
  60969. dispose(): void;
  60970. private static _SetRenderingGroupId;
  60971. }
  60972. }
  60973. declare module "babylonjs/Debug/boneAxesViewer" {
  60974. import { Nullable } from "babylonjs/types";
  60975. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  60976. import { Vector3 } from "babylonjs/Maths/math.vector";
  60977. import { Mesh } from "babylonjs/Meshes/mesh";
  60978. import { Bone } from "babylonjs/Bones/bone";
  60979. import { Scene } from "babylonjs/scene";
  60980. /**
  60981. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  60982. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  60983. */
  60984. export class BoneAxesViewer extends AxesViewer {
  60985. /**
  60986. * Gets or sets the target mesh where to display the axes viewer
  60987. */
  60988. mesh: Nullable<Mesh>;
  60989. /**
  60990. * Gets or sets the target bone where to display the axes viewer
  60991. */
  60992. bone: Nullable<Bone>;
  60993. /** Gets current position */
  60994. pos: Vector3;
  60995. /** Gets direction of X axis */
  60996. xaxis: Vector3;
  60997. /** Gets direction of Y axis */
  60998. yaxis: Vector3;
  60999. /** Gets direction of Z axis */
  61000. zaxis: Vector3;
  61001. /**
  61002. * Creates a new BoneAxesViewer
  61003. * @param scene defines the hosting scene
  61004. * @param bone defines the target bone
  61005. * @param mesh defines the target mesh
  61006. * @param scaleLines defines a scaling factor for line length (1 by default)
  61007. */
  61008. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  61009. /**
  61010. * Force the viewer to update
  61011. */
  61012. update(): void;
  61013. /** Releases resources */
  61014. dispose(): void;
  61015. }
  61016. }
  61017. declare module "babylonjs/Debug/debugLayer" {
  61018. import { Scene } from "babylonjs/scene";
  61019. /**
  61020. * Interface used to define scene explorer extensibility option
  61021. */
  61022. export interface IExplorerExtensibilityOption {
  61023. /**
  61024. * Define the option label
  61025. */
  61026. label: string;
  61027. /**
  61028. * Defines the action to execute on click
  61029. */
  61030. action: (entity: any) => void;
  61031. }
  61032. /**
  61033. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  61034. */
  61035. export interface IExplorerExtensibilityGroup {
  61036. /**
  61037. * Defines a predicate to test if a given type mut be extended
  61038. */
  61039. predicate: (entity: any) => boolean;
  61040. /**
  61041. * Gets the list of options added to a type
  61042. */
  61043. entries: IExplorerExtensibilityOption[];
  61044. }
  61045. /**
  61046. * Interface used to define the options to use to create the Inspector
  61047. */
  61048. export interface IInspectorOptions {
  61049. /**
  61050. * Display in overlay mode (default: false)
  61051. */
  61052. overlay?: boolean;
  61053. /**
  61054. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  61055. */
  61056. globalRoot?: HTMLElement;
  61057. /**
  61058. * Display the Scene explorer
  61059. */
  61060. showExplorer?: boolean;
  61061. /**
  61062. * Display the property inspector
  61063. */
  61064. showInspector?: boolean;
  61065. /**
  61066. * Display in embed mode (both panes on the right)
  61067. */
  61068. embedMode?: boolean;
  61069. /**
  61070. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  61071. */
  61072. handleResize?: boolean;
  61073. /**
  61074. * Allow the panes to popup (default: true)
  61075. */
  61076. enablePopup?: boolean;
  61077. /**
  61078. * Allow the panes to be closed by users (default: true)
  61079. */
  61080. enableClose?: boolean;
  61081. /**
  61082. * Optional list of extensibility entries
  61083. */
  61084. explorerExtensibility?: IExplorerExtensibilityGroup[];
  61085. /**
  61086. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  61087. */
  61088. inspectorURL?: string;
  61089. /**
  61090. * Optional initial tab (default to DebugLayerTab.Properties)
  61091. */
  61092. initialTab?: DebugLayerTab;
  61093. }
  61094. module "babylonjs/scene" {
  61095. interface Scene {
  61096. /**
  61097. * @hidden
  61098. * Backing field
  61099. */
  61100. _debugLayer: DebugLayer;
  61101. /**
  61102. * Gets the debug layer (aka Inspector) associated with the scene
  61103. * @see https://doc.babylonjs.com/features/playground_debuglayer
  61104. */
  61105. debugLayer: DebugLayer;
  61106. }
  61107. }
  61108. /**
  61109. * Enum of inspector action tab
  61110. */
  61111. export enum DebugLayerTab {
  61112. /**
  61113. * Properties tag (default)
  61114. */
  61115. Properties = 0,
  61116. /**
  61117. * Debug tab
  61118. */
  61119. Debug = 1,
  61120. /**
  61121. * Statistics tab
  61122. */
  61123. Statistics = 2,
  61124. /**
  61125. * Tools tab
  61126. */
  61127. Tools = 3,
  61128. /**
  61129. * Settings tab
  61130. */
  61131. Settings = 4
  61132. }
  61133. /**
  61134. * The debug layer (aka Inspector) is the go to tool in order to better understand
  61135. * what is happening in your scene
  61136. * @see https://doc.babylonjs.com/features/playground_debuglayer
  61137. */
  61138. export class DebugLayer {
  61139. /**
  61140. * Define the url to get the inspector script from.
  61141. * By default it uses the babylonjs CDN.
  61142. * @ignoreNaming
  61143. */
  61144. static InspectorURL: string;
  61145. private _scene;
  61146. private BJSINSPECTOR;
  61147. private _onPropertyChangedObservable?;
  61148. /**
  61149. * Observable triggered when a property is changed through the inspector.
  61150. */
  61151. get onPropertyChangedObservable(): any;
  61152. /**
  61153. * Instantiates a new debug layer.
  61154. * The debug layer (aka Inspector) is the go to tool in order to better understand
  61155. * what is happening in your scene
  61156. * @see https://doc.babylonjs.com/features/playground_debuglayer
  61157. * @param scene Defines the scene to inspect
  61158. */
  61159. constructor(scene: Scene);
  61160. /** Creates the inspector window. */
  61161. private _createInspector;
  61162. /**
  61163. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  61164. * @param entity defines the entity to select
  61165. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  61166. */
  61167. select(entity: any, lineContainerTitles?: string | string[]): void;
  61168. /** Get the inspector from bundle or global */
  61169. private _getGlobalInspector;
  61170. /**
  61171. * Get if the inspector is visible or not.
  61172. * @returns true if visible otherwise, false
  61173. */
  61174. isVisible(): boolean;
  61175. /**
  61176. * Hide the inspector and close its window.
  61177. */
  61178. hide(): void;
  61179. /**
  61180. * Update the scene in the inspector
  61181. */
  61182. setAsActiveScene(): void;
  61183. /**
  61184. * Launch the debugLayer.
  61185. * @param config Define the configuration of the inspector
  61186. * @return a promise fulfilled when the debug layer is visible
  61187. */
  61188. show(config?: IInspectorOptions): Promise<DebugLayer>;
  61189. }
  61190. }
  61191. declare module "babylonjs/Debug/physicsViewer" {
  61192. import { Nullable } from "babylonjs/types";
  61193. import { Scene } from "babylonjs/scene";
  61194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61195. import { Mesh } from "babylonjs/Meshes/mesh";
  61196. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61197. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61198. /**
  61199. * Used to show the physics impostor around the specific mesh
  61200. */
  61201. export class PhysicsViewer {
  61202. /** @hidden */
  61203. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  61204. /** @hidden */
  61205. protected _meshes: Array<Nullable<AbstractMesh>>;
  61206. /** @hidden */
  61207. protected _scene: Nullable<Scene>;
  61208. /** @hidden */
  61209. protected _numMeshes: number;
  61210. /** @hidden */
  61211. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  61212. private _renderFunction;
  61213. private _utilityLayer;
  61214. private _debugBoxMesh;
  61215. private _debugSphereMesh;
  61216. private _debugCylinderMesh;
  61217. private _debugMaterial;
  61218. private _debugMeshMeshes;
  61219. /**
  61220. * Creates a new PhysicsViewer
  61221. * @param scene defines the hosting scene
  61222. */
  61223. constructor(scene: Scene);
  61224. /** @hidden */
  61225. protected _updateDebugMeshes(): void;
  61226. /**
  61227. * Renders a specified physic impostor
  61228. * @param impostor defines the impostor to render
  61229. * @param targetMesh defines the mesh represented by the impostor
  61230. * @returns the new debug mesh used to render the impostor
  61231. */
  61232. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  61233. /**
  61234. * Hides a specified physic impostor
  61235. * @param impostor defines the impostor to hide
  61236. */
  61237. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  61238. private _getDebugMaterial;
  61239. private _getDebugBoxMesh;
  61240. private _getDebugSphereMesh;
  61241. private _getDebugCylinderMesh;
  61242. private _getDebugMeshMesh;
  61243. private _getDebugMesh;
  61244. /** Releases all resources */
  61245. dispose(): void;
  61246. }
  61247. }
  61248. declare module "babylonjs/Debug/rayHelper" {
  61249. import { Nullable } from "babylonjs/types";
  61250. import { Ray } from "babylonjs/Culling/ray";
  61251. import { Vector3 } from "babylonjs/Maths/math.vector";
  61252. import { Color3 } from "babylonjs/Maths/math.color";
  61253. import { Scene } from "babylonjs/scene";
  61254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61255. import "babylonjs/Meshes/Builders/linesBuilder";
  61256. /**
  61257. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  61258. * in order to better appreciate the issue one might have.
  61259. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  61260. */
  61261. export class RayHelper {
  61262. /**
  61263. * Defines the ray we are currently tryin to visualize.
  61264. */
  61265. ray: Nullable<Ray>;
  61266. private _renderPoints;
  61267. private _renderLine;
  61268. private _renderFunction;
  61269. private _scene;
  61270. private _onAfterRenderObserver;
  61271. private _onAfterStepObserver;
  61272. private _attachedToMesh;
  61273. private _meshSpaceDirection;
  61274. private _meshSpaceOrigin;
  61275. /**
  61276. * Helper function to create a colored helper in a scene in one line.
  61277. * @param ray Defines the ray we are currently tryin to visualize
  61278. * @param scene Defines the scene the ray is used in
  61279. * @param color Defines the color we want to see the ray in
  61280. * @returns The newly created ray helper.
  61281. */
  61282. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  61283. /**
  61284. * Instantiate a new ray helper.
  61285. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  61286. * in order to better appreciate the issue one might have.
  61287. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  61288. * @param ray Defines the ray we are currently tryin to visualize
  61289. */
  61290. constructor(ray: Ray);
  61291. /**
  61292. * Shows the ray we are willing to debug.
  61293. * @param scene Defines the scene the ray needs to be rendered in
  61294. * @param color Defines the color the ray needs to be rendered in
  61295. */
  61296. show(scene: Scene, color?: Color3): void;
  61297. /**
  61298. * Hides the ray we are debugging.
  61299. */
  61300. hide(): void;
  61301. private _render;
  61302. /**
  61303. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  61304. * @param mesh Defines the mesh we want the helper attached to
  61305. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  61306. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  61307. * @param length Defines the length of the ray
  61308. */
  61309. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  61310. /**
  61311. * Detach the ray helper from the mesh it has previously been attached to.
  61312. */
  61313. detachFromMesh(): void;
  61314. private _updateToMesh;
  61315. /**
  61316. * Dispose the helper and release its associated resources.
  61317. */
  61318. dispose(): void;
  61319. }
  61320. }
  61321. declare module "babylonjs/Debug/ISkeletonViewer" {
  61322. import { Skeleton } from "babylonjs/Bones/skeleton";
  61323. import { Color3 } from "babylonjs/Maths/math.color";
  61324. /**
  61325. * Defines the options associated with the creation of a SkeletonViewer.
  61326. */
  61327. export interface ISkeletonViewerOptions {
  61328. /** Should the system pause animations before building the Viewer? */
  61329. pauseAnimations: boolean;
  61330. /** Should the system return the skeleton to rest before building? */
  61331. returnToRest: boolean;
  61332. /** public Display Mode of the Viewer */
  61333. displayMode: number;
  61334. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  61335. displayOptions: ISkeletonViewerDisplayOptions;
  61336. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  61337. computeBonesUsingShaders: boolean;
  61338. /** Flag ignore non weighted bones */
  61339. useAllBones: boolean;
  61340. }
  61341. /**
  61342. * Defines how to display the various bone meshes for the viewer.
  61343. */
  61344. export interface ISkeletonViewerDisplayOptions {
  61345. /** How far down to start tapering the bone spurs */
  61346. midStep?: number;
  61347. /** How big is the midStep? */
  61348. midStepFactor?: number;
  61349. /** Base for the Sphere Size */
  61350. sphereBaseSize?: number;
  61351. /** The ratio of the sphere to the longest bone in units */
  61352. sphereScaleUnit?: number;
  61353. /** Ratio for the Sphere Size */
  61354. sphereFactor?: number;
  61355. /** Whether a spur should attach its far end to the child bone position */
  61356. spurFollowsChild?: boolean;
  61357. /** Whether to show local axes or not */
  61358. showLocalAxes?: boolean;
  61359. /** Length of each local axis */
  61360. localAxesSize?: number;
  61361. }
  61362. /**
  61363. * Defines the constructor options for the BoneWeight Shader.
  61364. */
  61365. export interface IBoneWeightShaderOptions {
  61366. /** Skeleton to Map */
  61367. skeleton: Skeleton;
  61368. /** Colors for Uninfluenced bones */
  61369. colorBase?: Color3;
  61370. /** Colors for 0.0-0.25 Weight bones */
  61371. colorZero?: Color3;
  61372. /** Color for 0.25-0.5 Weight Influence */
  61373. colorQuarter?: Color3;
  61374. /** Color for 0.5-0.75 Weight Influence */
  61375. colorHalf?: Color3;
  61376. /** Color for 0.75-1 Weight Influence */
  61377. colorFull?: Color3;
  61378. /** Color for Zero Weight Influence */
  61379. targetBoneIndex?: number;
  61380. }
  61381. /**
  61382. * Simple structure of the gradient steps for the Color Map.
  61383. */
  61384. export interface ISkeletonMapShaderColorMapKnot {
  61385. /** Color of the Knot */
  61386. color: Color3;
  61387. /** Location of the Knot */
  61388. location: number;
  61389. }
  61390. /**
  61391. * Defines the constructor options for the SkeletonMap Shader.
  61392. */
  61393. export interface ISkeletonMapShaderOptions {
  61394. /** Skeleton to Map */
  61395. skeleton: Skeleton;
  61396. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  61397. colorMap?: ISkeletonMapShaderColorMapKnot[];
  61398. }
  61399. }
  61400. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  61401. import { Nullable } from "babylonjs/types";
  61402. import { Scene } from "babylonjs/scene";
  61403. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  61404. import { Color4 } from "babylonjs/Maths/math.color";
  61405. import { Mesh } from "babylonjs/Meshes/mesh";
  61406. /**
  61407. * Class containing static functions to help procedurally build meshes
  61408. */
  61409. export class RibbonBuilder {
  61410. /**
  61411. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61412. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61413. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61414. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61415. * * 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
  61416. * * 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
  61417. * * 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
  61418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61421. * * 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
  61422. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61423. * * 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
  61424. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61426. * @param name defines the name of the mesh
  61427. * @param options defines the options used to create the mesh
  61428. * @param scene defines the hosting scene
  61429. * @returns the ribbon mesh
  61430. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61432. */
  61433. static CreateRibbon(name: string, options: {
  61434. pathArray: Vector3[][];
  61435. closeArray?: boolean;
  61436. closePath?: boolean;
  61437. offset?: number;
  61438. updatable?: boolean;
  61439. sideOrientation?: number;
  61440. frontUVs?: Vector4;
  61441. backUVs?: Vector4;
  61442. instance?: Mesh;
  61443. invertUV?: boolean;
  61444. uvs?: Vector2[];
  61445. colors?: Color4[];
  61446. }, scene?: Nullable<Scene>): Mesh;
  61447. }
  61448. }
  61449. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  61450. import { Nullable } from "babylonjs/types";
  61451. import { Scene } from "babylonjs/scene";
  61452. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61453. import { Mesh } from "babylonjs/Meshes/mesh";
  61454. /**
  61455. * Class containing static functions to help procedurally build meshes
  61456. */
  61457. export class ShapeBuilder {
  61458. /**
  61459. * 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.
  61460. * * 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.
  61461. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61462. * * 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.
  61463. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61464. * * 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
  61465. * * 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
  61466. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61471. * @param name defines the name of the mesh
  61472. * @param options defines the options used to create the mesh
  61473. * @param scene defines the hosting scene
  61474. * @returns the extruded shape mesh
  61475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61476. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61477. */
  61478. static ExtrudeShape(name: string, options: {
  61479. shape: Vector3[];
  61480. path: Vector3[];
  61481. scale?: number;
  61482. rotation?: number;
  61483. cap?: number;
  61484. updatable?: boolean;
  61485. sideOrientation?: number;
  61486. frontUVs?: Vector4;
  61487. backUVs?: Vector4;
  61488. instance?: Mesh;
  61489. invertUV?: boolean;
  61490. }, scene?: Nullable<Scene>): Mesh;
  61491. /**
  61492. * Creates an custom extruded shape mesh.
  61493. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61494. * * 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.
  61495. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61496. * * 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 beginning of the path
  61497. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61498. * * 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 beginning of the path
  61499. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61500. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61501. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61502. * * 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
  61503. * * 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
  61504. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61507. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61509. * @param name defines the name of the mesh
  61510. * @param options defines the options used to create the mesh
  61511. * @param scene defines the hosting scene
  61512. * @returns the custom extruded shape mesh
  61513. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61516. */
  61517. static ExtrudeShapeCustom(name: string, options: {
  61518. shape: Vector3[];
  61519. path: Vector3[];
  61520. scaleFunction?: any;
  61521. rotationFunction?: any;
  61522. ribbonCloseArray?: boolean;
  61523. ribbonClosePath?: boolean;
  61524. cap?: number;
  61525. updatable?: boolean;
  61526. sideOrientation?: number;
  61527. frontUVs?: Vector4;
  61528. backUVs?: Vector4;
  61529. instance?: Mesh;
  61530. invertUV?: boolean;
  61531. }, scene?: Nullable<Scene>): Mesh;
  61532. private static _ExtrudeShapeGeneric;
  61533. }
  61534. }
  61535. declare module "babylonjs/Debug/skeletonViewer" {
  61536. import { Color3 } from "babylonjs/Maths/math.color";
  61537. import { Scene } from "babylonjs/scene";
  61538. import { Nullable } from "babylonjs/types";
  61539. import { Skeleton } from "babylonjs/Bones/skeleton";
  61540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61541. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  61542. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  61543. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  61544. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  61545. /**
  61546. * Class used to render a debug view of a given skeleton
  61547. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  61548. */
  61549. export class SkeletonViewer {
  61550. /** defines the skeleton to render */
  61551. skeleton: Skeleton;
  61552. /** defines the mesh attached to the skeleton */
  61553. mesh: AbstractMesh;
  61554. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  61555. autoUpdateBonesMatrices: boolean;
  61556. /** defines the rendering group id to use with the viewer */
  61557. renderingGroupId: number;
  61558. /** is the options for the viewer */
  61559. options: Partial<ISkeletonViewerOptions>;
  61560. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  61561. static readonly DISPLAY_LINES: number;
  61562. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  61563. static readonly DISPLAY_SPHERES: number;
  61564. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  61565. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  61566. /** public static method to create a BoneWeight Shader
  61567. * @param options The constructor options
  61568. * @param scene The scene that the shader is scoped to
  61569. * @returns The created ShaderMaterial
  61570. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  61571. */
  61572. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  61573. /** public static method to create a BoneWeight Shader
  61574. * @param options The constructor options
  61575. * @param scene The scene that the shader is scoped to
  61576. * @returns The created ShaderMaterial
  61577. */
  61578. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  61579. /** private static method to create a BoneWeight Shader
  61580. * @param size The size of the buffer to create (usually the bone count)
  61581. * @param colorMap The gradient data to generate
  61582. * @param scene The scene that the shader is scoped to
  61583. * @returns an Array of floats from the color gradient values
  61584. */
  61585. private static _CreateBoneMapColorBuffer;
  61586. /** If SkeletonViewer scene scope. */
  61587. private _scene;
  61588. /** Gets or sets the color used to render the skeleton */
  61589. color: Color3;
  61590. /** Array of the points of the skeleton fo the line view. */
  61591. private _debugLines;
  61592. /** The SkeletonViewers Mesh. */
  61593. private _debugMesh;
  61594. /** The local axes Meshes. */
  61595. private _localAxes;
  61596. /** If SkeletonViewer is enabled. */
  61597. private _isEnabled;
  61598. /** If SkeletonViewer is ready. */
  61599. private _ready;
  61600. /** SkeletonViewer render observable. */
  61601. private _obs;
  61602. /** The Utility Layer to render the gizmos in. */
  61603. private _utilityLayer;
  61604. private _boneIndices;
  61605. /** Gets the Scene. */
  61606. get scene(): Scene;
  61607. /** Gets the utilityLayer. */
  61608. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  61609. /** Checks Ready Status. */
  61610. get isReady(): Boolean;
  61611. /** Sets Ready Status. */
  61612. set ready(value: boolean);
  61613. /** Gets the debugMesh */
  61614. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  61615. /** Sets the debugMesh */
  61616. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  61617. /** Gets the displayMode */
  61618. get displayMode(): number;
  61619. /** Sets the displayMode */
  61620. set displayMode(value: number);
  61621. /**
  61622. * Creates a new SkeletonViewer
  61623. * @param skeleton defines the skeleton to render
  61624. * @param mesh defines the mesh attached to the skeleton
  61625. * @param scene defines the hosting scene
  61626. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  61627. * @param renderingGroupId defines the rendering group id to use with the viewer
  61628. * @param options All of the extra constructor options for the SkeletonViewer
  61629. */
  61630. constructor(
  61631. /** defines the skeleton to render */
  61632. skeleton: Skeleton,
  61633. /** defines the mesh attached to the skeleton */
  61634. mesh: AbstractMesh,
  61635. /** The Scene scope*/
  61636. scene: Scene,
  61637. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  61638. autoUpdateBonesMatrices?: boolean,
  61639. /** defines the rendering group id to use with the viewer */
  61640. renderingGroupId?: number,
  61641. /** is the options for the viewer */
  61642. options?: Partial<ISkeletonViewerOptions>);
  61643. /** The Dynamic bindings for the update functions */
  61644. private _bindObs;
  61645. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  61646. update(): void;
  61647. /** Gets or sets a boolean indicating if the viewer is enabled */
  61648. set isEnabled(value: boolean);
  61649. get isEnabled(): boolean;
  61650. private _getBonePosition;
  61651. private _getLinesForBonesWithLength;
  61652. private _getLinesForBonesNoLength;
  61653. /** function to revert the mesh and scene back to the initial state. */
  61654. private _revert;
  61655. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  61656. private _getAbsoluteBindPoseToRef;
  61657. /** function to build and bind sphere joint points and spur bone representations. */
  61658. private _buildSpheresAndSpurs;
  61659. private _buildLocalAxes;
  61660. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  61661. private _displayLinesUpdate;
  61662. /** Changes the displayMode of the skeleton viewer
  61663. * @param mode The displayMode numerical value
  61664. */
  61665. changeDisplayMode(mode: number): void;
  61666. /** Sets a display option of the skeleton viewer
  61667. *
  61668. * | Option | Type | Default | Description |
  61669. * | ---------------- | ------- | ------- | ----------- |
  61670. * | 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`. |
  61671. * | 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`. |
  61672. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  61673. * | 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`. |
  61674. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  61675. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  61676. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  61677. *
  61678. * @param option String of the option name
  61679. * @param value The numerical option value
  61680. */
  61681. changeDisplayOptions(option: string, value: number): void;
  61682. /** Release associated resources */
  61683. dispose(): void;
  61684. }
  61685. }
  61686. declare module "babylonjs/Debug/index" {
  61687. export * from "babylonjs/Debug/axesViewer";
  61688. export * from "babylonjs/Debug/boneAxesViewer";
  61689. export * from "babylonjs/Debug/debugLayer";
  61690. export * from "babylonjs/Debug/physicsViewer";
  61691. export * from "babylonjs/Debug/rayHelper";
  61692. export * from "babylonjs/Debug/skeletonViewer";
  61693. export * from "babylonjs/Debug/ISkeletonViewer";
  61694. }
  61695. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  61696. /**
  61697. * Enum for Device Types
  61698. */
  61699. export enum DeviceType {
  61700. /** Generic */
  61701. Generic = 0,
  61702. /** Keyboard */
  61703. Keyboard = 1,
  61704. /** Mouse */
  61705. Mouse = 2,
  61706. /** Touch Pointers */
  61707. Touch = 3,
  61708. /** PS4 Dual Shock */
  61709. DualShock = 4,
  61710. /** Xbox */
  61711. Xbox = 5,
  61712. /** Switch Controller */
  61713. Switch = 6
  61714. }
  61715. /**
  61716. * Enum for All Pointers (Touch/Mouse)
  61717. */
  61718. export enum PointerInput {
  61719. /** Horizontal Axis */
  61720. Horizontal = 0,
  61721. /** Vertical Axis */
  61722. Vertical = 1,
  61723. /** Left Click or Touch */
  61724. LeftClick = 2,
  61725. /** Middle Click */
  61726. MiddleClick = 3,
  61727. /** Right Click */
  61728. RightClick = 4,
  61729. /** Browser Back */
  61730. BrowserBack = 5,
  61731. /** Browser Forward */
  61732. BrowserForward = 6
  61733. }
  61734. /**
  61735. * Enum for Dual Shock Gamepad
  61736. */
  61737. export enum DualShockInput {
  61738. /** Cross */
  61739. Cross = 0,
  61740. /** Circle */
  61741. Circle = 1,
  61742. /** Square */
  61743. Square = 2,
  61744. /** Triangle */
  61745. Triangle = 3,
  61746. /** L1 */
  61747. L1 = 4,
  61748. /** R1 */
  61749. R1 = 5,
  61750. /** L2 */
  61751. L2 = 6,
  61752. /** R2 */
  61753. R2 = 7,
  61754. /** Share */
  61755. Share = 8,
  61756. /** Options */
  61757. Options = 9,
  61758. /** L3 */
  61759. L3 = 10,
  61760. /** R3 */
  61761. R3 = 11,
  61762. /** DPadUp */
  61763. DPadUp = 12,
  61764. /** DPadDown */
  61765. DPadDown = 13,
  61766. /** DPadLeft */
  61767. DPadLeft = 14,
  61768. /** DRight */
  61769. DPadRight = 15,
  61770. /** Home */
  61771. Home = 16,
  61772. /** TouchPad */
  61773. TouchPad = 17,
  61774. /** LStickXAxis */
  61775. LStickXAxis = 18,
  61776. /** LStickYAxis */
  61777. LStickYAxis = 19,
  61778. /** RStickXAxis */
  61779. RStickXAxis = 20,
  61780. /** RStickYAxis */
  61781. RStickYAxis = 21
  61782. }
  61783. /**
  61784. * Enum for Xbox Gamepad
  61785. */
  61786. export enum XboxInput {
  61787. /** A */
  61788. A = 0,
  61789. /** B */
  61790. B = 1,
  61791. /** X */
  61792. X = 2,
  61793. /** Y */
  61794. Y = 3,
  61795. /** LB */
  61796. LB = 4,
  61797. /** RB */
  61798. RB = 5,
  61799. /** LT */
  61800. LT = 6,
  61801. /** RT */
  61802. RT = 7,
  61803. /** Back */
  61804. Back = 8,
  61805. /** Start */
  61806. Start = 9,
  61807. /** LS */
  61808. LS = 10,
  61809. /** RS */
  61810. RS = 11,
  61811. /** DPadUp */
  61812. DPadUp = 12,
  61813. /** DPadDown */
  61814. DPadDown = 13,
  61815. /** DPadLeft */
  61816. DPadLeft = 14,
  61817. /** DRight */
  61818. DPadRight = 15,
  61819. /** Home */
  61820. Home = 16,
  61821. /** LStickXAxis */
  61822. LStickXAxis = 17,
  61823. /** LStickYAxis */
  61824. LStickYAxis = 18,
  61825. /** RStickXAxis */
  61826. RStickXAxis = 19,
  61827. /** RStickYAxis */
  61828. RStickYAxis = 20
  61829. }
  61830. /**
  61831. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  61832. */
  61833. export enum SwitchInput {
  61834. /** B */
  61835. B = 0,
  61836. /** A */
  61837. A = 1,
  61838. /** Y */
  61839. Y = 2,
  61840. /** X */
  61841. X = 3,
  61842. /** L */
  61843. L = 4,
  61844. /** R */
  61845. R = 5,
  61846. /** ZL */
  61847. ZL = 6,
  61848. /** ZR */
  61849. ZR = 7,
  61850. /** Minus */
  61851. Minus = 8,
  61852. /** Plus */
  61853. Plus = 9,
  61854. /** LS */
  61855. LS = 10,
  61856. /** RS */
  61857. RS = 11,
  61858. /** DPadUp */
  61859. DPadUp = 12,
  61860. /** DPadDown */
  61861. DPadDown = 13,
  61862. /** DPadLeft */
  61863. DPadLeft = 14,
  61864. /** DRight */
  61865. DPadRight = 15,
  61866. /** Home */
  61867. Home = 16,
  61868. /** Capture */
  61869. Capture = 17,
  61870. /** LStickXAxis */
  61871. LStickXAxis = 18,
  61872. /** LStickYAxis */
  61873. LStickYAxis = 19,
  61874. /** RStickXAxis */
  61875. RStickXAxis = 20,
  61876. /** RStickYAxis */
  61877. RStickYAxis = 21
  61878. }
  61879. }
  61880. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  61881. import { Engine } from "babylonjs/Engines/engine";
  61882. import { IDisposable } from "babylonjs/scene";
  61883. import { Nullable } from "babylonjs/types";
  61884. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61885. /**
  61886. * This class will take all inputs from Keyboard, Pointer, and
  61887. * any Gamepads and provide a polling system that all devices
  61888. * will use. This class assumes that there will only be one
  61889. * pointer device and one keyboard.
  61890. */
  61891. export class DeviceInputSystem implements IDisposable {
  61892. /**
  61893. * Returns onDeviceConnected callback property
  61894. * @returns Callback with function to execute when a device is connected
  61895. */
  61896. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  61897. /**
  61898. * Sets callback function when a device is connected and executes against all connected devices
  61899. * @param callback Function to execute when a device is connected
  61900. */
  61901. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  61902. /**
  61903. * Callback to be triggered when a device is disconnected
  61904. */
  61905. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  61906. /**
  61907. * Callback to be triggered when event driven input is updated
  61908. */
  61909. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  61910. private _inputs;
  61911. private _gamepads;
  61912. private _keyboardActive;
  61913. private _pointerActive;
  61914. private _elementToAttachTo;
  61915. private _keyboardDownEvent;
  61916. private _keyboardUpEvent;
  61917. private _pointerMoveEvent;
  61918. private _pointerDownEvent;
  61919. private _pointerUpEvent;
  61920. private _gamepadConnectedEvent;
  61921. private _gamepadDisconnectedEvent;
  61922. private _onDeviceConnected;
  61923. private static _MAX_KEYCODES;
  61924. private static _MAX_POINTER_INPUTS;
  61925. private constructor();
  61926. /**
  61927. * Creates a new DeviceInputSystem instance
  61928. * @param engine Engine to pull input element from
  61929. * @returns The new instance
  61930. */
  61931. static Create(engine: Engine): DeviceInputSystem;
  61932. /**
  61933. * Checks for current device input value, given an id and input index
  61934. * @param deviceName Id of connected device
  61935. * @param inputIndex Index of device input
  61936. * @returns Current value of input
  61937. */
  61938. /**
  61939. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  61940. * @param deviceType Enum specifiying device type
  61941. * @param deviceSlot "Slot" or index that device is referenced in
  61942. * @param inputIndex Id of input to be checked
  61943. * @returns Current value of input
  61944. */
  61945. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  61946. /**
  61947. * Dispose of all the eventlisteners
  61948. */
  61949. dispose(): void;
  61950. /**
  61951. * Checks for existing connections to devices and register them, if necessary
  61952. * Currently handles gamepads and mouse
  61953. */
  61954. private _checkForConnectedDevices;
  61955. /**
  61956. * Add a gamepad to the DeviceInputSystem
  61957. * @param gamepad A single DOM Gamepad object
  61958. */
  61959. private _addGamePad;
  61960. /**
  61961. * Add pointer device to DeviceInputSystem
  61962. * @param deviceType Type of Pointer to add
  61963. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  61964. * @param currentX Current X at point of adding
  61965. * @param currentY Current Y at point of adding
  61966. */
  61967. private _addPointerDevice;
  61968. /**
  61969. * Add device and inputs to device array
  61970. * @param deviceType Enum specifiying device type
  61971. * @param deviceSlot "Slot" or index that device is referenced in
  61972. * @param numberOfInputs Number of input entries to create for given device
  61973. */
  61974. private _registerDevice;
  61975. /**
  61976. * Given a specific device name, remove that device from the device map
  61977. * @param deviceType Enum specifiying device type
  61978. * @param deviceSlot "Slot" or index that device is referenced in
  61979. */
  61980. private _unregisterDevice;
  61981. /**
  61982. * Handle all actions that come from keyboard interaction
  61983. */
  61984. private _handleKeyActions;
  61985. /**
  61986. * Handle all actions that come from pointer interaction
  61987. */
  61988. private _handlePointerActions;
  61989. /**
  61990. * Handle all actions that come from gamepad interaction
  61991. */
  61992. private _handleGamepadActions;
  61993. /**
  61994. * Update all non-event based devices with each frame
  61995. * @param deviceType Enum specifiying device type
  61996. * @param deviceSlot "Slot" or index that device is referenced in
  61997. * @param inputIndex Id of input to be checked
  61998. */
  61999. private _updateDevice;
  62000. /**
  62001. * Gets DeviceType from the device name
  62002. * @param deviceName Name of Device from DeviceInputSystem
  62003. * @returns DeviceType enum value
  62004. */
  62005. private _getGamepadDeviceType;
  62006. }
  62007. }
  62008. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  62009. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  62010. /**
  62011. * Type to handle enforcement of inputs
  62012. */
  62013. 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;
  62014. }
  62015. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  62016. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  62017. import { Engine } from "babylonjs/Engines/engine";
  62018. import { IDisposable } from "babylonjs/scene";
  62019. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  62020. import { Nullable } from "babylonjs/types";
  62021. import { Observable } from "babylonjs/Misc/observable";
  62022. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  62023. /**
  62024. * Class that handles all input for a specific device
  62025. */
  62026. export class DeviceSource<T extends DeviceType> {
  62027. /** Type of device */
  62028. readonly deviceType: DeviceType;
  62029. /** "Slot" or index that device is referenced in */
  62030. readonly deviceSlot: number;
  62031. /**
  62032. * Observable to handle device input changes per device
  62033. */
  62034. readonly onInputChangedObservable: Observable<{
  62035. inputIndex: DeviceInput<T>;
  62036. previousState: Nullable<number>;
  62037. currentState: Nullable<number>;
  62038. }>;
  62039. private readonly _deviceInputSystem;
  62040. /**
  62041. * Default Constructor
  62042. * @param deviceInputSystem Reference to DeviceInputSystem
  62043. * @param deviceType Type of device
  62044. * @param deviceSlot "Slot" or index that device is referenced in
  62045. */
  62046. constructor(deviceInputSystem: DeviceInputSystem,
  62047. /** Type of device */
  62048. deviceType: DeviceType,
  62049. /** "Slot" or index that device is referenced in */
  62050. deviceSlot?: number);
  62051. /**
  62052. * Get input for specific input
  62053. * @param inputIndex index of specific input on device
  62054. * @returns Input value from DeviceInputSystem
  62055. */
  62056. getInput(inputIndex: DeviceInput<T>): number;
  62057. }
  62058. /**
  62059. * Class to keep track of devices
  62060. */
  62061. export class DeviceSourceManager implements IDisposable {
  62062. /**
  62063. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  62064. */
  62065. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  62066. /**
  62067. * Observable to be triggered when after a device is disconnected
  62068. */
  62069. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  62070. private readonly _devices;
  62071. private readonly _firstDevice;
  62072. private readonly _deviceInputSystem;
  62073. /**
  62074. * Default Constructor
  62075. * @param engine engine to pull input element from
  62076. */
  62077. constructor(engine: Engine);
  62078. /**
  62079. * Gets a DeviceSource, given a type and slot
  62080. * @param deviceType Enum specifying device type
  62081. * @param deviceSlot "Slot" or index that device is referenced in
  62082. * @returns DeviceSource object
  62083. */
  62084. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  62085. /**
  62086. * Gets an array of DeviceSource objects for a given device type
  62087. * @param deviceType Enum specifying device type
  62088. * @returns Array of DeviceSource objects
  62089. */
  62090. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  62091. /**
  62092. * Returns a read-only list of all available devices
  62093. * @returns Read-only array with active devices
  62094. */
  62095. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  62096. /**
  62097. * Dispose of DeviceInputSystem and other parts
  62098. */
  62099. dispose(): void;
  62100. /**
  62101. * Function to add device name to device list
  62102. * @param deviceType Enum specifying device type
  62103. * @param deviceSlot "Slot" or index that device is referenced in
  62104. */
  62105. private _addDevice;
  62106. /**
  62107. * Function to remove device name to device list
  62108. * @param deviceType Enum specifying device type
  62109. * @param deviceSlot "Slot" or index that device is referenced in
  62110. */
  62111. private _removeDevice;
  62112. /**
  62113. * Updates array storing first connected device of each type
  62114. * @param type Type of Device
  62115. */
  62116. private _updateFirstDevices;
  62117. }
  62118. }
  62119. declare module "babylonjs/DeviceInput/index" {
  62120. export * from "babylonjs/DeviceInput/deviceInputSystem";
  62121. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  62122. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  62123. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  62124. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  62125. }
  62126. declare module "babylonjs/Engines/nullEngine" {
  62127. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  62128. import { Engine } from "babylonjs/Engines/engine";
  62129. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  62130. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  62131. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62132. import { Effect } from "babylonjs/Materials/effect";
  62133. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  62134. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  62135. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  62136. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  62137. /**
  62138. * Options to create the null engine
  62139. */
  62140. export class NullEngineOptions {
  62141. /**
  62142. * Render width (Default: 512)
  62143. */
  62144. renderWidth: number;
  62145. /**
  62146. * Render height (Default: 256)
  62147. */
  62148. renderHeight: number;
  62149. /**
  62150. * Texture size (Default: 512)
  62151. */
  62152. textureSize: number;
  62153. /**
  62154. * If delta time between frames should be constant
  62155. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  62156. */
  62157. deterministicLockstep: boolean;
  62158. /**
  62159. * Maximum about of steps between frames (Default: 4)
  62160. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  62161. */
  62162. lockstepMaxSteps: number;
  62163. /**
  62164. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  62165. */
  62166. useHighPrecisionMatrix?: boolean;
  62167. }
  62168. /**
  62169. * The null engine class provides support for headless version of babylon.js.
  62170. * This can be used in server side scenario or for testing purposes
  62171. */
  62172. export class NullEngine extends Engine {
  62173. private _options;
  62174. /**
  62175. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  62176. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  62177. * @returns true if engine is in deterministic lock step mode
  62178. */
  62179. isDeterministicLockStep(): boolean;
  62180. /**
  62181. * Gets the max steps when engine is running in deterministic lock step
  62182. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  62183. * @returns the max steps
  62184. */
  62185. getLockstepMaxSteps(): number;
  62186. /**
  62187. * Gets the current hardware scaling level.
  62188. * By default the hardware scaling level is computed from the window device ratio.
  62189. * 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.
  62190. * @returns a number indicating the current hardware scaling level
  62191. */
  62192. getHardwareScalingLevel(): number;
  62193. constructor(options?: NullEngineOptions);
  62194. /**
  62195. * Creates a vertex buffer
  62196. * @param vertices the data for the vertex buffer
  62197. * @returns the new WebGL static buffer
  62198. */
  62199. createVertexBuffer(vertices: FloatArray): DataBuffer;
  62200. /**
  62201. * Creates a new index buffer
  62202. * @param indices defines the content of the index buffer
  62203. * @param updatable defines if the index buffer must be updatable
  62204. * @returns a new webGL buffer
  62205. */
  62206. createIndexBuffer(indices: IndicesArray): DataBuffer;
  62207. /**
  62208. * Clear the current render buffer or the current render target (if any is set up)
  62209. * @param color defines the color to use
  62210. * @param backBuffer defines if the back buffer must be cleared
  62211. * @param depth defines if the depth buffer must be cleared
  62212. * @param stencil defines if the stencil buffer must be cleared
  62213. */
  62214. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  62215. /**
  62216. * Gets the current render width
  62217. * @param useScreen defines if screen size must be used (or the current render target if any)
  62218. * @returns a number defining the current render width
  62219. */
  62220. getRenderWidth(useScreen?: boolean): number;
  62221. /**
  62222. * Gets the current render height
  62223. * @param useScreen defines if screen size must be used (or the current render target if any)
  62224. * @returns a number defining the current render height
  62225. */
  62226. getRenderHeight(useScreen?: boolean): number;
  62227. /**
  62228. * Set the WebGL's viewport
  62229. * @param viewport defines the viewport element to be used
  62230. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  62231. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  62232. */
  62233. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  62234. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  62235. /**
  62236. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  62237. * @param pipelineContext defines the pipeline context to use
  62238. * @param uniformsNames defines the list of uniform names
  62239. * @returns an array of webGL uniform locations
  62240. */
  62241. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  62242. /**
  62243. * Gets the lsit of active attributes for a given webGL program
  62244. * @param pipelineContext defines the pipeline context to use
  62245. * @param attributesNames defines the list of attribute names to get
  62246. * @returns an array of indices indicating the offset of each attribute
  62247. */
  62248. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  62249. /**
  62250. * Binds an effect to the webGL context
  62251. * @param effect defines the effect to bind
  62252. */
  62253. bindSamplers(effect: Effect): void;
  62254. /**
  62255. * Activates an effect, making it the current one (ie. the one used for rendering)
  62256. * @param effect defines the effect to activate
  62257. */
  62258. enableEffect(effect: Effect): void;
  62259. /**
  62260. * Set various states to the webGL context
  62261. * @param culling defines backface culling state
  62262. * @param zOffset defines the value to apply to zOffset (0 by default)
  62263. * @param force defines if states must be applied even if cache is up to date
  62264. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  62265. */
  62266. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  62267. /**
  62268. * Set the value of an uniform to an array of int32
  62269. * @param uniform defines the webGL uniform location where to store the value
  62270. * @param array defines the array of int32 to store
  62271. * @returns true if value was set
  62272. */
  62273. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62274. /**
  62275. * Set the value of an uniform to an array of int32 (stored as vec2)
  62276. * @param uniform defines the webGL uniform location where to store the value
  62277. * @param array defines the array of int32 to store
  62278. * @returns true if value was set
  62279. */
  62280. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62281. /**
  62282. * Set the value of an uniform to an array of int32 (stored as vec3)
  62283. * @param uniform defines the webGL uniform location where to store the value
  62284. * @param array defines the array of int32 to store
  62285. * @returns true if value was set
  62286. */
  62287. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62288. /**
  62289. * Set the value of an uniform to an array of int32 (stored as vec4)
  62290. * @param uniform defines the webGL uniform location where to store the value
  62291. * @param array defines the array of int32 to store
  62292. * @returns true if value was set
  62293. */
  62294. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62295. /**
  62296. * Set the value of an uniform to an array of float32
  62297. * @param uniform defines the webGL uniform location where to store the value
  62298. * @param array defines the array of float32 to store
  62299. * @returns true if value was set
  62300. */
  62301. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62302. /**
  62303. * Set the value of an uniform to an array of float32 (stored as vec2)
  62304. * @param uniform defines the webGL uniform location where to store the value
  62305. * @param array defines the array of float32 to store
  62306. * @returns true if value was set
  62307. */
  62308. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62309. /**
  62310. * Set the value of an uniform to an array of float32 (stored as vec3)
  62311. * @param uniform defines the webGL uniform location where to store the value
  62312. * @param array defines the array of float32 to store
  62313. * @returns true if value was set
  62314. */
  62315. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62316. /**
  62317. * Set the value of an uniform to an array of float32 (stored as vec4)
  62318. * @param uniform defines the webGL uniform location where to store the value
  62319. * @param array defines the array of float32 to store
  62320. * @returns true if value was set
  62321. */
  62322. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62323. /**
  62324. * Set the value of an uniform to an array of number
  62325. * @param uniform defines the webGL uniform location where to store the value
  62326. * @param array defines the array of number to store
  62327. * @returns true if value was set
  62328. */
  62329. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  62330. /**
  62331. * Set the value of an uniform to an array of number (stored as vec2)
  62332. * @param uniform defines the webGL uniform location where to store the value
  62333. * @param array defines the array of number to store
  62334. * @returns true if value was set
  62335. */
  62336. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  62337. /**
  62338. * Set the value of an uniform to an array of number (stored as vec3)
  62339. * @param uniform defines the webGL uniform location where to store the value
  62340. * @param array defines the array of number to store
  62341. * @returns true if value was set
  62342. */
  62343. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  62344. /**
  62345. * Set the value of an uniform to an array of number (stored as vec4)
  62346. * @param uniform defines the webGL uniform location where to store the value
  62347. * @param array defines the array of number to store
  62348. * @returns true if value was set
  62349. */
  62350. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  62351. /**
  62352. * Set the value of an uniform to an array of float32 (stored as matrices)
  62353. * @param uniform defines the webGL uniform location where to store the value
  62354. * @param matrices defines the array of float32 to store
  62355. * @returns true if value was set
  62356. */
  62357. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  62358. /**
  62359. * Set the value of an uniform to a matrix (3x3)
  62360. * @param uniform defines the webGL uniform location where to store the value
  62361. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  62362. * @returns true if value was set
  62363. */
  62364. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62365. /**
  62366. * Set the value of an uniform to a matrix (2x2)
  62367. * @param uniform defines the webGL uniform location where to store the value
  62368. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  62369. * @returns true if value was set
  62370. */
  62371. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62372. /**
  62373. * Set the value of an uniform to a number (float)
  62374. * @param uniform defines the webGL uniform location where to store the value
  62375. * @param value defines the float number to store
  62376. * @returns true if value was set
  62377. */
  62378. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  62379. /**
  62380. * Set the value of an uniform to a vec2
  62381. * @param uniform defines the webGL uniform location where to store the value
  62382. * @param x defines the 1st component of the value
  62383. * @param y defines the 2nd component of the value
  62384. * @returns true if value was set
  62385. */
  62386. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  62387. /**
  62388. * Set the value of an uniform to a vec3
  62389. * @param uniform defines the webGL uniform location where to store the value
  62390. * @param x defines the 1st component of the value
  62391. * @param y defines the 2nd component of the value
  62392. * @param z defines the 3rd component of the value
  62393. * @returns true if value was set
  62394. */
  62395. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  62396. /**
  62397. * Set the value of an uniform to a boolean
  62398. * @param uniform defines the webGL uniform location where to store the value
  62399. * @param bool defines the boolean to store
  62400. * @returns true if value was set
  62401. */
  62402. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  62403. /**
  62404. * Set the value of an uniform to a vec4
  62405. * @param uniform defines the webGL uniform location where to store the value
  62406. * @param x defines the 1st component of the value
  62407. * @param y defines the 2nd component of the value
  62408. * @param z defines the 3rd component of the value
  62409. * @param w defines the 4th component of the value
  62410. * @returns true if value was set
  62411. */
  62412. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  62413. /**
  62414. * Sets the current alpha mode
  62415. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  62416. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  62417. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62418. */
  62419. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  62420. /**
  62421. * Bind webGl buffers directly to the webGL context
  62422. * @param vertexBuffers defines the vertex buffer to bind
  62423. * @param indexBuffer defines the index buffer to bind
  62424. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  62425. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  62426. * @param effect defines the effect associated with the vertex buffer
  62427. */
  62428. bindBuffers(vertexBuffers: {
  62429. [key: string]: VertexBuffer;
  62430. }, indexBuffer: DataBuffer, effect: Effect): void;
  62431. /**
  62432. * Force the entire cache to be cleared
  62433. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  62434. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  62435. */
  62436. wipeCaches(bruteForce?: boolean): void;
  62437. /**
  62438. * Send a draw order
  62439. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  62440. * @param indexStart defines the starting index
  62441. * @param indexCount defines the number of index to draw
  62442. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62443. */
  62444. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  62445. /**
  62446. * Draw a list of indexed primitives
  62447. * @param fillMode defines the primitive to use
  62448. * @param indexStart defines the starting index
  62449. * @param indexCount defines the number of index to draw
  62450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62451. */
  62452. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  62453. /**
  62454. * Draw a list of unindexed primitives
  62455. * @param fillMode defines the primitive to use
  62456. * @param verticesStart defines the index of first vertex to draw
  62457. * @param verticesCount defines the count of vertices to draw
  62458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62459. */
  62460. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  62461. /** @hidden */
  62462. protected _createTexture(): WebGLTexture;
  62463. /** @hidden */
  62464. _releaseTexture(texture: InternalTexture): void;
  62465. /**
  62466. * Usually called from Texture.ts.
  62467. * Passed information to create a WebGLTexture
  62468. * @param urlArg defines a value which contains one of the following:
  62469. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  62470. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  62471. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  62472. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  62473. * @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)
  62474. * @param scene needed for loading to the correct scene
  62475. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  62476. * @param onLoad optional callback to be called upon successful completion
  62477. * @param onError optional callback to be called upon failure
  62478. * @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
  62479. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  62480. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  62481. * @param forcedExtension defines the extension to use to pick the right loader
  62482. * @param mimeType defines an optional mime type
  62483. * @returns a InternalTexture for assignment back into BABYLON.Texture
  62484. */
  62485. 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;
  62486. /**
  62487. * Creates a new render target texture
  62488. * @param size defines the size of the texture
  62489. * @param options defines the options used to create the texture
  62490. * @returns a new render target texture stored in an InternalTexture
  62491. */
  62492. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  62493. /**
  62494. * Update the sampling mode of a given texture
  62495. * @param samplingMode defines the required sampling mode
  62496. * @param texture defines the texture to update
  62497. */
  62498. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  62499. /**
  62500. * Binds the frame buffer to the specified texture.
  62501. * @param texture The texture to render to or null for the default canvas
  62502. * @param faceIndex The face of the texture to render to in case of cube texture
  62503. * @param requiredWidth The width of the target to render to
  62504. * @param requiredHeight The height of the target to render to
  62505. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  62506. * @param lodLevel defines le lod level to bind to the frame buffer
  62507. */
  62508. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  62509. /**
  62510. * Unbind the current render target texture from the webGL context
  62511. * @param texture defines the render target texture to unbind
  62512. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  62513. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  62514. */
  62515. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  62516. /**
  62517. * Creates a dynamic vertex buffer
  62518. * @param vertices the data for the dynamic vertex buffer
  62519. * @returns the new WebGL dynamic buffer
  62520. */
  62521. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  62522. /**
  62523. * Update the content of a dynamic texture
  62524. * @param texture defines the texture to update
  62525. * @param canvas defines the canvas containing the source
  62526. * @param invertY defines if data must be stored with Y axis inverted
  62527. * @param premulAlpha defines if alpha is stored as premultiplied
  62528. * @param format defines the format of the data
  62529. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  62530. */
  62531. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  62532. /**
  62533. * Gets a boolean indicating if all created effects are ready
  62534. * @returns true if all effects are ready
  62535. */
  62536. areAllEffectsReady(): boolean;
  62537. /**
  62538. * @hidden
  62539. * Get the current error code of the webGL context
  62540. * @returns the error code
  62541. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  62542. */
  62543. getError(): number;
  62544. /** @hidden */
  62545. _getUnpackAlignement(): number;
  62546. /** @hidden */
  62547. _unpackFlipY(value: boolean): void;
  62548. /**
  62549. * Update a dynamic index buffer
  62550. * @param indexBuffer defines the target index buffer
  62551. * @param indices defines the data to update
  62552. * @param offset defines the offset in the target index buffer where update should start
  62553. */
  62554. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  62555. /**
  62556. * Updates a dynamic vertex buffer.
  62557. * @param vertexBuffer the vertex buffer to update
  62558. * @param vertices the data used to update the vertex buffer
  62559. * @param byteOffset the byte offset of the data (optional)
  62560. * @param byteLength the byte length of the data (optional)
  62561. */
  62562. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  62563. /** @hidden */
  62564. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  62565. /** @hidden */
  62566. _bindTexture(channel: number, texture: InternalTexture): void;
  62567. protected _deleteBuffer(buffer: WebGLBuffer): void;
  62568. /**
  62569. * 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
  62570. */
  62571. releaseEffects(): void;
  62572. displayLoadingUI(): void;
  62573. hideLoadingUI(): void;
  62574. /** @hidden */
  62575. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62576. /** @hidden */
  62577. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62578. /** @hidden */
  62579. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62580. /** @hidden */
  62581. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  62582. }
  62583. }
  62584. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  62585. import { Nullable, int } from "babylonjs/types";
  62586. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  62587. /** @hidden */
  62588. export class _OcclusionDataStorage {
  62589. /** @hidden */
  62590. occlusionInternalRetryCounter: number;
  62591. /** @hidden */
  62592. isOcclusionQueryInProgress: boolean;
  62593. /** @hidden */
  62594. isOccluded: boolean;
  62595. /** @hidden */
  62596. occlusionRetryCount: number;
  62597. /** @hidden */
  62598. occlusionType: number;
  62599. /** @hidden */
  62600. occlusionQueryAlgorithmType: number;
  62601. }
  62602. module "babylonjs/Engines/engine" {
  62603. interface Engine {
  62604. /**
  62605. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  62606. * @return the new query
  62607. */
  62608. createQuery(): WebGLQuery;
  62609. /**
  62610. * Delete and release a webGL query
  62611. * @param query defines the query to delete
  62612. * @return the current engine
  62613. */
  62614. deleteQuery(query: WebGLQuery): Engine;
  62615. /**
  62616. * Check if a given query has resolved and got its value
  62617. * @param query defines the query to check
  62618. * @returns true if the query got its value
  62619. */
  62620. isQueryResultAvailable(query: WebGLQuery): boolean;
  62621. /**
  62622. * Gets the value of a given query
  62623. * @param query defines the query to check
  62624. * @returns the value of the query
  62625. */
  62626. getQueryResult(query: WebGLQuery): number;
  62627. /**
  62628. * Initiates an occlusion query
  62629. * @param algorithmType defines the algorithm to use
  62630. * @param query defines the query to use
  62631. * @returns the current engine
  62632. * @see https://doc.babylonjs.com/features/occlusionquery
  62633. */
  62634. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  62635. /**
  62636. * Ends an occlusion query
  62637. * @see https://doc.babylonjs.com/features/occlusionquery
  62638. * @param algorithmType defines the algorithm to use
  62639. * @returns the current engine
  62640. */
  62641. endOcclusionQuery(algorithmType: number): Engine;
  62642. /**
  62643. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  62644. * Please note that only one query can be issued at a time
  62645. * @returns a time token used to track the time span
  62646. */
  62647. startTimeQuery(): Nullable<_TimeToken>;
  62648. /**
  62649. * Ends a time query
  62650. * @param token defines the token used to measure the time span
  62651. * @returns the time spent (in ns)
  62652. */
  62653. endTimeQuery(token: _TimeToken): int;
  62654. /** @hidden */
  62655. _currentNonTimestampToken: Nullable<_TimeToken>;
  62656. /** @hidden */
  62657. _createTimeQuery(): WebGLQuery;
  62658. /** @hidden */
  62659. _deleteTimeQuery(query: WebGLQuery): void;
  62660. /** @hidden */
  62661. _getGlAlgorithmType(algorithmType: number): number;
  62662. /** @hidden */
  62663. _getTimeQueryResult(query: WebGLQuery): any;
  62664. /** @hidden */
  62665. _getTimeQueryAvailability(query: WebGLQuery): any;
  62666. }
  62667. }
  62668. module "babylonjs/Meshes/abstractMesh" {
  62669. interface AbstractMesh {
  62670. /**
  62671. * Backing filed
  62672. * @hidden
  62673. */
  62674. __occlusionDataStorage: _OcclusionDataStorage;
  62675. /**
  62676. * Access property
  62677. * @hidden
  62678. */
  62679. _occlusionDataStorage: _OcclusionDataStorage;
  62680. /**
  62681. * 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 decides to show or hide the object.
  62682. * The default value is -1 which means don't break the query and wait till the result
  62683. * @see https://doc.babylonjs.com/features/occlusionquery
  62684. */
  62685. occlusionRetryCount: number;
  62686. /**
  62687. * 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:
  62688. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  62689. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  62690. * * 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.
  62691. * @see https://doc.babylonjs.com/features/occlusionquery
  62692. */
  62693. occlusionType: number;
  62694. /**
  62695. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  62696. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  62697. * * 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.
  62698. * @see https://doc.babylonjs.com/features/occlusionquery
  62699. */
  62700. occlusionQueryAlgorithmType: number;
  62701. /**
  62702. * Gets or sets whether the mesh is occluded or not, it is used also to set the initial state of the mesh to be occluded or not
  62703. * @see https://doc.babylonjs.com/features/occlusionquery
  62704. */
  62705. isOccluded: boolean;
  62706. /**
  62707. * Flag to check the progress status of the query
  62708. * @see https://doc.babylonjs.com/features/occlusionquery
  62709. */
  62710. isOcclusionQueryInProgress: boolean;
  62711. }
  62712. }
  62713. }
  62714. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  62715. import { Nullable } from "babylonjs/types";
  62716. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  62717. /** @hidden */
  62718. export var _forceTransformFeedbackToBundle: boolean;
  62719. module "babylonjs/Engines/engine" {
  62720. interface Engine {
  62721. /**
  62722. * Creates a webGL transform feedback object
  62723. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  62724. * @returns the webGL transform feedback object
  62725. */
  62726. createTransformFeedback(): WebGLTransformFeedback;
  62727. /**
  62728. * Delete a webGL transform feedback object
  62729. * @param value defines the webGL transform feedback object to delete
  62730. */
  62731. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  62732. /**
  62733. * Bind a webGL transform feedback object to the webgl context
  62734. * @param value defines the webGL transform feedback object to bind
  62735. */
  62736. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  62737. /**
  62738. * Begins a transform feedback operation
  62739. * @param usePoints defines if points or triangles must be used
  62740. */
  62741. beginTransformFeedback(usePoints: boolean): void;
  62742. /**
  62743. * Ends a transform feedback operation
  62744. */
  62745. endTransformFeedback(): void;
  62746. /**
  62747. * Specify the varyings to use with transform feedback
  62748. * @param program defines the associated webGL program
  62749. * @param value defines the list of strings representing the varying names
  62750. */
  62751. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  62752. /**
  62753. * Bind a webGL buffer for a transform feedback operation
  62754. * @param value defines the webGL buffer to bind
  62755. */
  62756. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  62757. }
  62758. }
  62759. }
  62760. declare module "babylonjs/Engines/Extensions/engine.views" {
  62761. import { Camera } from "babylonjs/Cameras/camera";
  62762. import { Nullable } from "babylonjs/types";
  62763. /**
  62764. * Class used to define an additional view for the engine
  62765. * @see https://doc.babylonjs.com/how_to/multi_canvases
  62766. */
  62767. export class EngineView {
  62768. /** Defines the canvas where to render the view */
  62769. target: HTMLCanvasElement;
  62770. /** Defines an optional camera used to render the view (will use active camera else) */
  62771. camera?: Camera;
  62772. }
  62773. module "babylonjs/Engines/engine" {
  62774. interface Engine {
  62775. /**
  62776. * Gets or sets the HTML element to use for attaching events
  62777. */
  62778. inputElement: Nullable<HTMLElement>;
  62779. /**
  62780. * Gets the current engine view
  62781. * @see https://doc.babylonjs.com/how_to/multi_canvases
  62782. */
  62783. activeView: Nullable<EngineView>;
  62784. /** Gets or sets the list of views */
  62785. views: EngineView[];
  62786. /**
  62787. * Register a new child canvas
  62788. * @param canvas defines the canvas to register
  62789. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  62790. * @returns the associated view
  62791. */
  62792. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  62793. /**
  62794. * Remove a registered child canvas
  62795. * @param canvas defines the canvas to remove
  62796. * @returns the current engine
  62797. */
  62798. unRegisterView(canvas: HTMLCanvasElement): Engine;
  62799. }
  62800. }
  62801. }
  62802. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  62803. import { Nullable } from "babylonjs/types";
  62804. module "babylonjs/Engines/engine" {
  62805. interface Engine {
  62806. /** @hidden */
  62807. _excludedCompressedTextures: string[];
  62808. /** @hidden */
  62809. _textureFormatInUse: string;
  62810. /**
  62811. * Gets the list of texture formats supported
  62812. */
  62813. readonly texturesSupported: Array<string>;
  62814. /**
  62815. * Gets the texture format in use
  62816. */
  62817. readonly textureFormatInUse: Nullable<string>;
  62818. /**
  62819. * Set the compressed texture extensions or file names to skip.
  62820. *
  62821. * @param skippedFiles defines the list of those texture files you want to skip
  62822. * Example: [".dds", ".env", "myfile.png"]
  62823. */
  62824. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  62825. /**
  62826. * Set the compressed texture format to use, based on the formats you have, and the formats
  62827. * supported by the hardware / browser.
  62828. *
  62829. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  62830. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  62831. * to API arguments needed to compressed textures. This puts the burden on the container
  62832. * generator to house the arcane code for determining these for current & future formats.
  62833. *
  62834. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62835. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62836. *
  62837. * Note: The result of this call is not taken into account when a texture is base64.
  62838. *
  62839. * @param formatsAvailable defines the list of those format families you have created
  62840. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  62841. *
  62842. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  62843. * @returns The extension selected.
  62844. */
  62845. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  62846. }
  62847. }
  62848. }
  62849. declare module "babylonjs/Engines/Extensions/index" {
  62850. export * from "babylonjs/Engines/Extensions/engine.alpha";
  62851. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  62852. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  62853. export * from "babylonjs/Engines/Extensions/engine.multiview";
  62854. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  62855. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62856. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  62857. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  62858. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  62859. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  62860. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62861. export * from "babylonjs/Engines/Extensions/engine.webVR";
  62862. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  62863. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  62864. export * from "babylonjs/Engines/Extensions/engine.views";
  62865. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  62866. import "babylonjs/Engines/Extensions/engine.textureSelector";
  62867. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  62868. }
  62869. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  62870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62871. /** @hidden */
  62872. export var rgbdEncodePixelShader: {
  62873. name: string;
  62874. shader: string;
  62875. };
  62876. }
  62877. declare module "babylonjs/Misc/environmentTextureTools" {
  62878. import { Nullable } from "babylonjs/types";
  62879. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  62880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62882. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62883. import "babylonjs/Engines/Extensions/engine.readTexture";
  62884. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62885. import "babylonjs/Shaders/rgbdEncode.fragment";
  62886. import "babylonjs/Shaders/rgbdDecode.fragment";
  62887. /**
  62888. * Raw texture data and descriptor sufficient for WebGL texture upload
  62889. */
  62890. export interface EnvironmentTextureInfo {
  62891. /**
  62892. * Version of the environment map
  62893. */
  62894. version: number;
  62895. /**
  62896. * Width of image
  62897. */
  62898. width: number;
  62899. /**
  62900. * Irradiance information stored in the file.
  62901. */
  62902. irradiance: any;
  62903. /**
  62904. * Specular information stored in the file.
  62905. */
  62906. specular: any;
  62907. }
  62908. /**
  62909. * Defines One Image in the file. It requires only the position in the file
  62910. * as well as the length.
  62911. */
  62912. interface BufferImageData {
  62913. /**
  62914. * Length of the image data.
  62915. */
  62916. length: number;
  62917. /**
  62918. * Position of the data from the null terminator delimiting the end of the JSON.
  62919. */
  62920. position: number;
  62921. }
  62922. /**
  62923. * Defines the specular data enclosed in the file.
  62924. * This corresponds to the version 1 of the data.
  62925. */
  62926. export interface EnvironmentTextureSpecularInfoV1 {
  62927. /**
  62928. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  62929. */
  62930. specularDataPosition?: number;
  62931. /**
  62932. * This contains all the images data needed to reconstruct the cubemap.
  62933. */
  62934. mipmaps: Array<BufferImageData>;
  62935. /**
  62936. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  62937. */
  62938. lodGenerationScale: number;
  62939. }
  62940. /**
  62941. * Sets of helpers addressing the serialization and deserialization of environment texture
  62942. * stored in a BabylonJS env file.
  62943. * Those files are usually stored as .env files.
  62944. */
  62945. export class EnvironmentTextureTools {
  62946. /**
  62947. * Magic number identifying the env file.
  62948. */
  62949. private static _MagicBytes;
  62950. /**
  62951. * Gets the environment info from an env file.
  62952. * @param data The array buffer containing the .env bytes.
  62953. * @returns the environment file info (the json header) if successfully parsed.
  62954. */
  62955. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  62956. /**
  62957. * Creates an environment texture from a loaded cube texture.
  62958. * @param texture defines the cube texture to convert in env file
  62959. * @return a promise containing the environment data if successful.
  62960. */
  62961. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  62962. /**
  62963. * Creates a JSON representation of the spherical data.
  62964. * @param texture defines the texture containing the polynomials
  62965. * @return the JSON representation of the spherical info
  62966. */
  62967. private static _CreateEnvTextureIrradiance;
  62968. /**
  62969. * Creates the ArrayBufferViews used for initializing environment texture image data.
  62970. * @param data the image data
  62971. * @param info parameters that determine what views will be created for accessing the underlying buffer
  62972. * @return the views described by info providing access to the underlying buffer
  62973. */
  62974. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  62975. /**
  62976. * Uploads the texture info contained in the env file to the GPU.
  62977. * @param texture defines the internal texture to upload to
  62978. * @param data defines the data to load
  62979. * @param info defines the texture info retrieved through the GetEnvInfo method
  62980. * @returns a promise
  62981. */
  62982. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  62983. private static _OnImageReadyAsync;
  62984. /**
  62985. * Uploads the levels of image data to the GPU.
  62986. * @param texture defines the internal texture to upload to
  62987. * @param imageData defines the array buffer views of image data [mipmap][face]
  62988. * @returns a promise
  62989. */
  62990. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  62991. /**
  62992. * Uploads spherical polynomials information to the texture.
  62993. * @param texture defines the texture we are trying to upload the information to
  62994. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  62995. */
  62996. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  62997. /** @hidden */
  62998. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62999. }
  63000. }
  63001. declare module "babylonjs/Engines/nativeEngine" {
  63002. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  63003. import { Engine } from "babylonjs/Engines/engine";
  63004. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  63005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63007. import { Effect } from "babylonjs/Materials/effect";
  63008. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  63009. import { Scene } from "babylonjs/scene";
  63010. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  63011. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  63012. import { IMatrixLike, IColor3Like, IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  63013. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  63014. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  63015. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  63016. /**
  63017. * Container for accessors for natively-stored mesh data buffers.
  63018. */
  63019. class NativeDataBuffer extends DataBuffer {
  63020. /**
  63021. * Accessor value used to identify/retrieve a natively-stored index buffer.
  63022. */
  63023. nativeIndexBuffer?: any;
  63024. /**
  63025. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  63026. */
  63027. nativeVertexBuffer?: any;
  63028. }
  63029. /** @hidden */
  63030. class NativeTexture extends InternalTexture {
  63031. getInternalTexture(): InternalTexture;
  63032. getViewCount(): number;
  63033. }
  63034. /** @hidden */
  63035. export class NativeEngine extends Engine {
  63036. private readonly _native;
  63037. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  63038. private readonly INVALID_HANDLE;
  63039. private _boundBuffersVertexArray;
  63040. private _currentDepthTest;
  63041. getHardwareScalingLevel(): number;
  63042. constructor();
  63043. dispose(): void;
  63044. /**
  63045. * Can be used to override the current requestAnimationFrame requester.
  63046. * @hidden
  63047. */
  63048. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  63049. /**
  63050. * Override default engine behavior.
  63051. * @param color
  63052. * @param backBuffer
  63053. * @param depth
  63054. * @param stencil
  63055. */
  63056. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  63057. /**
  63058. * Gets host document
  63059. * @returns the host document object
  63060. */
  63061. getHostDocument(): Nullable<Document>;
  63062. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  63063. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  63064. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  63065. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  63066. [key: string]: VertexBuffer;
  63067. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  63068. bindBuffers(vertexBuffers: {
  63069. [key: string]: VertexBuffer;
  63070. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  63071. recordVertexArrayObject(vertexBuffers: {
  63072. [key: string]: VertexBuffer;
  63073. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  63074. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  63075. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  63076. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  63077. /**
  63078. * Draw a list of indexed primitives
  63079. * @param fillMode defines the primitive to use
  63080. * @param indexStart defines the starting index
  63081. * @param indexCount defines the number of index to draw
  63082. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  63083. */
  63084. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  63085. /**
  63086. * Draw a list of unindexed primitives
  63087. * @param fillMode defines the primitive to use
  63088. * @param verticesStart defines the index of first vertex to draw
  63089. * @param verticesCount defines the count of vertices to draw
  63090. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  63091. */
  63092. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  63093. createPipelineContext(): IPipelineContext;
  63094. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  63095. /** @hidden */
  63096. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  63097. /** @hidden */
  63098. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  63099. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  63100. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  63101. protected _setProgram(program: WebGLProgram): void;
  63102. _releaseEffect(effect: Effect): void;
  63103. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  63104. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  63105. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  63106. bindSamplers(effect: Effect): void;
  63107. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  63108. getRenderWidth(useScreen?: boolean): number;
  63109. getRenderHeight(useScreen?: boolean): number;
  63110. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  63111. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  63112. /**
  63113. * Set the z offset to apply to current rendering
  63114. * @param value defines the offset to apply
  63115. */
  63116. setZOffset(value: number): void;
  63117. /**
  63118. * Gets the current value of the zOffset
  63119. * @returns the current zOffset state
  63120. */
  63121. getZOffset(): number;
  63122. /**
  63123. * Enable or disable depth buffering
  63124. * @param enable defines the state to set
  63125. */
  63126. setDepthBuffer(enable: boolean): void;
  63127. /**
  63128. * Gets a boolean indicating if depth writing is enabled
  63129. * @returns the current depth writing state
  63130. */
  63131. getDepthWrite(): boolean;
  63132. setDepthFunctionToGreater(): void;
  63133. setDepthFunctionToGreaterOrEqual(): void;
  63134. setDepthFunctionToLess(): void;
  63135. setDepthFunctionToLessOrEqual(): void;
  63136. /**
  63137. * Enable or disable depth writing
  63138. * @param enable defines the state to set
  63139. */
  63140. setDepthWrite(enable: boolean): void;
  63141. /**
  63142. * Enable or disable color writing
  63143. * @param enable defines the state to set
  63144. */
  63145. setColorWrite(enable: boolean): void;
  63146. /**
  63147. * Gets a boolean indicating if color writing is enabled
  63148. * @returns the current color writing state
  63149. */
  63150. getColorWrite(): boolean;
  63151. /**
  63152. * Sets alpha constants used by some alpha blending modes
  63153. * @param r defines the red component
  63154. * @param g defines the green component
  63155. * @param b defines the blue component
  63156. * @param a defines the alpha component
  63157. */
  63158. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  63159. /**
  63160. * Sets the current alpha mode
  63161. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  63162. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  63163. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  63164. */
  63165. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  63166. /**
  63167. * Gets the current alpha mode
  63168. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  63169. * @returns the current alpha mode
  63170. */
  63171. getAlphaMode(): number;
  63172. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  63173. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  63174. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  63175. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  63176. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  63177. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  63178. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  63179. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  63180. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  63181. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  63182. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  63183. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  63184. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  63185. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  63186. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  63187. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  63188. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  63189. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  63190. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  63191. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  63192. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  63193. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  63194. wipeCaches(bruteForce?: boolean): void;
  63195. protected _createTexture(): WebGLTexture;
  63196. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  63197. /**
  63198. * Update the content of a dynamic texture
  63199. * @param texture defines the texture to update
  63200. * @param canvas defines the canvas containing the source
  63201. * @param invertY defines if data must be stored with Y axis inverted
  63202. * @param premulAlpha defines if alpha is stored as premultiplied
  63203. * @param format defines the format of the data
  63204. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  63205. */
  63206. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  63207. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  63208. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  63209. /**
  63210. * Usually called from Texture.ts.
  63211. * Passed information to create a WebGLTexture
  63212. * @param url defines a value which contains one of the following:
  63213. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  63214. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  63215. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  63216. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  63217. * @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)
  63218. * @param scene needed for loading to the correct scene
  63219. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  63220. * @param onLoad optional callback to be called upon successful completion
  63221. * @param onError optional callback to be called upon failure
  63222. * @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
  63223. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  63224. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  63225. * @param forcedExtension defines the extension to use to pick the right loader
  63226. * @param mimeType defines an optional mime type
  63227. * @param loaderOptions options to be passed to the loader
  63228. * @returns a InternalTexture for assignment back into BABYLON.Texture
  63229. */
  63230. 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;
  63231. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  63232. _releaseFramebufferObjects(texture: InternalTexture): void;
  63233. /**
  63234. * Creates a cube texture
  63235. * @param rootUrl defines the url where the files to load is located
  63236. * @param scene defines the current scene
  63237. * @param files defines the list of files to load (1 per face)
  63238. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  63239. * @param onLoad defines an optional callback raised when the texture is loaded
  63240. * @param onError defines an optional callback raised if there is an issue to load the texture
  63241. * @param format defines the format of the data
  63242. * @param forcedExtension defines the extension to use to pick the right loader
  63243. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  63244. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63245. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63246. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  63247. * @returns the cube texture as an InternalTexture
  63248. */
  63249. 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;
  63250. createRenderTargetTexture(size: number | {
  63251. width: number;
  63252. height: number;
  63253. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  63254. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  63255. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  63256. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  63257. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  63258. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  63259. /**
  63260. * Updates a dynamic vertex buffer.
  63261. * @param vertexBuffer the vertex buffer to update
  63262. * @param data the data used to update the vertex buffer
  63263. * @param byteOffset the byte offset of the data (optional)
  63264. * @param byteLength the byte length of the data (optional)
  63265. */
  63266. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  63267. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  63268. private _updateAnisotropicLevel;
  63269. private _getAddressMode;
  63270. /** @hidden */
  63271. _bindTexture(channel: number, texture: InternalTexture): void;
  63272. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  63273. releaseEffects(): void;
  63274. /** @hidden */
  63275. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  63276. /** @hidden */
  63277. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  63278. /** @hidden */
  63279. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  63280. /** @hidden */
  63281. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  63282. private _getNativeSamplingMode;
  63283. private _getNativeTextureFormat;
  63284. private _getNativeAlphaMode;
  63285. private _getNativeAttribType;
  63286. }
  63287. }
  63288. declare module "babylonjs/Engines/engineFactory" {
  63289. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63290. /**
  63291. * Helper class to create the best engine depending on the current hardware
  63292. */
  63293. export class EngineFactory {
  63294. /**
  63295. * Creates an engine based on the capabilities of the underlying hardware
  63296. * @param canvas Defines the canvas to use to display the result
  63297. * @param options Defines the options passed to the engine to create the context dependencies
  63298. * @returns a promise that resolves with the created engine
  63299. */
  63300. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  63301. }
  63302. }
  63303. declare module "babylonjs/Engines/index" {
  63304. export * from "babylonjs/Engines/constants";
  63305. export * from "babylonjs/Engines/engineCapabilities";
  63306. export * from "babylonjs/Engines/instancingAttributeInfo";
  63307. export * from "babylonjs/Engines/thinEngine";
  63308. export * from "babylonjs/Engines/engine";
  63309. export * from "babylonjs/Engines/engineStore";
  63310. export * from "babylonjs/Engines/nullEngine";
  63311. export * from "babylonjs/Engines/Extensions/index";
  63312. export * from "babylonjs/Engines/IPipelineContext";
  63313. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  63314. export * from "babylonjs/Engines/WebGPU/webgpuConstants";
  63315. export * from "babylonjs/Engines/webgpuEngine";
  63316. export * from "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline";
  63317. export * from "babylonjs/Engines/WebGPU/webgpuCacheRenderPipelineTree";
  63318. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  63319. export * from "babylonjs/Engines/nativeEngine";
  63320. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  63321. export * from "babylonjs/Engines/performanceConfigurator";
  63322. export * from "babylonjs/Engines/engineFeatures";
  63323. export * from "babylonjs/Engines/engineFactory";
  63324. }
  63325. declare module "babylonjs/Events/clipboardEvents" {
  63326. /**
  63327. * Gather the list of clipboard event types as constants.
  63328. */
  63329. export class ClipboardEventTypes {
  63330. /**
  63331. * The clipboard event is fired when a copy command is active (pressed).
  63332. */
  63333. static readonly COPY: number;
  63334. /**
  63335. * The clipboard event is fired when a cut command is active (pressed).
  63336. */
  63337. static readonly CUT: number;
  63338. /**
  63339. * The clipboard event is fired when a paste command is active (pressed).
  63340. */
  63341. static readonly PASTE: number;
  63342. }
  63343. /**
  63344. * This class is used to store clipboard related info for the onClipboardObservable event.
  63345. */
  63346. export class ClipboardInfo {
  63347. /**
  63348. * Defines the type of event (BABYLON.ClipboardEventTypes)
  63349. */
  63350. type: number;
  63351. /**
  63352. * Defines the related dom event
  63353. */
  63354. event: ClipboardEvent;
  63355. /**
  63356. *Creates an instance of ClipboardInfo.
  63357. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  63358. * @param event Defines the related dom event
  63359. */
  63360. constructor(
  63361. /**
  63362. * Defines the type of event (BABYLON.ClipboardEventTypes)
  63363. */
  63364. type: number,
  63365. /**
  63366. * Defines the related dom event
  63367. */
  63368. event: ClipboardEvent);
  63369. /**
  63370. * Get the clipboard event's type from the keycode.
  63371. * @param keyCode Defines the keyCode for the current keyboard event.
  63372. * @return {number}
  63373. */
  63374. static GetTypeFromCharacter(keyCode: number): number;
  63375. }
  63376. }
  63377. declare module "babylonjs/Events/index" {
  63378. export * from "babylonjs/Events/keyboardEvents";
  63379. export * from "babylonjs/Events/pointerEvents";
  63380. export * from "babylonjs/Events/clipboardEvents";
  63381. }
  63382. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  63383. import { Scene } from "babylonjs/scene";
  63384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63385. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63386. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63387. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63388. /**
  63389. * Google Daydream controller
  63390. */
  63391. export class DaydreamController extends WebVRController {
  63392. /**
  63393. * Base Url for the controller model.
  63394. */
  63395. static MODEL_BASE_URL: string;
  63396. /**
  63397. * File name for the controller model.
  63398. */
  63399. static MODEL_FILENAME: string;
  63400. /**
  63401. * Gamepad Id prefix used to identify Daydream Controller.
  63402. */
  63403. static readonly GAMEPAD_ID_PREFIX: string;
  63404. /**
  63405. * Creates a new DaydreamController from a gamepad
  63406. * @param vrGamepad the gamepad that the controller should be created from
  63407. */
  63408. constructor(vrGamepad: any);
  63409. /**
  63410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63411. * @param scene scene in which to add meshes
  63412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63413. */
  63414. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63415. /**
  63416. * Called once for each button that changed state since the last frame
  63417. * @param buttonIdx Which button index changed
  63418. * @param state New state of the button
  63419. * @param changes Which properties on the state changed since last frame
  63420. */
  63421. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63422. }
  63423. }
  63424. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  63425. import { Scene } from "babylonjs/scene";
  63426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63427. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63428. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63429. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63430. /**
  63431. * Gear VR Controller
  63432. */
  63433. export class GearVRController extends WebVRController {
  63434. /**
  63435. * Base Url for the controller model.
  63436. */
  63437. static MODEL_BASE_URL: string;
  63438. /**
  63439. * File name for the controller model.
  63440. */
  63441. static MODEL_FILENAME: string;
  63442. /**
  63443. * Gamepad Id prefix used to identify this controller.
  63444. */
  63445. static readonly GAMEPAD_ID_PREFIX: string;
  63446. private readonly _buttonIndexToObservableNameMap;
  63447. /**
  63448. * Creates a new GearVRController from a gamepad
  63449. * @param vrGamepad the gamepad that the controller should be created from
  63450. */
  63451. constructor(vrGamepad: any);
  63452. /**
  63453. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63454. * @param scene scene in which to add meshes
  63455. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63456. */
  63457. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63458. /**
  63459. * Called once for each button that changed state since the last frame
  63460. * @param buttonIdx Which button index changed
  63461. * @param state New state of the button
  63462. * @param changes Which properties on the state changed since last frame
  63463. */
  63464. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63465. }
  63466. }
  63467. declare module "babylonjs/Gamepads/Controllers/genericController" {
  63468. import { Scene } from "babylonjs/scene";
  63469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63470. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63471. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63472. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63473. /**
  63474. * Generic Controller
  63475. */
  63476. export class GenericController extends WebVRController {
  63477. /**
  63478. * Base Url for the controller model.
  63479. */
  63480. static readonly MODEL_BASE_URL: string;
  63481. /**
  63482. * File name for the controller model.
  63483. */
  63484. static readonly MODEL_FILENAME: string;
  63485. /**
  63486. * Creates a new GenericController from a gamepad
  63487. * @param vrGamepad the gamepad that the controller should be created from
  63488. */
  63489. constructor(vrGamepad: any);
  63490. /**
  63491. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63492. * @param scene scene in which to add meshes
  63493. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63494. */
  63495. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63496. /**
  63497. * Called once for each button that changed state since the last frame
  63498. * @param buttonIdx Which button index changed
  63499. * @param state New state of the button
  63500. * @param changes Which properties on the state changed since last frame
  63501. */
  63502. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63503. }
  63504. }
  63505. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  63506. import { Observable } from "babylonjs/Misc/observable";
  63507. import { Scene } from "babylonjs/scene";
  63508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63509. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63510. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63511. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63512. /**
  63513. * Oculus Touch Controller
  63514. */
  63515. export class OculusTouchController extends WebVRController {
  63516. /**
  63517. * Base Url for the controller model.
  63518. */
  63519. static MODEL_BASE_URL: string;
  63520. /**
  63521. * File name for the left controller model.
  63522. */
  63523. static MODEL_LEFT_FILENAME: string;
  63524. /**
  63525. * File name for the right controller model.
  63526. */
  63527. static MODEL_RIGHT_FILENAME: string;
  63528. /**
  63529. * Base Url for the Quest controller model.
  63530. */
  63531. static QUEST_MODEL_BASE_URL: string;
  63532. /**
  63533. * @hidden
  63534. * If the controllers are running on a device that needs the updated Quest controller models
  63535. */
  63536. static _IsQuest: boolean;
  63537. /**
  63538. * Fired when the secondary trigger on this controller is modified
  63539. */
  63540. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  63541. /**
  63542. * Fired when the thumb rest on this controller is modified
  63543. */
  63544. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  63545. /**
  63546. * Creates a new OculusTouchController from a gamepad
  63547. * @param vrGamepad the gamepad that the controller should be created from
  63548. */
  63549. constructor(vrGamepad: any);
  63550. /**
  63551. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63552. * @param scene scene in which to add meshes
  63553. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63554. */
  63555. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63556. /**
  63557. * Fired when the A button on this controller is modified
  63558. */
  63559. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63560. /**
  63561. * Fired when the B button on this controller is modified
  63562. */
  63563. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63564. /**
  63565. * Fired when the X button on this controller is modified
  63566. */
  63567. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63568. /**
  63569. * Fired when the Y button on this controller is modified
  63570. */
  63571. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63572. /**
  63573. * Called once for each button that changed state since the last frame
  63574. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  63575. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  63576. * 2) secondary trigger (same)
  63577. * 3) A (right) X (left), touch, pressed = value
  63578. * 4) B / Y
  63579. * 5) thumb rest
  63580. * @param buttonIdx Which button index changed
  63581. * @param state New state of the button
  63582. * @param changes Which properties on the state changed since last frame
  63583. */
  63584. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63585. }
  63586. }
  63587. declare module "babylonjs/Gamepads/Controllers/viveController" {
  63588. import { Scene } from "babylonjs/scene";
  63589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63590. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63591. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63592. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63593. import { Observable } from "babylonjs/Misc/observable";
  63594. /**
  63595. * Vive Controller
  63596. */
  63597. export class ViveController extends WebVRController {
  63598. /**
  63599. * Base Url for the controller model.
  63600. */
  63601. static MODEL_BASE_URL: string;
  63602. /**
  63603. * File name for the controller model.
  63604. */
  63605. static MODEL_FILENAME: string;
  63606. /**
  63607. * Creates a new ViveController from a gamepad
  63608. * @param vrGamepad the gamepad that the controller should be created from
  63609. */
  63610. constructor(vrGamepad: any);
  63611. /**
  63612. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63613. * @param scene scene in which to add meshes
  63614. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63615. */
  63616. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  63617. /**
  63618. * Fired when the left button on this controller is modified
  63619. */
  63620. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63621. /**
  63622. * Fired when the right button on this controller is modified
  63623. */
  63624. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63625. /**
  63626. * Fired when the menu button on this controller is modified
  63627. */
  63628. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63629. /**
  63630. * Called once for each button that changed state since the last frame
  63631. * Vive mapping:
  63632. * 0: touchpad
  63633. * 1: trigger
  63634. * 2: left AND right buttons
  63635. * 3: menu button
  63636. * @param buttonIdx Which button index changed
  63637. * @param state New state of the button
  63638. * @param changes Which properties on the state changed since last frame
  63639. */
  63640. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63641. }
  63642. }
  63643. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  63644. import { Observable } from "babylonjs/Misc/observable";
  63645. import { Scene } from "babylonjs/scene";
  63646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63647. import { Ray } from "babylonjs/Culling/ray";
  63648. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  63649. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63650. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  63651. /**
  63652. * Defines the WindowsMotionController object that the state of the windows motion controller
  63653. */
  63654. export class WindowsMotionController extends WebVRController {
  63655. /**
  63656. * The base url used to load the left and right controller models
  63657. */
  63658. static MODEL_BASE_URL: string;
  63659. /**
  63660. * The name of the left controller model file
  63661. */
  63662. static MODEL_LEFT_FILENAME: string;
  63663. /**
  63664. * The name of the right controller model file
  63665. */
  63666. static MODEL_RIGHT_FILENAME: string;
  63667. /**
  63668. * The controller name prefix for this controller type
  63669. */
  63670. static readonly GAMEPAD_ID_PREFIX: string;
  63671. /**
  63672. * The controller id pattern for this controller type
  63673. */
  63674. private static readonly GAMEPAD_ID_PATTERN;
  63675. private _loadedMeshInfo;
  63676. protected readonly _mapping: {
  63677. buttons: string[];
  63678. buttonMeshNames: {
  63679. trigger: string;
  63680. menu: string;
  63681. grip: string;
  63682. thumbstick: string;
  63683. trackpad: string;
  63684. };
  63685. buttonObservableNames: {
  63686. trigger: string;
  63687. menu: string;
  63688. grip: string;
  63689. thumbstick: string;
  63690. trackpad: string;
  63691. };
  63692. axisMeshNames: string[];
  63693. pointingPoseMeshName: string;
  63694. };
  63695. /**
  63696. * Fired when the trackpad on this controller is clicked
  63697. */
  63698. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  63699. /**
  63700. * Fired when the trackpad on this controller is modified
  63701. */
  63702. onTrackpadValuesChangedObservable: Observable<StickValues>;
  63703. /**
  63704. * The current x and y values of this controller's trackpad
  63705. */
  63706. trackpad: StickValues;
  63707. /**
  63708. * Creates a new WindowsMotionController from a gamepad
  63709. * @param vrGamepad the gamepad that the controller should be created from
  63710. */
  63711. constructor(vrGamepad: any);
  63712. /**
  63713. * Fired when the trigger on this controller is modified
  63714. */
  63715. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63716. /**
  63717. * Fired when the menu button on this controller is modified
  63718. */
  63719. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63720. /**
  63721. * Fired when the grip button on this controller is modified
  63722. */
  63723. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63724. /**
  63725. * Fired when the thumbstick button on this controller is modified
  63726. */
  63727. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63728. /**
  63729. * Fired when the touchpad button on this controller is modified
  63730. */
  63731. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63732. /**
  63733. * Fired when the touchpad values on this controller are modified
  63734. */
  63735. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  63736. protected _updateTrackpad(): void;
  63737. /**
  63738. * Called once per frame by the engine.
  63739. */
  63740. update(): void;
  63741. /**
  63742. * Called once for each button that changed state since the last frame
  63743. * @param buttonIdx Which button index changed
  63744. * @param state New state of the button
  63745. * @param changes Which properties on the state changed since last frame
  63746. */
  63747. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  63748. /**
  63749. * Moves the buttons on the controller mesh based on their current state
  63750. * @param buttonName the name of the button to move
  63751. * @param buttonValue the value of the button which determines the buttons new position
  63752. */
  63753. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  63754. /**
  63755. * Moves the axis on the controller mesh based on its current state
  63756. * @param axis the index of the axis
  63757. * @param axisValue the value of the axis which determines the meshes new position
  63758. * @hidden
  63759. */
  63760. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  63761. /**
  63762. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  63763. * @param scene scene in which to add meshes
  63764. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  63765. */
  63766. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  63767. /**
  63768. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  63769. * can be transformed by button presses and axes values, based on this._mapping.
  63770. *
  63771. * @param scene scene in which the meshes exist
  63772. * @param meshes list of meshes that make up the controller model to process
  63773. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  63774. */
  63775. private processModel;
  63776. private createMeshInfo;
  63777. /**
  63778. * Gets the ray of the controller in the direction the controller is pointing
  63779. * @param length the length the resulting ray should be
  63780. * @returns a ray in the direction the controller is pointing
  63781. */
  63782. getForwardRay(length?: number): Ray;
  63783. /**
  63784. * Disposes of the controller
  63785. */
  63786. dispose(): void;
  63787. }
  63788. /**
  63789. * This class represents a new windows motion controller in XR.
  63790. */
  63791. export class XRWindowsMotionController extends WindowsMotionController {
  63792. /**
  63793. * Changing the original WIndowsMotionController mapping to fir the new mapping
  63794. */
  63795. protected readonly _mapping: {
  63796. buttons: string[];
  63797. buttonMeshNames: {
  63798. trigger: string;
  63799. menu: string;
  63800. grip: string;
  63801. thumbstick: string;
  63802. trackpad: string;
  63803. };
  63804. buttonObservableNames: {
  63805. trigger: string;
  63806. menu: string;
  63807. grip: string;
  63808. thumbstick: string;
  63809. trackpad: string;
  63810. };
  63811. axisMeshNames: string[];
  63812. pointingPoseMeshName: string;
  63813. };
  63814. /**
  63815. * Construct a new XR-Based windows motion controller
  63816. *
  63817. * @param gamepadInfo the gamepad object from the browser
  63818. */
  63819. constructor(gamepadInfo: any);
  63820. /**
  63821. * holds the thumbstick values (X,Y)
  63822. */
  63823. thumbstickValues: StickValues;
  63824. /**
  63825. * Fired when the thumbstick on this controller is clicked
  63826. */
  63827. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  63828. /**
  63829. * Fired when the thumbstick on this controller is modified
  63830. */
  63831. onThumbstickValuesChangedObservable: Observable<StickValues>;
  63832. /**
  63833. * Fired when the touchpad button on this controller is modified
  63834. */
  63835. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  63836. /**
  63837. * Fired when the touchpad values on this controller are modified
  63838. */
  63839. onTrackpadValuesChangedObservable: Observable<StickValues>;
  63840. /**
  63841. * Fired when the thumbstick button on this controller is modified
  63842. * here to prevent breaking changes
  63843. */
  63844. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63845. /**
  63846. * updating the thumbstick(!) and not the trackpad.
  63847. * This is named this way due to the difference between WebVR and XR and to avoid
  63848. * changing the parent class.
  63849. */
  63850. protected _updateTrackpad(): void;
  63851. /**
  63852. * Disposes the class with joy
  63853. */
  63854. dispose(): void;
  63855. }
  63856. }
  63857. declare module "babylonjs/Gamepads/Controllers/index" {
  63858. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  63859. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  63860. export * from "babylonjs/Gamepads/Controllers/genericController";
  63861. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  63862. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63863. export * from "babylonjs/Gamepads/Controllers/viveController";
  63864. export * from "babylonjs/Gamepads/Controllers/webVRController";
  63865. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  63866. }
  63867. declare module "babylonjs/Gamepads/index" {
  63868. export * from "babylonjs/Gamepads/Controllers/index";
  63869. export * from "babylonjs/Gamepads/gamepad";
  63870. export * from "babylonjs/Gamepads/gamepadManager";
  63871. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  63872. export * from "babylonjs/Gamepads/xboxGamepad";
  63873. export * from "babylonjs/Gamepads/dualShockGamepad";
  63874. }
  63875. declare module "babylonjs/Lights/directionalLight" {
  63876. import { Camera } from "babylonjs/Cameras/camera";
  63877. import { Scene } from "babylonjs/scene";
  63878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63880. import { Light } from "babylonjs/Lights/light";
  63881. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63882. import { Effect } from "babylonjs/Materials/effect";
  63883. /**
  63884. * A directional light is defined by a direction (what a surprise!).
  63885. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  63886. * 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.
  63887. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63888. */
  63889. export class DirectionalLight extends ShadowLight {
  63890. private _shadowFrustumSize;
  63891. /**
  63892. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  63893. */
  63894. get shadowFrustumSize(): number;
  63895. /**
  63896. * Specifies a fix frustum size for the shadow generation.
  63897. */
  63898. set shadowFrustumSize(value: number);
  63899. private _shadowOrthoScale;
  63900. /**
  63901. * Gets the shadow projection scale against the optimal computed one.
  63902. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63903. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63904. */
  63905. get shadowOrthoScale(): number;
  63906. /**
  63907. * Sets the shadow projection scale against the optimal computed one.
  63908. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63909. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63910. */
  63911. set shadowOrthoScale(value: number);
  63912. /**
  63913. * Automatically compute the projection matrix to best fit (including all the casters)
  63914. * on each frame.
  63915. */
  63916. autoUpdateExtends: boolean;
  63917. /**
  63918. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  63919. * on each frame. autoUpdateExtends must be set to true for this to work
  63920. */
  63921. autoCalcShadowZBounds: boolean;
  63922. private _orthoLeft;
  63923. private _orthoRight;
  63924. private _orthoTop;
  63925. private _orthoBottom;
  63926. /**
  63927. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  63928. * The directional light is emitted from everywhere in the given direction.
  63929. * It can cast shadows.
  63930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63931. * @param name The friendly name of the light
  63932. * @param direction The direction of the light
  63933. * @param scene The scene the light belongs to
  63934. */
  63935. constructor(name: string, direction: Vector3, scene: Scene);
  63936. /**
  63937. * Returns the string "DirectionalLight".
  63938. * @return The class name
  63939. */
  63940. getClassName(): string;
  63941. /**
  63942. * Returns the integer 1.
  63943. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63944. */
  63945. getTypeID(): number;
  63946. /**
  63947. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  63948. * Returns the DirectionalLight Shadow projection matrix.
  63949. */
  63950. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63951. /**
  63952. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  63953. * Returns the DirectionalLight Shadow projection matrix.
  63954. */
  63955. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  63956. /**
  63957. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  63958. * Returns the DirectionalLight Shadow projection matrix.
  63959. */
  63960. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63961. protected _buildUniformLayout(): void;
  63962. /**
  63963. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  63964. * @param effect The effect to update
  63965. * @param lightIndex The index of the light in the effect to update
  63966. * @returns The directional light
  63967. */
  63968. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  63969. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  63970. /**
  63971. * Gets the minZ used for shadow according to both the scene and the light.
  63972. *
  63973. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63974. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63975. * @param activeCamera The camera we are returning the min for
  63976. * @returns the depth min z
  63977. */
  63978. getDepthMinZ(activeCamera: Camera): number;
  63979. /**
  63980. * Gets the maxZ used for shadow according to both the scene and the light.
  63981. *
  63982. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63983. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63984. * @param activeCamera The camera we are returning the max for
  63985. * @returns the depth max z
  63986. */
  63987. getDepthMaxZ(activeCamera: Camera): number;
  63988. /**
  63989. * Prepares the list of defines specific to the light type.
  63990. * @param defines the list of defines
  63991. * @param lightIndex defines the index of the light for the effect
  63992. */
  63993. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63994. }
  63995. }
  63996. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  63997. import { Mesh } from "babylonjs/Meshes/mesh";
  63998. /**
  63999. * Class containing static functions to help procedurally build meshes
  64000. */
  64001. export class HemisphereBuilder {
  64002. /**
  64003. * Creates a hemisphere mesh
  64004. * @param name defines the name of the mesh
  64005. * @param options defines the options used to create the mesh
  64006. * @param scene defines the hosting scene
  64007. * @returns the hemisphere mesh
  64008. */
  64009. static CreateHemisphere(name: string, options: {
  64010. segments?: number;
  64011. diameter?: number;
  64012. sideOrientation?: number;
  64013. }, scene: any): Mesh;
  64014. }
  64015. }
  64016. declare module "babylonjs/Lights/spotLight" {
  64017. import { Nullable } from "babylonjs/types";
  64018. import { Scene } from "babylonjs/scene";
  64019. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64021. import { Effect } from "babylonjs/Materials/effect";
  64022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64023. import { Light } from "babylonjs/Lights/light";
  64024. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  64025. /**
  64026. * A spot light is defined by a position, a direction, an angle, and an exponent.
  64027. * These values define a cone of light starting from the position, emitting toward the direction.
  64028. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  64029. * and the exponent defines the speed of the decay of the light with distance (reach).
  64030. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64031. */
  64032. export class SpotLight extends ShadowLight {
  64033. private _angle;
  64034. private _innerAngle;
  64035. private _cosHalfAngle;
  64036. private _lightAngleScale;
  64037. private _lightAngleOffset;
  64038. /**
  64039. * Gets the cone angle of the spot light in Radians.
  64040. */
  64041. get angle(): number;
  64042. /**
  64043. * Sets the cone angle of the spot light in Radians.
  64044. */
  64045. set angle(value: number);
  64046. /**
  64047. * Only used in gltf falloff mode, this defines the angle where
  64048. * the directional falloff will start before cutting at angle which could be seen
  64049. * as outer angle.
  64050. */
  64051. get innerAngle(): number;
  64052. /**
  64053. * Only used in gltf falloff mode, this defines the angle where
  64054. * the directional falloff will start before cutting at angle which could be seen
  64055. * as outer angle.
  64056. */
  64057. set innerAngle(value: number);
  64058. private _shadowAngleScale;
  64059. /**
  64060. * Allows scaling the angle of the light for shadow generation only.
  64061. */
  64062. get shadowAngleScale(): number;
  64063. /**
  64064. * Allows scaling the angle of the light for shadow generation only.
  64065. */
  64066. set shadowAngleScale(value: number);
  64067. /**
  64068. * The light decay speed with the distance from the emission spot.
  64069. */
  64070. exponent: number;
  64071. private _projectionTextureMatrix;
  64072. /**
  64073. * Allows reading the projection texture
  64074. */
  64075. get projectionTextureMatrix(): Matrix;
  64076. protected _projectionTextureLightNear: number;
  64077. /**
  64078. * Gets the near clip of the Spotlight for texture projection.
  64079. */
  64080. get projectionTextureLightNear(): number;
  64081. /**
  64082. * Sets the near clip of the Spotlight for texture projection.
  64083. */
  64084. set projectionTextureLightNear(value: number);
  64085. protected _projectionTextureLightFar: number;
  64086. /**
  64087. * Gets the far clip of the Spotlight for texture projection.
  64088. */
  64089. get projectionTextureLightFar(): number;
  64090. /**
  64091. * Sets the far clip of the Spotlight for texture projection.
  64092. */
  64093. set projectionTextureLightFar(value: number);
  64094. protected _projectionTextureUpDirection: Vector3;
  64095. /**
  64096. * Gets the Up vector of the Spotlight for texture projection.
  64097. */
  64098. get projectionTextureUpDirection(): Vector3;
  64099. /**
  64100. * Sets the Up vector of the Spotlight for texture projection.
  64101. */
  64102. set projectionTextureUpDirection(value: Vector3);
  64103. private _projectionTexture;
  64104. /**
  64105. * Gets the projection texture of the light.
  64106. */
  64107. get projectionTexture(): Nullable<BaseTexture>;
  64108. /**
  64109. * Sets the projection texture of the light.
  64110. */
  64111. set projectionTexture(value: Nullable<BaseTexture>);
  64112. private static _IsProceduralTexture;
  64113. private static _IsTexture;
  64114. private _projectionTextureViewLightDirty;
  64115. private _projectionTextureProjectionLightDirty;
  64116. private _projectionTextureDirty;
  64117. private _projectionTextureViewTargetVector;
  64118. private _projectionTextureViewLightMatrix;
  64119. private _projectionTextureProjectionLightMatrix;
  64120. private _projectionTextureScalingMatrix;
  64121. /**
  64122. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  64123. * It can cast shadows.
  64124. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64125. * @param name The light friendly name
  64126. * @param position The position of the spot light in the scene
  64127. * @param direction The direction of the light in the scene
  64128. * @param angle The cone angle of the light in Radians
  64129. * @param exponent The light decay speed with the distance from the emission spot
  64130. * @param scene The scene the lights belongs to
  64131. */
  64132. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  64133. /**
  64134. * Returns the string "SpotLight".
  64135. * @returns the class name
  64136. */
  64137. getClassName(): string;
  64138. /**
  64139. * Returns the integer 2.
  64140. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64141. */
  64142. getTypeID(): number;
  64143. /**
  64144. * Overrides the direction setter to recompute the projection texture view light Matrix.
  64145. */
  64146. protected _setDirection(value: Vector3): void;
  64147. /**
  64148. * Overrides the position setter to recompute the projection texture view light Matrix.
  64149. */
  64150. protected _setPosition(value: Vector3): void;
  64151. /**
  64152. * 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.
  64153. * Returns the SpotLight.
  64154. */
  64155. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64156. protected _computeProjectionTextureViewLightMatrix(): void;
  64157. protected _computeProjectionTextureProjectionLightMatrix(): void;
  64158. /**
  64159. * Main function for light texture projection matrix computing.
  64160. */
  64161. protected _computeProjectionTextureMatrix(): void;
  64162. protected _buildUniformLayout(): void;
  64163. private _computeAngleValues;
  64164. /**
  64165. * Sets the passed Effect "effect" with the Light textures.
  64166. * @param effect The effect to update
  64167. * @param lightIndex The index of the light in the effect to update
  64168. * @returns The light
  64169. */
  64170. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  64171. /**
  64172. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  64173. * @param effect The effect to update
  64174. * @param lightIndex The index of the light in the effect to update
  64175. * @returns The spot light
  64176. */
  64177. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  64178. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64179. /**
  64180. * Disposes the light and the associated resources.
  64181. */
  64182. dispose(): void;
  64183. /**
  64184. * Prepares the list of defines specific to the light type.
  64185. * @param defines the list of defines
  64186. * @param lightIndex defines the index of the light for the effect
  64187. */
  64188. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64189. }
  64190. }
  64191. declare module "babylonjs/Gizmos/lightGizmo" {
  64192. import { Nullable } from "babylonjs/types";
  64193. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  64194. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  64195. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  64196. import { Light } from "babylonjs/Lights/light";
  64197. import { Observable } from "babylonjs/Misc/observable";
  64198. /**
  64199. * Gizmo that enables viewing a light
  64200. */
  64201. export class LightGizmo extends Gizmo {
  64202. private _lightMesh;
  64203. private _material;
  64204. private _cachedPosition;
  64205. private _cachedForward;
  64206. private _attachedMeshParent;
  64207. private _pointerObserver;
  64208. /**
  64209. * Event that fires each time the gizmo is clicked
  64210. */
  64211. onClickedObservable: Observable<Light>;
  64212. /**
  64213. * Creates a LightGizmo
  64214. * @param gizmoLayer The utility layer the gizmo will be added to
  64215. */
  64216. constructor(gizmoLayer?: UtilityLayerRenderer);
  64217. private _light;
  64218. /**
  64219. * The light that the gizmo is attached to
  64220. */
  64221. set light(light: Nullable<Light>);
  64222. get light(): Nullable<Light>;
  64223. /**
  64224. * Gets the material used to render the light gizmo
  64225. */
  64226. get material(): StandardMaterial;
  64227. /**
  64228. * @hidden
  64229. * Updates the gizmo to match the attached mesh's position/rotation
  64230. */
  64231. protected _update(): void;
  64232. private static _Scale;
  64233. /**
  64234. * Creates the lines for a light mesh
  64235. */
  64236. private static _CreateLightLines;
  64237. /**
  64238. * Disposes of the light gizmo
  64239. */
  64240. dispose(): void;
  64241. private static _CreateHemisphericLightMesh;
  64242. private static _CreatePointLightMesh;
  64243. private static _CreateSpotLightMesh;
  64244. private static _CreateDirectionalLightMesh;
  64245. }
  64246. }
  64247. declare module "babylonjs/Gizmos/cameraGizmo" {
  64248. import { Nullable } from "babylonjs/types";
  64249. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  64250. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  64251. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  64252. import { Camera } from "babylonjs/Cameras/camera";
  64253. import { Observable } from "babylonjs/Misc/observable";
  64254. /**
  64255. * Gizmo that enables viewing a camera
  64256. */
  64257. export class CameraGizmo extends Gizmo {
  64258. private _cameraMesh;
  64259. private _cameraLinesMesh;
  64260. private _material;
  64261. private _pointerObserver;
  64262. /**
  64263. * Event that fires each time the gizmo is clicked
  64264. */
  64265. onClickedObservable: Observable<Camera>;
  64266. /**
  64267. * Creates a CameraGizmo
  64268. * @param gizmoLayer The utility layer the gizmo will be added to
  64269. */
  64270. constructor(gizmoLayer?: UtilityLayerRenderer);
  64271. private _camera;
  64272. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  64273. get displayFrustum(): boolean;
  64274. set displayFrustum(value: boolean);
  64275. /**
  64276. * The camera that the gizmo is attached to
  64277. */
  64278. set camera(camera: Nullable<Camera>);
  64279. get camera(): Nullable<Camera>;
  64280. /**
  64281. * Gets the material used to render the camera gizmo
  64282. */
  64283. get material(): StandardMaterial;
  64284. /**
  64285. * @hidden
  64286. * Updates the gizmo to match the attached mesh's position/rotation
  64287. */
  64288. protected _update(): void;
  64289. private static _Scale;
  64290. private _invProjection;
  64291. /**
  64292. * Disposes of the camera gizmo
  64293. */
  64294. dispose(): void;
  64295. private static _CreateCameraMesh;
  64296. private static _CreateCameraFrustum;
  64297. }
  64298. }
  64299. declare module "babylonjs/Gizmos/index" {
  64300. export * from "babylonjs/Gizmos/axisDragGizmo";
  64301. export * from "babylonjs/Gizmos/axisScaleGizmo";
  64302. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  64303. export * from "babylonjs/Gizmos/gizmo";
  64304. export * from "babylonjs/Gizmos/gizmoManager";
  64305. export * from "babylonjs/Gizmos/planeRotationGizmo";
  64306. export * from "babylonjs/Gizmos/positionGizmo";
  64307. export * from "babylonjs/Gizmos/rotationGizmo";
  64308. export * from "babylonjs/Gizmos/scaleGizmo";
  64309. export * from "babylonjs/Gizmos/lightGizmo";
  64310. export * from "babylonjs/Gizmos/cameraGizmo";
  64311. export * from "babylonjs/Gizmos/planeDragGizmo";
  64312. }
  64313. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  64314. /** @hidden */
  64315. export var backgroundFragmentDeclaration: {
  64316. name: string;
  64317. shader: string;
  64318. };
  64319. }
  64320. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  64321. /** @hidden */
  64322. export var backgroundUboDeclaration: {
  64323. name: string;
  64324. shader: string;
  64325. };
  64326. }
  64327. declare module "babylonjs/Shaders/background.fragment" {
  64328. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  64329. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  64330. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  64331. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64332. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64333. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64335. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64336. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64337. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64338. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  64339. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64340. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  64341. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64342. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  64343. /** @hidden */
  64344. export var backgroundPixelShader: {
  64345. name: string;
  64346. shader: string;
  64347. };
  64348. }
  64349. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  64350. /** @hidden */
  64351. export var backgroundVertexDeclaration: {
  64352. name: string;
  64353. shader: string;
  64354. };
  64355. }
  64356. declare module "babylonjs/Shaders/background.vertex" {
  64357. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  64358. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  64359. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64360. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64361. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64362. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  64363. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  64364. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64365. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64366. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64367. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64368. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  64369. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  64370. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64371. /** @hidden */
  64372. export var backgroundVertexShader: {
  64373. name: string;
  64374. shader: string;
  64375. };
  64376. }
  64377. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  64378. import { Nullable, int, float } from "babylonjs/types";
  64379. import { Scene } from "babylonjs/scene";
  64380. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64381. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64383. import { Mesh } from "babylonjs/Meshes/mesh";
  64384. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  64385. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  64386. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  64387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64388. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  64389. import { Color3 } from "babylonjs/Maths/math.color";
  64390. import "babylonjs/Shaders/background.fragment";
  64391. import "babylonjs/Shaders/background.vertex";
  64392. /**
  64393. * Background material used to create an efficient environment around your scene.
  64394. */
  64395. export class BackgroundMaterial extends PushMaterial {
  64396. /**
  64397. * Standard reflectance value at parallel view angle.
  64398. */
  64399. static StandardReflectance0: number;
  64400. /**
  64401. * Standard reflectance value at grazing angle.
  64402. */
  64403. static StandardReflectance90: number;
  64404. protected _primaryColor: Color3;
  64405. /**
  64406. * Key light Color (multiply against the environment texture)
  64407. */
  64408. primaryColor: Color3;
  64409. protected __perceptualColor: Nullable<Color3>;
  64410. /**
  64411. * Experimental Internal Use Only.
  64412. *
  64413. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  64414. * This acts as a helper to set the primary color to a more "human friendly" value.
  64415. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  64416. * output color as close as possible from the chosen value.
  64417. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  64418. * part of lighting setup.)
  64419. */
  64420. get _perceptualColor(): Nullable<Color3>;
  64421. set _perceptualColor(value: Nullable<Color3>);
  64422. protected _primaryColorShadowLevel: float;
  64423. /**
  64424. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  64425. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  64426. */
  64427. get primaryColorShadowLevel(): float;
  64428. set primaryColorShadowLevel(value: float);
  64429. protected _primaryColorHighlightLevel: float;
  64430. /**
  64431. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  64432. * The primary color is used at the level chosen to define what the white area would look.
  64433. */
  64434. get primaryColorHighlightLevel(): float;
  64435. set primaryColorHighlightLevel(value: float);
  64436. protected _reflectionTexture: Nullable<BaseTexture>;
  64437. /**
  64438. * Reflection Texture used in the material.
  64439. * Should be author in a specific way for the best result (refer to the documentation).
  64440. */
  64441. reflectionTexture: Nullable<BaseTexture>;
  64442. protected _reflectionBlur: float;
  64443. /**
  64444. * Reflection Texture level of blur.
  64445. *
  64446. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  64447. * texture twice.
  64448. */
  64449. reflectionBlur: float;
  64450. protected _diffuseTexture: Nullable<BaseTexture>;
  64451. /**
  64452. * Diffuse Texture used in the material.
  64453. * Should be author in a specific way for the best result (refer to the documentation).
  64454. */
  64455. diffuseTexture: Nullable<BaseTexture>;
  64456. protected _shadowLights: Nullable<IShadowLight[]>;
  64457. /**
  64458. * Specify the list of lights casting shadow on the material.
  64459. * All scene shadow lights will be included if null.
  64460. */
  64461. shadowLights: Nullable<IShadowLight[]>;
  64462. protected _shadowLevel: float;
  64463. /**
  64464. * Helps adjusting the shadow to a softer level if required.
  64465. * 0 means black shadows and 1 means no shadows.
  64466. */
  64467. shadowLevel: float;
  64468. protected _sceneCenter: Vector3;
  64469. /**
  64470. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  64471. * It is usually zero but might be interesting to modify according to your setup.
  64472. */
  64473. sceneCenter: Vector3;
  64474. protected _opacityFresnel: boolean;
  64475. /**
  64476. * This helps specifying that the material is falling off to the sky box at grazing angle.
  64477. * This helps ensuring a nice transition when the camera goes under the ground.
  64478. */
  64479. opacityFresnel: boolean;
  64480. protected _reflectionFresnel: boolean;
  64481. /**
  64482. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  64483. * This helps adding a mirror texture on the ground.
  64484. */
  64485. reflectionFresnel: boolean;
  64486. protected _reflectionFalloffDistance: number;
  64487. /**
  64488. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  64489. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  64490. */
  64491. reflectionFalloffDistance: number;
  64492. protected _reflectionAmount: number;
  64493. /**
  64494. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  64495. */
  64496. reflectionAmount: number;
  64497. protected _reflectionReflectance0: number;
  64498. /**
  64499. * This specifies the weight of the reflection at grazing angle.
  64500. */
  64501. reflectionReflectance0: number;
  64502. protected _reflectionReflectance90: number;
  64503. /**
  64504. * This specifies the weight of the reflection at a perpendicular point of view.
  64505. */
  64506. reflectionReflectance90: number;
  64507. /**
  64508. * Sets the reflection reflectance fresnel values according to the default standard
  64509. * empirically know to work well :-)
  64510. */
  64511. set reflectionStandardFresnelWeight(value: number);
  64512. protected _useRGBColor: boolean;
  64513. /**
  64514. * Helps to directly use the maps channels instead of their level.
  64515. */
  64516. useRGBColor: boolean;
  64517. protected _enableNoise: boolean;
  64518. /**
  64519. * This helps reducing the banding effect that could occur on the background.
  64520. */
  64521. enableNoise: boolean;
  64522. /**
  64523. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  64524. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  64525. * Recommended to be keep at 1.0 except for special cases.
  64526. */
  64527. get fovMultiplier(): number;
  64528. set fovMultiplier(value: number);
  64529. private _fovMultiplier;
  64530. /**
  64531. * Enable the FOV adjustment feature controlled by fovMultiplier.
  64532. */
  64533. useEquirectangularFOV: boolean;
  64534. private _maxSimultaneousLights;
  64535. /**
  64536. * Number of Simultaneous lights allowed on the material.
  64537. */
  64538. maxSimultaneousLights: int;
  64539. private _shadowOnly;
  64540. /**
  64541. * Make the material only render shadows
  64542. */
  64543. shadowOnly: boolean;
  64544. /**
  64545. * Default configuration related to image processing available in the Background Material.
  64546. */
  64547. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  64548. /**
  64549. * Keep track of the image processing observer to allow dispose and replace.
  64550. */
  64551. private _imageProcessingObserver;
  64552. /**
  64553. * Attaches a new image processing configuration to the PBR Material.
  64554. * @param configuration (if null the scene configuration will be use)
  64555. */
  64556. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  64557. /**
  64558. * Gets the image processing configuration used either in this material.
  64559. */
  64560. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  64561. /**
  64562. * Sets the Default image processing configuration used either in the this material.
  64563. *
  64564. * If sets to null, the scene one is in use.
  64565. */
  64566. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  64567. /**
  64568. * Gets whether the color curves effect is enabled.
  64569. */
  64570. get cameraColorCurvesEnabled(): boolean;
  64571. /**
  64572. * Sets whether the color curves effect is enabled.
  64573. */
  64574. set cameraColorCurvesEnabled(value: boolean);
  64575. /**
  64576. * Gets whether the color grading effect is enabled.
  64577. */
  64578. get cameraColorGradingEnabled(): boolean;
  64579. /**
  64580. * Gets whether the color grading effect is enabled.
  64581. */
  64582. set cameraColorGradingEnabled(value: boolean);
  64583. /**
  64584. * Gets whether tonemapping is enabled or not.
  64585. */
  64586. get cameraToneMappingEnabled(): boolean;
  64587. /**
  64588. * Sets whether tonemapping is enabled or not
  64589. */
  64590. set cameraToneMappingEnabled(value: boolean);
  64591. /**
  64592. * The camera exposure used on this material.
  64593. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64594. * This corresponds to a photographic exposure.
  64595. */
  64596. get cameraExposure(): float;
  64597. /**
  64598. * The camera exposure used on this material.
  64599. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64600. * This corresponds to a photographic exposure.
  64601. */
  64602. set cameraExposure(value: float);
  64603. /**
  64604. * Gets The camera contrast used on this material.
  64605. */
  64606. get cameraContrast(): float;
  64607. /**
  64608. * Sets The camera contrast used on this material.
  64609. */
  64610. set cameraContrast(value: float);
  64611. /**
  64612. * Gets the Color Grading 2D Lookup Texture.
  64613. */
  64614. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  64615. /**
  64616. * Sets the Color Grading 2D Lookup Texture.
  64617. */
  64618. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  64619. /**
  64620. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  64621. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64622. * 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;
  64623. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64624. */
  64625. get cameraColorCurves(): Nullable<ColorCurves>;
  64626. /**
  64627. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  64628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64629. * 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;
  64630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64631. */
  64632. set cameraColorCurves(value: Nullable<ColorCurves>);
  64633. /**
  64634. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  64635. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  64636. */
  64637. switchToBGR: boolean;
  64638. private _renderTargets;
  64639. private _reflectionControls;
  64640. private _white;
  64641. private _primaryShadowColor;
  64642. private _primaryHighlightColor;
  64643. /**
  64644. * Instantiates a Background Material in the given scene
  64645. * @param name The friendly name of the material
  64646. * @param scene The scene to add the material to
  64647. */
  64648. constructor(name: string, scene: Scene);
  64649. /**
  64650. * Gets a boolean indicating that current material needs to register RTT
  64651. */
  64652. get hasRenderTargetTextures(): boolean;
  64653. /**
  64654. * The entire material has been created in order to prevent overdraw.
  64655. * @returns false
  64656. */
  64657. needAlphaTesting(): boolean;
  64658. /**
  64659. * The entire material has been created in order to prevent overdraw.
  64660. * @returns true if blending is enable
  64661. */
  64662. needAlphaBlending(): boolean;
  64663. /**
  64664. * Checks whether the material is ready to be rendered for a given mesh.
  64665. * @param mesh The mesh to render
  64666. * @param subMesh The submesh to check against
  64667. * @param useInstances Specify wether or not the material is used with instances
  64668. * @returns true if all the dependencies are ready (Textures, Effects...)
  64669. */
  64670. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  64671. /**
  64672. * Compute the primary color according to the chosen perceptual color.
  64673. */
  64674. private _computePrimaryColorFromPerceptualColor;
  64675. /**
  64676. * Compute the highlights and shadow colors according to their chosen levels.
  64677. */
  64678. private _computePrimaryColors;
  64679. /**
  64680. * Build the uniform buffer used in the material.
  64681. */
  64682. buildUniformLayout(): void;
  64683. /**
  64684. * Unbind the material.
  64685. */
  64686. unbind(): void;
  64687. /**
  64688. * Bind only the world matrix to the material.
  64689. * @param world The world matrix to bind.
  64690. */
  64691. bindOnlyWorldMatrix(world: Matrix): void;
  64692. /**
  64693. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  64694. * @param world The world matrix to bind.
  64695. * @param subMesh The submesh to bind for.
  64696. */
  64697. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  64698. /**
  64699. * Checks to see if a texture is used in the material.
  64700. * @param texture - Base texture to use.
  64701. * @returns - Boolean specifying if a texture is used in the material.
  64702. */
  64703. hasTexture(texture: BaseTexture): boolean;
  64704. /**
  64705. * Dispose the material.
  64706. * @param forceDisposeEffect Force disposal of the associated effect.
  64707. * @param forceDisposeTextures Force disposal of the associated textures.
  64708. */
  64709. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  64710. /**
  64711. * Clones the material.
  64712. * @param name The cloned name.
  64713. * @returns The cloned material.
  64714. */
  64715. clone(name: string): BackgroundMaterial;
  64716. /**
  64717. * Serializes the current material to its JSON representation.
  64718. * @returns The JSON representation.
  64719. */
  64720. serialize(): any;
  64721. /**
  64722. * Gets the class name of the material
  64723. * @returns "BackgroundMaterial"
  64724. */
  64725. getClassName(): string;
  64726. /**
  64727. * Parse a JSON input to create back a background material.
  64728. * @param source The JSON data to parse
  64729. * @param scene The scene to create the parsed material in
  64730. * @param rootUrl The root url of the assets the material depends upon
  64731. * @returns the instantiated BackgroundMaterial.
  64732. */
  64733. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  64734. }
  64735. }
  64736. declare module "babylonjs/Helpers/environmentHelper" {
  64737. import { Observable } from "babylonjs/Misc/observable";
  64738. import { Nullable } from "babylonjs/types";
  64739. import { Scene } from "babylonjs/scene";
  64740. import { Vector3 } from "babylonjs/Maths/math.vector";
  64741. import { Color3 } from "babylonjs/Maths/math.color";
  64742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64743. import { Mesh } from "babylonjs/Meshes/mesh";
  64744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64745. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  64746. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  64747. import "babylonjs/Meshes/Builders/planeBuilder";
  64748. import "babylonjs/Meshes/Builders/boxBuilder";
  64749. /**
  64750. * Represents the different options available during the creation of
  64751. * a Environment helper.
  64752. *
  64753. * This can control the default ground, skybox and image processing setup of your scene.
  64754. */
  64755. export interface IEnvironmentHelperOptions {
  64756. /**
  64757. * Specifies whether or not to create a ground.
  64758. * True by default.
  64759. */
  64760. createGround: boolean;
  64761. /**
  64762. * Specifies the ground size.
  64763. * 15 by default.
  64764. */
  64765. groundSize: number;
  64766. /**
  64767. * The texture used on the ground for the main color.
  64768. * Comes from the BabylonJS CDN by default.
  64769. *
  64770. * Remarks: Can be either a texture or a url.
  64771. */
  64772. groundTexture: string | BaseTexture;
  64773. /**
  64774. * The color mixed in the ground texture by default.
  64775. * BabylonJS clearColor by default.
  64776. */
  64777. groundColor: Color3;
  64778. /**
  64779. * Specifies the ground opacity.
  64780. * 1 by default.
  64781. */
  64782. groundOpacity: number;
  64783. /**
  64784. * Enables the ground to receive shadows.
  64785. * True by default.
  64786. */
  64787. enableGroundShadow: boolean;
  64788. /**
  64789. * Helps preventing the shadow to be fully black on the ground.
  64790. * 0.5 by default.
  64791. */
  64792. groundShadowLevel: number;
  64793. /**
  64794. * Creates a mirror texture attach to the ground.
  64795. * false by default.
  64796. */
  64797. enableGroundMirror: boolean;
  64798. /**
  64799. * Specifies the ground mirror size ratio.
  64800. * 0.3 by default as the default kernel is 64.
  64801. */
  64802. groundMirrorSizeRatio: number;
  64803. /**
  64804. * Specifies the ground mirror blur kernel size.
  64805. * 64 by default.
  64806. */
  64807. groundMirrorBlurKernel: number;
  64808. /**
  64809. * Specifies the ground mirror visibility amount.
  64810. * 1 by default
  64811. */
  64812. groundMirrorAmount: number;
  64813. /**
  64814. * Specifies the ground mirror reflectance weight.
  64815. * This uses the standard weight of the background material to setup the fresnel effect
  64816. * of the mirror.
  64817. * 1 by default.
  64818. */
  64819. groundMirrorFresnelWeight: number;
  64820. /**
  64821. * Specifies the ground mirror Falloff distance.
  64822. * This can helps reducing the size of the reflection.
  64823. * 0 by Default.
  64824. */
  64825. groundMirrorFallOffDistance: number;
  64826. /**
  64827. * Specifies the ground mirror texture type.
  64828. * Unsigned Int by Default.
  64829. */
  64830. groundMirrorTextureType: number;
  64831. /**
  64832. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  64833. * the shown objects.
  64834. */
  64835. groundYBias: number;
  64836. /**
  64837. * Specifies whether or not to create a skybox.
  64838. * True by default.
  64839. */
  64840. createSkybox: boolean;
  64841. /**
  64842. * Specifies the skybox size.
  64843. * 20 by default.
  64844. */
  64845. skyboxSize: number;
  64846. /**
  64847. * The texture used on the skybox for the main color.
  64848. * Comes from the BabylonJS CDN by default.
  64849. *
  64850. * Remarks: Can be either a texture or a url.
  64851. */
  64852. skyboxTexture: string | BaseTexture;
  64853. /**
  64854. * The color mixed in the skybox texture by default.
  64855. * BabylonJS clearColor by default.
  64856. */
  64857. skyboxColor: Color3;
  64858. /**
  64859. * The background rotation around the Y axis of the scene.
  64860. * This helps aligning the key lights of your scene with the background.
  64861. * 0 by default.
  64862. */
  64863. backgroundYRotation: number;
  64864. /**
  64865. * Compute automatically the size of the elements to best fit with the scene.
  64866. */
  64867. sizeAuto: boolean;
  64868. /**
  64869. * Default position of the rootMesh if autoSize is not true.
  64870. */
  64871. rootPosition: Vector3;
  64872. /**
  64873. * Sets up the image processing in the scene.
  64874. * true by default.
  64875. */
  64876. setupImageProcessing: boolean;
  64877. /**
  64878. * The texture used as your environment texture in the scene.
  64879. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  64880. *
  64881. * Remarks: Can be either a texture or a url.
  64882. */
  64883. environmentTexture: string | BaseTexture;
  64884. /**
  64885. * The value of the exposure to apply to the scene.
  64886. * 0.6 by default if setupImageProcessing is true.
  64887. */
  64888. cameraExposure: number;
  64889. /**
  64890. * The value of the contrast to apply to the scene.
  64891. * 1.6 by default if setupImageProcessing is true.
  64892. */
  64893. cameraContrast: number;
  64894. /**
  64895. * Specifies whether or not tonemapping should be enabled in the scene.
  64896. * true by default if setupImageProcessing is true.
  64897. */
  64898. toneMappingEnabled: boolean;
  64899. }
  64900. /**
  64901. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  64902. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  64903. * It also helps with the default setup of your imageProcessing configuration.
  64904. */
  64905. export class EnvironmentHelper {
  64906. /**
  64907. * Default ground texture URL.
  64908. */
  64909. private static _groundTextureCDNUrl;
  64910. /**
  64911. * Default skybox texture URL.
  64912. */
  64913. private static _skyboxTextureCDNUrl;
  64914. /**
  64915. * Default environment texture URL.
  64916. */
  64917. private static _environmentTextureCDNUrl;
  64918. /**
  64919. * Creates the default options for the helper.
  64920. */
  64921. private static _getDefaultOptions;
  64922. private _rootMesh;
  64923. /**
  64924. * Gets the root mesh created by the helper.
  64925. */
  64926. get rootMesh(): Mesh;
  64927. private _skybox;
  64928. /**
  64929. * Gets the skybox created by the helper.
  64930. */
  64931. get skybox(): Nullable<Mesh>;
  64932. private _skyboxTexture;
  64933. /**
  64934. * Gets the skybox texture created by the helper.
  64935. */
  64936. get skyboxTexture(): Nullable<BaseTexture>;
  64937. private _skyboxMaterial;
  64938. /**
  64939. * Gets the skybox material created by the helper.
  64940. */
  64941. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  64942. private _ground;
  64943. /**
  64944. * Gets the ground mesh created by the helper.
  64945. */
  64946. get ground(): Nullable<Mesh>;
  64947. private _groundTexture;
  64948. /**
  64949. * Gets the ground texture created by the helper.
  64950. */
  64951. get groundTexture(): Nullable<BaseTexture>;
  64952. private _groundMirror;
  64953. /**
  64954. * Gets the ground mirror created by the helper.
  64955. */
  64956. get groundMirror(): Nullable<MirrorTexture>;
  64957. /**
  64958. * Gets the ground mirror render list to helps pushing the meshes
  64959. * you wish in the ground reflection.
  64960. */
  64961. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  64962. private _groundMaterial;
  64963. /**
  64964. * Gets the ground material created by the helper.
  64965. */
  64966. get groundMaterial(): Nullable<BackgroundMaterial>;
  64967. /**
  64968. * Stores the creation options.
  64969. */
  64970. private readonly _scene;
  64971. private _options;
  64972. /**
  64973. * This observable will be notified with any error during the creation of the environment,
  64974. * mainly texture creation errors.
  64975. */
  64976. onErrorObservable: Observable<{
  64977. message?: string;
  64978. exception?: any;
  64979. }>;
  64980. /**
  64981. * constructor
  64982. * @param options Defines the options we want to customize the helper
  64983. * @param scene The scene to add the material to
  64984. */
  64985. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  64986. /**
  64987. * Updates the background according to the new options
  64988. * @param options
  64989. */
  64990. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  64991. /**
  64992. * Sets the primary color of all the available elements.
  64993. * @param color the main color to affect to the ground and the background
  64994. */
  64995. setMainColor(color: Color3): void;
  64996. /**
  64997. * Setup the image processing according to the specified options.
  64998. */
  64999. private _setupImageProcessing;
  65000. /**
  65001. * Setup the environment texture according to the specified options.
  65002. */
  65003. private _setupEnvironmentTexture;
  65004. /**
  65005. * Setup the background according to the specified options.
  65006. */
  65007. private _setupBackground;
  65008. /**
  65009. * Get the scene sizes according to the setup.
  65010. */
  65011. private _getSceneSize;
  65012. /**
  65013. * Setup the ground according to the specified options.
  65014. */
  65015. private _setupGround;
  65016. /**
  65017. * Setup the ground material according to the specified options.
  65018. */
  65019. private _setupGroundMaterial;
  65020. /**
  65021. * Setup the ground diffuse texture according to the specified options.
  65022. */
  65023. private _setupGroundDiffuseTexture;
  65024. /**
  65025. * Setup the ground mirror texture according to the specified options.
  65026. */
  65027. private _setupGroundMirrorTexture;
  65028. /**
  65029. * Setup the ground to receive the mirror texture.
  65030. */
  65031. private _setupMirrorInGroundMaterial;
  65032. /**
  65033. * Setup the skybox according to the specified options.
  65034. */
  65035. private _setupSkybox;
  65036. /**
  65037. * Setup the skybox material according to the specified options.
  65038. */
  65039. private _setupSkyboxMaterial;
  65040. /**
  65041. * Setup the skybox reflection texture according to the specified options.
  65042. */
  65043. private _setupSkyboxReflectionTexture;
  65044. private _errorHandler;
  65045. /**
  65046. * Dispose all the elements created by the Helper.
  65047. */
  65048. dispose(): void;
  65049. }
  65050. }
  65051. declare module "babylonjs/Helpers/textureDome" {
  65052. import { Scene } from "babylonjs/scene";
  65053. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65054. import { Mesh } from "babylonjs/Meshes/mesh";
  65055. import { Texture } from "babylonjs/Materials/Textures/texture";
  65056. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  65057. import "babylonjs/Meshes/Builders/sphereBuilder";
  65058. import { Nullable } from "babylonjs/types";
  65059. import { Observable } from "babylonjs/Misc/observable";
  65060. /**
  65061. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  65062. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  65063. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  65064. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  65065. */
  65066. export abstract class TextureDome<T extends Texture> extends TransformNode {
  65067. protected onError: Nullable<(message?: string, exception?: any) => void>;
  65068. /**
  65069. * Define the source as a Monoscopic panoramic 360/180.
  65070. */
  65071. static readonly MODE_MONOSCOPIC: number;
  65072. /**
  65073. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  65074. */
  65075. static readonly MODE_TOPBOTTOM: number;
  65076. /**
  65077. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  65078. */
  65079. static readonly MODE_SIDEBYSIDE: number;
  65080. private _halfDome;
  65081. private _crossEye;
  65082. protected _useDirectMapping: boolean;
  65083. /**
  65084. * The texture being displayed on the sphere
  65085. */
  65086. protected _texture: T;
  65087. /**
  65088. * Gets the texture being displayed on the sphere
  65089. */
  65090. get texture(): T;
  65091. /**
  65092. * Sets the texture being displayed on the sphere
  65093. */
  65094. set texture(newTexture: T);
  65095. /**
  65096. * The skybox material
  65097. */
  65098. protected _material: BackgroundMaterial;
  65099. /**
  65100. * The surface used for the dome
  65101. */
  65102. protected _mesh: Mesh;
  65103. /**
  65104. * Gets the mesh used for the dome.
  65105. */
  65106. get mesh(): Mesh;
  65107. /**
  65108. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  65109. */
  65110. private _halfDomeMask;
  65111. /**
  65112. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  65113. * Also see the options.resolution property.
  65114. */
  65115. get fovMultiplier(): number;
  65116. set fovMultiplier(value: number);
  65117. protected _textureMode: number;
  65118. /**
  65119. * Gets or set the current texture mode for the texture. It can be:
  65120. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  65121. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  65122. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  65123. */
  65124. get textureMode(): number;
  65125. /**
  65126. * Sets the current texture mode for the texture. It can be:
  65127. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  65128. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  65129. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  65130. */
  65131. set textureMode(value: number);
  65132. /**
  65133. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  65134. */
  65135. get halfDome(): boolean;
  65136. /**
  65137. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  65138. */
  65139. set halfDome(enabled: boolean);
  65140. /**
  65141. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  65142. */
  65143. set crossEye(enabled: boolean);
  65144. /**
  65145. * Is it a cross-eye texture?
  65146. */
  65147. get crossEye(): boolean;
  65148. /**
  65149. * The background material of this dome.
  65150. */
  65151. get material(): BackgroundMaterial;
  65152. /**
  65153. * Oberserver used in Stereoscopic VR Mode.
  65154. */
  65155. private _onBeforeCameraRenderObserver;
  65156. /**
  65157. * Observable raised when an error occurred while loading the texture
  65158. */
  65159. onLoadErrorObservable: Observable<string>;
  65160. /**
  65161. * Observable raised when the texture finished loading
  65162. */
  65163. onLoadObservable: Observable<void>;
  65164. /**
  65165. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  65166. * @param name Element's name, child elements will append suffixes for their own names.
  65167. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  65168. * @param options An object containing optional or exposed sub element properties
  65169. */
  65170. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  65171. resolution?: number;
  65172. clickToPlay?: boolean;
  65173. autoPlay?: boolean;
  65174. loop?: boolean;
  65175. size?: number;
  65176. poster?: string;
  65177. faceForward?: boolean;
  65178. useDirectMapping?: boolean;
  65179. halfDomeMode?: boolean;
  65180. crossEyeMode?: boolean;
  65181. generateMipMaps?: boolean;
  65182. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  65183. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  65184. protected _changeTextureMode(value: number): void;
  65185. /**
  65186. * Releases resources associated with this node.
  65187. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65188. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65189. */
  65190. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65191. }
  65192. }
  65193. declare module "babylonjs/Helpers/photoDome" {
  65194. import { Scene } from "babylonjs/scene";
  65195. import { Texture } from "babylonjs/Materials/Textures/texture";
  65196. import { TextureDome } from "babylonjs/Helpers/textureDome";
  65197. /**
  65198. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  65199. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  65200. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  65201. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  65202. */
  65203. export class PhotoDome extends TextureDome<Texture> {
  65204. /**
  65205. * Define the image as a Monoscopic panoramic 360 image.
  65206. */
  65207. static readonly MODE_MONOSCOPIC: number;
  65208. /**
  65209. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  65210. */
  65211. static readonly MODE_TOPBOTTOM: number;
  65212. /**
  65213. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  65214. */
  65215. static readonly MODE_SIDEBYSIDE: number;
  65216. /**
  65217. * Gets or sets the texture being displayed on the sphere
  65218. */
  65219. get photoTexture(): Texture;
  65220. /**
  65221. * sets the texture being displayed on the sphere
  65222. */
  65223. set photoTexture(value: Texture);
  65224. /**
  65225. * Gets the current video mode for the video. It can be:
  65226. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  65227. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  65228. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  65229. */
  65230. get imageMode(): number;
  65231. /**
  65232. * Sets the current video mode for the video. It can be:
  65233. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  65234. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  65235. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  65236. */
  65237. set imageMode(value: number);
  65238. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  65239. }
  65240. }
  65241. declare module "babylonjs/Misc/dds" {
  65242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65244. import { Nullable } from "babylonjs/types";
  65245. import { Scene } from "babylonjs/scene";
  65246. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  65247. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65248. /**
  65249. * Direct draw surface info
  65250. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  65251. */
  65252. export interface DDSInfo {
  65253. /**
  65254. * Width of the texture
  65255. */
  65256. width: number;
  65257. /**
  65258. * Width of the texture
  65259. */
  65260. height: number;
  65261. /**
  65262. * Number of Mipmaps for the texture
  65263. * @see https://en.wikipedia.org/wiki/Mipmap
  65264. */
  65265. mipmapCount: number;
  65266. /**
  65267. * If the textures format is a known fourCC format
  65268. * @see https://www.fourcc.org/
  65269. */
  65270. isFourCC: boolean;
  65271. /**
  65272. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  65273. */
  65274. isRGB: boolean;
  65275. /**
  65276. * If the texture is a lumincance format
  65277. */
  65278. isLuminance: boolean;
  65279. /**
  65280. * If this is a cube texture
  65281. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  65282. */
  65283. isCube: boolean;
  65284. /**
  65285. * If the texture is a compressed format eg. FOURCC_DXT1
  65286. */
  65287. isCompressed: boolean;
  65288. /**
  65289. * The dxgiFormat of the texture
  65290. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  65291. */
  65292. dxgiFormat: number;
  65293. /**
  65294. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  65295. */
  65296. textureType: number;
  65297. /**
  65298. * Sphericle polynomial created for the dds texture
  65299. */
  65300. sphericalPolynomial?: SphericalPolynomial;
  65301. }
  65302. /**
  65303. * Class used to provide DDS decompression tools
  65304. */
  65305. export class DDSTools {
  65306. /**
  65307. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  65308. */
  65309. static StoreLODInAlphaChannel: boolean;
  65310. /**
  65311. * Gets DDS information from an array buffer
  65312. * @param data defines the array buffer view to read data from
  65313. * @returns the DDS information
  65314. */
  65315. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  65316. private static _FloatView;
  65317. private static _Int32View;
  65318. private static _ToHalfFloat;
  65319. private static _FromHalfFloat;
  65320. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  65321. private static _GetHalfFloatRGBAArrayBuffer;
  65322. private static _GetFloatRGBAArrayBuffer;
  65323. private static _GetFloatAsUIntRGBAArrayBuffer;
  65324. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  65325. private static _GetRGBAArrayBuffer;
  65326. private static _ExtractLongWordOrder;
  65327. private static _GetRGBArrayBuffer;
  65328. private static _GetLuminanceArrayBuffer;
  65329. /**
  65330. * Uploads DDS Levels to a Babylon Texture
  65331. * @hidden
  65332. */
  65333. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  65334. }
  65335. module "babylonjs/Engines/thinEngine" {
  65336. interface ThinEngine {
  65337. /**
  65338. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  65339. * @param rootUrl defines the url where the file to load is located
  65340. * @param scene defines the current scene
  65341. * @param lodScale defines scale to apply to the mip map selection
  65342. * @param lodOffset defines offset to apply to the mip map selection
  65343. * @param onLoad defines an optional callback raised when the texture is loaded
  65344. * @param onError defines an optional callback raised if there is an issue to load the texture
  65345. * @param format defines the format of the data
  65346. * @param forcedExtension defines the extension to use to pick the right loader
  65347. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  65348. * @returns the cube texture as an InternalTexture
  65349. */
  65350. 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;
  65351. }
  65352. }
  65353. }
  65354. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  65355. import { Nullable } from "babylonjs/types";
  65356. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65357. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65358. /**
  65359. * Implementation of the DDS Texture Loader.
  65360. * @hidden
  65361. */
  65362. export class _DDSTextureLoader implements IInternalTextureLoader {
  65363. /**
  65364. * Defines whether the loader supports cascade loading the different faces.
  65365. */
  65366. readonly supportCascades: boolean;
  65367. /**
  65368. * This returns if the loader support the current file information.
  65369. * @param extension defines the file extension of the file being loaded
  65370. * @returns true if the loader can load the specified file
  65371. */
  65372. canLoad(extension: string): boolean;
  65373. /**
  65374. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65375. * @param data contains the texture data
  65376. * @param texture defines the BabylonJS internal texture
  65377. * @param createPolynomials will be true if polynomials have been requested
  65378. * @param onLoad defines the callback to trigger once the texture is ready
  65379. * @param onError defines the callback to trigger in case of error
  65380. */
  65381. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65382. /**
  65383. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65384. * @param data contains the texture data
  65385. * @param texture defines the BabylonJS internal texture
  65386. * @param callback defines the method to call once ready to upload
  65387. */
  65388. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65389. }
  65390. }
  65391. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  65392. import { Nullable } from "babylonjs/types";
  65393. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65394. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65395. /**
  65396. * Implementation of the ENV Texture Loader.
  65397. * @hidden
  65398. */
  65399. export class _ENVTextureLoader implements IInternalTextureLoader {
  65400. /**
  65401. * Defines whether the loader supports cascade loading the different faces.
  65402. */
  65403. readonly supportCascades: boolean;
  65404. /**
  65405. * This returns if the loader support the current file information.
  65406. * @param extension defines the file extension of the file being loaded
  65407. * @returns true if the loader can load the specified file
  65408. */
  65409. canLoad(extension: string): boolean;
  65410. /**
  65411. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65412. * @param data contains the texture data
  65413. * @param texture defines the BabylonJS internal texture
  65414. * @param createPolynomials will be true if polynomials have been requested
  65415. * @param onLoad defines the callback to trigger once the texture is ready
  65416. * @param onError defines the callback to trigger in case of error
  65417. */
  65418. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65419. /**
  65420. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65421. * @param data contains the texture data
  65422. * @param texture defines the BabylonJS internal texture
  65423. * @param callback defines the method to call once ready to upload
  65424. */
  65425. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65426. }
  65427. }
  65428. declare module "babylonjs/Misc/khronosTextureContainer" {
  65429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65430. /**
  65431. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  65432. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  65433. */
  65434. export class KhronosTextureContainer {
  65435. /** contents of the KTX container file */
  65436. data: ArrayBufferView;
  65437. private static HEADER_LEN;
  65438. private static COMPRESSED_2D;
  65439. private static COMPRESSED_3D;
  65440. private static TEX_2D;
  65441. private static TEX_3D;
  65442. /**
  65443. * Gets the openGL type
  65444. */
  65445. glType: number;
  65446. /**
  65447. * Gets the openGL type size
  65448. */
  65449. glTypeSize: number;
  65450. /**
  65451. * Gets the openGL format
  65452. */
  65453. glFormat: number;
  65454. /**
  65455. * Gets the openGL internal format
  65456. */
  65457. glInternalFormat: number;
  65458. /**
  65459. * Gets the base internal format
  65460. */
  65461. glBaseInternalFormat: number;
  65462. /**
  65463. * Gets image width in pixel
  65464. */
  65465. pixelWidth: number;
  65466. /**
  65467. * Gets image height in pixel
  65468. */
  65469. pixelHeight: number;
  65470. /**
  65471. * Gets image depth in pixels
  65472. */
  65473. pixelDepth: number;
  65474. /**
  65475. * Gets the number of array elements
  65476. */
  65477. numberOfArrayElements: number;
  65478. /**
  65479. * Gets the number of faces
  65480. */
  65481. numberOfFaces: number;
  65482. /**
  65483. * Gets the number of mipmap levels
  65484. */
  65485. numberOfMipmapLevels: number;
  65486. /**
  65487. * Gets the bytes of key value data
  65488. */
  65489. bytesOfKeyValueData: number;
  65490. /**
  65491. * Gets the load type
  65492. */
  65493. loadType: number;
  65494. /**
  65495. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  65496. */
  65497. isInvalid: boolean;
  65498. /**
  65499. * Creates a new KhronosTextureContainer
  65500. * @param data contents of the KTX container file
  65501. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  65502. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  65503. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  65504. */
  65505. constructor(
  65506. /** contents of the KTX container file */
  65507. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  65508. /**
  65509. * Uploads KTX content to a Babylon Texture.
  65510. * It is assumed that the texture has already been created & is currently bound
  65511. * @hidden
  65512. */
  65513. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  65514. private _upload2DCompressedLevels;
  65515. /**
  65516. * Checks if the given data starts with a KTX file identifier.
  65517. * @param data the data to check
  65518. * @returns true if the data is a KTX file or false otherwise
  65519. */
  65520. static IsValid(data: ArrayBufferView): boolean;
  65521. }
  65522. }
  65523. declare module "babylonjs/Misc/workerPool" {
  65524. import { IDisposable } from "babylonjs/scene";
  65525. /**
  65526. * Helper class to push actions to a pool of workers.
  65527. */
  65528. export class WorkerPool implements IDisposable {
  65529. private _workerInfos;
  65530. private _pendingActions;
  65531. /**
  65532. * Constructor
  65533. * @param workers Array of workers to use for actions
  65534. */
  65535. constructor(workers: Array<Worker>);
  65536. /**
  65537. * Terminates all workers and clears any pending actions.
  65538. */
  65539. dispose(): void;
  65540. /**
  65541. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65542. * pended until a worker has completed its action.
  65543. * @param action The action to perform. Call onComplete when the action is complete.
  65544. */
  65545. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65546. private _execute;
  65547. }
  65548. }
  65549. declare module "babylonjs/Misc/khronosTextureContainer2" {
  65550. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65551. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65552. /**
  65553. * Class for loading KTX2 files
  65554. */
  65555. export class KhronosTextureContainer2 {
  65556. private static _WorkerPoolPromise?;
  65557. private static _Initialized;
  65558. private static _Ktx2Decoder;
  65559. /**
  65560. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  65561. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  65562. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  65563. * Urls you can change:
  65564. * URLConfig.jsDecoderModule
  65565. * URLConfig.wasmUASTCToASTC
  65566. * URLConfig.wasmUASTCToBC7
  65567. * URLConfig.wasmUASTCToRGBA_UNORM
  65568. * URLConfig.wasmUASTCToRGBA_SRGB
  65569. * URLConfig.jsMSCTranscoder
  65570. * URLConfig.wasmMSCTranscoder
  65571. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  65572. */
  65573. static URLConfig: {
  65574. jsDecoderModule: string;
  65575. wasmUASTCToASTC: null;
  65576. wasmUASTCToBC7: null;
  65577. wasmUASTCToRGBA_UNORM: null;
  65578. wasmUASTCToRGBA_SRGB: null;
  65579. jsMSCTranscoder: null;
  65580. wasmMSCTranscoder: null;
  65581. };
  65582. /**
  65583. * Default number of workers used to handle data decoding
  65584. */
  65585. static DefaultNumWorkers: number;
  65586. private static GetDefaultNumWorkers;
  65587. private _engine;
  65588. private static _CreateWorkerPool;
  65589. /**
  65590. * Constructor
  65591. * @param engine The engine to use
  65592. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65593. */
  65594. constructor(engine: ThinEngine, numWorkers?: number);
  65595. /** @hidden */
  65596. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  65597. /**
  65598. * Stop all async operations and release resources.
  65599. */
  65600. dispose(): void;
  65601. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  65602. /**
  65603. * Checks if the given data starts with a KTX2 file identifier.
  65604. * @param data the data to check
  65605. * @returns true if the data is a KTX2 file or false otherwise
  65606. */
  65607. static IsValid(data: ArrayBufferView): boolean;
  65608. }
  65609. }
  65610. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  65611. import { Nullable } from "babylonjs/types";
  65612. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65613. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65614. /**
  65615. * Implementation of the KTX Texture Loader.
  65616. * @hidden
  65617. */
  65618. export class _KTXTextureLoader implements IInternalTextureLoader {
  65619. /**
  65620. * Defines whether the loader supports cascade loading the different faces.
  65621. */
  65622. readonly supportCascades: boolean;
  65623. /**
  65624. * This returns if the loader support the current file information.
  65625. * @param extension defines the file extension of the file being loaded
  65626. * @param mimeType defines the optional mime type of the file being loaded
  65627. * @returns true if the loader can load the specified file
  65628. */
  65629. canLoad(extension: string, mimeType?: string): boolean;
  65630. /**
  65631. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65632. * @param data contains the texture data
  65633. * @param texture defines the BabylonJS internal texture
  65634. * @param createPolynomials will be true if polynomials have been requested
  65635. * @param onLoad defines the callback to trigger once the texture is ready
  65636. * @param onError defines the callback to trigger in case of error
  65637. */
  65638. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65639. /**
  65640. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65641. * @param data contains the texture data
  65642. * @param texture defines the BabylonJS internal texture
  65643. * @param callback defines the method to call once ready to upload
  65644. */
  65645. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  65646. }
  65647. }
  65648. declare module "babylonjs/Helpers/sceneHelpers" {
  65649. import { Nullable } from "babylonjs/types";
  65650. import { Mesh } from "babylonjs/Meshes/mesh";
  65651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65652. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  65653. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  65654. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65655. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65656. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65657. import "babylonjs/Meshes/Builders/boxBuilder";
  65658. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  65659. /** @hidden */
  65660. export var _forceSceneHelpersToBundle: boolean;
  65661. module "babylonjs/scene" {
  65662. interface Scene {
  65663. /**
  65664. * Creates a default light for the scene.
  65665. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  65666. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  65667. */
  65668. createDefaultLight(replace?: boolean): void;
  65669. /**
  65670. * Creates a default camera for the scene.
  65671. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  65672. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  65673. * @param replace has default false, when true replaces the active camera in the scene
  65674. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  65675. */
  65676. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  65677. /**
  65678. * Creates a default camera and a default light.
  65679. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  65680. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  65681. * @param replace has the default false, when true replaces the active camera/light in the scene
  65682. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  65683. */
  65684. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  65685. /**
  65686. * Creates a new sky box
  65687. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  65688. * @param environmentTexture defines the texture to use as environment texture
  65689. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  65690. * @param scale defines the overall scale of the skybox
  65691. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  65692. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  65693. * @returns a new mesh holding the sky box
  65694. */
  65695. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  65696. /**
  65697. * Creates a new environment
  65698. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  65699. * @param options defines the options you can use to configure the environment
  65700. * @returns the new EnvironmentHelper
  65701. */
  65702. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  65703. /**
  65704. * Creates a new VREXperienceHelper
  65705. * @see https://doc.babylonjs.com/how_to/webvr_helper
  65706. * @param webVROptions defines the options used to create the new VREXperienceHelper
  65707. * @returns a new VREXperienceHelper
  65708. */
  65709. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  65710. /**
  65711. * Creates a new WebXRDefaultExperience
  65712. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  65713. * @param options experience options
  65714. * @returns a promise for a new WebXRDefaultExperience
  65715. */
  65716. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  65717. }
  65718. }
  65719. }
  65720. declare module "babylonjs/Helpers/videoDome" {
  65721. import { Scene } from "babylonjs/scene";
  65722. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  65723. import { TextureDome } from "babylonjs/Helpers/textureDome";
  65724. /**
  65725. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  65726. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  65727. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  65728. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  65729. */
  65730. export class VideoDome extends TextureDome<VideoTexture> {
  65731. /**
  65732. * Define the video source as a Monoscopic panoramic 360 video.
  65733. */
  65734. static readonly MODE_MONOSCOPIC: number;
  65735. /**
  65736. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  65737. */
  65738. static readonly MODE_TOPBOTTOM: number;
  65739. /**
  65740. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  65741. */
  65742. static readonly MODE_SIDEBYSIDE: number;
  65743. /**
  65744. * Get the video texture associated with this video dome
  65745. */
  65746. get videoTexture(): VideoTexture;
  65747. /**
  65748. * Get the video mode of this dome
  65749. */
  65750. get videoMode(): number;
  65751. /**
  65752. * Set the video mode of this dome.
  65753. * @see textureMode
  65754. */
  65755. set videoMode(value: number);
  65756. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  65757. }
  65758. }
  65759. declare module "babylonjs/Helpers/index" {
  65760. export * from "babylonjs/Helpers/environmentHelper";
  65761. export * from "babylonjs/Helpers/photoDome";
  65762. export * from "babylonjs/Helpers/sceneHelpers";
  65763. export * from "babylonjs/Helpers/videoDome";
  65764. }
  65765. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  65766. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  65767. import { IDisposable } from "babylonjs/scene";
  65768. import { Engine } from "babylonjs/Engines/engine";
  65769. /**
  65770. * This class can be used to get instrumentation data from a Babylon engine
  65771. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  65772. */
  65773. export class EngineInstrumentation implements IDisposable {
  65774. /**
  65775. * Define the instrumented engine.
  65776. */
  65777. engine: Engine;
  65778. private _captureGPUFrameTime;
  65779. private _gpuFrameTimeToken;
  65780. private _gpuFrameTime;
  65781. private _captureShaderCompilationTime;
  65782. private _shaderCompilationTime;
  65783. private _onBeginFrameObserver;
  65784. private _onEndFrameObserver;
  65785. private _onBeforeShaderCompilationObserver;
  65786. private _onAfterShaderCompilationObserver;
  65787. /**
  65788. * Gets the perf counter used for GPU frame time
  65789. */
  65790. get gpuFrameTimeCounter(): PerfCounter;
  65791. /**
  65792. * Gets the GPU frame time capture status
  65793. */
  65794. get captureGPUFrameTime(): boolean;
  65795. /**
  65796. * Enable or disable the GPU frame time capture
  65797. */
  65798. set captureGPUFrameTime(value: boolean);
  65799. /**
  65800. * Gets the perf counter used for shader compilation time
  65801. */
  65802. get shaderCompilationTimeCounter(): PerfCounter;
  65803. /**
  65804. * Gets the shader compilation time capture status
  65805. */
  65806. get captureShaderCompilationTime(): boolean;
  65807. /**
  65808. * Enable or disable the shader compilation time capture
  65809. */
  65810. set captureShaderCompilationTime(value: boolean);
  65811. /**
  65812. * Instantiates a new engine instrumentation.
  65813. * This class can be used to get instrumentation data from a Babylon engine
  65814. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  65815. * @param engine Defines the engine to instrument
  65816. */
  65817. constructor(
  65818. /**
  65819. * Define the instrumented engine.
  65820. */
  65821. engine: Engine);
  65822. /**
  65823. * Dispose and release associated resources.
  65824. */
  65825. dispose(): void;
  65826. }
  65827. }
  65828. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  65829. import { Scene, IDisposable } from "babylonjs/scene";
  65830. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  65831. /**
  65832. * This class can be used to get instrumentation data from a Babylon engine
  65833. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  65834. */
  65835. export class SceneInstrumentation implements IDisposable {
  65836. /**
  65837. * Defines the scene to instrument
  65838. */
  65839. scene: Scene;
  65840. private _captureActiveMeshesEvaluationTime;
  65841. private _activeMeshesEvaluationTime;
  65842. private _captureRenderTargetsRenderTime;
  65843. private _renderTargetsRenderTime;
  65844. private _captureFrameTime;
  65845. private _frameTime;
  65846. private _captureRenderTime;
  65847. private _renderTime;
  65848. private _captureInterFrameTime;
  65849. private _interFrameTime;
  65850. private _captureParticlesRenderTime;
  65851. private _particlesRenderTime;
  65852. private _captureSpritesRenderTime;
  65853. private _spritesRenderTime;
  65854. private _capturePhysicsTime;
  65855. private _physicsTime;
  65856. private _captureAnimationsTime;
  65857. private _animationsTime;
  65858. private _captureCameraRenderTime;
  65859. private _cameraRenderTime;
  65860. private _onBeforeActiveMeshesEvaluationObserver;
  65861. private _onAfterActiveMeshesEvaluationObserver;
  65862. private _onBeforeRenderTargetsRenderObserver;
  65863. private _onAfterRenderTargetsRenderObserver;
  65864. private _onAfterRenderObserver;
  65865. private _onBeforeDrawPhaseObserver;
  65866. private _onAfterDrawPhaseObserver;
  65867. private _onBeforeAnimationsObserver;
  65868. private _onBeforeParticlesRenderingObserver;
  65869. private _onAfterParticlesRenderingObserver;
  65870. private _onBeforeSpritesRenderingObserver;
  65871. private _onAfterSpritesRenderingObserver;
  65872. private _onBeforePhysicsObserver;
  65873. private _onAfterPhysicsObserver;
  65874. private _onAfterAnimationsObserver;
  65875. private _onBeforeCameraRenderObserver;
  65876. private _onAfterCameraRenderObserver;
  65877. /**
  65878. * Gets the perf counter used for active meshes evaluation time
  65879. */
  65880. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  65881. /**
  65882. * Gets the active meshes evaluation time capture status
  65883. */
  65884. get captureActiveMeshesEvaluationTime(): boolean;
  65885. /**
  65886. * Enable or disable the active meshes evaluation time capture
  65887. */
  65888. set captureActiveMeshesEvaluationTime(value: boolean);
  65889. /**
  65890. * Gets the perf counter used for render targets render time
  65891. */
  65892. get renderTargetsRenderTimeCounter(): PerfCounter;
  65893. /**
  65894. * Gets the render targets render time capture status
  65895. */
  65896. get captureRenderTargetsRenderTime(): boolean;
  65897. /**
  65898. * Enable or disable the render targets render time capture
  65899. */
  65900. set captureRenderTargetsRenderTime(value: boolean);
  65901. /**
  65902. * Gets the perf counter used for particles render time
  65903. */
  65904. get particlesRenderTimeCounter(): PerfCounter;
  65905. /**
  65906. * Gets the particles render time capture status
  65907. */
  65908. get captureParticlesRenderTime(): boolean;
  65909. /**
  65910. * Enable or disable the particles render time capture
  65911. */
  65912. set captureParticlesRenderTime(value: boolean);
  65913. /**
  65914. * Gets the perf counter used for sprites render time
  65915. */
  65916. get spritesRenderTimeCounter(): PerfCounter;
  65917. /**
  65918. * Gets the sprites render time capture status
  65919. */
  65920. get captureSpritesRenderTime(): boolean;
  65921. /**
  65922. * Enable or disable the sprites render time capture
  65923. */
  65924. set captureSpritesRenderTime(value: boolean);
  65925. /**
  65926. * Gets the perf counter used for physics time
  65927. */
  65928. get physicsTimeCounter(): PerfCounter;
  65929. /**
  65930. * Gets the physics time capture status
  65931. */
  65932. get capturePhysicsTime(): boolean;
  65933. /**
  65934. * Enable or disable the physics time capture
  65935. */
  65936. set capturePhysicsTime(value: boolean);
  65937. /**
  65938. * Gets the perf counter used for animations time
  65939. */
  65940. get animationsTimeCounter(): PerfCounter;
  65941. /**
  65942. * Gets the animations time capture status
  65943. */
  65944. get captureAnimationsTime(): boolean;
  65945. /**
  65946. * Enable or disable the animations time capture
  65947. */
  65948. set captureAnimationsTime(value: boolean);
  65949. /**
  65950. * Gets the perf counter used for frame time capture
  65951. */
  65952. get frameTimeCounter(): PerfCounter;
  65953. /**
  65954. * Gets the frame time capture status
  65955. */
  65956. get captureFrameTime(): boolean;
  65957. /**
  65958. * Enable or disable the frame time capture
  65959. */
  65960. set captureFrameTime(value: boolean);
  65961. /**
  65962. * Gets the perf counter used for inter-frames time capture
  65963. */
  65964. get interFrameTimeCounter(): PerfCounter;
  65965. /**
  65966. * Gets the inter-frames time capture status
  65967. */
  65968. get captureInterFrameTime(): boolean;
  65969. /**
  65970. * Enable or disable the inter-frames time capture
  65971. */
  65972. set captureInterFrameTime(value: boolean);
  65973. /**
  65974. * Gets the perf counter used for render time capture
  65975. */
  65976. get renderTimeCounter(): PerfCounter;
  65977. /**
  65978. * Gets the render time capture status
  65979. */
  65980. get captureRenderTime(): boolean;
  65981. /**
  65982. * Enable or disable the render time capture
  65983. */
  65984. set captureRenderTime(value: boolean);
  65985. /**
  65986. * Gets the perf counter used for camera render time capture
  65987. */
  65988. get cameraRenderTimeCounter(): PerfCounter;
  65989. /**
  65990. * Gets the camera render time capture status
  65991. */
  65992. get captureCameraRenderTime(): boolean;
  65993. /**
  65994. * Enable or disable the camera render time capture
  65995. */
  65996. set captureCameraRenderTime(value: boolean);
  65997. /**
  65998. * Gets the perf counter used for draw calls
  65999. */
  66000. get drawCallsCounter(): PerfCounter;
  66001. /**
  66002. * Instantiates a new scene instrumentation.
  66003. * This class can be used to get instrumentation data from a Babylon engine
  66004. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  66005. * @param scene Defines the scene to instrument
  66006. */
  66007. constructor(
  66008. /**
  66009. * Defines the scene to instrument
  66010. */
  66011. scene: Scene);
  66012. /**
  66013. * Dispose and release associated resources.
  66014. */
  66015. dispose(): void;
  66016. }
  66017. }
  66018. declare module "babylonjs/Instrumentation/index" {
  66019. export * from "babylonjs/Instrumentation/engineInstrumentation";
  66020. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  66021. export * from "babylonjs/Instrumentation/timeToken";
  66022. }
  66023. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  66024. /** @hidden */
  66025. export var glowMapGenerationPixelShader: {
  66026. name: string;
  66027. shader: string;
  66028. };
  66029. }
  66030. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  66031. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66032. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66033. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66034. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal";
  66036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66037. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66038. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66039. /** @hidden */
  66040. export var glowMapGenerationVertexShader: {
  66041. name: string;
  66042. shader: string;
  66043. };
  66044. }
  66045. declare module "babylonjs/Layers/effectLayer" {
  66046. import { Observable } from "babylonjs/Misc/observable";
  66047. import { Nullable } from "babylonjs/types";
  66048. import { Camera } from "babylonjs/Cameras/camera";
  66049. import { Scene } from "babylonjs/scene";
  66050. import { ISize } from "babylonjs/Maths/math.size";
  66051. import { Color4 } from "babylonjs/Maths/math.color";
  66052. import { Engine } from "babylonjs/Engines/engine";
  66053. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66055. import { Mesh } from "babylonjs/Meshes/mesh";
  66056. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66057. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66058. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66059. import { Effect } from "babylonjs/Materials/effect";
  66060. import { Material } from "babylonjs/Materials/material";
  66061. import "babylonjs/Shaders/glowMapGeneration.fragment";
  66062. import "babylonjs/Shaders/glowMapGeneration.vertex";
  66063. /**
  66064. * Effect layer options. This helps customizing the behaviour
  66065. * of the effect layer.
  66066. */
  66067. export interface IEffectLayerOptions {
  66068. /**
  66069. * Multiplication factor apply to the canvas size to compute the render target size
  66070. * used to generated the objects (the smaller the faster).
  66071. */
  66072. mainTextureRatio: number;
  66073. /**
  66074. * Enforces a fixed size texture to ensure effect stability across devices.
  66075. */
  66076. mainTextureFixedSize?: number;
  66077. /**
  66078. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  66079. */
  66080. alphaBlendingMode: number;
  66081. /**
  66082. * The camera attached to the layer.
  66083. */
  66084. camera: Nullable<Camera>;
  66085. /**
  66086. * The rendering group to draw the layer in.
  66087. */
  66088. renderingGroupId: number;
  66089. }
  66090. /**
  66091. * The effect layer Helps adding post process effect blended with the main pass.
  66092. *
  66093. * This can be for instance use to generate glow or highlight effects on the scene.
  66094. *
  66095. * The effect layer class can not be used directly and is intented to inherited from to be
  66096. * customized per effects.
  66097. */
  66098. export abstract class EffectLayer {
  66099. private _vertexBuffers;
  66100. private _indexBuffer;
  66101. private _cachedDefines;
  66102. private _effectLayerMapGenerationEffect;
  66103. private _effectLayerOptions;
  66104. private _mergeEffect;
  66105. protected _scene: Scene;
  66106. protected _engine: Engine;
  66107. protected _maxSize: number;
  66108. protected _mainTextureDesiredSize: ISize;
  66109. protected _mainTexture: RenderTargetTexture;
  66110. protected _shouldRender: boolean;
  66111. protected _postProcesses: PostProcess[];
  66112. protected _textures: BaseTexture[];
  66113. protected _emissiveTextureAndColor: {
  66114. texture: Nullable<BaseTexture>;
  66115. color: Color4;
  66116. };
  66117. /**
  66118. * The name of the layer
  66119. */
  66120. name: string;
  66121. /**
  66122. * The clear color of the texture used to generate the glow map.
  66123. */
  66124. neutralColor: Color4;
  66125. /**
  66126. * Specifies whether the highlight layer is enabled or not.
  66127. */
  66128. isEnabled: boolean;
  66129. /**
  66130. * Gets the camera attached to the layer.
  66131. */
  66132. get camera(): Nullable<Camera>;
  66133. /**
  66134. * Gets the rendering group id the layer should render in.
  66135. */
  66136. get renderingGroupId(): number;
  66137. set renderingGroupId(renderingGroupId: number);
  66138. /**
  66139. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  66140. */
  66141. disableBoundingBoxesFromEffectLayer: boolean;
  66142. /**
  66143. * An event triggered when the effect layer has been disposed.
  66144. */
  66145. onDisposeObservable: Observable<EffectLayer>;
  66146. /**
  66147. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  66148. */
  66149. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  66150. /**
  66151. * An event triggered when the generated texture is being merged in the scene.
  66152. */
  66153. onBeforeComposeObservable: Observable<EffectLayer>;
  66154. /**
  66155. * An event triggered when the mesh is rendered into the effect render target.
  66156. */
  66157. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  66158. /**
  66159. * An event triggered after the mesh has been rendered into the effect render target.
  66160. */
  66161. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  66162. /**
  66163. * An event triggered when the generated texture has been merged in the scene.
  66164. */
  66165. onAfterComposeObservable: Observable<EffectLayer>;
  66166. /**
  66167. * An event triggered when the effect layer changes its size.
  66168. */
  66169. onSizeChangedObservable: Observable<EffectLayer>;
  66170. /** @hidden */
  66171. static _SceneComponentInitialization: (scene: Scene) => void;
  66172. /**
  66173. * Instantiates a new effect Layer and references it in the scene.
  66174. * @param name The name of the layer
  66175. * @param scene The scene to use the layer in
  66176. */
  66177. constructor(
  66178. /** The Friendly of the effect in the scene */
  66179. name: string, scene: Scene);
  66180. /**
  66181. * Get the effect name of the layer.
  66182. * @return The effect name
  66183. */
  66184. abstract getEffectName(): string;
  66185. /**
  66186. * Checks for the readiness of the element composing the layer.
  66187. * @param subMesh the mesh to check for
  66188. * @param useInstances specify whether or not to use instances to render the mesh
  66189. * @return true if ready otherwise, false
  66190. */
  66191. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66192. /**
  66193. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  66194. * @returns true if the effect requires stencil during the main canvas render pass.
  66195. */
  66196. abstract needStencil(): boolean;
  66197. /**
  66198. * Create the merge effect. This is the shader use to blit the information back
  66199. * to the main canvas at the end of the scene rendering.
  66200. * @returns The effect containing the shader used to merge the effect on the main canvas
  66201. */
  66202. protected abstract _createMergeEffect(): Effect;
  66203. /**
  66204. * Creates the render target textures and post processes used in the effect layer.
  66205. */
  66206. protected abstract _createTextureAndPostProcesses(): void;
  66207. /**
  66208. * Implementation specific of rendering the generating effect on the main canvas.
  66209. * @param effect The effect used to render through
  66210. */
  66211. protected abstract _internalRender(effect: Effect): void;
  66212. /**
  66213. * Sets the required values for both the emissive texture and and the main color.
  66214. */
  66215. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  66216. /**
  66217. * Free any resources and references associated to a mesh.
  66218. * Internal use
  66219. * @param mesh The mesh to free.
  66220. */
  66221. abstract _disposeMesh(mesh: Mesh): void;
  66222. /**
  66223. * Serializes this layer (Glow or Highlight for example)
  66224. * @returns a serialized layer object
  66225. */
  66226. abstract serialize?(): any;
  66227. /**
  66228. * Initializes the effect layer with the required options.
  66229. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  66230. */
  66231. protected _init(options: Partial<IEffectLayerOptions>): void;
  66232. /**
  66233. * Generates the index buffer of the full screen quad blending to the main canvas.
  66234. */
  66235. private _generateIndexBuffer;
  66236. /**
  66237. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  66238. */
  66239. private _generateVertexBuffer;
  66240. /**
  66241. * Sets the main texture desired size which is the closest power of two
  66242. * of the engine canvas size.
  66243. */
  66244. private _setMainTextureSize;
  66245. /**
  66246. * Creates the main texture for the effect layer.
  66247. */
  66248. protected _createMainTexture(): void;
  66249. /**
  66250. * Adds specific effects defines.
  66251. * @param defines The defines to add specifics to.
  66252. */
  66253. protected _addCustomEffectDefines(defines: string[]): void;
  66254. /**
  66255. * Checks for the readiness of the element composing the layer.
  66256. * @param subMesh the mesh to check for
  66257. * @param useInstances specify whether or not to use instances to render the mesh
  66258. * @param emissiveTexture the associated emissive texture used to generate the glow
  66259. * @return true if ready otherwise, false
  66260. */
  66261. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  66262. /**
  66263. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  66264. */
  66265. render(): void;
  66266. /**
  66267. * Determine if a given mesh will be used in the current effect.
  66268. * @param mesh mesh to test
  66269. * @returns true if the mesh will be used
  66270. */
  66271. hasMesh(mesh: AbstractMesh): boolean;
  66272. /**
  66273. * Returns true if the layer contains information to display, otherwise false.
  66274. * @returns true if the glow layer should be rendered
  66275. */
  66276. shouldRender(): boolean;
  66277. /**
  66278. * Returns true if the mesh should render, otherwise false.
  66279. * @param mesh The mesh to render
  66280. * @returns true if it should render otherwise false
  66281. */
  66282. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  66283. /**
  66284. * Returns true if the mesh can be rendered, otherwise false.
  66285. * @param mesh The mesh to render
  66286. * @param material The material used on the mesh
  66287. * @returns true if it can be rendered otherwise false
  66288. */
  66289. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  66290. /**
  66291. * Returns true if the mesh should render, otherwise false.
  66292. * @param mesh The mesh to render
  66293. * @returns true if it should render otherwise false
  66294. */
  66295. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  66296. /**
  66297. * Renders the submesh passed in parameter to the generation map.
  66298. */
  66299. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  66300. /**
  66301. * Defines whether the current material of the mesh should be use to render the effect.
  66302. * @param mesh defines the current mesh to render
  66303. */
  66304. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  66305. /**
  66306. * Rebuild the required buffers.
  66307. * @hidden Internal use only.
  66308. */
  66309. _rebuild(): void;
  66310. /**
  66311. * Dispose only the render target textures and post process.
  66312. */
  66313. private _disposeTextureAndPostProcesses;
  66314. /**
  66315. * Dispose the highlight layer and free resources.
  66316. */
  66317. dispose(): void;
  66318. /**
  66319. * Gets the class name of the effect layer
  66320. * @returns the string with the class name of the effect layer
  66321. */
  66322. getClassName(): string;
  66323. /**
  66324. * Creates an effect layer from parsed effect layer data
  66325. * @param parsedEffectLayer defines effect layer data
  66326. * @param scene defines the current scene
  66327. * @param rootUrl defines the root URL containing the effect layer information
  66328. * @returns a parsed effect Layer
  66329. */
  66330. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  66331. }
  66332. }
  66333. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  66334. import { Scene } from "babylonjs/scene";
  66335. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  66336. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  66337. import { AbstractScene } from "babylonjs/abstractScene";
  66338. module "babylonjs/abstractScene" {
  66339. interface AbstractScene {
  66340. /**
  66341. * The list of effect layers (highlights/glow) added to the scene
  66342. * @see https://doc.babylonjs.com/how_to/highlight_layer
  66343. * @see https://doc.babylonjs.com/how_to/glow_layer
  66344. */
  66345. effectLayers: Array<EffectLayer>;
  66346. /**
  66347. * Removes the given effect layer from this scene.
  66348. * @param toRemove defines the effect layer to remove
  66349. * @returns the index of the removed effect layer
  66350. */
  66351. removeEffectLayer(toRemove: EffectLayer): number;
  66352. /**
  66353. * Adds the given effect layer to this scene
  66354. * @param newEffectLayer defines the effect layer to add
  66355. */
  66356. addEffectLayer(newEffectLayer: EffectLayer): void;
  66357. }
  66358. }
  66359. /**
  66360. * Defines the layer scene component responsible to manage any effect layers
  66361. * in a given scene.
  66362. */
  66363. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  66364. /**
  66365. * The component name helpful to identify the component in the list of scene components.
  66366. */
  66367. readonly name: string;
  66368. /**
  66369. * The scene the component belongs to.
  66370. */
  66371. scene: Scene;
  66372. private _engine;
  66373. private _renderEffects;
  66374. private _needStencil;
  66375. private _previousStencilState;
  66376. /**
  66377. * Creates a new instance of the component for the given scene
  66378. * @param scene Defines the scene to register the component in
  66379. */
  66380. constructor(scene: Scene);
  66381. /**
  66382. * Registers the component in a given scene
  66383. */
  66384. register(): void;
  66385. /**
  66386. * Rebuilds the elements related to this component in case of
  66387. * context lost for instance.
  66388. */
  66389. rebuild(): void;
  66390. /**
  66391. * Serializes the component data to the specified json object
  66392. * @param serializationObject The object to serialize to
  66393. */
  66394. serialize(serializationObject: any): void;
  66395. /**
  66396. * Adds all the elements from the container to the scene
  66397. * @param container the container holding the elements
  66398. */
  66399. addFromContainer(container: AbstractScene): void;
  66400. /**
  66401. * Removes all the elements in the container from the scene
  66402. * @param container contains the elements to remove
  66403. * @param dispose if the removed element should be disposed (default: false)
  66404. */
  66405. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66406. /**
  66407. * Disposes the component and the associated resources.
  66408. */
  66409. dispose(): void;
  66410. private _isReadyForMesh;
  66411. private _renderMainTexture;
  66412. private _setStencil;
  66413. private _setStencilBack;
  66414. private _draw;
  66415. private _drawCamera;
  66416. private _drawRenderingGroup;
  66417. }
  66418. }
  66419. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  66420. /** @hidden */
  66421. export var glowMapMergePixelShader: {
  66422. name: string;
  66423. shader: string;
  66424. };
  66425. }
  66426. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  66427. /** @hidden */
  66428. export var glowMapMergeVertexShader: {
  66429. name: string;
  66430. shader: string;
  66431. };
  66432. }
  66433. declare module "babylonjs/Layers/glowLayer" {
  66434. import { Nullable } from "babylonjs/types";
  66435. import { Camera } from "babylonjs/Cameras/camera";
  66436. import { Scene } from "babylonjs/scene";
  66437. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66439. import { Mesh } from "babylonjs/Meshes/mesh";
  66440. import { Texture } from "babylonjs/Materials/Textures/texture";
  66441. import { Effect } from "babylonjs/Materials/effect";
  66442. import { Material } from "babylonjs/Materials/material";
  66443. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  66444. import { Color4 } from "babylonjs/Maths/math.color";
  66445. import "babylonjs/Shaders/glowMapMerge.fragment";
  66446. import "babylonjs/Shaders/glowMapMerge.vertex";
  66447. import "babylonjs/Layers/effectLayerSceneComponent";
  66448. module "babylonjs/abstractScene" {
  66449. interface AbstractScene {
  66450. /**
  66451. * Return a the first highlight layer of the scene with a given name.
  66452. * @param name The name of the highlight layer to look for.
  66453. * @return The highlight layer if found otherwise null.
  66454. */
  66455. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  66456. }
  66457. }
  66458. /**
  66459. * Glow layer options. This helps customizing the behaviour
  66460. * of the glow layer.
  66461. */
  66462. export interface IGlowLayerOptions {
  66463. /**
  66464. * Multiplication factor apply to the canvas size to compute the render target size
  66465. * used to generated the glowing objects (the smaller the faster).
  66466. */
  66467. mainTextureRatio: number;
  66468. /**
  66469. * Enforces a fixed size texture to ensure resize independent blur.
  66470. */
  66471. mainTextureFixedSize?: number;
  66472. /**
  66473. * How big is the kernel of the blur texture.
  66474. */
  66475. blurKernelSize: number;
  66476. /**
  66477. * The camera attached to the layer.
  66478. */
  66479. camera: Nullable<Camera>;
  66480. /**
  66481. * Enable MSAA by choosing the number of samples.
  66482. */
  66483. mainTextureSamples?: number;
  66484. /**
  66485. * The rendering group to draw the layer in.
  66486. */
  66487. renderingGroupId: number;
  66488. }
  66489. /**
  66490. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  66491. *
  66492. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  66493. *
  66494. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  66495. */
  66496. export class GlowLayer extends EffectLayer {
  66497. /**
  66498. * Effect Name of the layer.
  66499. */
  66500. static readonly EffectName: string;
  66501. /**
  66502. * The default blur kernel size used for the glow.
  66503. */
  66504. static DefaultBlurKernelSize: number;
  66505. /**
  66506. * The default texture size ratio used for the glow.
  66507. */
  66508. static DefaultTextureRatio: number;
  66509. /**
  66510. * Sets the kernel size of the blur.
  66511. */
  66512. set blurKernelSize(value: number);
  66513. /**
  66514. * Gets the kernel size of the blur.
  66515. */
  66516. get blurKernelSize(): number;
  66517. /**
  66518. * Sets the glow intensity.
  66519. */
  66520. set intensity(value: number);
  66521. /**
  66522. * Gets the glow intensity.
  66523. */
  66524. get intensity(): number;
  66525. private _options;
  66526. private _intensity;
  66527. private _horizontalBlurPostprocess1;
  66528. private _verticalBlurPostprocess1;
  66529. private _horizontalBlurPostprocess2;
  66530. private _verticalBlurPostprocess2;
  66531. private _blurTexture1;
  66532. private _blurTexture2;
  66533. private _postProcesses1;
  66534. private _postProcesses2;
  66535. private _includedOnlyMeshes;
  66536. private _excludedMeshes;
  66537. private _meshesUsingTheirOwnMaterials;
  66538. /**
  66539. * Callback used to let the user override the color selection on a per mesh basis
  66540. */
  66541. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  66542. /**
  66543. * Callback used to let the user override the texture selection on a per mesh basis
  66544. */
  66545. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  66546. /**
  66547. * Instantiates a new glow Layer and references it to the scene.
  66548. * @param name The name of the layer
  66549. * @param scene The scene to use the layer in
  66550. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  66551. */
  66552. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  66553. /**
  66554. * Get the effect name of the layer.
  66555. * @return The effect name
  66556. */
  66557. getEffectName(): string;
  66558. /**
  66559. * Create the merge effect. This is the shader use to blit the information back
  66560. * to the main canvas at the end of the scene rendering.
  66561. */
  66562. protected _createMergeEffect(): Effect;
  66563. /**
  66564. * Creates the render target textures and post processes used in the glow layer.
  66565. */
  66566. protected _createTextureAndPostProcesses(): void;
  66567. /**
  66568. * Checks for the readiness of the element composing the layer.
  66569. * @param subMesh the mesh to check for
  66570. * @param useInstances specify whether or not to use instances to render the mesh
  66571. * @param emissiveTexture the associated emissive texture used to generate the glow
  66572. * @return true if ready otherwise, false
  66573. */
  66574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66575. /**
  66576. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  66577. */
  66578. needStencil(): boolean;
  66579. /**
  66580. * Returns true if the mesh can be rendered, otherwise false.
  66581. * @param mesh The mesh to render
  66582. * @param material The material used on the mesh
  66583. * @returns true if it can be rendered otherwise false
  66584. */
  66585. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  66586. /**
  66587. * Implementation specific of rendering the generating effect on the main canvas.
  66588. * @param effect The effect used to render through
  66589. */
  66590. protected _internalRender(effect: Effect): void;
  66591. /**
  66592. * Sets the required values for both the emissive texture and and the main color.
  66593. */
  66594. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  66595. /**
  66596. * Returns true if the mesh should render, otherwise false.
  66597. * @param mesh The mesh to render
  66598. * @returns true if it should render otherwise false
  66599. */
  66600. protected _shouldRenderMesh(mesh: Mesh): boolean;
  66601. /**
  66602. * Adds specific effects defines.
  66603. * @param defines The defines to add specifics to.
  66604. */
  66605. protected _addCustomEffectDefines(defines: string[]): void;
  66606. /**
  66607. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  66608. * @param mesh The mesh to exclude from the glow layer
  66609. */
  66610. addExcludedMesh(mesh: Mesh): void;
  66611. /**
  66612. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  66613. * @param mesh The mesh to remove
  66614. */
  66615. removeExcludedMesh(mesh: Mesh): void;
  66616. /**
  66617. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  66618. * @param mesh The mesh to include in the glow layer
  66619. */
  66620. addIncludedOnlyMesh(mesh: Mesh): void;
  66621. /**
  66622. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  66623. * @param mesh The mesh to remove
  66624. */
  66625. removeIncludedOnlyMesh(mesh: Mesh): void;
  66626. /**
  66627. * Determine if a given mesh will be used in the glow layer
  66628. * @param mesh The mesh to test
  66629. * @returns true if the mesh will be highlighted by the current glow layer
  66630. */
  66631. hasMesh(mesh: AbstractMesh): boolean;
  66632. /**
  66633. * Defines whether the current material of the mesh should be use to render the effect.
  66634. * @param mesh defines the current mesh to render
  66635. */
  66636. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  66637. /**
  66638. * Add a mesh to be rendered through its own material and not with emissive only.
  66639. * @param mesh The mesh for which we need to use its material
  66640. */
  66641. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  66642. /**
  66643. * Remove a mesh from being rendered through its own material and not with emissive only.
  66644. * @param mesh The mesh for which we need to not use its material
  66645. */
  66646. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  66647. /**
  66648. * Free any resources and references associated to a mesh.
  66649. * Internal use
  66650. * @param mesh The mesh to free.
  66651. * @hidden
  66652. */
  66653. _disposeMesh(mesh: Mesh): void;
  66654. /**
  66655. * Gets the class name of the effect layer
  66656. * @returns the string with the class name of the effect layer
  66657. */
  66658. getClassName(): string;
  66659. /**
  66660. * Serializes this glow layer
  66661. * @returns a serialized glow layer object
  66662. */
  66663. serialize(): any;
  66664. /**
  66665. * Creates a Glow Layer from parsed glow layer data
  66666. * @param parsedGlowLayer defines glow layer data
  66667. * @param scene defines the current scene
  66668. * @param rootUrl defines the root URL containing the glow layer information
  66669. * @returns a parsed Glow Layer
  66670. */
  66671. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  66672. }
  66673. }
  66674. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  66675. /** @hidden */
  66676. export var glowBlurPostProcessPixelShader: {
  66677. name: string;
  66678. shader: string;
  66679. };
  66680. }
  66681. declare module "babylonjs/Layers/highlightLayer" {
  66682. import { Observable } from "babylonjs/Misc/observable";
  66683. import { Nullable } from "babylonjs/types";
  66684. import { Camera } from "babylonjs/Cameras/camera";
  66685. import { Scene } from "babylonjs/scene";
  66686. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66688. import { Mesh } from "babylonjs/Meshes/mesh";
  66689. import { Effect } from "babylonjs/Materials/effect";
  66690. import { Material } from "babylonjs/Materials/material";
  66691. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  66692. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66693. import "babylonjs/Shaders/glowMapMerge.fragment";
  66694. import "babylonjs/Shaders/glowMapMerge.vertex";
  66695. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  66696. module "babylonjs/abstractScene" {
  66697. interface AbstractScene {
  66698. /**
  66699. * Return a the first highlight layer of the scene with a given name.
  66700. * @param name The name of the highlight layer to look for.
  66701. * @return The highlight layer if found otherwise null.
  66702. */
  66703. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  66704. }
  66705. }
  66706. /**
  66707. * Highlight layer options. This helps customizing the behaviour
  66708. * of the highlight layer.
  66709. */
  66710. export interface IHighlightLayerOptions {
  66711. /**
  66712. * Multiplication factor apply to the canvas size to compute the render target size
  66713. * used to generated the glowing objects (the smaller the faster).
  66714. */
  66715. mainTextureRatio: number;
  66716. /**
  66717. * Enforces a fixed size texture to ensure resize independent blur.
  66718. */
  66719. mainTextureFixedSize?: number;
  66720. /**
  66721. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  66722. * of the picture to blur (the smaller the faster).
  66723. */
  66724. blurTextureSizeRatio: number;
  66725. /**
  66726. * How big in texel of the blur texture is the vertical blur.
  66727. */
  66728. blurVerticalSize: number;
  66729. /**
  66730. * How big in texel of the blur texture is the horizontal blur.
  66731. */
  66732. blurHorizontalSize: number;
  66733. /**
  66734. * Alpha blending mode used to apply the blur. Default is combine.
  66735. */
  66736. alphaBlendingMode: number;
  66737. /**
  66738. * The camera attached to the layer.
  66739. */
  66740. camera: Nullable<Camera>;
  66741. /**
  66742. * Should we display highlight as a solid stroke?
  66743. */
  66744. isStroke?: boolean;
  66745. /**
  66746. * The rendering group to draw the layer in.
  66747. */
  66748. renderingGroupId: number;
  66749. }
  66750. /**
  66751. * The highlight layer Helps adding a glow effect around a mesh.
  66752. *
  66753. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  66754. * glowy meshes to your scene.
  66755. *
  66756. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  66757. */
  66758. export class HighlightLayer extends EffectLayer {
  66759. name: string;
  66760. /**
  66761. * Effect Name of the highlight layer.
  66762. */
  66763. static readonly EffectName: string;
  66764. /**
  66765. * The neutral color used during the preparation of the glow effect.
  66766. * This is black by default as the blend operation is a blend operation.
  66767. */
  66768. static NeutralColor: Color4;
  66769. /**
  66770. * Stencil value used for glowing meshes.
  66771. */
  66772. static GlowingMeshStencilReference: number;
  66773. /**
  66774. * Stencil value used for the other meshes in the scene.
  66775. */
  66776. static NormalMeshStencilReference: number;
  66777. /**
  66778. * Specifies whether or not the inner glow is ACTIVE in the layer.
  66779. */
  66780. innerGlow: boolean;
  66781. /**
  66782. * Specifies whether or not the outer glow is ACTIVE in the layer.
  66783. */
  66784. outerGlow: boolean;
  66785. /**
  66786. * Specifies the horizontal size of the blur.
  66787. */
  66788. set blurHorizontalSize(value: number);
  66789. /**
  66790. * Specifies the vertical size of the blur.
  66791. */
  66792. set blurVerticalSize(value: number);
  66793. /**
  66794. * Gets the horizontal size of the blur.
  66795. */
  66796. get blurHorizontalSize(): number;
  66797. /**
  66798. * Gets the vertical size of the blur.
  66799. */
  66800. get blurVerticalSize(): number;
  66801. /**
  66802. * An event triggered when the highlight layer is being blurred.
  66803. */
  66804. onBeforeBlurObservable: Observable<HighlightLayer>;
  66805. /**
  66806. * An event triggered when the highlight layer has been blurred.
  66807. */
  66808. onAfterBlurObservable: Observable<HighlightLayer>;
  66809. private _instanceGlowingMeshStencilReference;
  66810. private _options;
  66811. private _downSamplePostprocess;
  66812. private _horizontalBlurPostprocess;
  66813. private _verticalBlurPostprocess;
  66814. private _blurTexture;
  66815. private _meshes;
  66816. private _excludedMeshes;
  66817. /**
  66818. * Instantiates a new highlight Layer and references it to the scene..
  66819. * @param name The name of the layer
  66820. * @param scene The scene to use the layer in
  66821. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  66822. */
  66823. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  66824. /**
  66825. * Get the effect name of the layer.
  66826. * @return The effect name
  66827. */
  66828. getEffectName(): string;
  66829. /**
  66830. * Create the merge effect. This is the shader use to blit the information back
  66831. * to the main canvas at the end of the scene rendering.
  66832. */
  66833. protected _createMergeEffect(): Effect;
  66834. /**
  66835. * Creates the render target textures and post processes used in the highlight layer.
  66836. */
  66837. protected _createTextureAndPostProcesses(): void;
  66838. /**
  66839. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  66840. */
  66841. needStencil(): boolean;
  66842. /**
  66843. * Checks for the readiness of the element composing the layer.
  66844. * @param subMesh the mesh to check for
  66845. * @param useInstances specify wether or not to use instances to render the mesh
  66846. * @param emissiveTexture the associated emissive texture used to generate the glow
  66847. * @return true if ready otherwise, false
  66848. */
  66849. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66850. /**
  66851. * Implementation specific of rendering the generating effect on the main canvas.
  66852. * @param effect The effect used to render through
  66853. */
  66854. protected _internalRender(effect: Effect): void;
  66855. /**
  66856. * Returns true if the layer contains information to display, otherwise false.
  66857. */
  66858. shouldRender(): boolean;
  66859. /**
  66860. * Returns true if the mesh should render, otherwise false.
  66861. * @param mesh The mesh to render
  66862. * @returns true if it should render otherwise false
  66863. */
  66864. protected _shouldRenderMesh(mesh: Mesh): boolean;
  66865. /**
  66866. * Returns true if the mesh can be rendered, otherwise false.
  66867. * @param mesh The mesh to render
  66868. * @param material The material used on the mesh
  66869. * @returns true if it can be rendered otherwise false
  66870. */
  66871. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  66872. /**
  66873. * Adds specific effects defines.
  66874. * @param defines The defines to add specifics to.
  66875. */
  66876. protected _addCustomEffectDefines(defines: string[]): void;
  66877. /**
  66878. * Sets the required values for both the emissive texture and and the main color.
  66879. */
  66880. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  66881. /**
  66882. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  66883. * @param mesh The mesh to exclude from the highlight layer
  66884. */
  66885. addExcludedMesh(mesh: Mesh): void;
  66886. /**
  66887. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  66888. * @param mesh The mesh to highlight
  66889. */
  66890. removeExcludedMesh(mesh: Mesh): void;
  66891. /**
  66892. * Determine if a given mesh will be highlighted by the current HighlightLayer
  66893. * @param mesh mesh to test
  66894. * @returns true if the mesh will be highlighted by the current HighlightLayer
  66895. */
  66896. hasMesh(mesh: AbstractMesh): boolean;
  66897. /**
  66898. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  66899. * @param mesh The mesh to highlight
  66900. * @param color The color of the highlight
  66901. * @param glowEmissiveOnly Extract the glow from the emissive texture
  66902. */
  66903. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  66904. /**
  66905. * Remove a mesh from the highlight layer in order to make it stop glowing.
  66906. * @param mesh The mesh to highlight
  66907. */
  66908. removeMesh(mesh: Mesh): void;
  66909. /**
  66910. * Remove all the meshes currently referenced in the highlight layer
  66911. */
  66912. removeAllMeshes(): void;
  66913. /**
  66914. * Force the stencil to the normal expected value for none glowing parts
  66915. */
  66916. private _defaultStencilReference;
  66917. /**
  66918. * Free any resources and references associated to a mesh.
  66919. * Internal use
  66920. * @param mesh The mesh to free.
  66921. * @hidden
  66922. */
  66923. _disposeMesh(mesh: Mesh): void;
  66924. /**
  66925. * Dispose the highlight layer and free resources.
  66926. */
  66927. dispose(): void;
  66928. /**
  66929. * Gets the class name of the effect layer
  66930. * @returns the string with the class name of the effect layer
  66931. */
  66932. getClassName(): string;
  66933. /**
  66934. * Serializes this Highlight layer
  66935. * @returns a serialized Highlight layer object
  66936. */
  66937. serialize(): any;
  66938. /**
  66939. * Creates a Highlight layer from parsed Highlight layer data
  66940. * @param parsedHightlightLayer defines the Highlight layer data
  66941. * @param scene defines the current scene
  66942. * @param rootUrl defines the root URL containing the Highlight layer information
  66943. * @returns a parsed Highlight layer
  66944. */
  66945. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  66946. }
  66947. }
  66948. declare module "babylonjs/Layers/layerSceneComponent" {
  66949. import { Scene } from "babylonjs/scene";
  66950. import { ISceneComponent } from "babylonjs/sceneComponent";
  66951. import { Layer } from "babylonjs/Layers/layer";
  66952. import { AbstractScene } from "babylonjs/abstractScene";
  66953. module "babylonjs/abstractScene" {
  66954. interface AbstractScene {
  66955. /**
  66956. * The list of layers (background and foreground) of the scene
  66957. */
  66958. layers: Array<Layer>;
  66959. }
  66960. }
  66961. /**
  66962. * Defines the layer scene component responsible to manage any layers
  66963. * in a given scene.
  66964. */
  66965. export class LayerSceneComponent implements ISceneComponent {
  66966. /**
  66967. * The component name helpful to identify the component in the list of scene components.
  66968. */
  66969. readonly name: string;
  66970. /**
  66971. * The scene the component belongs to.
  66972. */
  66973. scene: Scene;
  66974. private _engine;
  66975. /**
  66976. * Creates a new instance of the component for the given scene
  66977. * @param scene Defines the scene to register the component in
  66978. */
  66979. constructor(scene: Scene);
  66980. /**
  66981. * Registers the component in a given scene
  66982. */
  66983. register(): void;
  66984. /**
  66985. * Rebuilds the elements related to this component in case of
  66986. * context lost for instance.
  66987. */
  66988. rebuild(): void;
  66989. /**
  66990. * Disposes the component and the associated resources.
  66991. */
  66992. dispose(): void;
  66993. private _draw;
  66994. private _drawCameraPredicate;
  66995. private _drawCameraBackground;
  66996. private _drawCameraForeground;
  66997. private _drawRenderTargetPredicate;
  66998. private _drawRenderTargetBackground;
  66999. private _drawRenderTargetForeground;
  67000. /**
  67001. * Adds all the elements from the container to the scene
  67002. * @param container the container holding the elements
  67003. */
  67004. addFromContainer(container: AbstractScene): void;
  67005. /**
  67006. * Removes all the elements in the container from the scene
  67007. * @param container contains the elements to remove
  67008. * @param dispose if the removed element should be disposed (default: false)
  67009. */
  67010. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  67011. }
  67012. }
  67013. declare module "babylonjs/Shaders/layer.fragment" {
  67014. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67015. /** @hidden */
  67016. export var layerPixelShader: {
  67017. name: string;
  67018. shader: string;
  67019. };
  67020. }
  67021. declare module "babylonjs/Shaders/layer.vertex" {
  67022. /** @hidden */
  67023. export var layerVertexShader: {
  67024. name: string;
  67025. shader: string;
  67026. };
  67027. }
  67028. declare module "babylonjs/Layers/layer" {
  67029. import { Observable } from "babylonjs/Misc/observable";
  67030. import { Nullable } from "babylonjs/types";
  67031. import { Scene } from "babylonjs/scene";
  67032. import { Vector2 } from "babylonjs/Maths/math.vector";
  67033. import { Color4 } from "babylonjs/Maths/math.color";
  67034. import { Texture } from "babylonjs/Materials/Textures/texture";
  67035. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67036. import "babylonjs/Shaders/layer.fragment";
  67037. import "babylonjs/Shaders/layer.vertex";
  67038. /**
  67039. * This represents a full screen 2d layer.
  67040. * This can be useful to display a picture in the background of your scene for instance.
  67041. * @see https://www.babylonjs-playground.com/#08A2BS#1
  67042. */
  67043. export class Layer {
  67044. /**
  67045. * Define the name of the layer.
  67046. */
  67047. name: string;
  67048. /**
  67049. * Define the texture the layer should display.
  67050. */
  67051. texture: Nullable<Texture>;
  67052. /**
  67053. * Is the layer in background or foreground.
  67054. */
  67055. isBackground: boolean;
  67056. /**
  67057. * Define the color of the layer (instead of texture).
  67058. */
  67059. color: Color4;
  67060. /**
  67061. * Define the scale of the layer in order to zoom in out of the texture.
  67062. */
  67063. scale: Vector2;
  67064. /**
  67065. * Define an offset for the layer in order to shift the texture.
  67066. */
  67067. offset: Vector2;
  67068. /**
  67069. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  67070. */
  67071. alphaBlendingMode: number;
  67072. /**
  67073. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  67074. * Alpha test will not mix with the background color in case of transparency.
  67075. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  67076. */
  67077. alphaTest: boolean;
  67078. /**
  67079. * Define a mask to restrict the layer to only some of the scene cameras.
  67080. */
  67081. layerMask: number;
  67082. /**
  67083. * Define the list of render target the layer is visible into.
  67084. */
  67085. renderTargetTextures: RenderTargetTexture[];
  67086. /**
  67087. * Define if the layer is only used in renderTarget or if it also
  67088. * renders in the main frame buffer of the canvas.
  67089. */
  67090. renderOnlyInRenderTargetTextures: boolean;
  67091. private _scene;
  67092. private _vertexBuffers;
  67093. private _indexBuffer;
  67094. private _effect;
  67095. private _previousDefines;
  67096. /**
  67097. * An event triggered when the layer is disposed.
  67098. */
  67099. onDisposeObservable: Observable<Layer>;
  67100. private _onDisposeObserver;
  67101. /**
  67102. * Back compatibility with callback before the onDisposeObservable existed.
  67103. * The set callback will be triggered when the layer has been disposed.
  67104. */
  67105. set onDispose(callback: () => void);
  67106. /**
  67107. * An event triggered before rendering the scene
  67108. */
  67109. onBeforeRenderObservable: Observable<Layer>;
  67110. private _onBeforeRenderObserver;
  67111. /**
  67112. * Back compatibility with callback before the onBeforeRenderObservable existed.
  67113. * The set callback will be triggered just before rendering the layer.
  67114. */
  67115. set onBeforeRender(callback: () => void);
  67116. /**
  67117. * An event triggered after rendering the scene
  67118. */
  67119. onAfterRenderObservable: Observable<Layer>;
  67120. private _onAfterRenderObserver;
  67121. /**
  67122. * Back compatibility with callback before the onAfterRenderObservable existed.
  67123. * The set callback will be triggered just after rendering the layer.
  67124. */
  67125. set onAfterRender(callback: () => void);
  67126. /**
  67127. * Instantiates a new layer.
  67128. * This represents a full screen 2d layer.
  67129. * This can be useful to display a picture in the background of your scene for instance.
  67130. * @see https://www.babylonjs-playground.com/#08A2BS#1
  67131. * @param name Define the name of the layer in the scene
  67132. * @param imgUrl Define the url of the texture to display in the layer
  67133. * @param scene Define the scene the layer belongs to
  67134. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  67135. * @param color Defines a color for the layer
  67136. */
  67137. constructor(
  67138. /**
  67139. * Define the name of the layer.
  67140. */
  67141. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  67142. private _createIndexBuffer;
  67143. /** @hidden */
  67144. _rebuild(): void;
  67145. /**
  67146. * Renders the layer in the scene.
  67147. */
  67148. render(): void;
  67149. /**
  67150. * Disposes and releases the associated resources.
  67151. */
  67152. dispose(): void;
  67153. }
  67154. }
  67155. declare module "babylonjs/Layers/index" {
  67156. export * from "babylonjs/Layers/effectLayer";
  67157. export * from "babylonjs/Layers/effectLayerSceneComponent";
  67158. export * from "babylonjs/Layers/glowLayer";
  67159. export * from "babylonjs/Layers/highlightLayer";
  67160. export * from "babylonjs/Layers/layer";
  67161. export * from "babylonjs/Layers/layerSceneComponent";
  67162. }
  67163. declare module "babylonjs/Shaders/lensFlare.fragment" {
  67164. /** @hidden */
  67165. export var lensFlarePixelShader: {
  67166. name: string;
  67167. shader: string;
  67168. };
  67169. }
  67170. declare module "babylonjs/Shaders/lensFlare.vertex" {
  67171. /** @hidden */
  67172. export var lensFlareVertexShader: {
  67173. name: string;
  67174. shader: string;
  67175. };
  67176. }
  67177. declare module "babylonjs/LensFlares/lensFlareSystem" {
  67178. import { Scene } from "babylonjs/scene";
  67179. import { Vector3 } from "babylonjs/Maths/math.vector";
  67180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67181. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  67182. import "babylonjs/Shaders/lensFlare.fragment";
  67183. import "babylonjs/Shaders/lensFlare.vertex";
  67184. import { Viewport } from "babylonjs/Maths/math.viewport";
  67185. /**
  67186. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  67187. * It is usually composed of several `lensFlare`.
  67188. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  67189. */
  67190. export class LensFlareSystem {
  67191. /**
  67192. * Define the name of the lens flare system
  67193. */
  67194. name: string;
  67195. /**
  67196. * List of lens flares used in this system.
  67197. */
  67198. lensFlares: LensFlare[];
  67199. /**
  67200. * Define a limit from the border the lens flare can be visible.
  67201. */
  67202. borderLimit: number;
  67203. /**
  67204. * Define a viewport border we do not want to see the lens flare in.
  67205. */
  67206. viewportBorder: number;
  67207. /**
  67208. * Define a predicate which could limit the list of meshes able to occlude the effect.
  67209. */
  67210. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  67211. /**
  67212. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  67213. */
  67214. layerMask: number;
  67215. /**
  67216. * Define the id of the lens flare system in the scene.
  67217. * (equal to name by default)
  67218. */
  67219. id: string;
  67220. private _scene;
  67221. private _emitter;
  67222. private _vertexBuffers;
  67223. private _indexBuffer;
  67224. private _effect;
  67225. private _positionX;
  67226. private _positionY;
  67227. private _isEnabled;
  67228. /** @hidden */
  67229. static _SceneComponentInitialization: (scene: Scene) => void;
  67230. /**
  67231. * Instantiates a lens flare system.
  67232. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  67233. * It is usually composed of several `lensFlare`.
  67234. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  67235. * @param name Define the name of the lens flare system in the scene
  67236. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  67237. * @param scene Define the scene the lens flare system belongs to
  67238. */
  67239. constructor(
  67240. /**
  67241. * Define the name of the lens flare system
  67242. */
  67243. name: string, emitter: any, scene: Scene);
  67244. /**
  67245. * Define if the lens flare system is enabled.
  67246. */
  67247. get isEnabled(): boolean;
  67248. set isEnabled(value: boolean);
  67249. /**
  67250. * Get the scene the effects belongs to.
  67251. * @returns the scene holding the lens flare system
  67252. */
  67253. getScene(): Scene;
  67254. /**
  67255. * Get the emitter of the lens flare system.
  67256. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  67257. * @returns the emitter of the lens flare system
  67258. */
  67259. getEmitter(): any;
  67260. /**
  67261. * Set the emitter of the lens flare system.
  67262. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  67263. * @param newEmitter Define the new emitter of the system
  67264. */
  67265. setEmitter(newEmitter: any): void;
  67266. /**
  67267. * Get the lens flare system emitter position.
  67268. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  67269. * @returns the position
  67270. */
  67271. getEmitterPosition(): Vector3;
  67272. /**
  67273. * @hidden
  67274. */
  67275. computeEffectivePosition(globalViewport: Viewport): boolean;
  67276. /** @hidden */
  67277. _isVisible(): boolean;
  67278. /**
  67279. * @hidden
  67280. */
  67281. render(): boolean;
  67282. /**
  67283. * Dispose and release the lens flare with its associated resources.
  67284. */
  67285. dispose(): void;
  67286. /**
  67287. * Parse a lens flare system from a JSON representation
  67288. * @param parsedLensFlareSystem Define the JSON to parse
  67289. * @param scene Define the scene the parsed system should be instantiated in
  67290. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  67291. * @returns the parsed system
  67292. */
  67293. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  67294. /**
  67295. * Serialize the current Lens Flare System into a JSON representation.
  67296. * @returns the serialized JSON
  67297. */
  67298. serialize(): any;
  67299. }
  67300. }
  67301. declare module "babylonjs/LensFlares/lensFlare" {
  67302. import { Nullable } from "babylonjs/types";
  67303. import { Color3 } from "babylonjs/Maths/math.color";
  67304. import { Texture } from "babylonjs/Materials/Textures/texture";
  67305. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  67306. /**
  67307. * This represents one of the lens effect in a `lensFlareSystem`.
  67308. * It controls one of the individual texture used in the effect.
  67309. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  67310. */
  67311. export class LensFlare {
  67312. /**
  67313. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  67314. */
  67315. size: number;
  67316. /**
  67317. * 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.
  67318. */
  67319. position: number;
  67320. /**
  67321. * Define the lens color.
  67322. */
  67323. color: Color3;
  67324. /**
  67325. * Define the lens texture.
  67326. */
  67327. texture: Nullable<Texture>;
  67328. /**
  67329. * Define the alpha mode to render this particular lens.
  67330. */
  67331. alphaMode: number;
  67332. private _system;
  67333. /**
  67334. * Creates a new Lens Flare.
  67335. * This represents one of the lens effect in a `lensFlareSystem`.
  67336. * It controls one of the individual texture used in the effect.
  67337. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  67338. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  67339. * @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.
  67340. * @param color Define the lens color
  67341. * @param imgUrl Define the lens texture url
  67342. * @param system Define the `lensFlareSystem` this flare is part of
  67343. * @returns The newly created Lens Flare
  67344. */
  67345. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  67346. /**
  67347. * Instantiates a new Lens Flare.
  67348. * This represents one of the lens effect in a `lensFlareSystem`.
  67349. * It controls one of the individual texture used in the effect.
  67350. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  67351. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  67352. * @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.
  67353. * @param color Define the lens color
  67354. * @param imgUrl Define the lens texture url
  67355. * @param system Define the `lensFlareSystem` this flare is part of
  67356. */
  67357. constructor(
  67358. /**
  67359. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  67360. */
  67361. size: number,
  67362. /**
  67363. * 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.
  67364. */
  67365. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  67366. /**
  67367. * Dispose and release the lens flare with its associated resources.
  67368. */
  67369. dispose(): void;
  67370. }
  67371. }
  67372. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  67373. import { Nullable } from "babylonjs/types";
  67374. import { Scene } from "babylonjs/scene";
  67375. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  67376. import { AbstractScene } from "babylonjs/abstractScene";
  67377. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  67378. module "babylonjs/abstractScene" {
  67379. interface AbstractScene {
  67380. /**
  67381. * The list of lens flare system added to the scene
  67382. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  67383. */
  67384. lensFlareSystems: Array<LensFlareSystem>;
  67385. /**
  67386. * Removes the given lens flare system from this scene.
  67387. * @param toRemove The lens flare system to remove
  67388. * @returns The index of the removed lens flare system
  67389. */
  67390. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  67391. /**
  67392. * Adds the given lens flare system to this scene
  67393. * @param newLensFlareSystem The lens flare system to add
  67394. */
  67395. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  67396. /**
  67397. * Gets a lens flare system using its name
  67398. * @param name defines the name to look for
  67399. * @returns the lens flare system or null if not found
  67400. */
  67401. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  67402. /**
  67403. * Gets a lens flare system using its id
  67404. * @param id defines the id to look for
  67405. * @returns the lens flare system or null if not found
  67406. */
  67407. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  67408. }
  67409. }
  67410. /**
  67411. * Defines the lens flare scene component responsible to manage any lens flares
  67412. * in a given scene.
  67413. */
  67414. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  67415. /**
  67416. * The component name helpful to identify the component in the list of scene components.
  67417. */
  67418. readonly name: string;
  67419. /**
  67420. * The scene the component belongs to.
  67421. */
  67422. scene: Scene;
  67423. /**
  67424. * Creates a new instance of the component for the given scene
  67425. * @param scene Defines the scene to register the component in
  67426. */
  67427. constructor(scene: Scene);
  67428. /**
  67429. * Registers the component in a given scene
  67430. */
  67431. register(): void;
  67432. /**
  67433. * Rebuilds the elements related to this component in case of
  67434. * context lost for instance.
  67435. */
  67436. rebuild(): void;
  67437. /**
  67438. * Adds all the elements from the container to the scene
  67439. * @param container the container holding the elements
  67440. */
  67441. addFromContainer(container: AbstractScene): void;
  67442. /**
  67443. * Removes all the elements in the container from the scene
  67444. * @param container contains the elements to remove
  67445. * @param dispose if the removed element should be disposed (default: false)
  67446. */
  67447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  67448. /**
  67449. * Serializes the component data to the specified json object
  67450. * @param serializationObject The object to serialize to
  67451. */
  67452. serialize(serializationObject: any): void;
  67453. /**
  67454. * Disposes the component and the associated resources.
  67455. */
  67456. dispose(): void;
  67457. private _draw;
  67458. }
  67459. }
  67460. declare module "babylonjs/LensFlares/index" {
  67461. export * from "babylonjs/LensFlares/lensFlare";
  67462. export * from "babylonjs/LensFlares/lensFlareSystem";
  67463. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  67464. }
  67465. declare module "babylonjs/Shaders/depth.fragment" {
  67466. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67467. /** @hidden */
  67468. export var depthPixelShader: {
  67469. name: string;
  67470. shader: string;
  67471. };
  67472. }
  67473. declare module "babylonjs/Shaders/depth.vertex" {
  67474. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67475. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67476. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67477. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67478. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal";
  67479. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67480. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67481. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67482. /** @hidden */
  67483. export var depthVertexShader: {
  67484. name: string;
  67485. shader: string;
  67486. };
  67487. }
  67488. declare module "babylonjs/Rendering/depthRenderer" {
  67489. import { Nullable } from "babylonjs/types";
  67490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67491. import { Scene } from "babylonjs/scene";
  67492. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67493. import { Camera } from "babylonjs/Cameras/camera";
  67494. import "babylonjs/Shaders/depth.fragment";
  67495. import "babylonjs/Shaders/depth.vertex";
  67496. /**
  67497. * This represents a depth renderer in Babylon.
  67498. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  67499. */
  67500. export class DepthRenderer {
  67501. private _scene;
  67502. private _depthMap;
  67503. private _effect;
  67504. private readonly _storeNonLinearDepth;
  67505. private readonly _clearColor;
  67506. /** Get if the depth renderer is using packed depth or not */
  67507. readonly isPacked: boolean;
  67508. private _cachedDefines;
  67509. private _camera;
  67510. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  67511. enabled: boolean;
  67512. /**
  67513. * Specifies that the depth renderer will only be used within
  67514. * the camera it is created for.
  67515. * This can help forcing its rendering during the camera processing.
  67516. */
  67517. useOnlyInActiveCamera: boolean;
  67518. /** @hidden */
  67519. static _SceneComponentInitialization: (scene: Scene) => void;
  67520. /**
  67521. * Instantiates a depth renderer
  67522. * @param scene The scene the renderer belongs to
  67523. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  67524. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  67525. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67526. */
  67527. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  67528. /**
  67529. * Creates the depth rendering effect and checks if the effect is ready.
  67530. * @param subMesh The submesh to be used to render the depth map of
  67531. * @param useInstances If multiple world instances should be used
  67532. * @returns if the depth renderer is ready to render the depth map
  67533. */
  67534. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67535. /**
  67536. * Gets the texture which the depth map will be written to.
  67537. * @returns The depth map texture
  67538. */
  67539. getDepthMap(): RenderTargetTexture;
  67540. /**
  67541. * Disposes of the depth renderer.
  67542. */
  67543. dispose(): void;
  67544. }
  67545. }
  67546. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  67547. /** @hidden */
  67548. export var minmaxReduxPixelShader: {
  67549. name: string;
  67550. shader: string;
  67551. };
  67552. }
  67553. declare module "babylonjs/Misc/minMaxReducer" {
  67554. import { Nullable } from "babylonjs/types";
  67555. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67556. import { Camera } from "babylonjs/Cameras/camera";
  67557. import { Observer } from "babylonjs/Misc/observable";
  67558. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67559. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  67560. import { Observable } from "babylonjs/Misc/observable";
  67561. import "babylonjs/Shaders/minmaxRedux.fragment";
  67562. /**
  67563. * This class computes a min/max reduction from a texture: it means it computes the minimum
  67564. * and maximum values from all values of the texture.
  67565. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  67566. * The source values are read from the red channel of the texture.
  67567. */
  67568. export class MinMaxReducer {
  67569. /**
  67570. * Observable triggered when the computation has been performed
  67571. */
  67572. onAfterReductionPerformed: Observable<{
  67573. min: number;
  67574. max: number;
  67575. }>;
  67576. protected _camera: Camera;
  67577. protected _sourceTexture: Nullable<RenderTargetTexture>;
  67578. protected _reductionSteps: Nullable<Array<PostProcess>>;
  67579. protected _postProcessManager: PostProcessManager;
  67580. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  67581. protected _forceFullscreenViewport: boolean;
  67582. /**
  67583. * Creates a min/max reducer
  67584. * @param camera The camera to use for the post processes
  67585. */
  67586. constructor(camera: Camera);
  67587. /**
  67588. * Gets the texture used to read the values from.
  67589. */
  67590. get sourceTexture(): Nullable<RenderTargetTexture>;
  67591. /**
  67592. * Sets the source texture to read the values from.
  67593. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  67594. * because in such textures '1' value must not be taken into account to compute the maximum
  67595. * as this value is used to clear the texture.
  67596. * Note that the computation is not activated by calling this function, you must call activate() for that!
  67597. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  67598. * @param depthRedux Indicates if the texture is a depth texture or not
  67599. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  67600. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  67601. */
  67602. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  67603. /**
  67604. * Defines the refresh rate of the computation.
  67605. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  67606. */
  67607. get refreshRate(): number;
  67608. set refreshRate(value: number);
  67609. protected _activated: boolean;
  67610. /**
  67611. * Gets the activation status of the reducer
  67612. */
  67613. get activated(): boolean;
  67614. /**
  67615. * Activates the reduction computation.
  67616. * When activated, the observers registered in onAfterReductionPerformed are
  67617. * called after the computation is performed
  67618. */
  67619. activate(): void;
  67620. /**
  67621. * Deactivates the reduction computation.
  67622. */
  67623. deactivate(): void;
  67624. /**
  67625. * Disposes the min/max reducer
  67626. * @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.
  67627. */
  67628. dispose(disposeAll?: boolean): void;
  67629. }
  67630. }
  67631. declare module "babylonjs/Misc/depthReducer" {
  67632. import { Nullable } from "babylonjs/types";
  67633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67634. import { Camera } from "babylonjs/Cameras/camera";
  67635. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  67636. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  67637. /**
  67638. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  67639. */
  67640. export class DepthReducer extends MinMaxReducer {
  67641. private _depthRenderer;
  67642. private _depthRendererId;
  67643. /**
  67644. * Gets the depth renderer used for the computation.
  67645. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  67646. */
  67647. get depthRenderer(): Nullable<DepthRenderer>;
  67648. /**
  67649. * Creates a depth reducer
  67650. * @param camera The camera used to render the depth texture
  67651. */
  67652. constructor(camera: Camera);
  67653. /**
  67654. * Sets the depth renderer to use to generate the depth map
  67655. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  67656. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  67657. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  67658. */
  67659. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  67660. /** @hidden */
  67661. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  67662. /**
  67663. * Activates the reduction computation.
  67664. * When activated, the observers registered in onAfterReductionPerformed are
  67665. * called after the computation is performed
  67666. */
  67667. activate(): void;
  67668. /**
  67669. * Deactivates the reduction computation.
  67670. */
  67671. deactivate(): void;
  67672. /**
  67673. * Disposes the depth reducer
  67674. * @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.
  67675. */
  67676. dispose(disposeAll?: boolean): void;
  67677. }
  67678. }
  67679. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  67680. import { Nullable } from "babylonjs/types";
  67681. import { Scene } from "babylonjs/scene";
  67682. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67685. import { Effect } from "babylonjs/Materials/effect";
  67686. import "babylonjs/Shaders/shadowMap.fragment";
  67687. import "babylonjs/Shaders/shadowMap.vertex";
  67688. import "babylonjs/Shaders/depthBoxBlur.fragment";
  67689. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  67690. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67691. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67692. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  67693. /**
  67694. * A CSM implementation allowing casting shadows on large scenes.
  67695. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  67696. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  67697. */
  67698. export class CascadedShadowGenerator extends ShadowGenerator {
  67699. private static readonly frustumCornersNDCSpace;
  67700. /**
  67701. * Name of the CSM class
  67702. */
  67703. static CLASSNAME: string;
  67704. /**
  67705. * Defines the default number of cascades used by the CSM.
  67706. */
  67707. static readonly DEFAULT_CASCADES_COUNT: number;
  67708. /**
  67709. * Defines the minimum number of cascades used by the CSM.
  67710. */
  67711. static readonly MIN_CASCADES_COUNT: number;
  67712. /**
  67713. * Defines the maximum number of cascades used by the CSM.
  67714. */
  67715. static readonly MAX_CASCADES_COUNT: number;
  67716. protected _validateFilter(filter: number): number;
  67717. /**
  67718. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  67719. */
  67720. penumbraDarkness: number;
  67721. private _numCascades;
  67722. /**
  67723. * Gets or set the number of cascades used by the CSM.
  67724. */
  67725. get numCascades(): number;
  67726. set numCascades(value: number);
  67727. /**
  67728. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  67729. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  67730. */
  67731. stabilizeCascades: boolean;
  67732. private _freezeShadowCastersBoundingInfo;
  67733. private _freezeShadowCastersBoundingInfoObservable;
  67734. /**
  67735. * Enables or disables the shadow casters bounding info computation.
  67736. * If your shadow casters don't move, you can disable this feature.
  67737. * If it is enabled, the bounding box computation is done every frame.
  67738. */
  67739. get freezeShadowCastersBoundingInfo(): boolean;
  67740. set freezeShadowCastersBoundingInfo(freeze: boolean);
  67741. private _scbiMin;
  67742. private _scbiMax;
  67743. protected _computeShadowCastersBoundingInfo(): void;
  67744. protected _shadowCastersBoundingInfo: BoundingInfo;
  67745. /**
  67746. * Gets or sets the shadow casters bounding info.
  67747. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  67748. * so that the system won't overwrite the bounds you provide
  67749. */
  67750. get shadowCastersBoundingInfo(): BoundingInfo;
  67751. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  67752. protected _breaksAreDirty: boolean;
  67753. protected _minDistance: number;
  67754. protected _maxDistance: number;
  67755. /**
  67756. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  67757. *
  67758. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  67759. * If you don't know these values, simply leave them to their defaults and don't call this function.
  67760. * @param min minimal distance for the breaks (default to 0.)
  67761. * @param max maximal distance for the breaks (default to 1.)
  67762. */
  67763. setMinMaxDistance(min: number, max: number): void;
  67764. /** Gets the minimal distance used in the cascade break computation */
  67765. get minDistance(): number;
  67766. /** Gets the maximal distance used in the cascade break computation */
  67767. get maxDistance(): number;
  67768. /**
  67769. * Gets the class name of that object
  67770. * @returns "CascadedShadowGenerator"
  67771. */
  67772. getClassName(): string;
  67773. private _cascadeMinExtents;
  67774. private _cascadeMaxExtents;
  67775. /**
  67776. * Gets a cascade minimum extents
  67777. * @param cascadeIndex index of the cascade
  67778. * @returns the minimum cascade extents
  67779. */
  67780. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  67781. /**
  67782. * Gets a cascade maximum extents
  67783. * @param cascadeIndex index of the cascade
  67784. * @returns the maximum cascade extents
  67785. */
  67786. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  67787. private _cascades;
  67788. private _currentLayer;
  67789. private _viewSpaceFrustumsZ;
  67790. private _viewMatrices;
  67791. private _projectionMatrices;
  67792. private _transformMatrices;
  67793. private _transformMatricesAsArray;
  67794. private _frustumLengths;
  67795. private _lightSizeUVCorrection;
  67796. private _depthCorrection;
  67797. private _frustumCornersWorldSpace;
  67798. private _frustumCenter;
  67799. private _shadowCameraPos;
  67800. private _shadowMaxZ;
  67801. /**
  67802. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  67803. * It defaults to camera.maxZ
  67804. */
  67805. get shadowMaxZ(): number;
  67806. /**
  67807. * Sets the shadow max z distance.
  67808. */
  67809. set shadowMaxZ(value: number);
  67810. protected _debug: boolean;
  67811. /**
  67812. * Gets or sets the debug flag.
  67813. * When enabled, the cascades are materialized by different colors on the screen.
  67814. */
  67815. get debug(): boolean;
  67816. set debug(dbg: boolean);
  67817. private _depthClamp;
  67818. /**
  67819. * Gets or sets the depth clamping value.
  67820. *
  67821. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  67822. * to account for the shadow casters far away.
  67823. *
  67824. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  67825. */
  67826. get depthClamp(): boolean;
  67827. set depthClamp(value: boolean);
  67828. private _cascadeBlendPercentage;
  67829. /**
  67830. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  67831. * It defaults to 0.1 (10% blending).
  67832. */
  67833. get cascadeBlendPercentage(): number;
  67834. set cascadeBlendPercentage(value: number);
  67835. private _lambda;
  67836. /**
  67837. * Gets or set the lambda parameter.
  67838. * This parameter is used to split the camera frustum and create the cascades.
  67839. * 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.
  67840. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  67841. */
  67842. get lambda(): number;
  67843. set lambda(value: number);
  67844. /**
  67845. * Gets the view matrix corresponding to a given cascade
  67846. * @param cascadeNum cascade to retrieve the view matrix from
  67847. * @returns the cascade view matrix
  67848. */
  67849. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  67850. /**
  67851. * Gets the projection matrix corresponding to a given cascade
  67852. * @param cascadeNum cascade to retrieve the projection matrix from
  67853. * @returns the cascade projection matrix
  67854. */
  67855. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  67856. /**
  67857. * Gets the transformation matrix corresponding to a given cascade
  67858. * @param cascadeNum cascade to retrieve the transformation matrix from
  67859. * @returns the cascade transformation matrix
  67860. */
  67861. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  67862. private _depthRenderer;
  67863. /**
  67864. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  67865. *
  67866. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  67867. *
  67868. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  67869. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  67870. * @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
  67871. */
  67872. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  67873. private _depthReducer;
  67874. private _autoCalcDepthBounds;
  67875. /**
  67876. * Gets or sets the autoCalcDepthBounds property.
  67877. *
  67878. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  67879. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  67880. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  67881. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  67882. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  67883. */
  67884. get autoCalcDepthBounds(): boolean;
  67885. set autoCalcDepthBounds(value: boolean);
  67886. /**
  67887. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  67888. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  67889. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  67890. * for setting the refresh rate on the renderer yourself!
  67891. */
  67892. get autoCalcDepthBoundsRefreshRate(): number;
  67893. set autoCalcDepthBoundsRefreshRate(value: number);
  67894. /**
  67895. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  67896. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  67897. * you change the camera near/far planes!
  67898. */
  67899. splitFrustum(): void;
  67900. private _splitFrustum;
  67901. private _computeMatrices;
  67902. private _computeFrustumInWorldSpace;
  67903. private _computeCascadeFrustum;
  67904. /**
  67905. * Support test.
  67906. */
  67907. static get IsSupported(): boolean;
  67908. /** @hidden */
  67909. static _SceneComponentInitialization: (scene: Scene) => void;
  67910. /**
  67911. * Creates a Cascaded Shadow Generator object.
  67912. * A ShadowGenerator is the required tool to use the shadows.
  67913. * Each directional light casting shadows needs to use its own ShadowGenerator.
  67914. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  67915. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67916. * @param light The directional light object generating the shadows.
  67917. * @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.
  67918. */
  67919. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  67920. protected _initializeGenerator(): void;
  67921. protected _createTargetRenderTexture(): void;
  67922. protected _initializeShadowMap(): void;
  67923. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  67924. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  67925. /**
  67926. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67927. * @param defines Defines of the material we want to update
  67928. * @param lightIndex Index of the light in the enabled light list of the material
  67929. */
  67930. prepareDefines(defines: any, lightIndex: number): void;
  67931. /**
  67932. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67933. * defined in the generator but impacting the effect).
  67934. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67935. * @param effect The effect we are binfing the information for
  67936. */
  67937. bindShadowLight(lightIndex: string, effect: Effect): void;
  67938. /**
  67939. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  67940. * (eq to view projection * shadow projection matrices)
  67941. * @returns The transform matrix used to create the shadow map
  67942. */
  67943. getTransformMatrix(): Matrix;
  67944. /**
  67945. * Disposes the ShadowGenerator.
  67946. * Returns nothing.
  67947. */
  67948. dispose(): void;
  67949. /**
  67950. * Serializes the shadow generator setup to a json object.
  67951. * @returns The serialized JSON object
  67952. */
  67953. serialize(): any;
  67954. /**
  67955. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67956. * @param parsedShadowGenerator The JSON object to parse
  67957. * @param scene The scene to create the shadow map for
  67958. * @returns The parsed shadow generator
  67959. */
  67960. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67961. }
  67962. }
  67963. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  67964. import { Scene } from "babylonjs/scene";
  67965. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  67966. import { AbstractScene } from "babylonjs/abstractScene";
  67967. /**
  67968. * Defines the shadow generator component responsible to manage any shadow generators
  67969. * in a given scene.
  67970. */
  67971. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  67972. /**
  67973. * The component name helpful to identify the component in the list of scene components.
  67974. */
  67975. readonly name: string;
  67976. /**
  67977. * The scene the component belongs to.
  67978. */
  67979. scene: Scene;
  67980. /**
  67981. * Creates a new instance of the component for the given scene
  67982. * @param scene Defines the scene to register the component in
  67983. */
  67984. constructor(scene: Scene);
  67985. /**
  67986. * Registers the component in a given scene
  67987. */
  67988. register(): void;
  67989. /**
  67990. * Rebuilds the elements related to this component in case of
  67991. * context lost for instance.
  67992. */
  67993. rebuild(): void;
  67994. /**
  67995. * Serializes the component data to the specified json object
  67996. * @param serializationObject The object to serialize to
  67997. */
  67998. serialize(serializationObject: any): void;
  67999. /**
  68000. * Adds all the elements from the container to the scene
  68001. * @param container the container holding the elements
  68002. */
  68003. addFromContainer(container: AbstractScene): void;
  68004. /**
  68005. * Removes all the elements in the container from the scene
  68006. * @param container contains the elements to remove
  68007. * @param dispose if the removed element should be disposed (default: false)
  68008. */
  68009. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  68010. /**
  68011. * Rebuilds the elements related to this component in case of
  68012. * context lost for instance.
  68013. */
  68014. dispose(): void;
  68015. private _gatherRenderTargets;
  68016. }
  68017. }
  68018. declare module "babylonjs/Lights/Shadows/index" {
  68019. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  68020. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  68021. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  68022. }
  68023. declare module "babylonjs/Lights/pointLight" {
  68024. import { Scene } from "babylonjs/scene";
  68025. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68027. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  68028. import { Effect } from "babylonjs/Materials/effect";
  68029. /**
  68030. * A point light is a light defined by an unique point in world space.
  68031. * The light is emitted in every direction from this point.
  68032. * A good example of a point light is a standard light bulb.
  68033. * Documentation: https://doc.babylonjs.com/babylon101/lights
  68034. */
  68035. export class PointLight extends ShadowLight {
  68036. private _shadowAngle;
  68037. /**
  68038. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  68039. * This specifies what angle the shadow will use to be created.
  68040. *
  68041. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  68042. */
  68043. get shadowAngle(): number;
  68044. /**
  68045. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  68046. * This specifies what angle the shadow will use to be created.
  68047. *
  68048. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  68049. */
  68050. set shadowAngle(value: number);
  68051. /**
  68052. * Gets the direction if it has been set.
  68053. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  68054. */
  68055. get direction(): Vector3;
  68056. /**
  68057. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  68058. */
  68059. set direction(value: Vector3);
  68060. /**
  68061. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  68062. * A PointLight emits the light in every direction.
  68063. * It can cast shadows.
  68064. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  68065. * ```javascript
  68066. * var pointLight = new PointLight("pl", camera.position, scene);
  68067. * ```
  68068. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68069. * @param name The light friendly name
  68070. * @param position The position of the point light in the scene
  68071. * @param scene The scene the lights belongs to
  68072. */
  68073. constructor(name: string, position: Vector3, scene: Scene);
  68074. /**
  68075. * Returns the string "PointLight"
  68076. * @returns the class name
  68077. */
  68078. getClassName(): string;
  68079. /**
  68080. * Returns the integer 0.
  68081. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68082. */
  68083. getTypeID(): number;
  68084. /**
  68085. * Specifies whether or not the shadowmap should be a cube texture.
  68086. * @returns true if the shadowmap needs to be a cube texture.
  68087. */
  68088. needCube(): boolean;
  68089. /**
  68090. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  68091. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68092. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68093. */
  68094. getShadowDirection(faceIndex?: number): Vector3;
  68095. /**
  68096. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  68097. * - fov = PI / 2
  68098. * - aspect ratio : 1.0
  68099. * - z-near and far equal to the active camera minZ and maxZ.
  68100. * Returns the PointLight.
  68101. */
  68102. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68103. protected _buildUniformLayout(): void;
  68104. /**
  68105. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  68106. * @param effect The effect to update
  68107. * @param lightIndex The index of the light in the effect to update
  68108. * @returns The point light
  68109. */
  68110. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  68111. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  68112. /**
  68113. * Prepares the list of defines specific to the light type.
  68114. * @param defines the list of defines
  68115. * @param lightIndex defines the index of the light for the effect
  68116. */
  68117. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68118. }
  68119. }
  68120. declare module "babylonjs/Lights/index" {
  68121. export * from "babylonjs/Lights/light";
  68122. export * from "babylonjs/Lights/shadowLight";
  68123. export * from "babylonjs/Lights/Shadows/index";
  68124. export * from "babylonjs/Lights/directionalLight";
  68125. export * from "babylonjs/Lights/hemisphericLight";
  68126. export * from "babylonjs/Lights/pointLight";
  68127. export * from "babylonjs/Lights/spotLight";
  68128. }
  68129. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  68130. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  68131. /**
  68132. * Header information of HDR texture files.
  68133. */
  68134. export interface HDRInfo {
  68135. /**
  68136. * The height of the texture in pixels.
  68137. */
  68138. height: number;
  68139. /**
  68140. * The width of the texture in pixels.
  68141. */
  68142. width: number;
  68143. /**
  68144. * The index of the beginning of the data in the binary file.
  68145. */
  68146. dataPosition: number;
  68147. }
  68148. /**
  68149. * This groups tools to convert HDR texture to native colors array.
  68150. */
  68151. export class HDRTools {
  68152. private static Ldexp;
  68153. private static Rgbe2float;
  68154. private static readStringLine;
  68155. /**
  68156. * Reads header information from an RGBE texture stored in a native array.
  68157. * More information on this format are available here:
  68158. * https://en.wikipedia.org/wiki/RGBE_image_format
  68159. *
  68160. * @param uint8array The binary file stored in native array.
  68161. * @return The header information.
  68162. */
  68163. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  68164. /**
  68165. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  68166. * This RGBE texture needs to store the information as a panorama.
  68167. *
  68168. * More information on this format are available here:
  68169. * https://en.wikipedia.org/wiki/RGBE_image_format
  68170. *
  68171. * @param buffer The binary file stored in an array buffer.
  68172. * @param size The expected size of the extracted cubemap.
  68173. * @return The Cube Map information.
  68174. */
  68175. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  68176. /**
  68177. * Returns the pixels data extracted from an RGBE texture.
  68178. * This pixels will be stored left to right up to down in the R G B order in one array.
  68179. *
  68180. * More information on this format are available here:
  68181. * https://en.wikipedia.org/wiki/RGBE_image_format
  68182. *
  68183. * @param uint8array The binary file stored in an array buffer.
  68184. * @param hdrInfo The header information of the file.
  68185. * @return The pixels data in RGB right to left up to down order.
  68186. */
  68187. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  68188. private static RGBE_ReadPixels_RLE;
  68189. private static RGBE_ReadPixels_NOT_RLE;
  68190. }
  68191. }
  68192. declare module "babylonjs/Materials/effectRenderer" {
  68193. import { Nullable } from "babylonjs/types";
  68194. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  68195. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68196. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  68197. import { Viewport } from "babylonjs/Maths/math.viewport";
  68198. import { Observable } from "babylonjs/Misc/observable";
  68199. import { Effect } from "babylonjs/Materials/effect";
  68200. import "babylonjs/Shaders/postprocess.vertex";
  68201. /**
  68202. * Effect Render Options
  68203. */
  68204. export interface IEffectRendererOptions {
  68205. /**
  68206. * Defines the vertices positions.
  68207. */
  68208. positions?: number[];
  68209. /**
  68210. * Defines the indices.
  68211. */
  68212. indices?: number[];
  68213. }
  68214. /**
  68215. * Helper class to render one or more effects.
  68216. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  68217. */
  68218. export class EffectRenderer {
  68219. private engine;
  68220. private static _DefaultOptions;
  68221. private _vertexBuffers;
  68222. private _indexBuffer;
  68223. private _fullscreenViewport;
  68224. /**
  68225. * Creates an effect renderer
  68226. * @param engine the engine to use for rendering
  68227. * @param options defines the options of the effect renderer
  68228. */
  68229. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  68230. /**
  68231. * Sets the current viewport in normalized coordinates 0-1
  68232. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  68233. */
  68234. setViewport(viewport?: Viewport): void;
  68235. /**
  68236. * Binds the embedded attributes buffer to the effect.
  68237. * @param effect Defines the effect to bind the attributes for
  68238. */
  68239. bindBuffers(effect: Effect): void;
  68240. /**
  68241. * Sets the current effect wrapper to use during draw.
  68242. * The effect needs to be ready before calling this api.
  68243. * This also sets the default full screen position attribute.
  68244. * @param effectWrapper Defines the effect to draw with
  68245. */
  68246. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  68247. /**
  68248. * Restores engine states
  68249. */
  68250. restoreStates(): void;
  68251. /**
  68252. * Draws a full screen quad.
  68253. */
  68254. draw(): void;
  68255. private isRenderTargetTexture;
  68256. /**
  68257. * renders one or more effects to a specified texture
  68258. * @param effectWrapper the effect to renderer
  68259. * @param outputTexture texture to draw to, if null it will render to the screen.
  68260. */
  68261. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  68262. /**
  68263. * Disposes of the effect renderer
  68264. */
  68265. dispose(): void;
  68266. }
  68267. /**
  68268. * Options to create an EffectWrapper
  68269. */
  68270. interface EffectWrapperCreationOptions {
  68271. /**
  68272. * Engine to use to create the effect
  68273. */
  68274. engine: ThinEngine;
  68275. /**
  68276. * Fragment shader for the effect
  68277. */
  68278. fragmentShader: string;
  68279. /**
  68280. * Use the shader store instead of direct source code
  68281. */
  68282. useShaderStore?: boolean;
  68283. /**
  68284. * Vertex shader for the effect
  68285. */
  68286. vertexShader?: string;
  68287. /**
  68288. * Attributes to use in the shader
  68289. */
  68290. attributeNames?: Array<string>;
  68291. /**
  68292. * Uniforms to use in the shader
  68293. */
  68294. uniformNames?: Array<string>;
  68295. /**
  68296. * Texture sampler names to use in the shader
  68297. */
  68298. samplerNames?: Array<string>;
  68299. /**
  68300. * Defines to use in the shader
  68301. */
  68302. defines?: Array<string>;
  68303. /**
  68304. * Callback when effect is compiled
  68305. */
  68306. onCompiled?: Nullable<(effect: Effect) => void>;
  68307. /**
  68308. * The friendly name of the effect displayed in Spector.
  68309. */
  68310. name?: string;
  68311. }
  68312. /**
  68313. * Wraps an effect to be used for rendering
  68314. */
  68315. export class EffectWrapper {
  68316. /**
  68317. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  68318. */
  68319. onApplyObservable: Observable<{}>;
  68320. /**
  68321. * The underlying effect
  68322. */
  68323. effect: Effect;
  68324. /**
  68325. * Creates an effect to be renderer
  68326. * @param creationOptions options to create the effect
  68327. */
  68328. constructor(creationOptions: EffectWrapperCreationOptions);
  68329. /**
  68330. * Disposes of the effect wrapper
  68331. */
  68332. dispose(): void;
  68333. }
  68334. }
  68335. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  68336. /** @hidden */
  68337. export var hdrFilteringVertexShader: {
  68338. name: string;
  68339. shader: string;
  68340. };
  68341. }
  68342. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  68343. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68344. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  68345. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  68346. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  68347. /** @hidden */
  68348. export var hdrFilteringPixelShader: {
  68349. name: string;
  68350. shader: string;
  68351. };
  68352. }
  68353. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  68354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68355. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  68356. import { Nullable } from "babylonjs/types";
  68357. import "babylonjs/Shaders/hdrFiltering.vertex";
  68358. import "babylonjs/Shaders/hdrFiltering.fragment";
  68359. /**
  68360. * Options for texture filtering
  68361. */
  68362. interface IHDRFilteringOptions {
  68363. /**
  68364. * Scales pixel intensity for the input HDR map.
  68365. */
  68366. hdrScale?: number;
  68367. /**
  68368. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  68369. */
  68370. quality?: number;
  68371. }
  68372. /**
  68373. * Filters HDR maps to get correct renderings of PBR reflections
  68374. */
  68375. export class HDRFiltering {
  68376. private _engine;
  68377. private _effectRenderer;
  68378. private _effectWrapper;
  68379. private _lodGenerationOffset;
  68380. private _lodGenerationScale;
  68381. /**
  68382. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  68383. * you care about baking speed.
  68384. */
  68385. quality: number;
  68386. /**
  68387. * Scales pixel intensity for the input HDR map.
  68388. */
  68389. hdrScale: number;
  68390. /**
  68391. * Instantiates HDR filter for reflection maps
  68392. *
  68393. * @param engine Thin engine
  68394. * @param options Options
  68395. */
  68396. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  68397. private _createRenderTarget;
  68398. private _prefilterInternal;
  68399. private _createEffect;
  68400. /**
  68401. * Get a value indicating if the filter is ready to be used
  68402. * @param texture Texture to filter
  68403. * @returns true if the filter is ready
  68404. */
  68405. isReady(texture: BaseTexture): boolean;
  68406. /**
  68407. * Prefilters a cube texture to have mipmap levels representing roughness values.
  68408. * Prefiltering will be invoked at the end of next rendering pass.
  68409. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  68410. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  68411. * @param texture Texture to filter
  68412. * @param onFinished Callback when filtering is done
  68413. * @return Promise called when prefiltering is done
  68414. */
  68415. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  68416. }
  68417. }
  68418. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  68419. import { Nullable } from "babylonjs/types";
  68420. import { Scene } from "babylonjs/scene";
  68421. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68423. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  68424. import "babylonjs/Engines/Extensions/engine.rawTexture";
  68425. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  68426. /**
  68427. * This represents a texture coming from an HDR input.
  68428. *
  68429. * The only supported format is currently panorama picture stored in RGBE format.
  68430. * Example of such files can be found on HDRLib: http://hdrlib.com/
  68431. */
  68432. export class HDRCubeTexture extends BaseTexture {
  68433. private static _facesMapping;
  68434. private _generateHarmonics;
  68435. private _noMipmap;
  68436. private _prefilterOnLoad;
  68437. private _textureMatrix;
  68438. private _size;
  68439. private _onLoad;
  68440. private _onError;
  68441. /**
  68442. * The texture URL.
  68443. */
  68444. url: string;
  68445. protected _isBlocking: boolean;
  68446. /**
  68447. * Sets whether or not the texture is blocking during loading.
  68448. */
  68449. set isBlocking(value: boolean);
  68450. /**
  68451. * Gets whether or not the texture is blocking during loading.
  68452. */
  68453. get isBlocking(): boolean;
  68454. protected _rotationY: number;
  68455. /**
  68456. * Sets texture matrix rotation angle around Y axis in radians.
  68457. */
  68458. set rotationY(value: number);
  68459. /**
  68460. * Gets texture matrix rotation angle around Y axis radians.
  68461. */
  68462. get rotationY(): number;
  68463. /**
  68464. * Gets or sets the center of the bounding box associated with the cube texture
  68465. * It must define where the camera used to render the texture was set
  68466. */
  68467. boundingBoxPosition: Vector3;
  68468. private _boundingBoxSize;
  68469. /**
  68470. * Gets or sets the size of the bounding box associated with the cube texture
  68471. * When defined, the cubemap will switch to local mode
  68472. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68473. * @example https://www.babylonjs-playground.com/#RNASML
  68474. */
  68475. set boundingBoxSize(value: Vector3);
  68476. get boundingBoxSize(): Vector3;
  68477. /**
  68478. * Instantiates an HDRTexture from the following parameters.
  68479. *
  68480. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  68481. * @param sceneOrEngine The scene or engine the texture will be used in
  68482. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  68483. * @param noMipmap Forces to not generate the mipmap if true
  68484. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  68485. * @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)
  68486. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  68487. */
  68488. 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>);
  68489. /**
  68490. * Get the current class name of the texture useful for serialization or dynamic coding.
  68491. * @returns "HDRCubeTexture"
  68492. */
  68493. getClassName(): string;
  68494. /**
  68495. * Occurs when the file is raw .hdr file.
  68496. */
  68497. private loadTexture;
  68498. clone(): HDRCubeTexture;
  68499. delayLoad(): void;
  68500. /**
  68501. * Get the texture reflection matrix used to rotate/transform the reflection.
  68502. * @returns the reflection matrix
  68503. */
  68504. getReflectionTextureMatrix(): Matrix;
  68505. /**
  68506. * Set the texture reflection matrix used to rotate/transform the reflection.
  68507. * @param value Define the reflection matrix to set
  68508. */
  68509. setReflectionTextureMatrix(value: Matrix): void;
  68510. /**
  68511. * Parses a JSON representation of an HDR Texture in order to create the texture
  68512. * @param parsedTexture Define the JSON representation
  68513. * @param scene Define the scene the texture should be created in
  68514. * @param rootUrl Define the root url in case we need to load relative dependencies
  68515. * @returns the newly created texture after parsing
  68516. */
  68517. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  68518. serialize(): any;
  68519. }
  68520. }
  68521. declare module "babylonjs/Physics/physicsEngine" {
  68522. import { Nullable } from "babylonjs/types";
  68523. import { Vector3 } from "babylonjs/Maths/math.vector";
  68524. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  68525. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  68526. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  68527. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68528. /**
  68529. * Class used to control physics engine
  68530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68531. */
  68532. export class PhysicsEngine implements IPhysicsEngine {
  68533. private _physicsPlugin;
  68534. /**
  68535. * Global value used to control the smallest number supported by the simulation
  68536. */
  68537. static Epsilon: number;
  68538. private _impostors;
  68539. private _joints;
  68540. private _subTimeStep;
  68541. /**
  68542. * Gets the gravity vector used by the simulation
  68543. */
  68544. gravity: Vector3;
  68545. /**
  68546. * Factory used to create the default physics plugin.
  68547. * @returns The default physics plugin
  68548. */
  68549. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  68550. /**
  68551. * Creates a new Physics Engine
  68552. * @param gravity defines the gravity vector used by the simulation
  68553. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  68554. */
  68555. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  68556. /**
  68557. * Sets the gravity vector used by the simulation
  68558. * @param gravity defines the gravity vector to use
  68559. */
  68560. setGravity(gravity: Vector3): void;
  68561. /**
  68562. * Set the time step of the physics engine.
  68563. * Default is 1/60.
  68564. * To slow it down, enter 1/600 for example.
  68565. * To speed it up, 1/30
  68566. * @param newTimeStep defines the new timestep to apply to this world.
  68567. */
  68568. setTimeStep(newTimeStep?: number): void;
  68569. /**
  68570. * Get the time step of the physics engine.
  68571. * @returns the current time step
  68572. */
  68573. getTimeStep(): number;
  68574. /**
  68575. * Set the sub time step of the physics engine.
  68576. * Default is 0 meaning there is no sub steps
  68577. * To increase physics resolution precision, set a small value (like 1 ms)
  68578. * @param subTimeStep defines the new sub timestep used for physics resolution.
  68579. */
  68580. setSubTimeStep(subTimeStep?: number): void;
  68581. /**
  68582. * Get the sub time step of the physics engine.
  68583. * @returns the current sub time step
  68584. */
  68585. getSubTimeStep(): number;
  68586. /**
  68587. * Release all resources
  68588. */
  68589. dispose(): void;
  68590. /**
  68591. * Gets the name of the current physics plugin
  68592. * @returns the name of the plugin
  68593. */
  68594. getPhysicsPluginName(): string;
  68595. /**
  68596. * Adding a new impostor for the impostor tracking.
  68597. * This will be done by the impostor itself.
  68598. * @param impostor the impostor to add
  68599. */
  68600. addImpostor(impostor: PhysicsImpostor): void;
  68601. /**
  68602. * Remove an impostor from the engine.
  68603. * This impostor and its mesh will not longer be updated by the physics engine.
  68604. * @param impostor the impostor to remove
  68605. */
  68606. removeImpostor(impostor: PhysicsImpostor): void;
  68607. /**
  68608. * Add a joint to the physics engine
  68609. * @param mainImpostor defines the main impostor to which the joint is added.
  68610. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  68611. * @param joint defines the joint that will connect both impostors.
  68612. */
  68613. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  68614. /**
  68615. * Removes a joint from the simulation
  68616. * @param mainImpostor defines the impostor used with the joint
  68617. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  68618. * @param joint defines the joint to remove
  68619. */
  68620. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  68621. /**
  68622. * Called by the scene. No need to call it.
  68623. * @param delta defines the timespan between frames
  68624. */
  68625. _step(delta: number): void;
  68626. /**
  68627. * Gets the current plugin used to run the simulation
  68628. * @returns current plugin
  68629. */
  68630. getPhysicsPlugin(): IPhysicsEnginePlugin;
  68631. /**
  68632. * Gets the list of physic impostors
  68633. * @returns an array of PhysicsImpostor
  68634. */
  68635. getImpostors(): Array<PhysicsImpostor>;
  68636. /**
  68637. * Gets the impostor for a physics enabled object
  68638. * @param object defines the object impersonated by the impostor
  68639. * @returns the PhysicsImpostor or null if not found
  68640. */
  68641. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  68642. /**
  68643. * Gets the impostor for a physics body object
  68644. * @param body defines physics body used by the impostor
  68645. * @returns the PhysicsImpostor or null if not found
  68646. */
  68647. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  68648. /**
  68649. * Does a raycast in the physics world
  68650. * @param from when should the ray start?
  68651. * @param to when should the ray end?
  68652. * @returns PhysicsRaycastResult
  68653. */
  68654. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68655. }
  68656. }
  68657. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  68658. import { Nullable } from "babylonjs/types";
  68659. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  68660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68661. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68662. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68663. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68664. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68665. /** @hidden */
  68666. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  68667. private _useDeltaForWorldStep;
  68668. world: any;
  68669. name: string;
  68670. private _physicsMaterials;
  68671. private _fixedTimeStep;
  68672. private _cannonRaycastResult;
  68673. private _raycastResult;
  68674. private _physicsBodysToRemoveAfterStep;
  68675. private _firstFrame;
  68676. BJSCANNON: any;
  68677. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  68678. setGravity(gravity: Vector3): void;
  68679. setTimeStep(timeStep: number): void;
  68680. getTimeStep(): number;
  68681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68682. private _removeMarkedPhysicsBodiesFromWorld;
  68683. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68684. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68685. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68686. private _processChildMeshes;
  68687. removePhysicsBody(impostor: PhysicsImpostor): void;
  68688. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68689. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68690. private _addMaterial;
  68691. private _checkWithEpsilon;
  68692. private _createShape;
  68693. private _createHeightmap;
  68694. private _minus90X;
  68695. private _plus90X;
  68696. private _tmpPosition;
  68697. private _tmpDeltaPosition;
  68698. private _tmpUnityRotation;
  68699. private _updatePhysicsBodyTransformation;
  68700. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68701. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68702. isSupported(): boolean;
  68703. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68704. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68705. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68706. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68707. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68708. getBodyMass(impostor: PhysicsImpostor): number;
  68709. getBodyFriction(impostor: PhysicsImpostor): number;
  68710. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68711. getBodyRestitution(impostor: PhysicsImpostor): number;
  68712. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68713. sleepBody(impostor: PhysicsImpostor): void;
  68714. wakeUpBody(impostor: PhysicsImpostor): void;
  68715. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  68716. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  68717. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  68718. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68719. getRadius(impostor: PhysicsImpostor): number;
  68720. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68721. dispose(): void;
  68722. private _extendNamespace;
  68723. /**
  68724. * Does a raycast in the physics world
  68725. * @param from when should the ray start?
  68726. * @param to when should the ray end?
  68727. * @returns PhysicsRaycastResult
  68728. */
  68729. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68730. }
  68731. }
  68732. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  68733. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68734. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68735. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68737. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  68738. import { Nullable } from "babylonjs/types";
  68739. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68740. /** @hidden */
  68741. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  68742. private _useDeltaForWorldStep;
  68743. world: any;
  68744. name: string;
  68745. BJSOIMO: any;
  68746. private _raycastResult;
  68747. private _fixedTimeStep;
  68748. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  68749. setGravity(gravity: Vector3): void;
  68750. setTimeStep(timeStep: number): void;
  68751. getTimeStep(): number;
  68752. private _tmpImpostorsArray;
  68753. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68754. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68755. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68756. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68757. private _tmpPositionVector;
  68758. removePhysicsBody(impostor: PhysicsImpostor): void;
  68759. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68760. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68761. isSupported(): boolean;
  68762. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68763. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68764. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68765. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68766. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68767. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68768. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68769. getBodyMass(impostor: PhysicsImpostor): number;
  68770. getBodyFriction(impostor: PhysicsImpostor): number;
  68771. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68772. getBodyRestitution(impostor: PhysicsImpostor): number;
  68773. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68774. sleepBody(impostor: PhysicsImpostor): void;
  68775. wakeUpBody(impostor: PhysicsImpostor): void;
  68776. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  68777. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  68778. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  68779. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68780. getRadius(impostor: PhysicsImpostor): number;
  68781. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68782. dispose(): void;
  68783. /**
  68784. * Does a raycast in the physics world
  68785. * @param from when should the ray start?
  68786. * @param to when should the ray end?
  68787. * @returns PhysicsRaycastResult
  68788. */
  68789. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68790. }
  68791. }
  68792. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  68793. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  68794. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  68795. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68796. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  68797. import { Nullable } from "babylonjs/types";
  68798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68799. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  68800. /**
  68801. * AmmoJS Physics plugin
  68802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68803. * @see https://github.com/kripken/ammo.js/
  68804. */
  68805. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  68806. private _useDeltaForWorldStep;
  68807. /**
  68808. * Reference to the Ammo library
  68809. */
  68810. bjsAMMO: any;
  68811. /**
  68812. * Created ammoJS world which physics bodies are added to
  68813. */
  68814. world: any;
  68815. /**
  68816. * Name of the plugin
  68817. */
  68818. name: string;
  68819. private _timeStep;
  68820. private _fixedTimeStep;
  68821. private _maxSteps;
  68822. private _tmpQuaternion;
  68823. private _tmpAmmoTransform;
  68824. private _tmpAmmoQuaternion;
  68825. private _tmpAmmoConcreteContactResultCallback;
  68826. private _collisionConfiguration;
  68827. private _dispatcher;
  68828. private _overlappingPairCache;
  68829. private _solver;
  68830. private _softBodySolver;
  68831. private _tmpAmmoVectorA;
  68832. private _tmpAmmoVectorB;
  68833. private _tmpAmmoVectorC;
  68834. private _tmpAmmoVectorD;
  68835. private _tmpContactCallbackResult;
  68836. private _tmpAmmoVectorRCA;
  68837. private _tmpAmmoVectorRCB;
  68838. private _raycastResult;
  68839. private _tmpContactPoint;
  68840. private static readonly DISABLE_COLLISION_FLAG;
  68841. private static readonly KINEMATIC_FLAG;
  68842. private static readonly DISABLE_DEACTIVATION_FLAG;
  68843. /**
  68844. * Initializes the ammoJS plugin
  68845. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  68846. * @param ammoInjection can be used to inject your own ammo reference
  68847. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  68848. */
  68849. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  68850. /**
  68851. * Sets the gravity of the physics world (m/(s^2))
  68852. * @param gravity Gravity to set
  68853. */
  68854. setGravity(gravity: Vector3): void;
  68855. /**
  68856. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  68857. * @param timeStep timestep to use in seconds
  68858. */
  68859. setTimeStep(timeStep: number): void;
  68860. /**
  68861. * 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)
  68862. * @param fixedTimeStep fixedTimeStep to use in seconds
  68863. */
  68864. setFixedTimeStep(fixedTimeStep: number): void;
  68865. /**
  68866. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  68867. * @param maxSteps the maximum number of steps by the physics engine per frame
  68868. */
  68869. setMaxSteps(maxSteps: number): void;
  68870. /**
  68871. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  68872. * @returns the current timestep in seconds
  68873. */
  68874. getTimeStep(): number;
  68875. /**
  68876. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  68877. */
  68878. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  68879. private _isImpostorInContact;
  68880. private _isImpostorPairInContact;
  68881. private _stepSimulation;
  68882. /**
  68883. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  68884. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  68885. * After the step the babylon meshes are set to the position of the physics imposters
  68886. * @param delta amount of time to step forward
  68887. * @param impostors array of imposters to update before/after the step
  68888. */
  68889. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68890. /**
  68891. * Update babylon mesh to match physics world object
  68892. * @param impostor imposter to match
  68893. */
  68894. private _afterSoftStep;
  68895. /**
  68896. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68897. * @param impostor imposter to match
  68898. */
  68899. private _ropeStep;
  68900. /**
  68901. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68902. * @param impostor imposter to match
  68903. */
  68904. private _softbodyOrClothStep;
  68905. private _tmpMatrix;
  68906. /**
  68907. * Applies an impulse on the imposter
  68908. * @param impostor imposter to apply impulse to
  68909. * @param force amount of force to be applied to the imposter
  68910. * @param contactPoint the location to apply the impulse on the imposter
  68911. */
  68912. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68913. /**
  68914. * Applies a force on the imposter
  68915. * @param impostor imposter to apply force
  68916. * @param force amount of force to be applied to the imposter
  68917. * @param contactPoint the location to apply the force on the imposter
  68918. */
  68919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68920. /**
  68921. * Creates a physics body using the plugin
  68922. * @param impostor the imposter to create the physics body on
  68923. */
  68924. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68925. /**
  68926. * Removes the physics body from the imposter and disposes of the body's memory
  68927. * @param impostor imposter to remove the physics body from
  68928. */
  68929. removePhysicsBody(impostor: PhysicsImpostor): void;
  68930. /**
  68931. * Generates a joint
  68932. * @param impostorJoint the imposter joint to create the joint with
  68933. */
  68934. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68935. /**
  68936. * Removes a joint
  68937. * @param impostorJoint the imposter joint to remove the joint from
  68938. */
  68939. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68940. private _addMeshVerts;
  68941. /**
  68942. * Initialise the soft body vertices to match its object's (mesh) vertices
  68943. * Softbody vertices (nodes) are in world space and to match this
  68944. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  68945. * @param impostor to create the softbody for
  68946. */
  68947. private _softVertexData;
  68948. /**
  68949. * Create an impostor's soft body
  68950. * @param impostor to create the softbody for
  68951. */
  68952. private _createSoftbody;
  68953. /**
  68954. * Create cloth for an impostor
  68955. * @param impostor to create the softbody for
  68956. */
  68957. private _createCloth;
  68958. /**
  68959. * Create rope for an impostor
  68960. * @param impostor to create the softbody for
  68961. */
  68962. private _createRope;
  68963. /**
  68964. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  68965. * @param impostor to create the custom physics shape for
  68966. */
  68967. private _createCustom;
  68968. private _addHullVerts;
  68969. private _createShape;
  68970. /**
  68971. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  68972. * @param impostor imposter containing the physics body and babylon object
  68973. */
  68974. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68975. /**
  68976. * Sets the babylon object's position/rotation from the physics body's position/rotation
  68977. * @param impostor imposter containing the physics body and babylon object
  68978. * @param newPosition new position
  68979. * @param newRotation new rotation
  68980. */
  68981. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68982. /**
  68983. * If this plugin is supported
  68984. * @returns true if its supported
  68985. */
  68986. isSupported(): boolean;
  68987. /**
  68988. * Sets the linear velocity of the physics body
  68989. * @param impostor imposter to set the velocity on
  68990. * @param velocity velocity to set
  68991. */
  68992. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68993. /**
  68994. * Sets the angular velocity of the physics body
  68995. * @param impostor imposter to set the velocity on
  68996. * @param velocity velocity to set
  68997. */
  68998. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68999. /**
  69000. * gets the linear velocity
  69001. * @param impostor imposter to get linear velocity from
  69002. * @returns linear velocity
  69003. */
  69004. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  69005. /**
  69006. * gets the angular velocity
  69007. * @param impostor imposter to get angular velocity from
  69008. * @returns angular velocity
  69009. */
  69010. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  69011. /**
  69012. * Sets the mass of physics body
  69013. * @param impostor imposter to set the mass on
  69014. * @param mass mass to set
  69015. */
  69016. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  69017. /**
  69018. * Gets the mass of the physics body
  69019. * @param impostor imposter to get the mass from
  69020. * @returns mass
  69021. */
  69022. getBodyMass(impostor: PhysicsImpostor): number;
  69023. /**
  69024. * Gets friction of the impostor
  69025. * @param impostor impostor to get friction from
  69026. * @returns friction value
  69027. */
  69028. getBodyFriction(impostor: PhysicsImpostor): number;
  69029. /**
  69030. * Sets friction of the impostor
  69031. * @param impostor impostor to set friction on
  69032. * @param friction friction value
  69033. */
  69034. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  69035. /**
  69036. * Gets restitution of the impostor
  69037. * @param impostor impostor to get restitution from
  69038. * @returns restitution value
  69039. */
  69040. getBodyRestitution(impostor: PhysicsImpostor): number;
  69041. /**
  69042. * Sets restitution of the impostor
  69043. * @param impostor impostor to set resitution on
  69044. * @param restitution resitution value
  69045. */
  69046. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  69047. /**
  69048. * Gets pressure inside the impostor
  69049. * @param impostor impostor to get pressure from
  69050. * @returns pressure value
  69051. */
  69052. getBodyPressure(impostor: PhysicsImpostor): number;
  69053. /**
  69054. * Sets pressure inside a soft body impostor
  69055. * Cloth and rope must remain 0 pressure
  69056. * @param impostor impostor to set pressure on
  69057. * @param pressure pressure value
  69058. */
  69059. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  69060. /**
  69061. * Gets stiffness of the impostor
  69062. * @param impostor impostor to get stiffness from
  69063. * @returns pressure value
  69064. */
  69065. getBodyStiffness(impostor: PhysicsImpostor): number;
  69066. /**
  69067. * Sets stiffness of the impostor
  69068. * @param impostor impostor to set stiffness on
  69069. * @param stiffness stiffness value from 0 to 1
  69070. */
  69071. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  69072. /**
  69073. * Gets velocityIterations of the impostor
  69074. * @param impostor impostor to get velocity iterations from
  69075. * @returns velocityIterations value
  69076. */
  69077. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  69078. /**
  69079. * Sets velocityIterations of the impostor
  69080. * @param impostor impostor to set velocity iterations on
  69081. * @param velocityIterations velocityIterations value
  69082. */
  69083. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  69084. /**
  69085. * Gets positionIterations of the impostor
  69086. * @param impostor impostor to get position iterations from
  69087. * @returns positionIterations value
  69088. */
  69089. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  69090. /**
  69091. * Sets positionIterations of the impostor
  69092. * @param impostor impostor to set position on
  69093. * @param positionIterations positionIterations value
  69094. */
  69095. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  69096. /**
  69097. * Append an anchor to a cloth object
  69098. * @param impostor is the cloth impostor to add anchor to
  69099. * @param otherImpostor is the rigid impostor to anchor to
  69100. * @param width ratio across width from 0 to 1
  69101. * @param height ratio up height from 0 to 1
  69102. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  69103. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  69104. */
  69105. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  69106. /**
  69107. * Append an hook to a rope object
  69108. * @param impostor is the rope impostor to add hook to
  69109. * @param otherImpostor is the rigid impostor to hook to
  69110. * @param length ratio along the rope from 0 to 1
  69111. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  69112. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  69113. */
  69114. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  69115. /**
  69116. * Sleeps the physics body and stops it from being active
  69117. * @param impostor impostor to sleep
  69118. */
  69119. sleepBody(impostor: PhysicsImpostor): void;
  69120. /**
  69121. * Activates the physics body
  69122. * @param impostor impostor to activate
  69123. */
  69124. wakeUpBody(impostor: PhysicsImpostor): void;
  69125. /**
  69126. * Updates the distance parameters of the joint
  69127. * @param joint joint to update
  69128. * @param maxDistance maximum distance of the joint
  69129. * @param minDistance minimum distance of the joint
  69130. */
  69131. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  69132. /**
  69133. * Sets a motor on the joint
  69134. * @param joint joint to set motor on
  69135. * @param speed speed of the motor
  69136. * @param maxForce maximum force of the motor
  69137. * @param motorIndex index of the motor
  69138. */
  69139. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  69140. /**
  69141. * Sets the motors limit
  69142. * @param joint joint to set limit on
  69143. * @param upperLimit upper limit
  69144. * @param lowerLimit lower limit
  69145. */
  69146. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  69147. /**
  69148. * Syncs the position and rotation of a mesh with the impostor
  69149. * @param mesh mesh to sync
  69150. * @param impostor impostor to update the mesh with
  69151. */
  69152. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  69153. /**
  69154. * Gets the radius of the impostor
  69155. * @param impostor impostor to get radius from
  69156. * @returns the radius
  69157. */
  69158. getRadius(impostor: PhysicsImpostor): number;
  69159. /**
  69160. * Gets the box size of the impostor
  69161. * @param impostor impostor to get box size from
  69162. * @param result the resulting box size
  69163. */
  69164. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  69165. /**
  69166. * Disposes of the impostor
  69167. */
  69168. dispose(): void;
  69169. /**
  69170. * Does a raycast in the physics world
  69171. * @param from when should the ray start?
  69172. * @param to when should the ray end?
  69173. * @returns PhysicsRaycastResult
  69174. */
  69175. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  69176. }
  69177. }
  69178. declare module "babylonjs/Probes/reflectionProbe" {
  69179. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69180. import { Vector3 } from "babylonjs/Maths/math.vector";
  69181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69182. import { Nullable } from "babylonjs/types";
  69183. import { Scene } from "babylonjs/scene";
  69184. module "babylonjs/abstractScene" {
  69185. interface AbstractScene {
  69186. /**
  69187. * The list of reflection probes added to the scene
  69188. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  69189. */
  69190. reflectionProbes: Array<ReflectionProbe>;
  69191. /**
  69192. * Removes the given reflection probe from this scene.
  69193. * @param toRemove The reflection probe to remove
  69194. * @returns The index of the removed reflection probe
  69195. */
  69196. removeReflectionProbe(toRemove: ReflectionProbe): number;
  69197. /**
  69198. * Adds the given reflection probe to this scene.
  69199. * @param newReflectionProbe The reflection probe to add
  69200. */
  69201. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  69202. }
  69203. }
  69204. /**
  69205. * Class used to generate realtime reflection / refraction cube textures
  69206. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  69207. */
  69208. export class ReflectionProbe {
  69209. /** defines the name of the probe */
  69210. name: string;
  69211. private _scene;
  69212. private _renderTargetTexture;
  69213. private _projectionMatrix;
  69214. private _viewMatrix;
  69215. private _target;
  69216. private _add;
  69217. private _attachedMesh;
  69218. private _invertYAxis;
  69219. /** Gets or sets probe position (center of the cube map) */
  69220. position: Vector3;
  69221. /**
  69222. * Creates a new reflection probe
  69223. * @param name defines the name of the probe
  69224. * @param size defines the texture resolution (for each face)
  69225. * @param scene defines the hosting scene
  69226. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  69227. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  69228. */
  69229. constructor(
  69230. /** defines the name of the probe */
  69231. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  69232. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  69233. get samples(): number;
  69234. set samples(value: number);
  69235. /** Gets or sets the refresh rate to use (on every frame by default) */
  69236. get refreshRate(): number;
  69237. set refreshRate(value: number);
  69238. /**
  69239. * Gets the hosting scene
  69240. * @returns a Scene
  69241. */
  69242. getScene(): Scene;
  69243. /** Gets the internal CubeTexture used to render to */
  69244. get cubeTexture(): RenderTargetTexture;
  69245. /** Gets the list of meshes to render */
  69246. get renderList(): Nullable<AbstractMesh[]>;
  69247. /**
  69248. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  69249. * @param mesh defines the mesh to attach to
  69250. */
  69251. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  69252. /**
  69253. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  69254. * @param renderingGroupId The rendering group id corresponding to its index
  69255. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  69256. */
  69257. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  69258. /**
  69259. * Clean all associated resources
  69260. */
  69261. dispose(): void;
  69262. /**
  69263. * Converts the reflection probe information to a readable string for debug purpose.
  69264. * @param fullDetails Supports for multiple levels of logging within scene loading
  69265. * @returns the human readable reflection probe info
  69266. */
  69267. toString(fullDetails?: boolean): string;
  69268. /**
  69269. * Get the class name of the refection probe.
  69270. * @returns "ReflectionProbe"
  69271. */
  69272. getClassName(): string;
  69273. /**
  69274. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  69275. * @returns The JSON representation of the texture
  69276. */
  69277. serialize(): any;
  69278. /**
  69279. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  69280. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  69281. * @param scene Define the scene the parsed reflection probe should be instantiated in
  69282. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  69283. * @returns The parsed reflection probe if successful
  69284. */
  69285. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  69286. }
  69287. }
  69288. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  69289. /** @hidden */
  69290. export var _BabylonLoaderRegistered: boolean;
  69291. /**
  69292. * Helps setting up some configuration for the babylon file loader.
  69293. */
  69294. export class BabylonFileLoaderConfiguration {
  69295. /**
  69296. * The loader does not allow injecting custom physics engine into the plugins.
  69297. * Unfortunately in ES6, we need to manually inject them into the plugin.
  69298. * So you could set this variable to your engine import to make it work.
  69299. */
  69300. static LoaderInjectedPhysicsEngine: any;
  69301. }
  69302. }
  69303. declare module "babylonjs/Loading/Plugins/index" {
  69304. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  69305. }
  69306. declare module "babylonjs/Loading/index" {
  69307. export * from "babylonjs/Loading/loadingScreen";
  69308. export * from "babylonjs/Loading/Plugins/index";
  69309. export * from "babylonjs/Loading/sceneLoader";
  69310. export * from "babylonjs/Loading/sceneLoaderFlags";
  69311. }
  69312. declare module "babylonjs/Materials/Background/index" {
  69313. export * from "babylonjs/Materials/Background/backgroundMaterial";
  69314. }
  69315. declare module "babylonjs/Materials/Occlusion/occlusionMaterial" {
  69316. import { Scene } from "babylonjs/scene";
  69317. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  69318. import "babylonjs/Shaders/color.fragment";
  69319. import "babylonjs/Shaders/color.vertex";
  69320. /**
  69321. * A material to use for fast depth-only rendering.
  69322. */
  69323. export class OcclusionMaterial extends ShaderMaterial {
  69324. constructor(name: string, scene: Scene);
  69325. }
  69326. }
  69327. declare module "babylonjs/Materials/Occlusion/index" {
  69328. export * from "babylonjs/Materials/Occlusion/occlusionMaterial";
  69329. }
  69330. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  69331. import { Scene } from "babylonjs/scene";
  69332. import { Color3 } from "babylonjs/Maths/math.color";
  69333. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  69334. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69335. /**
  69336. * The Physically based simple base material of BJS.
  69337. *
  69338. * This enables better naming and convention enforcements on top of the pbrMaterial.
  69339. * It is used as the base class for both the specGloss and metalRough conventions.
  69340. */
  69341. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  69342. /**
  69343. * Number of Simultaneous lights allowed on the material.
  69344. */
  69345. maxSimultaneousLights: number;
  69346. /**
  69347. * If sets to true, disables all the lights affecting the material.
  69348. */
  69349. disableLighting: boolean;
  69350. /**
  69351. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  69352. */
  69353. environmentTexture: BaseTexture;
  69354. /**
  69355. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  69356. */
  69357. invertNormalMapX: boolean;
  69358. /**
  69359. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  69360. */
  69361. invertNormalMapY: boolean;
  69362. /**
  69363. * Normal map used in the model.
  69364. */
  69365. normalTexture: BaseTexture;
  69366. /**
  69367. * Emissivie color used to self-illuminate the model.
  69368. */
  69369. emissiveColor: Color3;
  69370. /**
  69371. * Emissivie texture used to self-illuminate the model.
  69372. */
  69373. emissiveTexture: BaseTexture;
  69374. /**
  69375. * Occlusion Channel Strength.
  69376. */
  69377. occlusionStrength: number;
  69378. /**
  69379. * Occlusion Texture of the material (adding extra occlusion effects).
  69380. */
  69381. occlusionTexture: BaseTexture;
  69382. /**
  69383. * Defines the alpha limits in alpha test mode.
  69384. */
  69385. alphaCutOff: number;
  69386. /**
  69387. * Gets the current double sided mode.
  69388. */
  69389. get doubleSided(): boolean;
  69390. /**
  69391. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  69392. */
  69393. set doubleSided(value: boolean);
  69394. /**
  69395. * Stores the pre-calculated light information of a mesh in a texture.
  69396. */
  69397. lightmapTexture: BaseTexture;
  69398. /**
  69399. * If true, the light map contains occlusion information instead of lighting info.
  69400. */
  69401. useLightmapAsShadowmap: boolean;
  69402. /**
  69403. * Instantiates a new PBRMaterial instance.
  69404. *
  69405. * @param name The material name
  69406. * @param scene The scene the material will be use in.
  69407. */
  69408. constructor(name: string, scene: Scene);
  69409. getClassName(): string;
  69410. }
  69411. }
  69412. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  69413. import { Scene } from "babylonjs/scene";
  69414. import { Color3 } from "babylonjs/Maths/math.color";
  69415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69416. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  69417. /**
  69418. * The PBR material of BJS following the metal roughness convention.
  69419. *
  69420. * This fits to the PBR convention in the GLTF definition:
  69421. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  69422. */
  69423. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  69424. /**
  69425. * The base color has two different interpretations depending on the value of metalness.
  69426. * When the material is a metal, the base color is the specific measured reflectance value
  69427. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  69428. * of the material.
  69429. */
  69430. baseColor: Color3;
  69431. /**
  69432. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  69433. * well as opacity information in the alpha channel.
  69434. */
  69435. baseTexture: BaseTexture;
  69436. /**
  69437. * Specifies the metallic scalar value of the material.
  69438. * Can also be used to scale the metalness values of the metallic texture.
  69439. */
  69440. metallic: number;
  69441. /**
  69442. * Specifies the roughness scalar value of the material.
  69443. * Can also be used to scale the roughness values of the metallic texture.
  69444. */
  69445. roughness: number;
  69446. /**
  69447. * Texture containing both the metallic value in the B channel and the
  69448. * roughness value in the G channel to keep better precision.
  69449. */
  69450. metallicRoughnessTexture: BaseTexture;
  69451. /**
  69452. * Instantiates a new PBRMetalRoughnessMaterial instance.
  69453. *
  69454. * @param name The material name
  69455. * @param scene The scene the material will be use in.
  69456. */
  69457. constructor(name: string, scene: Scene);
  69458. /**
  69459. * Return the current class name of the material.
  69460. */
  69461. getClassName(): string;
  69462. /**
  69463. * Makes a duplicate of the current material.
  69464. * @param name - name to use for the new material.
  69465. */
  69466. clone(name: string): PBRMetallicRoughnessMaterial;
  69467. /**
  69468. * Serialize the material to a parsable JSON object.
  69469. */
  69470. serialize(): any;
  69471. /**
  69472. * Parses a JSON object corresponding to the serialize function.
  69473. */
  69474. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  69475. }
  69476. }
  69477. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  69478. import { Scene } from "babylonjs/scene";
  69479. import { Color3 } from "babylonjs/Maths/math.color";
  69480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69481. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  69482. /**
  69483. * The PBR material of BJS following the specular glossiness convention.
  69484. *
  69485. * This fits to the PBR convention in the GLTF definition:
  69486. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  69487. */
  69488. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  69489. /**
  69490. * Specifies the diffuse color of the material.
  69491. */
  69492. diffuseColor: Color3;
  69493. /**
  69494. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  69495. * channel.
  69496. */
  69497. diffuseTexture: BaseTexture;
  69498. /**
  69499. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  69500. */
  69501. specularColor: Color3;
  69502. /**
  69503. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  69504. */
  69505. glossiness: number;
  69506. /**
  69507. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  69508. */
  69509. specularGlossinessTexture: BaseTexture;
  69510. /**
  69511. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  69512. */
  69513. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  69514. /**
  69515. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  69516. *
  69517. * @param name The material name
  69518. * @param scene The scene the material will be use in.
  69519. */
  69520. constructor(name: string, scene: Scene);
  69521. /**
  69522. * Return the current class name of the material.
  69523. */
  69524. getClassName(): string;
  69525. /**
  69526. * Makes a duplicate of the current material.
  69527. * @param name - name to use for the new material.
  69528. */
  69529. clone(name: string): PBRSpecularGlossinessMaterial;
  69530. /**
  69531. * Serialize the material to a parsable JSON object.
  69532. */
  69533. serialize(): any;
  69534. /**
  69535. * Parses a JSON object corresponding to the serialize function.
  69536. */
  69537. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  69538. }
  69539. }
  69540. declare module "babylonjs/Materials/PBR/index" {
  69541. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  69542. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  69543. export * from "babylonjs/Materials/PBR/pbrMaterial";
  69544. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  69545. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  69546. }
  69547. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  69548. import { Nullable } from "babylonjs/types";
  69549. import { Scene } from "babylonjs/scene";
  69550. import { Matrix } from "babylonjs/Maths/math.vector";
  69551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69552. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  69553. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69554. /**
  69555. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  69556. * It can help converting any input color in a desired output one. This can then be used to create effects
  69557. * from sepia, black and white to sixties or futuristic rendering...
  69558. *
  69559. * The only supported format is currently 3dl.
  69560. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  69561. */
  69562. export class ColorGradingTexture extends BaseTexture {
  69563. /**
  69564. * The texture URL.
  69565. */
  69566. url: string;
  69567. /**
  69568. * Empty line regex stored for GC.
  69569. */
  69570. private static _noneEmptyLineRegex;
  69571. private _textureMatrix;
  69572. private _onLoad;
  69573. /**
  69574. * Instantiates a ColorGradingTexture from the following parameters.
  69575. *
  69576. * @param url The location of the color grading data (currently only supporting 3dl)
  69577. * @param sceneOrEngine The scene or engine the texture will be used in
  69578. * @param onLoad defines a callback triggered when the texture has been loaded
  69579. */
  69580. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  69581. /**
  69582. * Fires the onload event from the constructor if requested.
  69583. */
  69584. private _triggerOnLoad;
  69585. /**
  69586. * Returns the texture matrix used in most of the material.
  69587. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  69588. */
  69589. getTextureMatrix(): Matrix;
  69590. /**
  69591. * Occurs when the file being loaded is a .3dl LUT file.
  69592. */
  69593. private load3dlTexture;
  69594. /**
  69595. * Starts the loading process of the texture.
  69596. */
  69597. private loadTexture;
  69598. /**
  69599. * Clones the color grading texture.
  69600. */
  69601. clone(): ColorGradingTexture;
  69602. /**
  69603. * Called during delayed load for textures.
  69604. */
  69605. delayLoad(): void;
  69606. /**
  69607. * Parses a color grading texture serialized by Babylon.
  69608. * @param parsedTexture The texture information being parsedTexture
  69609. * @param scene The scene to load the texture in
  69610. * @param rootUrl The root url of the data assets to load
  69611. * @return A color grading texture
  69612. */
  69613. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  69614. /**
  69615. * Serializes the LUT texture to json format.
  69616. */
  69617. serialize(): any;
  69618. }
  69619. }
  69620. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  69621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69622. import { Scene } from "babylonjs/scene";
  69623. import { Nullable } from "babylonjs/types";
  69624. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69625. /**
  69626. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  69627. */
  69628. export class EquiRectangularCubeTexture extends BaseTexture {
  69629. /** The six faces of the cube. */
  69630. private static _FacesMapping;
  69631. private _noMipmap;
  69632. private _onLoad;
  69633. private _onError;
  69634. /** The size of the cubemap. */
  69635. private _size;
  69636. /** The buffer of the image. */
  69637. private _buffer;
  69638. /** The width of the input image. */
  69639. private _width;
  69640. /** The height of the input image. */
  69641. private _height;
  69642. /** The URL to the image. */
  69643. url: string;
  69644. /**
  69645. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  69646. * @param url The location of the image
  69647. * @param scene The scene the texture will be used in
  69648. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  69649. * @param noMipmap Forces to not generate the mipmap if true
  69650. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69651. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69652. * @param onLoad — defines a callback called when texture is loaded
  69653. * @param onError — defines a callback called if there is an error
  69654. */
  69655. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  69656. /**
  69657. * Load the image data, by putting the image on a canvas and extracting its buffer.
  69658. */
  69659. private loadImage;
  69660. /**
  69661. * Convert the image buffer into a cubemap and create a CubeTexture.
  69662. */
  69663. private loadTexture;
  69664. /**
  69665. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  69666. * @param buffer The ArrayBuffer that should be converted.
  69667. * @returns The buffer as Float32Array.
  69668. */
  69669. private getFloat32ArrayFromArrayBuffer;
  69670. /**
  69671. * Get the current class name of the texture useful for serialization or dynamic coding.
  69672. * @returns "EquiRectangularCubeTexture"
  69673. */
  69674. getClassName(): string;
  69675. /**
  69676. * Create a clone of the current EquiRectangularCubeTexture and return it.
  69677. * @returns A clone of the current EquiRectangularCubeTexture.
  69678. */
  69679. clone(): EquiRectangularCubeTexture;
  69680. }
  69681. }
  69682. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  69683. import { Nullable } from "babylonjs/types";
  69684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69685. import { Matrix } from "babylonjs/Maths/math.vector";
  69686. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  69687. import "babylonjs/Engines/Extensions/engine.videoTexture";
  69688. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  69689. import { Scene } from "babylonjs/scene";
  69690. /**
  69691. * Defines the options related to the creation of an HtmlElementTexture
  69692. */
  69693. export interface IHtmlElementTextureOptions {
  69694. /**
  69695. * Defines whether mip maps should be created or not.
  69696. */
  69697. generateMipMaps?: boolean;
  69698. /**
  69699. * Defines the sampling mode of the texture.
  69700. */
  69701. samplingMode?: number;
  69702. /**
  69703. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  69704. */
  69705. engine: Nullable<ThinEngine>;
  69706. /**
  69707. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  69708. */
  69709. scene: Nullable<Scene>;
  69710. }
  69711. /**
  69712. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  69713. * To be as efficient as possible depending on your constraints nothing aside the first upload
  69714. * is automatically managed.
  69715. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  69716. * in your application.
  69717. *
  69718. * As the update is not automatic, you need to call them manually.
  69719. */
  69720. export class HtmlElementTexture extends BaseTexture {
  69721. /**
  69722. * The texture URL.
  69723. */
  69724. element: HTMLVideoElement | HTMLCanvasElement;
  69725. private static readonly DefaultOptions;
  69726. private _textureMatrix;
  69727. private _isVideo;
  69728. private _generateMipMaps;
  69729. private _samplingMode;
  69730. /**
  69731. * Instantiates a HtmlElementTexture from the following parameters.
  69732. *
  69733. * @param name Defines the name of the texture
  69734. * @param element Defines the video or canvas the texture is filled with
  69735. * @param options Defines the other none mandatory texture creation options
  69736. */
  69737. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  69738. private _createInternalTexture;
  69739. /**
  69740. * Returns the texture matrix used in most of the material.
  69741. */
  69742. getTextureMatrix(): Matrix;
  69743. /**
  69744. * Updates the content of the texture.
  69745. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  69746. */
  69747. update(invertY?: Nullable<boolean>): void;
  69748. }
  69749. }
  69750. declare module "babylonjs/Misc/tga" {
  69751. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69752. /**
  69753. * Based on jsTGALoader - Javascript loader for TGA file
  69754. * By Vincent Thibault
  69755. * @see http://blog.robrowser.com/javascript-tga-loader.html
  69756. */
  69757. export class TGATools {
  69758. private static _TYPE_INDEXED;
  69759. private static _TYPE_RGB;
  69760. private static _TYPE_GREY;
  69761. private static _TYPE_RLE_INDEXED;
  69762. private static _TYPE_RLE_RGB;
  69763. private static _TYPE_RLE_GREY;
  69764. private static _ORIGIN_MASK;
  69765. private static _ORIGIN_SHIFT;
  69766. private static _ORIGIN_BL;
  69767. private static _ORIGIN_BR;
  69768. private static _ORIGIN_UL;
  69769. private static _ORIGIN_UR;
  69770. /**
  69771. * Gets the header of a TGA file
  69772. * @param data defines the TGA data
  69773. * @returns the header
  69774. */
  69775. static GetTGAHeader(data: Uint8Array): any;
  69776. /**
  69777. * Uploads TGA content to a Babylon Texture
  69778. * @hidden
  69779. */
  69780. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  69781. /** @hidden */
  69782. 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;
  69783. /** @hidden */
  69784. 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;
  69785. /** @hidden */
  69786. 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;
  69787. /** @hidden */
  69788. 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;
  69789. /** @hidden */
  69790. 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;
  69791. /** @hidden */
  69792. 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;
  69793. }
  69794. }
  69795. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  69796. import { Nullable } from "babylonjs/types";
  69797. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69798. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69799. /**
  69800. * Implementation of the TGA Texture Loader.
  69801. * @hidden
  69802. */
  69803. export class _TGATextureLoader implements IInternalTextureLoader {
  69804. /**
  69805. * Defines whether the loader supports cascade loading the different faces.
  69806. */
  69807. readonly supportCascades: boolean;
  69808. /**
  69809. * This returns if the loader support the current file information.
  69810. * @param extension defines the file extension of the file being loaded
  69811. * @returns true if the loader can load the specified file
  69812. */
  69813. canLoad(extension: string): boolean;
  69814. /**
  69815. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69816. * @param data contains the texture data
  69817. * @param texture defines the BabylonJS internal texture
  69818. * @param createPolynomials will be true if polynomials have been requested
  69819. * @param onLoad defines the callback to trigger once the texture is ready
  69820. * @param onError defines the callback to trigger in case of error
  69821. */
  69822. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69823. /**
  69824. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69825. * @param data contains the texture data
  69826. * @param texture defines the BabylonJS internal texture
  69827. * @param callback defines the method to call once ready to upload
  69828. */
  69829. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69830. }
  69831. }
  69832. declare module "babylonjs/Materials/Textures/Loaders/hdrTextureLoader" {
  69833. import { Nullable } from "babylonjs/types";
  69834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69835. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69836. /**
  69837. * Implementation of the HDR Texture Loader.
  69838. * @hidden
  69839. */
  69840. export class _HDRTextureLoader implements IInternalTextureLoader {
  69841. /**
  69842. * Defines whether the loader supports cascade loading the different faces.
  69843. */
  69844. readonly supportCascades: boolean;
  69845. /**
  69846. * This returns if the loader support the current file information.
  69847. * @param extension defines the file extension of the file being loaded
  69848. * @returns true if the loader can load the specified file
  69849. */
  69850. canLoad(extension: string): boolean;
  69851. /**
  69852. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69853. * @param data contains the texture data
  69854. * @param texture defines the BabylonJS internal texture
  69855. * @param createPolynomials will be true if polynomials have been requested
  69856. * @param onLoad defines the callback to trigger once the texture is ready
  69857. * @param onError defines the callback to trigger in case of error
  69858. */
  69859. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69860. /**
  69861. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69862. * @param data contains the texture data
  69863. * @param texture defines the BabylonJS internal texture
  69864. * @param callback defines the method to call once ready to upload
  69865. */
  69866. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69867. }
  69868. }
  69869. declare module "babylonjs/Misc/basis" {
  69870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69871. /**
  69872. * Info about the .basis files
  69873. */
  69874. class BasisFileInfo {
  69875. /**
  69876. * If the file has alpha
  69877. */
  69878. hasAlpha: boolean;
  69879. /**
  69880. * Info about each image of the basis file
  69881. */
  69882. images: Array<{
  69883. levels: Array<{
  69884. width: number;
  69885. height: number;
  69886. transcodedPixels: ArrayBufferView;
  69887. }>;
  69888. }>;
  69889. }
  69890. /**
  69891. * Result of transcoding a basis file
  69892. */
  69893. class TranscodeResult {
  69894. /**
  69895. * Info about the .basis file
  69896. */
  69897. fileInfo: BasisFileInfo;
  69898. /**
  69899. * Format to use when loading the file
  69900. */
  69901. format: number;
  69902. }
  69903. /**
  69904. * Configuration options for the Basis transcoder
  69905. */
  69906. export class BasisTranscodeConfiguration {
  69907. /**
  69908. * Supported compression formats used to determine the supported output format of the transcoder
  69909. */
  69910. supportedCompressionFormats?: {
  69911. /**
  69912. * etc1 compression format
  69913. */
  69914. etc1?: boolean;
  69915. /**
  69916. * s3tc compression format
  69917. */
  69918. s3tc?: boolean;
  69919. /**
  69920. * pvrtc compression format
  69921. */
  69922. pvrtc?: boolean;
  69923. /**
  69924. * etc2 compression format
  69925. */
  69926. etc2?: boolean;
  69927. };
  69928. /**
  69929. * If mipmap levels should be loaded for transcoded images (Default: true)
  69930. */
  69931. loadMipmapLevels?: boolean;
  69932. /**
  69933. * Index of a single image to load (Default: all images)
  69934. */
  69935. loadSingleImage?: number;
  69936. }
  69937. /**
  69938. * Used to load .Basis files
  69939. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  69940. */
  69941. export class BasisTools {
  69942. private static _IgnoreSupportedFormats;
  69943. /**
  69944. * URL to use when loading the basis transcoder
  69945. */
  69946. static JSModuleURL: string;
  69947. /**
  69948. * URL to use when loading the wasm module for the transcoder
  69949. */
  69950. static WasmModuleURL: string;
  69951. /**
  69952. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  69953. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  69954. * @returns internal format corresponding to the Basis format
  69955. */
  69956. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  69957. private static _WorkerPromise;
  69958. private static _Worker;
  69959. private static _actionId;
  69960. private static _CreateWorkerAsync;
  69961. /**
  69962. * Transcodes a loaded image file to compressed pixel data
  69963. * @param data image data to transcode
  69964. * @param config configuration options for the transcoding
  69965. * @returns a promise resulting in the transcoded image
  69966. */
  69967. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  69968. /**
  69969. * Loads a texture from the transcode result
  69970. * @param texture texture load to
  69971. * @param transcodeResult the result of transcoding the basis file to load from
  69972. */
  69973. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  69974. }
  69975. }
  69976. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  69977. import { Nullable } from "babylonjs/types";
  69978. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69979. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69980. /**
  69981. * Loader for .basis file format
  69982. */
  69983. export class _BasisTextureLoader implements IInternalTextureLoader {
  69984. /**
  69985. * Defines whether the loader supports cascade loading the different faces.
  69986. */
  69987. readonly supportCascades: boolean;
  69988. /**
  69989. * This returns if the loader support the current file information.
  69990. * @param extension defines the file extension of the file being loaded
  69991. * @returns true if the loader can load the specified file
  69992. */
  69993. canLoad(extension: string): boolean;
  69994. /**
  69995. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69996. * @param data contains the texture data
  69997. * @param texture defines the BabylonJS internal texture
  69998. * @param createPolynomials will be true if polynomials have been requested
  69999. * @param onLoad defines the callback to trigger once the texture is ready
  70000. * @param onError defines the callback to trigger in case of error
  70001. */
  70002. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70003. /**
  70004. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  70005. * @param data contains the texture data
  70006. * @param texture defines the BabylonJS internal texture
  70007. * @param callback defines the method to call once ready to upload
  70008. */
  70009. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  70010. }
  70011. }
  70012. declare module "babylonjs/Materials/Textures/Loaders/index" {
  70013. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  70014. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  70015. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  70016. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  70017. export * from "babylonjs/Materials/Textures/Loaders/hdrTextureLoader";
  70018. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  70019. }
  70020. declare module "babylonjs/Materials/Textures/Packer/frame" {
  70021. import { Vector2 } from "babylonjs/Maths/math.vector";
  70022. /**
  70023. * Defines the basic options interface of a TexturePacker Frame
  70024. */
  70025. export interface ITexturePackerFrame {
  70026. /**
  70027. * The frame ID
  70028. */
  70029. id: number;
  70030. /**
  70031. * The frames Scale
  70032. */
  70033. scale: Vector2;
  70034. /**
  70035. * The Frames offset
  70036. */
  70037. offset: Vector2;
  70038. }
  70039. /**
  70040. * This is a support class for frame Data on texture packer sets.
  70041. */
  70042. export class TexturePackerFrame implements ITexturePackerFrame {
  70043. /**
  70044. * The frame ID
  70045. */
  70046. id: number;
  70047. /**
  70048. * The frames Scale
  70049. */
  70050. scale: Vector2;
  70051. /**
  70052. * The Frames offset
  70053. */
  70054. offset: Vector2;
  70055. /**
  70056. * Initializes a texture package frame.
  70057. * @param id The numerical frame identifier
  70058. * @param scale Scalar Vector2 for UV frame
  70059. * @param offset Vector2 for the frame position in UV units.
  70060. * @returns TexturePackerFrame
  70061. */
  70062. constructor(id: number, scale: Vector2, offset: Vector2);
  70063. }
  70064. }
  70065. declare module "babylonjs/Materials/Textures/Packer/packer" {
  70066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70067. import { Scene } from "babylonjs/scene";
  70068. import { Nullable } from "babylonjs/types";
  70069. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  70070. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  70071. /**
  70072. * Defines the basic options interface of a TexturePacker
  70073. */
  70074. export interface ITexturePackerOptions {
  70075. /**
  70076. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  70077. */
  70078. map?: string[];
  70079. /**
  70080. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  70081. */
  70082. uvsIn?: string;
  70083. /**
  70084. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  70085. */
  70086. uvsOut?: string;
  70087. /**
  70088. * number representing the layout style. Defaults to LAYOUT_STRIP
  70089. */
  70090. layout?: number;
  70091. /**
  70092. * number of columns if using custom column count layout(2). This defaults to 4.
  70093. */
  70094. colnum?: number;
  70095. /**
  70096. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  70097. */
  70098. updateInputMeshes?: boolean;
  70099. /**
  70100. * boolean flag to dispose all the source textures. Defaults to true.
  70101. */
  70102. disposeSources?: boolean;
  70103. /**
  70104. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  70105. */
  70106. fillBlanks?: boolean;
  70107. /**
  70108. * string value representing the context fill style color. Defaults to 'black'.
  70109. */
  70110. customFillColor?: string;
  70111. /**
  70112. * Width and Height Value of each Frame in the TexturePacker Sets
  70113. */
  70114. frameSize?: number;
  70115. /**
  70116. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  70117. */
  70118. paddingRatio?: number;
  70119. /**
  70120. * Number that declares the fill method for the padding gutter.
  70121. */
  70122. paddingMode?: number;
  70123. /**
  70124. * If in SUBUV_COLOR padding mode what color to use.
  70125. */
  70126. paddingColor?: Color3 | Color4;
  70127. }
  70128. /**
  70129. * Defines the basic interface of a TexturePacker JSON File
  70130. */
  70131. export interface ITexturePackerJSON {
  70132. /**
  70133. * The frame ID
  70134. */
  70135. name: string;
  70136. /**
  70137. * The base64 channel data
  70138. */
  70139. sets: any;
  70140. /**
  70141. * The options of the Packer
  70142. */
  70143. options: ITexturePackerOptions;
  70144. /**
  70145. * The frame data of the Packer
  70146. */
  70147. frames: Array<number>;
  70148. }
  70149. /**
  70150. * This is a support class that generates a series of packed texture sets.
  70151. * @see https://doc.babylonjs.com/babylon101/materials
  70152. */
  70153. export class TexturePacker {
  70154. /** Packer Layout Constant 0 */
  70155. static readonly LAYOUT_STRIP: number;
  70156. /** Packer Layout Constant 1 */
  70157. static readonly LAYOUT_POWER2: number;
  70158. /** Packer Layout Constant 2 */
  70159. static readonly LAYOUT_COLNUM: number;
  70160. /** Packer Layout Constant 0 */
  70161. static readonly SUBUV_WRAP: number;
  70162. /** Packer Layout Constant 1 */
  70163. static readonly SUBUV_EXTEND: number;
  70164. /** Packer Layout Constant 2 */
  70165. static readonly SUBUV_COLOR: number;
  70166. /** The Name of the Texture Package */
  70167. name: string;
  70168. /** The scene scope of the TexturePacker */
  70169. scene: Scene;
  70170. /** The Meshes to target */
  70171. meshes: AbstractMesh[];
  70172. /** Arguments passed with the Constructor */
  70173. options: ITexturePackerOptions;
  70174. /** The promise that is started upon initialization */
  70175. promise: Nullable<Promise<TexturePacker | string>>;
  70176. /** The Container object for the channel sets that are generated */
  70177. sets: object;
  70178. /** The Container array for the frames that are generated */
  70179. frames: TexturePackerFrame[];
  70180. /** The expected number of textures the system is parsing. */
  70181. private _expecting;
  70182. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  70183. private _paddingValue;
  70184. /**
  70185. * Initializes a texture package series from an array of meshes or a single mesh.
  70186. * @param name The name of the package
  70187. * @param meshes The target meshes to compose the package from
  70188. * @param options The arguments that texture packer should follow while building.
  70189. * @param scene The scene which the textures are scoped to.
  70190. * @returns TexturePacker
  70191. */
  70192. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  70193. /**
  70194. * Starts the package process
  70195. * @param resolve The promises resolution function
  70196. * @returns TexturePacker
  70197. */
  70198. private _createFrames;
  70199. /**
  70200. * Calculates the Size of the Channel Sets
  70201. * @returns Vector2
  70202. */
  70203. private _calculateSize;
  70204. /**
  70205. * Calculates the UV data for the frames.
  70206. * @param baseSize the base frameSize
  70207. * @param padding the base frame padding
  70208. * @param dtSize size of the Dynamic Texture for that channel
  70209. * @param dtUnits is 1/dtSize
  70210. * @param update flag to update the input meshes
  70211. */
  70212. private _calculateMeshUVFrames;
  70213. /**
  70214. * Calculates the frames Offset.
  70215. * @param index of the frame
  70216. * @returns Vector2
  70217. */
  70218. private _getFrameOffset;
  70219. /**
  70220. * Updates a Mesh to the frame data
  70221. * @param mesh that is the target
  70222. * @param frameID or the frame index
  70223. */
  70224. private _updateMeshUV;
  70225. /**
  70226. * Updates a Meshes materials to use the texture packer channels
  70227. * @param m is the mesh to target
  70228. * @param force all channels on the packer to be set.
  70229. */
  70230. private _updateTextureReferences;
  70231. /**
  70232. * Public method to set a Mesh to a frame
  70233. * @param m that is the target
  70234. * @param frameID or the frame index
  70235. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  70236. */
  70237. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  70238. /**
  70239. * Starts the async promise to compile the texture packer.
  70240. * @returns Promise<void>
  70241. */
  70242. processAsync(): Promise<void>;
  70243. /**
  70244. * Disposes all textures associated with this packer
  70245. */
  70246. dispose(): void;
  70247. /**
  70248. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  70249. * @param imageType is the image type to use.
  70250. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  70251. */
  70252. download(imageType?: string, quality?: number): void;
  70253. /**
  70254. * Public method to load a texturePacker JSON file.
  70255. * @param data of the JSON file in string format.
  70256. */
  70257. updateFromJSON(data: string): void;
  70258. }
  70259. }
  70260. declare module "babylonjs/Materials/Textures/Packer/index" {
  70261. export * from "babylonjs/Materials/Textures/Packer/packer";
  70262. export * from "babylonjs/Materials/Textures/Packer/frame";
  70263. }
  70264. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  70265. import { Scene } from "babylonjs/scene";
  70266. import { Texture } from "babylonjs/Materials/Textures/texture";
  70267. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  70268. /**
  70269. * 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.
  70270. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  70271. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  70272. */
  70273. export class CustomProceduralTexture extends ProceduralTexture {
  70274. private _animate;
  70275. private _time;
  70276. private _config;
  70277. private _texturePath;
  70278. /**
  70279. * Instantiates a new Custom Procedural Texture.
  70280. * 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.
  70281. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  70282. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  70283. * @param name Define the name of the texture
  70284. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  70285. * @param size Define the size of the texture to create
  70286. * @param scene Define the scene the texture belongs to
  70287. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70288. * @param generateMipMaps Define if the texture should creates mip maps or not
  70289. */
  70290. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  70291. private _loadJson;
  70292. /**
  70293. * Is the texture ready to be used ? (rendered at least once)
  70294. * @returns true if ready, otherwise, false.
  70295. */
  70296. isReady(): boolean;
  70297. /**
  70298. * Render the texture to its associated render target.
  70299. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  70300. */
  70301. render(useCameraPostProcess?: boolean): void;
  70302. /**
  70303. * Update the list of dependant textures samplers in the shader.
  70304. */
  70305. updateTextures(): void;
  70306. /**
  70307. * Update the uniform values of the procedural texture in the shader.
  70308. */
  70309. updateShaderUniforms(): void;
  70310. /**
  70311. * Define if the texture animates or not.
  70312. */
  70313. get animate(): boolean;
  70314. set animate(value: boolean);
  70315. }
  70316. }
  70317. declare module "babylonjs/Shaders/noise.fragment" {
  70318. /** @hidden */
  70319. export var noisePixelShader: {
  70320. name: string;
  70321. shader: string;
  70322. };
  70323. }
  70324. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  70325. import { Nullable } from "babylonjs/types";
  70326. import { Scene } from "babylonjs/scene";
  70327. import { Texture } from "babylonjs/Materials/Textures/texture";
  70328. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  70329. import "babylonjs/Shaders/noise.fragment";
  70330. /**
  70331. * Class used to generate noise procedural textures
  70332. */
  70333. export class NoiseProceduralTexture extends ProceduralTexture {
  70334. /** Gets or sets the start time (default is 0) */
  70335. time: number;
  70336. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  70337. brightness: number;
  70338. /** Defines the number of octaves to process */
  70339. octaves: number;
  70340. /** Defines the level of persistence (0.8 by default) */
  70341. persistence: number;
  70342. /** Gets or sets animation speed factor (default is 1) */
  70343. animationSpeedFactor: number;
  70344. /**
  70345. * Creates a new NoiseProceduralTexture
  70346. * @param name defines the name fo the texture
  70347. * @param size defines the size of the texture (default is 256)
  70348. * @param scene defines the hosting scene
  70349. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  70350. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  70351. */
  70352. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  70353. private _updateShaderUniforms;
  70354. protected _getDefines(): string;
  70355. /** Generate the current state of the procedural texture */
  70356. render(useCameraPostProcess?: boolean): void;
  70357. /**
  70358. * Serializes this noise procedural texture
  70359. * @returns a serialized noise procedural texture object
  70360. */
  70361. serialize(): any;
  70362. /**
  70363. * Clone the texture.
  70364. * @returns the cloned texture
  70365. */
  70366. clone(): NoiseProceduralTexture;
  70367. /**
  70368. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  70369. * @param parsedTexture defines parsed texture data
  70370. * @param scene defines the current scene
  70371. * @param rootUrl defines the root URL containing noise procedural texture information
  70372. * @returns a parsed NoiseProceduralTexture
  70373. */
  70374. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  70375. }
  70376. }
  70377. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  70378. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  70379. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  70380. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  70381. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  70382. }
  70383. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  70384. import { Nullable } from "babylonjs/types";
  70385. import { Scene } from "babylonjs/scene";
  70386. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  70387. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  70388. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70389. import "babylonjs/Engines/Extensions/engine.rawTexture";
  70390. /**
  70391. * Raw cube texture where the raw buffers are passed in
  70392. */
  70393. export class RawCubeTexture extends CubeTexture {
  70394. /**
  70395. * Creates a cube texture where the raw buffers are passed in.
  70396. * @param scene defines the scene the texture is attached to
  70397. * @param data defines the array of data to use to create each face
  70398. * @param size defines the size of the textures
  70399. * @param format defines the format of the data
  70400. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  70401. * @param generateMipMaps defines if the engine should generate the mip levels
  70402. * @param invertY defines if data must be stored with Y axis inverted
  70403. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  70404. * @param compression defines the compression used (null by default)
  70405. */
  70406. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  70407. /**
  70408. * Updates the raw cube texture.
  70409. * @param data defines the data to store
  70410. * @param format defines the data format
  70411. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70412. * @param invertY defines if data must be stored with Y axis inverted
  70413. * @param compression defines the compression used (null by default)
  70414. * @param level defines which level of the texture to update
  70415. */
  70416. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  70417. /**
  70418. * Updates a raw cube texture with RGBD encoded data.
  70419. * @param data defines the array of data [mipmap][face] to use to create each face
  70420. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  70421. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70422. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70423. * @returns a promise that resolves when the operation is complete
  70424. */
  70425. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  70426. /**
  70427. * Clones the raw cube texture.
  70428. * @return a new cube texture
  70429. */
  70430. clone(): CubeTexture;
  70431. /** @hidden */
  70432. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  70433. }
  70434. }
  70435. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  70436. import { Scene } from "babylonjs/scene";
  70437. import { Texture } from "babylonjs/Materials/Textures/texture";
  70438. import "babylonjs/Engines/Extensions/engine.rawTexture";
  70439. /**
  70440. * Class used to store 3D textures containing user data
  70441. */
  70442. export class RawTexture3D extends Texture {
  70443. /** Gets or sets the texture format to use */
  70444. format: number;
  70445. /**
  70446. * Create a new RawTexture3D
  70447. * @param data defines the data of the texture
  70448. * @param width defines the width of the texture
  70449. * @param height defines the height of the texture
  70450. * @param depth defines the depth of the texture
  70451. * @param format defines the texture format to use
  70452. * @param scene defines the hosting scene
  70453. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  70454. * @param invertY defines if texture must be stored with Y axis inverted
  70455. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70456. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  70457. */
  70458. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  70459. /** Gets or sets the texture format to use */
  70460. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  70461. /**
  70462. * Update the texture with new data
  70463. * @param data defines the data to store in the texture
  70464. */
  70465. update(data: ArrayBufferView): void;
  70466. }
  70467. }
  70468. declare module "babylonjs/Materials/Textures/refractionTexture" {
  70469. import { Scene } from "babylonjs/scene";
  70470. import { Plane } from "babylonjs/Maths/math.plane";
  70471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70472. /**
  70473. * Creates a refraction texture used by refraction channel of the standard material.
  70474. * It is like a mirror but to see through a material.
  70475. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  70476. */
  70477. export class RefractionTexture extends RenderTargetTexture {
  70478. /**
  70479. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  70480. * 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.
  70481. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  70482. */
  70483. refractionPlane: Plane;
  70484. /**
  70485. * Define how deep under the surface we should see.
  70486. */
  70487. depth: number;
  70488. /**
  70489. * Creates a refraction texture used by refraction channel of the standard material.
  70490. * It is like a mirror but to see through a material.
  70491. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  70492. * @param name Define the texture name
  70493. * @param size Define the size of the underlying texture
  70494. * @param scene Define the scene the refraction belongs to
  70495. * @param generateMipMaps Define if we need to generate mips level for the refraction
  70496. */
  70497. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  70498. /**
  70499. * Clone the refraction texture.
  70500. * @returns the cloned texture
  70501. */
  70502. clone(): RefractionTexture;
  70503. /**
  70504. * Serialize the texture to a JSON representation you could use in Parse later on
  70505. * @returns the serialized JSON representation
  70506. */
  70507. serialize(): any;
  70508. }
  70509. }
  70510. declare module "babylonjs/Materials/Textures/index" {
  70511. export * from "babylonjs/Materials/Textures/baseTexture";
  70512. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  70513. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  70514. export * from "babylonjs/Materials/Textures/cubeTexture";
  70515. export * from "babylonjs/Materials/Textures/dynamicTexture";
  70516. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70517. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  70518. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  70519. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  70520. export * from "babylonjs/Materials/Textures/internalTexture";
  70521. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  70522. export * from "babylonjs/Materials/Textures/Loaders/index";
  70523. export * from "babylonjs/Materials/Textures/mirrorTexture";
  70524. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  70525. export * from "babylonjs/Materials/Textures/Packer/index";
  70526. export * from "babylonjs/Materials/Textures/Procedurals/index";
  70527. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  70528. export * from "babylonjs/Materials/Textures/rawTexture";
  70529. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  70530. export * from "babylonjs/Materials/Textures/rawTexture3D";
  70531. export * from "babylonjs/Materials/Textures/refractionTexture";
  70532. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  70533. export * from "babylonjs/Materials/Textures/texture";
  70534. export * from "babylonjs/Materials/Textures/videoTexture";
  70535. }
  70536. declare module "babylonjs/Materials/Node/Enums/index" {
  70537. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  70538. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  70539. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  70540. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  70541. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  70542. }
  70543. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  70544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70547. import { Mesh } from "babylonjs/Meshes/mesh";
  70548. import { Effect } from "babylonjs/Materials/effect";
  70549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70550. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70551. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70552. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70553. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70554. /**
  70555. * Block used to add support for vertex skinning (bones)
  70556. */
  70557. export class BonesBlock extends NodeMaterialBlock {
  70558. /**
  70559. * Creates a new BonesBlock
  70560. * @param name defines the block name
  70561. */
  70562. constructor(name: string);
  70563. /**
  70564. * Initialize the block and prepare the context for build
  70565. * @param state defines the state that will be used for the build
  70566. */
  70567. initialize(state: NodeMaterialBuildState): void;
  70568. /**
  70569. * Gets the current class name
  70570. * @returns the class name
  70571. */
  70572. getClassName(): string;
  70573. /**
  70574. * Gets the matrix indices input component
  70575. */
  70576. get matricesIndices(): NodeMaterialConnectionPoint;
  70577. /**
  70578. * Gets the matrix weights input component
  70579. */
  70580. get matricesWeights(): NodeMaterialConnectionPoint;
  70581. /**
  70582. * Gets the extra matrix indices input component
  70583. */
  70584. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  70585. /**
  70586. * Gets the extra matrix weights input component
  70587. */
  70588. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  70589. /**
  70590. * Gets the world input component
  70591. */
  70592. get world(): NodeMaterialConnectionPoint;
  70593. /**
  70594. * Gets the output component
  70595. */
  70596. get output(): NodeMaterialConnectionPoint;
  70597. autoConfigure(material: NodeMaterial): void;
  70598. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  70599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70601. protected _buildBlock(state: NodeMaterialBuildState): this;
  70602. }
  70603. }
  70604. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  70605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70609. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70610. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70611. /**
  70612. * Block used to add support for instances
  70613. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  70614. */
  70615. export class InstancesBlock extends NodeMaterialBlock {
  70616. /**
  70617. * Creates a new InstancesBlock
  70618. * @param name defines the block name
  70619. */
  70620. constructor(name: string);
  70621. /**
  70622. * Gets the current class name
  70623. * @returns the class name
  70624. */
  70625. getClassName(): string;
  70626. /**
  70627. * Gets the first world row input component
  70628. */
  70629. get world0(): NodeMaterialConnectionPoint;
  70630. /**
  70631. * Gets the second world row input component
  70632. */
  70633. get world1(): NodeMaterialConnectionPoint;
  70634. /**
  70635. * Gets the third world row input component
  70636. */
  70637. get world2(): NodeMaterialConnectionPoint;
  70638. /**
  70639. * Gets the forth world row input component
  70640. */
  70641. get world3(): NodeMaterialConnectionPoint;
  70642. /**
  70643. * Gets the world input component
  70644. */
  70645. get world(): NodeMaterialConnectionPoint;
  70646. /**
  70647. * Gets the output component
  70648. */
  70649. get output(): NodeMaterialConnectionPoint;
  70650. /**
  70651. * Gets the instanceID component
  70652. */
  70653. get instanceID(): NodeMaterialConnectionPoint;
  70654. autoConfigure(material: NodeMaterial): void;
  70655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  70656. protected _buildBlock(state: NodeMaterialBuildState): this;
  70657. }
  70658. }
  70659. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  70660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70664. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70665. import { Effect } from "babylonjs/Materials/effect";
  70666. import { Mesh } from "babylonjs/Meshes/mesh";
  70667. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70668. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70669. /**
  70670. * Block used to add morph targets support to vertex shader
  70671. */
  70672. export class MorphTargetsBlock extends NodeMaterialBlock {
  70673. private _repeatableContentAnchor;
  70674. /**
  70675. * Create a new MorphTargetsBlock
  70676. * @param name defines the block name
  70677. */
  70678. constructor(name: string);
  70679. /**
  70680. * Gets the current class name
  70681. * @returns the class name
  70682. */
  70683. getClassName(): string;
  70684. /**
  70685. * Gets the position input component
  70686. */
  70687. get position(): NodeMaterialConnectionPoint;
  70688. /**
  70689. * Gets the normal input component
  70690. */
  70691. get normal(): NodeMaterialConnectionPoint;
  70692. /**
  70693. * Gets the tangent input component
  70694. */
  70695. get tangent(): NodeMaterialConnectionPoint;
  70696. /**
  70697. * Gets the tangent input component
  70698. */
  70699. get uv(): NodeMaterialConnectionPoint;
  70700. /**
  70701. * Gets the position output component
  70702. */
  70703. get positionOutput(): NodeMaterialConnectionPoint;
  70704. /**
  70705. * Gets the normal output component
  70706. */
  70707. get normalOutput(): NodeMaterialConnectionPoint;
  70708. /**
  70709. * Gets the tangent output component
  70710. */
  70711. get tangentOutput(): NodeMaterialConnectionPoint;
  70712. /**
  70713. * Gets the tangent output component
  70714. */
  70715. get uvOutput(): NodeMaterialConnectionPoint;
  70716. initialize(state: NodeMaterialBuildState): void;
  70717. autoConfigure(material: NodeMaterial): void;
  70718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70720. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  70721. protected _buildBlock(state: NodeMaterialBuildState): this;
  70722. }
  70723. }
  70724. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  70725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70728. import { Nullable } from "babylonjs/types";
  70729. import { Scene } from "babylonjs/scene";
  70730. import { Effect } from "babylonjs/Materials/effect";
  70731. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70732. import { Mesh } from "babylonjs/Meshes/mesh";
  70733. import { Light } from "babylonjs/Lights/light";
  70734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70735. /**
  70736. * Block used to get data information from a light
  70737. */
  70738. export class LightInformationBlock extends NodeMaterialBlock {
  70739. private _lightDataUniformName;
  70740. private _lightColorUniformName;
  70741. private _lightTypeDefineName;
  70742. /**
  70743. * Gets or sets the light associated with this block
  70744. */
  70745. light: Nullable<Light>;
  70746. /**
  70747. * Creates a new LightInformationBlock
  70748. * @param name defines the block name
  70749. */
  70750. constructor(name: string);
  70751. /**
  70752. * Gets the current class name
  70753. * @returns the class name
  70754. */
  70755. getClassName(): string;
  70756. /**
  70757. * Gets the world position input component
  70758. */
  70759. get worldPosition(): NodeMaterialConnectionPoint;
  70760. /**
  70761. * Gets the direction output component
  70762. */
  70763. get direction(): NodeMaterialConnectionPoint;
  70764. /**
  70765. * Gets the direction output component
  70766. */
  70767. get color(): NodeMaterialConnectionPoint;
  70768. /**
  70769. * Gets the direction output component
  70770. */
  70771. get intensity(): NodeMaterialConnectionPoint;
  70772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70774. protected _buildBlock(state: NodeMaterialBuildState): this;
  70775. serialize(): any;
  70776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70777. }
  70778. }
  70779. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  70780. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  70781. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  70782. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  70783. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  70784. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  70785. }
  70786. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  70787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70791. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70792. import { Effect } from "babylonjs/Materials/effect";
  70793. import { Mesh } from "babylonjs/Meshes/mesh";
  70794. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70795. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70796. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70797. /**
  70798. * Block used to add image processing support to fragment shader
  70799. */
  70800. export class ImageProcessingBlock extends NodeMaterialBlock {
  70801. /**
  70802. * Create a new ImageProcessingBlock
  70803. * @param name defines the block name
  70804. */
  70805. constructor(name: string);
  70806. /**
  70807. * Gets the current class name
  70808. * @returns the class name
  70809. */
  70810. getClassName(): string;
  70811. /**
  70812. * Gets the color input component
  70813. */
  70814. get color(): NodeMaterialConnectionPoint;
  70815. /**
  70816. * Gets the output component
  70817. */
  70818. get output(): NodeMaterialConnectionPoint;
  70819. /**
  70820. * Initialize the block and prepare the context for build
  70821. * @param state defines the state that will be used for the build
  70822. */
  70823. initialize(state: NodeMaterialBuildState): void;
  70824. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  70825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70827. protected _buildBlock(state: NodeMaterialBuildState): this;
  70828. }
  70829. }
  70830. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  70831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70834. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70836. import { Effect } from "babylonjs/Materials/effect";
  70837. import { Mesh } from "babylonjs/Meshes/mesh";
  70838. import { Scene } from "babylonjs/scene";
  70839. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70840. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70841. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70842. /**
  70843. * Block used to perturb normals based on a normal map
  70844. */
  70845. export class PerturbNormalBlock extends NodeMaterialBlock {
  70846. private _tangentSpaceParameterName;
  70847. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  70848. invertX: boolean;
  70849. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  70850. invertY: boolean;
  70851. /**
  70852. * Create a new PerturbNormalBlock
  70853. * @param name defines the block name
  70854. */
  70855. constructor(name: string);
  70856. /**
  70857. * Gets the current class name
  70858. * @returns the class name
  70859. */
  70860. getClassName(): string;
  70861. /**
  70862. * Gets the world position input component
  70863. */
  70864. get worldPosition(): NodeMaterialConnectionPoint;
  70865. /**
  70866. * Gets the world normal input component
  70867. */
  70868. get worldNormal(): NodeMaterialConnectionPoint;
  70869. /**
  70870. * Gets the world tangent input component
  70871. */
  70872. get worldTangent(): NodeMaterialConnectionPoint;
  70873. /**
  70874. * Gets the uv input component
  70875. */
  70876. get uv(): NodeMaterialConnectionPoint;
  70877. /**
  70878. * Gets the normal map color input component
  70879. */
  70880. get normalMapColor(): NodeMaterialConnectionPoint;
  70881. /**
  70882. * Gets the strength input component
  70883. */
  70884. get strength(): NodeMaterialConnectionPoint;
  70885. /**
  70886. * Gets the output component
  70887. */
  70888. get output(): NodeMaterialConnectionPoint;
  70889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70890. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70891. autoConfigure(material: NodeMaterial): void;
  70892. protected _buildBlock(state: NodeMaterialBuildState): this;
  70893. protected _dumpPropertiesCode(): string;
  70894. serialize(): any;
  70895. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70896. }
  70897. }
  70898. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  70899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70902. /**
  70903. * Block used to discard a pixel if a value is smaller than a cutoff
  70904. */
  70905. export class DiscardBlock extends NodeMaterialBlock {
  70906. /**
  70907. * Create a new DiscardBlock
  70908. * @param name defines the block name
  70909. */
  70910. constructor(name: string);
  70911. /**
  70912. * Gets the current class name
  70913. * @returns the class name
  70914. */
  70915. getClassName(): string;
  70916. /**
  70917. * Gets the color input component
  70918. */
  70919. get value(): NodeMaterialConnectionPoint;
  70920. /**
  70921. * Gets the cutoff input component
  70922. */
  70923. get cutoff(): NodeMaterialConnectionPoint;
  70924. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70925. }
  70926. }
  70927. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  70928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70931. /**
  70932. * Block used to test if the fragment shader is front facing
  70933. */
  70934. export class FrontFacingBlock extends NodeMaterialBlock {
  70935. /**
  70936. * Creates a new FrontFacingBlock
  70937. * @param name defines the block name
  70938. */
  70939. constructor(name: string);
  70940. /**
  70941. * Gets the current class name
  70942. * @returns the class name
  70943. */
  70944. getClassName(): string;
  70945. /**
  70946. * Gets the output component
  70947. */
  70948. get output(): NodeMaterialConnectionPoint;
  70949. protected _buildBlock(state: NodeMaterialBuildState): this;
  70950. }
  70951. }
  70952. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  70953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70956. /**
  70957. * Block used to get the derivative value on x and y of a given input
  70958. */
  70959. export class DerivativeBlock extends NodeMaterialBlock {
  70960. /**
  70961. * Create a new DerivativeBlock
  70962. * @param name defines the block name
  70963. */
  70964. constructor(name: string);
  70965. /**
  70966. * Gets the current class name
  70967. * @returns the class name
  70968. */
  70969. getClassName(): string;
  70970. /**
  70971. * Gets the input component
  70972. */
  70973. get input(): NodeMaterialConnectionPoint;
  70974. /**
  70975. * Gets the derivative output on x
  70976. */
  70977. get dx(): NodeMaterialConnectionPoint;
  70978. /**
  70979. * Gets the derivative output on y
  70980. */
  70981. get dy(): NodeMaterialConnectionPoint;
  70982. protected _buildBlock(state: NodeMaterialBuildState): this;
  70983. }
  70984. }
  70985. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  70986. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70987. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70988. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70989. /**
  70990. * Block used to make gl_FragCoord available
  70991. */
  70992. export class FragCoordBlock extends NodeMaterialBlock {
  70993. /**
  70994. * Creates a new FragCoordBlock
  70995. * @param name defines the block name
  70996. */
  70997. constructor(name: string);
  70998. /**
  70999. * Gets the current class name
  71000. * @returns the class name
  71001. */
  71002. getClassName(): string;
  71003. /**
  71004. * Gets the xy component
  71005. */
  71006. get xy(): NodeMaterialConnectionPoint;
  71007. /**
  71008. * Gets the xyz component
  71009. */
  71010. get xyz(): NodeMaterialConnectionPoint;
  71011. /**
  71012. * Gets the xyzw component
  71013. */
  71014. get xyzw(): NodeMaterialConnectionPoint;
  71015. /**
  71016. * Gets the x component
  71017. */
  71018. get x(): NodeMaterialConnectionPoint;
  71019. /**
  71020. * Gets the y component
  71021. */
  71022. get y(): NodeMaterialConnectionPoint;
  71023. /**
  71024. * Gets the z component
  71025. */
  71026. get z(): NodeMaterialConnectionPoint;
  71027. /**
  71028. * Gets the w component
  71029. */
  71030. get output(): NodeMaterialConnectionPoint;
  71031. protected writeOutputs(state: NodeMaterialBuildState): string;
  71032. protected _buildBlock(state: NodeMaterialBuildState): this;
  71033. }
  71034. }
  71035. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  71036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71039. import { Effect } from "babylonjs/Materials/effect";
  71040. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71041. import { Mesh } from "babylonjs/Meshes/mesh";
  71042. /**
  71043. * Block used to get the screen sizes
  71044. */
  71045. export class ScreenSizeBlock extends NodeMaterialBlock {
  71046. private _varName;
  71047. private _scene;
  71048. /**
  71049. * Creates a new ScreenSizeBlock
  71050. * @param name defines the block name
  71051. */
  71052. constructor(name: string);
  71053. /**
  71054. * Gets the current class name
  71055. * @returns the class name
  71056. */
  71057. getClassName(): string;
  71058. /**
  71059. * Gets the xy component
  71060. */
  71061. get xy(): NodeMaterialConnectionPoint;
  71062. /**
  71063. * Gets the x component
  71064. */
  71065. get x(): NodeMaterialConnectionPoint;
  71066. /**
  71067. * Gets the y component
  71068. */
  71069. get y(): NodeMaterialConnectionPoint;
  71070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  71071. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  71072. protected _buildBlock(state: NodeMaterialBuildState): this;
  71073. }
  71074. }
  71075. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  71076. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  71077. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  71078. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  71079. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  71080. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  71081. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  71082. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  71083. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  71084. }
  71085. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  71086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71088. import { Mesh } from "babylonjs/Meshes/mesh";
  71089. import { Effect } from "babylonjs/Materials/effect";
  71090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71092. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  71093. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  71094. /**
  71095. * Block used to add support for scene fog
  71096. */
  71097. export class FogBlock extends NodeMaterialBlock {
  71098. private _fogDistanceName;
  71099. private _fogParameters;
  71100. /**
  71101. * Create a new FogBlock
  71102. * @param name defines the block name
  71103. */
  71104. constructor(name: string);
  71105. /**
  71106. * Gets the current class name
  71107. * @returns the class name
  71108. */
  71109. getClassName(): string;
  71110. /**
  71111. * Gets the world position input component
  71112. */
  71113. get worldPosition(): NodeMaterialConnectionPoint;
  71114. /**
  71115. * Gets the view input component
  71116. */
  71117. get view(): NodeMaterialConnectionPoint;
  71118. /**
  71119. * Gets the color input component
  71120. */
  71121. get input(): NodeMaterialConnectionPoint;
  71122. /**
  71123. * Gets the fog color input component
  71124. */
  71125. get fogColor(): NodeMaterialConnectionPoint;
  71126. /**
  71127. * Gets the output component
  71128. */
  71129. get output(): NodeMaterialConnectionPoint;
  71130. autoConfigure(material: NodeMaterial): void;
  71131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  71132. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  71133. protected _buildBlock(state: NodeMaterialBuildState): this;
  71134. }
  71135. }
  71136. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  71137. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71138. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71141. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  71142. import { Effect } from "babylonjs/Materials/effect";
  71143. import { Mesh } from "babylonjs/Meshes/mesh";
  71144. import { Light } from "babylonjs/Lights/light";
  71145. import { Nullable } from "babylonjs/types";
  71146. import { Scene } from "babylonjs/scene";
  71147. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  71148. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  71149. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  71150. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  71151. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  71152. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71153. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  71154. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  71155. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  71156. /**
  71157. * Block used to add light in the fragment shader
  71158. */
  71159. export class LightBlock extends NodeMaterialBlock {
  71160. private _lightId;
  71161. /**
  71162. * Gets or sets the light associated with this block
  71163. */
  71164. light: Nullable<Light>;
  71165. /**
  71166. * Create a new LightBlock
  71167. * @param name defines the block name
  71168. */
  71169. constructor(name: string);
  71170. /**
  71171. * Gets the current class name
  71172. * @returns the class name
  71173. */
  71174. getClassName(): string;
  71175. /**
  71176. * Gets the world position input component
  71177. */
  71178. get worldPosition(): NodeMaterialConnectionPoint;
  71179. /**
  71180. * Gets the world normal input component
  71181. */
  71182. get worldNormal(): NodeMaterialConnectionPoint;
  71183. /**
  71184. * Gets the camera (or eye) position component
  71185. */
  71186. get cameraPosition(): NodeMaterialConnectionPoint;
  71187. /**
  71188. * Gets the glossiness component
  71189. */
  71190. get glossiness(): NodeMaterialConnectionPoint;
  71191. /**
  71192. * Gets the glossiness power component
  71193. */
  71194. get glossPower(): NodeMaterialConnectionPoint;
  71195. /**
  71196. * Gets the diffuse color component
  71197. */
  71198. get diffuseColor(): NodeMaterialConnectionPoint;
  71199. /**
  71200. * Gets the specular color component
  71201. */
  71202. get specularColor(): NodeMaterialConnectionPoint;
  71203. /**
  71204. * Gets the view matrix component
  71205. */
  71206. get view(): NodeMaterialConnectionPoint;
  71207. /**
  71208. * Gets the diffuse output component
  71209. */
  71210. get diffuseOutput(): NodeMaterialConnectionPoint;
  71211. /**
  71212. * Gets the specular output component
  71213. */
  71214. get specularOutput(): NodeMaterialConnectionPoint;
  71215. /**
  71216. * Gets the shadow output component
  71217. */
  71218. get shadow(): NodeMaterialConnectionPoint;
  71219. autoConfigure(material: NodeMaterial): void;
  71220. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  71221. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  71222. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  71223. private _injectVertexCode;
  71224. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71225. serialize(): any;
  71226. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71227. }
  71228. }
  71229. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  71230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71232. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71233. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  71234. /**
  71235. * Block used to read a reflection texture from a sampler
  71236. */
  71237. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  71238. /**
  71239. * Create a new ReflectionTextureBlock
  71240. * @param name defines the block name
  71241. */
  71242. constructor(name: string);
  71243. /**
  71244. * Gets the current class name
  71245. * @returns the class name
  71246. */
  71247. getClassName(): string;
  71248. /**
  71249. * Gets the world position input component
  71250. */
  71251. get position(): NodeMaterialConnectionPoint;
  71252. /**
  71253. * Gets the world position input component
  71254. */
  71255. get worldPosition(): NodeMaterialConnectionPoint;
  71256. /**
  71257. * Gets the world normal input component
  71258. */
  71259. get worldNormal(): NodeMaterialConnectionPoint;
  71260. /**
  71261. * Gets the world input component
  71262. */
  71263. get world(): NodeMaterialConnectionPoint;
  71264. /**
  71265. * Gets the camera (or eye) position component
  71266. */
  71267. get cameraPosition(): NodeMaterialConnectionPoint;
  71268. /**
  71269. * Gets the view input component
  71270. */
  71271. get view(): NodeMaterialConnectionPoint;
  71272. /**
  71273. * Gets the rgb output component
  71274. */
  71275. get rgb(): NodeMaterialConnectionPoint;
  71276. /**
  71277. * Gets the rgba output component
  71278. */
  71279. get rgba(): NodeMaterialConnectionPoint;
  71280. /**
  71281. * Gets the r output component
  71282. */
  71283. get r(): NodeMaterialConnectionPoint;
  71284. /**
  71285. * Gets the g output component
  71286. */
  71287. get g(): NodeMaterialConnectionPoint;
  71288. /**
  71289. * Gets the b output component
  71290. */
  71291. get b(): NodeMaterialConnectionPoint;
  71292. /**
  71293. * Gets the a output component
  71294. */
  71295. get a(): NodeMaterialConnectionPoint;
  71296. autoConfigure(material: NodeMaterial): void;
  71297. protected _buildBlock(state: NodeMaterialBuildState): this;
  71298. }
  71299. }
  71300. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  71301. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  71302. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  71303. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  71304. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  71305. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  71306. }
  71307. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  71308. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  71309. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  71310. }
  71311. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  71312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71315. /**
  71316. * Block used to add 2 vectors
  71317. */
  71318. export class AddBlock extends NodeMaterialBlock {
  71319. /**
  71320. * Creates a new AddBlock
  71321. * @param name defines the block name
  71322. */
  71323. constructor(name: string);
  71324. /**
  71325. * Gets the current class name
  71326. * @returns the class name
  71327. */
  71328. getClassName(): string;
  71329. /**
  71330. * Gets the left operand input component
  71331. */
  71332. get left(): NodeMaterialConnectionPoint;
  71333. /**
  71334. * Gets the right operand input component
  71335. */
  71336. get right(): NodeMaterialConnectionPoint;
  71337. /**
  71338. * Gets the output component
  71339. */
  71340. get output(): NodeMaterialConnectionPoint;
  71341. protected _buildBlock(state: NodeMaterialBuildState): this;
  71342. }
  71343. }
  71344. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  71345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71348. /**
  71349. * Block used to scale a vector by a float
  71350. */
  71351. export class ScaleBlock extends NodeMaterialBlock {
  71352. /**
  71353. * Creates a new ScaleBlock
  71354. * @param name defines the block name
  71355. */
  71356. constructor(name: string);
  71357. /**
  71358. * Gets the current class name
  71359. * @returns the class name
  71360. */
  71361. getClassName(): string;
  71362. /**
  71363. * Gets the input component
  71364. */
  71365. get input(): NodeMaterialConnectionPoint;
  71366. /**
  71367. * Gets the factor input component
  71368. */
  71369. get factor(): NodeMaterialConnectionPoint;
  71370. /**
  71371. * Gets the output component
  71372. */
  71373. get output(): NodeMaterialConnectionPoint;
  71374. protected _buildBlock(state: NodeMaterialBuildState): this;
  71375. }
  71376. }
  71377. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  71378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71381. import { Scene } from "babylonjs/scene";
  71382. /**
  71383. * Block used to clamp a float
  71384. */
  71385. export class ClampBlock extends NodeMaterialBlock {
  71386. /** Gets or sets the minimum range */
  71387. minimum: number;
  71388. /** Gets or sets the maximum range */
  71389. maximum: number;
  71390. /**
  71391. * Creates a new ClampBlock
  71392. * @param name defines the block name
  71393. */
  71394. constructor(name: string);
  71395. /**
  71396. * Gets the current class name
  71397. * @returns the class name
  71398. */
  71399. getClassName(): string;
  71400. /**
  71401. * Gets the value input component
  71402. */
  71403. get value(): NodeMaterialConnectionPoint;
  71404. /**
  71405. * Gets the output component
  71406. */
  71407. get output(): NodeMaterialConnectionPoint;
  71408. protected _buildBlock(state: NodeMaterialBuildState): this;
  71409. protected _dumpPropertiesCode(): string;
  71410. serialize(): any;
  71411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71412. }
  71413. }
  71414. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  71415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71418. /**
  71419. * Block used to apply a cross product between 2 vectors
  71420. */
  71421. export class CrossBlock extends NodeMaterialBlock {
  71422. /**
  71423. * Creates a new CrossBlock
  71424. * @param name defines the block name
  71425. */
  71426. constructor(name: string);
  71427. /**
  71428. * Gets the current class name
  71429. * @returns the class name
  71430. */
  71431. getClassName(): string;
  71432. /**
  71433. * Gets the left operand input component
  71434. */
  71435. get left(): NodeMaterialConnectionPoint;
  71436. /**
  71437. * Gets the right operand input component
  71438. */
  71439. get right(): NodeMaterialConnectionPoint;
  71440. /**
  71441. * Gets the output component
  71442. */
  71443. get output(): NodeMaterialConnectionPoint;
  71444. protected _buildBlock(state: NodeMaterialBuildState): this;
  71445. }
  71446. }
  71447. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  71448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71451. /**
  71452. * Block used to apply a dot product between 2 vectors
  71453. */
  71454. export class DotBlock extends NodeMaterialBlock {
  71455. /**
  71456. * Creates a new DotBlock
  71457. * @param name defines the block name
  71458. */
  71459. constructor(name: string);
  71460. /**
  71461. * Gets the current class name
  71462. * @returns the class name
  71463. */
  71464. getClassName(): string;
  71465. /**
  71466. * Gets the left operand input component
  71467. */
  71468. get left(): NodeMaterialConnectionPoint;
  71469. /**
  71470. * Gets the right operand input component
  71471. */
  71472. get right(): NodeMaterialConnectionPoint;
  71473. /**
  71474. * Gets the output component
  71475. */
  71476. get output(): NodeMaterialConnectionPoint;
  71477. protected _buildBlock(state: NodeMaterialBuildState): this;
  71478. }
  71479. }
  71480. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  71481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71484. /**
  71485. * Block used to normalize a vector
  71486. */
  71487. export class NormalizeBlock extends NodeMaterialBlock {
  71488. /**
  71489. * Creates a new NormalizeBlock
  71490. * @param name defines the block name
  71491. */
  71492. constructor(name: string);
  71493. /**
  71494. * Gets the current class name
  71495. * @returns the class name
  71496. */
  71497. getClassName(): string;
  71498. /**
  71499. * Gets the input component
  71500. */
  71501. get input(): NodeMaterialConnectionPoint;
  71502. /**
  71503. * Gets the output component
  71504. */
  71505. get output(): NodeMaterialConnectionPoint;
  71506. protected _buildBlock(state: NodeMaterialBuildState): this;
  71507. }
  71508. }
  71509. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  71510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71513. /**
  71514. * Block used to create a Color3/4 out of individual inputs (one for each component)
  71515. */
  71516. export class ColorMergerBlock extends NodeMaterialBlock {
  71517. /**
  71518. * Create a new ColorMergerBlock
  71519. * @param name defines the block name
  71520. */
  71521. constructor(name: string);
  71522. /**
  71523. * Gets the current class name
  71524. * @returns the class name
  71525. */
  71526. getClassName(): string;
  71527. /**
  71528. * Gets the rgb component (input)
  71529. */
  71530. get rgbIn(): NodeMaterialConnectionPoint;
  71531. /**
  71532. * Gets the r component (input)
  71533. */
  71534. get r(): NodeMaterialConnectionPoint;
  71535. /**
  71536. * Gets the g component (input)
  71537. */
  71538. get g(): NodeMaterialConnectionPoint;
  71539. /**
  71540. * Gets the b component (input)
  71541. */
  71542. get b(): NodeMaterialConnectionPoint;
  71543. /**
  71544. * Gets the a component (input)
  71545. */
  71546. get a(): NodeMaterialConnectionPoint;
  71547. /**
  71548. * Gets the rgba component (output)
  71549. */
  71550. get rgba(): NodeMaterialConnectionPoint;
  71551. /**
  71552. * Gets the rgb component (output)
  71553. */
  71554. get rgbOut(): NodeMaterialConnectionPoint;
  71555. /**
  71556. * Gets the rgb component (output)
  71557. * @deprecated Please use rgbOut instead.
  71558. */
  71559. get rgb(): NodeMaterialConnectionPoint;
  71560. protected _buildBlock(state: NodeMaterialBuildState): this;
  71561. }
  71562. }
  71563. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  71564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71567. /**
  71568. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  71569. */
  71570. export class VectorSplitterBlock extends NodeMaterialBlock {
  71571. /**
  71572. * Create a new VectorSplitterBlock
  71573. * @param name defines the block name
  71574. */
  71575. constructor(name: string);
  71576. /**
  71577. * Gets the current class name
  71578. * @returns the class name
  71579. */
  71580. getClassName(): string;
  71581. /**
  71582. * Gets the xyzw component (input)
  71583. */
  71584. get xyzw(): NodeMaterialConnectionPoint;
  71585. /**
  71586. * Gets the xyz component (input)
  71587. */
  71588. get xyzIn(): NodeMaterialConnectionPoint;
  71589. /**
  71590. * Gets the xy component (input)
  71591. */
  71592. get xyIn(): NodeMaterialConnectionPoint;
  71593. /**
  71594. * Gets the xyz component (output)
  71595. */
  71596. get xyzOut(): NodeMaterialConnectionPoint;
  71597. /**
  71598. * Gets the xy component (output)
  71599. */
  71600. get xyOut(): NodeMaterialConnectionPoint;
  71601. /**
  71602. * Gets the x component (output)
  71603. */
  71604. get x(): NodeMaterialConnectionPoint;
  71605. /**
  71606. * Gets the y component (output)
  71607. */
  71608. get y(): NodeMaterialConnectionPoint;
  71609. /**
  71610. * Gets the z component (output)
  71611. */
  71612. get z(): NodeMaterialConnectionPoint;
  71613. /**
  71614. * Gets the w component (output)
  71615. */
  71616. get w(): NodeMaterialConnectionPoint;
  71617. protected _inputRename(name: string): string;
  71618. protected _outputRename(name: string): string;
  71619. protected _buildBlock(state: NodeMaterialBuildState): this;
  71620. }
  71621. }
  71622. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  71623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71626. /**
  71627. * Block used to lerp between 2 values
  71628. */
  71629. export class LerpBlock extends NodeMaterialBlock {
  71630. /**
  71631. * Creates a new LerpBlock
  71632. * @param name defines the block name
  71633. */
  71634. constructor(name: string);
  71635. /**
  71636. * Gets the current class name
  71637. * @returns the class name
  71638. */
  71639. getClassName(): string;
  71640. /**
  71641. * Gets the left operand input component
  71642. */
  71643. get left(): NodeMaterialConnectionPoint;
  71644. /**
  71645. * Gets the right operand input component
  71646. */
  71647. get right(): NodeMaterialConnectionPoint;
  71648. /**
  71649. * Gets the gradient operand input component
  71650. */
  71651. get gradient(): NodeMaterialConnectionPoint;
  71652. /**
  71653. * Gets the output component
  71654. */
  71655. get output(): NodeMaterialConnectionPoint;
  71656. protected _buildBlock(state: NodeMaterialBuildState): this;
  71657. }
  71658. }
  71659. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  71660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71663. /**
  71664. * Block used to divide 2 vectors
  71665. */
  71666. export class DivideBlock extends NodeMaterialBlock {
  71667. /**
  71668. * Creates a new DivideBlock
  71669. * @param name defines the block name
  71670. */
  71671. constructor(name: string);
  71672. /**
  71673. * Gets the current class name
  71674. * @returns the class name
  71675. */
  71676. getClassName(): string;
  71677. /**
  71678. * Gets the left operand input component
  71679. */
  71680. get left(): NodeMaterialConnectionPoint;
  71681. /**
  71682. * Gets the right operand input component
  71683. */
  71684. get right(): NodeMaterialConnectionPoint;
  71685. /**
  71686. * Gets the output component
  71687. */
  71688. get output(): NodeMaterialConnectionPoint;
  71689. protected _buildBlock(state: NodeMaterialBuildState): this;
  71690. }
  71691. }
  71692. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  71693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71696. /**
  71697. * Block used to subtract 2 vectors
  71698. */
  71699. export class SubtractBlock extends NodeMaterialBlock {
  71700. /**
  71701. * Creates a new SubtractBlock
  71702. * @param name defines the block name
  71703. */
  71704. constructor(name: string);
  71705. /**
  71706. * Gets the current class name
  71707. * @returns the class name
  71708. */
  71709. getClassName(): string;
  71710. /**
  71711. * Gets the left operand input component
  71712. */
  71713. get left(): NodeMaterialConnectionPoint;
  71714. /**
  71715. * Gets the right operand input component
  71716. */
  71717. get right(): NodeMaterialConnectionPoint;
  71718. /**
  71719. * Gets the output component
  71720. */
  71721. get output(): NodeMaterialConnectionPoint;
  71722. protected _buildBlock(state: NodeMaterialBuildState): this;
  71723. }
  71724. }
  71725. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  71726. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71728. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71729. /**
  71730. * Block used to step a value
  71731. */
  71732. export class StepBlock extends NodeMaterialBlock {
  71733. /**
  71734. * Creates a new StepBlock
  71735. * @param name defines the block name
  71736. */
  71737. constructor(name: string);
  71738. /**
  71739. * Gets the current class name
  71740. * @returns the class name
  71741. */
  71742. getClassName(): string;
  71743. /**
  71744. * Gets the value operand input component
  71745. */
  71746. get value(): NodeMaterialConnectionPoint;
  71747. /**
  71748. * Gets the edge operand input component
  71749. */
  71750. get edge(): NodeMaterialConnectionPoint;
  71751. /**
  71752. * Gets the output component
  71753. */
  71754. get output(): NodeMaterialConnectionPoint;
  71755. protected _buildBlock(state: NodeMaterialBuildState): this;
  71756. }
  71757. }
  71758. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  71759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71762. /**
  71763. * Block used to get the opposite (1 - x) of a value
  71764. */
  71765. export class OneMinusBlock extends NodeMaterialBlock {
  71766. /**
  71767. * Creates a new OneMinusBlock
  71768. * @param name defines the block name
  71769. */
  71770. constructor(name: string);
  71771. /**
  71772. * Gets the current class name
  71773. * @returns the class name
  71774. */
  71775. getClassName(): string;
  71776. /**
  71777. * Gets the input component
  71778. */
  71779. get input(): NodeMaterialConnectionPoint;
  71780. /**
  71781. * Gets the output component
  71782. */
  71783. get output(): NodeMaterialConnectionPoint;
  71784. protected _buildBlock(state: NodeMaterialBuildState): this;
  71785. }
  71786. }
  71787. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  71788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71791. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71792. /**
  71793. * Block used to get the view direction
  71794. */
  71795. export class ViewDirectionBlock extends NodeMaterialBlock {
  71796. /**
  71797. * Creates a new ViewDirectionBlock
  71798. * @param name defines the block name
  71799. */
  71800. constructor(name: string);
  71801. /**
  71802. * Gets the current class name
  71803. * @returns the class name
  71804. */
  71805. getClassName(): string;
  71806. /**
  71807. * Gets the world position component
  71808. */
  71809. get worldPosition(): NodeMaterialConnectionPoint;
  71810. /**
  71811. * Gets the camera position component
  71812. */
  71813. get cameraPosition(): NodeMaterialConnectionPoint;
  71814. /**
  71815. * Gets the output component
  71816. */
  71817. get output(): NodeMaterialConnectionPoint;
  71818. autoConfigure(material: NodeMaterial): void;
  71819. protected _buildBlock(state: NodeMaterialBuildState): this;
  71820. }
  71821. }
  71822. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  71823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71826. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71827. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  71828. /**
  71829. * Block used to compute fresnel value
  71830. */
  71831. export class FresnelBlock extends NodeMaterialBlock {
  71832. /**
  71833. * Create a new FresnelBlock
  71834. * @param name defines the block name
  71835. */
  71836. constructor(name: string);
  71837. /**
  71838. * Gets the current class name
  71839. * @returns the class name
  71840. */
  71841. getClassName(): string;
  71842. /**
  71843. * Gets the world normal input component
  71844. */
  71845. get worldNormal(): NodeMaterialConnectionPoint;
  71846. /**
  71847. * Gets the view direction input component
  71848. */
  71849. get viewDirection(): NodeMaterialConnectionPoint;
  71850. /**
  71851. * Gets the bias input component
  71852. */
  71853. get bias(): NodeMaterialConnectionPoint;
  71854. /**
  71855. * Gets the camera (or eye) position component
  71856. */
  71857. get power(): NodeMaterialConnectionPoint;
  71858. /**
  71859. * Gets the fresnel output component
  71860. */
  71861. get fresnel(): NodeMaterialConnectionPoint;
  71862. autoConfigure(material: NodeMaterial): void;
  71863. protected _buildBlock(state: NodeMaterialBuildState): this;
  71864. }
  71865. }
  71866. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  71867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71870. /**
  71871. * Block used to get the max of 2 values
  71872. */
  71873. export class MaxBlock extends NodeMaterialBlock {
  71874. /**
  71875. * Creates a new MaxBlock
  71876. * @param name defines the block name
  71877. */
  71878. constructor(name: string);
  71879. /**
  71880. * Gets the current class name
  71881. * @returns the class name
  71882. */
  71883. getClassName(): string;
  71884. /**
  71885. * Gets the left operand input component
  71886. */
  71887. get left(): NodeMaterialConnectionPoint;
  71888. /**
  71889. * Gets the right operand input component
  71890. */
  71891. get right(): NodeMaterialConnectionPoint;
  71892. /**
  71893. * Gets the output component
  71894. */
  71895. get output(): NodeMaterialConnectionPoint;
  71896. protected _buildBlock(state: NodeMaterialBuildState): this;
  71897. }
  71898. }
  71899. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  71900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71903. /**
  71904. * Block used to get the min of 2 values
  71905. */
  71906. export class MinBlock extends NodeMaterialBlock {
  71907. /**
  71908. * Creates a new MinBlock
  71909. * @param name defines the block name
  71910. */
  71911. constructor(name: string);
  71912. /**
  71913. * Gets the current class name
  71914. * @returns the class name
  71915. */
  71916. getClassName(): string;
  71917. /**
  71918. * Gets the left operand input component
  71919. */
  71920. get left(): NodeMaterialConnectionPoint;
  71921. /**
  71922. * Gets the right operand input component
  71923. */
  71924. get right(): NodeMaterialConnectionPoint;
  71925. /**
  71926. * Gets the output component
  71927. */
  71928. get output(): NodeMaterialConnectionPoint;
  71929. protected _buildBlock(state: NodeMaterialBuildState): this;
  71930. }
  71931. }
  71932. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  71933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71936. /**
  71937. * Block used to get the distance between 2 values
  71938. */
  71939. export class DistanceBlock extends NodeMaterialBlock {
  71940. /**
  71941. * Creates a new DistanceBlock
  71942. * @param name defines the block name
  71943. */
  71944. constructor(name: string);
  71945. /**
  71946. * Gets the current class name
  71947. * @returns the class name
  71948. */
  71949. getClassName(): string;
  71950. /**
  71951. * Gets the left operand input component
  71952. */
  71953. get left(): NodeMaterialConnectionPoint;
  71954. /**
  71955. * Gets the right operand input component
  71956. */
  71957. get right(): NodeMaterialConnectionPoint;
  71958. /**
  71959. * Gets the output component
  71960. */
  71961. get output(): NodeMaterialConnectionPoint;
  71962. protected _buildBlock(state: NodeMaterialBuildState): this;
  71963. }
  71964. }
  71965. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  71966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71969. /**
  71970. * Block used to get the length of a vector
  71971. */
  71972. export class LengthBlock extends NodeMaterialBlock {
  71973. /**
  71974. * Creates a new LengthBlock
  71975. * @param name defines the block name
  71976. */
  71977. constructor(name: string);
  71978. /**
  71979. * Gets the current class name
  71980. * @returns the class name
  71981. */
  71982. getClassName(): string;
  71983. /**
  71984. * Gets the value input component
  71985. */
  71986. get value(): NodeMaterialConnectionPoint;
  71987. /**
  71988. * Gets the output component
  71989. */
  71990. get output(): NodeMaterialConnectionPoint;
  71991. protected _buildBlock(state: NodeMaterialBuildState): this;
  71992. }
  71993. }
  71994. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  71995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71998. /**
  71999. * Block used to get negative version of a value (i.e. x * -1)
  72000. */
  72001. export class NegateBlock extends NodeMaterialBlock {
  72002. /**
  72003. * Creates a new NegateBlock
  72004. * @param name defines the block name
  72005. */
  72006. constructor(name: string);
  72007. /**
  72008. * Gets the current class name
  72009. * @returns the class name
  72010. */
  72011. getClassName(): string;
  72012. /**
  72013. * Gets the value input component
  72014. */
  72015. get value(): NodeMaterialConnectionPoint;
  72016. /**
  72017. * Gets the output component
  72018. */
  72019. get output(): NodeMaterialConnectionPoint;
  72020. protected _buildBlock(state: NodeMaterialBuildState): this;
  72021. }
  72022. }
  72023. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  72024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72027. /**
  72028. * Block used to get the value of the first parameter raised to the power of the second
  72029. */
  72030. export class PowBlock extends NodeMaterialBlock {
  72031. /**
  72032. * Creates a new PowBlock
  72033. * @param name defines the block name
  72034. */
  72035. constructor(name: string);
  72036. /**
  72037. * Gets the current class name
  72038. * @returns the class name
  72039. */
  72040. getClassName(): string;
  72041. /**
  72042. * Gets the value operand input component
  72043. */
  72044. get value(): NodeMaterialConnectionPoint;
  72045. /**
  72046. * Gets the power operand input component
  72047. */
  72048. get power(): NodeMaterialConnectionPoint;
  72049. /**
  72050. * Gets the output component
  72051. */
  72052. get output(): NodeMaterialConnectionPoint;
  72053. protected _buildBlock(state: NodeMaterialBuildState): this;
  72054. }
  72055. }
  72056. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  72057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72060. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72061. /**
  72062. * Block used to get a random number
  72063. */
  72064. export class RandomNumberBlock extends NodeMaterialBlock {
  72065. /**
  72066. * Creates a new RandomNumberBlock
  72067. * @param name defines the block name
  72068. */
  72069. constructor(name: string);
  72070. /**
  72071. * Gets the current class name
  72072. * @returns the class name
  72073. */
  72074. getClassName(): string;
  72075. /**
  72076. * Gets the seed input component
  72077. */
  72078. get seed(): NodeMaterialConnectionPoint;
  72079. /**
  72080. * Gets the output component
  72081. */
  72082. get output(): NodeMaterialConnectionPoint;
  72083. protected _buildBlock(state: NodeMaterialBuildState): this;
  72084. }
  72085. }
  72086. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  72087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72090. /**
  72091. * Block used to compute arc tangent of 2 values
  72092. */
  72093. export class ArcTan2Block extends NodeMaterialBlock {
  72094. /**
  72095. * Creates a new ArcTan2Block
  72096. * @param name defines the block name
  72097. */
  72098. constructor(name: string);
  72099. /**
  72100. * Gets the current class name
  72101. * @returns the class name
  72102. */
  72103. getClassName(): string;
  72104. /**
  72105. * Gets the x operand input component
  72106. */
  72107. get x(): NodeMaterialConnectionPoint;
  72108. /**
  72109. * Gets the y operand input component
  72110. */
  72111. get y(): NodeMaterialConnectionPoint;
  72112. /**
  72113. * Gets the output component
  72114. */
  72115. get output(): NodeMaterialConnectionPoint;
  72116. protected _buildBlock(state: NodeMaterialBuildState): this;
  72117. }
  72118. }
  72119. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  72120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72123. /**
  72124. * Block used to smooth step a value
  72125. */
  72126. export class SmoothStepBlock extends NodeMaterialBlock {
  72127. /**
  72128. * Creates a new SmoothStepBlock
  72129. * @param name defines the block name
  72130. */
  72131. constructor(name: string);
  72132. /**
  72133. * Gets the current class name
  72134. * @returns the class name
  72135. */
  72136. getClassName(): string;
  72137. /**
  72138. * Gets the value operand input component
  72139. */
  72140. get value(): NodeMaterialConnectionPoint;
  72141. /**
  72142. * Gets the first edge operand input component
  72143. */
  72144. get edge0(): NodeMaterialConnectionPoint;
  72145. /**
  72146. * Gets the second edge operand input component
  72147. */
  72148. get edge1(): NodeMaterialConnectionPoint;
  72149. /**
  72150. * Gets the output component
  72151. */
  72152. get output(): NodeMaterialConnectionPoint;
  72153. protected _buildBlock(state: NodeMaterialBuildState): this;
  72154. }
  72155. }
  72156. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  72157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72160. /**
  72161. * Block used to get the reciprocal (1 / x) of a value
  72162. */
  72163. export class ReciprocalBlock extends NodeMaterialBlock {
  72164. /**
  72165. * Creates a new ReciprocalBlock
  72166. * @param name defines the block name
  72167. */
  72168. constructor(name: string);
  72169. /**
  72170. * Gets the current class name
  72171. * @returns the class name
  72172. */
  72173. getClassName(): string;
  72174. /**
  72175. * Gets the input component
  72176. */
  72177. get input(): NodeMaterialConnectionPoint;
  72178. /**
  72179. * Gets the output component
  72180. */
  72181. get output(): NodeMaterialConnectionPoint;
  72182. protected _buildBlock(state: NodeMaterialBuildState): this;
  72183. }
  72184. }
  72185. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  72186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72189. /**
  72190. * Block used to replace a color by another one
  72191. */
  72192. export class ReplaceColorBlock extends NodeMaterialBlock {
  72193. /**
  72194. * Creates a new ReplaceColorBlock
  72195. * @param name defines the block name
  72196. */
  72197. constructor(name: string);
  72198. /**
  72199. * Gets the current class name
  72200. * @returns the class name
  72201. */
  72202. getClassName(): string;
  72203. /**
  72204. * Gets the value input component
  72205. */
  72206. get value(): NodeMaterialConnectionPoint;
  72207. /**
  72208. * Gets the reference input component
  72209. */
  72210. get reference(): NodeMaterialConnectionPoint;
  72211. /**
  72212. * Gets the distance input component
  72213. */
  72214. get distance(): NodeMaterialConnectionPoint;
  72215. /**
  72216. * Gets the replacement input component
  72217. */
  72218. get replacement(): NodeMaterialConnectionPoint;
  72219. /**
  72220. * Gets the output component
  72221. */
  72222. get output(): NodeMaterialConnectionPoint;
  72223. protected _buildBlock(state: NodeMaterialBuildState): this;
  72224. }
  72225. }
  72226. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  72227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72230. /**
  72231. * Block used to posterize a value
  72232. * @see https://en.wikipedia.org/wiki/Posterization
  72233. */
  72234. export class PosterizeBlock extends NodeMaterialBlock {
  72235. /**
  72236. * Creates a new PosterizeBlock
  72237. * @param name defines the block name
  72238. */
  72239. constructor(name: string);
  72240. /**
  72241. * Gets the current class name
  72242. * @returns the class name
  72243. */
  72244. getClassName(): string;
  72245. /**
  72246. * Gets the value input component
  72247. */
  72248. get value(): NodeMaterialConnectionPoint;
  72249. /**
  72250. * Gets the steps input component
  72251. */
  72252. get steps(): NodeMaterialConnectionPoint;
  72253. /**
  72254. * Gets the output component
  72255. */
  72256. get output(): NodeMaterialConnectionPoint;
  72257. protected _buildBlock(state: NodeMaterialBuildState): this;
  72258. }
  72259. }
  72260. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  72261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72264. import { Scene } from "babylonjs/scene";
  72265. /**
  72266. * Operations supported by the Wave block
  72267. */
  72268. export enum WaveBlockKind {
  72269. /** SawTooth */
  72270. SawTooth = 0,
  72271. /** Square */
  72272. Square = 1,
  72273. /** Triangle */
  72274. Triangle = 2
  72275. }
  72276. /**
  72277. * Block used to apply wave operation to floats
  72278. */
  72279. export class WaveBlock extends NodeMaterialBlock {
  72280. /**
  72281. * Gets or sets the kibnd of wave to be applied by the block
  72282. */
  72283. kind: WaveBlockKind;
  72284. /**
  72285. * Creates a new WaveBlock
  72286. * @param name defines the block name
  72287. */
  72288. constructor(name: string);
  72289. /**
  72290. * Gets the current class name
  72291. * @returns the class name
  72292. */
  72293. getClassName(): string;
  72294. /**
  72295. * Gets the input component
  72296. */
  72297. get input(): NodeMaterialConnectionPoint;
  72298. /**
  72299. * Gets the output component
  72300. */
  72301. get output(): NodeMaterialConnectionPoint;
  72302. protected _buildBlock(state: NodeMaterialBuildState): this;
  72303. serialize(): any;
  72304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72305. }
  72306. }
  72307. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  72308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72311. import { Color3 } from "babylonjs/Maths/math.color";
  72312. import { Scene } from "babylonjs/scene";
  72313. import { Observable } from "babylonjs/Misc/observable";
  72314. /**
  72315. * Class used to store a color step for the GradientBlock
  72316. */
  72317. export class GradientBlockColorStep {
  72318. private _step;
  72319. /**
  72320. * Gets value indicating which step this color is associated with (between 0 and 1)
  72321. */
  72322. get step(): number;
  72323. /**
  72324. * Sets a value indicating which step this color is associated with (between 0 and 1)
  72325. */
  72326. set step(val: number);
  72327. private _color;
  72328. /**
  72329. * Gets the color associated with this step
  72330. */
  72331. get color(): Color3;
  72332. /**
  72333. * Sets the color associated with this step
  72334. */
  72335. set color(val: Color3);
  72336. /**
  72337. * Creates a new GradientBlockColorStep
  72338. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  72339. * @param color defines the color associated with this step
  72340. */
  72341. constructor(step: number, color: Color3);
  72342. }
  72343. /**
  72344. * Block used to return a color from a gradient based on an input value between 0 and 1
  72345. */
  72346. export class GradientBlock extends NodeMaterialBlock {
  72347. /**
  72348. * Gets or sets the list of color steps
  72349. */
  72350. colorSteps: GradientBlockColorStep[];
  72351. /** Gets an observable raised when the value is changed */
  72352. onValueChangedObservable: Observable<GradientBlock>;
  72353. /** calls observable when the value is changed*/
  72354. colorStepsUpdated(): void;
  72355. /**
  72356. * Creates a new GradientBlock
  72357. * @param name defines the block name
  72358. */
  72359. constructor(name: string);
  72360. /**
  72361. * Gets the current class name
  72362. * @returns the class name
  72363. */
  72364. getClassName(): string;
  72365. /**
  72366. * Gets the gradient input component
  72367. */
  72368. get gradient(): NodeMaterialConnectionPoint;
  72369. /**
  72370. * Gets the output component
  72371. */
  72372. get output(): NodeMaterialConnectionPoint;
  72373. private _writeColorConstant;
  72374. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  72375. serialize(): any;
  72376. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72377. protected _dumpPropertiesCode(): string;
  72378. }
  72379. }
  72380. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  72381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72384. /**
  72385. * Block used to normalize lerp between 2 values
  72386. */
  72387. export class NLerpBlock extends NodeMaterialBlock {
  72388. /**
  72389. * Creates a new NLerpBlock
  72390. * @param name defines the block name
  72391. */
  72392. constructor(name: string);
  72393. /**
  72394. * Gets the current class name
  72395. * @returns the class name
  72396. */
  72397. getClassName(): string;
  72398. /**
  72399. * Gets the left operand input component
  72400. */
  72401. get left(): NodeMaterialConnectionPoint;
  72402. /**
  72403. * Gets the right operand input component
  72404. */
  72405. get right(): NodeMaterialConnectionPoint;
  72406. /**
  72407. * Gets the gradient operand input component
  72408. */
  72409. get gradient(): NodeMaterialConnectionPoint;
  72410. /**
  72411. * Gets the output component
  72412. */
  72413. get output(): NodeMaterialConnectionPoint;
  72414. protected _buildBlock(state: NodeMaterialBuildState): this;
  72415. }
  72416. }
  72417. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  72418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72421. import { Scene } from "babylonjs/scene";
  72422. /**
  72423. * block used to Generate a Worley Noise 3D Noise Pattern
  72424. */
  72425. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  72426. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  72427. manhattanDistance: boolean;
  72428. /**
  72429. * Creates a new WorleyNoise3DBlock
  72430. * @param name defines the block name
  72431. */
  72432. constructor(name: string);
  72433. /**
  72434. * Gets the current class name
  72435. * @returns the class name
  72436. */
  72437. getClassName(): string;
  72438. /**
  72439. * Gets the seed input component
  72440. */
  72441. get seed(): NodeMaterialConnectionPoint;
  72442. /**
  72443. * Gets the jitter input component
  72444. */
  72445. get jitter(): NodeMaterialConnectionPoint;
  72446. /**
  72447. * Gets the output component
  72448. */
  72449. get output(): NodeMaterialConnectionPoint;
  72450. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  72451. /**
  72452. * Exposes the properties to the UI?
  72453. */
  72454. protected _dumpPropertiesCode(): string;
  72455. /**
  72456. * Exposes the properties to the Serialize?
  72457. */
  72458. serialize(): any;
  72459. /**
  72460. * Exposes the properties to the deserialize?
  72461. */
  72462. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72463. }
  72464. }
  72465. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  72466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72469. /**
  72470. * block used to Generate a Simplex Perlin 3d Noise Pattern
  72471. */
  72472. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  72473. /**
  72474. * Creates a new SimplexPerlin3DBlock
  72475. * @param name defines the block name
  72476. */
  72477. constructor(name: string);
  72478. /**
  72479. * Gets the current class name
  72480. * @returns the class name
  72481. */
  72482. getClassName(): string;
  72483. /**
  72484. * Gets the seed operand input component
  72485. */
  72486. get seed(): NodeMaterialConnectionPoint;
  72487. /**
  72488. * Gets the output component
  72489. */
  72490. get output(): NodeMaterialConnectionPoint;
  72491. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  72492. }
  72493. }
  72494. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  72495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72498. /**
  72499. * Block used to blend normals
  72500. */
  72501. export class NormalBlendBlock extends NodeMaterialBlock {
  72502. /**
  72503. * Creates a new NormalBlendBlock
  72504. * @param name defines the block name
  72505. */
  72506. constructor(name: string);
  72507. /**
  72508. * Gets the current class name
  72509. * @returns the class name
  72510. */
  72511. getClassName(): string;
  72512. /**
  72513. * Gets the first input component
  72514. */
  72515. get normalMap0(): NodeMaterialConnectionPoint;
  72516. /**
  72517. * Gets the second input component
  72518. */
  72519. get normalMap1(): NodeMaterialConnectionPoint;
  72520. /**
  72521. * Gets the output component
  72522. */
  72523. get output(): NodeMaterialConnectionPoint;
  72524. protected _buildBlock(state: NodeMaterialBuildState): this;
  72525. }
  72526. }
  72527. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  72528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72531. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  72532. /**
  72533. * Block used to rotate a 2d vector by a given angle
  72534. */
  72535. export class Rotate2dBlock extends NodeMaterialBlock {
  72536. /**
  72537. * Creates a new Rotate2dBlock
  72538. * @param name defines the block name
  72539. */
  72540. constructor(name: string);
  72541. /**
  72542. * Gets the current class name
  72543. * @returns the class name
  72544. */
  72545. getClassName(): string;
  72546. /**
  72547. * Gets the input vector
  72548. */
  72549. get input(): NodeMaterialConnectionPoint;
  72550. /**
  72551. * Gets the input angle
  72552. */
  72553. get angle(): NodeMaterialConnectionPoint;
  72554. /**
  72555. * Gets the output component
  72556. */
  72557. get output(): NodeMaterialConnectionPoint;
  72558. autoConfigure(material: NodeMaterial): void;
  72559. protected _buildBlock(state: NodeMaterialBuildState): this;
  72560. }
  72561. }
  72562. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  72563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72566. /**
  72567. * Block used to get the reflected vector from a direction and a normal
  72568. */
  72569. export class ReflectBlock extends NodeMaterialBlock {
  72570. /**
  72571. * Creates a new ReflectBlock
  72572. * @param name defines the block name
  72573. */
  72574. constructor(name: string);
  72575. /**
  72576. * Gets the current class name
  72577. * @returns the class name
  72578. */
  72579. getClassName(): string;
  72580. /**
  72581. * Gets the incident component
  72582. */
  72583. get incident(): NodeMaterialConnectionPoint;
  72584. /**
  72585. * Gets the normal component
  72586. */
  72587. get normal(): NodeMaterialConnectionPoint;
  72588. /**
  72589. * Gets the output component
  72590. */
  72591. get output(): NodeMaterialConnectionPoint;
  72592. protected _buildBlock(state: NodeMaterialBuildState): this;
  72593. }
  72594. }
  72595. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  72596. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72597. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72598. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72599. /**
  72600. * Block used to get the refracted vector from a direction and a normal
  72601. */
  72602. export class RefractBlock extends NodeMaterialBlock {
  72603. /**
  72604. * Creates a new RefractBlock
  72605. * @param name defines the block name
  72606. */
  72607. constructor(name: string);
  72608. /**
  72609. * Gets the current class name
  72610. * @returns the class name
  72611. */
  72612. getClassName(): string;
  72613. /**
  72614. * Gets the incident component
  72615. */
  72616. get incident(): NodeMaterialConnectionPoint;
  72617. /**
  72618. * Gets the normal component
  72619. */
  72620. get normal(): NodeMaterialConnectionPoint;
  72621. /**
  72622. * Gets the index of refraction component
  72623. */
  72624. get ior(): NodeMaterialConnectionPoint;
  72625. /**
  72626. * Gets the output component
  72627. */
  72628. get output(): NodeMaterialConnectionPoint;
  72629. protected _buildBlock(state: NodeMaterialBuildState): this;
  72630. }
  72631. }
  72632. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  72633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72636. /**
  72637. * Block used to desaturate a color
  72638. */
  72639. export class DesaturateBlock extends NodeMaterialBlock {
  72640. /**
  72641. * Creates a new DesaturateBlock
  72642. * @param name defines the block name
  72643. */
  72644. constructor(name: string);
  72645. /**
  72646. * Gets the current class name
  72647. * @returns the class name
  72648. */
  72649. getClassName(): string;
  72650. /**
  72651. * Gets the color operand input component
  72652. */
  72653. get color(): NodeMaterialConnectionPoint;
  72654. /**
  72655. * Gets the level operand input component
  72656. */
  72657. get level(): NodeMaterialConnectionPoint;
  72658. /**
  72659. * Gets the output component
  72660. */
  72661. get output(): NodeMaterialConnectionPoint;
  72662. protected _buildBlock(state: NodeMaterialBuildState): this;
  72663. }
  72664. }
  72665. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  72666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72668. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72669. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  72670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72671. import { Nullable } from "babylonjs/types";
  72672. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  72673. import { Mesh } from "babylonjs/Meshes/mesh";
  72674. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72675. import { Effect } from "babylonjs/Materials/effect";
  72676. import { Scene } from "babylonjs/scene";
  72677. /**
  72678. * Block used to implement the reflection module of the PBR material
  72679. */
  72680. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  72681. /** @hidden */
  72682. _defineLODReflectionAlpha: string;
  72683. /** @hidden */
  72684. _defineLinearSpecularReflection: string;
  72685. private _vEnvironmentIrradianceName;
  72686. /** @hidden */
  72687. _vReflectionMicrosurfaceInfosName: string;
  72688. /** @hidden */
  72689. _vReflectionInfosName: string;
  72690. /** @hidden */
  72691. _vReflectionFilteringInfoName: string;
  72692. private _scene;
  72693. /**
  72694. * The properties below are set by the main PBR block prior to calling methods of this class.
  72695. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  72696. * It's less burden on the user side in the editor part.
  72697. */
  72698. /** @hidden */
  72699. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  72700. /** @hidden */
  72701. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  72702. /** @hidden */
  72703. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  72704. /** @hidden */
  72705. viewConnectionPoint: NodeMaterialConnectionPoint;
  72706. /**
  72707. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  72708. * diffuse part of the IBL.
  72709. */
  72710. useSphericalHarmonics: boolean;
  72711. /**
  72712. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  72713. */
  72714. forceIrradianceInFragment: boolean;
  72715. /**
  72716. * Create a new ReflectionBlock
  72717. * @param name defines the block name
  72718. */
  72719. constructor(name: string);
  72720. /**
  72721. * Gets the current class name
  72722. * @returns the class name
  72723. */
  72724. getClassName(): string;
  72725. /**
  72726. * Gets the position input component
  72727. */
  72728. get position(): NodeMaterialConnectionPoint;
  72729. /**
  72730. * Gets the world position input component
  72731. */
  72732. get worldPosition(): NodeMaterialConnectionPoint;
  72733. /**
  72734. * Gets the world normal input component
  72735. */
  72736. get worldNormal(): NodeMaterialConnectionPoint;
  72737. /**
  72738. * Gets the world input component
  72739. */
  72740. get world(): NodeMaterialConnectionPoint;
  72741. /**
  72742. * Gets the camera (or eye) position component
  72743. */
  72744. get cameraPosition(): NodeMaterialConnectionPoint;
  72745. /**
  72746. * Gets the view input component
  72747. */
  72748. get view(): NodeMaterialConnectionPoint;
  72749. /**
  72750. * Gets the color input component
  72751. */
  72752. get color(): NodeMaterialConnectionPoint;
  72753. /**
  72754. * Gets the reflection object output component
  72755. */
  72756. get reflection(): NodeMaterialConnectionPoint;
  72757. /**
  72758. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  72759. */
  72760. get hasTexture(): boolean;
  72761. /**
  72762. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  72763. */
  72764. get reflectionColor(): string;
  72765. protected _getTexture(): Nullable<BaseTexture>;
  72766. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  72768. /**
  72769. * Gets the code to inject in the vertex shader
  72770. * @param state current state of the node material building
  72771. * @returns the shader code
  72772. */
  72773. handleVertexSide(state: NodeMaterialBuildState): string;
  72774. /**
  72775. * Gets the main code of the block (fragment side)
  72776. * @param state current state of the node material building
  72777. * @param normalVarName name of the existing variable corresponding to the normal
  72778. * @returns the shader code
  72779. */
  72780. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  72781. protected _buildBlock(state: NodeMaterialBuildState): this;
  72782. protected _dumpPropertiesCode(): string;
  72783. serialize(): any;
  72784. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72785. }
  72786. }
  72787. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  72788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72791. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72793. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72794. import { Scene } from "babylonjs/scene";
  72795. import { Nullable } from "babylonjs/types";
  72796. /**
  72797. * Block used to implement the sheen module of the PBR material
  72798. */
  72799. export class SheenBlock extends NodeMaterialBlock {
  72800. /**
  72801. * Create a new SheenBlock
  72802. * @param name defines the block name
  72803. */
  72804. constructor(name: string);
  72805. /**
  72806. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  72807. * It allows the strength of the sheen effect to not depend on the base color of the material,
  72808. * making it easier to setup and tweak the effect
  72809. */
  72810. albedoScaling: boolean;
  72811. /**
  72812. * Defines if the sheen is linked to the sheen color.
  72813. */
  72814. linkSheenWithAlbedo: boolean;
  72815. /**
  72816. * Initialize the block and prepare the context for build
  72817. * @param state defines the state that will be used for the build
  72818. */
  72819. initialize(state: NodeMaterialBuildState): void;
  72820. /**
  72821. * Gets the current class name
  72822. * @returns the class name
  72823. */
  72824. getClassName(): string;
  72825. /**
  72826. * Gets the intensity input component
  72827. */
  72828. get intensity(): NodeMaterialConnectionPoint;
  72829. /**
  72830. * Gets the color input component
  72831. */
  72832. get color(): NodeMaterialConnectionPoint;
  72833. /**
  72834. * Gets the roughness input component
  72835. */
  72836. get roughness(): NodeMaterialConnectionPoint;
  72837. /**
  72838. * Gets the sheen object output component
  72839. */
  72840. get sheen(): NodeMaterialConnectionPoint;
  72841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72842. /**
  72843. * Gets the main code of the block (fragment side)
  72844. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72845. * @returns the shader code
  72846. */
  72847. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  72848. protected _buildBlock(state: NodeMaterialBuildState): this;
  72849. protected _dumpPropertiesCode(): string;
  72850. serialize(): any;
  72851. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72852. }
  72853. }
  72854. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  72855. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72860. /**
  72861. * Block used to implement the anisotropy module of the PBR material
  72862. */
  72863. export class AnisotropyBlock extends NodeMaterialBlock {
  72864. /**
  72865. * The two properties below are set by the main PBR block prior to calling methods of this class.
  72866. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  72867. * It's less burden on the user side in the editor part.
  72868. */
  72869. /** @hidden */
  72870. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  72871. /** @hidden */
  72872. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  72873. /**
  72874. * Create a new AnisotropyBlock
  72875. * @param name defines the block name
  72876. */
  72877. constructor(name: string);
  72878. /**
  72879. * Initialize the block and prepare the context for build
  72880. * @param state defines the state that will be used for the build
  72881. */
  72882. initialize(state: NodeMaterialBuildState): void;
  72883. /**
  72884. * Gets the current class name
  72885. * @returns the class name
  72886. */
  72887. getClassName(): string;
  72888. /**
  72889. * Gets the intensity input component
  72890. */
  72891. get intensity(): NodeMaterialConnectionPoint;
  72892. /**
  72893. * Gets the direction input component
  72894. */
  72895. get direction(): NodeMaterialConnectionPoint;
  72896. /**
  72897. * Gets the uv input component
  72898. */
  72899. get uv(): NodeMaterialConnectionPoint;
  72900. /**
  72901. * Gets the worldTangent input component
  72902. */
  72903. get worldTangent(): NodeMaterialConnectionPoint;
  72904. /**
  72905. * Gets the anisotropy object output component
  72906. */
  72907. get anisotropy(): NodeMaterialConnectionPoint;
  72908. private _generateTBNSpace;
  72909. /**
  72910. * Gets the main code of the block (fragment side)
  72911. * @param state current state of the node material building
  72912. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72913. * @returns the shader code
  72914. */
  72915. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  72916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72917. protected _buildBlock(state: NodeMaterialBuildState): this;
  72918. }
  72919. }
  72920. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  72921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72924. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72926. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72927. import { Scene } from "babylonjs/scene";
  72928. import { Nullable } from "babylonjs/types";
  72929. import { Mesh } from "babylonjs/Meshes/mesh";
  72930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72931. import { Effect } from "babylonjs/Materials/effect";
  72932. /**
  72933. * Block used to implement the clear coat module of the PBR material
  72934. */
  72935. export class ClearCoatBlock extends NodeMaterialBlock {
  72936. private _scene;
  72937. /**
  72938. * Create a new ClearCoatBlock
  72939. * @param name defines the block name
  72940. */
  72941. constructor(name: string);
  72942. /**
  72943. * Defines if the F0 value should be remapped to account for the interface change in the material.
  72944. */
  72945. remapF0OnInterfaceChange: boolean;
  72946. /**
  72947. * Initialize the block and prepare the context for build
  72948. * @param state defines the state that will be used for the build
  72949. */
  72950. initialize(state: NodeMaterialBuildState): void;
  72951. /**
  72952. * Gets the current class name
  72953. * @returns the class name
  72954. */
  72955. getClassName(): string;
  72956. /**
  72957. * Gets the intensity input component
  72958. */
  72959. get intensity(): NodeMaterialConnectionPoint;
  72960. /**
  72961. * Gets the roughness input component
  72962. */
  72963. get roughness(): NodeMaterialConnectionPoint;
  72964. /**
  72965. * Gets the ior input component
  72966. */
  72967. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72968. /**
  72969. * Gets the bump texture input component
  72970. */
  72971. get normalMapColor(): NodeMaterialConnectionPoint;
  72972. /**
  72973. * Gets the uv input component
  72974. */
  72975. get uv(): NodeMaterialConnectionPoint;
  72976. /**
  72977. * Gets the tint color input component
  72978. */
  72979. get tintColor(): NodeMaterialConnectionPoint;
  72980. /**
  72981. * Gets the tint "at distance" input component
  72982. */
  72983. get tintAtDistance(): NodeMaterialConnectionPoint;
  72984. /**
  72985. * Gets the tint thickness input component
  72986. */
  72987. get tintThickness(): NodeMaterialConnectionPoint;
  72988. /**
  72989. * Gets the world tangent input component
  72990. */
  72991. get worldTangent(): NodeMaterialConnectionPoint;
  72992. /**
  72993. * Gets the clear coat object output component
  72994. */
  72995. get clearcoat(): NodeMaterialConnectionPoint;
  72996. autoConfigure(material: NodeMaterial): void;
  72997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72998. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  72999. private _generateTBNSpace;
  73000. /**
  73001. * Gets the main code of the block (fragment side)
  73002. * @param state current state of the node material building
  73003. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  73004. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  73005. * @param worldPosVarName name of the variable holding the world position
  73006. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  73007. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  73008. * @param worldNormalVarName name of the variable holding the world normal
  73009. * @returns the shader code
  73010. */
  73011. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  73012. protected _buildBlock(state: NodeMaterialBuildState): this;
  73013. protected _dumpPropertiesCode(): string;
  73014. serialize(): any;
  73015. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  73016. }
  73017. }
  73018. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  73019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  73020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  73021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  73022. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  73023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73024. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  73025. import { Nullable } from "babylonjs/types";
  73026. /**
  73027. * Block used to implement the sub surface module of the PBR material
  73028. */
  73029. export class SubSurfaceBlock extends NodeMaterialBlock {
  73030. /**
  73031. * Create a new SubSurfaceBlock
  73032. * @param name defines the block name
  73033. */
  73034. constructor(name: string);
  73035. /**
  73036. * Initialize the block and prepare the context for build
  73037. * @param state defines the state that will be used for the build
  73038. */
  73039. initialize(state: NodeMaterialBuildState): void;
  73040. /**
  73041. * Gets the current class name
  73042. * @returns the class name
  73043. */
  73044. getClassName(): string;
  73045. /**
  73046. * Gets the thickness component
  73047. */
  73048. get thickness(): NodeMaterialConnectionPoint;
  73049. /**
  73050. * Gets the tint color input component
  73051. */
  73052. get tintColor(): NodeMaterialConnectionPoint;
  73053. /**
  73054. * Gets the translucency intensity input component
  73055. */
  73056. get translucencyIntensity(): NodeMaterialConnectionPoint;
  73057. /**
  73058. * Gets the translucency diffusion distance input component
  73059. */
  73060. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  73061. /**
  73062. * Gets the refraction object parameters
  73063. */
  73064. get refraction(): NodeMaterialConnectionPoint;
  73065. /**
  73066. * Gets the sub surface object output component
  73067. */
  73068. get subsurface(): NodeMaterialConnectionPoint;
  73069. autoConfigure(material: NodeMaterial): void;
  73070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  73071. /**
  73072. * Gets the main code of the block (fragment side)
  73073. * @param state current state of the node material building
  73074. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  73075. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  73076. * @param worldPosVarName name of the variable holding the world position
  73077. * @returns the shader code
  73078. */
  73079. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  73080. protected _buildBlock(state: NodeMaterialBuildState): this;
  73081. }
  73082. }
  73083. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  73084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  73085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  73086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  73087. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  73088. import { Light } from "babylonjs/Lights/light";
  73089. import { Nullable } from "babylonjs/types";
  73090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73091. import { Effect } from "babylonjs/Materials/effect";
  73092. import { Mesh } from "babylonjs/Meshes/mesh";
  73093. import { Scene } from "babylonjs/scene";
  73094. /**
  73095. * Block used to implement the PBR metallic/roughness model
  73096. */
  73097. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  73098. /**
  73099. * Gets or sets the light associated with this block
  73100. */
  73101. light: Nullable<Light>;
  73102. private _lightId;
  73103. private _scene;
  73104. private _environmentBRDFTexture;
  73105. private _environmentBrdfSamplerName;
  73106. private _vNormalWName;
  73107. private _invertNormalName;
  73108. private _metallicReflectanceColor;
  73109. private _metallicF0Factor;
  73110. private _vMetallicReflectanceFactorsName;
  73111. /**
  73112. * Create a new ReflectionBlock
  73113. * @param name defines the block name
  73114. */
  73115. constructor(name: string);
  73116. /**
  73117. * Intensity of the direct lights e.g. the four lights available in your scene.
  73118. * This impacts both the direct diffuse and specular highlights.
  73119. */
  73120. directIntensity: number;
  73121. /**
  73122. * Intensity of the environment e.g. how much the environment will light the object
  73123. * either through harmonics for rough material or through the reflection for shiny ones.
  73124. */
  73125. environmentIntensity: number;
  73126. /**
  73127. * This is a special control allowing the reduction of the specular highlights coming from the
  73128. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  73129. */
  73130. specularIntensity: number;
  73131. /**
  73132. * Defines the falloff type used in this material.
  73133. * It by default is Physical.
  73134. */
  73135. lightFalloff: number;
  73136. /**
  73137. * Specifies that alpha test should be used
  73138. */
  73139. useAlphaTest: boolean;
  73140. /**
  73141. * Defines the alpha limits in alpha test mode.
  73142. */
  73143. alphaTestCutoff: number;
  73144. /**
  73145. * Specifies that alpha blending should be used
  73146. */
  73147. useAlphaBlending: boolean;
  73148. /**
  73149. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  73150. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  73151. */
  73152. useRadianceOverAlpha: boolean;
  73153. /**
  73154. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  73155. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  73156. */
  73157. useSpecularOverAlpha: boolean;
  73158. /**
  73159. * Enables specular anti aliasing in the PBR shader.
  73160. * It will both interacts on the Geometry for analytical and IBL lighting.
  73161. * It also prefilter the roughness map based on the bump values.
  73162. */
  73163. enableSpecularAntiAliasing: boolean;
  73164. /**
  73165. * Enables realtime filtering on the texture.
  73166. */
  73167. realTimeFiltering: boolean;
  73168. /**
  73169. * Quality switch for realtime filtering
  73170. */
  73171. realTimeFilteringQuality: number;
  73172. /**
  73173. * Defines if the material uses energy conservation.
  73174. */
  73175. useEnergyConservation: boolean;
  73176. /**
  73177. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  73178. * too much the area relying on ambient texture to define their ambient occlusion.
  73179. */
  73180. useRadianceOcclusion: boolean;
  73181. /**
  73182. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  73183. * makes the reflect vector face the model (under horizon).
  73184. */
  73185. useHorizonOcclusion: boolean;
  73186. /**
  73187. * If set to true, no lighting calculations will be applied.
  73188. */
  73189. unlit: boolean;
  73190. /**
  73191. * Force normal to face away from face.
  73192. */
  73193. forceNormalForward: boolean;
  73194. /**
  73195. * Defines the material debug mode.
  73196. * It helps seeing only some components of the material while troubleshooting.
  73197. */
  73198. debugMode: number;
  73199. /**
  73200. * Specify from where on screen the debug mode should start.
  73201. * The value goes from -1 (full screen) to 1 (not visible)
  73202. * It helps with side by side comparison against the final render
  73203. * This defaults to 0
  73204. */
  73205. debugLimit: number;
  73206. /**
  73207. * As the default viewing range might not be enough (if the ambient is really small for instance)
  73208. * You can use the factor to better multiply the final value.
  73209. */
  73210. debugFactor: number;
  73211. /**
  73212. * Initialize the block and prepare the context for build
  73213. * @param state defines the state that will be used for the build
  73214. */
  73215. initialize(state: NodeMaterialBuildState): void;
  73216. /**
  73217. * Gets the current class name
  73218. * @returns the class name
  73219. */
  73220. getClassName(): string;
  73221. /**
  73222. * Gets the world position input component
  73223. */
  73224. get worldPosition(): NodeMaterialConnectionPoint;
  73225. /**
  73226. * Gets the world normal input component
  73227. */
  73228. get worldNormal(): NodeMaterialConnectionPoint;
  73229. /**
  73230. * Gets the view matrix parameter
  73231. */
  73232. get view(): NodeMaterialConnectionPoint;
  73233. /**
  73234. * Gets the camera position input component
  73235. */
  73236. get cameraPosition(): NodeMaterialConnectionPoint;
  73237. /**
  73238. * Gets the perturbed normal input component
  73239. */
  73240. get perturbedNormal(): NodeMaterialConnectionPoint;
  73241. /**
  73242. * Gets the base color input component
  73243. */
  73244. get baseColor(): NodeMaterialConnectionPoint;
  73245. /**
  73246. * Gets the metallic input component
  73247. */
  73248. get metallic(): NodeMaterialConnectionPoint;
  73249. /**
  73250. * Gets the roughness input component
  73251. */
  73252. get roughness(): NodeMaterialConnectionPoint;
  73253. /**
  73254. * Gets the ambient occlusion input component
  73255. */
  73256. get ambientOcc(): NodeMaterialConnectionPoint;
  73257. /**
  73258. * Gets the opacity input component
  73259. */
  73260. get opacity(): NodeMaterialConnectionPoint;
  73261. /**
  73262. * Gets the index of refraction input component
  73263. */
  73264. get indexOfRefraction(): NodeMaterialConnectionPoint;
  73265. /**
  73266. * Gets the ambient color input component
  73267. */
  73268. get ambientColor(): NodeMaterialConnectionPoint;
  73269. /**
  73270. * Gets the reflection object parameters
  73271. */
  73272. get reflection(): NodeMaterialConnectionPoint;
  73273. /**
  73274. * Gets the clear coat object parameters
  73275. */
  73276. get clearcoat(): NodeMaterialConnectionPoint;
  73277. /**
  73278. * Gets the sheen object parameters
  73279. */
  73280. get sheen(): NodeMaterialConnectionPoint;
  73281. /**
  73282. * Gets the sub surface object parameters
  73283. */
  73284. get subsurface(): NodeMaterialConnectionPoint;
  73285. /**
  73286. * Gets the anisotropy object parameters
  73287. */
  73288. get anisotropy(): NodeMaterialConnectionPoint;
  73289. /**
  73290. * Gets the ambient output component
  73291. */
  73292. get ambientClr(): NodeMaterialConnectionPoint;
  73293. /**
  73294. * Gets the diffuse output component
  73295. */
  73296. get diffuseDir(): NodeMaterialConnectionPoint;
  73297. /**
  73298. * Gets the specular output component
  73299. */
  73300. get specularDir(): NodeMaterialConnectionPoint;
  73301. /**
  73302. * Gets the clear coat output component
  73303. */
  73304. get clearcoatDir(): NodeMaterialConnectionPoint;
  73305. /**
  73306. * Gets the sheen output component
  73307. */
  73308. get sheenDir(): NodeMaterialConnectionPoint;
  73309. /**
  73310. * Gets the indirect diffuse output component
  73311. */
  73312. get diffuseIndirect(): NodeMaterialConnectionPoint;
  73313. /**
  73314. * Gets the indirect specular output component
  73315. */
  73316. get specularIndirect(): NodeMaterialConnectionPoint;
  73317. /**
  73318. * Gets the indirect clear coat output component
  73319. */
  73320. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  73321. /**
  73322. * Gets the indirect sheen output component
  73323. */
  73324. get sheenIndirect(): NodeMaterialConnectionPoint;
  73325. /**
  73326. * Gets the refraction output component
  73327. */
  73328. get refraction(): NodeMaterialConnectionPoint;
  73329. /**
  73330. * Gets the global lighting output component
  73331. */
  73332. get lighting(): NodeMaterialConnectionPoint;
  73333. /**
  73334. * Gets the shadow output component
  73335. */
  73336. get shadow(): NodeMaterialConnectionPoint;
  73337. /**
  73338. * Gets the alpha output component
  73339. */
  73340. get alpha(): NodeMaterialConnectionPoint;
  73341. autoConfigure(material: NodeMaterial): void;
  73342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  73343. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  73344. isReady(): boolean;
  73345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  73346. private _injectVertexCode;
  73347. private _getAlbedoOpacityCode;
  73348. private _getAmbientOcclusionCode;
  73349. private _getReflectivityCode;
  73350. protected _buildBlock(state: NodeMaterialBuildState): this;
  73351. protected _dumpPropertiesCode(): string;
  73352. serialize(): any;
  73353. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  73354. }
  73355. }
  73356. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  73357. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  73358. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  73359. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  73360. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  73361. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  73362. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  73363. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  73364. }
  73365. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  73366. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  73367. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  73368. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  73369. }
  73370. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  73371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  73372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  73373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  73374. /**
  73375. * Block used to compute value of one parameter modulo another
  73376. */
  73377. export class ModBlock extends NodeMaterialBlock {
  73378. /**
  73379. * Creates a new ModBlock
  73380. * @param name defines the block name
  73381. */
  73382. constructor(name: string);
  73383. /**
  73384. * Gets the current class name
  73385. * @returns the class name
  73386. */
  73387. getClassName(): string;
  73388. /**
  73389. * Gets the left operand input component
  73390. */
  73391. get left(): NodeMaterialConnectionPoint;
  73392. /**
  73393. * Gets the right operand input component
  73394. */
  73395. get right(): NodeMaterialConnectionPoint;
  73396. /**
  73397. * Gets the output component
  73398. */
  73399. get output(): NodeMaterialConnectionPoint;
  73400. protected _buildBlock(state: NodeMaterialBuildState): this;
  73401. }
  73402. }
  73403. declare module "babylonjs/Materials/Node/Blocks/index" {
  73404. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  73405. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  73406. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  73407. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  73408. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  73409. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  73410. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  73411. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  73412. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  73413. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  73414. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  73415. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  73416. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  73417. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  73418. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  73419. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  73420. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  73421. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  73422. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  73423. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  73424. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  73425. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  73426. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  73427. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  73428. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  73429. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  73430. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  73431. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  73432. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  73433. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  73434. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  73435. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  73436. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  73437. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  73438. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  73439. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  73440. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  73441. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  73442. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  73443. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  73444. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  73445. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  73446. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  73447. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  73448. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  73449. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  73450. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  73451. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  73452. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  73453. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  73454. }
  73455. declare module "babylonjs/Materials/Node/Optimizers/index" {
  73456. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  73457. }
  73458. declare module "babylonjs/Materials/Node/index" {
  73459. export * from "babylonjs/Materials/Node/Enums/index";
  73460. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  73461. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  73462. export * from "babylonjs/Materials/Node/nodeMaterial";
  73463. export * from "babylonjs/Materials/Node/Blocks/index";
  73464. export * from "babylonjs/Materials/Node/Optimizers/index";
  73465. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  73466. }
  73467. declare module "babylonjs/Materials/index" {
  73468. export * from "babylonjs/Materials/Background/index";
  73469. export * from "babylonjs/Materials/colorCurves";
  73470. export * from "babylonjs/Materials/iEffectFallbacks";
  73471. export * from "babylonjs/Materials/effectFallbacks";
  73472. export * from "babylonjs/Materials/effect";
  73473. export * from "babylonjs/Materials/fresnelParameters";
  73474. export * from "babylonjs/Materials/imageProcessingConfiguration";
  73475. export * from "babylonjs/Materials/material";
  73476. export * from "babylonjs/Materials/materialDefines";
  73477. export * from "babylonjs/Materials/thinMaterialHelper";
  73478. export * from "babylonjs/Materials/materialHelper";
  73479. export * from "babylonjs/Materials/multiMaterial";
  73480. export * from "babylonjs/Materials/Occlusion/index";
  73481. export * from "babylonjs/Materials/PBR/index";
  73482. export * from "babylonjs/Materials/pushMaterial";
  73483. export * from "babylonjs/Materials/shaderMaterial";
  73484. export * from "babylonjs/Materials/standardMaterial";
  73485. export * from "babylonjs/Materials/Textures/index";
  73486. export * from "babylonjs/Materials/uniformBuffer";
  73487. export * from "babylonjs/Materials/materialFlags";
  73488. export * from "babylonjs/Materials/Node/index";
  73489. export * from "babylonjs/Materials/effectRenderer";
  73490. export * from "babylonjs/Materials/shadowDepthWrapper";
  73491. }
  73492. declare module "babylonjs/Maths/index" {
  73493. export * from "babylonjs/Maths/math.scalar";
  73494. export * from "babylonjs/Maths/math.functions";
  73495. export * from "babylonjs/Maths/math";
  73496. export * from "babylonjs/Maths/sphericalPolynomial";
  73497. }
  73498. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  73499. import { IDisposable } from "babylonjs/scene";
  73500. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  73501. /**
  73502. * Configuration for Draco compression
  73503. */
  73504. export interface IDracoCompressionConfiguration {
  73505. /**
  73506. * Configuration for the decoder.
  73507. */
  73508. decoder: {
  73509. /**
  73510. * The url to the WebAssembly module.
  73511. */
  73512. wasmUrl?: string;
  73513. /**
  73514. * The url to the WebAssembly binary.
  73515. */
  73516. wasmBinaryUrl?: string;
  73517. /**
  73518. * The url to the fallback JavaScript module.
  73519. */
  73520. fallbackUrl?: string;
  73521. };
  73522. }
  73523. /**
  73524. * Draco compression (https://google.github.io/draco/)
  73525. *
  73526. * This class wraps the Draco module.
  73527. *
  73528. * **Encoder**
  73529. *
  73530. * The encoder is not currently implemented.
  73531. *
  73532. * **Decoder**
  73533. *
  73534. * 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.
  73535. *
  73536. * To update the configuration, use the following code:
  73537. * ```javascript
  73538. * DracoCompression.Configuration = {
  73539. * decoder: {
  73540. * wasmUrl: "<url to the WebAssembly library>",
  73541. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  73542. * fallbackUrl: "<url to the fallback JavaScript library>",
  73543. * }
  73544. * };
  73545. * ```
  73546. *
  73547. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.
  73548. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  73549. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  73550. *
  73551. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  73552. * ```javascript
  73553. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  73554. * ```
  73555. *
  73556. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  73557. */
  73558. export class DracoCompression implements IDisposable {
  73559. private _workerPoolPromise?;
  73560. private _decoderModulePromise?;
  73561. /**
  73562. * The configuration. Defaults to the following urls:
  73563. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  73564. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  73565. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  73566. */
  73567. static Configuration: IDracoCompressionConfiguration;
  73568. /**
  73569. * Returns true if the decoder configuration is available.
  73570. */
  73571. static get DecoderAvailable(): boolean;
  73572. /**
  73573. * Default number of workers to create when creating the draco compression object.
  73574. */
  73575. static DefaultNumWorkers: number;
  73576. private static GetDefaultNumWorkers;
  73577. private static _Default;
  73578. /**
  73579. * Default instance for the draco compression object.
  73580. */
  73581. static get Default(): DracoCompression;
  73582. /**
  73583. * Constructor
  73584. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  73585. */
  73586. constructor(numWorkers?: number);
  73587. /**
  73588. * Stop all async operations and release resources.
  73589. */
  73590. dispose(): void;
  73591. /**
  73592. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  73593. * @returns a promise that resolves when ready
  73594. */
  73595. whenReadyAsync(): Promise<void>;
  73596. /**
  73597. * Decode Draco compressed mesh data to vertex data.
  73598. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  73599. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  73600. * @returns A promise that resolves with the decoded vertex data
  73601. */
  73602. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  73603. [kind: string]: number;
  73604. }): Promise<VertexData>;
  73605. }
  73606. }
  73607. declare module "babylonjs/Meshes/Compression/index" {
  73608. export * from "babylonjs/Meshes/Compression/dracoCompression";
  73609. }
  73610. declare module "babylonjs/Meshes/csg" {
  73611. import { Nullable } from "babylonjs/types";
  73612. import { Scene } from "babylonjs/scene";
  73613. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  73614. import { Mesh } from "babylonjs/Meshes/mesh";
  73615. import { Material } from "babylonjs/Materials/material";
  73616. /**
  73617. * Class for building Constructive Solid Geometry
  73618. */
  73619. export class CSG {
  73620. private polygons;
  73621. /**
  73622. * The world matrix
  73623. */
  73624. matrix: Matrix;
  73625. /**
  73626. * Stores the position
  73627. */
  73628. position: Vector3;
  73629. /**
  73630. * Stores the rotation
  73631. */
  73632. rotation: Vector3;
  73633. /**
  73634. * Stores the rotation quaternion
  73635. */
  73636. rotationQuaternion: Nullable<Quaternion>;
  73637. /**
  73638. * Stores the scaling vector
  73639. */
  73640. scaling: Vector3;
  73641. /**
  73642. * Convert the Mesh to CSG
  73643. * @param mesh The Mesh to convert to CSG
  73644. * @returns A new CSG from the Mesh
  73645. */
  73646. static FromMesh(mesh: Mesh): CSG;
  73647. /**
  73648. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  73649. * @param polygons Polygons used to construct a CSG solid
  73650. */
  73651. private static FromPolygons;
  73652. /**
  73653. * Clones, or makes a deep copy, of the CSG
  73654. * @returns A new CSG
  73655. */
  73656. clone(): CSG;
  73657. /**
  73658. * Unions this CSG with another CSG
  73659. * @param csg The CSG to union against this CSG
  73660. * @returns The unioned CSG
  73661. */
  73662. union(csg: CSG): CSG;
  73663. /**
  73664. * Unions this CSG with another CSG in place
  73665. * @param csg The CSG to union against this CSG
  73666. */
  73667. unionInPlace(csg: CSG): void;
  73668. /**
  73669. * Subtracts this CSG with another CSG
  73670. * @param csg The CSG to subtract against this CSG
  73671. * @returns A new CSG
  73672. */
  73673. subtract(csg: CSG): CSG;
  73674. /**
  73675. * Subtracts this CSG with another CSG in place
  73676. * @param csg The CSG to subtract against this CSG
  73677. */
  73678. subtractInPlace(csg: CSG): void;
  73679. /**
  73680. * Intersect this CSG with another CSG
  73681. * @param csg The CSG to intersect against this CSG
  73682. * @returns A new CSG
  73683. */
  73684. intersect(csg: CSG): CSG;
  73685. /**
  73686. * Intersects this CSG with another CSG in place
  73687. * @param csg The CSG to intersect against this CSG
  73688. */
  73689. intersectInPlace(csg: CSG): void;
  73690. /**
  73691. * Return a new CSG solid with solid and empty space switched. This solid is
  73692. * not modified.
  73693. * @returns A new CSG solid with solid and empty space switched
  73694. */
  73695. inverse(): CSG;
  73696. /**
  73697. * Inverses the CSG in place
  73698. */
  73699. inverseInPlace(): void;
  73700. /**
  73701. * This is used to keep meshes transformations so they can be restored
  73702. * when we build back a Babylon Mesh
  73703. * NB : All CSG operations are performed in world coordinates
  73704. * @param csg The CSG to copy the transform attributes from
  73705. * @returns This CSG
  73706. */
  73707. copyTransformAttributes(csg: CSG): CSG;
  73708. /**
  73709. * Build Raw mesh from CSG
  73710. * Coordinates here are in world space
  73711. * @param name The name of the mesh geometry
  73712. * @param scene The Scene
  73713. * @param keepSubMeshes Specifies if the submeshes should be kept
  73714. * @returns A new Mesh
  73715. */
  73716. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  73717. /**
  73718. * Build Mesh from CSG taking material and transforms into account
  73719. * @param name The name of the Mesh
  73720. * @param material The material of the Mesh
  73721. * @param scene The Scene
  73722. * @param keepSubMeshes Specifies if submeshes should be kept
  73723. * @returns The new Mesh
  73724. */
  73725. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  73726. }
  73727. }
  73728. declare module "babylonjs/Meshes/trailMesh" {
  73729. import { Mesh } from "babylonjs/Meshes/mesh";
  73730. import { Scene } from "babylonjs/scene";
  73731. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73732. /**
  73733. * Class used to create a trail following a mesh
  73734. */
  73735. export class TrailMesh extends Mesh {
  73736. private _generator;
  73737. private _autoStart;
  73738. private _running;
  73739. private _diameter;
  73740. private _length;
  73741. private _sectionPolygonPointsCount;
  73742. private _sectionVectors;
  73743. private _sectionNormalVectors;
  73744. private _beforeRenderObserver;
  73745. /**
  73746. * @constructor
  73747. * @param name The value used by scene.getMeshByName() to do a lookup.
  73748. * @param generator The mesh or transform node to generate a trail.
  73749. * @param scene The scene to add this mesh to.
  73750. * @param diameter Diameter of trailing mesh. Default is 1.
  73751. * @param length Length of trailing mesh. Default is 60.
  73752. * @param autoStart Automatically start trailing mesh. Default true.
  73753. */
  73754. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  73755. /**
  73756. * "TrailMesh"
  73757. * @returns "TrailMesh"
  73758. */
  73759. getClassName(): string;
  73760. private _createMesh;
  73761. /**
  73762. * Start trailing mesh.
  73763. */
  73764. start(): void;
  73765. /**
  73766. * Stop trailing mesh.
  73767. */
  73768. stop(): void;
  73769. /**
  73770. * Update trailing mesh geometry.
  73771. */
  73772. update(): void;
  73773. /**
  73774. * Returns a new TrailMesh object.
  73775. * @param name is a string, the name given to the new mesh
  73776. * @param newGenerator use new generator object for cloned trail mesh
  73777. * @returns a new mesh
  73778. */
  73779. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  73780. /**
  73781. * Serializes this trail mesh
  73782. * @param serializationObject object to write serialization to
  73783. */
  73784. serialize(serializationObject: any): void;
  73785. /**
  73786. * Parses a serialized trail mesh
  73787. * @param parsedMesh the serialized mesh
  73788. * @param scene the scene to create the trail mesh in
  73789. * @returns the created trail mesh
  73790. */
  73791. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  73792. }
  73793. }
  73794. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  73795. import { Nullable } from "babylonjs/types";
  73796. import { Scene } from "babylonjs/scene";
  73797. import { Vector4 } from "babylonjs/Maths/math.vector";
  73798. import { Color4 } from "babylonjs/Maths/math.color";
  73799. import { Mesh } from "babylonjs/Meshes/mesh";
  73800. /**
  73801. * Class containing static functions to help procedurally build meshes
  73802. */
  73803. export class TiledBoxBuilder {
  73804. /**
  73805. * Creates a box mesh
  73806. * 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)
  73807. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73811. * @param name defines the name of the mesh
  73812. * @param options defines the options used to create the mesh
  73813. * @param scene defines the hosting scene
  73814. * @returns the box mesh
  73815. */
  73816. static CreateTiledBox(name: string, options: {
  73817. pattern?: number;
  73818. width?: number;
  73819. height?: number;
  73820. depth?: number;
  73821. tileSize?: number;
  73822. tileWidth?: number;
  73823. tileHeight?: number;
  73824. alignHorizontal?: number;
  73825. alignVertical?: number;
  73826. faceUV?: Vector4[];
  73827. faceColors?: Color4[];
  73828. sideOrientation?: number;
  73829. updatable?: boolean;
  73830. }, scene?: Nullable<Scene>): Mesh;
  73831. }
  73832. }
  73833. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  73834. import { Vector4 } from "babylonjs/Maths/math.vector";
  73835. import { Mesh } from "babylonjs/Meshes/mesh";
  73836. /**
  73837. * Class containing static functions to help procedurally build meshes
  73838. */
  73839. export class TorusKnotBuilder {
  73840. /**
  73841. * Creates a torus knot mesh
  73842. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  73843. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  73844. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  73845. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  73846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  73848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73849. * @param name defines the name of the mesh
  73850. * @param options defines the options used to create the mesh
  73851. * @param scene defines the hosting scene
  73852. * @returns the torus knot mesh
  73853. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  73854. */
  73855. static CreateTorusKnot(name: string, options: {
  73856. radius?: number;
  73857. tube?: number;
  73858. radialSegments?: number;
  73859. tubularSegments?: number;
  73860. p?: number;
  73861. q?: number;
  73862. updatable?: boolean;
  73863. sideOrientation?: number;
  73864. frontUVs?: Vector4;
  73865. backUVs?: Vector4;
  73866. }, scene: any): Mesh;
  73867. }
  73868. }
  73869. declare module "babylonjs/Meshes/polygonMesh" {
  73870. import { Scene } from "babylonjs/scene";
  73871. import { Vector2 } from "babylonjs/Maths/math.vector";
  73872. import { Mesh } from "babylonjs/Meshes/mesh";
  73873. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  73874. import { Path2 } from "babylonjs/Maths/math.path";
  73875. /**
  73876. * Polygon
  73877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  73878. */
  73879. export class Polygon {
  73880. /**
  73881. * Creates a rectangle
  73882. * @param xmin bottom X coord
  73883. * @param ymin bottom Y coord
  73884. * @param xmax top X coord
  73885. * @param ymax top Y coord
  73886. * @returns points that make the resulting rectangle
  73887. */
  73888. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  73889. /**
  73890. * Creates a circle
  73891. * @param radius radius of circle
  73892. * @param cx scale in x
  73893. * @param cy scale in y
  73894. * @param numberOfSides number of sides that make up the circle
  73895. * @returns points that make the resulting circle
  73896. */
  73897. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  73898. /**
  73899. * Creates a polygon from input string
  73900. * @param input Input polygon data
  73901. * @returns the parsed points
  73902. */
  73903. static Parse(input: string): Vector2[];
  73904. /**
  73905. * Starts building a polygon from x and y coordinates
  73906. * @param x x coordinate
  73907. * @param y y coordinate
  73908. * @returns the started path2
  73909. */
  73910. static StartingAt(x: number, y: number): Path2;
  73911. }
  73912. /**
  73913. * Builds a polygon
  73914. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  73915. */
  73916. export class PolygonMeshBuilder {
  73917. private _points;
  73918. private _outlinepoints;
  73919. private _holes;
  73920. private _name;
  73921. private _scene;
  73922. private _epoints;
  73923. private _eholes;
  73924. private _addToepoint;
  73925. /**
  73926. * Babylon reference to the earcut plugin.
  73927. */
  73928. bjsEarcut: any;
  73929. /**
  73930. * Creates a PolygonMeshBuilder
  73931. * @param name name of the builder
  73932. * @param contours Path of the polygon
  73933. * @param scene scene to add to when creating the mesh
  73934. * @param earcutInjection can be used to inject your own earcut reference
  73935. */
  73936. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  73937. /**
  73938. * Adds a hole within the polygon
  73939. * @param hole Array of points defining the hole
  73940. * @returns this
  73941. */
  73942. addHole(hole: Vector2[]): PolygonMeshBuilder;
  73943. /**
  73944. * Creates the polygon
  73945. * @param updatable If the mesh should be updatable
  73946. * @param depth The depth of the mesh created
  73947. * @param smoothingThreshold Dot product threshold for smoothed normals
  73948. * @returns the created mesh
  73949. */
  73950. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  73951. /**
  73952. * Creates the polygon
  73953. * @param depth The depth of the mesh created
  73954. * @param smoothingThreshold Dot product threshold for smoothed normals
  73955. * @returns the created VertexData
  73956. */
  73957. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  73958. /**
  73959. * Adds a side to the polygon
  73960. * @param positions points that make the polygon
  73961. * @param normals normals of the polygon
  73962. * @param uvs uvs of the polygon
  73963. * @param indices indices of the polygon
  73964. * @param bounds bounds of the polygon
  73965. * @param points points of the polygon
  73966. * @param depth depth of the polygon
  73967. * @param flip flip of the polygon
  73968. */
  73969. private addSide;
  73970. }
  73971. }
  73972. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  73973. import { Scene } from "babylonjs/scene";
  73974. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73975. import { Color4 } from "babylonjs/Maths/math.color";
  73976. import { Mesh } from "babylonjs/Meshes/mesh";
  73977. import { Nullable } from "babylonjs/types";
  73978. /**
  73979. * Class containing static functions to help procedurally build meshes
  73980. */
  73981. export class PolygonBuilder {
  73982. /**
  73983. * Creates a polygon mesh
  73984. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  73985. * * 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
  73986. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  73989. * * Remember you can only change the shape positions, not their number when updating a polygon
  73990. * @param name defines the name of the mesh
  73991. * @param options defines the options used to create the mesh
  73992. * @param scene defines the hosting scene
  73993. * @param earcutInjection can be used to inject your own earcut reference
  73994. * @returns the polygon mesh
  73995. */
  73996. static CreatePolygon(name: string, options: {
  73997. shape: Vector3[];
  73998. holes?: Vector3[][];
  73999. depth?: number;
  74000. smoothingThreshold?: number;
  74001. faceUV?: Vector4[];
  74002. faceColors?: Color4[];
  74003. updatable?: boolean;
  74004. sideOrientation?: number;
  74005. frontUVs?: Vector4;
  74006. backUVs?: Vector4;
  74007. wrap?: boolean;
  74008. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74009. /**
  74010. * Creates an extruded polygon mesh, with depth in the Y direction.
  74011. * * 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)
  74012. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74013. * @param name defines the name of the mesh
  74014. * @param options defines the options used to create the mesh
  74015. * @param scene defines the hosting scene
  74016. * @param earcutInjection can be used to inject your own earcut reference
  74017. * @returns the polygon mesh
  74018. */
  74019. static ExtrudePolygon(name: string, options: {
  74020. shape: Vector3[];
  74021. holes?: Vector3[][];
  74022. depth?: number;
  74023. faceUV?: Vector4[];
  74024. faceColors?: Color4[];
  74025. updatable?: boolean;
  74026. sideOrientation?: number;
  74027. frontUVs?: Vector4;
  74028. backUVs?: Vector4;
  74029. wrap?: boolean;
  74030. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74031. }
  74032. }
  74033. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  74034. import { Scene } from "babylonjs/scene";
  74035. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  74036. import { Mesh } from "babylonjs/Meshes/mesh";
  74037. import { Nullable } from "babylonjs/types";
  74038. /**
  74039. * Class containing static functions to help procedurally build meshes
  74040. */
  74041. export class LatheBuilder {
  74042. /**
  74043. * Creates lathe mesh.
  74044. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  74045. * * 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
  74046. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  74047. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  74048. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  74049. * * 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
  74050. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  74051. * * 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
  74052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74054. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74056. * @param name defines the name of the mesh
  74057. * @param options defines the options used to create the mesh
  74058. * @param scene defines the hosting scene
  74059. * @returns the lathe mesh
  74060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  74061. */
  74062. static CreateLathe(name: string, options: {
  74063. shape: Vector3[];
  74064. radius?: number;
  74065. tessellation?: number;
  74066. clip?: number;
  74067. arc?: number;
  74068. closed?: boolean;
  74069. updatable?: boolean;
  74070. sideOrientation?: number;
  74071. frontUVs?: Vector4;
  74072. backUVs?: Vector4;
  74073. cap?: number;
  74074. invertUV?: boolean;
  74075. }, scene?: Nullable<Scene>): Mesh;
  74076. }
  74077. }
  74078. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  74079. import { Nullable } from "babylonjs/types";
  74080. import { Scene } from "babylonjs/scene";
  74081. import { Vector4 } from "babylonjs/Maths/math.vector";
  74082. import { Mesh } from "babylonjs/Meshes/mesh";
  74083. /**
  74084. * Class containing static functions to help procedurally build meshes
  74085. */
  74086. export class TiledPlaneBuilder {
  74087. /**
  74088. * Creates a tiled plane mesh
  74089. * * The parameter `pattern` will, depending on value, do nothing or
  74090. * * * flip (reflect about central vertical) alternate tiles across and up
  74091. * * * flip every tile on alternate rows
  74092. * * * rotate (180 degs) alternate tiles across and up
  74093. * * * rotate every tile on alternate rows
  74094. * * * flip and rotate alternate tiles across and up
  74095. * * * flip and rotate every tile on alternate rows
  74096. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  74097. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  74098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74099. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  74100. * * 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)
  74101. * * 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)
  74102. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  74103. * @param name defines the name of the mesh
  74104. * @param options defines the options used to create the mesh
  74105. * @param scene defines the hosting scene
  74106. * @returns the box mesh
  74107. */
  74108. static CreateTiledPlane(name: string, options: {
  74109. pattern?: number;
  74110. tileSize?: number;
  74111. tileWidth?: number;
  74112. tileHeight?: number;
  74113. size?: number;
  74114. width?: number;
  74115. height?: number;
  74116. alignHorizontal?: number;
  74117. alignVertical?: number;
  74118. sideOrientation?: number;
  74119. frontUVs?: Vector4;
  74120. backUVs?: Vector4;
  74121. updatable?: boolean;
  74122. }, scene?: Nullable<Scene>): Mesh;
  74123. }
  74124. }
  74125. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  74126. import { Nullable } from "babylonjs/types";
  74127. import { Scene } from "babylonjs/scene";
  74128. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  74129. import { Mesh } from "babylonjs/Meshes/mesh";
  74130. /**
  74131. * Class containing static functions to help procedurally build meshes
  74132. */
  74133. export class TubeBuilder {
  74134. /**
  74135. * Creates a tube mesh.
  74136. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  74137. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  74138. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  74139. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  74140. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  74141. * * 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)
  74142. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  74143. * * 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
  74144. * * 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
  74145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74146. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74147. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74149. * @param name defines the name of the mesh
  74150. * @param options defines the options used to create the mesh
  74151. * @param scene defines the hosting scene
  74152. * @returns the tube mesh
  74153. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74154. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  74155. */
  74156. static CreateTube(name: string, options: {
  74157. path: Vector3[];
  74158. radius?: number;
  74159. tessellation?: number;
  74160. radiusFunction?: {
  74161. (i: number, distance: number): number;
  74162. };
  74163. cap?: number;
  74164. arc?: number;
  74165. updatable?: boolean;
  74166. sideOrientation?: number;
  74167. frontUVs?: Vector4;
  74168. backUVs?: Vector4;
  74169. instance?: Mesh;
  74170. invertUV?: boolean;
  74171. }, scene?: Nullable<Scene>): Mesh;
  74172. }
  74173. }
  74174. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  74175. import { Scene } from "babylonjs/scene";
  74176. import { Vector4 } from "babylonjs/Maths/math.vector";
  74177. import { Mesh } from "babylonjs/Meshes/mesh";
  74178. import { Nullable } from "babylonjs/types";
  74179. /**
  74180. * Class containing static functions to help procedurally build meshes
  74181. */
  74182. export class IcoSphereBuilder {
  74183. /**
  74184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  74185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  74186. * * 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`)
  74187. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  74188. * * 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
  74189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74192. * @param name defines the name of the mesh
  74193. * @param options defines the options used to create the mesh
  74194. * @param scene defines the hosting scene
  74195. * @returns the icosahedron mesh
  74196. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  74197. */
  74198. static CreateIcoSphere(name: string, options: {
  74199. radius?: number;
  74200. radiusX?: number;
  74201. radiusY?: number;
  74202. radiusZ?: number;
  74203. flat?: boolean;
  74204. subdivisions?: number;
  74205. sideOrientation?: number;
  74206. frontUVs?: Vector4;
  74207. backUVs?: Vector4;
  74208. updatable?: boolean;
  74209. }, scene?: Nullable<Scene>): Mesh;
  74210. }
  74211. }
  74212. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  74213. import { Vector3 } from "babylonjs/Maths/math.vector";
  74214. import { Mesh } from "babylonjs/Meshes/mesh";
  74215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74216. /**
  74217. * Class containing static functions to help procedurally build meshes
  74218. */
  74219. export class DecalBuilder {
  74220. /**
  74221. * Creates a decal mesh.
  74222. * 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
  74223. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  74224. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  74225. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  74226. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  74227. * @param name defines the name of the mesh
  74228. * @param sourceMesh defines the mesh where the decal must be applied
  74229. * @param options defines the options used to create the mesh
  74230. * @param scene defines the hosting scene
  74231. * @returns the decal mesh
  74232. * @see https://doc.babylonjs.com/how_to/decals
  74233. */
  74234. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  74235. position?: Vector3;
  74236. normal?: Vector3;
  74237. size?: Vector3;
  74238. angle?: number;
  74239. }): Mesh;
  74240. }
  74241. }
  74242. declare module "babylonjs/Meshes/meshBuilder" {
  74243. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  74244. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  74245. import { Nullable } from "babylonjs/types";
  74246. import { Scene } from "babylonjs/scene";
  74247. import { Mesh } from "babylonjs/Meshes/mesh";
  74248. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  74249. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  74250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74251. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  74252. import { Plane } from "babylonjs/Maths/math.plane";
  74253. /**
  74254. * Class containing static functions to help procedurally build meshes
  74255. */
  74256. export class MeshBuilder {
  74257. /**
  74258. * Creates a box mesh
  74259. * * The parameter `size` sets the size (float) of each box side (default 1)
  74260. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  74261. * * 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)
  74262. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74266. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  74267. * @param name defines the name of the mesh
  74268. * @param options defines the options used to create the mesh
  74269. * @param scene defines the hosting scene
  74270. * @returns the box mesh
  74271. */
  74272. static CreateBox(name: string, options: {
  74273. size?: number;
  74274. width?: number;
  74275. height?: number;
  74276. depth?: number;
  74277. faceUV?: Vector4[];
  74278. faceColors?: Color4[];
  74279. sideOrientation?: number;
  74280. frontUVs?: Vector4;
  74281. backUVs?: Vector4;
  74282. wrap?: boolean;
  74283. topBaseAt?: number;
  74284. bottomBaseAt?: number;
  74285. updatable?: boolean;
  74286. }, scene?: Nullable<Scene>): Mesh;
  74287. /**
  74288. * Creates a tiled box mesh
  74289. * * faceTiles sets the pattern, tile size and number of tiles for a face
  74290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74291. * @param name defines the name of the mesh
  74292. * @param options defines the options used to create the mesh
  74293. * @param scene defines the hosting scene
  74294. * @returns the tiled box mesh
  74295. */
  74296. static CreateTiledBox(name: string, options: {
  74297. pattern?: number;
  74298. size?: number;
  74299. width?: number;
  74300. height?: number;
  74301. depth: number;
  74302. tileSize?: number;
  74303. tileWidth?: number;
  74304. tileHeight?: number;
  74305. faceUV?: Vector4[];
  74306. faceColors?: Color4[];
  74307. alignHorizontal?: number;
  74308. alignVertical?: number;
  74309. sideOrientation?: number;
  74310. updatable?: boolean;
  74311. }, scene?: Nullable<Scene>): Mesh;
  74312. /**
  74313. * Creates a sphere mesh
  74314. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  74315. * * 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`)
  74316. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  74317. * * 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
  74318. * * 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)
  74319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74322. * @param name defines the name of the mesh
  74323. * @param options defines the options used to create the mesh
  74324. * @param scene defines the hosting scene
  74325. * @returns the sphere mesh
  74326. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  74327. */
  74328. static CreateSphere(name: string, options: {
  74329. segments?: number;
  74330. diameter?: number;
  74331. diameterX?: number;
  74332. diameterY?: number;
  74333. diameterZ?: number;
  74334. arc?: number;
  74335. slice?: number;
  74336. sideOrientation?: number;
  74337. frontUVs?: Vector4;
  74338. backUVs?: Vector4;
  74339. updatable?: boolean;
  74340. }, scene?: Nullable<Scene>): Mesh;
  74341. /**
  74342. * Creates a plane polygonal mesh. By default, this is a disc
  74343. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  74344. * * 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
  74345. * * 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
  74346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74349. * @param name defines the name of the mesh
  74350. * @param options defines the options used to create the mesh
  74351. * @param scene defines the hosting scene
  74352. * @returns the plane polygonal mesh
  74353. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  74354. */
  74355. static CreateDisc(name: string, options: {
  74356. radius?: number;
  74357. tessellation?: number;
  74358. arc?: number;
  74359. updatable?: boolean;
  74360. sideOrientation?: number;
  74361. frontUVs?: Vector4;
  74362. backUVs?: Vector4;
  74363. }, scene?: Nullable<Scene>): Mesh;
  74364. /**
  74365. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  74366. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  74367. * * 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`)
  74368. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  74369. * * 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
  74370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74373. * @param name defines the name of the mesh
  74374. * @param options defines the options used to create the mesh
  74375. * @param scene defines the hosting scene
  74376. * @returns the icosahedron mesh
  74377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  74378. */
  74379. static CreateIcoSphere(name: string, options: {
  74380. radius?: number;
  74381. radiusX?: number;
  74382. radiusY?: number;
  74383. radiusZ?: number;
  74384. flat?: boolean;
  74385. subdivisions?: number;
  74386. sideOrientation?: number;
  74387. frontUVs?: Vector4;
  74388. backUVs?: Vector4;
  74389. updatable?: boolean;
  74390. }, scene?: Nullable<Scene>): Mesh;
  74391. /**
  74392. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  74393. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  74394. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  74395. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  74396. * * 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
  74397. * * 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
  74398. * * 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
  74399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74402. * * 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
  74403. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  74404. * * 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
  74405. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  74406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74407. * @param name defines the name of the mesh
  74408. * @param options defines the options used to create the mesh
  74409. * @param scene defines the hosting scene
  74410. * @returns the ribbon mesh
  74411. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  74412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74413. */
  74414. static CreateRibbon(name: string, options: {
  74415. pathArray: Vector3[][];
  74416. closeArray?: boolean;
  74417. closePath?: boolean;
  74418. offset?: number;
  74419. updatable?: boolean;
  74420. sideOrientation?: number;
  74421. frontUVs?: Vector4;
  74422. backUVs?: Vector4;
  74423. instance?: Mesh;
  74424. invertUV?: boolean;
  74425. uvs?: Vector2[];
  74426. colors?: Color4[];
  74427. }, scene?: Nullable<Scene>): Mesh;
  74428. /**
  74429. * Creates a cylinder or a cone mesh
  74430. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  74431. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  74432. * * 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.
  74433. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  74434. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  74435. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  74436. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  74437. * * 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).
  74438. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  74439. * * 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).
  74440. * * 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
  74441. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  74442. * * 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
  74443. * * 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.
  74444. * * If `enclose` is false, a ring surface is one element.
  74445. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  74446. * * 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
  74447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74450. * @param name defines the name of the mesh
  74451. * @param options defines the options used to create the mesh
  74452. * @param scene defines the hosting scene
  74453. * @returns the cylinder mesh
  74454. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  74455. */
  74456. static CreateCylinder(name: string, options: {
  74457. height?: number;
  74458. diameterTop?: number;
  74459. diameterBottom?: number;
  74460. diameter?: number;
  74461. tessellation?: number;
  74462. subdivisions?: number;
  74463. arc?: number;
  74464. faceColors?: Color4[];
  74465. faceUV?: Vector4[];
  74466. updatable?: boolean;
  74467. hasRings?: boolean;
  74468. enclose?: boolean;
  74469. cap?: number;
  74470. sideOrientation?: number;
  74471. frontUVs?: Vector4;
  74472. backUVs?: Vector4;
  74473. }, scene?: Nullable<Scene>): Mesh;
  74474. /**
  74475. * Creates a torus mesh
  74476. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  74477. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  74478. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  74479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74482. * @param name defines the name of the mesh
  74483. * @param options defines the options used to create the mesh
  74484. * @param scene defines the hosting scene
  74485. * @returns the torus mesh
  74486. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  74487. */
  74488. static CreateTorus(name: string, options: {
  74489. diameter?: number;
  74490. thickness?: number;
  74491. tessellation?: number;
  74492. updatable?: boolean;
  74493. sideOrientation?: number;
  74494. frontUVs?: Vector4;
  74495. backUVs?: Vector4;
  74496. }, scene?: Nullable<Scene>): Mesh;
  74497. /**
  74498. * Creates a torus knot mesh
  74499. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  74500. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  74501. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  74502. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  74503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74506. * @param name defines the name of the mesh
  74507. * @param options defines the options used to create the mesh
  74508. * @param scene defines the hosting scene
  74509. * @returns the torus knot mesh
  74510. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  74511. */
  74512. static CreateTorusKnot(name: string, options: {
  74513. radius?: number;
  74514. tube?: number;
  74515. radialSegments?: number;
  74516. tubularSegments?: number;
  74517. p?: number;
  74518. q?: number;
  74519. updatable?: boolean;
  74520. sideOrientation?: number;
  74521. frontUVs?: Vector4;
  74522. backUVs?: Vector4;
  74523. }, scene?: Nullable<Scene>): Mesh;
  74524. /**
  74525. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  74526. * * 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
  74527. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  74528. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  74529. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  74530. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  74531. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  74532. * * 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
  74533. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  74534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  74536. * @param name defines the name of the new line system
  74537. * @param options defines the options used to create the line system
  74538. * @param scene defines the hosting scene
  74539. * @returns a new line system mesh
  74540. */
  74541. static CreateLineSystem(name: string, options: {
  74542. lines: Vector3[][];
  74543. updatable?: boolean;
  74544. instance?: Nullable<LinesMesh>;
  74545. colors?: Nullable<Color4[][]>;
  74546. useVertexAlpha?: boolean;
  74547. }, scene: Nullable<Scene>): LinesMesh;
  74548. /**
  74549. * Creates a line mesh
  74550. * 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
  74551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  74552. * * The parameter `points` is an array successive Vector3
  74553. * * 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
  74554. * * The optional parameter `colors` is an array of successive Color4, one per line point
  74555. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  74556. * * When updating an instance, remember that only point positions can change, not the number of points
  74557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  74559. * @param name defines the name of the new line system
  74560. * @param options defines the options used to create the line system
  74561. * @param scene defines the hosting scene
  74562. * @returns a new line mesh
  74563. */
  74564. static CreateLines(name: string, options: {
  74565. points: Vector3[];
  74566. updatable?: boolean;
  74567. instance?: Nullable<LinesMesh>;
  74568. colors?: Color4[];
  74569. useVertexAlpha?: boolean;
  74570. }, scene?: Nullable<Scene>): LinesMesh;
  74571. /**
  74572. * Creates a dashed line mesh
  74573. * * 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
  74574. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  74575. * * The parameter `points` is an array successive Vector3
  74576. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  74577. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  74578. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  74579. * * 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
  74580. * * When updating an instance, remember that only point positions can change, not the number of points
  74581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74582. * @param name defines the name of the mesh
  74583. * @param options defines the options used to create the mesh
  74584. * @param scene defines the hosting scene
  74585. * @returns the dashed line mesh
  74586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  74587. */
  74588. static CreateDashedLines(name: string, options: {
  74589. points: Vector3[];
  74590. dashSize?: number;
  74591. gapSize?: number;
  74592. dashNb?: number;
  74593. updatable?: boolean;
  74594. instance?: LinesMesh;
  74595. }, scene?: Nullable<Scene>): LinesMesh;
  74596. /**
  74597. * 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.
  74598. * * 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.
  74599. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  74600. * * 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.
  74601. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  74602. * * 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
  74603. * * 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
  74604. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  74605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  74608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74609. * @param name defines the name of the mesh
  74610. * @param options defines the options used to create the mesh
  74611. * @param scene defines the hosting scene
  74612. * @returns the extruded shape mesh
  74613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  74615. */
  74616. static ExtrudeShape(name: string, options: {
  74617. shape: Vector3[];
  74618. path: Vector3[];
  74619. scale?: number;
  74620. rotation?: number;
  74621. cap?: number;
  74622. updatable?: boolean;
  74623. sideOrientation?: number;
  74624. frontUVs?: Vector4;
  74625. backUVs?: Vector4;
  74626. instance?: Mesh;
  74627. invertUV?: boolean;
  74628. }, scene?: Nullable<Scene>): Mesh;
  74629. /**
  74630. * Creates an custom extruded shape mesh.
  74631. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  74632. * * 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.
  74633. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  74634. * * 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 beginning of the path
  74635. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  74636. * * 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
  74637. * * It must returns a float value that will be the scale value applied to the shape on each path point
  74638. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  74639. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  74640. * * 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
  74641. * * 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
  74642. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  74643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74645. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74647. * @param name defines the name of the mesh
  74648. * @param options defines the options used to create the mesh
  74649. * @param scene defines the hosting scene
  74650. * @returns the custom extruded shape mesh
  74651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  74652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  74654. */
  74655. static ExtrudeShapeCustom(name: string, options: {
  74656. shape: Vector3[];
  74657. path: Vector3[];
  74658. scaleFunction?: any;
  74659. rotationFunction?: any;
  74660. ribbonCloseArray?: boolean;
  74661. ribbonClosePath?: boolean;
  74662. cap?: number;
  74663. updatable?: boolean;
  74664. sideOrientation?: number;
  74665. frontUVs?: Vector4;
  74666. backUVs?: Vector4;
  74667. instance?: Mesh;
  74668. invertUV?: boolean;
  74669. }, scene?: Nullable<Scene>): Mesh;
  74670. /**
  74671. * Creates lathe mesh.
  74672. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  74673. * * 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
  74674. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  74675. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  74676. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  74677. * * 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
  74678. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  74679. * * 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
  74680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74684. * @param name defines the name of the mesh
  74685. * @param options defines the options used to create the mesh
  74686. * @param scene defines the hosting scene
  74687. * @returns the lathe mesh
  74688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  74689. */
  74690. static CreateLathe(name: string, options: {
  74691. shape: Vector3[];
  74692. radius?: number;
  74693. tessellation?: number;
  74694. clip?: number;
  74695. arc?: number;
  74696. closed?: boolean;
  74697. updatable?: boolean;
  74698. sideOrientation?: number;
  74699. frontUVs?: Vector4;
  74700. backUVs?: Vector4;
  74701. cap?: number;
  74702. invertUV?: boolean;
  74703. }, scene?: Nullable<Scene>): Mesh;
  74704. /**
  74705. * Creates a tiled plane mesh
  74706. * * You can set a limited pattern arrangement with the tiles
  74707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74710. * @param name defines the name of the mesh
  74711. * @param options defines the options used to create the mesh
  74712. * @param scene defines the hosting scene
  74713. * @returns the plane mesh
  74714. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  74715. */
  74716. static CreateTiledPlane(name: string, options: {
  74717. pattern?: number;
  74718. tileSize?: number;
  74719. tileWidth?: number;
  74720. tileHeight?: number;
  74721. size?: number;
  74722. width?: number;
  74723. height?: number;
  74724. alignHorizontal?: number;
  74725. alignVertical?: number;
  74726. sideOrientation?: number;
  74727. frontUVs?: Vector4;
  74728. backUVs?: Vector4;
  74729. updatable?: boolean;
  74730. }, scene?: Nullable<Scene>): Mesh;
  74731. /**
  74732. * Creates a plane mesh
  74733. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  74734. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  74735. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  74736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74739. * @param name defines the name of the mesh
  74740. * @param options defines the options used to create the mesh
  74741. * @param scene defines the hosting scene
  74742. * @returns the plane mesh
  74743. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  74744. */
  74745. static CreatePlane(name: string, options: {
  74746. size?: number;
  74747. width?: number;
  74748. height?: number;
  74749. sideOrientation?: number;
  74750. frontUVs?: Vector4;
  74751. backUVs?: Vector4;
  74752. updatable?: boolean;
  74753. sourcePlane?: Plane;
  74754. }, scene?: Nullable<Scene>): Mesh;
  74755. /**
  74756. * Creates a ground mesh
  74757. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  74758. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  74759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74760. * @param name defines the name of the mesh
  74761. * @param options defines the options used to create the mesh
  74762. * @param scene defines the hosting scene
  74763. * @returns the ground mesh
  74764. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  74765. */
  74766. static CreateGround(name: string, options: {
  74767. width?: number;
  74768. height?: number;
  74769. subdivisions?: number;
  74770. subdivisionsX?: number;
  74771. subdivisionsY?: number;
  74772. updatable?: boolean;
  74773. }, scene?: Nullable<Scene>): Mesh;
  74774. /**
  74775. * Creates a tiled ground mesh
  74776. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  74777. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  74778. * * 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
  74779. * * 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
  74780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74781. * @param name defines the name of the mesh
  74782. * @param options defines the options used to create the mesh
  74783. * @param scene defines the hosting scene
  74784. * @returns the tiled ground mesh
  74785. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  74786. */
  74787. static CreateTiledGround(name: string, options: {
  74788. xmin: number;
  74789. zmin: number;
  74790. xmax: number;
  74791. zmax: number;
  74792. subdivisions?: {
  74793. w: number;
  74794. h: number;
  74795. };
  74796. precision?: {
  74797. w: number;
  74798. h: number;
  74799. };
  74800. updatable?: boolean;
  74801. }, scene?: Nullable<Scene>): Mesh;
  74802. /**
  74803. * Creates a ground mesh from a height map
  74804. * * The parameter `url` sets the URL of the height map image resource.
  74805. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  74806. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  74807. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  74808. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  74809. * * 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.
  74810. * * 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).
  74811. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  74812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  74813. * @param name defines the name of the mesh
  74814. * @param url defines the url to the height map
  74815. * @param options defines the options used to create the mesh
  74816. * @param scene defines the hosting scene
  74817. * @returns the ground mesh
  74818. * @see https://doc.babylonjs.com/babylon101/height_map
  74819. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  74820. */
  74821. static CreateGroundFromHeightMap(name: string, url: string, options: {
  74822. width?: number;
  74823. height?: number;
  74824. subdivisions?: number;
  74825. minHeight?: number;
  74826. maxHeight?: number;
  74827. colorFilter?: Color3;
  74828. alphaFilter?: number;
  74829. updatable?: boolean;
  74830. onReady?: (mesh: GroundMesh) => void;
  74831. }, scene?: Nullable<Scene>): GroundMesh;
  74832. /**
  74833. * Creates a polygon mesh
  74834. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  74835. * * 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
  74836. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  74837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  74839. * * Remember you can only change the shape positions, not their number when updating a polygon
  74840. * @param name defines the name of the mesh
  74841. * @param options defines the options used to create the mesh
  74842. * @param scene defines the hosting scene
  74843. * @param earcutInjection can be used to inject your own earcut reference
  74844. * @returns the polygon mesh
  74845. */
  74846. static CreatePolygon(name: string, options: {
  74847. shape: Vector3[];
  74848. holes?: Vector3[][];
  74849. depth?: number;
  74850. faceUV?: Vector4[];
  74851. faceColors?: Color4[];
  74852. updatable?: boolean;
  74853. sideOrientation?: number;
  74854. frontUVs?: Vector4;
  74855. backUVs?: Vector4;
  74856. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74857. /**
  74858. * Creates an extruded polygon mesh, with depth in the Y direction.
  74859. * * 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)
  74860. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74861. * @param name defines the name of the mesh
  74862. * @param options defines the options used to create the mesh
  74863. * @param scene defines the hosting scene
  74864. * @param earcutInjection can be used to inject your own earcut reference
  74865. * @returns the polygon mesh
  74866. */
  74867. static ExtrudePolygon(name: string, options: {
  74868. shape: Vector3[];
  74869. holes?: Vector3[][];
  74870. depth?: number;
  74871. faceUV?: Vector4[];
  74872. faceColors?: Color4[];
  74873. updatable?: boolean;
  74874. sideOrientation?: number;
  74875. frontUVs?: Vector4;
  74876. backUVs?: Vector4;
  74877. wrap?: boolean;
  74878. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74879. /**
  74880. * Creates a tube mesh.
  74881. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  74882. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  74883. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  74884. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  74885. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  74886. * * 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)
  74887. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  74888. * * 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
  74889. * * 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
  74890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74894. * @param name defines the name of the mesh
  74895. * @param options defines the options used to create the mesh
  74896. * @param scene defines the hosting scene
  74897. * @returns the tube mesh
  74898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74899. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  74900. */
  74901. static CreateTube(name: string, options: {
  74902. path: Vector3[];
  74903. radius?: number;
  74904. tessellation?: number;
  74905. radiusFunction?: {
  74906. (i: number, distance: number): number;
  74907. };
  74908. cap?: number;
  74909. arc?: number;
  74910. updatable?: boolean;
  74911. sideOrientation?: number;
  74912. frontUVs?: Vector4;
  74913. backUVs?: Vector4;
  74914. instance?: Mesh;
  74915. invertUV?: boolean;
  74916. }, scene?: Nullable<Scene>): Mesh;
  74917. /**
  74918. * Creates a polyhedron mesh
  74919. * * 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
  74920. * * The parameter `size` (positive float, default 1) sets the polygon size
  74921. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  74922. * * 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`
  74923. * * 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
  74924. * * 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)`)
  74925. * * 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
  74926. * * 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
  74927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74930. * @param name defines the name of the mesh
  74931. * @param options defines the options used to create the mesh
  74932. * @param scene defines the hosting scene
  74933. * @returns the polyhedron mesh
  74934. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  74935. */
  74936. static CreatePolyhedron(name: string, options: {
  74937. type?: number;
  74938. size?: number;
  74939. sizeX?: number;
  74940. sizeY?: number;
  74941. sizeZ?: number;
  74942. custom?: any;
  74943. faceUV?: Vector4[];
  74944. faceColors?: Color4[];
  74945. flat?: boolean;
  74946. updatable?: boolean;
  74947. sideOrientation?: number;
  74948. frontUVs?: Vector4;
  74949. backUVs?: Vector4;
  74950. }, scene?: Nullable<Scene>): Mesh;
  74951. /**
  74952. * Creates a decal mesh.
  74953. * 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
  74954. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  74955. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  74956. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  74957. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  74958. * @param name defines the name of the mesh
  74959. * @param sourceMesh defines the mesh where the decal must be applied
  74960. * @param options defines the options used to create the mesh
  74961. * @param scene defines the hosting scene
  74962. * @returns the decal mesh
  74963. * @see https://doc.babylonjs.com/how_to/decals
  74964. */
  74965. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  74966. position?: Vector3;
  74967. normal?: Vector3;
  74968. size?: Vector3;
  74969. angle?: number;
  74970. }): Mesh;
  74971. /**
  74972. * Creates a Capsule Mesh
  74973. * @param name defines the name of the mesh.
  74974. * @param options the constructors options used to shape the mesh.
  74975. * @param scene defines the scene the mesh is scoped to.
  74976. * @returns the capsule mesh
  74977. * @see https://doc.babylonjs.com/how_to/capsule_shape
  74978. */
  74979. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  74980. }
  74981. }
  74982. declare module "babylonjs/Meshes/meshSimplification" {
  74983. import { Mesh } from "babylonjs/Meshes/mesh";
  74984. /**
  74985. * A simplifier interface for future simplification implementations
  74986. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74987. */
  74988. export interface ISimplifier {
  74989. /**
  74990. * Simplification of a given mesh according to the given settings.
  74991. * Since this requires computation, it is assumed that the function runs async.
  74992. * @param settings The settings of the simplification, including quality and distance
  74993. * @param successCallback A callback that will be called after the mesh was simplified.
  74994. * @param errorCallback in case of an error, this callback will be called. optional.
  74995. */
  74996. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  74997. }
  74998. /**
  74999. * Expected simplification settings.
  75000. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  75001. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  75002. */
  75003. export interface ISimplificationSettings {
  75004. /**
  75005. * Gets or sets the expected quality
  75006. */
  75007. quality: number;
  75008. /**
  75009. * Gets or sets the distance when this optimized version should be used
  75010. */
  75011. distance: number;
  75012. /**
  75013. * Gets an already optimized mesh
  75014. */
  75015. optimizeMesh?: boolean;
  75016. }
  75017. /**
  75018. * Class used to specify simplification options
  75019. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  75020. */
  75021. export class SimplificationSettings implements ISimplificationSettings {
  75022. /** expected quality */
  75023. quality: number;
  75024. /** distance when this optimized version should be used */
  75025. distance: number;
  75026. /** already optimized mesh */
  75027. optimizeMesh?: boolean | undefined;
  75028. /**
  75029. * Creates a SimplificationSettings
  75030. * @param quality expected quality
  75031. * @param distance distance when this optimized version should be used
  75032. * @param optimizeMesh already optimized mesh
  75033. */
  75034. constructor(
  75035. /** expected quality */
  75036. quality: number,
  75037. /** distance when this optimized version should be used */
  75038. distance: number,
  75039. /** already optimized mesh */
  75040. optimizeMesh?: boolean | undefined);
  75041. }
  75042. /**
  75043. * Interface used to define a simplification task
  75044. */
  75045. export interface ISimplificationTask {
  75046. /**
  75047. * Array of settings
  75048. */
  75049. settings: Array<ISimplificationSettings>;
  75050. /**
  75051. * Simplification type
  75052. */
  75053. simplificationType: SimplificationType;
  75054. /**
  75055. * Mesh to simplify
  75056. */
  75057. mesh: Mesh;
  75058. /**
  75059. * Callback called on success
  75060. */
  75061. successCallback?: () => void;
  75062. /**
  75063. * Defines if parallel processing can be used
  75064. */
  75065. parallelProcessing: boolean;
  75066. }
  75067. /**
  75068. * Queue used to order the simplification tasks
  75069. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  75070. */
  75071. export class SimplificationQueue {
  75072. private _simplificationArray;
  75073. /**
  75074. * Gets a boolean indicating that the process is still running
  75075. */
  75076. running: boolean;
  75077. /**
  75078. * Creates a new queue
  75079. */
  75080. constructor();
  75081. /**
  75082. * Adds a new simplification task
  75083. * @param task defines a task to add
  75084. */
  75085. addTask(task: ISimplificationTask): void;
  75086. /**
  75087. * Execute next task
  75088. */
  75089. executeNext(): void;
  75090. /**
  75091. * Execute a simplification task
  75092. * @param task defines the task to run
  75093. */
  75094. runSimplification(task: ISimplificationTask): void;
  75095. private getSimplifier;
  75096. }
  75097. /**
  75098. * The implemented types of simplification
  75099. * At the moment only Quadratic Error Decimation is implemented
  75100. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  75101. */
  75102. export enum SimplificationType {
  75103. /** Quadratic error decimation */
  75104. QUADRATIC = 0
  75105. }
  75106. /**
  75107. * An implementation of the Quadratic Error simplification algorithm.
  75108. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  75109. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  75110. * @author RaananW
  75111. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  75112. */
  75113. export class QuadraticErrorSimplification implements ISimplifier {
  75114. private _mesh;
  75115. private triangles;
  75116. private vertices;
  75117. private references;
  75118. private _reconstructedMesh;
  75119. /** Gets or sets the number pf sync iterations */
  75120. syncIterations: number;
  75121. /** Gets or sets the aggressiveness of the simplifier */
  75122. aggressiveness: number;
  75123. /** Gets or sets the number of allowed iterations for decimation */
  75124. decimationIterations: number;
  75125. /** Gets or sets the espilon to use for bounding box computation */
  75126. boundingBoxEpsilon: number;
  75127. /**
  75128. * Creates a new QuadraticErrorSimplification
  75129. * @param _mesh defines the target mesh
  75130. */
  75131. constructor(_mesh: Mesh);
  75132. /**
  75133. * Simplification of a given mesh according to the given settings.
  75134. * Since this requires computation, it is assumed that the function runs async.
  75135. * @param settings The settings of the simplification, including quality and distance
  75136. * @param successCallback A callback that will be called after the mesh was simplified.
  75137. */
  75138. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  75139. private runDecimation;
  75140. private initWithMesh;
  75141. private init;
  75142. private reconstructMesh;
  75143. private initDecimatedMesh;
  75144. private isFlipped;
  75145. private updateTriangles;
  75146. private identifyBorder;
  75147. private updateMesh;
  75148. private vertexError;
  75149. private calculateError;
  75150. }
  75151. }
  75152. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  75153. import { Scene } from "babylonjs/scene";
  75154. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  75155. import { ISceneComponent } from "babylonjs/sceneComponent";
  75156. module "babylonjs/scene" {
  75157. interface Scene {
  75158. /** @hidden (Backing field) */
  75159. _simplificationQueue: SimplificationQueue;
  75160. /**
  75161. * Gets or sets the simplification queue attached to the scene
  75162. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  75163. */
  75164. simplificationQueue: SimplificationQueue;
  75165. }
  75166. }
  75167. module "babylonjs/Meshes/mesh" {
  75168. interface Mesh {
  75169. /**
  75170. * Simplify the mesh according to the given array of settings.
  75171. * Function will return immediately and will simplify async
  75172. * @param settings a collection of simplification settings
  75173. * @param parallelProcessing should all levels calculate parallel or one after the other
  75174. * @param simplificationType the type of simplification to run
  75175. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  75176. * @returns the current mesh
  75177. */
  75178. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  75179. }
  75180. }
  75181. /**
  75182. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  75183. * created in a scene
  75184. */
  75185. export class SimplicationQueueSceneComponent implements ISceneComponent {
  75186. /**
  75187. * The component name helpfull to identify the component in the list of scene components.
  75188. */
  75189. readonly name: string;
  75190. /**
  75191. * The scene the component belongs to.
  75192. */
  75193. scene: Scene;
  75194. /**
  75195. * Creates a new instance of the component for the given scene
  75196. * @param scene Defines the scene to register the component in
  75197. */
  75198. constructor(scene: Scene);
  75199. /**
  75200. * Registers the component in a given scene
  75201. */
  75202. register(): void;
  75203. /**
  75204. * Rebuilds the elements related to this component in case of
  75205. * context lost for instance.
  75206. */
  75207. rebuild(): void;
  75208. /**
  75209. * Disposes the component and the associated resources
  75210. */
  75211. dispose(): void;
  75212. private _beforeCameraUpdate;
  75213. }
  75214. }
  75215. declare module "babylonjs/Meshes/Builders/index" {
  75216. export * from "babylonjs/Meshes/Builders/boxBuilder";
  75217. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  75218. export * from "babylonjs/Meshes/Builders/discBuilder";
  75219. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  75220. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  75221. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  75222. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  75223. export * from "babylonjs/Meshes/Builders/torusBuilder";
  75224. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  75225. export * from "babylonjs/Meshes/Builders/linesBuilder";
  75226. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  75227. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  75228. export * from "babylonjs/Meshes/Builders/latheBuilder";
  75229. export * from "babylonjs/Meshes/Builders/planeBuilder";
  75230. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  75231. export * from "babylonjs/Meshes/Builders/groundBuilder";
  75232. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  75233. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  75234. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  75235. export * from "babylonjs/Meshes/Builders/decalBuilder";
  75236. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  75237. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  75238. }
  75239. declare module "babylonjs/Meshes/thinInstanceMesh" {
  75240. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  75241. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  75242. import { Matrix } from "babylonjs/Maths/math.vector";
  75243. module "babylonjs/Meshes/mesh" {
  75244. interface Mesh {
  75245. /**
  75246. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  75247. */
  75248. thinInstanceEnablePicking: boolean;
  75249. /**
  75250. * Creates a new thin instance
  75251. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  75252. * @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
  75253. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  75254. */
  75255. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  75256. /**
  75257. * Adds the transformation (matrix) of the current mesh as a thin instance
  75258. * @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
  75259. * @returns the thin instance index number
  75260. */
  75261. thinInstanceAddSelf(refresh: boolean): number;
  75262. /**
  75263. * Registers a custom attribute to be used with thin instances
  75264. * @param kind name of the attribute
  75265. * @param stride size in floats of the attribute
  75266. */
  75267. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  75268. /**
  75269. * Sets the matrix of a thin instance
  75270. * @param index index of the thin instance
  75271. * @param matrix matrix to set
  75272. * @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
  75273. */
  75274. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  75275. /**
  75276. * Sets the value of a custom attribute for a thin instance
  75277. * @param kind name of the attribute
  75278. * @param index index of the thin instance
  75279. * @param value value to set
  75280. * @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
  75281. */
  75282. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  75283. /**
  75284. * 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.
  75285. */
  75286. thinInstanceCount: number;
  75287. /**
  75288. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  75289. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  75290. * @param buffer buffer to set
  75291. * @param stride size in floats of each value of the buffer
  75292. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  75293. */
  75294. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  75295. /**
  75296. * Gets the list of world matrices
  75297. * @return an array containing all the world matrices from the thin instances
  75298. */
  75299. thinInstanceGetWorldMatrices(): Matrix[];
  75300. /**
  75301. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  75302. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  75303. */
  75304. thinInstanceBufferUpdated(kind: string): void;
  75305. /**
  75306. * Applies a partial update to a buffer directly on the GPU
  75307. * 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
  75308. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  75309. * @param data the data to set in the GPU buffer
  75310. * @param offset the offset in the GPU buffer where to update the data
  75311. */
  75312. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  75313. /**
  75314. * Refreshes the bounding info, taking into account all the thin instances defined
  75315. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  75316. */
  75317. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  75318. /** @hidden */
  75319. _thinInstanceInitializeUserStorage(): void;
  75320. /** @hidden */
  75321. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  75322. /** @hidden */
  75323. _userThinInstanceBuffersStorage: {
  75324. data: {
  75325. [key: string]: Float32Array;
  75326. };
  75327. sizes: {
  75328. [key: string]: number;
  75329. };
  75330. vertexBuffers: {
  75331. [key: string]: Nullable<VertexBuffer>;
  75332. };
  75333. strides: {
  75334. [key: string]: number;
  75335. };
  75336. };
  75337. }
  75338. }
  75339. }
  75340. declare module "babylonjs/Meshes/index" {
  75341. export * from "babylonjs/Meshes/abstractMesh";
  75342. export * from "babylonjs/Meshes/buffer";
  75343. export * from "babylonjs/Meshes/Compression/index";
  75344. export * from "babylonjs/Meshes/csg";
  75345. export * from "babylonjs/Meshes/geometry";
  75346. export * from "babylonjs/Meshes/groundMesh";
  75347. export * from "babylonjs/Meshes/trailMesh";
  75348. export * from "babylonjs/Meshes/instancedMesh";
  75349. export * from "babylonjs/Meshes/linesMesh";
  75350. export * from "babylonjs/Meshes/mesh";
  75351. export * from "babylonjs/Meshes/mesh.vertexData";
  75352. export * from "babylonjs/Meshes/meshBuilder";
  75353. export * from "babylonjs/Meshes/meshSimplification";
  75354. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  75355. export * from "babylonjs/Meshes/polygonMesh";
  75356. export * from "babylonjs/Meshes/subMesh";
  75357. export * from "babylonjs/Meshes/meshLODLevel";
  75358. export * from "babylonjs/Meshes/transformNode";
  75359. export * from "babylonjs/Meshes/Builders/index";
  75360. export * from "babylonjs/Meshes/dataBuffer";
  75361. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  75362. export * from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  75363. import "babylonjs/Meshes/thinInstanceMesh";
  75364. export * from "babylonjs/Meshes/thinInstanceMesh";
  75365. }
  75366. declare module "babylonjs/Morph/index" {
  75367. export * from "babylonjs/Morph/morphTarget";
  75368. export * from "babylonjs/Morph/morphTargetManager";
  75369. }
  75370. declare module "babylonjs/Navigation/INavigationEngine" {
  75371. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75372. import { Vector3 } from "babylonjs/Maths/math";
  75373. import { Mesh } from "babylonjs/Meshes/mesh";
  75374. import { Scene } from "babylonjs/scene";
  75375. /**
  75376. * Navigation plugin interface to add navigation constrained by a navigation mesh
  75377. */
  75378. export interface INavigationEnginePlugin {
  75379. /**
  75380. * plugin name
  75381. */
  75382. name: string;
  75383. /**
  75384. * Creates a navigation mesh
  75385. * @param meshes array of all the geometry used to compute the navigation mesh
  75386. * @param parameters bunch of parameters used to filter geometry
  75387. */
  75388. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  75389. /**
  75390. * Create a navigation mesh debug mesh
  75391. * @param scene is where the mesh will be added
  75392. * @returns debug display mesh
  75393. */
  75394. createDebugNavMesh(scene: Scene): Mesh;
  75395. /**
  75396. * Get a navigation mesh constrained position, closest to the parameter position
  75397. * @param position world position
  75398. * @returns the closest point to position constrained by the navigation mesh
  75399. */
  75400. getClosestPoint(position: Vector3): Vector3;
  75401. /**
  75402. * Get a navigation mesh constrained position, closest to the parameter position
  75403. * @param position world position
  75404. * @param result output the closest point to position constrained by the navigation mesh
  75405. */
  75406. getClosestPointToRef(position: Vector3, result: Vector3): void;
  75407. /**
  75408. * Get a navigation mesh constrained position, within a particular radius
  75409. * @param position world position
  75410. * @param maxRadius the maximum distance to the constrained world position
  75411. * @returns the closest point to position constrained by the navigation mesh
  75412. */
  75413. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  75414. /**
  75415. * Get a navigation mesh constrained position, within a particular radius
  75416. * @param position world position
  75417. * @param maxRadius the maximum distance to the constrained world position
  75418. * @param result output the closest point to position constrained by the navigation mesh
  75419. */
  75420. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  75421. /**
  75422. * Compute the final position from a segment made of destination-position
  75423. * @param position world position
  75424. * @param destination world position
  75425. * @returns the resulting point along the navmesh
  75426. */
  75427. moveAlong(position: Vector3, destination: Vector3): Vector3;
  75428. /**
  75429. * Compute the final position from a segment made of destination-position
  75430. * @param position world position
  75431. * @param destination world position
  75432. * @param result output the resulting point along the navmesh
  75433. */
  75434. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  75435. /**
  75436. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  75437. * @param start world position
  75438. * @param end world position
  75439. * @returns array containing world position composing the path
  75440. */
  75441. computePath(start: Vector3, end: Vector3): Vector3[];
  75442. /**
  75443. * If this plugin is supported
  75444. * @returns true if plugin is supported
  75445. */
  75446. isSupported(): boolean;
  75447. /**
  75448. * Create a new Crowd so you can add agents
  75449. * @param maxAgents the maximum agent count in the crowd
  75450. * @param maxAgentRadius the maximum radius an agent can have
  75451. * @param scene to attach the crowd to
  75452. * @returns the crowd you can add agents to
  75453. */
  75454. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  75455. /**
  75456. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75457. * The queries will try to find a solution within those bounds
  75458. * default is (1,1,1)
  75459. * @param extent x,y,z value that define the extent around the queries point of reference
  75460. */
  75461. setDefaultQueryExtent(extent: Vector3): void;
  75462. /**
  75463. * Get the Bounding box extent specified by setDefaultQueryExtent
  75464. * @returns the box extent values
  75465. */
  75466. getDefaultQueryExtent(): Vector3;
  75467. /**
  75468. * build the navmesh from a previously saved state using getNavmeshData
  75469. * @param data the Uint8Array returned by getNavmeshData
  75470. */
  75471. buildFromNavmeshData(data: Uint8Array): void;
  75472. /**
  75473. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  75474. * @returns data the Uint8Array that can be saved and reused
  75475. */
  75476. getNavmeshData(): Uint8Array;
  75477. /**
  75478. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75479. * @param result output the box extent values
  75480. */
  75481. getDefaultQueryExtentToRef(result: Vector3): void;
  75482. /**
  75483. * Set the time step of the navigation tick update.
  75484. * Default is 1/60.
  75485. * A value of 0 will disable fixed time update
  75486. * @param newTimeStep the new timestep to apply to this world.
  75487. */
  75488. setTimeStep(newTimeStep: number): void;
  75489. /**
  75490. * Get the time step of the navigation tick update.
  75491. * @returns the current time step
  75492. */
  75493. getTimeStep(): number;
  75494. /**
  75495. * If delta time in navigation tick update is greater than the time step
  75496. * a number of sub iterations are done. If more iterations are need to reach deltatime
  75497. * they will be discarded.
  75498. * A value of 0 will set to no maximum and update will use as many substeps as needed
  75499. * @param newStepCount the maximum number of iterations
  75500. */
  75501. setMaximumSubStepCount(newStepCount: number): void;
  75502. /**
  75503. * Get the maximum number of iterations per navigation tick update
  75504. * @returns the maximum number of iterations
  75505. */
  75506. getMaximumSubStepCount(): number;
  75507. /**
  75508. * Release all resources
  75509. */
  75510. dispose(): void;
  75511. }
  75512. /**
  75513. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  75514. */
  75515. export interface ICrowd {
  75516. /**
  75517. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  75518. * You can attach anything to that node. The node position is updated in the scene update tick.
  75519. * @param pos world position that will be constrained by the navigation mesh
  75520. * @param parameters agent parameters
  75521. * @param transform hooked to the agent that will be update by the scene
  75522. * @returns agent index
  75523. */
  75524. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  75525. /**
  75526. * Returns the agent position in world space
  75527. * @param index agent index returned by addAgent
  75528. * @returns world space position
  75529. */
  75530. getAgentPosition(index: number): Vector3;
  75531. /**
  75532. * Gets the agent position result in world space
  75533. * @param index agent index returned by addAgent
  75534. * @param result output world space position
  75535. */
  75536. getAgentPositionToRef(index: number, result: Vector3): void;
  75537. /**
  75538. * Gets the agent velocity in world space
  75539. * @param index agent index returned by addAgent
  75540. * @returns world space velocity
  75541. */
  75542. getAgentVelocity(index: number): Vector3;
  75543. /**
  75544. * Gets the agent velocity result in world space
  75545. * @param index agent index returned by addAgent
  75546. * @param result output world space velocity
  75547. */
  75548. getAgentVelocityToRef(index: number, result: Vector3): void;
  75549. /**
  75550. * Gets the agent next target point on the path
  75551. * @param index agent index returned by addAgent
  75552. * @returns world space position
  75553. */
  75554. getAgentNextTargetPath(index: number): Vector3;
  75555. /**
  75556. * Gets the agent state
  75557. * @param index agent index returned by addAgent
  75558. * @returns agent state
  75559. */
  75560. getAgentState(index: number): number;
  75561. /**
  75562. * returns true if the agent in over an off mesh link connection
  75563. * @param index agent index returned by addAgent
  75564. * @returns true if over an off mesh link connection
  75565. */
  75566. overOffmeshConnection(index: number): boolean;
  75567. /**
  75568. * Gets the agent next target point on the path
  75569. * @param index agent index returned by addAgent
  75570. * @param result output world space position
  75571. */
  75572. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  75573. /**
  75574. * remove a particular agent previously created
  75575. * @param index agent index returned by addAgent
  75576. */
  75577. removeAgent(index: number): void;
  75578. /**
  75579. * get the list of all agents attached to this crowd
  75580. * @returns list of agent indices
  75581. */
  75582. getAgents(): number[];
  75583. /**
  75584. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  75585. * @param deltaTime in seconds
  75586. */
  75587. update(deltaTime: number): void;
  75588. /**
  75589. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  75590. * @param index agent index returned by addAgent
  75591. * @param destination targeted world position
  75592. */
  75593. agentGoto(index: number, destination: Vector3): void;
  75594. /**
  75595. * Teleport the agent to a new position
  75596. * @param index agent index returned by addAgent
  75597. * @param destination targeted world position
  75598. */
  75599. agentTeleport(index: number, destination: Vector3): void;
  75600. /**
  75601. * Update agent parameters
  75602. * @param index agent index returned by addAgent
  75603. * @param parameters agent parameters
  75604. */
  75605. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  75606. /**
  75607. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75608. * The queries will try to find a solution within those bounds
  75609. * default is (1,1,1)
  75610. * @param extent x,y,z value that define the extent around the queries point of reference
  75611. */
  75612. setDefaultQueryExtent(extent: Vector3): void;
  75613. /**
  75614. * Get the Bounding box extent specified by setDefaultQueryExtent
  75615. * @returns the box extent values
  75616. */
  75617. getDefaultQueryExtent(): Vector3;
  75618. /**
  75619. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75620. * @param result output the box extent values
  75621. */
  75622. getDefaultQueryExtentToRef(result: Vector3): void;
  75623. /**
  75624. * Release all resources
  75625. */
  75626. dispose(): void;
  75627. }
  75628. /**
  75629. * Configures an agent
  75630. */
  75631. export interface IAgentParameters {
  75632. /**
  75633. * Agent radius. [Limit: >= 0]
  75634. */
  75635. radius: number;
  75636. /**
  75637. * Agent height. [Limit: > 0]
  75638. */
  75639. height: number;
  75640. /**
  75641. * Maximum allowed acceleration. [Limit: >= 0]
  75642. */
  75643. maxAcceleration: number;
  75644. /**
  75645. * Maximum allowed speed. [Limit: >= 0]
  75646. */
  75647. maxSpeed: number;
  75648. /**
  75649. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  75650. */
  75651. collisionQueryRange: number;
  75652. /**
  75653. * The path visibility optimization range. [Limit: > 0]
  75654. */
  75655. pathOptimizationRange: number;
  75656. /**
  75657. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  75658. */
  75659. separationWeight: number;
  75660. }
  75661. /**
  75662. * Configures the navigation mesh creation
  75663. */
  75664. export interface INavMeshParameters {
  75665. /**
  75666. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  75667. */
  75668. cs: number;
  75669. /**
  75670. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  75671. */
  75672. ch: number;
  75673. /**
  75674. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  75675. */
  75676. walkableSlopeAngle: number;
  75677. /**
  75678. * Minimum floor to 'ceiling' height that will still allow the floor area to
  75679. * be considered walkable. [Limit: >= 3] [Units: vx]
  75680. */
  75681. walkableHeight: number;
  75682. /**
  75683. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  75684. */
  75685. walkableClimb: number;
  75686. /**
  75687. * The distance to erode/shrink the walkable area of the heightfield away from
  75688. * obstructions. [Limit: >=0] [Units: vx]
  75689. */
  75690. walkableRadius: number;
  75691. /**
  75692. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  75693. */
  75694. maxEdgeLen: number;
  75695. /**
  75696. * The maximum distance a simplified contour's border edges should deviate
  75697. * the original raw contour. [Limit: >=0] [Units: vx]
  75698. */
  75699. maxSimplificationError: number;
  75700. /**
  75701. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  75702. */
  75703. minRegionArea: number;
  75704. /**
  75705. * Any regions with a span count smaller than this value will, if possible,
  75706. * be merged with larger regions. [Limit: >=0] [Units: vx]
  75707. */
  75708. mergeRegionArea: number;
  75709. /**
  75710. * The maximum number of vertices allowed for polygons generated during the
  75711. * contour to polygon conversion process. [Limit: >= 3]
  75712. */
  75713. maxVertsPerPoly: number;
  75714. /**
  75715. * Sets the sampling distance to use when generating the detail mesh.
  75716. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  75717. */
  75718. detailSampleDist: number;
  75719. /**
  75720. * The maximum distance the detail mesh surface should deviate from heightfield
  75721. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  75722. */
  75723. detailSampleMaxError: number;
  75724. }
  75725. }
  75726. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  75727. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  75728. import { Mesh } from "babylonjs/Meshes/mesh";
  75729. import { Scene } from "babylonjs/scene";
  75730. import { Vector3 } from "babylonjs/Maths/math";
  75731. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75732. /**
  75733. * RecastJS navigation plugin
  75734. */
  75735. export class RecastJSPlugin implements INavigationEnginePlugin {
  75736. /**
  75737. * Reference to the Recast library
  75738. */
  75739. bjsRECAST: any;
  75740. /**
  75741. * plugin name
  75742. */
  75743. name: string;
  75744. /**
  75745. * the first navmesh created. We might extend this to support multiple navmeshes
  75746. */
  75747. navMesh: any;
  75748. private _maximumSubStepCount;
  75749. private _timeStep;
  75750. /**
  75751. * Initializes the recastJS plugin
  75752. * @param recastInjection can be used to inject your own recast reference
  75753. */
  75754. constructor(recastInjection?: any);
  75755. /**
  75756. * Set the time step of the navigation tick update.
  75757. * Default is 1/60.
  75758. * A value of 0 will disable fixed time update
  75759. * @param newTimeStep the new timestep to apply to this world.
  75760. */
  75761. setTimeStep(newTimeStep?: number): void;
  75762. /**
  75763. * Get the time step of the navigation tick update.
  75764. * @returns the current time step
  75765. */
  75766. getTimeStep(): number;
  75767. /**
  75768. * If delta time in navigation tick update is greater than the time step
  75769. * a number of sub iterations are done. If more iterations are need to reach deltatime
  75770. * they will be discarded.
  75771. * A value of 0 will set to no maximum and update will use as many substeps as needed
  75772. * @param newStepCount the maximum number of iterations
  75773. */
  75774. setMaximumSubStepCount(newStepCount?: number): void;
  75775. /**
  75776. * Get the maximum number of iterations per navigation tick update
  75777. * @returns the maximum number of iterations
  75778. */
  75779. getMaximumSubStepCount(): number;
  75780. /**
  75781. * Creates a navigation mesh
  75782. * @param meshes array of all the geometry used to compute the navigation mesh
  75783. * @param parameters bunch of parameters used to filter geometry
  75784. */
  75785. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  75786. /**
  75787. * Create a navigation mesh debug mesh
  75788. * @param scene is where the mesh will be added
  75789. * @returns debug display mesh
  75790. */
  75791. createDebugNavMesh(scene: Scene): Mesh;
  75792. /**
  75793. * Get a navigation mesh constrained position, closest to the parameter position
  75794. * @param position world position
  75795. * @returns the closest point to position constrained by the navigation mesh
  75796. */
  75797. getClosestPoint(position: Vector3): Vector3;
  75798. /**
  75799. * Get a navigation mesh constrained position, closest to the parameter position
  75800. * @param position world position
  75801. * @param result output the closest point to position constrained by the navigation mesh
  75802. */
  75803. getClosestPointToRef(position: Vector3, result: Vector3): void;
  75804. /**
  75805. * Get a navigation mesh constrained position, within a particular radius
  75806. * @param position world position
  75807. * @param maxRadius the maximum distance to the constrained world position
  75808. * @returns the closest point to position constrained by the navigation mesh
  75809. */
  75810. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  75811. /**
  75812. * Get a navigation mesh constrained position, within a particular radius
  75813. * @param position world position
  75814. * @param maxRadius the maximum distance to the constrained world position
  75815. * @param result output the closest point to position constrained by the navigation mesh
  75816. */
  75817. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  75818. /**
  75819. * Compute the final position from a segment made of destination-position
  75820. * @param position world position
  75821. * @param destination world position
  75822. * @returns the resulting point along the navmesh
  75823. */
  75824. moveAlong(position: Vector3, destination: Vector3): Vector3;
  75825. /**
  75826. * Compute the final position from a segment made of destination-position
  75827. * @param position world position
  75828. * @param destination world position
  75829. * @param result output the resulting point along the navmesh
  75830. */
  75831. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  75832. /**
  75833. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  75834. * @param start world position
  75835. * @param end world position
  75836. * @returns array containing world position composing the path
  75837. */
  75838. computePath(start: Vector3, end: Vector3): Vector3[];
  75839. /**
  75840. * Create a new Crowd so you can add agents
  75841. * @param maxAgents the maximum agent count in the crowd
  75842. * @param maxAgentRadius the maximum radius an agent can have
  75843. * @param scene to attach the crowd to
  75844. * @returns the crowd you can add agents to
  75845. */
  75846. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  75847. /**
  75848. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75849. * The queries will try to find a solution within those bounds
  75850. * default is (1,1,1)
  75851. * @param extent x,y,z value that define the extent around the queries point of reference
  75852. */
  75853. setDefaultQueryExtent(extent: Vector3): void;
  75854. /**
  75855. * Get the Bounding box extent specified by setDefaultQueryExtent
  75856. * @returns the box extent values
  75857. */
  75858. getDefaultQueryExtent(): Vector3;
  75859. /**
  75860. * build the navmesh from a previously saved state using getNavmeshData
  75861. * @param data the Uint8Array returned by getNavmeshData
  75862. */
  75863. buildFromNavmeshData(data: Uint8Array): void;
  75864. /**
  75865. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  75866. * @returns data the Uint8Array that can be saved and reused
  75867. */
  75868. getNavmeshData(): Uint8Array;
  75869. /**
  75870. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75871. * @param result output the box extent values
  75872. */
  75873. getDefaultQueryExtentToRef(result: Vector3): void;
  75874. /**
  75875. * Disposes
  75876. */
  75877. dispose(): void;
  75878. /**
  75879. * If this plugin is supported
  75880. * @returns true if plugin is supported
  75881. */
  75882. isSupported(): boolean;
  75883. }
  75884. /**
  75885. * Recast detour crowd implementation
  75886. */
  75887. export class RecastJSCrowd implements ICrowd {
  75888. /**
  75889. * Recast/detour plugin
  75890. */
  75891. bjsRECASTPlugin: RecastJSPlugin;
  75892. /**
  75893. * Link to the detour crowd
  75894. */
  75895. recastCrowd: any;
  75896. /**
  75897. * One transform per agent
  75898. */
  75899. transforms: TransformNode[];
  75900. /**
  75901. * All agents created
  75902. */
  75903. agents: number[];
  75904. /**
  75905. * Link to the scene is kept to unregister the crowd from the scene
  75906. */
  75907. private _scene;
  75908. /**
  75909. * Observer for crowd updates
  75910. */
  75911. private _onBeforeAnimationsObserver;
  75912. /**
  75913. * Constructor
  75914. * @param plugin recastJS plugin
  75915. * @param maxAgents the maximum agent count in the crowd
  75916. * @param maxAgentRadius the maximum radius an agent can have
  75917. * @param scene to attach the crowd to
  75918. * @returns the crowd you can add agents to
  75919. */
  75920. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  75921. /**
  75922. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  75923. * You can attach anything to that node. The node position is updated in the scene update tick.
  75924. * @param pos world position that will be constrained by the navigation mesh
  75925. * @param parameters agent parameters
  75926. * @param transform hooked to the agent that will be update by the scene
  75927. * @returns agent index
  75928. */
  75929. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  75930. /**
  75931. * Returns the agent position in world space
  75932. * @param index agent index returned by addAgent
  75933. * @returns world space position
  75934. */
  75935. getAgentPosition(index: number): Vector3;
  75936. /**
  75937. * Returns the agent position result in world space
  75938. * @param index agent index returned by addAgent
  75939. * @param result output world space position
  75940. */
  75941. getAgentPositionToRef(index: number, result: Vector3): void;
  75942. /**
  75943. * Returns the agent velocity in world space
  75944. * @param index agent index returned by addAgent
  75945. * @returns world space velocity
  75946. */
  75947. getAgentVelocity(index: number): Vector3;
  75948. /**
  75949. * Returns the agent velocity result in world space
  75950. * @param index agent index returned by addAgent
  75951. * @param result output world space velocity
  75952. */
  75953. getAgentVelocityToRef(index: number, result: Vector3): void;
  75954. /**
  75955. * Returns the agent next target point on the path
  75956. * @param index agent index returned by addAgent
  75957. * @returns world space position
  75958. */
  75959. getAgentNextTargetPath(index: number): Vector3;
  75960. /**
  75961. * Returns the agent next target point on the path
  75962. * @param index agent index returned by addAgent
  75963. * @param result output world space position
  75964. */
  75965. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  75966. /**
  75967. * Gets the agent state
  75968. * @param index agent index returned by addAgent
  75969. * @returns agent state
  75970. */
  75971. getAgentState(index: number): number;
  75972. /**
  75973. * returns true if the agent in over an off mesh link connection
  75974. * @param index agent index returned by addAgent
  75975. * @returns true if over an off mesh link connection
  75976. */
  75977. overOffmeshConnection(index: number): boolean;
  75978. /**
  75979. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  75980. * @param index agent index returned by addAgent
  75981. * @param destination targeted world position
  75982. */
  75983. agentGoto(index: number, destination: Vector3): void;
  75984. /**
  75985. * Teleport the agent to a new position
  75986. * @param index agent index returned by addAgent
  75987. * @param destination targeted world position
  75988. */
  75989. agentTeleport(index: number, destination: Vector3): void;
  75990. /**
  75991. * Update agent parameters
  75992. * @param index agent index returned by addAgent
  75993. * @param parameters agent parameters
  75994. */
  75995. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  75996. /**
  75997. * remove a particular agent previously created
  75998. * @param index agent index returned by addAgent
  75999. */
  76000. removeAgent(index: number): void;
  76001. /**
  76002. * get the list of all agents attached to this crowd
  76003. * @returns list of agent indices
  76004. */
  76005. getAgents(): number[];
  76006. /**
  76007. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  76008. * @param deltaTime in seconds
  76009. */
  76010. update(deltaTime: number): void;
  76011. /**
  76012. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  76013. * The queries will try to find a solution within those bounds
  76014. * default is (1,1,1)
  76015. * @param extent x,y,z value that define the extent around the queries point of reference
  76016. */
  76017. setDefaultQueryExtent(extent: Vector3): void;
  76018. /**
  76019. * Get the Bounding box extent specified by setDefaultQueryExtent
  76020. * @returns the box extent values
  76021. */
  76022. getDefaultQueryExtent(): Vector3;
  76023. /**
  76024. * Get the Bounding box extent result specified by setDefaultQueryExtent
  76025. * @param result output the box extent values
  76026. */
  76027. getDefaultQueryExtentToRef(result: Vector3): void;
  76028. /**
  76029. * Release all resources
  76030. */
  76031. dispose(): void;
  76032. }
  76033. }
  76034. declare module "babylonjs/Navigation/Plugins/index" {
  76035. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  76036. }
  76037. declare module "babylonjs/Navigation/index" {
  76038. export * from "babylonjs/Navigation/INavigationEngine";
  76039. export * from "babylonjs/Navigation/Plugins/index";
  76040. }
  76041. declare module "babylonjs/Offline/database" {
  76042. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  76043. /**
  76044. * Class used to enable access to IndexedDB
  76045. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  76046. */
  76047. export class Database implements IOfflineProvider {
  76048. private _callbackManifestChecked;
  76049. private _currentSceneUrl;
  76050. private _db;
  76051. private _enableSceneOffline;
  76052. private _enableTexturesOffline;
  76053. private _manifestVersionFound;
  76054. private _mustUpdateRessources;
  76055. private _hasReachedQuota;
  76056. private _isSupported;
  76057. private _idbFactory;
  76058. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  76059. private static IsUASupportingBlobStorage;
  76060. /**
  76061. * Gets a boolean indicating if Database storage is enabled (off by default)
  76062. */
  76063. static IDBStorageEnabled: boolean;
  76064. /**
  76065. * Gets a boolean indicating if scene must be saved in the database
  76066. */
  76067. get enableSceneOffline(): boolean;
  76068. /**
  76069. * Gets a boolean indicating if textures must be saved in the database
  76070. */
  76071. get enableTexturesOffline(): boolean;
  76072. /**
  76073. * Creates a new Database
  76074. * @param urlToScene defines the url to load the scene
  76075. * @param callbackManifestChecked defines the callback to use when manifest is checked
  76076. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  76077. */
  76078. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  76079. private static _ParseURL;
  76080. private static _ReturnFullUrlLocation;
  76081. private _checkManifestFile;
  76082. /**
  76083. * Open the database and make it available
  76084. * @param successCallback defines the callback to call on success
  76085. * @param errorCallback defines the callback to call on error
  76086. */
  76087. open(successCallback: () => void, errorCallback: () => void): void;
  76088. /**
  76089. * Loads an image from the database
  76090. * @param url defines the url to load from
  76091. * @param image defines the target DOM image
  76092. */
  76093. loadImage(url: string, image: HTMLImageElement): void;
  76094. private _loadImageFromDBAsync;
  76095. private _saveImageIntoDBAsync;
  76096. private _checkVersionFromDB;
  76097. private _loadVersionFromDBAsync;
  76098. private _saveVersionIntoDBAsync;
  76099. /**
  76100. * Loads a file from database
  76101. * @param url defines the URL to load from
  76102. * @param sceneLoaded defines a callback to call on success
  76103. * @param progressCallBack defines a callback to call when progress changed
  76104. * @param errorCallback defines a callback to call on error
  76105. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  76106. */
  76107. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  76108. private _loadFileAsync;
  76109. private _saveFileAsync;
  76110. /**
  76111. * Validates if xhr data is correct
  76112. * @param xhr defines the request to validate
  76113. * @param dataType defines the expected data type
  76114. * @returns true if data is correct
  76115. */
  76116. private static _ValidateXHRData;
  76117. }
  76118. }
  76119. declare module "babylonjs/Offline/index" {
  76120. export * from "babylonjs/Offline/database";
  76121. export * from "babylonjs/Offline/IOfflineProvider";
  76122. }
  76123. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  76124. /** @hidden */
  76125. export var gpuUpdateParticlesPixelShader: {
  76126. name: string;
  76127. shader: string;
  76128. };
  76129. }
  76130. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  76131. /** @hidden */
  76132. export var gpuUpdateParticlesVertexShader: {
  76133. name: string;
  76134. shader: string;
  76135. };
  76136. }
  76137. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  76138. /** @hidden */
  76139. export var clipPlaneFragmentDeclaration2: {
  76140. name: string;
  76141. shader: string;
  76142. };
  76143. }
  76144. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  76145. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  76146. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  76147. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76148. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  76149. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  76150. /** @hidden */
  76151. export var gpuRenderParticlesPixelShader: {
  76152. name: string;
  76153. shader: string;
  76154. };
  76155. }
  76156. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  76157. /** @hidden */
  76158. export var clipPlaneVertexDeclaration2: {
  76159. name: string;
  76160. shader: string;
  76161. };
  76162. }
  76163. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  76164. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  76165. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  76166. /** @hidden */
  76167. export var gpuRenderParticlesVertexShader: {
  76168. name: string;
  76169. shader: string;
  76170. };
  76171. }
  76172. declare module "babylonjs/Particles/gpuParticleSystem" {
  76173. import { Nullable } from "babylonjs/types";
  76174. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  76175. import { Observable } from "babylonjs/Misc/observable";
  76176. import { Matrix } from "babylonjs/Maths/math.vector";
  76177. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  76178. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76179. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  76180. import { IDisposable } from "babylonjs/scene";
  76181. import { Effect } from "babylonjs/Materials/effect";
  76182. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76183. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  76185. import { Scene } from "babylonjs/scene";
  76186. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  76187. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  76188. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  76189. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  76190. /**
  76191. * This represents a GPU particle system in Babylon
  76192. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  76193. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  76194. */
  76195. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  76196. /**
  76197. * The layer mask we are rendering the particles through.
  76198. */
  76199. layerMask: number;
  76200. private _capacity;
  76201. private _activeCount;
  76202. private _currentActiveCount;
  76203. private _accumulatedCount;
  76204. private _renderEffect;
  76205. private _updateEffect;
  76206. private _buffer0;
  76207. private _buffer1;
  76208. private _spriteBuffer;
  76209. private _updateVAO;
  76210. private _renderVAO;
  76211. private _targetIndex;
  76212. private _sourceBuffer;
  76213. private _targetBuffer;
  76214. private _currentRenderId;
  76215. private _started;
  76216. private _stopped;
  76217. private _timeDelta;
  76218. private _randomTexture;
  76219. private _randomTexture2;
  76220. private _attributesStrideSize;
  76221. private _updateEffectOptions;
  76222. private _randomTextureSize;
  76223. private _actualFrame;
  76224. private _customEffect;
  76225. private readonly _rawTextureWidth;
  76226. /**
  76227. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  76228. */
  76229. static get IsSupported(): boolean;
  76230. /**
  76231. * An event triggered when the system is disposed.
  76232. */
  76233. onDisposeObservable: Observable<IParticleSystem>;
  76234. /**
  76235. * An event triggered when the system is stopped
  76236. */
  76237. onStoppedObservable: Observable<IParticleSystem>;
  76238. /**
  76239. * Gets the maximum number of particles active at the same time.
  76240. * @returns The max number of active particles.
  76241. */
  76242. getCapacity(): number;
  76243. /**
  76244. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  76245. * to override the particles.
  76246. */
  76247. forceDepthWrite: boolean;
  76248. /**
  76249. * Gets or set the number of active particles
  76250. */
  76251. get activeParticleCount(): number;
  76252. set activeParticleCount(value: number);
  76253. private _preWarmDone;
  76254. /**
  76255. * Specifies if the particles are updated in emitter local space or world space.
  76256. */
  76257. isLocal: boolean;
  76258. /** Gets or sets a matrix to use to compute projection */
  76259. defaultProjectionMatrix: Matrix;
  76260. /**
  76261. * Is this system ready to be used/rendered
  76262. * @return true if the system is ready
  76263. */
  76264. isReady(): boolean;
  76265. /**
  76266. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76267. * @returns True if it has been started, otherwise false.
  76268. */
  76269. isStarted(): boolean;
  76270. /**
  76271. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  76272. * @returns True if it has been stopped, otherwise false.
  76273. */
  76274. isStopped(): boolean;
  76275. /**
  76276. * Gets a boolean indicating that the system is stopping
  76277. * @returns true if the system is currently stopping
  76278. */
  76279. isStopping(): boolean;
  76280. /**
  76281. * Gets the number of particles active at the same time.
  76282. * @returns The number of active particles.
  76283. */
  76284. getActiveCount(): number;
  76285. /**
  76286. * Starts the particle system and begins to emit
  76287. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  76288. */
  76289. start(delay?: number): void;
  76290. /**
  76291. * Stops the particle system.
  76292. */
  76293. stop(): void;
  76294. /**
  76295. * Remove all active particles
  76296. */
  76297. reset(): void;
  76298. /**
  76299. * Returns the string "GPUParticleSystem"
  76300. * @returns a string containing the class name
  76301. */
  76302. getClassName(): string;
  76303. /**
  76304. * Gets the custom effect used to render the particles
  76305. * @param blendMode Blend mode for which the effect should be retrieved
  76306. * @returns The effect
  76307. */
  76308. getCustomEffect(blendMode?: number): Nullable<Effect>;
  76309. /**
  76310. * Sets the custom effect used to render the particles
  76311. * @param effect The effect to set
  76312. * @param blendMode Blend mode for which the effect should be set
  76313. */
  76314. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  76315. /** @hidden */
  76316. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  76317. /**
  76318. * Observable that will be called just before the particles are drawn
  76319. */
  76320. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  76321. /**
  76322. * Gets the name of the particle vertex shader
  76323. */
  76324. get vertexShaderName(): string;
  76325. private _colorGradientsTexture;
  76326. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  76327. /**
  76328. * Adds a new color gradient
  76329. * @param gradient defines the gradient to use (between 0 and 1)
  76330. * @param color1 defines the color to affect to the specified gradient
  76331. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76332. * @returns the current particle system
  76333. */
  76334. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  76335. private _refreshColorGradient;
  76336. /** Force the system to rebuild all gradients that need to be resync */
  76337. forceRefreshGradients(): void;
  76338. /**
  76339. * Remove a specific color gradient
  76340. * @param gradient defines the gradient to remove
  76341. * @returns the current particle system
  76342. */
  76343. removeColorGradient(gradient: number): GPUParticleSystem;
  76344. private _angularSpeedGradientsTexture;
  76345. private _sizeGradientsTexture;
  76346. private _velocityGradientsTexture;
  76347. private _limitVelocityGradientsTexture;
  76348. private _dragGradientsTexture;
  76349. private _addFactorGradient;
  76350. /**
  76351. * Adds a new size gradient
  76352. * @param gradient defines the gradient to use (between 0 and 1)
  76353. * @param factor defines the size factor to affect to the specified gradient
  76354. * @returns the current particle system
  76355. */
  76356. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  76357. /**
  76358. * Remove a specific size gradient
  76359. * @param gradient defines the gradient to remove
  76360. * @returns the current particle system
  76361. */
  76362. removeSizeGradient(gradient: number): GPUParticleSystem;
  76363. private _refreshFactorGradient;
  76364. /**
  76365. * Adds a new angular speed gradient
  76366. * @param gradient defines the gradient to use (between 0 and 1)
  76367. * @param factor defines the angular speed to affect to the specified gradient
  76368. * @returns the current particle system
  76369. */
  76370. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  76371. /**
  76372. * Remove a specific angular speed gradient
  76373. * @param gradient defines the gradient to remove
  76374. * @returns the current particle system
  76375. */
  76376. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  76377. /**
  76378. * Adds a new velocity gradient
  76379. * @param gradient defines the gradient to use (between 0 and 1)
  76380. * @param factor defines the velocity to affect to the specified gradient
  76381. * @returns the current particle system
  76382. */
  76383. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  76384. /**
  76385. * Remove a specific velocity gradient
  76386. * @param gradient defines the gradient to remove
  76387. * @returns the current particle system
  76388. */
  76389. removeVelocityGradient(gradient: number): GPUParticleSystem;
  76390. /**
  76391. * Adds a new limit velocity gradient
  76392. * @param gradient defines the gradient to use (between 0 and 1)
  76393. * @param factor defines the limit velocity value to affect to the specified gradient
  76394. * @returns the current particle system
  76395. */
  76396. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  76397. /**
  76398. * Remove a specific limit velocity gradient
  76399. * @param gradient defines the gradient to remove
  76400. * @returns the current particle system
  76401. */
  76402. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  76403. /**
  76404. * Adds a new drag gradient
  76405. * @param gradient defines the gradient to use (between 0 and 1)
  76406. * @param factor defines the drag value to affect to the specified gradient
  76407. * @returns the current particle system
  76408. */
  76409. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  76410. /**
  76411. * Remove a specific drag gradient
  76412. * @param gradient defines the gradient to remove
  76413. * @returns the current particle system
  76414. */
  76415. removeDragGradient(gradient: number): GPUParticleSystem;
  76416. /**
  76417. * Not supported by GPUParticleSystem
  76418. * @param gradient defines the gradient to use (between 0 and 1)
  76419. * @param factor defines the emit rate value to affect to the specified gradient
  76420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76421. * @returns the current particle system
  76422. */
  76423. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76424. /**
  76425. * Not supported by GPUParticleSystem
  76426. * @param gradient defines the gradient to remove
  76427. * @returns the current particle system
  76428. */
  76429. removeEmitRateGradient(gradient: number): IParticleSystem;
  76430. /**
  76431. * Not supported by GPUParticleSystem
  76432. * @param gradient defines the gradient to use (between 0 and 1)
  76433. * @param factor defines the start size value to affect to the specified gradient
  76434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76435. * @returns the current particle system
  76436. */
  76437. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76438. /**
  76439. * Not supported by GPUParticleSystem
  76440. * @param gradient defines the gradient to remove
  76441. * @returns the current particle system
  76442. */
  76443. removeStartSizeGradient(gradient: number): IParticleSystem;
  76444. /**
  76445. * Not supported by GPUParticleSystem
  76446. * @param gradient defines the gradient to use (between 0 and 1)
  76447. * @param min defines the color remap minimal range
  76448. * @param max defines the color remap maximal range
  76449. * @returns the current particle system
  76450. */
  76451. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76452. /**
  76453. * Not supported by GPUParticleSystem
  76454. * @param gradient defines the gradient to remove
  76455. * @returns the current particle system
  76456. */
  76457. removeColorRemapGradient(): IParticleSystem;
  76458. /**
  76459. * Not supported by GPUParticleSystem
  76460. * @param gradient defines the gradient to use (between 0 and 1)
  76461. * @param min defines the alpha remap minimal range
  76462. * @param max defines the alpha remap maximal range
  76463. * @returns the current particle system
  76464. */
  76465. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76466. /**
  76467. * Not supported by GPUParticleSystem
  76468. * @param gradient defines the gradient to remove
  76469. * @returns the current particle system
  76470. */
  76471. removeAlphaRemapGradient(): IParticleSystem;
  76472. /**
  76473. * Not supported by GPUParticleSystem
  76474. * @param gradient defines the gradient to use (between 0 and 1)
  76475. * @param color defines the color to affect to the specified gradient
  76476. * @returns the current particle system
  76477. */
  76478. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76479. /**
  76480. * Not supported by GPUParticleSystem
  76481. * @param gradient defines the gradient to remove
  76482. * @returns the current particle system
  76483. */
  76484. removeRampGradient(): IParticleSystem;
  76485. /**
  76486. * Not supported by GPUParticleSystem
  76487. * @returns the list of ramp gradients
  76488. */
  76489. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76490. /**
  76491. * Not supported by GPUParticleSystem
  76492. * Gets or sets a boolean indicating that ramp gradients must be used
  76493. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76494. */
  76495. get useRampGradients(): boolean;
  76496. set useRampGradients(value: boolean);
  76497. /**
  76498. * Not supported by GPUParticleSystem
  76499. * @param gradient defines the gradient to use (between 0 and 1)
  76500. * @param factor defines the life time factor to affect to the specified gradient
  76501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76502. * @returns the current particle system
  76503. */
  76504. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76505. /**
  76506. * Not supported by GPUParticleSystem
  76507. * @param gradient defines the gradient to remove
  76508. * @returns the current particle system
  76509. */
  76510. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76511. /**
  76512. * Instantiates a GPU particle system.
  76513. * 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.
  76514. * @param name The name of the particle system
  76515. * @param options The options used to create the system
  76516. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  76517. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  76518. * @param customEffect a custom effect used to change the way particles are rendered by default
  76519. */
  76520. constructor(name: string, options: Partial<{
  76521. capacity: number;
  76522. randomTextureSize: number;
  76523. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  76524. protected _reset(): void;
  76525. private _createUpdateVAO;
  76526. private _createRenderVAO;
  76527. private _initialize;
  76528. /** @hidden */
  76529. _recreateUpdateEffect(): void;
  76530. private _getEffect;
  76531. /**
  76532. * Fill the defines array according to the current settings of the particle system
  76533. * @param defines Array to be updated
  76534. * @param blendMode blend mode to take into account when updating the array
  76535. */
  76536. fillDefines(defines: Array<string>, blendMode?: number): void;
  76537. /**
  76538. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  76539. * @param uniforms Uniforms array to fill
  76540. * @param attributes Attributes array to fill
  76541. * @param samplers Samplers array to fill
  76542. */
  76543. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  76544. /** @hidden */
  76545. _recreateRenderEffect(): Effect;
  76546. /**
  76547. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  76548. * @param preWarm defines if we are in the pre-warmimg phase
  76549. */
  76550. animate(preWarm?: boolean): void;
  76551. private _createFactorGradientTexture;
  76552. private _createSizeGradientTexture;
  76553. private _createAngularSpeedGradientTexture;
  76554. private _createVelocityGradientTexture;
  76555. private _createLimitVelocityGradientTexture;
  76556. private _createDragGradientTexture;
  76557. private _createColorGradientTexture;
  76558. /**
  76559. * Renders the particle system in its current state
  76560. * @param preWarm defines if the system should only update the particles but not render them
  76561. * @returns the current number of particles
  76562. */
  76563. render(preWarm?: boolean): number;
  76564. /**
  76565. * Rebuilds the particle system
  76566. */
  76567. rebuild(): void;
  76568. private _releaseBuffers;
  76569. private _releaseVAOs;
  76570. /**
  76571. * Disposes the particle system and free the associated resources
  76572. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76573. */
  76574. dispose(disposeTexture?: boolean): void;
  76575. /**
  76576. * Clones the particle system.
  76577. * @param name The name of the cloned object
  76578. * @param newEmitter The new emitter to use
  76579. * @returns the cloned particle system
  76580. */
  76581. clone(name: string, newEmitter: any): GPUParticleSystem;
  76582. /**
  76583. * Serializes the particle system to a JSON object
  76584. * @param serializeTexture defines if the texture must be serialized as well
  76585. * @returns the JSON object
  76586. */
  76587. serialize(serializeTexture?: boolean): any;
  76588. /**
  76589. * Parses a JSON object to create a GPU particle system.
  76590. * @param parsedParticleSystem The JSON object to parse
  76591. * @param sceneOrEngine The scene or the engine to create the particle system in
  76592. * @param rootUrl The root url to use to load external dependencies like texture
  76593. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  76594. * @returns the parsed GPU particle system
  76595. */
  76596. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  76597. }
  76598. }
  76599. declare module "babylonjs/Particles/particleSystemSet" {
  76600. import { Nullable } from "babylonjs/types";
  76601. import { Color3 } from "babylonjs/Maths/math.color";
  76602. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76604. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76605. import { Scene, IDisposable } from "babylonjs/scene";
  76606. /**
  76607. * Represents a set of particle systems working together to create a specific effect
  76608. */
  76609. export class ParticleSystemSet implements IDisposable {
  76610. /**
  76611. * Gets or sets base Assets URL
  76612. */
  76613. static BaseAssetsUrl: string;
  76614. private _emitterCreationOptions;
  76615. private _emitterNode;
  76616. /**
  76617. * Gets the particle system list
  76618. */
  76619. systems: IParticleSystem[];
  76620. /**
  76621. * Gets the emitter node used with this set
  76622. */
  76623. get emitterNode(): Nullable<TransformNode>;
  76624. /**
  76625. * Creates a new emitter mesh as a sphere
  76626. * @param options defines the options used to create the sphere
  76627. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  76628. * @param scene defines the hosting scene
  76629. */
  76630. setEmitterAsSphere(options: {
  76631. diameter: number;
  76632. segments: number;
  76633. color: Color3;
  76634. }, renderingGroupId: number, scene: Scene): void;
  76635. /**
  76636. * Starts all particle systems of the set
  76637. * @param emitter defines an optional mesh to use as emitter for the particle systems
  76638. */
  76639. start(emitter?: AbstractMesh): void;
  76640. /**
  76641. * Release all associated resources
  76642. */
  76643. dispose(): void;
  76644. /**
  76645. * Serialize the set into a JSON compatible object
  76646. * @param serializeTexture defines if the texture must be serialized as well
  76647. * @returns a JSON compatible representation of the set
  76648. */
  76649. serialize(serializeTexture?: boolean): any;
  76650. /**
  76651. * Parse a new ParticleSystemSet from a serialized source
  76652. * @param data defines a JSON compatible representation of the set
  76653. * @param scene defines the hosting scene
  76654. * @param gpu defines if we want GPU particles or CPU particles
  76655. * @returns a new ParticleSystemSet
  76656. */
  76657. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  76658. }
  76659. }
  76660. declare module "babylonjs/Particles/particleHelper" {
  76661. import { Nullable } from "babylonjs/types";
  76662. import { Scene } from "babylonjs/scene";
  76663. import { Vector3 } from "babylonjs/Maths/math.vector";
  76664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76665. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76666. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  76667. /**
  76668. * This class is made for on one-liner static method to help creating particle system set.
  76669. */
  76670. export class ParticleHelper {
  76671. /**
  76672. * Gets or sets base Assets URL
  76673. */
  76674. static BaseAssetsUrl: string;
  76675. /** Define the Url to load snippets */
  76676. static SnippetUrl: string;
  76677. /**
  76678. * Create a default particle system that you can tweak
  76679. * @param emitter defines the emitter to use
  76680. * @param capacity defines the system capacity (default is 500 particles)
  76681. * @param scene defines the hosting scene
  76682. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  76683. * @returns the new Particle system
  76684. */
  76685. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  76686. /**
  76687. * This is the main static method (one-liner) of this helper to create different particle systems
  76688. * @param type This string represents the type to the particle system to create
  76689. * @param scene The scene where the particle system should live
  76690. * @param gpu If the system will use gpu
  76691. * @returns the ParticleSystemSet created
  76692. */
  76693. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  76694. /**
  76695. * Static function used to export a particle system to a ParticleSystemSet variable.
  76696. * Please note that the emitter shape is not exported
  76697. * @param systems defines the particle systems to export
  76698. * @returns the created particle system set
  76699. */
  76700. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  76701. /**
  76702. * Creates a particle system from a snippet saved in a remote file
  76703. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  76704. * @param url defines the url to load from
  76705. * @param scene defines the hosting scene
  76706. * @param gpu If the system will use gpu
  76707. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76708. * @returns a promise that will resolve to the new particle system
  76709. */
  76710. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  76711. /**
  76712. * Creates a particle system from a snippet saved by the particle system editor
  76713. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  76714. * @param scene defines the hosting scene
  76715. * @param gpu If the system will use gpu
  76716. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76717. * @returns a promise that will resolve to the new particle system
  76718. */
  76719. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  76720. }
  76721. }
  76722. declare module "babylonjs/Particles/particleSystemComponent" {
  76723. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76724. import { Effect } from "babylonjs/Materials/effect";
  76725. import "babylonjs/Shaders/particles.vertex";
  76726. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  76727. module "babylonjs/Engines/engine" {
  76728. interface Engine {
  76729. /**
  76730. * Create an effect to use with particle systems.
  76731. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  76732. * the particle system for which you want to create a custom effect in the last parameter
  76733. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  76734. * @param uniformsNames defines a list of attribute names
  76735. * @param samplers defines an array of string used to represent textures
  76736. * @param defines defines the string containing the defines to use to compile the shaders
  76737. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  76738. * @param onCompiled defines a function to call when the effect creation is successful
  76739. * @param onError defines a function to call when the effect creation has failed
  76740. * @param particleSystem the particle system you want to create the effect for
  76741. * @returns the new Effect
  76742. */
  76743. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  76744. }
  76745. }
  76746. module "babylonjs/Meshes/mesh" {
  76747. interface Mesh {
  76748. /**
  76749. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  76750. * @returns an array of IParticleSystem
  76751. */
  76752. getEmittedParticleSystems(): IParticleSystem[];
  76753. /**
  76754. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  76755. * @returns an array of IParticleSystem
  76756. */
  76757. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  76758. }
  76759. }
  76760. }
  76761. declare module "babylonjs/Particles/pointsCloudSystem" {
  76762. import { Color4 } from "babylonjs/Maths/math";
  76763. import { Mesh } from "babylonjs/Meshes/mesh";
  76764. import { Scene, IDisposable } from "babylonjs/scene";
  76765. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  76766. /** Defines the 4 color options */
  76767. export enum PointColor {
  76768. /** color value */
  76769. Color = 2,
  76770. /** uv value */
  76771. UV = 1,
  76772. /** random value */
  76773. Random = 0,
  76774. /** stated value */
  76775. Stated = 3
  76776. }
  76777. /**
  76778. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  76779. * 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.
  76780. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  76781. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  76782. *
  76783. * Full documentation here : TO BE ENTERED
  76784. */
  76785. export class PointsCloudSystem implements IDisposable {
  76786. /**
  76787. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  76788. * Example : var p = SPS.particles[i];
  76789. */
  76790. particles: CloudPoint[];
  76791. /**
  76792. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  76793. */
  76794. nbParticles: number;
  76795. /**
  76796. * This a counter for your own usage. It's not set by any SPS functions.
  76797. */
  76798. counter: number;
  76799. /**
  76800. * The PCS name. This name is also given to the underlying mesh.
  76801. */
  76802. name: string;
  76803. /**
  76804. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  76805. */
  76806. mesh: Mesh;
  76807. /**
  76808. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  76809. * Please read :
  76810. */
  76811. vars: any;
  76812. /**
  76813. * @hidden
  76814. */
  76815. _size: number;
  76816. private _scene;
  76817. private _promises;
  76818. private _positions;
  76819. private _indices;
  76820. private _normals;
  76821. private _colors;
  76822. private _uvs;
  76823. private _indices32;
  76824. private _positions32;
  76825. private _colors32;
  76826. private _uvs32;
  76827. private _updatable;
  76828. private _isVisibilityBoxLocked;
  76829. private _alwaysVisible;
  76830. private _groups;
  76831. private _groupCounter;
  76832. private _computeParticleColor;
  76833. private _computeParticleTexture;
  76834. private _computeParticleRotation;
  76835. private _computeBoundingBox;
  76836. private _isReady;
  76837. /**
  76838. * Creates a PCS (Points Cloud System) object
  76839. * @param name (String) is the PCS name, this will be the underlying mesh name
  76840. * @param pointSize (number) is the size for each point
  76841. * @param scene (Scene) is the scene in which the PCS is added
  76842. * @param options defines the options of the PCS e.g.
  76843. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  76844. */
  76845. constructor(name: string, pointSize: number, scene: Scene, options?: {
  76846. updatable?: boolean;
  76847. });
  76848. /**
  76849. * Builds the PCS underlying mesh. Returns a standard Mesh.
  76850. * If no points were added to the PCS, the returned mesh is just a single point.
  76851. * @returns a promise for the created mesh
  76852. */
  76853. buildMeshAsync(): Promise<Mesh>;
  76854. /**
  76855. * @hidden
  76856. */
  76857. private _buildMesh;
  76858. private _addParticle;
  76859. private _randomUnitVector;
  76860. private _getColorIndicesForCoord;
  76861. private _setPointsColorOrUV;
  76862. private _colorFromTexture;
  76863. private _calculateDensity;
  76864. /**
  76865. * Adds points to the PCS in random positions within a unit sphere
  76866. * @param nb (positive integer) the number of particles to be created from this model
  76867. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  76868. * @returns the number of groups in the system
  76869. */
  76870. addPoints(nb: number, pointFunction?: any): number;
  76871. /**
  76872. * Adds points to the PCS from the surface of the model shape
  76873. * @param mesh is any Mesh object that will be used as a surface model for the points
  76874. * @param nb (positive integer) the number of particles to be created from this model
  76875. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76876. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76877. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76878. * @returns the number of groups in the system
  76879. */
  76880. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76881. /**
  76882. * Adds points to the PCS inside the model shape
  76883. * @param mesh is any Mesh object that will be used as a surface model for the points
  76884. * @param nb (positive integer) the number of particles to be created from this model
  76885. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76886. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76887. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76888. * @returns the number of groups in the system
  76889. */
  76890. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76891. /**
  76892. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  76893. * This method calls `updateParticle()` for each particle of the SPS.
  76894. * For an animated SPS, it is usually called within the render loop.
  76895. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  76896. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  76897. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  76898. * @returns the PCS.
  76899. */
  76900. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  76901. /**
  76902. * Disposes the PCS.
  76903. */
  76904. dispose(): void;
  76905. /**
  76906. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  76907. * doc :
  76908. * @returns the PCS.
  76909. */
  76910. refreshVisibleSize(): PointsCloudSystem;
  76911. /**
  76912. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  76913. * @param size the size (float) of the visibility box
  76914. * note : this doesn't lock the PCS mesh bounding box.
  76915. * doc :
  76916. */
  76917. setVisibilityBox(size: number): void;
  76918. /**
  76919. * Gets whether the PCS is always visible or not
  76920. * doc :
  76921. */
  76922. get isAlwaysVisible(): boolean;
  76923. /**
  76924. * Sets the PCS as always visible or not
  76925. * doc :
  76926. */
  76927. set isAlwaysVisible(val: boolean);
  76928. /**
  76929. * Tells to `setParticles()` to compute the particle rotations or not
  76930. * Default value : false. The PCS is faster when it's set to false
  76931. * Note : particle rotations are only applied to parent particles
  76932. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  76933. */
  76934. set computeParticleRotation(val: boolean);
  76935. /**
  76936. * Tells to `setParticles()` to compute the particle colors or not.
  76937. * Default value : true. The PCS is faster when it's set to false.
  76938. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76939. */
  76940. set computeParticleColor(val: boolean);
  76941. set computeParticleTexture(val: boolean);
  76942. /**
  76943. * Gets if `setParticles()` computes the particle colors or not.
  76944. * Default value : false. The PCS is faster when it's set to false.
  76945. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76946. */
  76947. get computeParticleColor(): boolean;
  76948. /**
  76949. * Gets if `setParticles()` computes the particle textures or not.
  76950. * Default value : false. The PCS is faster when it's set to false.
  76951. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  76952. */
  76953. get computeParticleTexture(): boolean;
  76954. /**
  76955. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  76956. */
  76957. set computeBoundingBox(val: boolean);
  76958. /**
  76959. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  76960. */
  76961. get computeBoundingBox(): boolean;
  76962. /**
  76963. * This function does nothing. It may be overwritten to set all the particle first values.
  76964. * The PCS doesn't call this function, you may have to call it by your own.
  76965. * doc :
  76966. */
  76967. initParticles(): void;
  76968. /**
  76969. * This function does nothing. It may be overwritten to recycle a particle
  76970. * The PCS doesn't call this function, you can to call it
  76971. * doc :
  76972. * @param particle The particle to recycle
  76973. * @returns the recycled particle
  76974. */
  76975. recycleParticle(particle: CloudPoint): CloudPoint;
  76976. /**
  76977. * Updates a particle : this function should be overwritten by the user.
  76978. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  76979. * doc :
  76980. * @example : just set a particle position or velocity and recycle conditions
  76981. * @param particle The particle to update
  76982. * @returns the updated particle
  76983. */
  76984. updateParticle(particle: CloudPoint): CloudPoint;
  76985. /**
  76986. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  76987. * This does nothing and may be overwritten by the user.
  76988. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76989. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76990. * @param update the boolean update value actually passed to setParticles()
  76991. */
  76992. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76993. /**
  76994. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  76995. * This will be passed three parameters.
  76996. * This does nothing and may be overwritten by the user.
  76997. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76998. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76999. * @param update the boolean update value actually passed to setParticles()
  77000. */
  77001. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  77002. }
  77003. }
  77004. declare module "babylonjs/Particles/cloudPoint" {
  77005. import { Nullable } from "babylonjs/types";
  77006. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  77007. import { Mesh } from "babylonjs/Meshes/mesh";
  77008. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  77009. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  77010. /**
  77011. * Represents one particle of a points cloud system.
  77012. */
  77013. export class CloudPoint {
  77014. /**
  77015. * particle global index
  77016. */
  77017. idx: number;
  77018. /**
  77019. * The color of the particle
  77020. */
  77021. color: Nullable<Color4>;
  77022. /**
  77023. * The world space position of the particle.
  77024. */
  77025. position: Vector3;
  77026. /**
  77027. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  77028. */
  77029. rotation: Vector3;
  77030. /**
  77031. * The world space rotation quaternion of the particle.
  77032. */
  77033. rotationQuaternion: Nullable<Quaternion>;
  77034. /**
  77035. * The uv of the particle.
  77036. */
  77037. uv: Nullable<Vector2>;
  77038. /**
  77039. * The current speed of the particle.
  77040. */
  77041. velocity: Vector3;
  77042. /**
  77043. * The pivot point in the particle local space.
  77044. */
  77045. pivot: Vector3;
  77046. /**
  77047. * Must the particle be translated from its pivot point in its local space ?
  77048. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  77049. * Default : false
  77050. */
  77051. translateFromPivot: boolean;
  77052. /**
  77053. * Index of this particle in the global "positions" array (Internal use)
  77054. * @hidden
  77055. */
  77056. _pos: number;
  77057. /**
  77058. * @hidden Index of this particle in the global "indices" array (Internal use)
  77059. */
  77060. _ind: number;
  77061. /**
  77062. * Group this particle belongs to
  77063. */
  77064. _group: PointsGroup;
  77065. /**
  77066. * Group id of this particle
  77067. */
  77068. groupId: number;
  77069. /**
  77070. * Index of the particle in its group id (Internal use)
  77071. */
  77072. idxInGroup: number;
  77073. /**
  77074. * @hidden Particle BoundingInfo object (Internal use)
  77075. */
  77076. _boundingInfo: BoundingInfo;
  77077. /**
  77078. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  77079. */
  77080. _pcs: PointsCloudSystem;
  77081. /**
  77082. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  77083. */
  77084. _stillInvisible: boolean;
  77085. /**
  77086. * @hidden Last computed particle rotation matrix
  77087. */
  77088. _rotationMatrix: number[];
  77089. /**
  77090. * Parent particle Id, if any.
  77091. * Default null.
  77092. */
  77093. parentId: Nullable<number>;
  77094. /**
  77095. * @hidden Internal global position in the PCS.
  77096. */
  77097. _globalPosition: Vector3;
  77098. /**
  77099. * Creates a Point Cloud object.
  77100. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  77101. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  77102. * @param group (PointsGroup) is the group the particle belongs to
  77103. * @param groupId (integer) is the group identifier in the PCS.
  77104. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  77105. * @param pcs defines the PCS it is associated to
  77106. */
  77107. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  77108. /**
  77109. * get point size
  77110. */
  77111. get size(): Vector3;
  77112. /**
  77113. * Set point size
  77114. */
  77115. set size(scale: Vector3);
  77116. /**
  77117. * Legacy support, changed quaternion to rotationQuaternion
  77118. */
  77119. get quaternion(): Nullable<Quaternion>;
  77120. /**
  77121. * Legacy support, changed quaternion to rotationQuaternion
  77122. */
  77123. set quaternion(q: Nullable<Quaternion>);
  77124. /**
  77125. * Returns a boolean. True if the particle intersects a mesh, else false
  77126. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  77127. * @param target is the object (point or mesh) what the intersection is computed against
  77128. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  77129. * @returns true if it intersects
  77130. */
  77131. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  77132. /**
  77133. * get the rotation matrix of the particle
  77134. * @hidden
  77135. */
  77136. getRotationMatrix(m: Matrix): void;
  77137. }
  77138. /**
  77139. * Represents a group of points in a points cloud system
  77140. * * PCS internal tool, don't use it manually.
  77141. */
  77142. export class PointsGroup {
  77143. /**
  77144. * The group id
  77145. * @hidden
  77146. */
  77147. groupID: number;
  77148. /**
  77149. * image data for group (internal use)
  77150. * @hidden
  77151. */
  77152. _groupImageData: Nullable<ArrayBufferView>;
  77153. /**
  77154. * Image Width (internal use)
  77155. * @hidden
  77156. */
  77157. _groupImgWidth: number;
  77158. /**
  77159. * Image Height (internal use)
  77160. * @hidden
  77161. */
  77162. _groupImgHeight: number;
  77163. /**
  77164. * Custom position function (internal use)
  77165. * @hidden
  77166. */
  77167. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  77168. /**
  77169. * density per facet for surface points
  77170. * @hidden
  77171. */
  77172. _groupDensity: number[];
  77173. /**
  77174. * Only when points are colored by texture carries pointer to texture list array
  77175. * @hidden
  77176. */
  77177. _textureNb: number;
  77178. /**
  77179. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  77180. * PCS internal tool, don't use it manually.
  77181. * @hidden
  77182. */
  77183. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  77184. }
  77185. }
  77186. declare module "babylonjs/Particles/index" {
  77187. export * from "babylonjs/Particles/baseParticleSystem";
  77188. export * from "babylonjs/Particles/EmitterTypes/index";
  77189. export * from "babylonjs/Particles/gpuParticleSystem";
  77190. export * from "babylonjs/Particles/IParticleSystem";
  77191. export * from "babylonjs/Particles/particle";
  77192. export * from "babylonjs/Particles/particleHelper";
  77193. export * from "babylonjs/Particles/particleSystem";
  77194. import "babylonjs/Particles/particleSystemComponent";
  77195. export * from "babylonjs/Particles/particleSystemComponent";
  77196. export * from "babylonjs/Particles/particleSystemSet";
  77197. export * from "babylonjs/Particles/solidParticle";
  77198. export * from "babylonjs/Particles/solidParticleSystem";
  77199. export * from "babylonjs/Particles/cloudPoint";
  77200. export * from "babylonjs/Particles/pointsCloudSystem";
  77201. export * from "babylonjs/Particles/subEmitter";
  77202. }
  77203. declare module "babylonjs/Physics/physicsEngineComponent" {
  77204. import { Nullable } from "babylonjs/types";
  77205. import { Observable, Observer } from "babylonjs/Misc/observable";
  77206. import { Vector3 } from "babylonjs/Maths/math.vector";
  77207. import { Mesh } from "babylonjs/Meshes/mesh";
  77208. import { ISceneComponent } from "babylonjs/sceneComponent";
  77209. import { Scene } from "babylonjs/scene";
  77210. import { Node } from "babylonjs/node";
  77211. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  77212. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77213. module "babylonjs/scene" {
  77214. interface Scene {
  77215. /** @hidden (Backing field) */
  77216. _physicsEngine: Nullable<IPhysicsEngine>;
  77217. /** @hidden */
  77218. _physicsTimeAccumulator: number;
  77219. /**
  77220. * Gets the current physics engine
  77221. * @returns a IPhysicsEngine or null if none attached
  77222. */
  77223. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  77224. /**
  77225. * Enables physics to the current scene
  77226. * @param gravity defines the scene's gravity for the physics engine
  77227. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  77228. * @return a boolean indicating if the physics engine was initialized
  77229. */
  77230. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  77231. /**
  77232. * Disables and disposes the physics engine associated with the scene
  77233. */
  77234. disablePhysicsEngine(): void;
  77235. /**
  77236. * Gets a boolean indicating if there is an active physics engine
  77237. * @returns a boolean indicating if there is an active physics engine
  77238. */
  77239. isPhysicsEnabled(): boolean;
  77240. /**
  77241. * Deletes a physics compound impostor
  77242. * @param compound defines the compound to delete
  77243. */
  77244. deleteCompoundImpostor(compound: any): void;
  77245. /**
  77246. * An event triggered when physic simulation is about to be run
  77247. */
  77248. onBeforePhysicsObservable: Observable<Scene>;
  77249. /**
  77250. * An event triggered when physic simulation has been done
  77251. */
  77252. onAfterPhysicsObservable: Observable<Scene>;
  77253. }
  77254. }
  77255. module "babylonjs/Meshes/abstractMesh" {
  77256. interface AbstractMesh {
  77257. /** @hidden */
  77258. _physicsImpostor: Nullable<PhysicsImpostor>;
  77259. /**
  77260. * Gets or sets impostor used for physic simulation
  77261. * @see https://doc.babylonjs.com/features/physics_engine
  77262. */
  77263. physicsImpostor: Nullable<PhysicsImpostor>;
  77264. /**
  77265. * Gets the current physics impostor
  77266. * @see https://doc.babylonjs.com/features/physics_engine
  77267. * @returns a physics impostor or null
  77268. */
  77269. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  77270. /** Apply a physic impulse to the mesh
  77271. * @param force defines the force to apply
  77272. * @param contactPoint defines where to apply the force
  77273. * @returns the current mesh
  77274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77275. */
  77276. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  77277. /**
  77278. * Creates a physic joint between two meshes
  77279. * @param otherMesh defines the other mesh to use
  77280. * @param pivot1 defines the pivot to use on this mesh
  77281. * @param pivot2 defines the pivot to use on the other mesh
  77282. * @param options defines additional options (can be plugin dependent)
  77283. * @returns the current mesh
  77284. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  77285. */
  77286. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  77287. /** @hidden */
  77288. _disposePhysicsObserver: Nullable<Observer<Node>>;
  77289. }
  77290. }
  77291. /**
  77292. * Defines the physics engine scene component responsible to manage a physics engine
  77293. */
  77294. export class PhysicsEngineSceneComponent implements ISceneComponent {
  77295. /**
  77296. * The component name helpful to identify the component in the list of scene components.
  77297. */
  77298. readonly name: string;
  77299. /**
  77300. * The scene the component belongs to.
  77301. */
  77302. scene: Scene;
  77303. /**
  77304. * Creates a new instance of the component for the given scene
  77305. * @param scene Defines the scene to register the component in
  77306. */
  77307. constructor(scene: Scene);
  77308. /**
  77309. * Registers the component in a given scene
  77310. */
  77311. register(): void;
  77312. /**
  77313. * Rebuilds the elements related to this component in case of
  77314. * context lost for instance.
  77315. */
  77316. rebuild(): void;
  77317. /**
  77318. * Disposes the component and the associated resources
  77319. */
  77320. dispose(): void;
  77321. }
  77322. }
  77323. declare module "babylonjs/Physics/physicsHelper" {
  77324. import { Nullable } from "babylonjs/types";
  77325. import { Vector3 } from "babylonjs/Maths/math.vector";
  77326. import { Mesh } from "babylonjs/Meshes/mesh";
  77327. import { Scene } from "babylonjs/scene";
  77328. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77329. /**
  77330. * A helper for physics simulations
  77331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77332. */
  77333. export class PhysicsHelper {
  77334. private _scene;
  77335. private _physicsEngine;
  77336. /**
  77337. * Initializes the Physics helper
  77338. * @param scene Babylon.js scene
  77339. */
  77340. constructor(scene: Scene);
  77341. /**
  77342. * Applies a radial explosion impulse
  77343. * @param origin the origin of the explosion
  77344. * @param radiusOrEventOptions the radius or the options of radial explosion
  77345. * @param strength the explosion strength
  77346. * @param falloff possible options: Constant & Linear. Defaults to Constant
  77347. * @returns A physics radial explosion event, or null
  77348. */
  77349. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  77350. /**
  77351. * Applies a radial explosion force
  77352. * @param origin the origin of the explosion
  77353. * @param radiusOrEventOptions the radius or the options of radial explosion
  77354. * @param strength the explosion strength
  77355. * @param falloff possible options: Constant & Linear. Defaults to Constant
  77356. * @returns A physics radial explosion event, or null
  77357. */
  77358. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  77359. /**
  77360. * Creates a gravitational field
  77361. * @param origin the origin of the explosion
  77362. * @param radiusOrEventOptions the radius or the options of radial explosion
  77363. * @param strength the explosion strength
  77364. * @param falloff possible options: Constant & Linear. Defaults to Constant
  77365. * @returns A physics gravitational field event, or null
  77366. */
  77367. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  77368. /**
  77369. * Creates a physics updraft event
  77370. * @param origin the origin of the updraft
  77371. * @param radiusOrEventOptions the radius or the options of the updraft
  77372. * @param strength the strength of the updraft
  77373. * @param height the height of the updraft
  77374. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  77375. * @returns A physics updraft event, or null
  77376. */
  77377. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  77378. /**
  77379. * Creates a physics vortex event
  77380. * @param origin the of the vortex
  77381. * @param radiusOrEventOptions the radius or the options of the vortex
  77382. * @param strength the strength of the vortex
  77383. * @param height the height of the vortex
  77384. * @returns a Physics vortex event, or null
  77385. * A physics vortex event or null
  77386. */
  77387. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  77388. }
  77389. /**
  77390. * Represents a physics radial explosion event
  77391. */
  77392. class PhysicsRadialExplosionEvent {
  77393. private _scene;
  77394. private _options;
  77395. private _sphere;
  77396. private _dataFetched;
  77397. /**
  77398. * Initializes a radial explosion event
  77399. * @param _scene BabylonJS scene
  77400. * @param _options The options for the vortex event
  77401. */
  77402. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  77403. /**
  77404. * Returns the data related to the radial explosion event (sphere).
  77405. * @returns The radial explosion event data
  77406. */
  77407. getData(): PhysicsRadialExplosionEventData;
  77408. /**
  77409. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  77410. * @param impostor A physics imposter
  77411. * @param origin the origin of the explosion
  77412. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  77413. */
  77414. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  77415. /**
  77416. * Triggers affected impostors callbacks
  77417. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  77418. */
  77419. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  77420. /**
  77421. * Disposes the sphere.
  77422. * @param force Specifies if the sphere should be disposed by force
  77423. */
  77424. dispose(force?: boolean): void;
  77425. /*** Helpers ***/
  77426. private _prepareSphere;
  77427. private _intersectsWithSphere;
  77428. }
  77429. /**
  77430. * Represents a gravitational field event
  77431. */
  77432. class PhysicsGravitationalFieldEvent {
  77433. private _physicsHelper;
  77434. private _scene;
  77435. private _origin;
  77436. private _options;
  77437. private _tickCallback;
  77438. private _sphere;
  77439. private _dataFetched;
  77440. /**
  77441. * Initializes the physics gravitational field event
  77442. * @param _physicsHelper A physics helper
  77443. * @param _scene BabylonJS scene
  77444. * @param _origin The origin position of the gravitational field event
  77445. * @param _options The options for the vortex event
  77446. */
  77447. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  77448. /**
  77449. * Returns the data related to the gravitational field event (sphere).
  77450. * @returns A gravitational field event
  77451. */
  77452. getData(): PhysicsGravitationalFieldEventData;
  77453. /**
  77454. * Enables the gravitational field.
  77455. */
  77456. enable(): void;
  77457. /**
  77458. * Disables the gravitational field.
  77459. */
  77460. disable(): void;
  77461. /**
  77462. * Disposes the sphere.
  77463. * @param force The force to dispose from the gravitational field event
  77464. */
  77465. dispose(force?: boolean): void;
  77466. private _tick;
  77467. }
  77468. /**
  77469. * Represents a physics updraft event
  77470. */
  77471. class PhysicsUpdraftEvent {
  77472. private _scene;
  77473. private _origin;
  77474. private _options;
  77475. private _physicsEngine;
  77476. private _originTop;
  77477. private _originDirection;
  77478. private _tickCallback;
  77479. private _cylinder;
  77480. private _cylinderPosition;
  77481. private _dataFetched;
  77482. /**
  77483. * Initializes the physics updraft event
  77484. * @param _scene BabylonJS scene
  77485. * @param _origin The origin position of the updraft
  77486. * @param _options The options for the updraft event
  77487. */
  77488. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  77489. /**
  77490. * Returns the data related to the updraft event (cylinder).
  77491. * @returns A physics updraft event
  77492. */
  77493. getData(): PhysicsUpdraftEventData;
  77494. /**
  77495. * Enables the updraft.
  77496. */
  77497. enable(): void;
  77498. /**
  77499. * Disables the updraft.
  77500. */
  77501. disable(): void;
  77502. /**
  77503. * Disposes the cylinder.
  77504. * @param force Specifies if the updraft should be disposed by force
  77505. */
  77506. dispose(force?: boolean): void;
  77507. private getImpostorHitData;
  77508. private _tick;
  77509. /*** Helpers ***/
  77510. private _prepareCylinder;
  77511. private _intersectsWithCylinder;
  77512. }
  77513. /**
  77514. * Represents a physics vortex event
  77515. */
  77516. class PhysicsVortexEvent {
  77517. private _scene;
  77518. private _origin;
  77519. private _options;
  77520. private _physicsEngine;
  77521. private _originTop;
  77522. private _tickCallback;
  77523. private _cylinder;
  77524. private _cylinderPosition;
  77525. private _dataFetched;
  77526. /**
  77527. * Initializes the physics vortex event
  77528. * @param _scene The BabylonJS scene
  77529. * @param _origin The origin position of the vortex
  77530. * @param _options The options for the vortex event
  77531. */
  77532. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  77533. /**
  77534. * Returns the data related to the vortex event (cylinder).
  77535. * @returns The physics vortex event data
  77536. */
  77537. getData(): PhysicsVortexEventData;
  77538. /**
  77539. * Enables the vortex.
  77540. */
  77541. enable(): void;
  77542. /**
  77543. * Disables the cortex.
  77544. */
  77545. disable(): void;
  77546. /**
  77547. * Disposes the sphere.
  77548. * @param force
  77549. */
  77550. dispose(force?: boolean): void;
  77551. private getImpostorHitData;
  77552. private _tick;
  77553. /*** Helpers ***/
  77554. private _prepareCylinder;
  77555. private _intersectsWithCylinder;
  77556. }
  77557. /**
  77558. * Options fot the radial explosion event
  77559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77560. */
  77561. export class PhysicsRadialExplosionEventOptions {
  77562. /**
  77563. * The radius of the sphere for the radial explosion.
  77564. */
  77565. radius: number;
  77566. /**
  77567. * The strength of the explosion.
  77568. */
  77569. strength: number;
  77570. /**
  77571. * The strength of the force in correspondence to the distance of the affected object
  77572. */
  77573. falloff: PhysicsRadialImpulseFalloff;
  77574. /**
  77575. * Sphere options for the radial explosion.
  77576. */
  77577. sphere: {
  77578. segments: number;
  77579. diameter: number;
  77580. };
  77581. /**
  77582. * Sphere options for the radial explosion.
  77583. */
  77584. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  77585. }
  77586. /**
  77587. * Options fot the updraft event
  77588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77589. */
  77590. export class PhysicsUpdraftEventOptions {
  77591. /**
  77592. * The radius of the cylinder for the vortex
  77593. */
  77594. radius: number;
  77595. /**
  77596. * The strength of the updraft.
  77597. */
  77598. strength: number;
  77599. /**
  77600. * The height of the cylinder for the updraft.
  77601. */
  77602. height: number;
  77603. /**
  77604. * The mode for the the updraft.
  77605. */
  77606. updraftMode: PhysicsUpdraftMode;
  77607. }
  77608. /**
  77609. * Options fot the vortex event
  77610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77611. */
  77612. export class PhysicsVortexEventOptions {
  77613. /**
  77614. * The radius of the cylinder for the vortex
  77615. */
  77616. radius: number;
  77617. /**
  77618. * The strength of the vortex.
  77619. */
  77620. strength: number;
  77621. /**
  77622. * The height of the cylinder for the vortex.
  77623. */
  77624. height: number;
  77625. /**
  77626. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  77627. */
  77628. centripetalForceThreshold: number;
  77629. /**
  77630. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  77631. */
  77632. centripetalForceMultiplier: number;
  77633. /**
  77634. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  77635. */
  77636. centrifugalForceMultiplier: number;
  77637. /**
  77638. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  77639. */
  77640. updraftForceMultiplier: number;
  77641. }
  77642. /**
  77643. * The strength of the force in correspondence to the distance of the affected object
  77644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77645. */
  77646. export enum PhysicsRadialImpulseFalloff {
  77647. /** Defines that impulse is constant in strength across it's whole radius */
  77648. Constant = 0,
  77649. /** Defines that impulse gets weaker if it's further from the origin */
  77650. Linear = 1
  77651. }
  77652. /**
  77653. * The strength of the force in correspondence to the distance of the affected object
  77654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77655. */
  77656. export enum PhysicsUpdraftMode {
  77657. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  77658. Center = 0,
  77659. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  77660. Perpendicular = 1
  77661. }
  77662. /**
  77663. * Interface for a physics hit data
  77664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77665. */
  77666. export interface PhysicsHitData {
  77667. /**
  77668. * The force applied at the contact point
  77669. */
  77670. force: Vector3;
  77671. /**
  77672. * The contact point
  77673. */
  77674. contactPoint: Vector3;
  77675. /**
  77676. * The distance from the origin to the contact point
  77677. */
  77678. distanceFromOrigin: number;
  77679. }
  77680. /**
  77681. * Interface for radial explosion event data
  77682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77683. */
  77684. export interface PhysicsRadialExplosionEventData {
  77685. /**
  77686. * A sphere used for the radial explosion event
  77687. */
  77688. sphere: Mesh;
  77689. }
  77690. /**
  77691. * Interface for gravitational field event data
  77692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77693. */
  77694. export interface PhysicsGravitationalFieldEventData {
  77695. /**
  77696. * A sphere mesh used for the gravitational field event
  77697. */
  77698. sphere: Mesh;
  77699. }
  77700. /**
  77701. * Interface for updraft event data
  77702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77703. */
  77704. export interface PhysicsUpdraftEventData {
  77705. /**
  77706. * A cylinder used for the updraft event
  77707. */
  77708. cylinder: Mesh;
  77709. }
  77710. /**
  77711. * Interface for vortex event data
  77712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77713. */
  77714. export interface PhysicsVortexEventData {
  77715. /**
  77716. * A cylinder used for the vortex event
  77717. */
  77718. cylinder: Mesh;
  77719. }
  77720. /**
  77721. * Interface for an affected physics impostor
  77722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  77723. */
  77724. export interface PhysicsAffectedImpostorWithData {
  77725. /**
  77726. * The impostor affected by the effect
  77727. */
  77728. impostor: PhysicsImpostor;
  77729. /**
  77730. * The data about the hit/force from the explosion
  77731. */
  77732. hitData: PhysicsHitData;
  77733. }
  77734. }
  77735. declare module "babylonjs/Physics/Plugins/index" {
  77736. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  77737. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  77738. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  77739. }
  77740. declare module "babylonjs/Physics/index" {
  77741. export * from "babylonjs/Physics/IPhysicsEngine";
  77742. export * from "babylonjs/Physics/physicsEngine";
  77743. export * from "babylonjs/Physics/physicsEngineComponent";
  77744. export * from "babylonjs/Physics/physicsHelper";
  77745. export * from "babylonjs/Physics/physicsImpostor";
  77746. export * from "babylonjs/Physics/physicsJoint";
  77747. export * from "babylonjs/Physics/Plugins/index";
  77748. }
  77749. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  77750. /** @hidden */
  77751. export var blackAndWhitePixelShader: {
  77752. name: string;
  77753. shader: string;
  77754. };
  77755. }
  77756. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  77757. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77758. import { Camera } from "babylonjs/Cameras/camera";
  77759. import { Engine } from "babylonjs/Engines/engine";
  77760. import "babylonjs/Shaders/blackAndWhite.fragment";
  77761. import { Nullable } from "babylonjs/types";
  77762. import { Scene } from "babylonjs/scene";
  77763. /**
  77764. * Post process used to render in black and white
  77765. */
  77766. export class BlackAndWhitePostProcess extends PostProcess {
  77767. /**
  77768. * Linear about to convert he result to black and white (default: 1)
  77769. */
  77770. degree: number;
  77771. /**
  77772. * Gets a string identifying the name of the class
  77773. * @returns "BlackAndWhitePostProcess" string
  77774. */
  77775. getClassName(): string;
  77776. /**
  77777. * Creates a black and white post process
  77778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  77779. * @param name The name of the effect.
  77780. * @param options The required width/height ratio to downsize to before computing the render pass.
  77781. * @param camera The camera to apply the render pass to.
  77782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77783. * @param engine The engine which the post process will be applied. (default: current engine)
  77784. * @param reusable If the post process can be reused on the same frame. (default: false)
  77785. */
  77786. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77787. /** @hidden */
  77788. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  77789. }
  77790. }
  77791. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  77792. import { Nullable } from "babylonjs/types";
  77793. import { Camera } from "babylonjs/Cameras/camera";
  77794. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77795. import { Engine } from "babylonjs/Engines/engine";
  77796. /**
  77797. * This represents a set of one or more post processes in Babylon.
  77798. * A post process can be used to apply a shader to a texture after it is rendered.
  77799. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  77800. */
  77801. export class PostProcessRenderEffect {
  77802. private _postProcesses;
  77803. private _getPostProcesses;
  77804. private _singleInstance;
  77805. private _cameras;
  77806. private _indicesForCamera;
  77807. /**
  77808. * Name of the effect
  77809. * @hidden
  77810. */
  77811. _name: string;
  77812. /**
  77813. * Instantiates a post process render effect.
  77814. * A post process can be used to apply a shader to a texture after it is rendered.
  77815. * @param engine The engine the effect is tied to
  77816. * @param name The name of the effect
  77817. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  77818. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  77819. */
  77820. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  77821. /**
  77822. * Checks if all the post processes in the effect are supported.
  77823. */
  77824. get isSupported(): boolean;
  77825. /**
  77826. * Updates the current state of the effect
  77827. * @hidden
  77828. */
  77829. _update(): void;
  77830. /**
  77831. * Attaches the effect on cameras
  77832. * @param cameras The camera to attach to.
  77833. * @hidden
  77834. */
  77835. _attachCameras(cameras: Camera): void;
  77836. /**
  77837. * Attaches the effect on cameras
  77838. * @param cameras The camera to attach to.
  77839. * @hidden
  77840. */
  77841. _attachCameras(cameras: Camera[]): void;
  77842. /**
  77843. * Detaches the effect on cameras
  77844. * @param cameras The camera to detach from.
  77845. * @hidden
  77846. */
  77847. _detachCameras(cameras: Camera): void;
  77848. /**
  77849. * Detaches the effect on cameras
  77850. * @param cameras The camera to detach from.
  77851. * @hidden
  77852. */
  77853. _detachCameras(cameras: Camera[]): void;
  77854. /**
  77855. * Enables the effect on given cameras
  77856. * @param cameras The camera to enable.
  77857. * @hidden
  77858. */
  77859. _enable(cameras: Camera): void;
  77860. /**
  77861. * Enables the effect on given cameras
  77862. * @param cameras The camera to enable.
  77863. * @hidden
  77864. */
  77865. _enable(cameras: Nullable<Camera[]>): void;
  77866. /**
  77867. * Disables the effect on the given cameras
  77868. * @param cameras The camera to disable.
  77869. * @hidden
  77870. */
  77871. _disable(cameras: Camera): void;
  77872. /**
  77873. * Disables the effect on the given cameras
  77874. * @param cameras The camera to disable.
  77875. * @hidden
  77876. */
  77877. _disable(cameras: Nullable<Camera[]>): void;
  77878. /**
  77879. * Gets a list of the post processes contained in the effect.
  77880. * @param camera The camera to get the post processes on.
  77881. * @returns The list of the post processes in the effect.
  77882. */
  77883. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  77884. }
  77885. }
  77886. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  77887. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77888. /** @hidden */
  77889. export var extractHighlightsPixelShader: {
  77890. name: string;
  77891. shader: string;
  77892. };
  77893. }
  77894. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  77895. import { Nullable } from "babylonjs/types";
  77896. import { Camera } from "babylonjs/Cameras/camera";
  77897. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77898. import { Engine } from "babylonjs/Engines/engine";
  77899. import "babylonjs/Shaders/extractHighlights.fragment";
  77900. /**
  77901. * 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.
  77902. */
  77903. export class ExtractHighlightsPostProcess extends PostProcess {
  77904. /**
  77905. * The luminance threshold, pixels below this value will be set to black.
  77906. */
  77907. threshold: number;
  77908. /** @hidden */
  77909. _exposure: number;
  77910. /**
  77911. * Post process which has the input texture to be used when performing highlight extraction
  77912. * @hidden
  77913. */
  77914. _inputPostProcess: Nullable<PostProcess>;
  77915. /**
  77916. * Gets a string identifying the name of the class
  77917. * @returns "ExtractHighlightsPostProcess" string
  77918. */
  77919. getClassName(): string;
  77920. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77921. }
  77922. }
  77923. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  77924. /** @hidden */
  77925. export var bloomMergePixelShader: {
  77926. name: string;
  77927. shader: string;
  77928. };
  77929. }
  77930. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  77931. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77932. import { Nullable } from "babylonjs/types";
  77933. import { Engine } from "babylonjs/Engines/engine";
  77934. import { Camera } from "babylonjs/Cameras/camera";
  77935. import "babylonjs/Shaders/bloomMerge.fragment";
  77936. /**
  77937. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77938. */
  77939. export class BloomMergePostProcess extends PostProcess {
  77940. /** Weight of the bloom to be added to the original input. */
  77941. weight: number;
  77942. /**
  77943. * Gets a string identifying the name of the class
  77944. * @returns "BloomMergePostProcess" string
  77945. */
  77946. getClassName(): string;
  77947. /**
  77948. * Creates a new instance of @see BloomMergePostProcess
  77949. * @param name The name of the effect.
  77950. * @param originalFromInput Post process which's input will be used for the merge.
  77951. * @param blurred Blurred highlights post process which's output will be used.
  77952. * @param weight Weight of the bloom to be added to the original input.
  77953. * @param options The required width/height ratio to downsize to before computing the render pass.
  77954. * @param camera The camera to apply the render pass to.
  77955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77956. * @param engine The engine which the post process will be applied. (default: current engine)
  77957. * @param reusable If the post process can be reused on the same frame. (default: false)
  77958. * @param textureType Type of textures used when performing the post process. (default: 0)
  77959. * @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)
  77960. */
  77961. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  77962. /** Weight of the bloom to be added to the original input. */
  77963. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77964. }
  77965. }
  77966. declare module "babylonjs/PostProcesses/bloomEffect" {
  77967. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77968. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77969. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77970. import { Camera } from "babylonjs/Cameras/camera";
  77971. import { Scene } from "babylonjs/scene";
  77972. /**
  77973. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  77974. */
  77975. export class BloomEffect extends PostProcessRenderEffect {
  77976. private bloomScale;
  77977. /**
  77978. * @hidden Internal
  77979. */
  77980. _effects: Array<PostProcess>;
  77981. /**
  77982. * @hidden Internal
  77983. */
  77984. _downscale: ExtractHighlightsPostProcess;
  77985. private _blurX;
  77986. private _blurY;
  77987. private _merge;
  77988. /**
  77989. * The luminance threshold to find bright areas of the image to bloom.
  77990. */
  77991. get threshold(): number;
  77992. set threshold(value: number);
  77993. /**
  77994. * The strength of the bloom.
  77995. */
  77996. get weight(): number;
  77997. set weight(value: number);
  77998. /**
  77999. * Specifies the size of the bloom blur kernel, relative to the final output size
  78000. */
  78001. get kernel(): number;
  78002. set kernel(value: number);
  78003. /**
  78004. * Creates a new instance of @see BloomEffect
  78005. * @param scene The scene the effect belongs to.
  78006. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  78007. * @param bloomKernel The size of the kernel to be used when applying the blur.
  78008. * @param bloomWeight The the strength of bloom.
  78009. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  78010. * @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)
  78011. */
  78012. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  78013. /**
  78014. * Disposes each of the internal effects for a given camera.
  78015. * @param camera The camera to dispose the effect on.
  78016. */
  78017. disposeEffects(camera: Camera): void;
  78018. /**
  78019. * @hidden Internal
  78020. */
  78021. _updateEffects(): void;
  78022. /**
  78023. * Internal
  78024. * @returns if all the contained post processes are ready.
  78025. * @hidden
  78026. */
  78027. _isReady(): boolean;
  78028. }
  78029. }
  78030. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  78031. /** @hidden */
  78032. export var chromaticAberrationPixelShader: {
  78033. name: string;
  78034. shader: string;
  78035. };
  78036. }
  78037. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  78038. import { Vector2 } from "babylonjs/Maths/math.vector";
  78039. import { Nullable } from "babylonjs/types";
  78040. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78041. import { Camera } from "babylonjs/Cameras/camera";
  78042. import { Engine } from "babylonjs/Engines/engine";
  78043. import "babylonjs/Shaders/chromaticAberration.fragment";
  78044. import { Scene } from "babylonjs/scene";
  78045. /**
  78046. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  78047. */
  78048. export class ChromaticAberrationPostProcess extends PostProcess {
  78049. /**
  78050. * The amount of separation of rgb channels (default: 30)
  78051. */
  78052. aberrationAmount: number;
  78053. /**
  78054. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  78055. */
  78056. radialIntensity: number;
  78057. /**
  78058. * The normalized direction in which the rgb channels should be separated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  78059. */
  78060. direction: Vector2;
  78061. /**
  78062. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corner] (default: Vector2(0.5 ,0.5))
  78063. */
  78064. centerPosition: Vector2;
  78065. /** The width of the screen to apply the effect on */
  78066. screenWidth: number;
  78067. /** The height of the screen to apply the effect on */
  78068. screenHeight: number;
  78069. /**
  78070. * Gets a string identifying the name of the class
  78071. * @returns "ChromaticAberrationPostProcess" string
  78072. */
  78073. getClassName(): string;
  78074. /**
  78075. * Creates a new instance ChromaticAberrationPostProcess
  78076. * @param name The name of the effect.
  78077. * @param screenWidth The width of the screen to apply the effect on.
  78078. * @param screenHeight The height of the screen to apply the effect on.
  78079. * @param options The required width/height ratio to downsize to before computing the render pass.
  78080. * @param camera The camera to apply the render pass to.
  78081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78082. * @param engine The engine which the post process will be applied. (default: current engine)
  78083. * @param reusable If the post process can be reused on the same frame. (default: false)
  78084. * @param textureType Type of textures used when performing the post process. (default: 0)
  78085. * @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)
  78086. */
  78087. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78088. /** @hidden */
  78089. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  78090. }
  78091. }
  78092. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  78093. /** @hidden */
  78094. export var circleOfConfusionPixelShader: {
  78095. name: string;
  78096. shader: string;
  78097. };
  78098. }
  78099. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  78100. import { Nullable } from "babylonjs/types";
  78101. import { Engine } from "babylonjs/Engines/engine";
  78102. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78103. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  78104. import { Camera } from "babylonjs/Cameras/camera";
  78105. import "babylonjs/Shaders/circleOfConfusion.fragment";
  78106. /**
  78107. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  78108. */
  78109. export class CircleOfConfusionPostProcess extends PostProcess {
  78110. /**
  78111. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
  78112. */
  78113. lensSize: number;
  78114. /**
  78115. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  78116. */
  78117. fStop: number;
  78118. /**
  78119. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  78120. */
  78121. focusDistance: number;
  78122. /**
  78123. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  78124. */
  78125. focalLength: number;
  78126. /**
  78127. * Gets a string identifying the name of the class
  78128. * @returns "CircleOfConfusionPostProcess" string
  78129. */
  78130. getClassName(): string;
  78131. private _depthTexture;
  78132. /**
  78133. * Creates a new instance CircleOfConfusionPostProcess
  78134. * @param name The name of the effect.
  78135. * @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.
  78136. * @param options The required width/height ratio to downsize to before computing the render pass.
  78137. * @param camera The camera to apply the render pass to.
  78138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78139. * @param engine The engine which the post process will be applied. (default: current engine)
  78140. * @param reusable If the post process can be reused on the same frame. (default: false)
  78141. * @param textureType Type of textures used when performing the post process. (default: 0)
  78142. * @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)
  78143. */
  78144. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78145. /**
  78146. * 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.
  78147. */
  78148. set depthTexture(value: RenderTargetTexture);
  78149. }
  78150. }
  78151. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  78152. /** @hidden */
  78153. export var colorCorrectionPixelShader: {
  78154. name: string;
  78155. shader: string;
  78156. };
  78157. }
  78158. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  78159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78160. import { Engine } from "babylonjs/Engines/engine";
  78161. import { Camera } from "babylonjs/Cameras/camera";
  78162. import "babylonjs/Shaders/colorCorrection.fragment";
  78163. import { Nullable } from "babylonjs/types";
  78164. import { Scene } from "babylonjs/scene";
  78165. /**
  78166. *
  78167. * This post-process allows the modification of rendered colors by using
  78168. * a 'look-up table' (LUT). This effect is also called Color Grading.
  78169. *
  78170. * The object needs to be provided an url to a texture containing the color
  78171. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  78172. * Use an image editing software to tweak the LUT to match your needs.
  78173. *
  78174. * For an example of a color LUT, see here:
  78175. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  78176. * For explanations on color grading, see here:
  78177. * @see http://udn.epicgames.com/Three/ColorGrading.html
  78178. *
  78179. */
  78180. export class ColorCorrectionPostProcess extends PostProcess {
  78181. private _colorTableTexture;
  78182. /**
  78183. * Gets the color table url used to create the LUT texture
  78184. */
  78185. colorTableUrl: string;
  78186. /**
  78187. * Gets a string identifying the name of the class
  78188. * @returns "ColorCorrectionPostProcess" string
  78189. */
  78190. getClassName(): string;
  78191. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78192. /** @hidden */
  78193. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  78194. }
  78195. }
  78196. declare module "babylonjs/Shaders/convolution.fragment" {
  78197. /** @hidden */
  78198. export var convolutionPixelShader: {
  78199. name: string;
  78200. shader: string;
  78201. };
  78202. }
  78203. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  78204. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78205. import { Nullable } from "babylonjs/types";
  78206. import { Camera } from "babylonjs/Cameras/camera";
  78207. import { Engine } from "babylonjs/Engines/engine";
  78208. import "babylonjs/Shaders/convolution.fragment";
  78209. import { Scene } from "babylonjs/scene";
  78210. /**
  78211. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  78212. * input texture to perform effects such as edge detection or sharpening
  78213. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  78214. */
  78215. export class ConvolutionPostProcess extends PostProcess {
  78216. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  78217. kernel: number[];
  78218. /**
  78219. * Gets a string identifying the name of the class
  78220. * @returns "ConvolutionPostProcess" string
  78221. */
  78222. getClassName(): string;
  78223. /**
  78224. * Creates a new instance ConvolutionPostProcess
  78225. * @param name The name of the effect.
  78226. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  78227. * @param options The required width/height ratio to downsize to before computing the render pass.
  78228. * @param camera The camera to apply the render pass to.
  78229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78230. * @param engine The engine which the post process will be applied. (default: current engine)
  78231. * @param reusable If the post process can be reused on the same frame. (default: false)
  78232. * @param textureType Type of textures used when performing the post process. (default: 0)
  78233. */
  78234. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  78235. /** @hidden */
  78236. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  78237. /**
  78238. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  78239. */
  78240. static EdgeDetect0Kernel: number[];
  78241. /**
  78242. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  78243. */
  78244. static EdgeDetect1Kernel: number[];
  78245. /**
  78246. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  78247. */
  78248. static EdgeDetect2Kernel: number[];
  78249. /**
  78250. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  78251. */
  78252. static SharpenKernel: number[];
  78253. /**
  78254. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  78255. */
  78256. static EmbossKernel: number[];
  78257. /**
  78258. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  78259. */
  78260. static GaussianKernel: number[];
  78261. }
  78262. }
  78263. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  78264. import { Nullable } from "babylonjs/types";
  78265. import { Vector2 } from "babylonjs/Maths/math.vector";
  78266. import { Camera } from "babylonjs/Cameras/camera";
  78267. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78268. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  78269. import { Engine } from "babylonjs/Engines/engine";
  78270. import { Scene } from "babylonjs/scene";
  78271. /**
  78272. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  78273. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  78274. * based on samples that have a large difference in distance than the center pixel.
  78275. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  78276. */
  78277. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  78278. /**
  78279. * The direction the blur should be applied
  78280. */
  78281. direction: Vector2;
  78282. /**
  78283. * Gets a string identifying the name of the class
  78284. * @returns "DepthOfFieldBlurPostProcess" string
  78285. */
  78286. getClassName(): string;
  78287. /**
  78288. * Creates a new instance CircleOfConfusionPostProcess
  78289. * @param name The name of the effect.
  78290. * @param scene The scene the effect belongs to.
  78291. * @param direction The direction the blur should be applied.
  78292. * @param kernel The size of the kernel used to blur.
  78293. * @param options The required width/height ratio to downsize to before computing the render pass.
  78294. * @param camera The camera to apply the render pass to.
  78295. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  78296. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  78297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78298. * @param engine The engine which the post process will be applied. (default: current engine)
  78299. * @param reusable If the post process can be reused on the same frame. (default: false)
  78300. * @param textureType Type of textures used when performing the post process. (default: 0)
  78301. * @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)
  78302. */
  78303. 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);
  78304. }
  78305. }
  78306. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  78307. /** @hidden */
  78308. export var depthOfFieldMergePixelShader: {
  78309. name: string;
  78310. shader: string;
  78311. };
  78312. }
  78313. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  78314. import { Nullable } from "babylonjs/types";
  78315. import { Camera } from "babylonjs/Cameras/camera";
  78316. import { Effect } from "babylonjs/Materials/effect";
  78317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78318. import { Engine } from "babylonjs/Engines/engine";
  78319. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  78320. /**
  78321. * Options to be set when merging outputs from the default pipeline.
  78322. */
  78323. export class DepthOfFieldMergePostProcessOptions {
  78324. /**
  78325. * The original image to merge on top of
  78326. */
  78327. originalFromInput: PostProcess;
  78328. /**
  78329. * Parameters to perform the merge of the depth of field effect
  78330. */
  78331. depthOfField?: {
  78332. circleOfConfusion: PostProcess;
  78333. blurSteps: Array<PostProcess>;
  78334. };
  78335. /**
  78336. * Parameters to perform the merge of bloom effect
  78337. */
  78338. bloom?: {
  78339. blurred: PostProcess;
  78340. weight: number;
  78341. };
  78342. }
  78343. /**
  78344. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  78345. */
  78346. export class DepthOfFieldMergePostProcess extends PostProcess {
  78347. private blurSteps;
  78348. /**
  78349. * Gets a string identifying the name of the class
  78350. * @returns "DepthOfFieldMergePostProcess" string
  78351. */
  78352. getClassName(): string;
  78353. /**
  78354. * Creates a new instance of DepthOfFieldMergePostProcess
  78355. * @param name The name of the effect.
  78356. * @param originalFromInput Post process which's input will be used for the merge.
  78357. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  78358. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  78359. * @param options The required width/height ratio to downsize to before computing the render pass.
  78360. * @param camera The camera to apply the render pass to.
  78361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78362. * @param engine The engine which the post process will be applied. (default: current engine)
  78363. * @param reusable If the post process can be reused on the same frame. (default: false)
  78364. * @param textureType Type of textures used when performing the post process. (default: 0)
  78365. * @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)
  78366. */
  78367. 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);
  78368. /**
  78369. * Updates the effect with the current post process compile time values and recompiles the shader.
  78370. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  78371. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  78372. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  78373. * @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
  78374. * @param onCompiled Called when the shader has been compiled.
  78375. * @param onError Called if there is an error when compiling a shader.
  78376. */
  78377. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78378. }
  78379. }
  78380. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  78381. import { Nullable } from "babylonjs/types";
  78382. import { Camera } from "babylonjs/Cameras/camera";
  78383. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  78384. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  78385. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  78386. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  78387. import { Scene } from "babylonjs/scene";
  78388. /**
  78389. * Specifies the level of max blur that should be applied when using the depth of field effect
  78390. */
  78391. export enum DepthOfFieldEffectBlurLevel {
  78392. /**
  78393. * Subtle blur
  78394. */
  78395. Low = 0,
  78396. /**
  78397. * Medium blur
  78398. */
  78399. Medium = 1,
  78400. /**
  78401. * Large blur
  78402. */
  78403. High = 2
  78404. }
  78405. /**
  78406. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  78407. */
  78408. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  78409. private _circleOfConfusion;
  78410. /**
  78411. * @hidden Internal, blurs from high to low
  78412. */
  78413. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  78414. private _depthOfFieldBlurY;
  78415. private _dofMerge;
  78416. /**
  78417. * @hidden Internal post processes in depth of field effect
  78418. */
  78419. _effects: Array<PostProcess>;
  78420. /**
  78421. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  78422. */
  78423. set focalLength(value: number);
  78424. get focalLength(): number;
  78425. /**
  78426. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  78427. */
  78428. set fStop(value: number);
  78429. get fStop(): number;
  78430. /**
  78431. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  78432. */
  78433. set focusDistance(value: number);
  78434. get focusDistance(): number;
  78435. /**
  78436. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
  78437. */
  78438. set lensSize(value: number);
  78439. get lensSize(): number;
  78440. /**
  78441. * Creates a new instance DepthOfFieldEffect
  78442. * @param scene The scene the effect belongs to.
  78443. * @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.
  78444. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  78445. * @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)
  78446. */
  78447. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  78448. /**
  78449. * Get the current class name of the current effect
  78450. * @returns "DepthOfFieldEffect"
  78451. */
  78452. getClassName(): string;
  78453. /**
  78454. * 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.
  78455. */
  78456. set depthTexture(value: RenderTargetTexture);
  78457. /**
  78458. * Disposes each of the internal effects for a given camera.
  78459. * @param camera The camera to dispose the effect on.
  78460. */
  78461. disposeEffects(camera: Camera): void;
  78462. /**
  78463. * @hidden Internal
  78464. */
  78465. _updateEffects(): void;
  78466. /**
  78467. * Internal
  78468. * @returns if all the contained post processes are ready.
  78469. * @hidden
  78470. */
  78471. _isReady(): boolean;
  78472. }
  78473. }
  78474. declare module "babylonjs/Shaders/displayPass.fragment" {
  78475. /** @hidden */
  78476. export var displayPassPixelShader: {
  78477. name: string;
  78478. shader: string;
  78479. };
  78480. }
  78481. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  78482. import { Nullable } from "babylonjs/types";
  78483. import { Camera } from "babylonjs/Cameras/camera";
  78484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78485. import { Engine } from "babylonjs/Engines/engine";
  78486. import "babylonjs/Shaders/displayPass.fragment";
  78487. import { Scene } from "babylonjs/scene";
  78488. /**
  78489. * DisplayPassPostProcess which produces an output the same as it's input
  78490. */
  78491. export class DisplayPassPostProcess extends PostProcess {
  78492. /**
  78493. * Gets a string identifying the name of the class
  78494. * @returns "DisplayPassPostProcess" string
  78495. */
  78496. getClassName(): string;
  78497. /**
  78498. * Creates the DisplayPassPostProcess
  78499. * @param name The name of the effect.
  78500. * @param options The required width/height ratio to downsize to before computing the render pass.
  78501. * @param camera The camera to apply the render pass to.
  78502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78503. * @param engine The engine which the post process will be applied. (default: current engine)
  78504. * @param reusable If the post process can be reused on the same frame. (default: false)
  78505. */
  78506. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78507. /** @hidden */
  78508. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  78509. }
  78510. }
  78511. declare module "babylonjs/Shaders/filter.fragment" {
  78512. /** @hidden */
  78513. export var filterPixelShader: {
  78514. name: string;
  78515. shader: string;
  78516. };
  78517. }
  78518. declare module "babylonjs/PostProcesses/filterPostProcess" {
  78519. import { Nullable } from "babylonjs/types";
  78520. import { Matrix } from "babylonjs/Maths/math.vector";
  78521. import { Camera } from "babylonjs/Cameras/camera";
  78522. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78523. import { Engine } from "babylonjs/Engines/engine";
  78524. import "babylonjs/Shaders/filter.fragment";
  78525. import { Scene } from "babylonjs/scene";
  78526. /**
  78527. * Applies a kernel filter to the image
  78528. */
  78529. export class FilterPostProcess extends PostProcess {
  78530. /** The matrix to be applied to the image */
  78531. kernelMatrix: Matrix;
  78532. /**
  78533. * Gets a string identifying the name of the class
  78534. * @returns "FilterPostProcess" string
  78535. */
  78536. getClassName(): string;
  78537. /**
  78538. *
  78539. * @param name The name of the effect.
  78540. * @param kernelMatrix The matrix to be applied to the image
  78541. * @param options The required width/height ratio to downsize to before computing the render pass.
  78542. * @param camera The camera to apply the render pass to.
  78543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78544. * @param engine The engine which the post process will be applied. (default: current engine)
  78545. * @param reusable If the post process can be reused on the same frame. (default: false)
  78546. */
  78547. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78548. /** @hidden */
  78549. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  78550. }
  78551. }
  78552. declare module "babylonjs/Shaders/fxaa.fragment" {
  78553. /** @hidden */
  78554. export var fxaaPixelShader: {
  78555. name: string;
  78556. shader: string;
  78557. };
  78558. }
  78559. declare module "babylonjs/Shaders/fxaa.vertex" {
  78560. /** @hidden */
  78561. export var fxaaVertexShader: {
  78562. name: string;
  78563. shader: string;
  78564. };
  78565. }
  78566. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  78567. import { Nullable } from "babylonjs/types";
  78568. import { Camera } from "babylonjs/Cameras/camera";
  78569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78570. import { Engine } from "babylonjs/Engines/engine";
  78571. import "babylonjs/Shaders/fxaa.fragment";
  78572. import "babylonjs/Shaders/fxaa.vertex";
  78573. import { Scene } from "babylonjs/scene";
  78574. /**
  78575. * Fxaa post process
  78576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  78577. */
  78578. export class FxaaPostProcess extends PostProcess {
  78579. /**
  78580. * Gets a string identifying the name of the class
  78581. * @returns "FxaaPostProcess" string
  78582. */
  78583. getClassName(): string;
  78584. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  78585. private _getDefines;
  78586. /** @hidden */
  78587. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  78588. }
  78589. }
  78590. declare module "babylonjs/Shaders/grain.fragment" {
  78591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  78592. /** @hidden */
  78593. export var grainPixelShader: {
  78594. name: string;
  78595. shader: string;
  78596. };
  78597. }
  78598. declare module "babylonjs/PostProcesses/grainPostProcess" {
  78599. import { Nullable } from "babylonjs/types";
  78600. import { Camera } from "babylonjs/Cameras/camera";
  78601. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78602. import { Engine } from "babylonjs/Engines/engine";
  78603. import "babylonjs/Shaders/grain.fragment";
  78604. import { Scene } from "babylonjs/scene";
  78605. /**
  78606. * The GrainPostProcess adds noise to the image at mid luminance levels
  78607. */
  78608. export class GrainPostProcess extends PostProcess {
  78609. /**
  78610. * The intensity of the grain added (default: 30)
  78611. */
  78612. intensity: number;
  78613. /**
  78614. * If the grain should be randomized on every frame
  78615. */
  78616. animated: boolean;
  78617. /**
  78618. * Gets a string identifying the name of the class
  78619. * @returns "GrainPostProcess" string
  78620. */
  78621. getClassName(): string;
  78622. /**
  78623. * Creates a new instance of @see GrainPostProcess
  78624. * @param name The name of the effect.
  78625. * @param options The required width/height ratio to downsize to before computing the render pass.
  78626. * @param camera The camera to apply the render pass to.
  78627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78628. * @param engine The engine which the post process will be applied. (default: current engine)
  78629. * @param reusable If the post process can be reused on the same frame. (default: false)
  78630. * @param textureType Type of textures used when performing the post process. (default: 0)
  78631. * @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)
  78632. */
  78633. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78634. /** @hidden */
  78635. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  78636. }
  78637. }
  78638. declare module "babylonjs/Shaders/highlights.fragment" {
  78639. /** @hidden */
  78640. export var highlightsPixelShader: {
  78641. name: string;
  78642. shader: string;
  78643. };
  78644. }
  78645. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  78646. import { Nullable } from "babylonjs/types";
  78647. import { Camera } from "babylonjs/Cameras/camera";
  78648. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78649. import { Engine } from "babylonjs/Engines/engine";
  78650. import "babylonjs/Shaders/highlights.fragment";
  78651. /**
  78652. * Extracts highlights from the image
  78653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78654. */
  78655. export class HighlightsPostProcess extends PostProcess {
  78656. /**
  78657. * Gets a string identifying the name of the class
  78658. * @returns "HighlightsPostProcess" string
  78659. */
  78660. getClassName(): string;
  78661. /**
  78662. * Extracts highlights from the image
  78663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78664. * @param name The name of the effect.
  78665. * @param options The required width/height ratio to downsize to before computing the render pass.
  78666. * @param camera The camera to apply the render pass to.
  78667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78668. * @param engine The engine which the post process will be applied. (default: current engine)
  78669. * @param reusable If the post process can be reused on the same frame. (default: false)
  78670. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  78671. */
  78672. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  78673. }
  78674. }
  78675. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  78676. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  78677. /**
  78678. * Contains all parameters needed for the prepass to perform
  78679. * motion blur
  78680. */
  78681. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  78682. /**
  78683. * Is motion blur enabled
  78684. */
  78685. enabled: boolean;
  78686. /**
  78687. * Name of the configuration
  78688. */
  78689. name: string;
  78690. /**
  78691. * Textures that should be present in the MRT for this effect to work
  78692. */
  78693. readonly texturesRequired: number[];
  78694. }
  78695. }
  78696. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  78697. import { Nullable } from "babylonjs/types";
  78698. import { Scene } from "babylonjs/scene";
  78699. import { ISceneComponent } from "babylonjs/sceneComponent";
  78700. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  78701. module "babylonjs/scene" {
  78702. interface Scene {
  78703. /** @hidden (Backing field) */
  78704. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  78705. /**
  78706. * Gets or Sets the current geometry buffer associated to the scene.
  78707. */
  78708. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  78709. /**
  78710. * Enables a GeometryBufferRender and associates it with the scene
  78711. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  78712. * @returns the GeometryBufferRenderer
  78713. */
  78714. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  78715. /**
  78716. * Disables the GeometryBufferRender associated with the scene
  78717. */
  78718. disableGeometryBufferRenderer(): void;
  78719. }
  78720. }
  78721. /**
  78722. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  78723. * in several rendering techniques.
  78724. */
  78725. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  78726. /**
  78727. * The component name helpful to identify the component in the list of scene components.
  78728. */
  78729. readonly name: string;
  78730. /**
  78731. * The scene the component belongs to.
  78732. */
  78733. scene: Scene;
  78734. /**
  78735. * Creates a new instance of the component for the given scene
  78736. * @param scene Defines the scene to register the component in
  78737. */
  78738. constructor(scene: Scene);
  78739. /**
  78740. * Registers the component in a given scene
  78741. */
  78742. register(): void;
  78743. /**
  78744. * Rebuilds the elements related to this component in case of
  78745. * context lost for instance.
  78746. */
  78747. rebuild(): void;
  78748. /**
  78749. * Disposes the component and the associated resources
  78750. */
  78751. dispose(): void;
  78752. private _gatherRenderTargets;
  78753. }
  78754. }
  78755. declare module "babylonjs/Shaders/motionBlur.fragment" {
  78756. /** @hidden */
  78757. export var motionBlurPixelShader: {
  78758. name: string;
  78759. shader: string;
  78760. };
  78761. }
  78762. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  78763. import { Nullable } from "babylonjs/types";
  78764. import { Camera } from "babylonjs/Cameras/camera";
  78765. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78767. import "babylonjs/Animations/animatable";
  78768. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  78769. import "babylonjs/Shaders/motionBlur.fragment";
  78770. import { Engine } from "babylonjs/Engines/engine";
  78771. import { Scene } from "babylonjs/scene";
  78772. /**
  78773. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  78774. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  78775. * As an example, all you have to do is to create the post-process:
  78776. * var mb = new BABYLON.MotionBlurPostProcess(
  78777. * 'mb', // The name of the effect.
  78778. * scene, // The scene containing the objects to blur according to their velocity.
  78779. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  78780. * camera // The camera to apply the render pass to.
  78781. * );
  78782. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  78783. */
  78784. export class MotionBlurPostProcess extends PostProcess {
  78785. /**
  78786. * Defines how much the image is blurred by the movement. Default value is equal to 1
  78787. */
  78788. motionStrength: number;
  78789. /**
  78790. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  78791. */
  78792. get motionBlurSamples(): number;
  78793. /**
  78794. * Sets the number of iterations to be used for motion blur quality
  78795. */
  78796. set motionBlurSamples(samples: number);
  78797. private _motionBlurSamples;
  78798. /**
  78799. * Gets whether or not the motion blur post-process is in object based mode.
  78800. */
  78801. get isObjectBased(): boolean;
  78802. /**
  78803. * Sets whether or not the motion blur post-process is in object based mode.
  78804. */
  78805. set isObjectBased(value: boolean);
  78806. private _isObjectBased;
  78807. private _forceGeometryBuffer;
  78808. private _geometryBufferRenderer;
  78809. private _prePassRenderer;
  78810. private _invViewProjection;
  78811. private _previousViewProjection;
  78812. /**
  78813. * Gets a string identifying the name of the class
  78814. * @returns "MotionBlurPostProcess" string
  78815. */
  78816. getClassName(): string;
  78817. /**
  78818. * Creates a new instance MotionBlurPostProcess
  78819. * @param name The name of the effect.
  78820. * @param scene The scene containing the objects to blur according to their velocity.
  78821. * @param options The required width/height ratio to downsize to before computing the render pass.
  78822. * @param camera The camera to apply the render pass to.
  78823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78824. * @param engine The engine which the post process will be applied. (default: current engine)
  78825. * @param reusable If the post process can be reused on the same frame. (default: false)
  78826. * @param textureType Type of textures used when performing the post process. (default: 0)
  78827. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  78828. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  78829. */
  78830. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  78831. /**
  78832. * Excludes the given skinned mesh from computing bones velocities.
  78833. * 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.
  78834. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  78835. */
  78836. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  78837. /**
  78838. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  78839. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  78840. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  78841. */
  78842. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  78843. /**
  78844. * Disposes the post process.
  78845. * @param camera The camera to dispose the post process on.
  78846. */
  78847. dispose(camera?: Camera): void;
  78848. /**
  78849. * Called on the mode changed (object based or screen based).
  78850. */
  78851. private _applyMode;
  78852. /**
  78853. * Called on the effect is applied when the motion blur post-process is in object based mode.
  78854. */
  78855. private _onApplyObjectBased;
  78856. /**
  78857. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  78858. */
  78859. private _onApplyScreenBased;
  78860. /**
  78861. * Called on the effect must be updated (changed mode, samples count, etc.).
  78862. */
  78863. private _updateEffect;
  78864. /** @hidden */
  78865. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  78866. }
  78867. }
  78868. declare module "babylonjs/Shaders/refraction.fragment" {
  78869. /** @hidden */
  78870. export var refractionPixelShader: {
  78871. name: string;
  78872. shader: string;
  78873. };
  78874. }
  78875. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  78876. import { Color3 } from "babylonjs/Maths/math.color";
  78877. import { Camera } from "babylonjs/Cameras/camera";
  78878. import { Texture } from "babylonjs/Materials/Textures/texture";
  78879. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78880. import { Engine } from "babylonjs/Engines/engine";
  78881. import "babylonjs/Shaders/refraction.fragment";
  78882. import { Scene } from "babylonjs/scene";
  78883. /**
  78884. * Post process which applies a refraction texture
  78885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78886. */
  78887. export class RefractionPostProcess extends PostProcess {
  78888. private _refTexture;
  78889. private _ownRefractionTexture;
  78890. /** the base color of the refraction (used to taint the rendering) */
  78891. color: Color3;
  78892. /** simulated refraction depth */
  78893. depth: number;
  78894. /** the coefficient of the base color (0 to remove base color tainting) */
  78895. colorLevel: number;
  78896. /** Gets the url used to load the refraction texture */
  78897. refractionTextureUrl: string;
  78898. /**
  78899. * Gets or sets the refraction texture
  78900. * Please note that you are responsible for disposing the texture if you set it manually
  78901. */
  78902. get refractionTexture(): Texture;
  78903. set refractionTexture(value: Texture);
  78904. /**
  78905. * Gets a string identifying the name of the class
  78906. * @returns "RefractionPostProcess" string
  78907. */
  78908. getClassName(): string;
  78909. /**
  78910. * Initializes the RefractionPostProcess
  78911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78912. * @param name The name of the effect.
  78913. * @param refractionTextureUrl Url of the refraction texture to use
  78914. * @param color the base color of the refraction (used to taint the rendering)
  78915. * @param depth simulated refraction depth
  78916. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  78917. * @param camera The camera to apply the render pass to.
  78918. * @param options The required width/height ratio to downsize to before computing the render pass.
  78919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78920. * @param engine The engine which the post process will be applied. (default: current engine)
  78921. * @param reusable If the post process can be reused on the same frame. (default: false)
  78922. */
  78923. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78924. /**
  78925. * Disposes of the post process
  78926. * @param camera Camera to dispose post process on
  78927. */
  78928. dispose(camera: Camera): void;
  78929. /** @hidden */
  78930. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  78931. }
  78932. }
  78933. declare module "babylonjs/Shaders/sharpen.fragment" {
  78934. /** @hidden */
  78935. export var sharpenPixelShader: {
  78936. name: string;
  78937. shader: string;
  78938. };
  78939. }
  78940. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  78941. import { Nullable } from "babylonjs/types";
  78942. import { Camera } from "babylonjs/Cameras/camera";
  78943. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78944. import "babylonjs/Shaders/sharpen.fragment";
  78945. import { Engine } from "babylonjs/Engines/engine";
  78946. import { Scene } from "babylonjs/scene";
  78947. /**
  78948. * The SharpenPostProcess applies a sharpen kernel to every pixel
  78949. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  78950. */
  78951. export class SharpenPostProcess extends PostProcess {
  78952. /**
  78953. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  78954. */
  78955. colorAmount: number;
  78956. /**
  78957. * How much sharpness should be applied (default: 0.3)
  78958. */
  78959. edgeAmount: number;
  78960. /**
  78961. * Gets a string identifying the name of the class
  78962. * @returns "SharpenPostProcess" string
  78963. */
  78964. getClassName(): string;
  78965. /**
  78966. * Creates a new instance ConvolutionPostProcess
  78967. * @param name The name of the effect.
  78968. * @param options The required width/height ratio to downsize to before computing the render pass.
  78969. * @param camera The camera to apply the render pass to.
  78970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78971. * @param engine The engine which the post process will be applied. (default: current engine)
  78972. * @param reusable If the post process can be reused on the same frame. (default: false)
  78973. * @param textureType Type of textures used when performing the post process. (default: 0)
  78974. * @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)
  78975. */
  78976. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78977. /** @hidden */
  78978. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  78979. }
  78980. }
  78981. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  78982. import { Nullable } from "babylonjs/types";
  78983. import { Camera } from "babylonjs/Cameras/camera";
  78984. import { Engine } from "babylonjs/Engines/engine";
  78985. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  78986. import { IInspectable } from "babylonjs/Misc/iInspectable";
  78987. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  78988. /**
  78989. * PostProcessRenderPipeline
  78990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78991. */
  78992. export class PostProcessRenderPipeline {
  78993. private engine;
  78994. private _renderEffects;
  78995. private _renderEffectsForIsolatedPass;
  78996. /**
  78997. * List of inspectable custom properties (used by the Inspector)
  78998. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78999. */
  79000. inspectableCustomProperties: IInspectable[];
  79001. /**
  79002. * @hidden
  79003. */
  79004. protected _cameras: Camera[];
  79005. /** @hidden */
  79006. _name: string;
  79007. /**
  79008. * Gets pipeline name
  79009. */
  79010. get name(): string;
  79011. /** Gets the list of attached cameras */
  79012. get cameras(): Camera[];
  79013. /**
  79014. * Initializes a PostProcessRenderPipeline
  79015. * @param engine engine to add the pipeline to
  79016. * @param name name of the pipeline
  79017. */
  79018. constructor(engine: Engine, name: string);
  79019. /**
  79020. * Gets the class name
  79021. * @returns "PostProcessRenderPipeline"
  79022. */
  79023. getClassName(): string;
  79024. /**
  79025. * If all the render effects in the pipeline are supported
  79026. */
  79027. get isSupported(): boolean;
  79028. /**
  79029. * Adds an effect to the pipeline
  79030. * @param renderEffect the effect to add
  79031. */
  79032. addEffect(renderEffect: PostProcessRenderEffect): void;
  79033. /** @hidden */
  79034. _rebuild(): void;
  79035. /** @hidden */
  79036. _enableEffect(renderEffectName: string, cameras: Camera): void;
  79037. /** @hidden */
  79038. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  79039. /** @hidden */
  79040. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  79041. /** @hidden */
  79042. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  79043. /** @hidden */
  79044. _attachCameras(cameras: Camera, unique: boolean): void;
  79045. /** @hidden */
  79046. _attachCameras(cameras: Camera[], unique: boolean): void;
  79047. /** @hidden */
  79048. _detachCameras(cameras: Camera): void;
  79049. /** @hidden */
  79050. _detachCameras(cameras: Nullable<Camera[]>): void;
  79051. /** @hidden */
  79052. _update(): void;
  79053. /** @hidden */
  79054. _reset(): void;
  79055. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  79056. /**
  79057. * Sets the required values to the prepass renderer.
  79058. * @param prePassRenderer defines the prepass renderer to setup.
  79059. * @returns true if the pre pass is needed.
  79060. */
  79061. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  79062. /**
  79063. * Disposes of the pipeline
  79064. */
  79065. dispose(): void;
  79066. }
  79067. }
  79068. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  79069. import { Camera } from "babylonjs/Cameras/camera";
  79070. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79071. /**
  79072. * PostProcessRenderPipelineManager class
  79073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  79074. */
  79075. export class PostProcessRenderPipelineManager {
  79076. private _renderPipelines;
  79077. /**
  79078. * Initializes a PostProcessRenderPipelineManager
  79079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  79080. */
  79081. constructor();
  79082. /**
  79083. * Gets the list of supported render pipelines
  79084. */
  79085. get supportedPipelines(): PostProcessRenderPipeline[];
  79086. /**
  79087. * Adds a pipeline to the manager
  79088. * @param renderPipeline The pipeline to add
  79089. */
  79090. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  79091. /**
  79092. * Attaches a camera to the pipeline
  79093. * @param renderPipelineName The name of the pipeline to attach to
  79094. * @param cameras the camera to attach
  79095. * @param unique if the camera can be attached multiple times to the pipeline
  79096. */
  79097. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  79098. /**
  79099. * Detaches a camera from the pipeline
  79100. * @param renderPipelineName The name of the pipeline to detach from
  79101. * @param cameras the camera to detach
  79102. */
  79103. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  79104. /**
  79105. * Enables an effect by name on a pipeline
  79106. * @param renderPipelineName the name of the pipeline to enable the effect in
  79107. * @param renderEffectName the name of the effect to enable
  79108. * @param cameras the cameras that the effect should be enabled on
  79109. */
  79110. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  79111. /**
  79112. * Disables an effect by name on a pipeline
  79113. * @param renderPipelineName the name of the pipeline to disable the effect in
  79114. * @param renderEffectName the name of the effect to disable
  79115. * @param cameras the cameras that the effect should be disabled on
  79116. */
  79117. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  79118. /**
  79119. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  79120. */
  79121. update(): void;
  79122. /** @hidden */
  79123. _rebuild(): void;
  79124. /**
  79125. * Disposes of the manager and pipelines
  79126. */
  79127. dispose(): void;
  79128. }
  79129. }
  79130. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  79131. import { ISceneComponent } from "babylonjs/sceneComponent";
  79132. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  79133. import { Scene } from "babylonjs/scene";
  79134. module "babylonjs/scene" {
  79135. interface Scene {
  79136. /** @hidden (Backing field) */
  79137. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  79138. /**
  79139. * Gets the postprocess render pipeline manager
  79140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  79141. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  79142. */
  79143. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  79144. }
  79145. }
  79146. /**
  79147. * Defines the Render Pipeline scene component responsible to rendering pipelines
  79148. */
  79149. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  79150. /**
  79151. * The component name helpful to identify the component in the list of scene components.
  79152. */
  79153. readonly name: string;
  79154. /**
  79155. * The scene the component belongs to.
  79156. */
  79157. scene: Scene;
  79158. /**
  79159. * Creates a new instance of the component for the given scene
  79160. * @param scene Defines the scene to register the component in
  79161. */
  79162. constructor(scene: Scene);
  79163. /**
  79164. * Registers the component in a given scene
  79165. */
  79166. register(): void;
  79167. /**
  79168. * Rebuilds the elements related to this component in case of
  79169. * context lost for instance.
  79170. */
  79171. rebuild(): void;
  79172. /**
  79173. * Disposes the component and the associated resources
  79174. */
  79175. dispose(): void;
  79176. private _gatherRenderTargets;
  79177. }
  79178. }
  79179. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  79180. import { Nullable } from "babylonjs/types";
  79181. import { Observable } from "babylonjs/Misc/observable";
  79182. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  79183. import { Camera } from "babylonjs/Cameras/camera";
  79184. import { IDisposable } from "babylonjs/scene";
  79185. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  79186. import { Scene } from "babylonjs/scene";
  79187. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  79188. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  79189. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  79190. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  79191. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  79192. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79193. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  79194. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79195. import { Animation } from "babylonjs/Animations/animation";
  79196. /**
  79197. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  79198. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  79199. */
  79200. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  79201. private _scene;
  79202. private _camerasToBeAttached;
  79203. /**
  79204. * ID of the sharpen post process,
  79205. */
  79206. private readonly SharpenPostProcessId;
  79207. /**
  79208. * @ignore
  79209. * ID of the image processing post process;
  79210. */
  79211. readonly ImageProcessingPostProcessId: string;
  79212. /**
  79213. * @ignore
  79214. * ID of the Fast Approximate Anti-Aliasing post process;
  79215. */
  79216. readonly FxaaPostProcessId: string;
  79217. /**
  79218. * ID of the chromatic aberration post process,
  79219. */
  79220. private readonly ChromaticAberrationPostProcessId;
  79221. /**
  79222. * ID of the grain post process
  79223. */
  79224. private readonly GrainPostProcessId;
  79225. /**
  79226. * Sharpen post process which will apply a sharpen convolution to enhance edges
  79227. */
  79228. sharpen: SharpenPostProcess;
  79229. private _sharpenEffect;
  79230. private bloom;
  79231. /**
  79232. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  79233. */
  79234. depthOfField: DepthOfFieldEffect;
  79235. /**
  79236. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  79237. */
  79238. fxaa: FxaaPostProcess;
  79239. /**
  79240. * Image post processing pass used to perform operations such as tone mapping or color grading.
  79241. */
  79242. imageProcessing: ImageProcessingPostProcess;
  79243. /**
  79244. * Chromatic aberration post process which will shift rgb colors in the image
  79245. */
  79246. chromaticAberration: ChromaticAberrationPostProcess;
  79247. private _chromaticAberrationEffect;
  79248. /**
  79249. * Grain post process which add noise to the image
  79250. */
  79251. grain: GrainPostProcess;
  79252. private _grainEffect;
  79253. /**
  79254. * Glow post process which adds a glow to emissive areas of the image
  79255. */
  79256. private _glowLayer;
  79257. /**
  79258. * Animations which can be used to tweak settings over a period of time
  79259. */
  79260. animations: Animation[];
  79261. private _imageProcessingConfigurationObserver;
  79262. private _sharpenEnabled;
  79263. private _bloomEnabled;
  79264. private _depthOfFieldEnabled;
  79265. private _depthOfFieldBlurLevel;
  79266. private _fxaaEnabled;
  79267. private _imageProcessingEnabled;
  79268. private _defaultPipelineTextureType;
  79269. private _bloomScale;
  79270. private _chromaticAberrationEnabled;
  79271. private _grainEnabled;
  79272. private _buildAllowed;
  79273. /**
  79274. * This is triggered each time the pipeline has been built.
  79275. */
  79276. onBuildObservable: Observable<DefaultRenderingPipeline>;
  79277. /**
  79278. * Gets active scene
  79279. */
  79280. get scene(): Scene;
  79281. /**
  79282. * Enable or disable the sharpen process from the pipeline
  79283. */
  79284. set sharpenEnabled(enabled: boolean);
  79285. get sharpenEnabled(): boolean;
  79286. private _resizeObserver;
  79287. private _hardwareScaleLevel;
  79288. private _bloomKernel;
  79289. /**
  79290. * Specifies the size of the bloom blur kernel, relative to the final output size
  79291. */
  79292. get bloomKernel(): number;
  79293. set bloomKernel(value: number);
  79294. /**
  79295. * Specifies the weight of the bloom in the final rendering
  79296. */
  79297. private _bloomWeight;
  79298. /**
  79299. * Specifies the luma threshold for the area that will be blurred by the bloom
  79300. */
  79301. private _bloomThreshold;
  79302. private _hdr;
  79303. /**
  79304. * The strength of the bloom.
  79305. */
  79306. set bloomWeight(value: number);
  79307. get bloomWeight(): number;
  79308. /**
  79309. * The strength of the bloom.
  79310. */
  79311. set bloomThreshold(value: number);
  79312. get bloomThreshold(): number;
  79313. /**
  79314. * The scale of the bloom, lower value will provide better performance.
  79315. */
  79316. set bloomScale(value: number);
  79317. get bloomScale(): number;
  79318. /**
  79319. * Enable or disable the bloom from the pipeline
  79320. */
  79321. set bloomEnabled(enabled: boolean);
  79322. get bloomEnabled(): boolean;
  79323. private _rebuildBloom;
  79324. /**
  79325. * If the depth of field is enabled.
  79326. */
  79327. get depthOfFieldEnabled(): boolean;
  79328. set depthOfFieldEnabled(enabled: boolean);
  79329. /**
  79330. * Blur level of the depth of field effect. (Higher blur will effect performance)
  79331. */
  79332. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  79333. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  79334. /**
  79335. * If the anti aliasing is enabled.
  79336. */
  79337. set fxaaEnabled(enabled: boolean);
  79338. get fxaaEnabled(): boolean;
  79339. private _samples;
  79340. /**
  79341. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  79342. */
  79343. set samples(sampleCount: number);
  79344. get samples(): number;
  79345. /**
  79346. * If image processing is enabled.
  79347. */
  79348. set imageProcessingEnabled(enabled: boolean);
  79349. get imageProcessingEnabled(): boolean;
  79350. /**
  79351. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  79352. */
  79353. set glowLayerEnabled(enabled: boolean);
  79354. get glowLayerEnabled(): boolean;
  79355. /**
  79356. * Gets the glow layer (or null if not defined)
  79357. */
  79358. get glowLayer(): Nullable<GlowLayer>;
  79359. /**
  79360. * Enable or disable the chromaticAberration process from the pipeline
  79361. */
  79362. set chromaticAberrationEnabled(enabled: boolean);
  79363. get chromaticAberrationEnabled(): boolean;
  79364. /**
  79365. * Enable or disable the grain process from the pipeline
  79366. */
  79367. set grainEnabled(enabled: boolean);
  79368. get grainEnabled(): boolean;
  79369. /**
  79370. * @constructor
  79371. * @param name - The rendering pipeline name (default: "")
  79372. * @param hdr - If high dynamic range textures should be used (default: true)
  79373. * @param scene - The scene linked to this pipeline (default: the last created scene)
  79374. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  79375. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  79376. */
  79377. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  79378. /**
  79379. * Get the class name
  79380. * @returns "DefaultRenderingPipeline"
  79381. */
  79382. getClassName(): string;
  79383. /**
  79384. * Force the compilation of the entire pipeline.
  79385. */
  79386. prepare(): void;
  79387. private _hasCleared;
  79388. private _prevPostProcess;
  79389. private _prevPrevPostProcess;
  79390. private _setAutoClearAndTextureSharing;
  79391. private _depthOfFieldSceneObserver;
  79392. private _buildPipeline;
  79393. private _disposePostProcesses;
  79394. /**
  79395. * Adds a camera to the pipeline
  79396. * @param camera the camera to be added
  79397. */
  79398. addCamera(camera: Camera): void;
  79399. /**
  79400. * Removes a camera from the pipeline
  79401. * @param camera the camera to remove
  79402. */
  79403. removeCamera(camera: Camera): void;
  79404. /**
  79405. * Dispose of the pipeline and stop all post processes
  79406. */
  79407. dispose(): void;
  79408. /**
  79409. * Serialize the rendering pipeline (Used when exporting)
  79410. * @returns the serialized object
  79411. */
  79412. serialize(): any;
  79413. /**
  79414. * Parse the serialized pipeline
  79415. * @param source Source pipeline.
  79416. * @param scene The scene to load the pipeline to.
  79417. * @param rootUrl The URL of the serialized pipeline.
  79418. * @returns An instantiated pipeline from the serialized object.
  79419. */
  79420. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  79421. }
  79422. }
  79423. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  79424. /** @hidden */
  79425. export var lensHighlightsPixelShader: {
  79426. name: string;
  79427. shader: string;
  79428. };
  79429. }
  79430. declare module "babylonjs/Shaders/depthOfField.fragment" {
  79431. /** @hidden */
  79432. export var depthOfFieldPixelShader: {
  79433. name: string;
  79434. shader: string;
  79435. };
  79436. }
  79437. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  79438. import { Camera } from "babylonjs/Cameras/camera";
  79439. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79440. import { Scene } from "babylonjs/scene";
  79441. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79442. import "babylonjs/Shaders/chromaticAberration.fragment";
  79443. import "babylonjs/Shaders/lensHighlights.fragment";
  79444. import "babylonjs/Shaders/depthOfField.fragment";
  79445. /**
  79446. * BABYLON.JS Chromatic Aberration GLSL Shader
  79447. * Author: Olivier Guyot
  79448. * Separates very slightly R, G and B colors on the edges of the screen
  79449. * Inspired by Francois Tarlier & Martins Upitis
  79450. */
  79451. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  79452. /**
  79453. * @ignore
  79454. * The chromatic aberration PostProcess id in the pipeline
  79455. */
  79456. LensChromaticAberrationEffect: string;
  79457. /**
  79458. * @ignore
  79459. * The highlights enhancing PostProcess id in the pipeline
  79460. */
  79461. HighlightsEnhancingEffect: string;
  79462. /**
  79463. * @ignore
  79464. * The depth-of-field PostProcess id in the pipeline
  79465. */
  79466. LensDepthOfFieldEffect: string;
  79467. private _scene;
  79468. private _depthTexture;
  79469. private _grainTexture;
  79470. private _chromaticAberrationPostProcess;
  79471. private _highlightsPostProcess;
  79472. private _depthOfFieldPostProcess;
  79473. private _edgeBlur;
  79474. private _grainAmount;
  79475. private _chromaticAberration;
  79476. private _distortion;
  79477. private _highlightsGain;
  79478. private _highlightsThreshold;
  79479. private _dofDistance;
  79480. private _dofAperture;
  79481. private _dofDarken;
  79482. private _dofPentagon;
  79483. private _blurNoise;
  79484. /**
  79485. * @constructor
  79486. *
  79487. * Effect parameters are as follow:
  79488. * {
  79489. * chromatic_aberration: number; // from 0 to x (1 for realism)
  79490. * edge_blur: number; // from 0 to x (1 for realism)
  79491. * distortion: number; // from 0 to x (1 for realism)
  79492. * grain_amount: number; // from 0 to 1
  79493. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  79494. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  79495. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  79496. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  79497. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  79498. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  79499. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  79500. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  79501. * }
  79502. * Note: if an effect parameter is unset, effect is disabled
  79503. *
  79504. * @param name The rendering pipeline name
  79505. * @param parameters - An object containing all parameters (see above)
  79506. * @param scene The scene linked to this pipeline
  79507. * @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)
  79508. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79509. */
  79510. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  79511. /**
  79512. * Get the class name
  79513. * @returns "LensRenderingPipeline"
  79514. */
  79515. getClassName(): string;
  79516. /**
  79517. * Gets associated scene
  79518. */
  79519. get scene(): Scene;
  79520. /**
  79521. * Gets or sets the edge blur
  79522. */
  79523. get edgeBlur(): number;
  79524. set edgeBlur(value: number);
  79525. /**
  79526. * Gets or sets the grain amount
  79527. */
  79528. get grainAmount(): number;
  79529. set grainAmount(value: number);
  79530. /**
  79531. * Gets or sets the chromatic aberration amount
  79532. */
  79533. get chromaticAberration(): number;
  79534. set chromaticAberration(value: number);
  79535. /**
  79536. * Gets or sets the depth of field aperture
  79537. */
  79538. get dofAperture(): number;
  79539. set dofAperture(value: number);
  79540. /**
  79541. * Gets or sets the edge distortion
  79542. */
  79543. get edgeDistortion(): number;
  79544. set edgeDistortion(value: number);
  79545. /**
  79546. * Gets or sets the depth of field distortion
  79547. */
  79548. get dofDistortion(): number;
  79549. set dofDistortion(value: number);
  79550. /**
  79551. * Gets or sets the darken out of focus amount
  79552. */
  79553. get darkenOutOfFocus(): number;
  79554. set darkenOutOfFocus(value: number);
  79555. /**
  79556. * Gets or sets a boolean indicating if blur noise is enabled
  79557. */
  79558. get blurNoise(): boolean;
  79559. set blurNoise(value: boolean);
  79560. /**
  79561. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  79562. */
  79563. get pentagonBokeh(): boolean;
  79564. set pentagonBokeh(value: boolean);
  79565. /**
  79566. * Gets or sets the highlight grain amount
  79567. */
  79568. get highlightsGain(): number;
  79569. set highlightsGain(value: number);
  79570. /**
  79571. * Gets or sets the highlight threshold
  79572. */
  79573. get highlightsThreshold(): number;
  79574. set highlightsThreshold(value: number);
  79575. /**
  79576. * Sets the amount of blur at the edges
  79577. * @param amount blur amount
  79578. */
  79579. setEdgeBlur(amount: number): void;
  79580. /**
  79581. * Sets edge blur to 0
  79582. */
  79583. disableEdgeBlur(): void;
  79584. /**
  79585. * Sets the amount of grain
  79586. * @param amount Amount of grain
  79587. */
  79588. setGrainAmount(amount: number): void;
  79589. /**
  79590. * Set grain amount to 0
  79591. */
  79592. disableGrain(): void;
  79593. /**
  79594. * Sets the chromatic aberration amount
  79595. * @param amount amount of chromatic aberration
  79596. */
  79597. setChromaticAberration(amount: number): void;
  79598. /**
  79599. * Sets chromatic aberration amount to 0
  79600. */
  79601. disableChromaticAberration(): void;
  79602. /**
  79603. * Sets the EdgeDistortion amount
  79604. * @param amount amount of EdgeDistortion
  79605. */
  79606. setEdgeDistortion(amount: number): void;
  79607. /**
  79608. * Sets edge distortion to 0
  79609. */
  79610. disableEdgeDistortion(): void;
  79611. /**
  79612. * Sets the FocusDistance amount
  79613. * @param amount amount of FocusDistance
  79614. */
  79615. setFocusDistance(amount: number): void;
  79616. /**
  79617. * Disables depth of field
  79618. */
  79619. disableDepthOfField(): void;
  79620. /**
  79621. * Sets the Aperture amount
  79622. * @param amount amount of Aperture
  79623. */
  79624. setAperture(amount: number): void;
  79625. /**
  79626. * Sets the DarkenOutOfFocus amount
  79627. * @param amount amount of DarkenOutOfFocus
  79628. */
  79629. setDarkenOutOfFocus(amount: number): void;
  79630. private _pentagonBokehIsEnabled;
  79631. /**
  79632. * Creates a pentagon bokeh effect
  79633. */
  79634. enablePentagonBokeh(): void;
  79635. /**
  79636. * Disables the pentagon bokeh effect
  79637. */
  79638. disablePentagonBokeh(): void;
  79639. /**
  79640. * Enables noise blur
  79641. */
  79642. enableNoiseBlur(): void;
  79643. /**
  79644. * Disables noise blur
  79645. */
  79646. disableNoiseBlur(): void;
  79647. /**
  79648. * Sets the HighlightsGain amount
  79649. * @param amount amount of HighlightsGain
  79650. */
  79651. setHighlightsGain(amount: number): void;
  79652. /**
  79653. * Sets the HighlightsThreshold amount
  79654. * @param amount amount of HighlightsThreshold
  79655. */
  79656. setHighlightsThreshold(amount: number): void;
  79657. /**
  79658. * Disables highlights
  79659. */
  79660. disableHighlights(): void;
  79661. /**
  79662. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  79663. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  79664. */
  79665. dispose(disableDepthRender?: boolean): void;
  79666. private _createChromaticAberrationPostProcess;
  79667. private _createHighlightsPostProcess;
  79668. private _createDepthOfFieldPostProcess;
  79669. private _createGrainTexture;
  79670. }
  79671. }
  79672. declare module "babylonjs/Rendering/ssao2Configuration" {
  79673. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  79674. /**
  79675. * Contains all parameters needed for the prepass to perform
  79676. * screen space subsurface scattering
  79677. */
  79678. export class SSAO2Configuration implements PrePassEffectConfiguration {
  79679. /**
  79680. * Is subsurface enabled
  79681. */
  79682. enabled: boolean;
  79683. /**
  79684. * Name of the configuration
  79685. */
  79686. name: string;
  79687. /**
  79688. * Textures that should be present in the MRT for this effect to work
  79689. */
  79690. readonly texturesRequired: number[];
  79691. }
  79692. }
  79693. declare module "babylonjs/Shaders/ssao2.fragment" {
  79694. /** @hidden */
  79695. export var ssao2PixelShader: {
  79696. name: string;
  79697. shader: string;
  79698. };
  79699. }
  79700. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  79701. /** @hidden */
  79702. export var ssaoCombinePixelShader: {
  79703. name: string;
  79704. shader: string;
  79705. };
  79706. }
  79707. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  79708. import { Camera } from "babylonjs/Cameras/camera";
  79709. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79710. import { Scene } from "babylonjs/scene";
  79711. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79712. import "babylonjs/Shaders/ssao2.fragment";
  79713. import "babylonjs/Shaders/ssaoCombine.fragment";
  79714. /**
  79715. * Render pipeline to produce ssao effect
  79716. */
  79717. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  79718. /**
  79719. * @ignore
  79720. * The PassPostProcess id in the pipeline that contains the original scene color
  79721. */
  79722. SSAOOriginalSceneColorEffect: string;
  79723. /**
  79724. * @ignore
  79725. * The SSAO PostProcess id in the pipeline
  79726. */
  79727. SSAORenderEffect: string;
  79728. /**
  79729. * @ignore
  79730. * The horizontal blur PostProcess id in the pipeline
  79731. */
  79732. SSAOBlurHRenderEffect: string;
  79733. /**
  79734. * @ignore
  79735. * The vertical blur PostProcess id in the pipeline
  79736. */
  79737. SSAOBlurVRenderEffect: string;
  79738. /**
  79739. * @ignore
  79740. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  79741. */
  79742. SSAOCombineRenderEffect: string;
  79743. /**
  79744. * The output strength of the SSAO post-process. Default value is 1.0.
  79745. */
  79746. totalStrength: number;
  79747. /**
  79748. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  79749. */
  79750. maxZ: number;
  79751. /**
  79752. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  79753. */
  79754. minZAspect: number;
  79755. private _samples;
  79756. /**
  79757. * Number of samples used for the SSAO calculations. Default value is 8
  79758. */
  79759. set samples(n: number);
  79760. get samples(): number;
  79761. private _textureSamples;
  79762. /**
  79763. * Number of samples to use for antialiasing
  79764. */
  79765. set textureSamples(n: number);
  79766. get textureSamples(): number;
  79767. /**
  79768. * Force rendering the geometry through geometry buffer
  79769. */
  79770. private _forceGeometryBuffer;
  79771. /**
  79772. * Ratio object used for SSAO ratio and blur ratio
  79773. */
  79774. private _ratio;
  79775. /**
  79776. * Dynamically generated sphere sampler.
  79777. */
  79778. private _sampleSphere;
  79779. /**
  79780. * Blur filter offsets
  79781. */
  79782. private _samplerOffsets;
  79783. private _expensiveBlur;
  79784. /**
  79785. * If bilateral blur should be used
  79786. */
  79787. set expensiveBlur(b: boolean);
  79788. get expensiveBlur(): boolean;
  79789. /**
  79790. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  79791. */
  79792. radius: number;
  79793. /**
  79794. * The base color of the SSAO post-process
  79795. * The final result is "base + ssao" between [0, 1]
  79796. */
  79797. base: number;
  79798. /**
  79799. * Support test.
  79800. */
  79801. static get IsSupported(): boolean;
  79802. private _scene;
  79803. private _randomTexture;
  79804. private _originalColorPostProcess;
  79805. private _ssaoPostProcess;
  79806. private _blurHPostProcess;
  79807. private _blurVPostProcess;
  79808. private _ssaoCombinePostProcess;
  79809. private _prePassRenderer;
  79810. /**
  79811. * Gets active scene
  79812. */
  79813. get scene(): Scene;
  79814. /**
  79815. * @constructor
  79816. * @param name The rendering pipeline name
  79817. * @param scene The scene linked to this pipeline
  79818. * @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 }
  79819. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79820. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  79821. */
  79822. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  79823. /**
  79824. * Get the class name
  79825. * @returns "SSAO2RenderingPipeline"
  79826. */
  79827. getClassName(): string;
  79828. /**
  79829. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  79830. */
  79831. dispose(disableGeometryBufferRenderer?: boolean): void;
  79832. private _createBlurPostProcess;
  79833. /** @hidden */
  79834. _rebuild(): void;
  79835. private _bits;
  79836. private _radicalInverse_VdC;
  79837. private _hammersley;
  79838. private _hemisphereSample_uniform;
  79839. private _generateHemisphere;
  79840. private _getDefinesForSSAO;
  79841. private static readonly ORTHO_DEPTH_PROJECTION;
  79842. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  79843. private _createSSAOPostProcess;
  79844. private _createSSAOCombinePostProcess;
  79845. private _createRandomTexture;
  79846. /**
  79847. * Serialize the rendering pipeline (Used when exporting)
  79848. * @returns the serialized object
  79849. */
  79850. serialize(): any;
  79851. /**
  79852. * Parse the serialized pipeline
  79853. * @param source Source pipeline.
  79854. * @param scene The scene to load the pipeline to.
  79855. * @param rootUrl The URL of the serialized pipeline.
  79856. * @returns An instantiated pipeline from the serialized object.
  79857. */
  79858. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  79859. }
  79860. }
  79861. declare module "babylonjs/Shaders/ssao.fragment" {
  79862. /** @hidden */
  79863. export var ssaoPixelShader: {
  79864. name: string;
  79865. shader: string;
  79866. };
  79867. }
  79868. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  79869. import { Camera } from "babylonjs/Cameras/camera";
  79870. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79871. import { Scene } from "babylonjs/scene";
  79872. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79873. import "babylonjs/Shaders/ssao.fragment";
  79874. import "babylonjs/Shaders/ssaoCombine.fragment";
  79875. /**
  79876. * Render pipeline to produce ssao effect
  79877. */
  79878. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  79879. /**
  79880. * @ignore
  79881. * The PassPostProcess id in the pipeline that contains the original scene color
  79882. */
  79883. SSAOOriginalSceneColorEffect: string;
  79884. /**
  79885. * @ignore
  79886. * The SSAO PostProcess id in the pipeline
  79887. */
  79888. SSAORenderEffect: string;
  79889. /**
  79890. * @ignore
  79891. * The horizontal blur PostProcess id in the pipeline
  79892. */
  79893. SSAOBlurHRenderEffect: string;
  79894. /**
  79895. * @ignore
  79896. * The vertical blur PostProcess id in the pipeline
  79897. */
  79898. SSAOBlurVRenderEffect: string;
  79899. /**
  79900. * @ignore
  79901. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  79902. */
  79903. SSAOCombineRenderEffect: string;
  79904. /**
  79905. * The output strength of the SSAO post-process. Default value is 1.0.
  79906. */
  79907. totalStrength: number;
  79908. /**
  79909. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  79910. */
  79911. radius: number;
  79912. /**
  79913. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  79914. * Must not be equal to fallOff and superior to fallOff.
  79915. * Default value is 0.0075
  79916. */
  79917. area: number;
  79918. /**
  79919. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  79920. * Must not be equal to area and inferior to area.
  79921. * Default value is 0.000001
  79922. */
  79923. fallOff: number;
  79924. /**
  79925. * The base color of the SSAO post-process
  79926. * The final result is "base + ssao" between [0, 1]
  79927. */
  79928. base: number;
  79929. private _scene;
  79930. private _depthTexture;
  79931. private _randomTexture;
  79932. private _originalColorPostProcess;
  79933. private _ssaoPostProcess;
  79934. private _blurHPostProcess;
  79935. private _blurVPostProcess;
  79936. private _ssaoCombinePostProcess;
  79937. private _firstUpdate;
  79938. /**
  79939. * Gets active scene
  79940. */
  79941. get scene(): Scene;
  79942. /**
  79943. * @constructor
  79944. * @param name - The rendering pipeline name
  79945. * @param scene - The scene linked to this pipeline
  79946. * @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 }
  79947. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  79948. */
  79949. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  79950. /**
  79951. * Get the class name
  79952. * @returns "SSAORenderingPipeline"
  79953. */
  79954. getClassName(): string;
  79955. /**
  79956. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  79957. */
  79958. dispose(disableDepthRender?: boolean): void;
  79959. private _createBlurPostProcess;
  79960. /** @hidden */
  79961. _rebuild(): void;
  79962. private _createSSAOPostProcess;
  79963. private _createSSAOCombinePostProcess;
  79964. private _createRandomTexture;
  79965. }
  79966. }
  79967. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  79968. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  79969. /**
  79970. * Contains all parameters needed for the prepass to perform
  79971. * screen space reflections
  79972. */
  79973. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  79974. /**
  79975. * Is ssr enabled
  79976. */
  79977. enabled: boolean;
  79978. /**
  79979. * Name of the configuration
  79980. */
  79981. name: string;
  79982. /**
  79983. * Textures that should be present in the MRT for this effect to work
  79984. */
  79985. readonly texturesRequired: number[];
  79986. }
  79987. }
  79988. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  79989. /** @hidden */
  79990. export var screenSpaceReflectionPixelShader: {
  79991. name: string;
  79992. shader: string;
  79993. };
  79994. }
  79995. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  79996. import { Nullable } from "babylonjs/types";
  79997. import { Camera } from "babylonjs/Cameras/camera";
  79998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  79999. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  80000. import { Engine } from "babylonjs/Engines/engine";
  80001. import { Scene } from "babylonjs/scene";
  80002. /**
  80003. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  80004. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  80005. */
  80006. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  80007. /**
  80008. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  80009. */
  80010. threshold: number;
  80011. /**
  80012. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  80013. */
  80014. strength: number;
  80015. /**
  80016. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  80017. */
  80018. reflectionSpecularFalloffExponent: number;
  80019. /**
  80020. * 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]
  80021. */
  80022. step: number;
  80023. /**
  80024. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  80025. */
  80026. roughnessFactor: number;
  80027. private _forceGeometryBuffer;
  80028. private _geometryBufferRenderer;
  80029. private _prePassRenderer;
  80030. private _enableSmoothReflections;
  80031. private _reflectionSamples;
  80032. private _smoothSteps;
  80033. /**
  80034. * Gets a string identifying the name of the class
  80035. * @returns "ScreenSpaceReflectionPostProcess" string
  80036. */
  80037. getClassName(): string;
  80038. /**
  80039. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  80040. * @param name The name of the effect.
  80041. * @param scene The scene containing the objects to calculate reflections.
  80042. * @param options The required width/height ratio to downsize to before computing the render pass.
  80043. * @param camera The camera to apply the render pass to.
  80044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80045. * @param engine The engine which the post process will be applied. (default: current engine)
  80046. * @param reusable If the post process can be reused on the same frame. (default: false)
  80047. * @param textureType Type of textures used when performing the post process. (default: 0)
  80048. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  80049. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  80050. */
  80051. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  80052. /**
  80053. * Gets whether or not smoothing reflections is enabled.
  80054. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  80055. */
  80056. get enableSmoothReflections(): boolean;
  80057. /**
  80058. * Sets whether or not smoothing reflections is enabled.
  80059. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  80060. */
  80061. set enableSmoothReflections(enabled: boolean);
  80062. /**
  80063. * Gets the number of samples taken while computing reflections. More samples count is high,
  80064. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  80065. */
  80066. get reflectionSamples(): number;
  80067. /**
  80068. * Sets the number of samples taken while computing reflections. More samples count is high,
  80069. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  80070. */
  80071. set reflectionSamples(samples: number);
  80072. /**
  80073. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  80074. * more the post-process will require GPU power and can generate a drop in FPS.
  80075. * Default value (5.0) work pretty well in all cases but can be adjusted.
  80076. */
  80077. get smoothSteps(): number;
  80078. set smoothSteps(steps: number);
  80079. private _updateEffectDefines;
  80080. /** @hidden */
  80081. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  80082. }
  80083. }
  80084. declare module "babylonjs/Shaders/standard.fragment" {
  80085. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  80086. /** @hidden */
  80087. export var standardPixelShader: {
  80088. name: string;
  80089. shader: string;
  80090. };
  80091. }
  80092. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  80093. import { Nullable } from "babylonjs/types";
  80094. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  80095. import { Camera } from "babylonjs/Cameras/camera";
  80096. import { Texture } from "babylonjs/Materials/Textures/texture";
  80097. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  80098. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  80099. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  80100. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  80101. import { IDisposable } from "babylonjs/scene";
  80102. import { SpotLight } from "babylonjs/Lights/spotLight";
  80103. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  80104. import { Scene } from "babylonjs/scene";
  80105. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  80106. import { Animation } from "babylonjs/Animations/animation";
  80107. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  80108. import "babylonjs/Shaders/standard.fragment";
  80109. /**
  80110. * Standard rendering pipeline
  80111. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  80112. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  80113. */
  80114. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  80115. /**
  80116. * Public members
  80117. */
  80118. /**
  80119. * Post-process which contains the original scene color before the pipeline applies all the effects
  80120. */
  80121. originalPostProcess: Nullable<PostProcess>;
  80122. /**
  80123. * Post-process used to down scale an image x4
  80124. */
  80125. downSampleX4PostProcess: Nullable<PostProcess>;
  80126. /**
  80127. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  80128. */
  80129. brightPassPostProcess: Nullable<PostProcess>;
  80130. /**
  80131. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  80132. */
  80133. blurHPostProcesses: PostProcess[];
  80134. /**
  80135. * Post-process array storing all the vertical blur post-processes used by the pipeline
  80136. */
  80137. blurVPostProcesses: PostProcess[];
  80138. /**
  80139. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  80140. */
  80141. textureAdderPostProcess: Nullable<PostProcess>;
  80142. /**
  80143. * Post-process used to create volumetric lighting effect
  80144. */
  80145. volumetricLightPostProcess: Nullable<PostProcess>;
  80146. /**
  80147. * Post-process used to smooth the previous volumetric light post-process on the X axis
  80148. */
  80149. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  80150. /**
  80151. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  80152. */
  80153. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  80154. /**
  80155. * Post-process used to merge the volumetric light effect and the real scene color
  80156. */
  80157. volumetricLightMergePostProces: Nullable<PostProcess>;
  80158. /**
  80159. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  80160. */
  80161. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  80162. /**
  80163. * Base post-process used to calculate the average luminance of the final image for HDR
  80164. */
  80165. luminancePostProcess: Nullable<PostProcess>;
  80166. /**
  80167. * Post-processes used to create down sample post-processes in order to get
  80168. * the average luminance of the final image for HDR
  80169. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  80170. */
  80171. luminanceDownSamplePostProcesses: PostProcess[];
  80172. /**
  80173. * Post-process used to create a HDR effect (light adaptation)
  80174. */
  80175. hdrPostProcess: Nullable<PostProcess>;
  80176. /**
  80177. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  80178. */
  80179. textureAdderFinalPostProcess: Nullable<PostProcess>;
  80180. /**
  80181. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  80182. */
  80183. lensFlareFinalPostProcess: Nullable<PostProcess>;
  80184. /**
  80185. * Post-process used to merge the final HDR post-process and the real scene color
  80186. */
  80187. hdrFinalPostProcess: Nullable<PostProcess>;
  80188. /**
  80189. * Post-process used to create a lens flare effect
  80190. */
  80191. lensFlarePostProcess: Nullable<PostProcess>;
  80192. /**
  80193. * Post-process that merges the result of the lens flare post-process and the real scene color
  80194. */
  80195. lensFlareComposePostProcess: Nullable<PostProcess>;
  80196. /**
  80197. * Post-process used to create a motion blur effect
  80198. */
  80199. motionBlurPostProcess: Nullable<PostProcess>;
  80200. /**
  80201. * Post-process used to create a depth of field effect
  80202. */
  80203. depthOfFieldPostProcess: Nullable<PostProcess>;
  80204. /**
  80205. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  80206. */
  80207. fxaaPostProcess: Nullable<FxaaPostProcess>;
  80208. /**
  80209. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  80210. */
  80211. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  80212. /**
  80213. * Represents the brightness threshold in order to configure the illuminated surfaces
  80214. */
  80215. brightThreshold: number;
  80216. /**
  80217. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  80218. */
  80219. blurWidth: number;
  80220. /**
  80221. * Sets if the blur for highlighted surfaces must be only horizontal
  80222. */
  80223. horizontalBlur: boolean;
  80224. /**
  80225. * Gets the overall exposure used by the pipeline
  80226. */
  80227. get exposure(): number;
  80228. /**
  80229. * Sets the overall exposure used by the pipeline
  80230. */
  80231. set exposure(value: number);
  80232. /**
  80233. * Texture used typically to simulate "dirty" on camera lens
  80234. */
  80235. lensTexture: Nullable<Texture>;
  80236. /**
  80237. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  80238. */
  80239. volumetricLightCoefficient: number;
  80240. /**
  80241. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  80242. */
  80243. volumetricLightPower: number;
  80244. /**
  80245. * Used the set the blur intensity to smooth the volumetric lights
  80246. */
  80247. volumetricLightBlurScale: number;
  80248. /**
  80249. * Light (spot or directional) used to generate the volumetric lights rays
  80250. * The source light must have a shadow generate so the pipeline can get its
  80251. * depth map
  80252. */
  80253. sourceLight: Nullable<SpotLight | DirectionalLight>;
  80254. /**
  80255. * For eye adaptation, represents the minimum luminance the eye can see
  80256. */
  80257. hdrMinimumLuminance: number;
  80258. /**
  80259. * For eye adaptation, represents the decrease luminance speed
  80260. */
  80261. hdrDecreaseRate: number;
  80262. /**
  80263. * For eye adaptation, represents the increase luminance speed
  80264. */
  80265. hdrIncreaseRate: number;
  80266. /**
  80267. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  80268. */
  80269. get hdrAutoExposure(): boolean;
  80270. /**
  80271. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  80272. */
  80273. set hdrAutoExposure(value: boolean);
  80274. /**
  80275. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  80276. */
  80277. lensColorTexture: Nullable<Texture>;
  80278. /**
  80279. * The overall strengh for the lens flare effect
  80280. */
  80281. lensFlareStrength: number;
  80282. /**
  80283. * Dispersion coefficient for lens flare ghosts
  80284. */
  80285. lensFlareGhostDispersal: number;
  80286. /**
  80287. * Main lens flare halo width
  80288. */
  80289. lensFlareHaloWidth: number;
  80290. /**
  80291. * Based on the lens distortion effect, defines how much the lens flare result
  80292. * is distorted
  80293. */
  80294. lensFlareDistortionStrength: number;
  80295. /**
  80296. * Configures the blur intensity used for for lens flare (halo)
  80297. */
  80298. lensFlareBlurWidth: number;
  80299. /**
  80300. * Lens star texture must be used to simulate rays on the flares and is available
  80301. * in the documentation
  80302. */
  80303. lensStarTexture: Nullable<Texture>;
  80304. /**
  80305. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  80306. * flare effect by taking account of the dirt texture
  80307. */
  80308. lensFlareDirtTexture: Nullable<Texture>;
  80309. /**
  80310. * Represents the focal length for the depth of field effect
  80311. */
  80312. depthOfFieldDistance: number;
  80313. /**
  80314. * Represents the blur intensity for the blurred part of the depth of field effect
  80315. */
  80316. depthOfFieldBlurWidth: number;
  80317. /**
  80318. * Gets how much the image is blurred by the movement while using the motion blur post-process
  80319. */
  80320. get motionStrength(): number;
  80321. /**
  80322. * Sets how much the image is blurred by the movement while using the motion blur post-process
  80323. */
  80324. set motionStrength(strength: number);
  80325. /**
  80326. * Gets whether or not the motion blur post-process is object based or screen based.
  80327. */
  80328. get objectBasedMotionBlur(): boolean;
  80329. /**
  80330. * Sets whether or not the motion blur post-process should be object based or screen based
  80331. */
  80332. set objectBasedMotionBlur(value: boolean);
  80333. /**
  80334. * List of animations for the pipeline (IAnimatable implementation)
  80335. */
  80336. animations: Animation[];
  80337. /**
  80338. * Private members
  80339. */
  80340. private _scene;
  80341. private _currentDepthOfFieldSource;
  80342. private _basePostProcess;
  80343. private _fixedExposure;
  80344. private _currentExposure;
  80345. private _hdrAutoExposure;
  80346. private _hdrCurrentLuminance;
  80347. private _motionStrength;
  80348. private _isObjectBasedMotionBlur;
  80349. private _floatTextureType;
  80350. private _camerasToBeAttached;
  80351. private _ratio;
  80352. private _bloomEnabled;
  80353. private _depthOfFieldEnabled;
  80354. private _vlsEnabled;
  80355. private _lensFlareEnabled;
  80356. private _hdrEnabled;
  80357. private _motionBlurEnabled;
  80358. private _fxaaEnabled;
  80359. private _screenSpaceReflectionsEnabled;
  80360. private _motionBlurSamples;
  80361. private _volumetricLightStepsCount;
  80362. private _samples;
  80363. /**
  80364. * @ignore
  80365. * Specifies if the bloom pipeline is enabled
  80366. */
  80367. get BloomEnabled(): boolean;
  80368. set BloomEnabled(enabled: boolean);
  80369. /**
  80370. * @ignore
  80371. * Specifies if the depth of field pipeline is enabled
  80372. */
  80373. get DepthOfFieldEnabled(): boolean;
  80374. set DepthOfFieldEnabled(enabled: boolean);
  80375. /**
  80376. * @ignore
  80377. * Specifies if the lens flare pipeline is enabled
  80378. */
  80379. get LensFlareEnabled(): boolean;
  80380. set LensFlareEnabled(enabled: boolean);
  80381. /**
  80382. * @ignore
  80383. * Specifies if the HDR pipeline is enabled
  80384. */
  80385. get HDREnabled(): boolean;
  80386. set HDREnabled(enabled: boolean);
  80387. /**
  80388. * @ignore
  80389. * Specifies if the volumetric lights scattering effect is enabled
  80390. */
  80391. get VLSEnabled(): boolean;
  80392. set VLSEnabled(enabled: boolean);
  80393. /**
  80394. * @ignore
  80395. * Specifies if the motion blur effect is enabled
  80396. */
  80397. get MotionBlurEnabled(): boolean;
  80398. set MotionBlurEnabled(enabled: boolean);
  80399. /**
  80400. * Specifies if anti-aliasing is enabled
  80401. */
  80402. get fxaaEnabled(): boolean;
  80403. set fxaaEnabled(enabled: boolean);
  80404. /**
  80405. * Specifies if screen space reflections are enabled.
  80406. */
  80407. get screenSpaceReflectionsEnabled(): boolean;
  80408. set screenSpaceReflectionsEnabled(enabled: boolean);
  80409. /**
  80410. * Specifies the number of steps used to calculate the volumetric lights
  80411. * Typically in interval [50, 200]
  80412. */
  80413. get volumetricLightStepsCount(): number;
  80414. set volumetricLightStepsCount(count: number);
  80415. /**
  80416. * Specifies the number of samples used for the motion blur effect
  80417. * Typically in interval [16, 64]
  80418. */
  80419. get motionBlurSamples(): number;
  80420. set motionBlurSamples(samples: number);
  80421. /**
  80422. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  80423. */
  80424. get samples(): number;
  80425. set samples(sampleCount: number);
  80426. /**
  80427. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  80428. * @constructor
  80429. * @param name The rendering pipeline name
  80430. * @param scene The scene linked to this pipeline
  80431. * @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)
  80432. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  80433. * @param cameras The array of cameras that the rendering pipeline will be attached to
  80434. */
  80435. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  80436. private _buildPipeline;
  80437. private _createDownSampleX4PostProcess;
  80438. private _createBrightPassPostProcess;
  80439. private _createBlurPostProcesses;
  80440. private _createTextureAdderPostProcess;
  80441. private _createVolumetricLightPostProcess;
  80442. private _createLuminancePostProcesses;
  80443. private _createHdrPostProcess;
  80444. private _createLensFlarePostProcess;
  80445. private _createDepthOfFieldPostProcess;
  80446. private _createMotionBlurPostProcess;
  80447. private _getDepthTexture;
  80448. private _disposePostProcesses;
  80449. /**
  80450. * Dispose of the pipeline and stop all post processes
  80451. */
  80452. dispose(): void;
  80453. /**
  80454. * Serialize the rendering pipeline (Used when exporting)
  80455. * @returns the serialized object
  80456. */
  80457. serialize(): any;
  80458. /**
  80459. * Parse the serialized pipeline
  80460. * @param source Source pipeline.
  80461. * @param scene The scene to load the pipeline to.
  80462. * @param rootUrl The URL of the serialized pipeline.
  80463. * @returns An instantiated pipeline from the serialized object.
  80464. */
  80465. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  80466. /**
  80467. * Luminance steps
  80468. */
  80469. static LuminanceSteps: number;
  80470. }
  80471. }
  80472. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  80473. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  80474. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  80475. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  80476. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  80477. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  80478. }
  80479. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  80480. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  80481. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  80482. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  80483. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  80484. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  80485. }
  80486. declare module "babylonjs/Shaders/tonemap.fragment" {
  80487. /** @hidden */
  80488. export var tonemapPixelShader: {
  80489. name: string;
  80490. shader: string;
  80491. };
  80492. }
  80493. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  80494. import { Camera } from "babylonjs/Cameras/camera";
  80495. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  80496. import "babylonjs/Shaders/tonemap.fragment";
  80497. import { Engine } from "babylonjs/Engines/engine";
  80498. /** Defines operator used for tonemapping */
  80499. export enum TonemappingOperator {
  80500. /** Hable */
  80501. Hable = 0,
  80502. /** Reinhard */
  80503. Reinhard = 1,
  80504. /** HejiDawson */
  80505. HejiDawson = 2,
  80506. /** Photographic */
  80507. Photographic = 3
  80508. }
  80509. /**
  80510. * Defines a post process to apply tone mapping
  80511. */
  80512. export class TonemapPostProcess extends PostProcess {
  80513. private _operator;
  80514. /** Defines the required exposure adjustment */
  80515. exposureAdjustment: number;
  80516. /**
  80517. * Gets a string identifying the name of the class
  80518. * @returns "TonemapPostProcess" string
  80519. */
  80520. getClassName(): string;
  80521. /**
  80522. * Creates a new TonemapPostProcess
  80523. * @param name defines the name of the postprocess
  80524. * @param _operator defines the operator to use
  80525. * @param exposureAdjustment defines the required exposure adjustement
  80526. * @param camera defines the camera to use (can be null)
  80527. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  80528. * @param engine defines the hosting engine (can be ignore if camera is set)
  80529. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80530. */
  80531. constructor(name: string, _operator: TonemappingOperator,
  80532. /** Defines the required exposure adjustment */
  80533. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  80534. }
  80535. }
  80536. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  80537. /** @hidden */
  80538. export var volumetricLightScatteringPixelShader: {
  80539. name: string;
  80540. shader: string;
  80541. };
  80542. }
  80543. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  80544. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  80545. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  80546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  80547. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  80548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal";
  80549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  80550. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  80551. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  80552. /** @hidden */
  80553. export var volumetricLightScatteringPassVertexShader: {
  80554. name: string;
  80555. shader: string;
  80556. };
  80557. }
  80558. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  80559. /** @hidden */
  80560. export var volumetricLightScatteringPassPixelShader: {
  80561. name: string;
  80562. shader: string;
  80563. };
  80564. }
  80565. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  80566. import { Vector3 } from "babylonjs/Maths/math.vector";
  80567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80568. import { Mesh } from "babylonjs/Meshes/mesh";
  80569. import { Camera } from "babylonjs/Cameras/camera";
  80570. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  80571. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  80572. import { Scene } from "babylonjs/scene";
  80573. import "babylonjs/Meshes/Builders/planeBuilder";
  80574. import "babylonjs/Shaders/depth.vertex";
  80575. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  80576. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  80577. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  80578. import { Engine } from "babylonjs/Engines/engine";
  80579. /**
  80580. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  80581. */
  80582. export class VolumetricLightScatteringPostProcess extends PostProcess {
  80583. private _volumetricLightScatteringPass;
  80584. private _volumetricLightScatteringRTT;
  80585. private _viewPort;
  80586. private _screenCoordinates;
  80587. private _cachedDefines;
  80588. /**
  80589. * If not undefined, the mesh position is computed from the attached node position
  80590. */
  80591. attachedNode: {
  80592. position: Vector3;
  80593. };
  80594. /**
  80595. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  80596. */
  80597. customMeshPosition: Vector3;
  80598. /**
  80599. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  80600. */
  80601. useCustomMeshPosition: boolean;
  80602. /**
  80603. * If the post-process should inverse the light scattering direction
  80604. */
  80605. invert: boolean;
  80606. /**
  80607. * The internal mesh used by the post-process
  80608. */
  80609. mesh: Mesh;
  80610. /**
  80611. * @hidden
  80612. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  80613. */
  80614. get useDiffuseColor(): boolean;
  80615. set useDiffuseColor(useDiffuseColor: boolean);
  80616. /**
  80617. * Array containing the excluded meshes not rendered in the internal pass
  80618. */
  80619. excludedMeshes: AbstractMesh[];
  80620. /**
  80621. * Controls the overall intensity of the post-process
  80622. */
  80623. exposure: number;
  80624. /**
  80625. * Dissipates each sample's contribution in range [0, 1]
  80626. */
  80627. decay: number;
  80628. /**
  80629. * Controls the overall intensity of each sample
  80630. */
  80631. weight: number;
  80632. /**
  80633. * Controls the density of each sample
  80634. */
  80635. density: number;
  80636. /**
  80637. * @constructor
  80638. * @param name The post-process name
  80639. * @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)
  80640. * @param camera The camera that the post-process will be attached to
  80641. * @param mesh The mesh used to create the light scattering
  80642. * @param samples The post-process quality, default 100
  80643. * @param samplingModeThe post-process filtering mode
  80644. * @param engine The babylon engine
  80645. * @param reusable If the post-process is reusable
  80646. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  80647. */
  80648. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  80649. /**
  80650. * Returns the string "VolumetricLightScatteringPostProcess"
  80651. * @returns "VolumetricLightScatteringPostProcess"
  80652. */
  80653. getClassName(): string;
  80654. private _isReady;
  80655. /**
  80656. * Sets the new light position for light scattering effect
  80657. * @param position The new custom light position
  80658. */
  80659. setCustomMeshPosition(position: Vector3): void;
  80660. /**
  80661. * Returns the light position for light scattering effect
  80662. * @return Vector3 The custom light position
  80663. */
  80664. getCustomMeshPosition(): Vector3;
  80665. /**
  80666. * Disposes the internal assets and detaches the post-process from the camera
  80667. */
  80668. dispose(camera: Camera): void;
  80669. /**
  80670. * Returns the render target texture used by the post-process
  80671. * @return the render target texture used by the post-process
  80672. */
  80673. getPass(): RenderTargetTexture;
  80674. private _meshExcluded;
  80675. private _createPass;
  80676. private _updateMeshScreenCoordinates;
  80677. /**
  80678. * Creates a default mesh for the Volumeric Light Scattering post-process
  80679. * @param name The mesh name
  80680. * @param scene The scene where to create the mesh
  80681. * @return the default mesh
  80682. */
  80683. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  80684. }
  80685. }
  80686. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  80687. /** @hidden */
  80688. export var screenSpaceCurvaturePixelShader: {
  80689. name: string;
  80690. shader: string;
  80691. };
  80692. }
  80693. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  80694. import { Nullable } from "babylonjs/types";
  80695. import { Camera } from "babylonjs/Cameras/camera";
  80696. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  80697. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  80698. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  80699. import { Engine } from "babylonjs/Engines/engine";
  80700. import { Scene } from "babylonjs/scene";
  80701. /**
  80702. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  80703. */
  80704. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  80705. /**
  80706. * Defines how much ridge the curvature effect displays.
  80707. */
  80708. ridge: number;
  80709. /**
  80710. * Defines how much valley the curvature effect displays.
  80711. */
  80712. valley: number;
  80713. private _geometryBufferRenderer;
  80714. /**
  80715. * Gets a string identifying the name of the class
  80716. * @returns "ScreenSpaceCurvaturePostProcess" string
  80717. */
  80718. getClassName(): string;
  80719. /**
  80720. * Creates a new instance ScreenSpaceCurvaturePostProcess
  80721. * @param name The name of the effect.
  80722. * @param scene The scene containing the objects to blur according to their velocity.
  80723. * @param options The required width/height ratio to downsize to before computing the render pass.
  80724. * @param camera The camera to apply the render pass to.
  80725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80726. * @param engine The engine which the post process will be applied. (default: current engine)
  80727. * @param reusable If the post process can be reused on the same frame. (default: false)
  80728. * @param textureType Type of textures used when performing the post process. (default: 0)
  80729. * @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)
  80730. */
  80731. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  80732. /**
  80733. * Support test.
  80734. */
  80735. static get IsSupported(): boolean;
  80736. /** @hidden */
  80737. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  80738. }
  80739. }
  80740. declare module "babylonjs/PostProcesses/index" {
  80741. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  80742. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  80743. export * from "babylonjs/PostProcesses/bloomEffect";
  80744. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  80745. export * from "babylonjs/PostProcesses/blurPostProcess";
  80746. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  80747. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  80748. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  80749. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  80750. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  80751. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  80752. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  80753. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  80754. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  80755. export * from "babylonjs/PostProcesses/filterPostProcess";
  80756. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  80757. export * from "babylonjs/PostProcesses/grainPostProcess";
  80758. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  80759. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  80760. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  80761. export * from "babylonjs/PostProcesses/passPostProcess";
  80762. export * from "babylonjs/PostProcesses/postProcess";
  80763. export * from "babylonjs/PostProcesses/postProcessManager";
  80764. export * from "babylonjs/PostProcesses/refractionPostProcess";
  80765. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  80766. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  80767. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  80768. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  80769. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  80770. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  80771. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  80772. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  80773. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  80774. }
  80775. declare module "babylonjs/Probes/index" {
  80776. export * from "babylonjs/Probes/reflectionProbe";
  80777. }
  80778. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  80779. import { Scene } from "babylonjs/scene";
  80780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80781. import { SmartArray } from "babylonjs/Misc/smartArray";
  80782. import { ISceneComponent } from "babylonjs/sceneComponent";
  80783. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  80784. import "babylonjs/Meshes/Builders/boxBuilder";
  80785. import "babylonjs/Shaders/color.fragment";
  80786. import "babylonjs/Shaders/color.vertex";
  80787. import { Color3 } from "babylonjs/Maths/math.color";
  80788. import { Observable } from "babylonjs/Misc/observable";
  80789. module "babylonjs/scene" {
  80790. interface Scene {
  80791. /** @hidden (Backing field) */
  80792. _boundingBoxRenderer: BoundingBoxRenderer;
  80793. /** @hidden (Backing field) */
  80794. _forceShowBoundingBoxes: boolean;
  80795. /**
  80796. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  80797. */
  80798. forceShowBoundingBoxes: boolean;
  80799. /**
  80800. * Gets the bounding box renderer associated with the scene
  80801. * @returns a BoundingBoxRenderer
  80802. */
  80803. getBoundingBoxRenderer(): BoundingBoxRenderer;
  80804. }
  80805. }
  80806. module "babylonjs/Meshes/abstractMesh" {
  80807. interface AbstractMesh {
  80808. /** @hidden (Backing field) */
  80809. _showBoundingBox: boolean;
  80810. /**
  80811. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  80812. */
  80813. showBoundingBox: boolean;
  80814. }
  80815. }
  80816. /**
  80817. * Component responsible of rendering the bounding box of the meshes in a scene.
  80818. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  80819. */
  80820. export class BoundingBoxRenderer implements ISceneComponent {
  80821. /**
  80822. * The component name helpful to identify the component in the list of scene components.
  80823. */
  80824. readonly name: string;
  80825. /**
  80826. * The scene the component belongs to.
  80827. */
  80828. scene: Scene;
  80829. /**
  80830. * Color of the bounding box lines placed in front of an object
  80831. */
  80832. frontColor: Color3;
  80833. /**
  80834. * Color of the bounding box lines placed behind an object
  80835. */
  80836. backColor: Color3;
  80837. /**
  80838. * Defines if the renderer should show the back lines or not
  80839. */
  80840. showBackLines: boolean;
  80841. /**
  80842. * Observable raised before rendering a bounding box
  80843. */
  80844. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  80845. /**
  80846. * Observable raised after rendering a bounding box
  80847. */
  80848. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  80849. /**
  80850. * Observable raised after resources are created
  80851. */
  80852. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  80853. /**
  80854. * When false, no bounding boxes will be rendered
  80855. */
  80856. enabled: boolean;
  80857. /**
  80858. * @hidden
  80859. */
  80860. renderList: SmartArray<BoundingBox>;
  80861. private _colorShader;
  80862. private _vertexBuffers;
  80863. private _indexBuffer;
  80864. private _fillIndexBuffer;
  80865. private _fillIndexData;
  80866. /**
  80867. * Instantiates a new bounding box renderer in a scene.
  80868. * @param scene the scene the renderer renders in
  80869. */
  80870. constructor(scene: Scene);
  80871. /**
  80872. * Registers the component in a given scene
  80873. */
  80874. register(): void;
  80875. private _evaluateSubMesh;
  80876. private _preActiveMesh;
  80877. private _prepareResources;
  80878. private _createIndexBuffer;
  80879. /**
  80880. * Rebuilds the elements related to this component in case of
  80881. * context lost for instance.
  80882. */
  80883. rebuild(): void;
  80884. /**
  80885. * @hidden
  80886. */
  80887. reset(): void;
  80888. /**
  80889. * Render the bounding boxes of a specific rendering group
  80890. * @param renderingGroupId defines the rendering group to render
  80891. */
  80892. render(renderingGroupId: number): void;
  80893. /**
  80894. * In case of occlusion queries, we can render the occlusion bounding box through this method
  80895. * @param mesh Define the mesh to render the occlusion bounding box for
  80896. */
  80897. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  80898. /**
  80899. * Dispose and release the resources attached to this renderer.
  80900. */
  80901. dispose(): void;
  80902. }
  80903. }
  80904. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  80905. import { Nullable } from "babylonjs/types";
  80906. import { Scene } from "babylonjs/scene";
  80907. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  80908. import { Camera } from "babylonjs/Cameras/camera";
  80909. import { ISceneComponent } from "babylonjs/sceneComponent";
  80910. module "babylonjs/scene" {
  80911. interface Scene {
  80912. /** @hidden (Backing field) */
  80913. _depthRenderer: {
  80914. [id: string]: DepthRenderer;
  80915. };
  80916. /**
  80917. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  80918. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  80919. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  80920. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  80921. * @returns the created depth renderer
  80922. */
  80923. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  80924. /**
  80925. * Disables a depth renderer for a given camera
  80926. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  80927. */
  80928. disableDepthRenderer(camera?: Nullable<Camera>): void;
  80929. }
  80930. }
  80931. /**
  80932. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  80933. * in several rendering techniques.
  80934. */
  80935. export class DepthRendererSceneComponent implements ISceneComponent {
  80936. /**
  80937. * The component name helpful to identify the component in the list of scene components.
  80938. */
  80939. readonly name: string;
  80940. /**
  80941. * The scene the component belongs to.
  80942. */
  80943. scene: Scene;
  80944. /**
  80945. * Creates a new instance of the component for the given scene
  80946. * @param scene Defines the scene to register the component in
  80947. */
  80948. constructor(scene: Scene);
  80949. /**
  80950. * Registers the component in a given scene
  80951. */
  80952. register(): void;
  80953. /**
  80954. * Rebuilds the elements related to this component in case of
  80955. * context lost for instance.
  80956. */
  80957. rebuild(): void;
  80958. /**
  80959. * Disposes the component and the associated resources
  80960. */
  80961. dispose(): void;
  80962. private _gatherRenderTargets;
  80963. private _gatherActiveCameraRenderTargets;
  80964. }
  80965. }
  80966. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  80967. import { Nullable } from "babylonjs/types";
  80968. import { Scene } from "babylonjs/scene";
  80969. import { ISceneComponent } from "babylonjs/sceneComponent";
  80970. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  80971. import { PrePassRenderTarget } from "babylonjs/Materials/Textures/prePassRenderTarget";
  80972. module "babylonjs/abstractScene" {
  80973. interface AbstractScene {
  80974. /** @hidden (Backing field) */
  80975. _prePassRenderer: Nullable<PrePassRenderer>;
  80976. /**
  80977. * Gets or Sets the current prepass renderer associated to the scene.
  80978. */
  80979. prePassRenderer: Nullable<PrePassRenderer>;
  80980. /**
  80981. * Enables the prepass and associates it with the scene
  80982. * @returns the PrePassRenderer
  80983. */
  80984. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  80985. /**
  80986. * Disables the prepass associated with the scene
  80987. */
  80988. disablePrePassRenderer(): void;
  80989. }
  80990. }
  80991. module "babylonjs/Materials/Textures/renderTargetTexture" {
  80992. interface RenderTargetTexture {
  80993. /** @hidden */
  80994. _prePassRenderTarget: PrePassRenderTarget;
  80995. }
  80996. }
  80997. /**
  80998. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80999. * in several rendering techniques.
  81000. */
  81001. export class PrePassRendererSceneComponent implements ISceneComponent {
  81002. /**
  81003. * The component name helpful to identify the component in the list of scene components.
  81004. */
  81005. readonly name: string;
  81006. /**
  81007. * The scene the component belongs to.
  81008. */
  81009. scene: Scene;
  81010. /**
  81011. * Creates a new instance of the component for the given scene
  81012. * @param scene Defines the scene to register the component in
  81013. */
  81014. constructor(scene: Scene);
  81015. /**
  81016. * Registers the component in a given scene
  81017. */
  81018. register(): void;
  81019. private _beforeRenderTargetDraw;
  81020. private _afterRenderTargetDraw;
  81021. private _beforeRenderTargetClearStage;
  81022. private _beforeCameraDraw;
  81023. private _afterCameraDraw;
  81024. private _beforeClearStage;
  81025. private _beforeRenderingMeshStage;
  81026. private _afterRenderingMeshStage;
  81027. /**
  81028. * Rebuilds the elements related to this component in case of
  81029. * context lost for instance.
  81030. */
  81031. rebuild(): void;
  81032. /**
  81033. * Disposes the component and the associated resources
  81034. */
  81035. dispose(): void;
  81036. }
  81037. }
  81038. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  81039. /** @hidden */
  81040. export var fibonacci: {
  81041. name: string;
  81042. shader: string;
  81043. };
  81044. }
  81045. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  81046. /** @hidden */
  81047. export var diffusionProfile: {
  81048. name: string;
  81049. shader: string;
  81050. };
  81051. }
  81052. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  81053. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  81054. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  81055. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  81056. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  81057. /** @hidden */
  81058. export var subSurfaceScatteringPixelShader: {
  81059. name: string;
  81060. shader: string;
  81061. };
  81062. }
  81063. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  81064. import { Nullable } from "babylonjs/types";
  81065. import { Camera } from "babylonjs/Cameras/camera";
  81066. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  81067. import { Engine } from "babylonjs/Engines/engine";
  81068. import { Scene } from "babylonjs/scene";
  81069. import "babylonjs/Shaders/imageProcessing.fragment";
  81070. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  81071. import "babylonjs/Shaders/postprocess.vertex";
  81072. /**
  81073. * Sub surface scattering post process
  81074. */
  81075. export class SubSurfaceScatteringPostProcess extends PostProcess {
  81076. /**
  81077. * Gets a string identifying the name of the class
  81078. * @returns "SubSurfaceScatteringPostProcess" string
  81079. */
  81080. getClassName(): string;
  81081. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  81082. }
  81083. }
  81084. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  81085. import { Scene } from "babylonjs/scene";
  81086. import { Color3 } from "babylonjs/Maths/math.color";
  81087. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  81088. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  81089. /**
  81090. * Contains all parameters needed for the prepass to perform
  81091. * screen space subsurface scattering
  81092. */
  81093. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  81094. /** @hidden */
  81095. static _SceneComponentInitialization: (scene: Scene) => void;
  81096. private _ssDiffusionS;
  81097. private _ssFilterRadii;
  81098. private _ssDiffusionD;
  81099. /**
  81100. * Post process to attach for screen space subsurface scattering
  81101. */
  81102. postProcess: SubSurfaceScatteringPostProcess;
  81103. /**
  81104. * Diffusion profile color for subsurface scattering
  81105. */
  81106. get ssDiffusionS(): number[];
  81107. /**
  81108. * Diffusion profile max color channel value for subsurface scattering
  81109. */
  81110. get ssDiffusionD(): number[];
  81111. /**
  81112. * Diffusion profile filter radius for subsurface scattering
  81113. */
  81114. get ssFilterRadii(): number[];
  81115. /**
  81116. * Is subsurface enabled
  81117. */
  81118. enabled: boolean;
  81119. /**
  81120. * Does the output of this prepass need to go through imageprocessing
  81121. */
  81122. needsImageProcessing: boolean;
  81123. /**
  81124. * Name of the configuration
  81125. */
  81126. name: string;
  81127. /**
  81128. * Diffusion profile colors for subsurface scattering
  81129. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  81130. * See ...
  81131. * Note that you can only store up to 5 of them
  81132. */
  81133. ssDiffusionProfileColors: Color3[];
  81134. /**
  81135. * Defines the ratio real world => scene units.
  81136. * Used for subsurface scattering
  81137. */
  81138. metersPerUnit: number;
  81139. /**
  81140. * Textures that should be present in the MRT for this effect to work
  81141. */
  81142. readonly texturesRequired: number[];
  81143. private _scene;
  81144. /**
  81145. * Builds a subsurface configuration object
  81146. * @param scene The scene
  81147. */
  81148. constructor(scene: Scene);
  81149. /**
  81150. * Adds a new diffusion profile.
  81151. * Useful for more realistic subsurface scattering on diverse materials.
  81152. * @param color The color of the diffusion profile. Should be the average color of the material.
  81153. * @return The index of the diffusion profile for the material subsurface configuration
  81154. */
  81155. addDiffusionProfile(color: Color3): number;
  81156. /**
  81157. * Creates the sss post process
  81158. * @return The created post process
  81159. */
  81160. createPostProcess(): SubSurfaceScatteringPostProcess;
  81161. /**
  81162. * Deletes all diffusion profiles.
  81163. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  81164. */
  81165. clearAllDiffusionProfiles(): void;
  81166. /**
  81167. * Disposes this object
  81168. */
  81169. dispose(): void;
  81170. /**
  81171. * @hidden
  81172. * https://zero-radiance.github.io/post/sampling-diffusion/
  81173. *
  81174. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  81175. * ------------------------------------------------------------------------------------
  81176. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  81177. * PDF[r, phi, s] = r * R[r, phi, s]
  81178. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  81179. * ------------------------------------------------------------------------------------
  81180. * We importance sample the color channel with the widest scattering distance.
  81181. */
  81182. getDiffusionProfileParameters(color: Color3): number;
  81183. /**
  81184. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  81185. * 'u' is the random number (the value of the CDF): [0, 1).
  81186. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  81187. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  81188. */
  81189. private _sampleBurleyDiffusionProfile;
  81190. }
  81191. }
  81192. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  81193. import { Nullable } from "babylonjs/types";
  81194. import { Scene } from "babylonjs/scene";
  81195. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  81196. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  81197. import { AbstractScene } from "babylonjs/abstractScene";
  81198. module "babylonjs/abstractScene" {
  81199. interface AbstractScene {
  81200. /** @hidden (Backing field) */
  81201. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  81202. /**
  81203. * Gets or Sets the current prepass renderer associated to the scene.
  81204. */
  81205. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  81206. /**
  81207. * Enables the subsurface effect for prepass
  81208. * @returns the SubSurfaceConfiguration
  81209. */
  81210. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  81211. /**
  81212. * Disables the subsurface effect for prepass
  81213. */
  81214. disableSubSurfaceForPrePass(): void;
  81215. }
  81216. }
  81217. /**
  81218. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  81219. * in several rendering techniques.
  81220. */
  81221. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  81222. /**
  81223. * The component name helpful to identify the component in the list of scene components.
  81224. */
  81225. readonly name: string;
  81226. /**
  81227. * The scene the component belongs to.
  81228. */
  81229. scene: Scene;
  81230. /**
  81231. * Creates a new instance of the component for the given scene
  81232. * @param scene Defines the scene to register the component in
  81233. */
  81234. constructor(scene: Scene);
  81235. /**
  81236. * Registers the component in a given scene
  81237. */
  81238. register(): void;
  81239. /**
  81240. * Serializes the component data to the specified json object
  81241. * @param serializationObject The object to serialize to
  81242. */
  81243. serialize(serializationObject: any): void;
  81244. /**
  81245. * Adds all the elements from the container to the scene
  81246. * @param container the container holding the elements
  81247. */
  81248. addFromContainer(container: AbstractScene): void;
  81249. /**
  81250. * Removes all the elements in the container from the scene
  81251. * @param container contains the elements to remove
  81252. * @param dispose if the removed element should be disposed (default: false)
  81253. */
  81254. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  81255. /**
  81256. * Rebuilds the elements related to this component in case of
  81257. * context lost for instance.
  81258. */
  81259. rebuild(): void;
  81260. /**
  81261. * Disposes the component and the associated resources
  81262. */
  81263. dispose(): void;
  81264. }
  81265. }
  81266. declare module "babylonjs/Shaders/outline.fragment" {
  81267. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  81268. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  81269. /** @hidden */
  81270. export var outlinePixelShader: {
  81271. name: string;
  81272. shader: string;
  81273. };
  81274. }
  81275. declare module "babylonjs/Shaders/outline.vertex" {
  81276. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  81277. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  81278. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  81279. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  81280. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  81281. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobal";
  81282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  81283. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  81284. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  81285. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  81286. /** @hidden */
  81287. export var outlineVertexShader: {
  81288. name: string;
  81289. shader: string;
  81290. };
  81291. }
  81292. declare module "babylonjs/Rendering/outlineRenderer" {
  81293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  81294. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  81295. import { Scene } from "babylonjs/scene";
  81296. import { ISceneComponent } from "babylonjs/sceneComponent";
  81297. import "babylonjs/Shaders/outline.fragment";
  81298. import "babylonjs/Shaders/outline.vertex";
  81299. module "babylonjs/scene" {
  81300. interface Scene {
  81301. /** @hidden */
  81302. _outlineRenderer: OutlineRenderer;
  81303. /**
  81304. * Gets the outline renderer associated with the scene
  81305. * @returns a OutlineRenderer
  81306. */
  81307. getOutlineRenderer(): OutlineRenderer;
  81308. }
  81309. }
  81310. module "babylonjs/Meshes/abstractMesh" {
  81311. interface AbstractMesh {
  81312. /** @hidden (Backing field) */
  81313. _renderOutline: boolean;
  81314. /**
  81315. * Gets or sets a boolean indicating if the outline must be rendered as well
  81316. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  81317. */
  81318. renderOutline: boolean;
  81319. /** @hidden (Backing field) */
  81320. _renderOverlay: boolean;
  81321. /**
  81322. * Gets or sets a boolean indicating if the overlay must be rendered as well
  81323. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  81324. */
  81325. renderOverlay: boolean;
  81326. }
  81327. }
  81328. /**
  81329. * This class is responsible to draw the outline/overlay of meshes.
  81330. * It should not be used directly but through the available method on mesh.
  81331. */
  81332. export class OutlineRenderer implements ISceneComponent {
  81333. /**
  81334. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  81335. */
  81336. private static _StencilReference;
  81337. /**
  81338. * The name of the component. Each component must have a unique name.
  81339. */
  81340. name: string;
  81341. /**
  81342. * The scene the component belongs to.
  81343. */
  81344. scene: Scene;
  81345. /**
  81346. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  81347. */
  81348. zOffset: number;
  81349. private _engine;
  81350. private _effect;
  81351. private _cachedDefines;
  81352. private _savedDepthWrite;
  81353. /**
  81354. * Instantiates a new outline renderer. (There could be only one per scene).
  81355. * @param scene Defines the scene it belongs to
  81356. */
  81357. constructor(scene: Scene);
  81358. /**
  81359. * Register the component to one instance of a scene.
  81360. */
  81361. register(): void;
  81362. /**
  81363. * Rebuilds the elements related to this component in case of
  81364. * context lost for instance.
  81365. */
  81366. rebuild(): void;
  81367. /**
  81368. * Disposes the component and the associated resources.
  81369. */
  81370. dispose(): void;
  81371. /**
  81372. * Renders the outline in the canvas.
  81373. * @param subMesh Defines the sumesh to render
  81374. * @param batch Defines the batch of meshes in case of instances
  81375. * @param useOverlay Defines if the rendering is for the overlay or the outline
  81376. */
  81377. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  81378. /**
  81379. * Returns whether or not the outline renderer is ready for a given submesh.
  81380. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  81381. * @param subMesh Defines the submesh to check readiness for
  81382. * @param useInstances Defines whether wee are trying to render instances or not
  81383. * @returns true if ready otherwise false
  81384. */
  81385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  81386. private _beforeRenderingMesh;
  81387. private _afterRenderingMesh;
  81388. }
  81389. }
  81390. declare module "babylonjs/Rendering/index" {
  81391. export * from "babylonjs/Rendering/boundingBoxRenderer";
  81392. export * from "babylonjs/Rendering/depthRenderer";
  81393. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  81394. export * from "babylonjs/Rendering/edgesRenderer";
  81395. export * from "babylonjs/Rendering/geometryBufferRenderer";
  81396. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  81397. export * from "babylonjs/Rendering/prePassRenderer";
  81398. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  81399. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  81400. export * from "babylonjs/Rendering/outlineRenderer";
  81401. export * from "babylonjs/Rendering/renderingGroup";
  81402. export * from "babylonjs/Rendering/renderingManager";
  81403. export * from "babylonjs/Rendering/utilityLayerRenderer";
  81404. }
  81405. declare module "babylonjs/Sprites/ISprites" {
  81406. /**
  81407. * Defines the basic options interface of a Sprite Frame Source Size.
  81408. */
  81409. export interface ISpriteJSONSpriteSourceSize {
  81410. /**
  81411. * number of the original width of the Frame
  81412. */
  81413. w: number;
  81414. /**
  81415. * number of the original height of the Frame
  81416. */
  81417. h: number;
  81418. }
  81419. /**
  81420. * Defines the basic options interface of a Sprite Frame Data.
  81421. */
  81422. export interface ISpriteJSONSpriteFrameData {
  81423. /**
  81424. * number of the x offset of the Frame
  81425. */
  81426. x: number;
  81427. /**
  81428. * number of the y offset of the Frame
  81429. */
  81430. y: number;
  81431. /**
  81432. * number of the width of the Frame
  81433. */
  81434. w: number;
  81435. /**
  81436. * number of the height of the Frame
  81437. */
  81438. h: number;
  81439. }
  81440. /**
  81441. * Defines the basic options interface of a JSON Sprite.
  81442. */
  81443. export interface ISpriteJSONSprite {
  81444. /**
  81445. * string name of the Frame
  81446. */
  81447. filename: string;
  81448. /**
  81449. * ISpriteJSONSpriteFrame basic object of the frame data
  81450. */
  81451. frame: ISpriteJSONSpriteFrameData;
  81452. /**
  81453. * boolean to flag is the frame was rotated.
  81454. */
  81455. rotated: boolean;
  81456. /**
  81457. * boolean to flag is the frame was trimmed.
  81458. */
  81459. trimmed: boolean;
  81460. /**
  81461. * ISpriteJSONSpriteFrame basic object of the source data
  81462. */
  81463. spriteSourceSize: ISpriteJSONSpriteFrameData;
  81464. /**
  81465. * ISpriteJSONSpriteFrame basic object of the source data
  81466. */
  81467. sourceSize: ISpriteJSONSpriteSourceSize;
  81468. }
  81469. /**
  81470. * Defines the basic options interface of a JSON atlas.
  81471. */
  81472. export interface ISpriteJSONAtlas {
  81473. /**
  81474. * Array of objects that contain the frame data.
  81475. */
  81476. frames: Array<ISpriteJSONSprite>;
  81477. /**
  81478. * object basic object containing the sprite meta data.
  81479. */
  81480. meta?: object;
  81481. }
  81482. }
  81483. declare module "babylonjs/Shaders/spriteMap.fragment" {
  81484. /** @hidden */
  81485. export var spriteMapPixelShader: {
  81486. name: string;
  81487. shader: string;
  81488. };
  81489. }
  81490. declare module "babylonjs/Shaders/spriteMap.vertex" {
  81491. /** @hidden */
  81492. export var spriteMapVertexShader: {
  81493. name: string;
  81494. shader: string;
  81495. };
  81496. }
  81497. declare module "babylonjs/Sprites/spriteMap" {
  81498. import { IDisposable, Scene } from "babylonjs/scene";
  81499. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  81500. import { Texture } from "babylonjs/Materials/Textures/texture";
  81501. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  81502. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  81503. import "babylonjs/Meshes/Builders/planeBuilder";
  81504. import "babylonjs/Shaders/spriteMap.fragment";
  81505. import "babylonjs/Shaders/spriteMap.vertex";
  81506. /**
  81507. * Defines the basic options interface of a SpriteMap
  81508. */
  81509. export interface ISpriteMapOptions {
  81510. /**
  81511. * Vector2 of the number of cells in the grid.
  81512. */
  81513. stageSize?: Vector2;
  81514. /**
  81515. * Vector2 of the size of the output plane in World Units.
  81516. */
  81517. outputSize?: Vector2;
  81518. /**
  81519. * Vector3 of the position of the output plane in World Units.
  81520. */
  81521. outputPosition?: Vector3;
  81522. /**
  81523. * Vector3 of the rotation of the output plane.
  81524. */
  81525. outputRotation?: Vector3;
  81526. /**
  81527. * number of layers that the system will reserve in resources.
  81528. */
  81529. layerCount?: number;
  81530. /**
  81531. * number of max animation frames a single cell will reserve in resources.
  81532. */
  81533. maxAnimationFrames?: number;
  81534. /**
  81535. * number cell index of the base tile when the system compiles.
  81536. */
  81537. baseTile?: number;
  81538. /**
  81539. * boolean flip the sprite after its been repositioned by the framing data.
  81540. */
  81541. flipU?: boolean;
  81542. /**
  81543. * Vector3 scalar of the global RGB values of the SpriteMap.
  81544. */
  81545. colorMultiply?: Vector3;
  81546. }
  81547. /**
  81548. * Defines the IDisposable interface in order to be cleanable from resources.
  81549. */
  81550. export interface ISpriteMap extends IDisposable {
  81551. /**
  81552. * String name of the SpriteMap.
  81553. */
  81554. name: string;
  81555. /**
  81556. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  81557. */
  81558. atlasJSON: ISpriteJSONAtlas;
  81559. /**
  81560. * Texture of the SpriteMap.
  81561. */
  81562. spriteSheet: Texture;
  81563. /**
  81564. * The parameters to initialize the SpriteMap with.
  81565. */
  81566. options: ISpriteMapOptions;
  81567. }
  81568. /**
  81569. * Class used to manage a grid restricted sprite deployment on an Output plane.
  81570. */
  81571. export class SpriteMap implements ISpriteMap {
  81572. /** The Name of the spriteMap */
  81573. name: string;
  81574. /** The JSON file with the frame and meta data */
  81575. atlasJSON: ISpriteJSONAtlas;
  81576. /** The systems Sprite Sheet Texture */
  81577. spriteSheet: Texture;
  81578. /** Arguments passed with the Constructor */
  81579. options: ISpriteMapOptions;
  81580. /** Public Sprite Storage array, parsed from atlasJSON */
  81581. sprites: Array<ISpriteJSONSprite>;
  81582. /** Returns the Number of Sprites in the System */
  81583. get spriteCount(): number;
  81584. /** Returns the Position of Output Plane*/
  81585. get position(): Vector3;
  81586. /** Returns the Position of Output Plane*/
  81587. set position(v: Vector3);
  81588. /** Returns the Rotation of Output Plane*/
  81589. get rotation(): Vector3;
  81590. /** Returns the Rotation of Output Plane*/
  81591. set rotation(v: Vector3);
  81592. /** Sets the AnimationMap*/
  81593. get animationMap(): RawTexture;
  81594. /** Sets the AnimationMap*/
  81595. set animationMap(v: RawTexture);
  81596. /** Scene that the SpriteMap was created in */
  81597. private _scene;
  81598. /** Texture Buffer of Float32 that holds tile frame data*/
  81599. private _frameMap;
  81600. /** Texture Buffers of Float32 that holds tileMap data*/
  81601. private _tileMaps;
  81602. /** Texture Buffer of Float32 that holds Animation Data*/
  81603. private _animationMap;
  81604. /** Custom ShaderMaterial Central to the System*/
  81605. private _material;
  81606. /** Custom ShaderMaterial Central to the System*/
  81607. private _output;
  81608. /** Systems Time Ticker*/
  81609. private _time;
  81610. /**
  81611. * Creates a new SpriteMap
  81612. * @param name defines the SpriteMaps Name
  81613. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  81614. * @param spriteSheet is the Texture that the Sprites are on.
  81615. * @param options a basic deployment configuration
  81616. * @param scene The Scene that the map is deployed on
  81617. */
  81618. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  81619. /**
  81620. * Returns tileID location
  81621. * @returns Vector2 the cell position ID
  81622. */
  81623. getTileID(): Vector2;
  81624. /**
  81625. * Gets the UV location of the mouse over the SpriteMap.
  81626. * @returns Vector2 the UV position of the mouse interaction
  81627. */
  81628. getMousePosition(): Vector2;
  81629. /**
  81630. * Creates the "frame" texture Buffer
  81631. * -------------------------------------
  81632. * Structure of frames
  81633. * "filename": "Falling-Water-2.png",
  81634. * "frame": {"x":69,"y":103,"w":24,"h":32},
  81635. * "rotated": true,
  81636. * "trimmed": true,
  81637. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  81638. * "sourceSize": {"w":32,"h":32}
  81639. * @returns RawTexture of the frameMap
  81640. */
  81641. private _createFrameBuffer;
  81642. /**
  81643. * Creates the tileMap texture Buffer
  81644. * @param buffer normally and array of numbers, or a false to generate from scratch
  81645. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  81646. * @returns RawTexture of the tileMap
  81647. */
  81648. private _createTileBuffer;
  81649. /**
  81650. * Modifies the data of the tileMaps
  81651. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  81652. * @param pos is the iVector2 Coordinates of the Tile
  81653. * @param tile The SpriteIndex of the new Tile
  81654. */
  81655. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  81656. /**
  81657. * Creates the animationMap texture Buffer
  81658. * @param buffer normally and array of numbers, or a false to generate from scratch
  81659. * @returns RawTexture of the animationMap
  81660. */
  81661. private _createTileAnimationBuffer;
  81662. /**
  81663. * Modifies the data of the animationMap
  81664. * @param cellID is the Index of the Sprite
  81665. * @param _frame is the target Animation frame
  81666. * @param toCell is the Target Index of the next frame of the animation
  81667. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  81668. * @param speed is a global scalar of the time variable on the map.
  81669. */
  81670. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  81671. /**
  81672. * Exports the .tilemaps file
  81673. */
  81674. saveTileMaps(): void;
  81675. /**
  81676. * Imports the .tilemaps file
  81677. * @param url of the .tilemaps file
  81678. */
  81679. loadTileMaps(url: string): void;
  81680. /**
  81681. * Release associated resources
  81682. */
  81683. dispose(): void;
  81684. }
  81685. }
  81686. declare module "babylonjs/Sprites/spritePackedManager" {
  81687. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  81688. import { Scene } from "babylonjs/scene";
  81689. /**
  81690. * Class used to manage multiple sprites of different sizes on the same spritesheet
  81691. * @see https://doc.babylonjs.com/babylon101/sprites
  81692. */
  81693. export class SpritePackedManager extends SpriteManager {
  81694. /** defines the packed manager's name */
  81695. name: string;
  81696. /**
  81697. * Creates a new sprite manager from a packed sprite sheet
  81698. * @param name defines the manager's name
  81699. * @param imgUrl defines the sprite sheet url
  81700. * @param capacity defines the maximum allowed number of sprites
  81701. * @param scene defines the hosting scene
  81702. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  81703. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  81704. * @param samplingMode defines the sampling mode to use with spritesheet
  81705. * @param fromPacked set to true; do not alter
  81706. */
  81707. constructor(
  81708. /** defines the packed manager's name */
  81709. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  81710. }
  81711. }
  81712. declare module "babylonjs/Sprites/index" {
  81713. export * from "babylonjs/Sprites/sprite";
  81714. export * from "babylonjs/Sprites/ISprites";
  81715. export * from "babylonjs/Sprites/spriteManager";
  81716. export * from "babylonjs/Sprites/spriteMap";
  81717. export * from "babylonjs/Sprites/spritePackedManager";
  81718. export * from "babylonjs/Sprites/spriteSceneComponent";
  81719. }
  81720. declare module "babylonjs/States/index" {
  81721. export * from "babylonjs/States/alphaCullingState";
  81722. export * from "babylonjs/States/depthCullingState";
  81723. export * from "babylonjs/States/stencilState";
  81724. }
  81725. declare module "babylonjs/Misc/assetsManager" {
  81726. import { Scene } from "babylonjs/scene";
  81727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81728. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  81729. import { Skeleton } from "babylonjs/Bones/skeleton";
  81730. import { Observable } from "babylonjs/Misc/observable";
  81731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  81732. import { Texture } from "babylonjs/Materials/Textures/texture";
  81733. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  81734. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  81735. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  81736. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  81737. import { AssetContainer } from "babylonjs/assetContainer";
  81738. /**
  81739. * Defines the list of states available for a task inside a AssetsManager
  81740. */
  81741. export enum AssetTaskState {
  81742. /**
  81743. * Initialization
  81744. */
  81745. INIT = 0,
  81746. /**
  81747. * Running
  81748. */
  81749. RUNNING = 1,
  81750. /**
  81751. * Done
  81752. */
  81753. DONE = 2,
  81754. /**
  81755. * Error
  81756. */
  81757. ERROR = 3
  81758. }
  81759. /**
  81760. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  81761. */
  81762. export abstract class AbstractAssetTask {
  81763. /**
  81764. * Task name
  81765. */ name: string;
  81766. /**
  81767. * Callback called when the task is successful
  81768. */
  81769. onSuccess: (task: any) => void;
  81770. /**
  81771. * Callback called when the task is not successful
  81772. */
  81773. onError: (task: any, message?: string, exception?: any) => void;
  81774. /**
  81775. * Creates a new AssetsManager
  81776. * @param name defines the name of the task
  81777. */
  81778. constructor(
  81779. /**
  81780. * Task name
  81781. */ name: string);
  81782. private _isCompleted;
  81783. private _taskState;
  81784. private _errorObject;
  81785. /**
  81786. * Get if the task is completed
  81787. */
  81788. get isCompleted(): boolean;
  81789. /**
  81790. * Gets the current state of the task
  81791. */
  81792. get taskState(): AssetTaskState;
  81793. /**
  81794. * Gets the current error object (if task is in error)
  81795. */
  81796. get errorObject(): {
  81797. message?: string;
  81798. exception?: any;
  81799. };
  81800. /**
  81801. * Internal only
  81802. * @hidden
  81803. */
  81804. _setErrorObject(message?: string, exception?: any): void;
  81805. /**
  81806. * Execute the current task
  81807. * @param scene defines the scene where you want your assets to be loaded
  81808. * @param onSuccess is a callback called when the task is successfully executed
  81809. * @param onError is a callback called if an error occurs
  81810. */
  81811. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81812. /**
  81813. * Execute the current task
  81814. * @param scene defines the scene where you want your assets to be loaded
  81815. * @param onSuccess is a callback called when the task is successfully executed
  81816. * @param onError is a callback called if an error occurs
  81817. */
  81818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81819. /**
  81820. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  81821. * This can be used with failed tasks that have the reason for failure fixed.
  81822. */
  81823. reset(): void;
  81824. private onErrorCallback;
  81825. private onDoneCallback;
  81826. }
  81827. /**
  81828. * Define the interface used by progress events raised during assets loading
  81829. */
  81830. export interface IAssetsProgressEvent {
  81831. /**
  81832. * Defines the number of remaining tasks to process
  81833. */
  81834. remainingCount: number;
  81835. /**
  81836. * Defines the total number of tasks
  81837. */
  81838. totalCount: number;
  81839. /**
  81840. * Defines the task that was just processed
  81841. */
  81842. task: AbstractAssetTask;
  81843. }
  81844. /**
  81845. * Class used to share progress information about assets loading
  81846. */
  81847. export class AssetsProgressEvent implements IAssetsProgressEvent {
  81848. /**
  81849. * Defines the number of remaining tasks to process
  81850. */
  81851. remainingCount: number;
  81852. /**
  81853. * Defines the total number of tasks
  81854. */
  81855. totalCount: number;
  81856. /**
  81857. * Defines the task that was just processed
  81858. */
  81859. task: AbstractAssetTask;
  81860. /**
  81861. * Creates a AssetsProgressEvent
  81862. * @param remainingCount defines the number of remaining tasks to process
  81863. * @param totalCount defines the total number of tasks
  81864. * @param task defines the task that was just processed
  81865. */
  81866. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  81867. }
  81868. /**
  81869. * Define a task used by AssetsManager to load assets into a container
  81870. */
  81871. export class ContainerAssetTask extends AbstractAssetTask {
  81872. /**
  81873. * Defines the name of the task
  81874. */
  81875. name: string;
  81876. /**
  81877. * Defines the list of mesh's names you want to load
  81878. */
  81879. meshesNames: any;
  81880. /**
  81881. * Defines the root url to use as a base to load your meshes and associated resources
  81882. */
  81883. rootUrl: string;
  81884. /**
  81885. * Defines the filename or File of the scene to load from
  81886. */
  81887. sceneFilename: string | File;
  81888. /**
  81889. * Get the loaded asset container
  81890. */
  81891. loadedContainer: AssetContainer;
  81892. /**
  81893. * Gets the list of loaded meshes
  81894. */
  81895. loadedMeshes: Array<AbstractMesh>;
  81896. /**
  81897. * Gets the list of loaded particle systems
  81898. */
  81899. loadedParticleSystems: Array<IParticleSystem>;
  81900. /**
  81901. * Gets the list of loaded skeletons
  81902. */
  81903. loadedSkeletons: Array<Skeleton>;
  81904. /**
  81905. * Gets the list of loaded animation groups
  81906. */
  81907. loadedAnimationGroups: Array<AnimationGroup>;
  81908. /**
  81909. * Callback called when the task is successful
  81910. */
  81911. onSuccess: (task: ContainerAssetTask) => void;
  81912. /**
  81913. * Callback called when the task is successful
  81914. */
  81915. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  81916. /**
  81917. * Creates a new ContainerAssetTask
  81918. * @param name defines the name of the task
  81919. * @param meshesNames defines the list of mesh's names you want to load
  81920. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81921. * @param sceneFilename defines the filename or File of the scene to load from
  81922. */
  81923. constructor(
  81924. /**
  81925. * Defines the name of the task
  81926. */
  81927. name: string,
  81928. /**
  81929. * Defines the list of mesh's names you want to load
  81930. */
  81931. meshesNames: any,
  81932. /**
  81933. * Defines the root url to use as a base to load your meshes and associated resources
  81934. */
  81935. rootUrl: string,
  81936. /**
  81937. * Defines the filename or File of the scene to load from
  81938. */
  81939. sceneFilename: string | File);
  81940. /**
  81941. * Execute the current task
  81942. * @param scene defines the scene where you want your assets to be loaded
  81943. * @param onSuccess is a callback called when the task is successfully executed
  81944. * @param onError is a callback called if an error occurs
  81945. */
  81946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81947. }
  81948. /**
  81949. * Define a task used by AssetsManager to load meshes
  81950. */
  81951. export class MeshAssetTask extends AbstractAssetTask {
  81952. /**
  81953. * Defines the name of the task
  81954. */
  81955. name: string;
  81956. /**
  81957. * Defines the list of mesh's names you want to load
  81958. */
  81959. meshesNames: any;
  81960. /**
  81961. * Defines the root url to use as a base to load your meshes and associated resources
  81962. */
  81963. rootUrl: string;
  81964. /**
  81965. * Defines the filename or File of the scene to load from
  81966. */
  81967. sceneFilename: string | File;
  81968. /**
  81969. * Gets the list of loaded meshes
  81970. */
  81971. loadedMeshes: Array<AbstractMesh>;
  81972. /**
  81973. * Gets the list of loaded particle systems
  81974. */
  81975. loadedParticleSystems: Array<IParticleSystem>;
  81976. /**
  81977. * Gets the list of loaded skeletons
  81978. */
  81979. loadedSkeletons: Array<Skeleton>;
  81980. /**
  81981. * Gets the list of loaded animation groups
  81982. */
  81983. loadedAnimationGroups: Array<AnimationGroup>;
  81984. /**
  81985. * Callback called when the task is successful
  81986. */
  81987. onSuccess: (task: MeshAssetTask) => void;
  81988. /**
  81989. * Callback called when the task is successful
  81990. */
  81991. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  81992. /**
  81993. * Creates a new MeshAssetTask
  81994. * @param name defines the name of the task
  81995. * @param meshesNames defines the list of mesh's names you want to load
  81996. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81997. * @param sceneFilename defines the filename or File of the scene to load from
  81998. */
  81999. constructor(
  82000. /**
  82001. * Defines the name of the task
  82002. */
  82003. name: string,
  82004. /**
  82005. * Defines the list of mesh's names you want to load
  82006. */
  82007. meshesNames: any,
  82008. /**
  82009. * Defines the root url to use as a base to load your meshes and associated resources
  82010. */
  82011. rootUrl: string,
  82012. /**
  82013. * Defines the filename or File of the scene to load from
  82014. */
  82015. sceneFilename: string | File);
  82016. /**
  82017. * Execute the current task
  82018. * @param scene defines the scene where you want your assets to be loaded
  82019. * @param onSuccess is a callback called when the task is successfully executed
  82020. * @param onError is a callback called if an error occurs
  82021. */
  82022. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82023. }
  82024. /**
  82025. * Define a task used by AssetsManager to load text content
  82026. */
  82027. export class TextFileAssetTask extends AbstractAssetTask {
  82028. /**
  82029. * Defines the name of the task
  82030. */
  82031. name: string;
  82032. /**
  82033. * Defines the location of the file to load
  82034. */
  82035. url: string;
  82036. /**
  82037. * Gets the loaded text string
  82038. */
  82039. text: string;
  82040. /**
  82041. * Callback called when the task is successful
  82042. */
  82043. onSuccess: (task: TextFileAssetTask) => void;
  82044. /**
  82045. * Callback called when the task is successful
  82046. */
  82047. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  82048. /**
  82049. * Creates a new TextFileAssetTask object
  82050. * @param name defines the name of the task
  82051. * @param url defines the location of the file to load
  82052. */
  82053. constructor(
  82054. /**
  82055. * Defines the name of the task
  82056. */
  82057. name: string,
  82058. /**
  82059. * Defines the location of the file to load
  82060. */
  82061. url: string);
  82062. /**
  82063. * Execute the current task
  82064. * @param scene defines the scene where you want your assets to be loaded
  82065. * @param onSuccess is a callback called when the task is successfully executed
  82066. * @param onError is a callback called if an error occurs
  82067. */
  82068. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82069. }
  82070. /**
  82071. * Define a task used by AssetsManager to load binary data
  82072. */
  82073. export class BinaryFileAssetTask extends AbstractAssetTask {
  82074. /**
  82075. * Defines the name of the task
  82076. */
  82077. name: string;
  82078. /**
  82079. * Defines the location of the file to load
  82080. */
  82081. url: string;
  82082. /**
  82083. * Gets the lodaded data (as an array buffer)
  82084. */
  82085. data: ArrayBuffer;
  82086. /**
  82087. * Callback called when the task is successful
  82088. */
  82089. onSuccess: (task: BinaryFileAssetTask) => void;
  82090. /**
  82091. * Callback called when the task is successful
  82092. */
  82093. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  82094. /**
  82095. * Creates a new BinaryFileAssetTask object
  82096. * @param name defines the name of the new task
  82097. * @param url defines the location of the file to load
  82098. */
  82099. constructor(
  82100. /**
  82101. * Defines the name of the task
  82102. */
  82103. name: string,
  82104. /**
  82105. * Defines the location of the file to load
  82106. */
  82107. url: string);
  82108. /**
  82109. * Execute the current task
  82110. * @param scene defines the scene where you want your assets to be loaded
  82111. * @param onSuccess is a callback called when the task is successfully executed
  82112. * @param onError is a callback called if an error occurs
  82113. */
  82114. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82115. }
  82116. /**
  82117. * Define a task used by AssetsManager to load images
  82118. */
  82119. export class ImageAssetTask extends AbstractAssetTask {
  82120. /**
  82121. * Defines the name of the task
  82122. */
  82123. name: string;
  82124. /**
  82125. * Defines the location of the image to load
  82126. */
  82127. url: string;
  82128. /**
  82129. * Gets the loaded images
  82130. */
  82131. image: HTMLImageElement;
  82132. /**
  82133. * Callback called when the task is successful
  82134. */
  82135. onSuccess: (task: ImageAssetTask) => void;
  82136. /**
  82137. * Callback called when the task is successful
  82138. */
  82139. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  82140. /**
  82141. * Creates a new ImageAssetTask
  82142. * @param name defines the name of the task
  82143. * @param url defines the location of the image to load
  82144. */
  82145. constructor(
  82146. /**
  82147. * Defines the name of the task
  82148. */
  82149. name: string,
  82150. /**
  82151. * Defines the location of the image to load
  82152. */
  82153. url: string);
  82154. /**
  82155. * Execute the current task
  82156. * @param scene defines the scene where you want your assets to be loaded
  82157. * @param onSuccess is a callback called when the task is successfully executed
  82158. * @param onError is a callback called if an error occurs
  82159. */
  82160. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82161. }
  82162. /**
  82163. * Defines the interface used by texture loading tasks
  82164. */
  82165. export interface ITextureAssetTask<TEX extends BaseTexture> {
  82166. /**
  82167. * Gets the loaded texture
  82168. */
  82169. texture: TEX;
  82170. }
  82171. /**
  82172. * Define a task used by AssetsManager to load 2D textures
  82173. */
  82174. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  82175. /**
  82176. * Defines the name of the task
  82177. */
  82178. name: string;
  82179. /**
  82180. * Defines the location of the file to load
  82181. */
  82182. url: string;
  82183. /**
  82184. * Defines if mipmap should not be generated (default is false)
  82185. */
  82186. noMipmap?: boolean | undefined;
  82187. /**
  82188. * Defines if texture must be inverted on Y axis (default is true)
  82189. */
  82190. invertY: boolean;
  82191. /**
  82192. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82193. */
  82194. samplingMode: number;
  82195. /**
  82196. * Gets the loaded texture
  82197. */
  82198. texture: Texture;
  82199. /**
  82200. * Callback called when the task is successful
  82201. */
  82202. onSuccess: (task: TextureAssetTask) => void;
  82203. /**
  82204. * Callback called when the task is successful
  82205. */
  82206. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  82207. /**
  82208. * Creates a new TextureAssetTask object
  82209. * @param name defines the name of the task
  82210. * @param url defines the location of the file to load
  82211. * @param noMipmap defines if mipmap should not be generated (default is false)
  82212. * @param invertY defines if texture must be inverted on Y axis (default is true)
  82213. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82214. */
  82215. constructor(
  82216. /**
  82217. * Defines the name of the task
  82218. */
  82219. name: string,
  82220. /**
  82221. * Defines the location of the file to load
  82222. */
  82223. url: string,
  82224. /**
  82225. * Defines if mipmap should not be generated (default is false)
  82226. */
  82227. noMipmap?: boolean | undefined,
  82228. /**
  82229. * Defines if texture must be inverted on Y axis (default is true)
  82230. */
  82231. invertY?: boolean,
  82232. /**
  82233. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82234. */
  82235. samplingMode?: number);
  82236. /**
  82237. * Execute the current task
  82238. * @param scene defines the scene where you want your assets to be loaded
  82239. * @param onSuccess is a callback called when the task is successfully executed
  82240. * @param onError is a callback called if an error occurs
  82241. */
  82242. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82243. }
  82244. /**
  82245. * Define a task used by AssetsManager to load cube textures
  82246. */
  82247. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  82248. /**
  82249. * Defines the name of the task
  82250. */
  82251. name: string;
  82252. /**
  82253. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  82254. */
  82255. url: string;
  82256. /**
  82257. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  82258. */
  82259. extensions?: string[] | undefined;
  82260. /**
  82261. * Defines if mipmaps should not be generated (default is false)
  82262. */
  82263. noMipmap?: boolean | undefined;
  82264. /**
  82265. * Defines the explicit list of files (undefined by default)
  82266. */
  82267. files?: string[] | undefined;
  82268. /**
  82269. * Gets the loaded texture
  82270. */
  82271. texture: CubeTexture;
  82272. /**
  82273. * Callback called when the task is successful
  82274. */
  82275. onSuccess: (task: CubeTextureAssetTask) => void;
  82276. /**
  82277. * Callback called when the task is successful
  82278. */
  82279. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  82280. /**
  82281. * Creates a new CubeTextureAssetTask
  82282. * @param name defines the name of the task
  82283. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  82284. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  82285. * @param noMipmap defines if mipmaps should not be generated (default is false)
  82286. * @param files defines the explicit list of files (undefined by default)
  82287. */
  82288. constructor(
  82289. /**
  82290. * Defines the name of the task
  82291. */
  82292. name: string,
  82293. /**
  82294. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  82295. */
  82296. url: string,
  82297. /**
  82298. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  82299. */
  82300. extensions?: string[] | undefined,
  82301. /**
  82302. * Defines if mipmaps should not be generated (default is false)
  82303. */
  82304. noMipmap?: boolean | undefined,
  82305. /**
  82306. * Defines the explicit list of files (undefined by default)
  82307. */
  82308. files?: string[] | undefined);
  82309. /**
  82310. * Execute the current task
  82311. * @param scene defines the scene where you want your assets to be loaded
  82312. * @param onSuccess is a callback called when the task is successfully executed
  82313. * @param onError is a callback called if an error occurs
  82314. */
  82315. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82316. }
  82317. /**
  82318. * Define a task used by AssetsManager to load HDR cube textures
  82319. */
  82320. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  82321. /**
  82322. * Defines the name of the task
  82323. */
  82324. name: string;
  82325. /**
  82326. * Defines the location of the file to load
  82327. */
  82328. url: string;
  82329. /**
  82330. * Defines the desired size (the more it increases the longer the generation will be)
  82331. */
  82332. size: number;
  82333. /**
  82334. * Defines if mipmaps should not be generated (default is false)
  82335. */
  82336. noMipmap: boolean;
  82337. /**
  82338. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  82339. */
  82340. generateHarmonics: boolean;
  82341. /**
  82342. * 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)
  82343. */
  82344. gammaSpace: boolean;
  82345. /**
  82346. * Internal Use Only
  82347. */
  82348. reserved: boolean;
  82349. /**
  82350. * Gets the loaded texture
  82351. */
  82352. texture: HDRCubeTexture;
  82353. /**
  82354. * Callback called when the task is successful
  82355. */
  82356. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  82357. /**
  82358. * Callback called when the task is successful
  82359. */
  82360. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  82361. /**
  82362. * Creates a new HDRCubeTextureAssetTask object
  82363. * @param name defines the name of the task
  82364. * @param url defines the location of the file to load
  82365. * @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.
  82366. * @param noMipmap defines if mipmaps should not be generated (default is false)
  82367. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  82368. * @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)
  82369. * @param reserved Internal use only
  82370. */
  82371. constructor(
  82372. /**
  82373. * Defines the name of the task
  82374. */
  82375. name: string,
  82376. /**
  82377. * Defines the location of the file to load
  82378. */
  82379. url: string,
  82380. /**
  82381. * Defines the desired size (the more it increases the longer the generation will be)
  82382. */
  82383. size: number,
  82384. /**
  82385. * Defines if mipmaps should not be generated (default is false)
  82386. */
  82387. noMipmap?: boolean,
  82388. /**
  82389. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  82390. */
  82391. generateHarmonics?: boolean,
  82392. /**
  82393. * 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)
  82394. */
  82395. gammaSpace?: boolean,
  82396. /**
  82397. * Internal Use Only
  82398. */
  82399. reserved?: boolean);
  82400. /**
  82401. * Execute the current task
  82402. * @param scene defines the scene where you want your assets to be loaded
  82403. * @param onSuccess is a callback called when the task is successfully executed
  82404. * @param onError is a callback called if an error occurs
  82405. */
  82406. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82407. }
  82408. /**
  82409. * Define a task used by AssetsManager to load Equirectangular cube textures
  82410. */
  82411. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  82412. /**
  82413. * Defines the name of the task
  82414. */
  82415. name: string;
  82416. /**
  82417. * Defines the location of the file to load
  82418. */
  82419. url: string;
  82420. /**
  82421. * Defines the desired size (the more it increases the longer the generation will be)
  82422. */
  82423. size: number;
  82424. /**
  82425. * Defines if mipmaps should not be generated (default is false)
  82426. */
  82427. noMipmap: boolean;
  82428. /**
  82429. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  82430. * but the standard material would require them in Gamma space) (default is true)
  82431. */
  82432. gammaSpace: boolean;
  82433. /**
  82434. * Gets the loaded texture
  82435. */
  82436. texture: EquiRectangularCubeTexture;
  82437. /**
  82438. * Callback called when the task is successful
  82439. */
  82440. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  82441. /**
  82442. * Callback called when the task is successful
  82443. */
  82444. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  82445. /**
  82446. * Creates a new EquiRectangularCubeTextureAssetTask object
  82447. * @param name defines the name of the task
  82448. * @param url defines the location of the file to load
  82449. * @param size defines the desired size (the more it increases the longer the generation will be)
  82450. * If the size is omitted this implies you are using a preprocessed cubemap.
  82451. * @param noMipmap defines if mipmaps should not be generated (default is false)
  82452. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  82453. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  82454. * (default is true)
  82455. */
  82456. constructor(
  82457. /**
  82458. * Defines the name of the task
  82459. */
  82460. name: string,
  82461. /**
  82462. * Defines the location of the file to load
  82463. */
  82464. url: string,
  82465. /**
  82466. * Defines the desired size (the more it increases the longer the generation will be)
  82467. */
  82468. size: number,
  82469. /**
  82470. * Defines if mipmaps should not be generated (default is false)
  82471. */
  82472. noMipmap?: boolean,
  82473. /**
  82474. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  82475. * but the standard material would require them in Gamma space) (default is true)
  82476. */
  82477. gammaSpace?: boolean);
  82478. /**
  82479. * Execute the current task
  82480. * @param scene defines the scene where you want your assets to be loaded
  82481. * @param onSuccess is a callback called when the task is successfully executed
  82482. * @param onError is a callback called if an error occurs
  82483. */
  82484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  82485. }
  82486. /**
  82487. * This class can be used to easily import assets into a scene
  82488. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  82489. */
  82490. export class AssetsManager {
  82491. private _scene;
  82492. private _isLoading;
  82493. protected _tasks: AbstractAssetTask[];
  82494. protected _waitingTasksCount: number;
  82495. protected _totalTasksCount: number;
  82496. /**
  82497. * Callback called when all tasks are processed
  82498. */
  82499. onFinish: (tasks: AbstractAssetTask[]) => void;
  82500. /**
  82501. * Callback called when a task is successful
  82502. */
  82503. onTaskSuccess: (task: AbstractAssetTask) => void;
  82504. /**
  82505. * Callback called when a task had an error
  82506. */
  82507. onTaskError: (task: AbstractAssetTask) => void;
  82508. /**
  82509. * Callback called when a task is done (whatever the result is)
  82510. */
  82511. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  82512. /**
  82513. * Observable called when all tasks are processed
  82514. */
  82515. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  82516. /**
  82517. * Observable called when a task had an error
  82518. */
  82519. onTaskErrorObservable: Observable<AbstractAssetTask>;
  82520. /**
  82521. * Observable called when all tasks were executed
  82522. */
  82523. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  82524. /**
  82525. * Observable called when a task is done (whatever the result is)
  82526. */
  82527. onProgressObservable: Observable<IAssetsProgressEvent>;
  82528. /**
  82529. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  82530. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82531. */
  82532. useDefaultLoadingScreen: boolean;
  82533. /**
  82534. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  82535. * when all assets have been downloaded.
  82536. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  82537. */
  82538. autoHideLoadingUI: boolean;
  82539. /**
  82540. * Creates a new AssetsManager
  82541. * @param scene defines the scene to work on
  82542. */
  82543. constructor(scene: Scene);
  82544. /**
  82545. * Add a ContainerAssetTask to the list of active tasks
  82546. * @param taskName defines the name of the new task
  82547. * @param meshesNames defines the name of meshes to load
  82548. * @param rootUrl defines the root url to use to locate files
  82549. * @param sceneFilename defines the filename of the scene file
  82550. * @returns a new ContainerAssetTask object
  82551. */
  82552. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  82553. /**
  82554. * Add a MeshAssetTask to the list of active tasks
  82555. * @param taskName defines the name of the new task
  82556. * @param meshesNames defines the name of meshes to load
  82557. * @param rootUrl defines the root url to use to locate files
  82558. * @param sceneFilename defines the filename of the scene file
  82559. * @returns a new MeshAssetTask object
  82560. */
  82561. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  82562. /**
  82563. * Add a TextFileAssetTask to the list of active tasks
  82564. * @param taskName defines the name of the new task
  82565. * @param url defines the url of the file to load
  82566. * @returns a new TextFileAssetTask object
  82567. */
  82568. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  82569. /**
  82570. * Add a BinaryFileAssetTask to the list of active tasks
  82571. * @param taskName defines the name of the new task
  82572. * @param url defines the url of the file to load
  82573. * @returns a new BinaryFileAssetTask object
  82574. */
  82575. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  82576. /**
  82577. * Add a ImageAssetTask to the list of active tasks
  82578. * @param taskName defines the name of the new task
  82579. * @param url defines the url of the file to load
  82580. * @returns a new ImageAssetTask object
  82581. */
  82582. addImageTask(taskName: string, url: string): ImageAssetTask;
  82583. /**
  82584. * Add a TextureAssetTask to the list of active tasks
  82585. * @param taskName defines the name of the new task
  82586. * @param url defines the url of the file to load
  82587. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82588. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  82589. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  82590. * @returns a new TextureAssetTask object
  82591. */
  82592. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  82593. /**
  82594. * Add a CubeTextureAssetTask to the list of active tasks
  82595. * @param taskName defines the name of the new task
  82596. * @param url defines the url of the file to load
  82597. * @param extensions defines the extension to use to load the cube map (can be null)
  82598. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82599. * @param files defines the list of files to load (can be null)
  82600. * @returns a new CubeTextureAssetTask object
  82601. */
  82602. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  82603. /**
  82604. *
  82605. * Add a HDRCubeTextureAssetTask to the list of active tasks
  82606. * @param taskName defines the name of the new task
  82607. * @param url defines the url of the file to load
  82608. * @param size defines the size you want for the cubemap (can be null)
  82609. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82610. * @param generateHarmonics defines if you want to automatically generate (true by default)
  82611. * @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)
  82612. * @param reserved Internal use only
  82613. * @returns a new HDRCubeTextureAssetTask object
  82614. */
  82615. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  82616. /**
  82617. *
  82618. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  82619. * @param taskName defines the name of the new task
  82620. * @param url defines the url of the file to load
  82621. * @param size defines the size you want for the cubemap (can be null)
  82622. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  82623. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  82624. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  82625. * @returns a new EquiRectangularCubeTextureAssetTask object
  82626. */
  82627. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  82628. /**
  82629. * Remove a task from the assets manager.
  82630. * @param task the task to remove
  82631. */
  82632. removeTask(task: AbstractAssetTask): void;
  82633. private _decreaseWaitingTasksCount;
  82634. private _runTask;
  82635. /**
  82636. * Reset the AssetsManager and remove all tasks
  82637. * @return the current instance of the AssetsManager
  82638. */
  82639. reset(): AssetsManager;
  82640. /**
  82641. * Start the loading process
  82642. * @return the current instance of the AssetsManager
  82643. */
  82644. load(): AssetsManager;
  82645. /**
  82646. * Start the loading process as an async operation
  82647. * @return a promise returning the list of failed tasks
  82648. */
  82649. loadAsync(): Promise<void>;
  82650. }
  82651. }
  82652. declare module "babylonjs/Misc/deferred" {
  82653. /**
  82654. * Wrapper class for promise with external resolve and reject.
  82655. */
  82656. export class Deferred<T> {
  82657. /**
  82658. * The promise associated with this deferred object.
  82659. */
  82660. readonly promise: Promise<T>;
  82661. private _resolve;
  82662. private _reject;
  82663. /**
  82664. * The resolve method of the promise associated with this deferred object.
  82665. */
  82666. get resolve(): (value: T | PromiseLike<T>) => void;
  82667. /**
  82668. * The reject method of the promise associated with this deferred object.
  82669. */
  82670. get reject(): (reason?: any) => void;
  82671. /**
  82672. * Constructor for this deferred object.
  82673. */
  82674. constructor();
  82675. }
  82676. }
  82677. declare module "babylonjs/Misc/meshExploder" {
  82678. import { Mesh } from "babylonjs/Meshes/mesh";
  82679. /**
  82680. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  82681. */
  82682. export class MeshExploder {
  82683. private _centerMesh;
  82684. private _meshes;
  82685. private _meshesOrigins;
  82686. private _toCenterVectors;
  82687. private _scaledDirection;
  82688. private _newPosition;
  82689. private _centerPosition;
  82690. /**
  82691. * Explodes meshes from a center mesh.
  82692. * @param meshes The meshes to explode.
  82693. * @param centerMesh The mesh to be center of explosion.
  82694. */
  82695. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  82696. private _setCenterMesh;
  82697. /**
  82698. * Get class name
  82699. * @returns "MeshExploder"
  82700. */
  82701. getClassName(): string;
  82702. /**
  82703. * "Exploded meshes"
  82704. * @returns Array of meshes with the centerMesh at index 0.
  82705. */
  82706. getMeshes(): Array<Mesh>;
  82707. /**
  82708. * Explodes meshes giving a specific direction
  82709. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  82710. */
  82711. explode(direction?: number): void;
  82712. }
  82713. }
  82714. declare module "babylonjs/Misc/filesInput" {
  82715. import { Engine } from "babylonjs/Engines/engine";
  82716. import { Scene } from "babylonjs/scene";
  82717. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  82718. import { Nullable } from "babylonjs/types";
  82719. /**
  82720. * Class used to help managing file picking and drag'n'drop
  82721. */
  82722. export class FilesInput {
  82723. /**
  82724. * List of files ready to be loaded
  82725. */
  82726. static get FilesToLoad(): {
  82727. [key: string]: File;
  82728. };
  82729. /**
  82730. * Callback called when a file is processed
  82731. */
  82732. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  82733. /**
  82734. * Function used when loading the scene file
  82735. */
  82736. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  82737. private _engine;
  82738. private _currentScene;
  82739. private _sceneLoadedCallback;
  82740. private _progressCallback;
  82741. private _additionalRenderLoopLogicCallback;
  82742. private _textureLoadingCallback;
  82743. private _startingProcessingFilesCallback;
  82744. private _onReloadCallback;
  82745. private _errorCallback;
  82746. private _elementToMonitor;
  82747. private _sceneFileToLoad;
  82748. private _filesToLoad;
  82749. /**
  82750. * Creates a new FilesInput
  82751. * @param engine defines the rendering engine
  82752. * @param scene defines the hosting scene
  82753. * @param sceneLoadedCallback callback called when scene is loaded
  82754. * @param progressCallback callback called to track progress
  82755. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  82756. * @param textureLoadingCallback callback called when a texture is loading
  82757. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  82758. * @param onReloadCallback callback called when a reload is requested
  82759. * @param errorCallback callback call if an error occurs
  82760. */
  82761. 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>);
  82762. private _dragEnterHandler;
  82763. private _dragOverHandler;
  82764. private _dropHandler;
  82765. /**
  82766. * Calls this function to listen to drag'n'drop events on a specific DOM element
  82767. * @param elementToMonitor defines the DOM element to track
  82768. */
  82769. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  82770. /** Gets the current list of files to load */
  82771. get filesToLoad(): File[];
  82772. /**
  82773. * Release all associated resources
  82774. */
  82775. dispose(): void;
  82776. private renderFunction;
  82777. private drag;
  82778. private drop;
  82779. private _traverseFolder;
  82780. private _processFiles;
  82781. /**
  82782. * Load files from a drop event
  82783. * @param event defines the drop event to use as source
  82784. */
  82785. loadFiles(event: any): void;
  82786. private _processReload;
  82787. /**
  82788. * Reload the current scene from the loaded files
  82789. */
  82790. reload(): void;
  82791. }
  82792. }
  82793. declare module "babylonjs/Misc/HighDynamicRange/index" {
  82794. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  82795. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  82796. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  82797. }
  82798. declare module "babylonjs/Misc/sceneOptimizer" {
  82799. import { Scene, IDisposable } from "babylonjs/scene";
  82800. import { Observable } from "babylonjs/Misc/observable";
  82801. /**
  82802. * Defines the root class used to create scene optimization to use with SceneOptimizer
  82803. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82804. */
  82805. export class SceneOptimization {
  82806. /**
  82807. * Defines the priority of this optimization (0 by default which means first in the list)
  82808. */
  82809. priority: number;
  82810. /**
  82811. * Gets a string describing the action executed by the current optimization
  82812. * @returns description string
  82813. */
  82814. getDescription(): string;
  82815. /**
  82816. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82817. * @param scene defines the current scene where to apply this optimization
  82818. * @param optimizer defines the current optimizer
  82819. * @returns true if everything that can be done was applied
  82820. */
  82821. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82822. /**
  82823. * Creates the SceneOptimization object
  82824. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82825. * @param desc defines the description associated with the optimization
  82826. */
  82827. constructor(
  82828. /**
  82829. * Defines the priority of this optimization (0 by default which means first in the list)
  82830. */
  82831. priority?: number);
  82832. }
  82833. /**
  82834. * Defines an optimization used to reduce the size of render target textures
  82835. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82836. */
  82837. export class TextureOptimization extends SceneOptimization {
  82838. /**
  82839. * Defines the priority of this optimization (0 by default which means first in the list)
  82840. */
  82841. priority: number;
  82842. /**
  82843. * 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
  82844. */
  82845. maximumSize: number;
  82846. /**
  82847. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82848. */
  82849. step: number;
  82850. /**
  82851. * Gets a string describing the action executed by the current optimization
  82852. * @returns description string
  82853. */
  82854. getDescription(): string;
  82855. /**
  82856. * Creates the TextureOptimization object
  82857. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82858. * @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
  82859. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82860. */
  82861. constructor(
  82862. /**
  82863. * Defines the priority of this optimization (0 by default which means first in the list)
  82864. */
  82865. priority?: number,
  82866. /**
  82867. * 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
  82868. */
  82869. maximumSize?: number,
  82870. /**
  82871. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82872. */
  82873. step?: number);
  82874. /**
  82875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82876. * @param scene defines the current scene where to apply this optimization
  82877. * @param optimizer defines the current optimizer
  82878. * @returns true if everything that can be done was applied
  82879. */
  82880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82881. }
  82882. /**
  82883. * Defines an optimization used to increase or decrease the rendering resolution
  82884. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82885. */
  82886. export class HardwareScalingOptimization extends SceneOptimization {
  82887. /**
  82888. * Defines the priority of this optimization (0 by default which means first in the list)
  82889. */
  82890. priority: number;
  82891. /**
  82892. * Defines the maximum scale to use (2 by default)
  82893. */
  82894. maximumScale: number;
  82895. /**
  82896. * Defines the step to use between two passes (0.5 by default)
  82897. */
  82898. step: number;
  82899. private _currentScale;
  82900. private _directionOffset;
  82901. /**
  82902. * Gets a string describing the action executed by the current optimization
  82903. * @return description string
  82904. */
  82905. getDescription(): string;
  82906. /**
  82907. * Creates the HardwareScalingOptimization object
  82908. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82909. * @param maximumScale defines the maximum scale to use (2 by default)
  82910. * @param step defines the step to use between two passes (0.5 by default)
  82911. */
  82912. constructor(
  82913. /**
  82914. * Defines the priority of this optimization (0 by default which means first in the list)
  82915. */
  82916. priority?: number,
  82917. /**
  82918. * Defines the maximum scale to use (2 by default)
  82919. */
  82920. maximumScale?: number,
  82921. /**
  82922. * Defines the step to use between two passes (0.5 by default)
  82923. */
  82924. step?: number);
  82925. /**
  82926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82927. * @param scene defines the current scene where to apply this optimization
  82928. * @param optimizer defines the current optimizer
  82929. * @returns true if everything that can be done was applied
  82930. */
  82931. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82932. }
  82933. /**
  82934. * Defines an optimization used to remove shadows
  82935. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82936. */
  82937. export class ShadowsOptimization extends SceneOptimization {
  82938. /**
  82939. * Gets a string describing the action executed by the current optimization
  82940. * @return description string
  82941. */
  82942. getDescription(): string;
  82943. /**
  82944. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82945. * @param scene defines the current scene where to apply this optimization
  82946. * @param optimizer defines the current optimizer
  82947. * @returns true if everything that can be done was applied
  82948. */
  82949. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82950. }
  82951. /**
  82952. * Defines an optimization used to turn post-processes off
  82953. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82954. */
  82955. export class PostProcessesOptimization extends SceneOptimization {
  82956. /**
  82957. * Gets a string describing the action executed by the current optimization
  82958. * @return description string
  82959. */
  82960. getDescription(): string;
  82961. /**
  82962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82963. * @param scene defines the current scene where to apply this optimization
  82964. * @param optimizer defines the current optimizer
  82965. * @returns true if everything that can be done was applied
  82966. */
  82967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82968. }
  82969. /**
  82970. * Defines an optimization used to turn lens flares off
  82971. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82972. */
  82973. export class LensFlaresOptimization extends SceneOptimization {
  82974. /**
  82975. * Gets a string describing the action executed by the current optimization
  82976. * @return description string
  82977. */
  82978. getDescription(): string;
  82979. /**
  82980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82981. * @param scene defines the current scene where to apply this optimization
  82982. * @param optimizer defines the current optimizer
  82983. * @returns true if everything that can be done was applied
  82984. */
  82985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82986. }
  82987. /**
  82988. * Defines an optimization based on user defined callback.
  82989. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82990. */
  82991. export class CustomOptimization extends SceneOptimization {
  82992. /**
  82993. * Callback called to apply the custom optimization.
  82994. */
  82995. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  82996. /**
  82997. * Callback called to get custom description
  82998. */
  82999. onGetDescription: () => string;
  83000. /**
  83001. * Gets a string describing the action executed by the current optimization
  83002. * @returns description string
  83003. */
  83004. getDescription(): string;
  83005. /**
  83006. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  83007. * @param scene defines the current scene where to apply this optimization
  83008. * @param optimizer defines the current optimizer
  83009. * @returns true if everything that can be done was applied
  83010. */
  83011. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  83012. }
  83013. /**
  83014. * Defines an optimization used to turn particles off
  83015. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  83016. */
  83017. export class ParticlesOptimization extends SceneOptimization {
  83018. /**
  83019. * Gets a string describing the action executed by the current optimization
  83020. * @return description string
  83021. */
  83022. getDescription(): string;
  83023. /**
  83024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  83025. * @param scene defines the current scene where to apply this optimization
  83026. * @param optimizer defines the current optimizer
  83027. * @returns true if everything that can be done was applied
  83028. */
  83029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  83030. }
  83031. /**
  83032. * Defines an optimization used to turn render targets off
  83033. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  83034. */
  83035. export class RenderTargetsOptimization extends SceneOptimization {
  83036. /**
  83037. * Gets a string describing the action executed by the current optimization
  83038. * @return description string
  83039. */
  83040. getDescription(): string;
  83041. /**
  83042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  83043. * @param scene defines the current scene where to apply this optimization
  83044. * @param optimizer defines the current optimizer
  83045. * @returns true if everything that can be done was applied
  83046. */
  83047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  83048. }
  83049. /**
  83050. * Defines an optimization used to merge meshes with compatible materials
  83051. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  83052. */
  83053. export class MergeMeshesOptimization extends SceneOptimization {
  83054. private static _UpdateSelectionTree;
  83055. /**
  83056. * Gets or sets a boolean which defines if optimization octree has to be updated
  83057. */
  83058. static get UpdateSelectionTree(): boolean;
  83059. /**
  83060. * Gets or sets a boolean which defines if optimization octree has to be updated
  83061. */
  83062. static set UpdateSelectionTree(value: boolean);
  83063. /**
  83064. * Gets a string describing the action executed by the current optimization
  83065. * @return description string
  83066. */
  83067. getDescription(): string;
  83068. private _canBeMerged;
  83069. /**
  83070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  83071. * @param scene defines the current scene where to apply this optimization
  83072. * @param optimizer defines the current optimizer
  83073. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  83074. * @returns true if everything that can be done was applied
  83075. */
  83076. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  83077. }
  83078. /**
  83079. * Defines a list of options used by SceneOptimizer
  83080. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  83081. */
  83082. export class SceneOptimizerOptions {
  83083. /**
  83084. * Defines the target frame rate to reach (60 by default)
  83085. */
  83086. targetFrameRate: number;
  83087. /**
  83088. * Defines the interval between two checks (2000ms by default)
  83089. */
  83090. trackerDuration: number;
  83091. /**
  83092. * Gets the list of optimizations to apply
  83093. */
  83094. optimizations: SceneOptimization[];
  83095. /**
  83096. * Creates a new list of options used by SceneOptimizer
  83097. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  83098. * @param trackerDuration defines the interval between two checks (2000ms by default)
  83099. */
  83100. constructor(
  83101. /**
  83102. * Defines the target frame rate to reach (60 by default)
  83103. */
  83104. targetFrameRate?: number,
  83105. /**
  83106. * Defines the interval between two checks (2000ms by default)
  83107. */
  83108. trackerDuration?: number);
  83109. /**
  83110. * Add a new optimization
  83111. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  83112. * @returns the current SceneOptimizerOptions
  83113. */
  83114. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  83115. /**
  83116. * Add a new custom optimization
  83117. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  83118. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  83119. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  83120. * @returns the current SceneOptimizerOptions
  83121. */
  83122. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  83123. /**
  83124. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  83125. * @param targetFrameRate defines the target frame rate (60 by default)
  83126. * @returns a SceneOptimizerOptions object
  83127. */
  83128. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  83129. /**
  83130. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  83131. * @param targetFrameRate defines the target frame rate (60 by default)
  83132. * @returns a SceneOptimizerOptions object
  83133. */
  83134. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  83135. /**
  83136. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  83137. * @param targetFrameRate defines the target frame rate (60 by default)
  83138. * @returns a SceneOptimizerOptions object
  83139. */
  83140. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  83141. }
  83142. /**
  83143. * Class used to run optimizations in order to reach a target frame rate
  83144. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  83145. */
  83146. export class SceneOptimizer implements IDisposable {
  83147. private _isRunning;
  83148. private _options;
  83149. private _scene;
  83150. private _currentPriorityLevel;
  83151. private _targetFrameRate;
  83152. private _trackerDuration;
  83153. private _currentFrameRate;
  83154. private _sceneDisposeObserver;
  83155. private _improvementMode;
  83156. /**
  83157. * Defines an observable called when the optimizer reaches the target frame rate
  83158. */
  83159. onSuccessObservable: Observable<SceneOptimizer>;
  83160. /**
  83161. * Defines an observable called when the optimizer enables an optimization
  83162. */
  83163. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  83164. /**
  83165. * Defines an observable called when the optimizer is not able to reach the target frame rate
  83166. */
  83167. onFailureObservable: Observable<SceneOptimizer>;
  83168. /**
  83169. * Gets a boolean indicating if the optimizer is in improvement mode
  83170. */
  83171. get isInImprovementMode(): boolean;
  83172. /**
  83173. * Gets the current priority level (0 at start)
  83174. */
  83175. get currentPriorityLevel(): number;
  83176. /**
  83177. * Gets the current frame rate checked by the SceneOptimizer
  83178. */
  83179. get currentFrameRate(): number;
  83180. /**
  83181. * Gets or sets the current target frame rate (60 by default)
  83182. */
  83183. get targetFrameRate(): number;
  83184. /**
  83185. * Gets or sets the current target frame rate (60 by default)
  83186. */
  83187. set targetFrameRate(value: number);
  83188. /**
  83189. * Gets or sets the current interval between two checks (every 2000ms by default)
  83190. */
  83191. get trackerDuration(): number;
  83192. /**
  83193. * Gets or sets the current interval between two checks (every 2000ms by default)
  83194. */
  83195. set trackerDuration(value: number);
  83196. /**
  83197. * Gets the list of active optimizations
  83198. */
  83199. get optimizations(): SceneOptimization[];
  83200. /**
  83201. * Creates a new SceneOptimizer
  83202. * @param scene defines the scene to work on
  83203. * @param options defines the options to use with the SceneOptimizer
  83204. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  83205. * @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)
  83206. */
  83207. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  83208. /**
  83209. * Stops the current optimizer
  83210. */
  83211. stop(): void;
  83212. /**
  83213. * Reset the optimizer to initial step (current priority level = 0)
  83214. */
  83215. reset(): void;
  83216. /**
  83217. * Start the optimizer. By default it will try to reach a specific framerate
  83218. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  83219. */
  83220. start(): void;
  83221. private _checkCurrentState;
  83222. /**
  83223. * Release all resources
  83224. */
  83225. dispose(): void;
  83226. /**
  83227. * Helper function to create a SceneOptimizer with one single line of code
  83228. * @param scene defines the scene to work on
  83229. * @param options defines the options to use with the SceneOptimizer
  83230. * @param onSuccess defines a callback to call on success
  83231. * @param onFailure defines a callback to call on failure
  83232. * @returns the new SceneOptimizer object
  83233. */
  83234. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  83235. }
  83236. }
  83237. declare module "babylonjs/Misc/sceneSerializer" {
  83238. import { Scene } from "babylonjs/scene";
  83239. /**
  83240. * Class used to serialize a scene into a string
  83241. */
  83242. export class SceneSerializer {
  83243. /**
  83244. * Clear cache used by a previous serialization
  83245. */
  83246. static ClearCache(): void;
  83247. /**
  83248. * Serialize a scene into a JSON compatible object
  83249. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  83250. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  83251. * @param scene defines the scene to serialize
  83252. * @returns a JSON compatible object
  83253. */
  83254. static Serialize(scene: Scene): any;
  83255. private static _Serialize;
  83256. /**
  83257. * Serialize a scene into a JSON compatible object
  83258. * @param scene defines the scene to serialize
  83259. * @returns a JSON promise compatible object
  83260. */
  83261. static SerializeAsync(scene: Scene): Promise<any>;
  83262. private static _CollectPromises;
  83263. /**
  83264. * Serialize a mesh into a JSON compatible object
  83265. * @param toSerialize defines the mesh to serialize
  83266. * @param withParents defines if parents must be serialized as well
  83267. * @param withChildren defines if children must be serialized as well
  83268. * @returns a JSON compatible object
  83269. */
  83270. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  83271. }
  83272. }
  83273. declare module "babylonjs/Misc/videoRecorder" {
  83274. import { Nullable } from "babylonjs/types";
  83275. import { Engine } from "babylonjs/Engines/engine";
  83276. /**
  83277. * This represents the different options available for the video capture.
  83278. */
  83279. export interface VideoRecorderOptions {
  83280. /** Defines the mime type of the video. */
  83281. mimeType: string;
  83282. /** Defines the FPS the video should be recorded at. */
  83283. fps: number;
  83284. /** Defines the chunk size for the recording data. */
  83285. recordChunckSize: number;
  83286. /** The audio tracks to attach to the recording. */
  83287. audioTracks?: MediaStreamTrack[];
  83288. }
  83289. /**
  83290. * This can help with recording videos from BabylonJS.
  83291. * This is based on the available WebRTC functionalities of the browser.
  83292. *
  83293. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  83294. */
  83295. export class VideoRecorder {
  83296. private static readonly _defaultOptions;
  83297. /**
  83298. * Returns whether or not the VideoRecorder is available in your browser.
  83299. * @param engine Defines the Babylon Engine.
  83300. * @returns true if supported otherwise false.
  83301. */
  83302. static IsSupported(engine: Engine): boolean;
  83303. private readonly _options;
  83304. private _canvas;
  83305. private _mediaRecorder;
  83306. private _recordedChunks;
  83307. private _fileName;
  83308. private _resolve;
  83309. private _reject;
  83310. /**
  83311. * True when a recording is already in progress.
  83312. */
  83313. get isRecording(): boolean;
  83314. /**
  83315. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  83316. * @param engine Defines the BabylonJS Engine you wish to record.
  83317. * @param options Defines options that can be used to customize the capture.
  83318. */
  83319. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  83320. /**
  83321. * Stops the current recording before the default capture timeout passed in the startRecording function.
  83322. */
  83323. stopRecording(): void;
  83324. /**
  83325. * Starts recording the canvas for a max duration specified in parameters.
  83326. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  83327. * If null no automatic download will start and you can rely on the promise to get the data back.
  83328. * @param maxDuration Defines the maximum recording time in seconds.
  83329. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  83330. * @return A promise callback at the end of the recording with the video data in Blob.
  83331. */
  83332. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  83333. /**
  83334. * Releases internal resources used during the recording.
  83335. */
  83336. dispose(): void;
  83337. private _handleDataAvailable;
  83338. private _handleError;
  83339. private _handleStop;
  83340. }
  83341. }
  83342. declare module "babylonjs/Misc/screenshotTools" {
  83343. import { Camera } from "babylonjs/Cameras/camera";
  83344. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  83345. import { Engine } from "babylonjs/Engines/engine";
  83346. /**
  83347. * Class containing a set of static utilities functions for screenshots
  83348. */
  83349. export class ScreenshotTools {
  83350. /**
  83351. * Captures a screenshot of the current rendering
  83352. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  83353. * @param engine defines the rendering engine
  83354. * @param camera defines the source camera
  83355. * @param size This parameter can be set to a single number or to an object with the
  83356. * following (optional) properties: precision, width, height. If a single number is passed,
  83357. * it will be used for both width and height. If an object is passed, the screenshot size
  83358. * will be derived from the parameters. The precision property is a multiplier allowing
  83359. * rendering at a higher or lower resolution
  83360. * @param successCallback defines the callback receives a single parameter which contains the
  83361. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  83362. * src parameter of an <img> to display it
  83363. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  83364. * Check your browser for supported MIME types
  83365. * @param forceDownload force the system to download the image even if a successCallback is provided
  83366. */
  83367. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  83368. /**
  83369. * Captures a screenshot of the current rendering
  83370. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  83371. * @param engine defines the rendering engine
  83372. * @param camera defines the source camera
  83373. * @param size This parameter can be set to a single number or to an object with the
  83374. * following (optional) properties: precision, width, height. If a single number is passed,
  83375. * it will be used for both width and height. If an object is passed, the screenshot size
  83376. * will be derived from the parameters. The precision property is a multiplier allowing
  83377. * rendering at a higher or lower resolution
  83378. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  83379. * Check your browser for supported MIME types
  83380. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  83381. * to the src parameter of an <img> to display it
  83382. */
  83383. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  83384. /**
  83385. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  83386. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  83387. * @param engine defines the rendering engine
  83388. * @param camera defines the source camera
  83389. * @param width defines the expected width
  83390. * @param height defines the expected height
  83391. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  83392. * Check your browser for supported MIME types
  83393. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  83394. * to the src parameter of an <img> to display it
  83395. */
  83396. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  83397. /**
  83398. * Generates an image screenshot from the specified camera.
  83399. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  83400. * @param engine The engine to use for rendering
  83401. * @param camera The camera to use for rendering
  83402. * @param size This parameter can be set to a single number or to an object with the
  83403. * following (optional) properties: precision, width, height. If a single number is passed,
  83404. * it will be used for both width and height. If an object is passed, the screenshot size
  83405. * will be derived from the parameters. The precision property is a multiplier allowing
  83406. * rendering at a higher or lower resolution
  83407. * @param successCallback The callback receives a single parameter which contains the
  83408. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  83409. * src parameter of an <img> to display it
  83410. * @param mimeType The MIME type of the screenshot image (default: image/png).
  83411. * Check your browser for supported MIME types
  83412. * @param samples Texture samples (default: 1)
  83413. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  83414. * @param fileName A name for for the downloaded file.
  83415. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  83416. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  83417. */
  83418. 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;
  83419. /**
  83420. * Generates an image screenshot from the specified camera.
  83421. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  83422. * @param engine The engine to use for rendering
  83423. * @param camera The camera to use for rendering
  83424. * @param size This parameter can be set to a single number or to an object with the
  83425. * following (optional) properties: precision, width, height. If a single number is passed,
  83426. * it will be used for both width and height. If an object is passed, the screenshot size
  83427. * will be derived from the parameters. The precision property is a multiplier allowing
  83428. * rendering at a higher or lower resolution
  83429. * @param mimeType The MIME type of the screenshot image (default: image/png).
  83430. * Check your browser for supported MIME types
  83431. * @param samples Texture samples (default: 1)
  83432. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  83433. * @param fileName A name for for the downloaded file.
  83434. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  83435. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  83436. * to the src parameter of an <img> to display it
  83437. */
  83438. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  83439. /**
  83440. * Gets height and width for screenshot size
  83441. * @private
  83442. */
  83443. private static _getScreenshotSize;
  83444. }
  83445. }
  83446. declare module "babylonjs/Misc/dataReader" {
  83447. /**
  83448. * Interface for a data buffer
  83449. */
  83450. export interface IDataBuffer {
  83451. /**
  83452. * Reads bytes from the data buffer.
  83453. * @param byteOffset The byte offset to read
  83454. * @param byteLength The byte length to read
  83455. * @returns A promise that resolves when the bytes are read
  83456. */
  83457. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  83458. /**
  83459. * The byte length of the buffer.
  83460. */
  83461. readonly byteLength: number;
  83462. }
  83463. /**
  83464. * Utility class for reading from a data buffer
  83465. */
  83466. export class DataReader {
  83467. /**
  83468. * The data buffer associated with this data reader.
  83469. */
  83470. readonly buffer: IDataBuffer;
  83471. /**
  83472. * The current byte offset from the beginning of the data buffer.
  83473. */
  83474. byteOffset: number;
  83475. private _dataView;
  83476. private _dataByteOffset;
  83477. /**
  83478. * Constructor
  83479. * @param buffer The buffer to read
  83480. */
  83481. constructor(buffer: IDataBuffer);
  83482. /**
  83483. * Loads the given byte length.
  83484. * @param byteLength The byte length to load
  83485. * @returns A promise that resolves when the load is complete
  83486. */
  83487. loadAsync(byteLength: number): Promise<void>;
  83488. /**
  83489. * Read a unsigned 32-bit integer from the currently loaded data range.
  83490. * @returns The 32-bit integer read
  83491. */
  83492. readUint32(): number;
  83493. /**
  83494. * Read a byte array from the currently loaded data range.
  83495. * @param byteLength The byte length to read
  83496. * @returns The byte array read
  83497. */
  83498. readUint8Array(byteLength: number): Uint8Array;
  83499. /**
  83500. * Read a string from the currently loaded data range.
  83501. * @param byteLength The byte length to read
  83502. * @returns The string read
  83503. */
  83504. readString(byteLength: number): string;
  83505. /**
  83506. * Skips the given byte length the currently loaded data range.
  83507. * @param byteLength The byte length to skip
  83508. */
  83509. skipBytes(byteLength: number): void;
  83510. }
  83511. }
  83512. declare module "babylonjs/Misc/dataStorage" {
  83513. /**
  83514. * Class for storing data to local storage if available or in-memory storage otherwise
  83515. */
  83516. export class DataStorage {
  83517. private static _Storage;
  83518. private static _GetStorage;
  83519. /**
  83520. * Reads a string from the data storage
  83521. * @param key The key to read
  83522. * @param defaultValue The value if the key doesn't exist
  83523. * @returns The string value
  83524. */
  83525. static ReadString(key: string, defaultValue: string): string;
  83526. /**
  83527. * Writes a string to the data storage
  83528. * @param key The key to write
  83529. * @param value The value to write
  83530. */
  83531. static WriteString(key: string, value: string): void;
  83532. /**
  83533. * Reads a boolean from the data storage
  83534. * @param key The key to read
  83535. * @param defaultValue The value if the key doesn't exist
  83536. * @returns The boolean value
  83537. */
  83538. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  83539. /**
  83540. * Writes a boolean to the data storage
  83541. * @param key The key to write
  83542. * @param value The value to write
  83543. */
  83544. static WriteBoolean(key: string, value: boolean): void;
  83545. /**
  83546. * Reads a number from the data storage
  83547. * @param key The key to read
  83548. * @param defaultValue The value if the key doesn't exist
  83549. * @returns The number value
  83550. */
  83551. static ReadNumber(key: string, defaultValue: number): number;
  83552. /**
  83553. * Writes a number to the data storage
  83554. * @param key The key to write
  83555. * @param value The value to write
  83556. */
  83557. static WriteNumber(key: string, value: number): void;
  83558. }
  83559. }
  83560. declare module "babylonjs/Misc/sceneRecorder" {
  83561. import { Scene } from "babylonjs/scene";
  83562. /**
  83563. * Class used to record delta files between 2 scene states
  83564. */
  83565. export class SceneRecorder {
  83566. private _trackedScene;
  83567. private _savedJSON;
  83568. /**
  83569. * Track a given scene. This means the current scene state will be considered the original state
  83570. * @param scene defines the scene to track
  83571. */
  83572. track(scene: Scene): void;
  83573. /**
  83574. * Get the delta between current state and original state
  83575. * @returns a any containing the delta
  83576. */
  83577. getDelta(): any;
  83578. private _compareArray;
  83579. private _compareObjects;
  83580. private _compareCollections;
  83581. private static GetShadowGeneratorById;
  83582. /**
  83583. * Apply a given delta to a given scene
  83584. * @param deltaJSON defines the JSON containing the delta
  83585. * @param scene defines the scene to apply the delta to
  83586. */
  83587. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  83588. private static _ApplyPropertiesToEntity;
  83589. private static _ApplyDeltaForEntity;
  83590. }
  83591. }
  83592. declare module "babylonjs/Misc/trajectoryClassifier" {
  83593. import { DeepImmutable, Nullable } from "babylonjs/types";
  83594. import { Vector3 } from "babylonjs/Maths/math.vector";
  83595. /**
  83596. * A 3D trajectory consisting of an order list of vectors describing a
  83597. * path of motion through 3D space.
  83598. */
  83599. export class Trajectory {
  83600. private _points;
  83601. private readonly _segmentLength;
  83602. /**
  83603. * Serialize to JSON.
  83604. * @returns serialized JSON string
  83605. */
  83606. serialize(): string;
  83607. /**
  83608. * Deserialize from JSON.
  83609. * @param json serialized JSON string
  83610. * @returns deserialized Trajectory
  83611. */
  83612. static Deserialize(json: string): Trajectory;
  83613. /**
  83614. * Create a new empty Trajectory.
  83615. * @param segmentLength radius of discretization for Trajectory points
  83616. */
  83617. constructor(segmentLength?: number);
  83618. /**
  83619. * Get the length of the Trajectory.
  83620. * @returns length of the Trajectory
  83621. */
  83622. getLength(): number;
  83623. /**
  83624. * Append a new point to the Trajectory.
  83625. * NOTE: This implementation has many allocations.
  83626. * @param point point to append to the Trajectory
  83627. */
  83628. add(point: DeepImmutable<Vector3>): void;
  83629. /**
  83630. * Create a new Trajectory with a segment length chosen to make it
  83631. * probable that the new Trajectory will have a specified number of
  83632. * segments. This operation is imprecise.
  83633. * @param targetResolution number of segments desired
  83634. * @returns new Trajectory with approximately the requested number of segments
  83635. */
  83636. resampleAtTargetResolution(targetResolution: number): Trajectory;
  83637. /**
  83638. * Convert Trajectory segments into tokenized representation. This
  83639. * representation is an array of numbers where each nth number is the
  83640. * index of the token which is most similar to the nth segment of the
  83641. * Trajectory.
  83642. * @param tokens list of vectors which serve as discrete tokens
  83643. * @returns list of indices of most similar token per segment
  83644. */
  83645. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  83646. private static _forwardDir;
  83647. private static _inverseFromVec;
  83648. private static _upDir;
  83649. private static _fromToVec;
  83650. private static _lookMatrix;
  83651. /**
  83652. * Transform the rotation (i.e., direction) of a segment to isolate
  83653. * the relative transformation represented by the segment. This operation
  83654. * may or may not succeed due to singularities in the equations that define
  83655. * motion relativity in this context.
  83656. * @param priorVec the origin of the prior segment
  83657. * @param fromVec the origin of the current segment
  83658. * @param toVec the destination of the current segment
  83659. * @param result reference to output variable
  83660. * @returns whether or not transformation was successful
  83661. */
  83662. private static _transformSegmentDirToRef;
  83663. private static _bestMatch;
  83664. private static _score;
  83665. private static _bestScore;
  83666. /**
  83667. * Determine which token vector is most similar to the
  83668. * segment vector.
  83669. * @param segment segment vector
  83670. * @param tokens token vector list
  83671. * @returns index of the most similar token to the segment
  83672. */
  83673. private static _tokenizeSegment;
  83674. }
  83675. /**
  83676. * Class representing a set of known, named trajectories to which Trajectories can be
  83677. * added and using which Trajectories can be recognized.
  83678. */
  83679. export class TrajectoryClassifier {
  83680. private _maximumAllowableMatchCost;
  83681. private _vector3Alphabet;
  83682. private _levenshteinAlphabet;
  83683. private _nameToDescribedTrajectory;
  83684. /**
  83685. * Serialize to JSON.
  83686. * @returns JSON serialization
  83687. */
  83688. serialize(): string;
  83689. /**
  83690. * Deserialize from JSON.
  83691. * @param json JSON serialization
  83692. * @returns deserialized TrajectorySet
  83693. */
  83694. static Deserialize(json: string): TrajectoryClassifier;
  83695. /**
  83696. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  83697. * VERY naive, need to be generating these things from known
  83698. * sets. Better version later, probably eliminating this one.
  83699. * @returns auto-generated TrajectorySet
  83700. */
  83701. static Generate(): TrajectoryClassifier;
  83702. private constructor();
  83703. /**
  83704. * Add a new Trajectory to the set with a given name.
  83705. * @param trajectory new Trajectory to be added
  83706. * @param classification name to which to add the Trajectory
  83707. */
  83708. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  83709. /**
  83710. * Remove a known named trajectory and all Trajectories associated with it.
  83711. * @param classification name to remove
  83712. * @returns whether anything was removed
  83713. */
  83714. deleteClassification(classification: string): boolean;
  83715. /**
  83716. * Attempt to recognize a Trajectory from among all the classifications
  83717. * already known to the classifier.
  83718. * @param trajectory Trajectory to be recognized
  83719. * @returns classification of Trajectory if recognized, null otherwise
  83720. */
  83721. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  83722. }
  83723. }
  83724. declare module "babylonjs/Misc/index" {
  83725. export * from "babylonjs/Misc/andOrNotEvaluator";
  83726. export * from "babylonjs/Misc/assetsManager";
  83727. export * from "babylonjs/Misc/basis";
  83728. export * from "babylonjs/Misc/dds";
  83729. export * from "babylonjs/Misc/decorators";
  83730. export * from "babylonjs/Misc/deferred";
  83731. export * from "babylonjs/Misc/environmentTextureTools";
  83732. export * from "babylonjs/Misc/meshExploder";
  83733. export * from "babylonjs/Misc/filesInput";
  83734. export * from "babylonjs/Misc/HighDynamicRange/index";
  83735. export * from "babylonjs/Misc/khronosTextureContainer";
  83736. export * from "babylonjs/Misc/observable";
  83737. export * from "babylonjs/Misc/performanceMonitor";
  83738. export * from "babylonjs/Misc/promise";
  83739. export * from "babylonjs/Misc/sceneOptimizer";
  83740. export * from "babylonjs/Misc/sceneSerializer";
  83741. export * from "babylonjs/Misc/smartArray";
  83742. export * from "babylonjs/Misc/stringDictionary";
  83743. export * from "babylonjs/Misc/tags";
  83744. export * from "babylonjs/Misc/textureTools";
  83745. export * from "babylonjs/Misc/tga";
  83746. export * from "babylonjs/Misc/tools";
  83747. export * from "babylonjs/Misc/videoRecorder";
  83748. export * from "babylonjs/Misc/virtualJoystick";
  83749. export * from "babylonjs/Misc/workerPool";
  83750. export * from "babylonjs/Misc/logger";
  83751. export * from "babylonjs/Misc/typeStore";
  83752. export * from "babylonjs/Misc/filesInputStore";
  83753. export * from "babylonjs/Misc/deepCopier";
  83754. export * from "babylonjs/Misc/pivotTools";
  83755. export * from "babylonjs/Misc/precisionDate";
  83756. export * from "babylonjs/Misc/screenshotTools";
  83757. export * from "babylonjs/Misc/typeStore";
  83758. export * from "babylonjs/Misc/webRequest";
  83759. export * from "babylonjs/Misc/iInspectable";
  83760. export * from "babylonjs/Misc/brdfTextureTools";
  83761. export * from "babylonjs/Misc/rgbdTextureTools";
  83762. export * from "babylonjs/Misc/gradients";
  83763. export * from "babylonjs/Misc/perfCounter";
  83764. export * from "babylonjs/Misc/fileRequest";
  83765. export * from "babylonjs/Misc/customAnimationFrameRequester";
  83766. export * from "babylonjs/Misc/retryStrategy";
  83767. export * from "babylonjs/Misc/interfaces/screenshotSize";
  83768. export * from "babylonjs/Misc/canvasGenerator";
  83769. export * from "babylonjs/Misc/fileTools";
  83770. export * from "babylonjs/Misc/stringTools";
  83771. export * from "babylonjs/Misc/dataReader";
  83772. export * from "babylonjs/Misc/minMaxReducer";
  83773. export * from "babylonjs/Misc/depthReducer";
  83774. export * from "babylonjs/Misc/dataStorage";
  83775. export * from "babylonjs/Misc/sceneRecorder";
  83776. export * from "babylonjs/Misc/khronosTextureContainer2";
  83777. export * from "babylonjs/Misc/trajectoryClassifier";
  83778. export * from "babylonjs/Misc/timer";
  83779. export * from "babylonjs/Misc/copyTools";
  83780. }
  83781. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  83782. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  83783. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83784. import { Observable } from "babylonjs/Misc/observable";
  83785. import { Matrix } from "babylonjs/Maths/math.vector";
  83786. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83787. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83788. /**
  83789. * An interface for all Hit test features
  83790. */
  83791. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  83792. /**
  83793. * Triggered when new babylon (transformed) hit test results are available
  83794. */
  83795. onHitTestResultObservable: Observable<T[]>;
  83796. }
  83797. /**
  83798. * Options used for hit testing
  83799. */
  83800. export interface IWebXRLegacyHitTestOptions {
  83801. /**
  83802. * Only test when user interacted with the scene. Default - hit test every frame
  83803. */
  83804. testOnPointerDownOnly?: boolean;
  83805. /**
  83806. * The node to use to transform the local results to world coordinates
  83807. */
  83808. worldParentNode?: TransformNode;
  83809. }
  83810. /**
  83811. * Interface defining the babylon result of raycasting/hit-test
  83812. */
  83813. export interface IWebXRLegacyHitResult {
  83814. /**
  83815. * Transformation matrix that can be applied to a node that will put it in the hit point location
  83816. */
  83817. transformationMatrix: Matrix;
  83818. /**
  83819. * The native hit test result
  83820. */
  83821. xrHitResult: XRHitResult | XRHitTestResult;
  83822. }
  83823. /**
  83824. * The currently-working hit-test module.
  83825. * Hit test (or Ray-casting) is used to interact with the real world.
  83826. * For further information read here - https://github.com/immersive-web/hit-test
  83827. */
  83828. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  83829. /**
  83830. * options to use when constructing this feature
  83831. */
  83832. readonly options: IWebXRLegacyHitTestOptions;
  83833. private _direction;
  83834. private _mat;
  83835. private _onSelectEnabled;
  83836. private _origin;
  83837. /**
  83838. * The module's name
  83839. */
  83840. static readonly Name: string;
  83841. /**
  83842. * The (Babylon) version of this module.
  83843. * This is an integer representing the implementation version.
  83844. * This number does not correspond to the WebXR specs version
  83845. */
  83846. static readonly Version: number;
  83847. /**
  83848. * Populated with the last native XR Hit Results
  83849. */
  83850. lastNativeXRHitResults: XRHitResult[];
  83851. /**
  83852. * Triggered when new babylon (transformed) hit test results are available
  83853. */
  83854. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  83855. /**
  83856. * Creates a new instance of the (legacy version) hit test feature
  83857. * @param _xrSessionManager an instance of WebXRSessionManager
  83858. * @param options options to use when constructing this feature
  83859. */
  83860. constructor(_xrSessionManager: WebXRSessionManager,
  83861. /**
  83862. * options to use when constructing this feature
  83863. */
  83864. options?: IWebXRLegacyHitTestOptions);
  83865. /**
  83866. * execute a hit test with an XR Ray
  83867. *
  83868. * @param xrSession a native xrSession that will execute this hit test
  83869. * @param xrRay the ray (position and direction) to use for ray-casting
  83870. * @param referenceSpace native XR reference space to use for the hit-test
  83871. * @param filter filter function that will filter the results
  83872. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83873. */
  83874. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  83875. /**
  83876. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  83877. * @param event the (select) event to use to select with
  83878. * @param referenceSpace the reference space to use for this hit test
  83879. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83880. */
  83881. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  83882. /**
  83883. * attach this feature
  83884. * Will usually be called by the features manager
  83885. *
  83886. * @returns true if successful.
  83887. */
  83888. attach(): boolean;
  83889. /**
  83890. * detach this feature.
  83891. * Will usually be called by the features manager
  83892. *
  83893. * @returns true if successful.
  83894. */
  83895. detach(): boolean;
  83896. /**
  83897. * Dispose this feature and all of the resources attached
  83898. */
  83899. dispose(): void;
  83900. protected _onXRFrame(frame: XRFrame): void;
  83901. private _onHitTestResults;
  83902. private _onSelect;
  83903. }
  83904. }
  83905. declare module "babylonjs/XR/features/WebXRHitTest" {
  83906. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83907. import { Observable } from "babylonjs/Misc/observable";
  83908. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83909. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83910. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  83911. /**
  83912. * Options used for hit testing (version 2)
  83913. */
  83914. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  83915. /**
  83916. * Do not create a permanent hit test. Will usually be used when only
  83917. * transient inputs are needed.
  83918. */
  83919. disablePermanentHitTest?: boolean;
  83920. /**
  83921. * Enable transient (for example touch-based) hit test inspections
  83922. */
  83923. enableTransientHitTest?: boolean;
  83924. /**
  83925. * Offset ray for the permanent hit test
  83926. */
  83927. offsetRay?: Vector3;
  83928. /**
  83929. * Offset ray for the transient hit test
  83930. */
  83931. transientOffsetRay?: Vector3;
  83932. /**
  83933. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  83934. */
  83935. useReferenceSpace?: boolean;
  83936. /**
  83937. * Override the default entity type(s) of the hit-test result
  83938. */
  83939. entityTypes?: XRHitTestTrackableType[];
  83940. }
  83941. /**
  83942. * Interface defining the babylon result of hit-test
  83943. */
  83944. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  83945. /**
  83946. * The input source that generated this hit test (if transient)
  83947. */
  83948. inputSource?: XRInputSource;
  83949. /**
  83950. * Is this a transient hit test
  83951. */
  83952. isTransient?: boolean;
  83953. /**
  83954. * Position of the hit test result
  83955. */
  83956. position: Vector3;
  83957. /**
  83958. * Rotation of the hit test result
  83959. */
  83960. rotationQuaternion: Quaternion;
  83961. /**
  83962. * The native hit test result
  83963. */
  83964. xrHitResult: XRHitTestResult;
  83965. }
  83966. /**
  83967. * The currently-working hit-test module.
  83968. * Hit test (or Ray-casting) is used to interact with the real world.
  83969. * For further information read here - https://github.com/immersive-web/hit-test
  83970. *
  83971. * Tested on chrome (mobile) 80.
  83972. */
  83973. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  83974. /**
  83975. * options to use when constructing this feature
  83976. */
  83977. readonly options: IWebXRHitTestOptions;
  83978. private _tmpMat;
  83979. private _tmpPos;
  83980. private _tmpQuat;
  83981. private _transientXrHitTestSource;
  83982. private _xrHitTestSource;
  83983. private initHitTestSource;
  83984. /**
  83985. * The module's name
  83986. */
  83987. static readonly Name: string;
  83988. /**
  83989. * The (Babylon) version of this module.
  83990. * This is an integer representing the implementation version.
  83991. * This number does not correspond to the WebXR specs version
  83992. */
  83993. static readonly Version: number;
  83994. /**
  83995. * When set to true, each hit test will have its own position/rotation objects
  83996. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  83997. * the developers will clone them or copy them as they see fit.
  83998. */
  83999. autoCloneTransformation: boolean;
  84000. /**
  84001. * Triggered when new babylon (transformed) hit test results are available
  84002. * Note - this will be called when results come back from the device. It can be an empty array!!
  84003. */
  84004. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  84005. /**
  84006. * Use this to temporarily pause hit test checks.
  84007. */
  84008. paused: boolean;
  84009. /**
  84010. * Creates a new instance of the hit test feature
  84011. * @param _xrSessionManager an instance of WebXRSessionManager
  84012. * @param options options to use when constructing this feature
  84013. */
  84014. constructor(_xrSessionManager: WebXRSessionManager,
  84015. /**
  84016. * options to use when constructing this feature
  84017. */
  84018. options?: IWebXRHitTestOptions);
  84019. /**
  84020. * attach this feature
  84021. * Will usually be called by the features manager
  84022. *
  84023. * @returns true if successful.
  84024. */
  84025. attach(): boolean;
  84026. /**
  84027. * detach this feature.
  84028. * Will usually be called by the features manager
  84029. *
  84030. * @returns true if successful.
  84031. */
  84032. detach(): boolean;
  84033. /**
  84034. * Dispose this feature and all of the resources attached
  84035. */
  84036. dispose(): void;
  84037. protected _onXRFrame(frame: XRFrame): void;
  84038. private _processWebXRHitTestResult;
  84039. }
  84040. }
  84041. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  84042. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84043. import { Observable } from "babylonjs/Misc/observable";
  84044. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  84045. import { TransformNode } from "babylonjs/Meshes/transformNode";
  84046. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84047. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  84048. /**
  84049. * Configuration options of the anchor system
  84050. */
  84051. export interface IWebXRAnchorSystemOptions {
  84052. /**
  84053. * a node that will be used to convert local to world coordinates
  84054. */
  84055. worldParentNode?: TransformNode;
  84056. /**
  84057. * If set to true a reference of the created anchors will be kept until the next session starts
  84058. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  84059. */
  84060. doNotRemoveAnchorsOnSessionEnded?: boolean;
  84061. }
  84062. /**
  84063. * A babylon container for an XR Anchor
  84064. */
  84065. export interface IWebXRAnchor {
  84066. /**
  84067. * A babylon-assigned ID for this anchor
  84068. */
  84069. id: number;
  84070. /**
  84071. * Transformation matrix to apply to an object attached to this anchor
  84072. */
  84073. transformationMatrix: Matrix;
  84074. /**
  84075. * The native anchor object
  84076. */
  84077. xrAnchor: XRAnchor;
  84078. /**
  84079. * if defined, this object will be constantly updated by the anchor's position and rotation
  84080. */
  84081. attachedNode?: TransformNode;
  84082. /**
  84083. * Remove this anchor from the scene
  84084. */
  84085. remove(): void;
  84086. }
  84087. /**
  84088. * An implementation of the anchor system for WebXR.
  84089. * For further information see https://github.com/immersive-web/anchors/
  84090. */
  84091. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  84092. private _options;
  84093. private _lastFrameDetected;
  84094. private _trackedAnchors;
  84095. private _referenceSpaceForFrameAnchors;
  84096. private _futureAnchors;
  84097. /**
  84098. * The module's name
  84099. */
  84100. static readonly Name: string;
  84101. /**
  84102. * The (Babylon) version of this module.
  84103. * This is an integer representing the implementation version.
  84104. * This number does not correspond to the WebXR specs version
  84105. */
  84106. static readonly Version: number;
  84107. /**
  84108. * Observers registered here will be executed when a new anchor was added to the session
  84109. */
  84110. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  84111. /**
  84112. * Observers registered here will be executed when an anchor was removed from the session
  84113. */
  84114. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  84115. /**
  84116. * Observers registered here will be executed when an existing anchor updates
  84117. * This can execute N times every frame
  84118. */
  84119. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  84120. /**
  84121. * Set the reference space to use for anchor creation, when not using a hit test.
  84122. * Will default to the session's reference space if not defined
  84123. */
  84124. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  84125. /**
  84126. * constructs a new anchor system
  84127. * @param _xrSessionManager an instance of WebXRSessionManager
  84128. * @param _options configuration object for this feature
  84129. */
  84130. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  84131. private _tmpVector;
  84132. private _tmpQuaternion;
  84133. private _populateTmpTransformation;
  84134. /**
  84135. * Create a new anchor point using a hit test result at a specific point in the scene
  84136. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  84137. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  84138. *
  84139. * @param hitTestResult The hit test result to use for this anchor creation
  84140. * @param position an optional position offset for this anchor
  84141. * @param rotationQuaternion an optional rotation offset for this anchor
  84142. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  84143. */
  84144. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  84145. /**
  84146. * Add a new anchor at a specific position and rotation
  84147. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  84148. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  84149. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  84150. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  84151. *
  84152. * @param position the position in which to add an anchor
  84153. * @param rotationQuaternion an optional rotation for the anchor transformation
  84154. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  84155. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  84156. */
  84157. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  84158. /**
  84159. * Get the list of anchors currently being tracked by the system
  84160. */
  84161. get anchors(): IWebXRAnchor[];
  84162. /**
  84163. * detach this feature.
  84164. * Will usually be called by the features manager
  84165. *
  84166. * @returns true if successful.
  84167. */
  84168. detach(): boolean;
  84169. /**
  84170. * Dispose this feature and all of the resources attached
  84171. */
  84172. dispose(): void;
  84173. protected _onXRFrame(frame: XRFrame): void;
  84174. /**
  84175. * avoiding using Array.find for global support.
  84176. * @param xrAnchor the plane to find in the array
  84177. */
  84178. private _findIndexInAnchorArray;
  84179. private _updateAnchorWithXRFrame;
  84180. private _createAnchorAtTransformation;
  84181. }
  84182. }
  84183. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  84184. import { TransformNode } from "babylonjs/Meshes/transformNode";
  84185. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84186. import { Observable } from "babylonjs/Misc/observable";
  84187. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  84188. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84189. /**
  84190. * Options used in the plane detector module
  84191. */
  84192. export interface IWebXRPlaneDetectorOptions {
  84193. /**
  84194. * The node to use to transform the local results to world coordinates
  84195. */
  84196. worldParentNode?: TransformNode;
  84197. /**
  84198. * If set to true a reference of the created planes will be kept until the next session starts
  84199. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  84200. */
  84201. doNotRemovePlanesOnSessionEnded?: boolean;
  84202. /**
  84203. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  84204. */
  84205. preferredDetectorOptions?: XRGeometryDetectorOptions;
  84206. }
  84207. /**
  84208. * A babylon interface for a WebXR plane.
  84209. * A Plane is actually a polygon, built from N points in space
  84210. *
  84211. * Supported in chrome 79, not supported in canary 81 ATM
  84212. */
  84213. export interface IWebXRPlane {
  84214. /**
  84215. * a babylon-assigned ID for this polygon
  84216. */
  84217. id: number;
  84218. /**
  84219. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  84220. */
  84221. polygonDefinition: Array<Vector3>;
  84222. /**
  84223. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  84224. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  84225. */
  84226. transformationMatrix: Matrix;
  84227. /**
  84228. * the native xr-plane object
  84229. */
  84230. xrPlane: XRPlane;
  84231. }
  84232. /**
  84233. * The plane detector is used to detect planes in the real world when in AR
  84234. * For more information see https://github.com/immersive-web/real-world-geometry/
  84235. */
  84236. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  84237. private _options;
  84238. private _detectedPlanes;
  84239. private _enabled;
  84240. private _lastFrameDetected;
  84241. /**
  84242. * The module's name
  84243. */
  84244. static readonly Name: string;
  84245. /**
  84246. * The (Babylon) version of this module.
  84247. * This is an integer representing the implementation version.
  84248. * This number does not correspond to the WebXR specs version
  84249. */
  84250. static readonly Version: number;
  84251. /**
  84252. * Observers registered here will be executed when a new plane was added to the session
  84253. */
  84254. onPlaneAddedObservable: Observable<IWebXRPlane>;
  84255. /**
  84256. * Observers registered here will be executed when a plane is no longer detected in the session
  84257. */
  84258. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  84259. /**
  84260. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  84261. * This can execute N times every frame
  84262. */
  84263. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  84264. /**
  84265. * construct a new Plane Detector
  84266. * @param _xrSessionManager an instance of xr Session manager
  84267. * @param _options configuration to use when constructing this feature
  84268. */
  84269. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  84270. /**
  84271. * detach this feature.
  84272. * Will usually be called by the features manager
  84273. *
  84274. * @returns true if successful.
  84275. */
  84276. detach(): boolean;
  84277. /**
  84278. * Dispose this feature and all of the resources attached
  84279. */
  84280. dispose(): void;
  84281. /**
  84282. * Check if the needed objects are defined.
  84283. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  84284. */
  84285. isCompatible(): boolean;
  84286. protected _onXRFrame(frame: XRFrame): void;
  84287. private _init;
  84288. private _updatePlaneWithXRPlane;
  84289. /**
  84290. * avoiding using Array.find for global support.
  84291. * @param xrPlane the plane to find in the array
  84292. */
  84293. private _findIndexInPlaneArray;
  84294. }
  84295. }
  84296. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  84297. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84299. import { Observable } from "babylonjs/Misc/observable";
  84300. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84301. /**
  84302. * Options interface for the background remover plugin
  84303. */
  84304. export interface IWebXRBackgroundRemoverOptions {
  84305. /**
  84306. * Further background meshes to disable when entering AR
  84307. */
  84308. backgroundMeshes?: AbstractMesh[];
  84309. /**
  84310. * flags to configure the removal of the environment helper.
  84311. * If not set, the entire background will be removed. If set, flags should be set as well.
  84312. */
  84313. environmentHelperRemovalFlags?: {
  84314. /**
  84315. * Should the skybox be removed (default false)
  84316. */
  84317. skyBox?: boolean;
  84318. /**
  84319. * Should the ground be removed (default false)
  84320. */
  84321. ground?: boolean;
  84322. };
  84323. /**
  84324. * don't disable the environment helper
  84325. */
  84326. ignoreEnvironmentHelper?: boolean;
  84327. }
  84328. /**
  84329. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  84330. */
  84331. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  84332. /**
  84333. * read-only options to be used in this module
  84334. */
  84335. readonly options: IWebXRBackgroundRemoverOptions;
  84336. /**
  84337. * The module's name
  84338. */
  84339. static readonly Name: string;
  84340. /**
  84341. * The (Babylon) version of this module.
  84342. * This is an integer representing the implementation version.
  84343. * This number does not correspond to the WebXR specs version
  84344. */
  84345. static readonly Version: number;
  84346. /**
  84347. * registered observers will be triggered when the background state changes
  84348. */
  84349. onBackgroundStateChangedObservable: Observable<boolean>;
  84350. /**
  84351. * constructs a new background remover module
  84352. * @param _xrSessionManager the session manager for this module
  84353. * @param options read-only options to be used in this module
  84354. */
  84355. constructor(_xrSessionManager: WebXRSessionManager,
  84356. /**
  84357. * read-only options to be used in this module
  84358. */
  84359. options?: IWebXRBackgroundRemoverOptions);
  84360. /**
  84361. * attach this feature
  84362. * Will usually be called by the features manager
  84363. *
  84364. * @returns true if successful.
  84365. */
  84366. attach(): boolean;
  84367. /**
  84368. * detach this feature.
  84369. * Will usually be called by the features manager
  84370. *
  84371. * @returns true if successful.
  84372. */
  84373. detach(): boolean;
  84374. /**
  84375. * Dispose this feature and all of the resources attached
  84376. */
  84377. dispose(): void;
  84378. protected _onXRFrame(_xrFrame: XRFrame): void;
  84379. private _setBackgroundState;
  84380. }
  84381. }
  84382. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  84383. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84384. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  84385. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  84386. import { WebXRInput } from "babylonjs/XR/webXRInput";
  84387. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84388. import { Nullable } from "babylonjs/types";
  84389. /**
  84390. * Options for the controller physics feature
  84391. */
  84392. export class IWebXRControllerPhysicsOptions {
  84393. /**
  84394. * Should the headset get its own impostor
  84395. */
  84396. enableHeadsetImpostor?: boolean;
  84397. /**
  84398. * Optional parameters for the headset impostor
  84399. */
  84400. headsetImpostorParams?: {
  84401. /**
  84402. * The type of impostor to create. Default is sphere
  84403. */
  84404. impostorType: number;
  84405. /**
  84406. * the size of the impostor. Defaults to 10cm
  84407. */
  84408. impostorSize?: number | {
  84409. width: number;
  84410. height: number;
  84411. depth: number;
  84412. };
  84413. /**
  84414. * Friction definitions
  84415. */
  84416. friction?: number;
  84417. /**
  84418. * Restitution
  84419. */
  84420. restitution?: number;
  84421. };
  84422. /**
  84423. * The physics properties of the future impostors
  84424. */
  84425. physicsProperties?: {
  84426. /**
  84427. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  84428. * Note that this requires a physics engine that supports mesh impostors!
  84429. */
  84430. useControllerMesh?: boolean;
  84431. /**
  84432. * The type of impostor to create. Default is sphere
  84433. */
  84434. impostorType?: number;
  84435. /**
  84436. * the size of the impostor. Defaults to 10cm
  84437. */
  84438. impostorSize?: number | {
  84439. width: number;
  84440. height: number;
  84441. depth: number;
  84442. };
  84443. /**
  84444. * Friction definitions
  84445. */
  84446. friction?: number;
  84447. /**
  84448. * Restitution
  84449. */
  84450. restitution?: number;
  84451. };
  84452. /**
  84453. * the xr input to use with this pointer selection
  84454. */
  84455. xrInput: WebXRInput;
  84456. }
  84457. /**
  84458. * Add physics impostor to your webxr controllers,
  84459. * including naive calculation of their linear and angular velocity
  84460. */
  84461. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  84462. private readonly _options;
  84463. private _attachController;
  84464. private _controllers;
  84465. private _debugMode;
  84466. private _delta;
  84467. private _headsetImpostor?;
  84468. private _headsetMesh?;
  84469. private _lastTimestamp;
  84470. private _tmpQuaternion;
  84471. private _tmpVector;
  84472. /**
  84473. * The module's name
  84474. */
  84475. static readonly Name: string;
  84476. /**
  84477. * The (Babylon) version of this module.
  84478. * This is an integer representing the implementation version.
  84479. * This number does not correspond to the webxr specs version
  84480. */
  84481. static readonly Version: number;
  84482. /**
  84483. * Construct a new Controller Physics Feature
  84484. * @param _xrSessionManager the corresponding xr session manager
  84485. * @param _options options to create this feature with
  84486. */
  84487. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  84488. /**
  84489. * @hidden
  84490. * enable debugging - will show console outputs and the impostor mesh
  84491. */
  84492. _enablePhysicsDebug(): void;
  84493. /**
  84494. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  84495. * @param xrController the controller to add
  84496. */
  84497. addController(xrController: WebXRInputSource): void;
  84498. /**
  84499. * attach this feature
  84500. * Will usually be called by the features manager
  84501. *
  84502. * @returns true if successful.
  84503. */
  84504. attach(): boolean;
  84505. /**
  84506. * detach this feature.
  84507. * Will usually be called by the features manager
  84508. *
  84509. * @returns true if successful.
  84510. */
  84511. detach(): boolean;
  84512. /**
  84513. * Get the headset impostor, if enabled
  84514. * @returns the impostor
  84515. */
  84516. getHeadsetImpostor(): PhysicsImpostor | undefined;
  84517. /**
  84518. * Get the physics impostor of a specific controller.
  84519. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  84520. * @param controller the controller or the controller id of which to get the impostor
  84521. * @returns the impostor or null
  84522. */
  84523. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  84524. /**
  84525. * Update the physics properties provided in the constructor
  84526. * @param newProperties the new properties object
  84527. */
  84528. setPhysicsProperties(newProperties: {
  84529. impostorType?: number;
  84530. impostorSize?: number | {
  84531. width: number;
  84532. height: number;
  84533. depth: number;
  84534. };
  84535. friction?: number;
  84536. restitution?: number;
  84537. }): void;
  84538. protected _onXRFrame(_xrFrame: any): void;
  84539. private _detachController;
  84540. }
  84541. }
  84542. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  84543. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84544. import { Observable } from "babylonjs/Misc/observable";
  84545. import { Vector3 } from "babylonjs/Maths/math.vector";
  84546. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84547. /**
  84548. * A babylon interface for a "WebXR" feature point.
  84549. * Represents the position and confidence value of a given feature point.
  84550. */
  84551. export interface IWebXRFeaturePoint {
  84552. /**
  84553. * Represents the position of the feature point in world space.
  84554. */
  84555. position: Vector3;
  84556. /**
  84557. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  84558. */
  84559. confidenceValue: number;
  84560. }
  84561. /**
  84562. * The feature point system is used to detect feature points from real world geometry.
  84563. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  84564. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  84565. */
  84566. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  84567. private _enabled;
  84568. private _featurePointCloud;
  84569. /**
  84570. * The module's name
  84571. */
  84572. static readonly Name: string;
  84573. /**
  84574. * The (Babylon) version of this module.
  84575. * This is an integer representing the implementation version.
  84576. * This number does not correspond to the WebXR specs version
  84577. */
  84578. static readonly Version: number;
  84579. /**
  84580. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  84581. * Will notify the observers about which feature points have been added.
  84582. */
  84583. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  84584. /**
  84585. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  84586. * Will notify the observers about which feature points have been updated.
  84587. */
  84588. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  84589. /**
  84590. * The current feature point cloud maintained across frames.
  84591. */
  84592. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  84593. /**
  84594. * construct the feature point system
  84595. * @param _xrSessionManager an instance of xr Session manager
  84596. */
  84597. constructor(_xrSessionManager: WebXRSessionManager);
  84598. /**
  84599. * Detach this feature.
  84600. * Will usually be called by the features manager
  84601. *
  84602. * @returns true if successful.
  84603. */
  84604. detach(): boolean;
  84605. /**
  84606. * Dispose this feature and all of the resources attached
  84607. */
  84608. dispose(): void;
  84609. /**
  84610. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  84611. */
  84612. protected _onXRFrame(frame: XRFrame): void;
  84613. /**
  84614. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  84615. */
  84616. private _init;
  84617. }
  84618. }
  84619. declare module "babylonjs/XR/features/WebXRHandTracking" {
  84620. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84621. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84623. import { Mesh } from "babylonjs/Meshes/mesh";
  84624. import { WebXRInput } from "babylonjs/XR/webXRInput";
  84625. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  84626. import { Nullable } from "babylonjs/types";
  84627. import { IDisposable } from "babylonjs/scene";
  84628. import { Observable } from "babylonjs/Misc/observable";
  84629. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  84630. /**
  84631. * Configuration interface for the hand tracking feature
  84632. */
  84633. export interface IWebXRHandTrackingOptions {
  84634. /**
  84635. * The xrInput that will be used as source for new hands
  84636. */
  84637. xrInput: WebXRInput;
  84638. /**
  84639. * Configuration object for the joint meshes
  84640. */
  84641. jointMeshes?: {
  84642. /**
  84643. * Should the meshes created be invisible (defaults to false)
  84644. */
  84645. invisible?: boolean;
  84646. /**
  84647. * A source mesh to be used to create instances. Defaults to a sphere.
  84648. * This mesh will be the source for all other (25) meshes.
  84649. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  84650. */
  84651. sourceMesh?: Mesh;
  84652. /**
  84653. * This function will be called after a mesh was created for a specific joint.
  84654. * Using this function you can either manipulate the instance or return a new mesh.
  84655. * When returning a new mesh the instance created before will be disposed
  84656. */
  84657. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  84658. /**
  84659. * Should the source mesh stay visible. Defaults to false
  84660. */
  84661. keepOriginalVisible?: boolean;
  84662. /**
  84663. * Scale factor for all instances (defaults to 2)
  84664. */
  84665. scaleFactor?: number;
  84666. /**
  84667. * Should each instance have its own physics impostor
  84668. */
  84669. enablePhysics?: boolean;
  84670. /**
  84671. * If enabled, override default physics properties
  84672. */
  84673. physicsProps?: {
  84674. friction?: number;
  84675. restitution?: number;
  84676. impostorType?: number;
  84677. };
  84678. /**
  84679. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  84680. */
  84681. disableDefaultHandMesh?: boolean;
  84682. /**
  84683. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  84684. */
  84685. handMeshes?: {
  84686. right: AbstractMesh;
  84687. left: AbstractMesh;
  84688. };
  84689. /**
  84690. * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.
  84691. */
  84692. leftHandedSystemMeshes?: boolean;
  84693. /**
  84694. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  84695. */
  84696. rigMapping?: {
  84697. right: string[];
  84698. left: string[];
  84699. };
  84700. };
  84701. }
  84702. /**
  84703. * Parts of the hands divided to writs and finger names
  84704. */
  84705. export const enum HandPart {
  84706. /**
  84707. * HandPart - Wrist
  84708. */
  84709. WRIST = "wrist",
  84710. /**
  84711. * HandPart - The Thumb
  84712. */
  84713. THUMB = "thumb",
  84714. /**
  84715. * HandPart - Index finger
  84716. */
  84717. INDEX = "index",
  84718. /**
  84719. * HandPart - Middle finger
  84720. */
  84721. MIDDLE = "middle",
  84722. /**
  84723. * HandPart - Ring finger
  84724. */
  84725. RING = "ring",
  84726. /**
  84727. * HandPart - Little finger
  84728. */
  84729. LITTLE = "little"
  84730. }
  84731. /**
  84732. * Representing a single hand (with its corresponding native XRHand object)
  84733. */
  84734. export class WebXRHand implements IDisposable {
  84735. /** the controller to which the hand correlates */
  84736. readonly xrController: WebXRInputSource;
  84737. /** the meshes to be used to track the hand joints */
  84738. readonly trackedMeshes: AbstractMesh[];
  84739. private _handMesh?;
  84740. private _rigMapping?;
  84741. private _leftHandedMeshes?;
  84742. private _scene;
  84743. private _defaultHandMesh;
  84744. private _transformNodeMapping;
  84745. private _boneMapping;
  84746. private _useBones;
  84747. /**
  84748. * Hand-parts definition (key is HandPart)
  84749. */
  84750. handPartsDefinition: {
  84751. [key: string]: number[];
  84752. };
  84753. /**
  84754. * Observers will be triggered when the mesh for this hand was initialized.
  84755. */
  84756. onHandMeshReadyObservable: Observable<WebXRHand>;
  84757. /**
  84758. * Populate the HandPartsDefinition object.
  84759. * This is called as a side effect since certain browsers don't have XRHand defined.
  84760. */
  84761. private generateHandPartsDefinition;
  84762. /**
  84763. * Construct a new hand object
  84764. * @param xrController the controller to which the hand correlates
  84765. * @param trackedMeshes the meshes to be used to track the hand joints
  84766. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  84767. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  84768. * @param disableDefaultHandMesh should the default mesh creation be disabled
  84769. * @param _leftHandedMeshes are the hand meshes left-handed-system meshes
  84770. */
  84771. constructor(
  84772. /** the controller to which the hand correlates */
  84773. xrController: WebXRInputSource,
  84774. /** the meshes to be used to track the hand joints */
  84775. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean, _leftHandedMeshes?: boolean | undefined);
  84776. /**
  84777. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  84778. */
  84779. get handMesh(): AbstractMesh | undefined;
  84780. /**
  84781. * Update this hand from the latest xr frame
  84782. * @param xrFrame xrFrame to update from
  84783. * @param referenceSpace The current viewer reference space
  84784. * @param scaleFactor optional scale factor for the meshes
  84785. */
  84786. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  84787. /**
  84788. * Get meshes of part of the hand
  84789. * @param part the part of hand to get
  84790. * @returns An array of meshes that correlate to the hand part requested
  84791. */
  84792. getHandPartMeshes(part: HandPart): AbstractMesh[];
  84793. /**
  84794. * Dispose this Hand object
  84795. */
  84796. dispose(): void;
  84797. private _generateDefaultHandMesh;
  84798. }
  84799. /**
  84800. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  84801. */
  84802. export class WebXRHandTracking extends WebXRAbstractFeature {
  84803. /**
  84804. * options to use when constructing this feature
  84805. */
  84806. readonly options: IWebXRHandTrackingOptions;
  84807. private static _idCounter;
  84808. /**
  84809. * The module's name
  84810. */
  84811. static readonly Name: string;
  84812. /**
  84813. * The (Babylon) version of this module.
  84814. * This is an integer representing the implementation version.
  84815. * This number does not correspond to the WebXR specs version
  84816. */
  84817. static readonly Version: number;
  84818. /**
  84819. * This observable will notify registered observers when a new hand object was added and initialized
  84820. */
  84821. onHandAddedObservable: Observable<WebXRHand>;
  84822. /**
  84823. * This observable will notify its observers right before the hand object is disposed
  84824. */
  84825. onHandRemovedObservable: Observable<WebXRHand>;
  84826. private _hands;
  84827. /**
  84828. * Creates a new instance of the hit test feature
  84829. * @param _xrSessionManager an instance of WebXRSessionManager
  84830. * @param options options to use when constructing this feature
  84831. */
  84832. constructor(_xrSessionManager: WebXRSessionManager,
  84833. /**
  84834. * options to use when constructing this feature
  84835. */
  84836. options: IWebXRHandTrackingOptions);
  84837. /**
  84838. * Check if the needed objects are defined.
  84839. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  84840. */
  84841. isCompatible(): boolean;
  84842. /**
  84843. * attach this feature
  84844. * Will usually be called by the features manager
  84845. *
  84846. * @returns true if successful.
  84847. */
  84848. attach(): boolean;
  84849. /**
  84850. * detach this feature.
  84851. * Will usually be called by the features manager
  84852. *
  84853. * @returns true if successful.
  84854. */
  84855. detach(): boolean;
  84856. /**
  84857. * Dispose this feature and all of the resources attached
  84858. */
  84859. dispose(): void;
  84860. /**
  84861. * Get the hand object according to the controller id
  84862. * @param controllerId the controller id to which we want to get the hand
  84863. * @returns null if not found or the WebXRHand object if found
  84864. */
  84865. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  84866. /**
  84867. * Get a hand object according to the requested handedness
  84868. * @param handedness the handedness to request
  84869. * @returns null if not found or the WebXRHand object if found
  84870. */
  84871. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  84872. protected _onXRFrame(_xrFrame: XRFrame): void;
  84873. private _attachHand;
  84874. private _detachHand;
  84875. }
  84876. }
  84877. declare module "babylonjs/XR/features/WebXRMeshDetector" {
  84878. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84879. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84880. import { TransformNode } from "babylonjs/Meshes/transformNode";
  84881. import { Matrix } from "babylonjs/Maths/math";
  84882. import { Observable } from "babylonjs/Misc/observable";
  84883. /**
  84884. * Options used in the mesh detector module
  84885. */
  84886. export interface IWebXRMeshDetectorOptions {
  84887. /**
  84888. * The node to use to transform the local results to world coordinates
  84889. */
  84890. worldParentNode?: TransformNode;
  84891. /**
  84892. * If set to true a reference of the created meshes will be kept until the next session starts
  84893. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  84894. */
  84895. doNotRemoveMeshesOnSessionEnded?: boolean;
  84896. /**
  84897. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  84898. */
  84899. preferredDetectorOptions?: XRGeometryDetectorOptions;
  84900. /**
  84901. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  84902. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  84903. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  84904. */
  84905. convertCoordinateSystems?: boolean;
  84906. }
  84907. /**
  84908. * A babylon interface for a XR mesh's vertex data.
  84909. *
  84910. * Currently not supported by WebXR, available only with BabylonNative
  84911. */
  84912. export interface IWebXRVertexData {
  84913. /**
  84914. * A babylon-assigned ID for this mesh
  84915. */
  84916. id: number;
  84917. /**
  84918. * Data required for constructing a mesh in Babylon.js.
  84919. */
  84920. xrMesh: XRMesh;
  84921. /**
  84922. * The node to use to transform the local results to world coordinates.
  84923. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  84924. */
  84925. worldParentNode?: TransformNode;
  84926. /**
  84927. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  84928. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84929. */
  84930. positions?: Float32Array;
  84931. /**
  84932. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  84933. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84934. */
  84935. indices?: Uint32Array;
  84936. /**
  84937. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  84938. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  84939. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  84940. */
  84941. normals?: Float32Array;
  84942. /**
  84943. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  84944. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  84945. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84946. */
  84947. transformationMatrix?: Matrix;
  84948. }
  84949. /**
  84950. * The mesh detector is used to detect meshes in the real world when in AR
  84951. */
  84952. export class WebXRMeshDetector extends WebXRAbstractFeature {
  84953. private _options;
  84954. private _detectedMeshes;
  84955. /**
  84956. * The module's name
  84957. */
  84958. static readonly Name: string;
  84959. /**
  84960. * The (Babylon) version of this module.
  84961. * This is an integer representing the implementation version.
  84962. * This number does not correspond to the WebXR specs version
  84963. */
  84964. static readonly Version: number;
  84965. /**
  84966. * Observers registered here will be executed when a new mesh was added to the session
  84967. */
  84968. onMeshAddedObservable: Observable<IWebXRVertexData>;
  84969. /**
  84970. * Observers registered here will be executed when a mesh is no longer detected in the session
  84971. */
  84972. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  84973. /**
  84974. * Observers registered here will be executed when an existing mesh updates
  84975. */
  84976. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  84977. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  84978. detach(): boolean;
  84979. dispose(): void;
  84980. protected _onXRFrame(frame: XRFrame): void;
  84981. private _init;
  84982. private _updateVertexDataWithXRMesh;
  84983. }
  84984. }
  84985. declare module "babylonjs/XR/features/WebXRImageTracking" {
  84986. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84987. import { Observable } from "babylonjs/Misc/observable";
  84988. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84989. import { Matrix } from "babylonjs/Maths/math.vector";
  84990. import { Nullable } from "babylonjs/types";
  84991. /**
  84992. * Options interface for the background remover plugin
  84993. */
  84994. export interface IWebXRImageTrackingOptions {
  84995. /**
  84996. * A required array with images to track
  84997. */
  84998. images: {
  84999. /**
  85000. * The source of the image. can be a URL or an image bitmap
  85001. */
  85002. src: string | ImageBitmap;
  85003. /**
  85004. * The estimated width in the real world (in meters)
  85005. */
  85006. estimatedRealWorldWidth: number;
  85007. }[];
  85008. }
  85009. /**
  85010. * An object representing an image tracked by the system
  85011. */
  85012. export interface IWebXRTrackedImage {
  85013. /**
  85014. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  85015. */
  85016. id: number;
  85017. /**
  85018. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  85019. */
  85020. emulated?: boolean;
  85021. /**
  85022. * Just in case it is needed - the image bitmap that is being tracked
  85023. */
  85024. originalBitmap: ImageBitmap;
  85025. /**
  85026. * The native XR result image tracking result, untouched
  85027. */
  85028. xrTrackingResult?: XRImageTrackingResult;
  85029. /**
  85030. * Width in real world (meters)
  85031. */
  85032. realWorldWidth?: number;
  85033. /**
  85034. * A transformation matrix of this current image in the current reference space.
  85035. */
  85036. transformationMatrix: Matrix;
  85037. /**
  85038. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  85039. */
  85040. ratio?: number;
  85041. }
  85042. /**
  85043. * Image tracking for immersive AR sessions.
  85044. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  85045. */
  85046. export class WebXRImageTracking extends WebXRAbstractFeature {
  85047. /**
  85048. * read-only options to be used in this module
  85049. */
  85050. readonly options: IWebXRImageTrackingOptions;
  85051. /**
  85052. * The module's name
  85053. */
  85054. static readonly Name: string;
  85055. /**
  85056. * The (Babylon) version of this module.
  85057. * This is an integer representing the implementation version.
  85058. * This number does not correspond to the WebXR specs version
  85059. */
  85060. static readonly Version: number;
  85061. /**
  85062. * This will be triggered if the underlying system deems an image untrackable.
  85063. * The index is the index of the image from the array used to initialize the feature.
  85064. */
  85065. onUntrackableImageFoundObservable: Observable<number>;
  85066. /**
  85067. * An image was deemed trackable, and the system will start tracking it.
  85068. */
  85069. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  85070. /**
  85071. * The image was found and its state was updated.
  85072. */
  85073. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  85074. private _trackedImages;
  85075. private _originalTrackingRequest;
  85076. /**
  85077. * constructs the image tracking feature
  85078. * @param _xrSessionManager the session manager for this module
  85079. * @param options read-only options to be used in this module
  85080. */
  85081. constructor(_xrSessionManager: WebXRSessionManager,
  85082. /**
  85083. * read-only options to be used in this module
  85084. */
  85085. options: IWebXRImageTrackingOptions);
  85086. /**
  85087. * attach this feature
  85088. * Will usually be called by the features manager
  85089. *
  85090. * @returns true if successful.
  85091. */
  85092. attach(): boolean;
  85093. /**
  85094. * detach this feature.
  85095. * Will usually be called by the features manager
  85096. *
  85097. * @returns true if successful.
  85098. */
  85099. detach(): boolean;
  85100. /**
  85101. * Check if the needed objects are defined.
  85102. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  85103. */
  85104. isCompatible(): boolean;
  85105. /**
  85106. * Get a tracked image by its ID.
  85107. *
  85108. * @param id the id of the image to load (position in the init array)
  85109. * @returns a trackable image, if exists in this location
  85110. */
  85111. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  85112. /**
  85113. * Dispose this feature and all of the resources attached
  85114. */
  85115. dispose(): void;
  85116. /**
  85117. * Extends the session init object if needed
  85118. * @returns augmentation object fo the xr session init object.
  85119. */
  85120. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  85121. protected _onXRFrame(_xrFrame: XRFrame): void;
  85122. private _init;
  85123. }
  85124. }
  85125. declare module "babylonjs/XR/features/index" {
  85126. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  85127. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  85128. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  85129. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  85130. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  85131. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  85132. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  85133. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  85134. export * from "babylonjs/XR/features/WebXRHitTest";
  85135. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  85136. export * from "babylonjs/XR/features/WebXRHandTracking";
  85137. export * from "babylonjs/XR/features/WebXRMeshDetector";
  85138. export * from "babylonjs/XR/features/WebXRImageTracking";
  85139. }
  85140. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  85141. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  85142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  85143. import { Scene } from "babylonjs/scene";
  85144. /**
  85145. * The motion controller class for all microsoft mixed reality controllers
  85146. */
  85147. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  85148. protected readonly _mapping: {
  85149. defaultButton: {
  85150. valueNodeName: string;
  85151. unpressedNodeName: string;
  85152. pressedNodeName: string;
  85153. };
  85154. defaultAxis: {
  85155. valueNodeName: string;
  85156. minNodeName: string;
  85157. maxNodeName: string;
  85158. };
  85159. buttons: {
  85160. "xr-standard-trigger": {
  85161. rootNodeName: string;
  85162. componentProperty: string;
  85163. states: string[];
  85164. };
  85165. "xr-standard-squeeze": {
  85166. rootNodeName: string;
  85167. componentProperty: string;
  85168. states: string[];
  85169. };
  85170. "xr-standard-touchpad": {
  85171. rootNodeName: string;
  85172. labelAnchorNodeName: string;
  85173. touchPointNodeName: string;
  85174. };
  85175. "xr-standard-thumbstick": {
  85176. rootNodeName: string;
  85177. componentProperty: string;
  85178. states: string[];
  85179. };
  85180. };
  85181. axes: {
  85182. "xr-standard-touchpad": {
  85183. "x-axis": {
  85184. rootNodeName: string;
  85185. };
  85186. "y-axis": {
  85187. rootNodeName: string;
  85188. };
  85189. };
  85190. "xr-standard-thumbstick": {
  85191. "x-axis": {
  85192. rootNodeName: string;
  85193. };
  85194. "y-axis": {
  85195. rootNodeName: string;
  85196. };
  85197. };
  85198. };
  85199. };
  85200. /**
  85201. * The base url used to load the left and right controller models
  85202. */
  85203. static MODEL_BASE_URL: string;
  85204. /**
  85205. * The name of the left controller model file
  85206. */
  85207. static MODEL_LEFT_FILENAME: string;
  85208. /**
  85209. * The name of the right controller model file
  85210. */
  85211. static MODEL_RIGHT_FILENAME: string;
  85212. profileId: string;
  85213. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  85214. protected _getFilenameAndPath(): {
  85215. filename: string;
  85216. path: string;
  85217. };
  85218. protected _getModelLoadingConstraints(): boolean;
  85219. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  85220. protected _setRootMesh(meshes: AbstractMesh[]): void;
  85221. protected _updateModel(): void;
  85222. }
  85223. }
  85224. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  85225. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  85226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  85227. import { Scene } from "babylonjs/scene";
  85228. /**
  85229. * The motion controller class for oculus touch (quest, rift).
  85230. * This class supports legacy mapping as well the standard xr mapping
  85231. */
  85232. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  85233. private _forceLegacyControllers;
  85234. private _modelRootNode;
  85235. /**
  85236. * The base url used to load the left and right controller models
  85237. */
  85238. static MODEL_BASE_URL: string;
  85239. /**
  85240. * The name of the left controller model file
  85241. */
  85242. static MODEL_LEFT_FILENAME: string;
  85243. /**
  85244. * The name of the right controller model file
  85245. */
  85246. static MODEL_RIGHT_FILENAME: string;
  85247. /**
  85248. * Base Url for the Quest controller model.
  85249. */
  85250. static QUEST_MODEL_BASE_URL: string;
  85251. profileId: string;
  85252. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  85253. protected _getFilenameAndPath(): {
  85254. filename: string;
  85255. path: string;
  85256. };
  85257. protected _getModelLoadingConstraints(): boolean;
  85258. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  85259. protected _setRootMesh(meshes: AbstractMesh[]): void;
  85260. protected _updateModel(): void;
  85261. /**
  85262. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  85263. * between the touch and touch 2.
  85264. */
  85265. private _isQuest;
  85266. }
  85267. }
  85268. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  85269. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  85270. import { Scene } from "babylonjs/scene";
  85271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  85272. /**
  85273. * The motion controller class for the standard HTC-Vive controllers
  85274. */
  85275. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  85276. private _modelRootNode;
  85277. /**
  85278. * The base url used to load the left and right controller models
  85279. */
  85280. static MODEL_BASE_URL: string;
  85281. /**
  85282. * File name for the controller model.
  85283. */
  85284. static MODEL_FILENAME: string;
  85285. profileId: string;
  85286. /**
  85287. * Create a new Vive motion controller object
  85288. * @param scene the scene to use to create this controller
  85289. * @param gamepadObject the corresponding gamepad object
  85290. * @param handedness the handedness of the controller
  85291. */
  85292. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  85293. protected _getFilenameAndPath(): {
  85294. filename: string;
  85295. path: string;
  85296. };
  85297. protected _getModelLoadingConstraints(): boolean;
  85298. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  85299. protected _setRootMesh(meshes: AbstractMesh[]): void;
  85300. protected _updateModel(): void;
  85301. }
  85302. }
  85303. declare module "babylonjs/XR/motionController/index" {
  85304. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  85305. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  85306. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  85307. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  85308. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  85309. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  85310. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  85311. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  85312. }
  85313. declare module "babylonjs/XR/index" {
  85314. export * from "babylonjs/XR/webXRCamera";
  85315. export * from "babylonjs/XR/webXREnterExitUI";
  85316. export * from "babylonjs/XR/webXRExperienceHelper";
  85317. export * from "babylonjs/XR/webXRInput";
  85318. export * from "babylonjs/XR/webXRInputSource";
  85319. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  85320. export * from "babylonjs/XR/webXRTypes";
  85321. export * from "babylonjs/XR/webXRSessionManager";
  85322. export * from "babylonjs/XR/webXRDefaultExperience";
  85323. export * from "babylonjs/XR/webXRFeaturesManager";
  85324. export * from "babylonjs/XR/features/index";
  85325. export * from "babylonjs/XR/motionController/index";
  85326. }
  85327. declare module "babylonjs/index" {
  85328. export * from "babylonjs/abstractScene";
  85329. export * from "babylonjs/Actions/index";
  85330. export * from "babylonjs/Animations/index";
  85331. export * from "babylonjs/assetContainer";
  85332. export * from "babylonjs/Audio/index";
  85333. export * from "babylonjs/Behaviors/index";
  85334. export * from "babylonjs/Bones/index";
  85335. export * from "babylonjs/Cameras/index";
  85336. export * from "babylonjs/Collisions/index";
  85337. export * from "babylonjs/Culling/index";
  85338. export * from "babylonjs/Debug/index";
  85339. export * from "babylonjs/DeviceInput/index";
  85340. export * from "babylonjs/Engines/index";
  85341. export * from "babylonjs/Events/index";
  85342. export * from "babylonjs/Gamepads/index";
  85343. export * from "babylonjs/Gizmos/index";
  85344. export * from "babylonjs/Helpers/index";
  85345. export * from "babylonjs/Instrumentation/index";
  85346. export * from "babylonjs/Layers/index";
  85347. export * from "babylonjs/LensFlares/index";
  85348. export * from "babylonjs/Lights/index";
  85349. export * from "babylonjs/Loading/index";
  85350. export * from "babylonjs/Materials/index";
  85351. export * from "babylonjs/Maths/index";
  85352. export * from "babylonjs/Meshes/index";
  85353. export * from "babylonjs/Morph/index";
  85354. export * from "babylonjs/Navigation/index";
  85355. export * from "babylonjs/node";
  85356. export * from "babylonjs/Offline/index";
  85357. export * from "babylonjs/Particles/index";
  85358. export * from "babylonjs/Physics/index";
  85359. export * from "babylonjs/PostProcesses/index";
  85360. export * from "babylonjs/Probes/index";
  85361. export * from "babylonjs/Rendering/index";
  85362. export * from "babylonjs/scene";
  85363. export * from "babylonjs/sceneComponent";
  85364. export * from "babylonjs/Sprites/index";
  85365. export * from "babylonjs/States/index";
  85366. export * from "babylonjs/Misc/index";
  85367. export * from "babylonjs/XR/index";
  85368. export * from "babylonjs/types";
  85369. }
  85370. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  85371. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  85372. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  85373. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  85374. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  85375. }
  85376. declare module "babylonjs/Engines/Processors/Expressions/index" {
  85377. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  85378. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  85379. }
  85380. declare module "babylonjs/Engines/Processors/index" {
  85381. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  85382. export * from "babylonjs/Engines/Processors/Expressions/index";
  85383. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  85384. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  85385. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  85386. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  85387. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  85388. export * from "babylonjs/Engines/Processors/shaderProcessor";
  85389. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  85390. }
  85391. declare module "babylonjs/Engines/WebGPU/webgpuCacheRenderPipelineString" {
  85392. import { Nullable } from "babylonjs/types";
  85393. import { WebGPUCacheRenderPipeline } from "babylonjs/Engines/WebGPU/webgpuCacheRenderPipeline";
  85394. /** @hidden */
  85395. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  85396. private static _Cache;
  85397. protected _getRenderPipeline(param: {
  85398. token: any;
  85399. pipeline: Nullable<GPURenderPipeline>;
  85400. }): void;
  85401. protected _setRenderPipeline(param: {
  85402. token: any;
  85403. pipeline: Nullable<GPURenderPipeline>;
  85404. }): void;
  85405. }
  85406. }
  85407. declare module "babylonjs/Legacy/legacy" {
  85408. import * as Babylon from "babylonjs/index";
  85409. export * from "babylonjs/index";
  85410. }
  85411. declare module "babylonjs/Shaders/blur.fragment" {
  85412. /** @hidden */
  85413. export var blurPixelShader: {
  85414. name: string;
  85415. shader: string;
  85416. };
  85417. }
  85418. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  85419. /** @hidden */
  85420. export var pointCloudVertexDeclaration: {
  85421. name: string;
  85422. shader: string;
  85423. };
  85424. }
  85425. declare module "babylonjs" {
  85426. export * from "babylonjs/Legacy/legacy";
  85427. }
  85428. declare module BABYLON {
  85429. /** Alias type for value that can be null */
  85430. export type Nullable<T> = T | null;
  85431. /**
  85432. * Alias type for number that are floats
  85433. * @ignorenaming
  85434. */
  85435. export type float = number;
  85436. /**
  85437. * Alias type for number that are doubles.
  85438. * @ignorenaming
  85439. */
  85440. export type double = number;
  85441. /**
  85442. * Alias type for number that are integer
  85443. * @ignorenaming
  85444. */
  85445. export type int = number;
  85446. /** Alias type for number array or Float32Array */
  85447. export type FloatArray = number[] | Float32Array;
  85448. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  85449. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  85450. /**
  85451. * Alias for types that can be used by a Buffer or VertexBuffer.
  85452. */
  85453. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  85454. /**
  85455. * Alias type for primitive types
  85456. * @ignorenaming
  85457. */
  85458. type Primitive = undefined | null | boolean | string | number | Function;
  85459. /**
  85460. * Type modifier to make all the properties of an object Readonly
  85461. */
  85462. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  85463. /**
  85464. * Type modifier to make all the properties of an object Readonly recursively
  85465. */
  85466. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  85467. /**
  85468. * Type modifier to make object properties readonly.
  85469. */
  85470. export type DeepImmutableObject<T> = {
  85471. readonly [K in keyof T]: DeepImmutable<T[K]>;
  85472. };
  85473. /** @hidden */
  85474. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  85475. }
  85476. }
  85477. declare module BABYLON {
  85478. /**
  85479. * A class serves as a medium between the observable and its observers
  85480. */
  85481. export class EventState {
  85482. /**
  85483. * Create a new EventState
  85484. * @param mask defines the mask associated with this state
  85485. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  85486. * @param target defines the original target of the state
  85487. * @param currentTarget defines the current target of the state
  85488. */
  85489. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  85490. /**
  85491. * Initialize the current event state
  85492. * @param mask defines the mask associated with this state
  85493. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  85494. * @param target defines the original target of the state
  85495. * @param currentTarget defines the current target of the state
  85496. * @returns the current event state
  85497. */
  85498. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  85499. /**
  85500. * An Observer can set this property to true to prevent subsequent observers of being notified
  85501. */
  85502. skipNextObservers: boolean;
  85503. /**
  85504. * Get the mask value that were used to trigger the event corresponding to this EventState object
  85505. */
  85506. mask: number;
  85507. /**
  85508. * The object that originally notified the event
  85509. */
  85510. target?: any;
  85511. /**
  85512. * The current object in the bubbling phase
  85513. */
  85514. currentTarget?: any;
  85515. /**
  85516. * This will be populated with the return value of the last function that was executed.
  85517. * If it is the first function in the callback chain it will be the event data.
  85518. */
  85519. lastReturnValue?: any;
  85520. /**
  85521. * User defined information that will be sent to observers
  85522. */
  85523. userInfo?: any;
  85524. }
  85525. /**
  85526. * Represent an Observer registered to a given Observable object.
  85527. */
  85528. export class Observer<T> {
  85529. /**
  85530. * Defines the callback to call when the observer is notified
  85531. */
  85532. callback: (eventData: T, eventState: EventState) => void;
  85533. /**
  85534. * Defines the mask of the observer (used to filter notifications)
  85535. */
  85536. mask: number;
  85537. /**
  85538. * Defines the current scope used to restore the JS context
  85539. */
  85540. scope: any;
  85541. /** @hidden */
  85542. _willBeUnregistered: boolean;
  85543. /**
  85544. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  85545. */
  85546. unregisterOnNextCall: boolean;
  85547. /**
  85548. * Creates a new observer
  85549. * @param callback defines the callback to call when the observer is notified
  85550. * @param mask defines the mask of the observer (used to filter notifications)
  85551. * @param scope defines the current scope used to restore the JS context
  85552. */
  85553. constructor(
  85554. /**
  85555. * Defines the callback to call when the observer is notified
  85556. */
  85557. callback: (eventData: T, eventState: EventState) => void,
  85558. /**
  85559. * Defines the mask of the observer (used to filter notifications)
  85560. */
  85561. mask: number,
  85562. /**
  85563. * Defines the current scope used to restore the JS context
  85564. */
  85565. scope?: any);
  85566. }
  85567. /**
  85568. * Represent a list of observers registered to multiple Observables object.
  85569. */
  85570. export class MultiObserver<T> {
  85571. private _observers;
  85572. private _observables;
  85573. /**
  85574. * Release associated resources
  85575. */
  85576. dispose(): void;
  85577. /**
  85578. * Raise a callback when one of the observable will notify
  85579. * @param observables defines a list of observables to watch
  85580. * @param callback defines the callback to call on notification
  85581. * @param mask defines the mask used to filter notifications
  85582. * @param scope defines the current scope used to restore the JS context
  85583. * @returns the new MultiObserver
  85584. */
  85585. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  85586. }
  85587. /**
  85588. * The Observable class is a simple implementation of the Observable pattern.
  85589. *
  85590. * 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.
  85591. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  85592. * 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).
  85593. * 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.
  85594. */
  85595. export class Observable<T> {
  85596. private _observers;
  85597. private _eventState;
  85598. private _onObserverAdded;
  85599. /**
  85600. * Gets the list of observers
  85601. */
  85602. get observers(): Array<Observer<T>>;
  85603. /**
  85604. * Creates a new observable
  85605. * @param onObserverAdded defines a callback to call when a new observer is added
  85606. */
  85607. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  85608. /**
  85609. * Create a new Observer with the specified callback
  85610. * @param callback the callback that will be executed for that Observer
  85611. * @param mask the mask used to filter observers
  85612. * @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.
  85613. * @param scope optional scope for the callback to be called from
  85614. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  85615. * @returns the new observer created for the callback
  85616. */
  85617. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  85618. /**
  85619. * Create a new Observer with the specified callback and unregisters after the next notification
  85620. * @param callback the callback that will be executed for that Observer
  85621. * @returns the new observer created for the callback
  85622. */
  85623. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  85624. /**
  85625. * Remove an Observer from the Observable object
  85626. * @param observer the instance of the Observer to remove
  85627. * @returns false if it doesn't belong to this Observable
  85628. */
  85629. remove(observer: Nullable<Observer<T>>): boolean;
  85630. /**
  85631. * Remove a callback from the Observable object
  85632. * @param callback the callback to remove
  85633. * @param scope optional scope. If used only the callbacks with this scope will be removed
  85634. * @returns false if it doesn't belong to this Observable
  85635. */
  85636. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  85637. private _deferUnregister;
  85638. private _remove;
  85639. /**
  85640. * Moves the observable to the top of the observer list making it get called first when notified
  85641. * @param observer the observer to move
  85642. */
  85643. makeObserverTopPriority(observer: Observer<T>): void;
  85644. /**
  85645. * Moves the observable to the bottom of the observer list making it get called last when notified
  85646. * @param observer the observer to move
  85647. */
  85648. makeObserverBottomPriority(observer: Observer<T>): void;
  85649. /**
  85650. * Notify all Observers by calling their respective callback with the given data
  85651. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  85652. * @param eventData defines the data to send to all observers
  85653. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  85654. * @param target defines the original target of the state
  85655. * @param currentTarget defines the current target of the state
  85656. * @param userInfo defines any user info to send to observers
  85657. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  85658. */
  85659. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  85660. /**
  85661. * Calling this will execute each callback, expecting it to be a promise or return a value.
  85662. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  85663. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  85664. * and it is crucial that all callbacks will be executed.
  85665. * The order of the callbacks is kept, callbacks are not executed parallel.
  85666. *
  85667. * @param eventData The data to be sent to each callback
  85668. * @param mask is used to filter observers defaults to -1
  85669. * @param target defines the callback target (see EventState)
  85670. * @param currentTarget defines he current object in the bubbling phase
  85671. * @param userInfo defines any user info to send to observers
  85672. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  85673. */
  85674. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  85675. /**
  85676. * Notify a specific observer
  85677. * @param observer defines the observer to notify
  85678. * @param eventData defines the data to be sent to each callback
  85679. * @param mask is used to filter observers defaults to -1
  85680. */
  85681. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  85682. /**
  85683. * Gets a boolean indicating if the observable has at least one observer
  85684. * @returns true is the Observable has at least one Observer registered
  85685. */
  85686. hasObservers(): boolean;
  85687. /**
  85688. * Clear the list of observers
  85689. */
  85690. clear(): void;
  85691. /**
  85692. * Clone the current observable
  85693. * @returns a new observable
  85694. */
  85695. clone(): Observable<T>;
  85696. /**
  85697. * Does this observable handles observer registered with a given mask
  85698. * @param mask defines the mask to be tested
  85699. * @return whether or not one observer registered with the given mask is handled
  85700. **/
  85701. hasSpecificMask(mask?: number): boolean;
  85702. }
  85703. }
  85704. declare module BABYLON {
  85705. /**
  85706. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  85707. * Babylon.js
  85708. */
  85709. export class DomManagement {
  85710. /**
  85711. * Checks if the window object exists
  85712. * @returns true if the window object exists
  85713. */
  85714. static IsWindowObjectExist(): boolean;
  85715. /**
  85716. * Checks if the navigator object exists
  85717. * @returns true if the navigator object exists
  85718. */
  85719. static IsNavigatorAvailable(): boolean;
  85720. /**
  85721. * Check if the document object exists
  85722. * @returns true if the document object exists
  85723. */
  85724. static IsDocumentAvailable(): boolean;
  85725. /**
  85726. * Extracts text content from a DOM element hierarchy
  85727. * @param element defines the root element
  85728. * @returns a string
  85729. */
  85730. static GetDOMTextContent(element: HTMLElement): string;
  85731. }
  85732. }
  85733. declare module BABYLON {
  85734. /**
  85735. * Logger used throughout the application to allow configuration of
  85736. * the log level required for the messages.
  85737. */
  85738. export class Logger {
  85739. /**
  85740. * No log
  85741. */
  85742. static readonly NoneLogLevel: number;
  85743. /**
  85744. * Only message logs
  85745. */
  85746. static readonly MessageLogLevel: number;
  85747. /**
  85748. * Only warning logs
  85749. */
  85750. static readonly WarningLogLevel: number;
  85751. /**
  85752. * Only error logs
  85753. */
  85754. static readonly ErrorLogLevel: number;
  85755. /**
  85756. * All logs
  85757. */
  85758. static readonly AllLogLevel: number;
  85759. /**
  85760. * Message to display when a message has been logged too many times
  85761. */
  85762. static MessageLimitReached: string;
  85763. private static _LogCache;
  85764. private static _LogLimitOutputs;
  85765. /**
  85766. * Gets a value indicating the number of loading errors
  85767. * @ignorenaming
  85768. */
  85769. static errorsCount: number;
  85770. /**
  85771. * Callback called when a new log is added
  85772. */
  85773. static OnNewCacheEntry: (entry: string) => void;
  85774. private static _CheckLimit;
  85775. private static _GenerateLimitMessage;
  85776. private static _AddLogEntry;
  85777. private static _FormatMessage;
  85778. private static _LogDisabled;
  85779. private static _LogEnabled;
  85780. private static _WarnDisabled;
  85781. private static _WarnEnabled;
  85782. private static _ErrorDisabled;
  85783. private static _ErrorEnabled;
  85784. /**
  85785. * Log a message to the console
  85786. */
  85787. static Log: (message: string, limit?: number) => void;
  85788. /**
  85789. * Write a warning message to the console
  85790. */
  85791. static Warn: (message: string, limit?: number) => void;
  85792. /**
  85793. * Write an error message to the console
  85794. */
  85795. static Error: (message: string, limit?: number) => void;
  85796. /**
  85797. * Gets current log cache (list of logs)
  85798. */
  85799. static get LogCache(): string;
  85800. /**
  85801. * Clears the log cache
  85802. */
  85803. static ClearLogCache(): void;
  85804. /**
  85805. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  85806. */
  85807. static set LogLevels(level: number);
  85808. }
  85809. }
  85810. declare module BABYLON {
  85811. /** @hidden */
  85812. export class _TypeStore {
  85813. /** @hidden */
  85814. static RegisteredTypes: {
  85815. [key: string]: Object;
  85816. };
  85817. /** @hidden */
  85818. static GetClass(fqdn: string): any;
  85819. }
  85820. }
  85821. declare module BABYLON {
  85822. /**
  85823. * Helper to manipulate strings
  85824. */
  85825. export class StringTools {
  85826. /**
  85827. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  85828. * @param str Source string
  85829. * @param suffix Suffix to search for in the source string
  85830. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  85831. */
  85832. static EndsWith(str: string, suffix: string): boolean;
  85833. /**
  85834. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  85835. * @param str Source string
  85836. * @param suffix Suffix to search for in the source string
  85837. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  85838. */
  85839. static StartsWith(str: string, suffix: string): boolean;
  85840. /**
  85841. * Decodes a buffer into a string
  85842. * @param buffer The buffer to decode
  85843. * @returns The decoded string
  85844. */
  85845. static Decode(buffer: Uint8Array | Uint16Array): string;
  85846. /**
  85847. * Encode a buffer to a base64 string
  85848. * @param buffer defines the buffer to encode
  85849. * @returns the encoded string
  85850. */
  85851. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  85852. /**
  85853. * Converts a number to string and pads with preceding zeroes until it is of specified length.
  85854. * @param num the number to convert and pad
  85855. * @param length the expected length of the string
  85856. * @returns the padded string
  85857. */
  85858. static PadNumber(num: number, length: number): string;
  85859. }
  85860. }
  85861. declare module BABYLON {
  85862. /**
  85863. * Class containing a set of static utilities functions for deep copy.
  85864. */
  85865. export class DeepCopier {
  85866. /**
  85867. * Tries to copy an object by duplicating every property
  85868. * @param source defines the source object
  85869. * @param destination defines the target object
  85870. * @param doNotCopyList defines a list of properties to avoid
  85871. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  85872. */
  85873. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  85874. }
  85875. }
  85876. declare module BABYLON {
  85877. /**
  85878. * Class containing a set of static utilities functions for precision date
  85879. */
  85880. export class PrecisionDate {
  85881. /**
  85882. * Gets either window.performance.now() if supported or Date.now() else
  85883. */
  85884. static get Now(): number;
  85885. }
  85886. }
  85887. declare module BABYLON {
  85888. /** @hidden */
  85889. export class _DevTools {
  85890. static WarnImport(name: string): string;
  85891. }
  85892. }
  85893. declare module BABYLON {
  85894. /**
  85895. * Interface used to define the mechanism to get data from the network
  85896. */
  85897. export interface IWebRequest {
  85898. /**
  85899. * Returns client's response url
  85900. */
  85901. responseURL: string;
  85902. /**
  85903. * Returns client's status
  85904. */
  85905. status: number;
  85906. /**
  85907. * Returns client's status as a text
  85908. */
  85909. statusText: string;
  85910. }
  85911. }
  85912. declare module BABYLON {
  85913. /**
  85914. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  85915. */
  85916. export class WebRequest implements IWebRequest {
  85917. private readonly _xhr;
  85918. /**
  85919. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  85920. * i.e. when loading files, where the server/service expects an Authorization header
  85921. */
  85922. static CustomRequestHeaders: {
  85923. [key: string]: string;
  85924. };
  85925. /**
  85926. * Add callback functions in this array to update all the requests before they get sent to the network
  85927. */
  85928. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  85929. private _injectCustomRequestHeaders;
  85930. /**
  85931. * Gets or sets a function to be called when loading progress changes
  85932. */
  85933. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  85934. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  85935. /**
  85936. * Returns client's state
  85937. */
  85938. get readyState(): number;
  85939. /**
  85940. * Returns client's status
  85941. */
  85942. get status(): number;
  85943. /**
  85944. * Returns client's status as a text
  85945. */
  85946. get statusText(): string;
  85947. /**
  85948. * Returns client's response
  85949. */
  85950. get response(): any;
  85951. /**
  85952. * Returns client's response url
  85953. */
  85954. get responseURL(): string;
  85955. /**
  85956. * Returns client's response as text
  85957. */
  85958. get responseText(): string;
  85959. /**
  85960. * Gets or sets the expected response type
  85961. */
  85962. get responseType(): XMLHttpRequestResponseType;
  85963. set responseType(value: XMLHttpRequestResponseType);
  85964. /** @hidden */
  85965. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  85966. /** @hidden */
  85967. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  85968. /**
  85969. * Cancels any network activity
  85970. */
  85971. abort(): void;
  85972. /**
  85973. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  85974. * @param body defines an optional request body
  85975. */
  85976. send(body?: Document | BodyInit | null): void;
  85977. /**
  85978. * Sets the request method, request URL
  85979. * @param method defines the method to use (GET, POST, etc..)
  85980. * @param url defines the url to connect with
  85981. */
  85982. open(method: string, url: string): void;
  85983. /**
  85984. * Sets the value of a request header.
  85985. * @param name The name of the header whose value is to be set
  85986. * @param value The value to set as the body of the header
  85987. */
  85988. setRequestHeader(name: string, value: string): void;
  85989. /**
  85990. * Get the string containing the text of a particular header's value.
  85991. * @param name The name of the header
  85992. * @returns The string containing the text of the given header name
  85993. */
  85994. getResponseHeader(name: string): Nullable<string>;
  85995. }
  85996. }
  85997. declare module BABYLON {
  85998. /**
  85999. * File request interface
  86000. */
  86001. export interface IFileRequest {
  86002. /**
  86003. * Raised when the request is complete (success or error).
  86004. */
  86005. onCompleteObservable: Observable<IFileRequest>;
  86006. /**
  86007. * Aborts the request for a file.
  86008. */
  86009. abort: () => void;
  86010. }
  86011. }
  86012. declare module BABYLON {
  86013. /**
  86014. * Define options used to create a render target texture
  86015. */
  86016. export class RenderTargetCreationOptions {
  86017. /**
  86018. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  86019. */
  86020. createMipMaps?: boolean;
  86021. /**
  86022. * Specifies if mipmaps must be generated
  86023. */
  86024. generateMipMaps?: boolean;
  86025. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  86026. generateDepthBuffer?: boolean;
  86027. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  86028. generateStencilBuffer?: boolean;
  86029. /** Defines texture type (int by default) */
  86030. type?: number;
  86031. /** Defines sampling mode (trilinear by default) */
  86032. samplingMode?: number;
  86033. /** Defines format (RGBA by default) */
  86034. format?: number;
  86035. /** Defines sample count (1 by default) */
  86036. samples?: number;
  86037. }
  86038. }
  86039. declare module BABYLON {
  86040. /** Defines the cross module used constants to avoid circular dependencies */
  86041. export class Constants {
  86042. /** Defines that alpha blending is disabled */
  86043. static readonly ALPHA_DISABLE: number;
  86044. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  86045. static readonly ALPHA_ADD: number;
  86046. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86047. static readonly ALPHA_COMBINE: number;
  86048. /** Defines that alpha blending is DEST - SRC * DEST */
  86049. static readonly ALPHA_SUBTRACT: number;
  86050. /** Defines that alpha blending is SRC * DEST */
  86051. static readonly ALPHA_MULTIPLY: number;
  86052. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  86053. static readonly ALPHA_MAXIMIZED: number;
  86054. /** Defines that alpha blending is SRC + DEST */
  86055. static readonly ALPHA_ONEONE: number;
  86056. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  86057. static readonly ALPHA_PREMULTIPLIED: number;
  86058. /**
  86059. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  86060. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86061. */
  86062. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86063. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  86064. static readonly ALPHA_INTERPOLATE: number;
  86065. /**
  86066. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  86067. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86068. */
  86069. static readonly ALPHA_SCREENMODE: number;
  86070. /**
  86071. * Defines that alpha blending is SRC + DST
  86072. * Alpha will be set to SRC ALPHA + DST ALPHA
  86073. */
  86074. static readonly ALPHA_ONEONE_ONEONE: number;
  86075. /**
  86076. * Defines that alpha blending is SRC * DST ALPHA + DST
  86077. * Alpha will be set to 0
  86078. */
  86079. static readonly ALPHA_ALPHATOCOLOR: number;
  86080. /**
  86081. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  86082. */
  86083. static readonly ALPHA_REVERSEONEMINUS: number;
  86084. /**
  86085. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  86086. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  86087. */
  86088. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  86089. /**
  86090. * Defines that alpha blending is SRC + DST
  86091. * Alpha will be set to SRC ALPHA
  86092. */
  86093. static readonly ALPHA_ONEONE_ONEZERO: number;
  86094. /**
  86095. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  86096. * Alpha will be set to DST ALPHA
  86097. */
  86098. static readonly ALPHA_EXCLUSION: number;
  86099. /** Defines that alpha blending equation a SUM */
  86100. static readonly ALPHA_EQUATION_ADD: number;
  86101. /** Defines that alpha blending equation a SUBSTRACTION */
  86102. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  86103. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  86104. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  86105. /** Defines that alpha blending equation a MAX operation */
  86106. static readonly ALPHA_EQUATION_MAX: number;
  86107. /** Defines that alpha blending equation a MIN operation */
  86108. static readonly ALPHA_EQUATION_MIN: number;
  86109. /**
  86110. * Defines that alpha blending equation a DARKEN operation:
  86111. * It takes the min of the src and sums the alpha channels.
  86112. */
  86113. static readonly ALPHA_EQUATION_DARKEN: number;
  86114. /** Defines that the resource is not delayed*/
  86115. static readonly DELAYLOADSTATE_NONE: number;
  86116. /** Defines that the resource was successfully delay loaded */
  86117. static readonly DELAYLOADSTATE_LOADED: number;
  86118. /** Defines that the resource is currently delay loading */
  86119. static readonly DELAYLOADSTATE_LOADING: number;
  86120. /** Defines that the resource is delayed and has not started loading */
  86121. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86122. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86123. static readonly NEVER: number;
  86124. /** 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 */
  86125. static readonly ALWAYS: number;
  86126. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86127. static readonly LESS: number;
  86128. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86129. static readonly EQUAL: number;
  86130. /** 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 */
  86131. static readonly LEQUAL: number;
  86132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86133. static readonly GREATER: number;
  86134. /** 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 */
  86135. static readonly GEQUAL: number;
  86136. /** 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 */
  86137. static readonly NOTEQUAL: number;
  86138. /** Passed to stencilOperation to specify that stencil value must be kept */
  86139. static readonly KEEP: number;
  86140. /** Passed to stencilOperation to specify that stencil value must be zero */
  86141. static readonly ZERO: number;
  86142. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86143. static readonly REPLACE: number;
  86144. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86145. static readonly INCR: number;
  86146. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86147. static readonly DECR: number;
  86148. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86149. static readonly INVERT: number;
  86150. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86151. static readonly INCR_WRAP: number;
  86152. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86153. static readonly DECR_WRAP: number;
  86154. /** Texture is not repeating outside of 0..1 UVs */
  86155. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86156. /** Texture is repeating outside of 0..1 UVs */
  86157. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86158. /** Texture is repeating and mirrored */
  86159. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86160. /** ALPHA */
  86161. static readonly TEXTUREFORMAT_ALPHA: number;
  86162. /** LUMINANCE */
  86163. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86164. /** LUMINANCE_ALPHA */
  86165. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86166. /** RGB */
  86167. static readonly TEXTUREFORMAT_RGB: number;
  86168. /** RGBA */
  86169. static readonly TEXTUREFORMAT_RGBA: number;
  86170. /** RED */
  86171. static readonly TEXTUREFORMAT_RED: number;
  86172. /** RED (2nd reference) */
  86173. static readonly TEXTUREFORMAT_R: number;
  86174. /** RG */
  86175. static readonly TEXTUREFORMAT_RG: number;
  86176. /** RED_INTEGER */
  86177. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86178. /** RED_INTEGER (2nd reference) */
  86179. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86180. /** RG_INTEGER */
  86181. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86182. /** RGB_INTEGER */
  86183. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86184. /** RGBA_INTEGER */
  86185. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86186. /** BGRA */
  86187. static readonly TEXTUREFORMAT_BGRA: number;
  86188. /** Depth 24 bits + Stencil 8 bits */
  86189. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  86190. /** Depth 32 bits float */
  86191. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  86192. /** Compressed BC7 */
  86193. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  86194. /** Compressed BC6 unsigned float */
  86195. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  86196. /** Compressed BC6 signed float */
  86197. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  86198. /** Compressed BC3 */
  86199. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  86200. /** Compressed BC2 */
  86201. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  86202. /** Compressed BC1 */
  86203. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  86204. /** UNSIGNED_BYTE */
  86205. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86206. /** UNSIGNED_BYTE (2nd reference) */
  86207. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86208. /** FLOAT */
  86209. static readonly TEXTURETYPE_FLOAT: number;
  86210. /** HALF_FLOAT */
  86211. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86212. /** BYTE */
  86213. static readonly TEXTURETYPE_BYTE: number;
  86214. /** SHORT */
  86215. static readonly TEXTURETYPE_SHORT: number;
  86216. /** UNSIGNED_SHORT */
  86217. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86218. /** INT */
  86219. static readonly TEXTURETYPE_INT: number;
  86220. /** UNSIGNED_INT */
  86221. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86222. /** UNSIGNED_SHORT_4_4_4_4 */
  86223. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86224. /** UNSIGNED_SHORT_5_5_5_1 */
  86225. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86226. /** UNSIGNED_SHORT_5_6_5 */
  86227. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86228. /** UNSIGNED_INT_2_10_10_10_REV */
  86229. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86230. /** UNSIGNED_INT_24_8 */
  86231. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86232. /** UNSIGNED_INT_10F_11F_11F_REV */
  86233. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86234. /** UNSIGNED_INT_5_9_9_9_REV */
  86235. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86236. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86237. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86238. /** nearest is mag = nearest and min = nearest and no mip */
  86239. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86240. /** mag = nearest and min = nearest and mip = none */
  86241. static readonly TEXTURE_NEAREST_NEAREST: number;
  86242. /** Bilinear is mag = linear and min = linear and no mip */
  86243. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86244. /** mag = linear and min = linear and mip = none */
  86245. static readonly TEXTURE_LINEAR_LINEAR: number;
  86246. /** Trilinear is mag = linear and min = linear and mip = linear */
  86247. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86248. /** Trilinear is mag = linear and min = linear and mip = linear */
  86249. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86250. /** mag = nearest and min = nearest and mip = nearest */
  86251. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86252. /** mag = nearest and min = linear and mip = nearest */
  86253. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86254. /** mag = nearest and min = linear and mip = linear */
  86255. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86256. /** mag = nearest and min = linear and mip = none */
  86257. static readonly TEXTURE_NEAREST_LINEAR: number;
  86258. /** nearest is mag = nearest and min = nearest and mip = linear */
  86259. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86260. /** mag = linear and min = nearest and mip = nearest */
  86261. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86262. /** mag = linear and min = nearest and mip = linear */
  86263. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86264. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86265. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86266. /** mag = linear and min = nearest and mip = none */
  86267. static readonly TEXTURE_LINEAR_NEAREST: number;
  86268. /** Explicit coordinates mode */
  86269. static readonly TEXTURE_EXPLICIT_MODE: number;
  86270. /** Spherical coordinates mode */
  86271. static readonly TEXTURE_SPHERICAL_MODE: number;
  86272. /** Planar coordinates mode */
  86273. static readonly TEXTURE_PLANAR_MODE: number;
  86274. /** Cubic coordinates mode */
  86275. static readonly TEXTURE_CUBIC_MODE: number;
  86276. /** Projection coordinates mode */
  86277. static readonly TEXTURE_PROJECTION_MODE: number;
  86278. /** Skybox coordinates mode */
  86279. static readonly TEXTURE_SKYBOX_MODE: number;
  86280. /** Inverse Cubic coordinates mode */
  86281. static readonly TEXTURE_INVCUBIC_MODE: number;
  86282. /** Equirectangular coordinates mode */
  86283. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86284. /** Equirectangular Fixed coordinates mode */
  86285. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86286. /** Equirectangular Fixed Mirrored coordinates mode */
  86287. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86288. /** Offline (baking) quality for texture filtering */
  86289. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  86290. /** High quality for texture filtering */
  86291. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  86292. /** Medium quality for texture filtering */
  86293. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  86294. /** Low quality for texture filtering */
  86295. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  86296. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86297. static readonly SCALEMODE_FLOOR: number;
  86298. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86299. static readonly SCALEMODE_NEAREST: number;
  86300. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86301. static readonly SCALEMODE_CEILING: number;
  86302. /**
  86303. * The dirty texture flag value
  86304. */
  86305. static readonly MATERIAL_TextureDirtyFlag: number;
  86306. /**
  86307. * The dirty light flag value
  86308. */
  86309. static readonly MATERIAL_LightDirtyFlag: number;
  86310. /**
  86311. * The dirty fresnel flag value
  86312. */
  86313. static readonly MATERIAL_FresnelDirtyFlag: number;
  86314. /**
  86315. * The dirty attribute flag value
  86316. */
  86317. static readonly MATERIAL_AttributesDirtyFlag: number;
  86318. /**
  86319. * The dirty misc flag value
  86320. */
  86321. static readonly MATERIAL_MiscDirtyFlag: number;
  86322. /**
  86323. * The dirty prepass flag value
  86324. */
  86325. static readonly MATERIAL_PrePassDirtyFlag: number;
  86326. /**
  86327. * The all dirty flag value
  86328. */
  86329. static readonly MATERIAL_AllDirtyFlag: number;
  86330. /**
  86331. * Returns the triangle fill mode
  86332. */
  86333. static readonly MATERIAL_TriangleFillMode: number;
  86334. /**
  86335. * Returns the wireframe mode
  86336. */
  86337. static readonly MATERIAL_WireFrameFillMode: number;
  86338. /**
  86339. * Returns the point fill mode
  86340. */
  86341. static readonly MATERIAL_PointFillMode: number;
  86342. /**
  86343. * Returns the point list draw mode
  86344. */
  86345. static readonly MATERIAL_PointListDrawMode: number;
  86346. /**
  86347. * Returns the line list draw mode
  86348. */
  86349. static readonly MATERIAL_LineListDrawMode: number;
  86350. /**
  86351. * Returns the line loop draw mode
  86352. */
  86353. static readonly MATERIAL_LineLoopDrawMode: number;
  86354. /**
  86355. * Returns the line strip draw mode
  86356. */
  86357. static readonly MATERIAL_LineStripDrawMode: number;
  86358. /**
  86359. * Returns the triangle strip draw mode
  86360. */
  86361. static readonly MATERIAL_TriangleStripDrawMode: number;
  86362. /**
  86363. * Returns the triangle fan draw mode
  86364. */
  86365. static readonly MATERIAL_TriangleFanDrawMode: number;
  86366. /**
  86367. * Stores the clock-wise side orientation
  86368. */
  86369. static readonly MATERIAL_ClockWiseSideOrientation: number;
  86370. /**
  86371. * Stores the counter clock-wise side orientation
  86372. */
  86373. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  86374. /**
  86375. * Nothing
  86376. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86377. */
  86378. static readonly ACTION_NothingTrigger: number;
  86379. /**
  86380. * On pick
  86381. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86382. */
  86383. static readonly ACTION_OnPickTrigger: number;
  86384. /**
  86385. * On left pick
  86386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86387. */
  86388. static readonly ACTION_OnLeftPickTrigger: number;
  86389. /**
  86390. * On right pick
  86391. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86392. */
  86393. static readonly ACTION_OnRightPickTrigger: number;
  86394. /**
  86395. * On center pick
  86396. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86397. */
  86398. static readonly ACTION_OnCenterPickTrigger: number;
  86399. /**
  86400. * On pick down
  86401. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86402. */
  86403. static readonly ACTION_OnPickDownTrigger: number;
  86404. /**
  86405. * On double pick
  86406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86407. */
  86408. static readonly ACTION_OnDoublePickTrigger: number;
  86409. /**
  86410. * On pick up
  86411. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86412. */
  86413. static readonly ACTION_OnPickUpTrigger: number;
  86414. /**
  86415. * On pick out.
  86416. * This trigger will only be raised if you also declared a OnPickDown
  86417. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86418. */
  86419. static readonly ACTION_OnPickOutTrigger: number;
  86420. /**
  86421. * On long press
  86422. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86423. */
  86424. static readonly ACTION_OnLongPressTrigger: number;
  86425. /**
  86426. * On pointer over
  86427. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86428. */
  86429. static readonly ACTION_OnPointerOverTrigger: number;
  86430. /**
  86431. * On pointer out
  86432. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86433. */
  86434. static readonly ACTION_OnPointerOutTrigger: number;
  86435. /**
  86436. * On every frame
  86437. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86438. */
  86439. static readonly ACTION_OnEveryFrameTrigger: number;
  86440. /**
  86441. * On intersection enter
  86442. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86443. */
  86444. static readonly ACTION_OnIntersectionEnterTrigger: number;
  86445. /**
  86446. * On intersection exit
  86447. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86448. */
  86449. static readonly ACTION_OnIntersectionExitTrigger: number;
  86450. /**
  86451. * On key down
  86452. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86453. */
  86454. static readonly ACTION_OnKeyDownTrigger: number;
  86455. /**
  86456. * On key up
  86457. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86458. */
  86459. static readonly ACTION_OnKeyUpTrigger: number;
  86460. /**
  86461. * Billboard mode will only apply to Y axis
  86462. */
  86463. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  86464. /**
  86465. * Billboard mode will apply to all axes
  86466. */
  86467. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  86468. /**
  86469. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86470. */
  86471. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  86472. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  86473. * Test order :
  86474. * Is the bounding sphere outside the frustum ?
  86475. * If not, are the bounding box vertices outside the frustum ?
  86476. * It not, then the cullable object is in the frustum.
  86477. */
  86478. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  86479. /** Culling strategy : Bounding Sphere Only.
  86480. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  86481. * It's also less accurate than the standard because some not visible objects can still be selected.
  86482. * Test : is the bounding sphere outside the frustum ?
  86483. * If not, then the cullable object is in the frustum.
  86484. */
  86485. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  86486. /** Culling strategy : Optimistic Inclusion.
  86487. * This in an inclusion test first, then the standard exclusion test.
  86488. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  86489. * 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.
  86490. * Anyway, it's as accurate as the standard strategy.
  86491. * Test :
  86492. * Is the cullable object bounding sphere center in the frustum ?
  86493. * If not, apply the default culling strategy.
  86494. */
  86495. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  86496. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  86497. * This in an inclusion test first, then the bounding sphere only exclusion test.
  86498. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  86499. * 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.
  86500. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  86501. * Test :
  86502. * Is the cullable object bounding sphere center in the frustum ?
  86503. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  86504. */
  86505. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  86506. /**
  86507. * No logging while loading
  86508. */
  86509. static readonly SCENELOADER_NO_LOGGING: number;
  86510. /**
  86511. * Minimal logging while loading
  86512. */
  86513. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  86514. /**
  86515. * Summary logging while loading
  86516. */
  86517. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  86518. /**
  86519. * Detailed logging while loading
  86520. */
  86521. static readonly SCENELOADER_DETAILED_LOGGING: number;
  86522. /**
  86523. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  86524. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  86525. */
  86526. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  86527. /**
  86528. * Constant used to retrieve the position texture index in the textures array in the prepass
  86529. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  86530. */
  86531. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  86532. /**
  86533. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  86534. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  86535. */
  86536. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  86537. /**
  86538. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  86539. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  86540. */
  86541. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  86542. /**
  86543. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  86544. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  86545. */
  86546. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  86547. /**
  86548. * Constant used to retrieve depth index in the textures array in the prepass
  86549. * using the getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE)
  86550. */
  86551. static readonly PREPASS_DEPTH_TEXTURE_TYPE: number;
  86552. /**
  86553. * Constant used to retrieve normal index in the textures array in the prepass
  86554. * using the getIndex(Constants.PREPASS_NORMAL_TEXTURE_TYPE)
  86555. */
  86556. static readonly PREPASS_NORMAL_TEXTURE_TYPE: number;
  86557. /**
  86558. * Constant used to retrieve albedo index in the textures array in the prepass
  86559. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  86560. */
  86561. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  86562. /**
  86563. * Prefixes used by the engine for custom effects
  86564. */
  86565. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  86566. }
  86567. }
  86568. declare module BABYLON {
  86569. /** @hidden */
  86570. export interface HardwareTextureWrapper {
  86571. underlyingResource: any;
  86572. set(hardwareTexture: any): void;
  86573. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  86574. reset(): void;
  86575. release(): void;
  86576. }
  86577. }
  86578. declare module BABYLON {
  86579. /**
  86580. * This represents the required contract to create a new type of texture loader.
  86581. */
  86582. export interface IInternalTextureLoader {
  86583. /**
  86584. * Defines whether the loader supports cascade loading the different faces.
  86585. */
  86586. supportCascades: boolean;
  86587. /**
  86588. * This returns if the loader support the current file information.
  86589. * @param extension defines the file extension of the file being loaded
  86590. * @param mimeType defines the optional mime type of the file being loaded
  86591. * @returns true if the loader can load the specified file
  86592. */
  86593. canLoad(extension: string, mimeType?: string): boolean;
  86594. /**
  86595. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  86596. * @param data contains the texture data
  86597. * @param texture defines the BabylonJS internal texture
  86598. * @param createPolynomials will be true if polynomials have been requested
  86599. * @param onLoad defines the callback to trigger once the texture is ready
  86600. * @param onError defines the callback to trigger in case of error
  86601. * @param options options to be passed to the loader
  86602. */
  86603. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  86604. /**
  86605. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  86606. * @param data contains the texture data
  86607. * @param texture defines the BabylonJS internal texture
  86608. * @param callback defines the method to call once ready to upload
  86609. * @param options options to be passed to the loader
  86610. */
  86611. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  86612. }
  86613. }
  86614. declare module BABYLON {
  86615. /**
  86616. * @hidden
  86617. */
  86618. export interface IColor4Like {
  86619. r: float;
  86620. g: float;
  86621. b: float;
  86622. a: float;
  86623. }
  86624. /**
  86625. * @hidden
  86626. */
  86627. export interface IColor3Like {
  86628. r: float;
  86629. g: float;
  86630. b: float;
  86631. }
  86632. /**
  86633. * @hidden
  86634. */
  86635. export interface IVector4Like {
  86636. x: float;
  86637. y: float;
  86638. z: float;
  86639. w: float;
  86640. }
  86641. /**
  86642. * @hidden
  86643. */
  86644. export interface IVector3Like {
  86645. x: float;
  86646. y: float;
  86647. z: float;
  86648. }
  86649. /**
  86650. * @hidden
  86651. */
  86652. export interface IVector2Like {
  86653. x: float;
  86654. y: float;
  86655. }
  86656. /**
  86657. * @hidden
  86658. */
  86659. export interface IMatrixLike {
  86660. toArray(): DeepImmutable<Float32Array | Array<number>>;
  86661. updateFlag: int;
  86662. }
  86663. /**
  86664. * @hidden
  86665. */
  86666. export interface IViewportLike {
  86667. x: float;
  86668. y: float;
  86669. width: float;
  86670. height: float;
  86671. }
  86672. /**
  86673. * @hidden
  86674. */
  86675. export interface IPlaneLike {
  86676. normal: IVector3Like;
  86677. d: float;
  86678. normalize(): void;
  86679. }
  86680. }
  86681. declare module BABYLON {
  86682. /**
  86683. * Class used to store and describe the pipeline context associated with an effect
  86684. */
  86685. export interface IPipelineContext {
  86686. /**
  86687. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  86688. */
  86689. isAsync: boolean;
  86690. /**
  86691. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  86692. */
  86693. isReady: boolean;
  86694. /** @hidden */
  86695. _name?: string;
  86696. /** @hidden */
  86697. _getVertexShaderCode(): string | null;
  86698. /** @hidden */
  86699. _getFragmentShaderCode(): string | null;
  86700. /** @hidden */
  86701. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  86702. /** @hidden */
  86703. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  86704. [key: string]: number;
  86705. }, uniformsNames: string[], uniforms: {
  86706. [key: string]: Nullable<WebGLUniformLocation>;
  86707. }, samplerList: string[], samplers: {
  86708. [key: string]: number;
  86709. }, attributesNames: string[], attributes: number[]): void;
  86710. /** Releases the resources associated with the pipeline. */
  86711. dispose(): void;
  86712. /**
  86713. * Sets an integer value on a uniform variable.
  86714. * @param uniformName Name of the variable.
  86715. * @param value Value to be set.
  86716. */
  86717. setInt(uniformName: string, value: number): void;
  86718. /**
  86719. * Sets an int2 value on a uniform variable.
  86720. * @param uniformName Name of the variable.
  86721. * @param x First int in int2.
  86722. * @param y Second int in int2.
  86723. */
  86724. setInt2(uniformName: string, x: number, y: number): void;
  86725. /**
  86726. * Sets an int3 value on a uniform variable.
  86727. * @param uniformName Name of the variable.
  86728. * @param x First int in int3.
  86729. * @param y Second int in int3.
  86730. * @param z Third int in int3.
  86731. */
  86732. setInt3(uniformName: string, x: number, y: number, z: number): void;
  86733. /**
  86734. * Sets an int4 value on a uniform variable.
  86735. * @param uniformName Name of the variable.
  86736. * @param x First int in int4.
  86737. * @param y Second int in int4.
  86738. * @param z Third int in int4.
  86739. * @param w Fourth int in int4.
  86740. */
  86741. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  86742. /**
  86743. * Sets an int array on a uniform variable.
  86744. * @param uniformName Name of the variable.
  86745. * @param array array to be set.
  86746. */
  86747. setIntArray(uniformName: string, array: Int32Array): void;
  86748. /**
  86749. * 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)
  86750. * @param uniformName Name of the variable.
  86751. * @param array array to be set.
  86752. */
  86753. setIntArray2(uniformName: string, array: Int32Array): void;
  86754. /**
  86755. * 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)
  86756. * @param uniformName Name of the variable.
  86757. * @param array array to be set.
  86758. */
  86759. setIntArray3(uniformName: string, array: Int32Array): void;
  86760. /**
  86761. * 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)
  86762. * @param uniformName Name of the variable.
  86763. * @param array array to be set.
  86764. */
  86765. setIntArray4(uniformName: string, array: Int32Array): void;
  86766. /**
  86767. * Sets an array on a uniform variable.
  86768. * @param uniformName Name of the variable.
  86769. * @param array array to be set.
  86770. */
  86771. setArray(uniformName: string, array: number[] | Float32Array): void;
  86772. /**
  86773. * 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)
  86774. * @param uniformName Name of the variable.
  86775. * @param array array to be set.
  86776. */
  86777. setArray2(uniformName: string, array: number[] | Float32Array): void;
  86778. /**
  86779. * 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)
  86780. * @param uniformName Name of the variable.
  86781. * @param array array to be set.
  86782. */
  86783. setArray3(uniformName: string, array: number[] | Float32Array): void;
  86784. /**
  86785. * 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)
  86786. * @param uniformName Name of the variable.
  86787. * @param array array to be set.
  86788. */
  86789. setArray4(uniformName: string, array: number[] | Float32Array): void;
  86790. /**
  86791. * Sets matrices on a uniform variable.
  86792. * @param uniformName Name of the variable.
  86793. * @param matrices matrices to be set.
  86794. */
  86795. setMatrices(uniformName: string, matrices: Float32Array): void;
  86796. /**
  86797. * Sets matrix on a uniform variable.
  86798. * @param uniformName Name of the variable.
  86799. * @param matrix matrix to be set.
  86800. */
  86801. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  86802. /**
  86803. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  86804. * @param uniformName Name of the variable.
  86805. * @param matrix matrix to be set.
  86806. */
  86807. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  86808. /**
  86809. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86810. * @param uniformName Name of the variable.
  86811. * @param matrix matrix to be set.
  86812. */
  86813. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  86814. /**
  86815. * Sets a float on a uniform variable.
  86816. * @param uniformName Name of the variable.
  86817. * @param value value to be set.
  86818. */
  86819. setFloat(uniformName: string, value: number): void;
  86820. /**
  86821. * Sets a Vector2 on a uniform variable.
  86822. * @param uniformName Name of the variable.
  86823. * @param vector2 vector2 to be set.
  86824. */
  86825. setVector2(uniformName: string, vector2: IVector2Like): void;
  86826. /**
  86827. * Sets a float2 on a uniform variable.
  86828. * @param uniformName Name of the variable.
  86829. * @param x First float in float2.
  86830. * @param y Second float in float2.
  86831. */
  86832. setFloat2(uniformName: string, x: number, y: number): void;
  86833. /**
  86834. * Sets a Vector3 on a uniform variable.
  86835. * @param uniformName Name of the variable.
  86836. * @param vector3 Value to be set.
  86837. */
  86838. setVector3(uniformName: string, vector3: IVector3Like): void;
  86839. /**
  86840. * Sets a float3 on a uniform variable.
  86841. * @param uniformName Name of the variable.
  86842. * @param x First float in float3.
  86843. * @param y Second float in float3.
  86844. * @param z Third float in float3.
  86845. */
  86846. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  86847. /**
  86848. * Sets a Vector4 on a uniform variable.
  86849. * @param uniformName Name of the variable.
  86850. * @param vector4 Value to be set.
  86851. */
  86852. setVector4(uniformName: string, vector4: IVector4Like): void;
  86853. /**
  86854. * Sets a float4 on a uniform variable.
  86855. * @param uniformName Name of the variable.
  86856. * @param x First float in float4.
  86857. * @param y Second float in float4.
  86858. * @param z Third float in float4.
  86859. * @param w Fourth float in float4.
  86860. */
  86861. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  86862. /**
  86863. * Sets a Color3 on a uniform variable.
  86864. * @param uniformName Name of the variable.
  86865. * @param color3 Value to be set.
  86866. */
  86867. setColor3(uniformName: string, color3: IColor3Like): void;
  86868. /**
  86869. * Sets a Color4 on a uniform variable.
  86870. * @param uniformName Name of the variable.
  86871. * @param color3 Value to be set.
  86872. * @param alpha Alpha value to be set.
  86873. */
  86874. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  86875. /**
  86876. * Sets a Color4 on a uniform variable
  86877. * @param uniformName defines the name of the variable
  86878. * @param color4 defines the value to be set
  86879. */
  86880. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  86881. }
  86882. }
  86883. declare module BABYLON {
  86884. /**
  86885. * Class used to store gfx data (like WebGLBuffer)
  86886. */
  86887. export class DataBuffer {
  86888. private static _Counter;
  86889. /**
  86890. * Gets or sets the number of objects referencing this buffer
  86891. */
  86892. references: number;
  86893. /** Gets or sets the size of the underlying buffer */
  86894. capacity: number;
  86895. /**
  86896. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  86897. */
  86898. is32Bits: boolean;
  86899. /**
  86900. * Gets the underlying buffer
  86901. */
  86902. get underlyingResource(): any;
  86903. /**
  86904. * Gets the unique id of this buffer
  86905. */
  86906. readonly uniqueId: number;
  86907. /**
  86908. * Constructs the buffer
  86909. */
  86910. constructor();
  86911. }
  86912. }
  86913. declare module BABYLON {
  86914. /** @hidden */
  86915. export interface IShaderProcessor {
  86916. attributeProcessor?: (attribute: string, preProcessors: {
  86917. [key: string]: string;
  86918. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86919. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  86920. [key: string]: string;
  86921. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86922. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  86923. [key: string]: string;
  86924. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  86925. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86926. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86927. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86928. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  86929. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  86930. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  86931. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  86932. vertexCode: string;
  86933. fragmentCode: string;
  86934. };
  86935. }
  86936. }
  86937. declare module BABYLON {
  86938. /** @hidden */
  86939. export interface ShaderProcessingContext {
  86940. }
  86941. /** @hidden */
  86942. export interface ProcessingOptions {
  86943. defines: string[];
  86944. indexParameters: any;
  86945. isFragment: boolean;
  86946. shouldUseHighPrecisionShader: boolean;
  86947. supportsUniformBuffers: boolean;
  86948. shadersRepository: string;
  86949. includesShadersStore: {
  86950. [key: string]: string;
  86951. };
  86952. processor: Nullable<IShaderProcessor>;
  86953. version: string;
  86954. platformName: string;
  86955. lookForClosingBracketForUniformBuffer?: boolean;
  86956. processingContext: Nullable<ShaderProcessingContext>;
  86957. }
  86958. }
  86959. declare module BABYLON {
  86960. /** @hidden */
  86961. export class ShaderCodeNode {
  86962. line: string;
  86963. children: ShaderCodeNode[];
  86964. additionalDefineKey?: string;
  86965. additionalDefineValue?: string;
  86966. isValid(preprocessors: {
  86967. [key: string]: string;
  86968. }): boolean;
  86969. process(preprocessors: {
  86970. [key: string]: string;
  86971. }, options: ProcessingOptions): string;
  86972. }
  86973. }
  86974. declare module BABYLON {
  86975. /** @hidden */
  86976. export class ShaderCodeCursor {
  86977. private _lines;
  86978. lineIndex: number;
  86979. get currentLine(): string;
  86980. get canRead(): boolean;
  86981. set lines(value: string[]);
  86982. }
  86983. }
  86984. declare module BABYLON {
  86985. /** @hidden */
  86986. export class ShaderCodeConditionNode extends ShaderCodeNode {
  86987. process(preprocessors: {
  86988. [key: string]: string;
  86989. }, options: ProcessingOptions): string;
  86990. }
  86991. }
  86992. declare module BABYLON {
  86993. /** @hidden */
  86994. export class ShaderDefineExpression {
  86995. isTrue(preprocessors: {
  86996. [key: string]: string;
  86997. }): boolean;
  86998. private static _OperatorPriority;
  86999. private static _Stack;
  87000. static postfixToInfix(postfix: string[]): string;
  87001. static infixToPostfix(infix: string): string[];
  87002. }
  87003. }
  87004. declare module BABYLON {
  87005. /** @hidden */
  87006. export class ShaderCodeTestNode extends ShaderCodeNode {
  87007. testExpression: ShaderDefineExpression;
  87008. isValid(preprocessors: {
  87009. [key: string]: string;
  87010. }): boolean;
  87011. }
  87012. }
  87013. declare module BABYLON {
  87014. /** @hidden */
  87015. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  87016. define: string;
  87017. not: boolean;
  87018. constructor(define: string, not?: boolean);
  87019. isTrue(preprocessors: {
  87020. [key: string]: string;
  87021. }): boolean;
  87022. }
  87023. }
  87024. declare module BABYLON {
  87025. /** @hidden */
  87026. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  87027. leftOperand: ShaderDefineExpression;
  87028. rightOperand: ShaderDefineExpression;
  87029. isTrue(preprocessors: {
  87030. [key: string]: string;
  87031. }): boolean;
  87032. }
  87033. }
  87034. declare module BABYLON {
  87035. /** @hidden */
  87036. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  87037. leftOperand: ShaderDefineExpression;
  87038. rightOperand: ShaderDefineExpression;
  87039. isTrue(preprocessors: {
  87040. [key: string]: string;
  87041. }): boolean;
  87042. }
  87043. }
  87044. declare module BABYLON {
  87045. /** @hidden */
  87046. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  87047. define: string;
  87048. operand: string;
  87049. testValue: string;
  87050. constructor(define: string, operand: string, testValue: string);
  87051. isTrue(preprocessors: {
  87052. [key: string]: string;
  87053. }): boolean;
  87054. }
  87055. }
  87056. declare module BABYLON {
  87057. /**
  87058. * Class used to enable access to offline support
  87059. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  87060. */
  87061. export interface IOfflineProvider {
  87062. /**
  87063. * Gets a boolean indicating if scene must be saved in the database
  87064. */
  87065. enableSceneOffline: boolean;
  87066. /**
  87067. * Gets a boolean indicating if textures must be saved in the database
  87068. */
  87069. enableTexturesOffline: boolean;
  87070. /**
  87071. * Open the offline support and make it available
  87072. * @param successCallback defines the callback to call on success
  87073. * @param errorCallback defines the callback to call on error
  87074. */
  87075. open(successCallback: () => void, errorCallback: () => void): void;
  87076. /**
  87077. * Loads an image from the offline support
  87078. * @param url defines the url to load from
  87079. * @param image defines the target DOM image
  87080. */
  87081. loadImage(url: string, image: HTMLImageElement): void;
  87082. /**
  87083. * Loads a file from offline support
  87084. * @param url defines the URL to load from
  87085. * @param sceneLoaded defines a callback to call on success
  87086. * @param progressCallBack defines a callback to call when progress changed
  87087. * @param errorCallback defines a callback to call on error
  87088. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  87089. */
  87090. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  87091. }
  87092. }
  87093. declare module BABYLON {
  87094. /**
  87095. * Class used to help managing file picking and drag'n'drop
  87096. * File Storage
  87097. */
  87098. export class FilesInputStore {
  87099. /**
  87100. * List of files ready to be loaded
  87101. */
  87102. static FilesToLoad: {
  87103. [key: string]: File;
  87104. };
  87105. }
  87106. }
  87107. declare module BABYLON {
  87108. /**
  87109. * Class used to define a retry strategy when error happens while loading assets
  87110. */
  87111. export class RetryStrategy {
  87112. /**
  87113. * Function used to defines an exponential back off strategy
  87114. * @param maxRetries defines the maximum number of retries (3 by default)
  87115. * @param baseInterval defines the interval between retries
  87116. * @returns the strategy function to use
  87117. */
  87118. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  87119. }
  87120. }
  87121. declare module BABYLON {
  87122. /**
  87123. * @ignore
  87124. * Application error to support additional information when loading a file
  87125. */
  87126. export abstract class BaseError extends Error {
  87127. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  87128. }
  87129. }
  87130. declare module BABYLON {
  87131. /** @ignore */
  87132. export class LoadFileError extends BaseError {
  87133. request?: WebRequest;
  87134. file?: File;
  87135. /**
  87136. * Creates a new LoadFileError
  87137. * @param message defines the message of the error
  87138. * @param request defines the optional web request
  87139. * @param file defines the optional file
  87140. */
  87141. constructor(message: string, object?: WebRequest | File);
  87142. }
  87143. /** @ignore */
  87144. export class RequestFileError extends BaseError {
  87145. request: WebRequest;
  87146. /**
  87147. * Creates a new LoadFileError
  87148. * @param message defines the message of the error
  87149. * @param request defines the optional web request
  87150. */
  87151. constructor(message: string, request: WebRequest);
  87152. }
  87153. /** @ignore */
  87154. export class ReadFileError extends BaseError {
  87155. file: File;
  87156. /**
  87157. * Creates a new ReadFileError
  87158. * @param message defines the message of the error
  87159. * @param file defines the optional file
  87160. */
  87161. constructor(message: string, file: File);
  87162. }
  87163. /**
  87164. * @hidden
  87165. */
  87166. export class FileTools {
  87167. /**
  87168. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87169. */
  87170. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  87171. /**
  87172. * Gets or sets the base URL to use to load assets
  87173. */
  87174. static BaseUrl: string;
  87175. /**
  87176. * Default behaviour for cors in the application.
  87177. * It can be a string if the expected behavior is identical in the entire app.
  87178. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87179. */
  87180. static CorsBehavior: string | ((url: string | string[]) => string);
  87181. /**
  87182. * Gets or sets a function used to pre-process url before using them to load assets
  87183. */
  87184. static PreprocessUrl: (url: string) => string;
  87185. /**
  87186. * Removes unwanted characters from an url
  87187. * @param url defines the url to clean
  87188. * @returns the cleaned url
  87189. */
  87190. private static _CleanUrl;
  87191. /**
  87192. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87193. * @param url define the url we are trying
  87194. * @param element define the dom element where to configure the cors policy
  87195. */
  87196. static SetCorsBehavior(url: string | string[], element: {
  87197. crossOrigin: string | null;
  87198. }): void;
  87199. /**
  87200. * Loads an image as an HTMLImageElement.
  87201. * @param input url string, ArrayBuffer, or Blob to load
  87202. * @param onLoad callback called when the image successfully loads
  87203. * @param onError callback called when the image fails to load
  87204. * @param offlineProvider offline provider for caching
  87205. * @param mimeType optional mime type
  87206. * @returns the HTMLImageElement of the loaded image
  87207. */
  87208. 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>;
  87209. /**
  87210. * Reads a file from a File object
  87211. * @param file defines the file to load
  87212. * @param onSuccess defines the callback to call when data is loaded
  87213. * @param onProgress defines the callback to call during loading process
  87214. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87215. * @param onError defines the callback to call when an error occurs
  87216. * @returns a file request object
  87217. */
  87218. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  87219. /**
  87220. * Loads a file from a url
  87221. * @param url url to load
  87222. * @param onSuccess callback called when the file successfully loads
  87223. * @param onProgress callback called while file is loading (if the server supports this mode)
  87224. * @param offlineProvider defines the offline provider for caching
  87225. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87226. * @param onError callback called when the file fails to load
  87227. * @returns a file request object
  87228. */
  87229. 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;
  87230. /**
  87231. * Loads a file
  87232. * @param url url to load
  87233. * @param onSuccess callback called when the file successfully loads
  87234. * @param onProgress callback called while file is loading (if the server supports this mode)
  87235. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87236. * @param onError callback called when the file fails to load
  87237. * @param onOpened callback called when the web request is opened
  87238. * @returns a file request object
  87239. */
  87240. 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;
  87241. /**
  87242. * Checks if the loaded document was accessed via `file:`-Protocol.
  87243. * @returns boolean
  87244. */
  87245. static IsFileURL(): boolean;
  87246. }
  87247. }
  87248. declare module BABYLON {
  87249. /** @hidden */
  87250. export class ShaderProcessor {
  87251. static Initialize(options: ProcessingOptions): void;
  87252. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  87253. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  87254. vertexCode: string;
  87255. fragmentCode: string;
  87256. };
  87257. private static _ProcessPrecision;
  87258. private static _ExtractOperation;
  87259. private static _BuildSubExpression;
  87260. private static _BuildExpression;
  87261. private static _MoveCursorWithinIf;
  87262. private static _MoveCursor;
  87263. private static _EvaluatePreProcessors;
  87264. private static _PreparePreProcessors;
  87265. private static _ProcessShaderConversion;
  87266. private static _ProcessIncludes;
  87267. /**
  87268. * Loads a file from a url
  87269. * @param url url to load
  87270. * @param onSuccess callback called when the file successfully loads
  87271. * @param onProgress callback called while file is loading (if the server supports this mode)
  87272. * @param offlineProvider defines the offline provider for caching
  87273. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87274. * @param onError callback called when the file fails to load
  87275. * @returns a file request object
  87276. * @hidden
  87277. */
  87278. 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;
  87279. }
  87280. }
  87281. declare module BABYLON {
  87282. /**
  87283. * Interface used to define common properties for effect fallbacks
  87284. */
  87285. export interface IEffectFallbacks {
  87286. /**
  87287. * Removes the defines that should be removed when falling back.
  87288. * @param currentDefines defines the current define statements for the shader.
  87289. * @param effect defines the current effect we try to compile
  87290. * @returns The resulting defines with defines of the current rank removed.
  87291. */
  87292. reduce(currentDefines: string, effect: Effect): string;
  87293. /**
  87294. * Removes the fallback from the bound mesh.
  87295. */
  87296. unBindMesh(): void;
  87297. /**
  87298. * Checks to see if more fallbacks are still available.
  87299. */
  87300. hasMoreFallbacks: boolean;
  87301. }
  87302. }
  87303. declare module BABYLON {
  87304. /**
  87305. * Interface for the size containing width and height
  87306. */
  87307. export interface ISize {
  87308. /**
  87309. * Width
  87310. */
  87311. width: number;
  87312. /**
  87313. * Heighht
  87314. */
  87315. height: number;
  87316. }
  87317. /**
  87318. * Size containing widht and height
  87319. */
  87320. export class Size implements ISize {
  87321. /**
  87322. * Width
  87323. */
  87324. width: number;
  87325. /**
  87326. * Height
  87327. */
  87328. height: number;
  87329. /**
  87330. * Creates a Size object from the given width and height (floats).
  87331. * @param width width of the new size
  87332. * @param height height of the new size
  87333. */
  87334. constructor(width: number, height: number);
  87335. /**
  87336. * Returns a string with the Size width and height
  87337. * @returns a string with the Size width and height
  87338. */
  87339. toString(): string;
  87340. /**
  87341. * "Size"
  87342. * @returns the string "Size"
  87343. */
  87344. getClassName(): string;
  87345. /**
  87346. * Returns the Size hash code.
  87347. * @returns a hash code for a unique width and height
  87348. */
  87349. getHashCode(): number;
  87350. /**
  87351. * Updates the current size from the given one.
  87352. * @param src the given size
  87353. */
  87354. copyFrom(src: Size): void;
  87355. /**
  87356. * Updates in place the current Size from the given floats.
  87357. * @param width width of the new size
  87358. * @param height height of the new size
  87359. * @returns the updated Size.
  87360. */
  87361. copyFromFloats(width: number, height: number): Size;
  87362. /**
  87363. * Updates in place the current Size from the given floats.
  87364. * @param width width to set
  87365. * @param height height to set
  87366. * @returns the updated Size.
  87367. */
  87368. set(width: number, height: number): Size;
  87369. /**
  87370. * Multiplies the width and height by numbers
  87371. * @param w factor to multiple the width by
  87372. * @param h factor to multiple the height by
  87373. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87374. */
  87375. multiplyByFloats(w: number, h: number): Size;
  87376. /**
  87377. * Clones the size
  87378. * @returns a new Size copied from the given one.
  87379. */
  87380. clone(): Size;
  87381. /**
  87382. * True if the current Size and the given one width and height are strictly equal.
  87383. * @param other the other size to compare against
  87384. * @returns True if the current Size and the given one width and height are strictly equal.
  87385. */
  87386. equals(other: Size): boolean;
  87387. /**
  87388. * The surface of the Size : width * height (float).
  87389. */
  87390. get surface(): number;
  87391. /**
  87392. * Create a new size of zero
  87393. * @returns a new Size set to (0.0, 0.0)
  87394. */
  87395. static Zero(): Size;
  87396. /**
  87397. * Sums the width and height of two sizes
  87398. * @param otherSize size to add to this size
  87399. * @returns a new Size set as the addition result of the current Size and the given one.
  87400. */
  87401. add(otherSize: Size): Size;
  87402. /**
  87403. * Subtracts the width and height of two
  87404. * @param otherSize size to subtract to this size
  87405. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87406. */
  87407. subtract(otherSize: Size): Size;
  87408. /**
  87409. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87410. * @param start starting size to lerp between
  87411. * @param end end size to lerp between
  87412. * @param amount amount to lerp between the start and end values
  87413. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87414. */
  87415. static Lerp(start: Size, end: Size, amount: number): Size;
  87416. }
  87417. }
  87418. declare module BABYLON {
  87419. /**
  87420. * Base class of all the textures in babylon.
  87421. * It groups all the common properties required to work with Thin Engine.
  87422. */
  87423. export class ThinTexture {
  87424. protected _wrapU: number;
  87425. /**
  87426. * | Value | Type | Description |
  87427. * | ----- | ------------------ | ----------- |
  87428. * | 0 | CLAMP_ADDRESSMODE | |
  87429. * | 1 | WRAP_ADDRESSMODE | |
  87430. * | 2 | MIRROR_ADDRESSMODE | |
  87431. */
  87432. get wrapU(): number;
  87433. set wrapU(value: number);
  87434. protected _wrapV: number;
  87435. /**
  87436. * | Value | Type | Description |
  87437. * | ----- | ------------------ | ----------- |
  87438. * | 0 | CLAMP_ADDRESSMODE | |
  87439. * | 1 | WRAP_ADDRESSMODE | |
  87440. * | 2 | MIRROR_ADDRESSMODE | |
  87441. */
  87442. get wrapV(): number;
  87443. set wrapV(value: number);
  87444. /**
  87445. * | Value | Type | Description |
  87446. * | ----- | ------------------ | ----------- |
  87447. * | 0 | CLAMP_ADDRESSMODE | |
  87448. * | 1 | WRAP_ADDRESSMODE | |
  87449. * | 2 | MIRROR_ADDRESSMODE | |
  87450. */
  87451. wrapR: number;
  87452. /**
  87453. * With compliant hardware and browser (supporting anisotropic filtering)
  87454. * this defines the level of anisotropic filtering in the texture.
  87455. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  87456. */
  87457. anisotropicFilteringLevel: number;
  87458. /**
  87459. * Define the current state of the loading sequence when in delayed load mode.
  87460. */
  87461. delayLoadState: number;
  87462. /**
  87463. * How a texture is mapped.
  87464. * Unused in thin texture mode.
  87465. */
  87466. get coordinatesMode(): number;
  87467. /**
  87468. * Define if the texture is a cube texture or if false a 2d texture.
  87469. */
  87470. get isCube(): boolean;
  87471. set isCube(value: boolean);
  87472. /**
  87473. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  87474. */
  87475. get is3D(): boolean;
  87476. set is3D(value: boolean);
  87477. /**
  87478. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  87479. */
  87480. get is2DArray(): boolean;
  87481. set is2DArray(value: boolean);
  87482. /**
  87483. * Get the class name of the texture.
  87484. * @returns "ThinTexture"
  87485. */
  87486. getClassName(): string;
  87487. /** @hidden */
  87488. _texture: Nullable<InternalTexture>;
  87489. protected _engine: Nullable<ThinEngine>;
  87490. private _cachedSize;
  87491. private _cachedBaseSize;
  87492. /**
  87493. * Instantiates a new ThinTexture.
  87494. * Base class of all the textures in babylon.
  87495. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  87496. * @param internalTexture Define the internalTexture to wrap
  87497. */
  87498. constructor(internalTexture: Nullable<InternalTexture>);
  87499. /**
  87500. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  87501. * @returns true if fully ready
  87502. */
  87503. isReady(): boolean;
  87504. /**
  87505. * Triggers the load sequence in delayed load mode.
  87506. */
  87507. delayLoad(): void;
  87508. /**
  87509. * Get the underlying lower level texture from Babylon.
  87510. * @returns the internal texture
  87511. */
  87512. getInternalTexture(): Nullable<InternalTexture>;
  87513. /**
  87514. * Get the size of the texture.
  87515. * @returns the texture size.
  87516. */
  87517. getSize(): ISize;
  87518. /**
  87519. * Get the base size of the texture.
  87520. * It can be different from the size if the texture has been resized for POT for instance
  87521. * @returns the base size
  87522. */
  87523. getBaseSize(): ISize;
  87524. /**
  87525. * Update the sampling mode of the texture.
  87526. * Default is Trilinear mode.
  87527. *
  87528. * | Value | Type | Description |
  87529. * | ----- | ------------------ | ----------- |
  87530. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  87531. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  87532. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  87533. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  87534. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  87535. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  87536. * | 7 | NEAREST_LINEAR | |
  87537. * | 8 | NEAREST_NEAREST | |
  87538. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  87539. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  87540. * | 11 | LINEAR_LINEAR | |
  87541. * | 12 | LINEAR_NEAREST | |
  87542. *
  87543. * > _mag_: magnification filter (close to the viewer)
  87544. * > _min_: minification filter (far from the viewer)
  87545. * > _mip_: filter used between mip map levels
  87546. *@param samplingMode Define the new sampling mode of the texture
  87547. */
  87548. updateSamplingMode(samplingMode: number): void;
  87549. /**
  87550. * Release and destroy the underlying lower level texture aka internalTexture.
  87551. */
  87552. releaseInternalTexture(): void;
  87553. /**
  87554. * Dispose the texture and release its associated resources.
  87555. */
  87556. dispose(): void;
  87557. }
  87558. }
  87559. declare module BABYLON {
  87560. /**
  87561. * Defines an array and its length.
  87562. * It can be helpful to group result from both Arrays and smart arrays in one structure.
  87563. */
  87564. export interface ISmartArrayLike<T> {
  87565. /**
  87566. * The data of the array.
  87567. */
  87568. data: Array<T>;
  87569. /**
  87570. * The active length of the array.
  87571. */
  87572. length: number;
  87573. }
  87574. /**
  87575. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87576. */
  87577. export class SmartArray<T> implements ISmartArrayLike<T> {
  87578. /**
  87579. * The full set of data from the array.
  87580. */
  87581. data: Array<T>;
  87582. /**
  87583. * The active length of the array.
  87584. */
  87585. length: number;
  87586. protected _id: number;
  87587. /**
  87588. * Instantiates a Smart Array.
  87589. * @param capacity defines the default capacity of the array.
  87590. */
  87591. constructor(capacity: number);
  87592. /**
  87593. * Pushes a value at the end of the active data.
  87594. * @param value defines the object to push in the array.
  87595. */
  87596. push(value: T): void;
  87597. /**
  87598. * Iterates over the active data and apply the lambda to them.
  87599. * @param func defines the action to apply on each value.
  87600. */
  87601. forEach(func: (content: T) => void): void;
  87602. /**
  87603. * Sorts the full sets of data.
  87604. * @param compareFn defines the comparison function to apply.
  87605. */
  87606. sort(compareFn: (a: T, b: T) => number): void;
  87607. /**
  87608. * Resets the active data to an empty array.
  87609. */
  87610. reset(): void;
  87611. /**
  87612. * Releases all the data from the array as well as the array.
  87613. */
  87614. dispose(): void;
  87615. /**
  87616. * Concats the active data with a given array.
  87617. * @param array defines the data to concatenate with.
  87618. */
  87619. concat(array: any): void;
  87620. /**
  87621. * Returns the position of a value in the active data.
  87622. * @param value defines the value to find the index for
  87623. * @returns the index if found in the active data otherwise -1
  87624. */
  87625. indexOf(value: T): number;
  87626. /**
  87627. * Returns whether an element is part of the active data.
  87628. * @param value defines the value to look for
  87629. * @returns true if found in the active data otherwise false
  87630. */
  87631. contains(value: T): boolean;
  87632. private static _GlobalId;
  87633. }
  87634. /**
  87635. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87636. * The data in this array can only be present once
  87637. */
  87638. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87639. private _duplicateId;
  87640. /**
  87641. * Pushes a value at the end of the active data.
  87642. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87643. * @param value defines the object to push in the array.
  87644. */
  87645. push(value: T): void;
  87646. /**
  87647. * Pushes a value at the end of the active data.
  87648. * If the data is already present, it won t be added again
  87649. * @param value defines the object to push in the array.
  87650. * @returns true if added false if it was already present
  87651. */
  87652. pushNoDuplicate(value: T): boolean;
  87653. /**
  87654. * Resets the active data to an empty array.
  87655. */
  87656. reset(): void;
  87657. /**
  87658. * Concats the active data with a given array.
  87659. * This ensures no duplicate will be present in the result.
  87660. * @param array defines the data to concatenate with.
  87661. */
  87662. concatWithNoDuplicate(array: any): void;
  87663. }
  87664. }
  87665. declare module BABYLON {
  87666. /**
  87667. * Class used to evaluate queries containing `and` and `or` operators
  87668. */
  87669. export class AndOrNotEvaluator {
  87670. /**
  87671. * Evaluate a query
  87672. * @param query defines the query to evaluate
  87673. * @param evaluateCallback defines the callback used to filter result
  87674. * @returns true if the query matches
  87675. */
  87676. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  87677. private static _HandleParenthesisContent;
  87678. private static _SimplifyNegation;
  87679. }
  87680. }
  87681. declare module BABYLON {
  87682. /**
  87683. * Class used to store custom tags
  87684. */
  87685. export class Tags {
  87686. /**
  87687. * Adds support for tags on the given object
  87688. * @param obj defines the object to use
  87689. */
  87690. static EnableFor(obj: any): void;
  87691. /**
  87692. * Removes tags support
  87693. * @param obj defines the object to use
  87694. */
  87695. static DisableFor(obj: any): void;
  87696. /**
  87697. * Gets a boolean indicating if the given object has tags
  87698. * @param obj defines the object to use
  87699. * @returns a boolean
  87700. */
  87701. static HasTags(obj: any): boolean;
  87702. /**
  87703. * Gets the tags available on a given object
  87704. * @param obj defines the object to use
  87705. * @param asString defines if the tags must be returned as a string instead of an array of strings
  87706. * @returns the tags
  87707. */
  87708. static GetTags(obj: any, asString?: boolean): any;
  87709. /**
  87710. * Adds tags to an object
  87711. * @param obj defines the object to use
  87712. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  87713. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  87714. */
  87715. static AddTagsTo(obj: any, tagsString: string): void;
  87716. /**
  87717. * @hidden
  87718. */
  87719. static _AddTagTo(obj: any, tag: string): void;
  87720. /**
  87721. * Removes specific tags from a specific object
  87722. * @param obj defines the object to use
  87723. * @param tagsString defines the tags to remove
  87724. */
  87725. static RemoveTagsFrom(obj: any, tagsString: string): void;
  87726. /**
  87727. * @hidden
  87728. */
  87729. static _RemoveTagFrom(obj: any, tag: string): void;
  87730. /**
  87731. * Defines if tags hosted on an object match a given query
  87732. * @param obj defines the object to use
  87733. * @param tagsQuery defines the tag query
  87734. * @returns a boolean
  87735. */
  87736. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  87737. }
  87738. }
  87739. declare module BABYLON {
  87740. /**
  87741. * Scalar computation library
  87742. */
  87743. export class Scalar {
  87744. /**
  87745. * Two pi constants convenient for computation.
  87746. */
  87747. static TwoPi: number;
  87748. /**
  87749. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  87750. * @param a number
  87751. * @param b number
  87752. * @param epsilon (default = 1.401298E-45)
  87753. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  87754. */
  87755. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  87756. /**
  87757. * Returns a string : the upper case translation of the number i to hexadecimal.
  87758. * @param i number
  87759. * @returns the upper case translation of the number i to hexadecimal.
  87760. */
  87761. static ToHex(i: number): string;
  87762. /**
  87763. * Returns -1 if value is negative and +1 is value is positive.
  87764. * @param value the value
  87765. * @returns the value itself if it's equal to zero.
  87766. */
  87767. static Sign(value: number): number;
  87768. /**
  87769. * Returns the value itself if it's between min and max.
  87770. * Returns min if the value is lower than min.
  87771. * Returns max if the value is greater than max.
  87772. * @param value the value to clmap
  87773. * @param min the min value to clamp to (default: 0)
  87774. * @param max the max value to clamp to (default: 1)
  87775. * @returns the clamped value
  87776. */
  87777. static Clamp(value: number, min?: number, max?: number): number;
  87778. /**
  87779. * the log2 of value.
  87780. * @param value the value to compute log2 of
  87781. * @returns the log2 of value.
  87782. */
  87783. static Log2(value: number): number;
  87784. /**
  87785. * the floor part of a log2 value.
  87786. * @param value the value to compute log2 of
  87787. * @returns the log2 of value.
  87788. */
  87789. static ILog2(value: number): number;
  87790. /**
  87791. * Loops the value, so that it is never larger than length and never smaller than 0.
  87792. *
  87793. * This is similar to the modulo operator but it works with floating point numbers.
  87794. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  87795. * With t = 5 and length = 2.5, the result would be 0.0.
  87796. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  87797. * @param value the value
  87798. * @param length the length
  87799. * @returns the looped value
  87800. */
  87801. static Repeat(value: number, length: number): number;
  87802. /**
  87803. * Normalize the value between 0.0 and 1.0 using min and max values
  87804. * @param value value to normalize
  87805. * @param min max to normalize between
  87806. * @param max min to normalize between
  87807. * @returns the normalized value
  87808. */
  87809. static Normalize(value: number, min: number, max: number): number;
  87810. /**
  87811. * Denormalize the value from 0.0 and 1.0 using min and max values
  87812. * @param normalized value to denormalize
  87813. * @param min max to denormalize between
  87814. * @param max min to denormalize between
  87815. * @returns the denormalized value
  87816. */
  87817. static Denormalize(normalized: number, min: number, max: number): number;
  87818. /**
  87819. * Calculates the shortest difference between two given angles given in degrees.
  87820. * @param current current angle in degrees
  87821. * @param target target angle in degrees
  87822. * @returns the delta
  87823. */
  87824. static DeltaAngle(current: number, target: number): number;
  87825. /**
  87826. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  87827. * @param tx value
  87828. * @param length length
  87829. * @returns The returned value will move back and forth between 0 and length
  87830. */
  87831. static PingPong(tx: number, length: number): number;
  87832. /**
  87833. * Interpolates between min and max with smoothing at the limits.
  87834. *
  87835. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  87836. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  87837. * @param from from
  87838. * @param to to
  87839. * @param tx value
  87840. * @returns the smooth stepped value
  87841. */
  87842. static SmoothStep(from: number, to: number, tx: number): number;
  87843. /**
  87844. * Moves a value current towards target.
  87845. *
  87846. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  87847. * Negative values of maxDelta pushes the value away from target.
  87848. * @param current current value
  87849. * @param target target value
  87850. * @param maxDelta max distance to move
  87851. * @returns resulting value
  87852. */
  87853. static MoveTowards(current: number, target: number, maxDelta: number): number;
  87854. /**
  87855. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  87856. *
  87857. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  87858. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  87859. * @param current current value
  87860. * @param target target value
  87861. * @param maxDelta max distance to move
  87862. * @returns resulting angle
  87863. */
  87864. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  87865. /**
  87866. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  87867. * @param start start value
  87868. * @param end target value
  87869. * @param amount amount to lerp between
  87870. * @returns the lerped value
  87871. */
  87872. static Lerp(start: number, end: number, amount: number): number;
  87873. /**
  87874. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  87875. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  87876. * @param start start value
  87877. * @param end target value
  87878. * @param amount amount to lerp between
  87879. * @returns the lerped value
  87880. */
  87881. static LerpAngle(start: number, end: number, amount: number): number;
  87882. /**
  87883. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  87884. * @param a start value
  87885. * @param b target value
  87886. * @param value value between a and b
  87887. * @returns the inverseLerp value
  87888. */
  87889. static InverseLerp(a: number, b: number, value: number): number;
  87890. /**
  87891. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  87892. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  87893. * @param value1 spline value
  87894. * @param tangent1 spline value
  87895. * @param value2 spline value
  87896. * @param tangent2 spline value
  87897. * @param amount input value
  87898. * @returns hermite result
  87899. */
  87900. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  87901. /**
  87902. * Returns a random float number between and min and max values
  87903. * @param min min value of random
  87904. * @param max max value of random
  87905. * @returns random value
  87906. */
  87907. static RandomRange(min: number, max: number): number;
  87908. /**
  87909. * This function returns percentage of a number in a given range.
  87910. *
  87911. * RangeToPercent(40,20,60) will return 0.5 (50%)
  87912. * RangeToPercent(34,0,100) will return 0.34 (34%)
  87913. * @param number to convert to percentage
  87914. * @param min min range
  87915. * @param max max range
  87916. * @returns the percentage
  87917. */
  87918. static RangeToPercent(number: number, min: number, max: number): number;
  87919. /**
  87920. * This function returns number that corresponds to the percentage in a given range.
  87921. *
  87922. * PercentToRange(0.34,0,100) will return 34.
  87923. * @param percent to convert to number
  87924. * @param min min range
  87925. * @param max max range
  87926. * @returns the number
  87927. */
  87928. static PercentToRange(percent: number, min: number, max: number): number;
  87929. /**
  87930. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  87931. * @param angle The angle to normalize in radian.
  87932. * @return The converted angle.
  87933. */
  87934. static NormalizeRadians(angle: number): number;
  87935. }
  87936. }
  87937. declare module BABYLON {
  87938. /**
  87939. * Constant used to convert a value to gamma space
  87940. * @ignorenaming
  87941. */
  87942. export const ToGammaSpace: number;
  87943. /**
  87944. * Constant used to convert a value to linear space
  87945. * @ignorenaming
  87946. */
  87947. export const ToLinearSpace = 2.2;
  87948. /**
  87949. * Constant used to define the minimal number value in Babylon.js
  87950. * @ignorenaming
  87951. */
  87952. let Epsilon: number;
  87953. }
  87954. declare module BABYLON {
  87955. /**
  87956. * Class used to represent a viewport on screen
  87957. */
  87958. export class Viewport {
  87959. /** viewport left coordinate */
  87960. x: number;
  87961. /** viewport top coordinate */
  87962. y: number;
  87963. /**viewport width */
  87964. width: number;
  87965. /** viewport height */
  87966. height: number;
  87967. /**
  87968. * Creates a Viewport object located at (x, y) and sized (width, height)
  87969. * @param x defines viewport left coordinate
  87970. * @param y defines viewport top coordinate
  87971. * @param width defines the viewport width
  87972. * @param height defines the viewport height
  87973. */
  87974. constructor(
  87975. /** viewport left coordinate */
  87976. x: number,
  87977. /** viewport top coordinate */
  87978. y: number,
  87979. /**viewport width */
  87980. width: number,
  87981. /** viewport height */
  87982. height: number);
  87983. /**
  87984. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  87985. * @param renderWidth defines the rendering width
  87986. * @param renderHeight defines the rendering height
  87987. * @returns a new Viewport
  87988. */
  87989. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  87990. /**
  87991. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  87992. * @param renderWidth defines the rendering width
  87993. * @param renderHeight defines the rendering height
  87994. * @param ref defines the target viewport
  87995. * @returns the current viewport
  87996. */
  87997. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  87998. /**
  87999. * Returns a new Viewport copied from the current one
  88000. * @returns a new Viewport
  88001. */
  88002. clone(): Viewport;
  88003. }
  88004. }
  88005. declare module BABYLON {
  88006. /**
  88007. * Class containing a set of static utilities functions for arrays.
  88008. */
  88009. export class ArrayTools {
  88010. /**
  88011. * Returns an array of the given size filled with element built from the given constructor and the parameters
  88012. * @param size the number of element to construct and put in the array
  88013. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  88014. * @returns a new array filled with new objects
  88015. */
  88016. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  88017. }
  88018. }
  88019. declare module BABYLON {
  88020. /**
  88021. * Represents a plane by the equation ax + by + cz + d = 0
  88022. */
  88023. export class Plane {
  88024. private static _TmpMatrix;
  88025. /**
  88026. * Normal of the plane (a,b,c)
  88027. */
  88028. normal: Vector3;
  88029. /**
  88030. * d component of the plane
  88031. */
  88032. d: number;
  88033. /**
  88034. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  88035. * @param a a component of the plane
  88036. * @param b b component of the plane
  88037. * @param c c component of the plane
  88038. * @param d d component of the plane
  88039. */
  88040. constructor(a: number, b: number, c: number, d: number);
  88041. /**
  88042. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  88043. */
  88044. asArray(): number[];
  88045. /**
  88046. * @returns a new plane copied from the current Plane.
  88047. */
  88048. clone(): Plane;
  88049. /**
  88050. * @returns the string "Plane".
  88051. */
  88052. getClassName(): string;
  88053. /**
  88054. * @returns the Plane hash code.
  88055. */
  88056. getHashCode(): number;
  88057. /**
  88058. * Normalize the current Plane in place.
  88059. * @returns the updated Plane.
  88060. */
  88061. normalize(): Plane;
  88062. /**
  88063. * Applies a transformation the plane and returns the result
  88064. * @param transformation the transformation matrix to be applied to the plane
  88065. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  88066. */
  88067. transform(transformation: DeepImmutable<Matrix>): Plane;
  88068. /**
  88069. * Compute the dot product between the point and the plane normal
  88070. * @param point point to calculate the dot product with
  88071. * @returns the dot product (float) of the point coordinates and the plane normal.
  88072. */
  88073. dotCoordinate(point: DeepImmutable<Vector3>): number;
  88074. /**
  88075. * Updates the current Plane from the plane defined by the three given points.
  88076. * @param point1 one of the points used to contruct the plane
  88077. * @param point2 one of the points used to contruct the plane
  88078. * @param point3 one of the points used to contruct the plane
  88079. * @returns the updated Plane.
  88080. */
  88081. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  88082. /**
  88083. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  88084. * Note that for this function to work as expected you should make sure that:
  88085. * - direction and the plane normal are normalized
  88086. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  88087. * @param direction the direction to check if the plane is facing
  88088. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  88089. * @returns True if the plane is facing the given direction
  88090. */
  88091. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  88092. /**
  88093. * Calculates the distance to a point
  88094. * @param point point to calculate distance to
  88095. * @returns the signed distance (float) from the given point to the Plane.
  88096. */
  88097. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  88098. /**
  88099. * Creates a plane from an array
  88100. * @param array the array to create a plane from
  88101. * @returns a new Plane from the given array.
  88102. */
  88103. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  88104. /**
  88105. * Creates a plane from three points
  88106. * @param point1 point used to create the plane
  88107. * @param point2 point used to create the plane
  88108. * @param point3 point used to create the plane
  88109. * @returns a new Plane defined by the three given points.
  88110. */
  88111. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  88112. /**
  88113. * Creates a plane from an origin point and a normal
  88114. * @param origin origin of the plane to be constructed
  88115. * @param normal normal of the plane to be constructed
  88116. * @returns a new Plane the normal vector to this plane at the given origin point.
  88117. * Note : the vector "normal" is updated because normalized.
  88118. */
  88119. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  88120. /**
  88121. * Calculates the distance from a plane and a point
  88122. * @param origin origin of the plane to be constructed
  88123. * @param normal normal of the plane to be constructed
  88124. * @param point point to calculate distance to
  88125. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  88126. */
  88127. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  88128. }
  88129. }
  88130. declare module BABYLON {
  88131. /** @hidden */
  88132. export class PerformanceConfigurator {
  88133. /** @hidden */
  88134. static MatrixUse64Bits: boolean;
  88135. /** @hidden */
  88136. static MatrixTrackPrecisionChange: boolean;
  88137. /** @hidden */
  88138. static MatrixCurrentType: any;
  88139. /** @hidden */
  88140. static MatrixTrackedMatrices: Array<any> | null;
  88141. /** @hidden */
  88142. static SetMatrixPrecision(use64bits: boolean): void;
  88143. }
  88144. }
  88145. declare module BABYLON {
  88146. /**
  88147. * Class representing a vector containing 2 coordinates
  88148. */
  88149. export class Vector2 {
  88150. /** defines the first coordinate */
  88151. x: number;
  88152. /** defines the second coordinate */
  88153. y: number;
  88154. /**
  88155. * Creates a new Vector2 from the given x and y coordinates
  88156. * @param x defines the first coordinate
  88157. * @param y defines the second coordinate
  88158. */
  88159. constructor(
  88160. /** defines the first coordinate */
  88161. x?: number,
  88162. /** defines the second coordinate */
  88163. y?: number);
  88164. /**
  88165. * Gets a string with the Vector2 coordinates
  88166. * @returns a string with the Vector2 coordinates
  88167. */
  88168. toString(): string;
  88169. /**
  88170. * Gets class name
  88171. * @returns the string "Vector2"
  88172. */
  88173. getClassName(): string;
  88174. /**
  88175. * Gets current vector hash code
  88176. * @returns the Vector2 hash code as a number
  88177. */
  88178. getHashCode(): number;
  88179. /**
  88180. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  88181. * @param array defines the source array
  88182. * @param index defines the offset in source array
  88183. * @returns the current Vector2
  88184. */
  88185. toArray(array: FloatArray, index?: number): Vector2;
  88186. /**
  88187. * Update the current vector from an array
  88188. * @param array defines the destination array
  88189. * @param index defines the offset in the destination array
  88190. * @returns the current Vector3
  88191. */
  88192. fromArray(array: FloatArray, index?: number): Vector2;
  88193. /**
  88194. * Copy the current vector to an array
  88195. * @returns a new array with 2 elements: the Vector2 coordinates.
  88196. */
  88197. asArray(): number[];
  88198. /**
  88199. * Sets the Vector2 coordinates with the given Vector2 coordinates
  88200. * @param source defines the source Vector2
  88201. * @returns the current updated Vector2
  88202. */
  88203. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  88204. /**
  88205. * Sets the Vector2 coordinates with the given floats
  88206. * @param x defines the first coordinate
  88207. * @param y defines the second coordinate
  88208. * @returns the current updated Vector2
  88209. */
  88210. copyFromFloats(x: number, y: number): Vector2;
  88211. /**
  88212. * Sets the Vector2 coordinates with the given floats
  88213. * @param x defines the first coordinate
  88214. * @param y defines the second coordinate
  88215. * @returns the current updated Vector2
  88216. */
  88217. set(x: number, y: number): Vector2;
  88218. /**
  88219. * Add another vector with the current one
  88220. * @param otherVector defines the other vector
  88221. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  88222. */
  88223. add(otherVector: DeepImmutable<Vector2>): Vector2;
  88224. /**
  88225. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  88226. * @param otherVector defines the other vector
  88227. * @param result defines the target vector
  88228. * @returns the unmodified current Vector2
  88229. */
  88230. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  88231. /**
  88232. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  88233. * @param otherVector defines the other vector
  88234. * @returns the current updated Vector2
  88235. */
  88236. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  88237. /**
  88238. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  88239. * @param otherVector defines the other vector
  88240. * @returns a new Vector2
  88241. */
  88242. addVector3(otherVector: Vector3): Vector2;
  88243. /**
  88244. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  88245. * @param otherVector defines the other vector
  88246. * @returns a new Vector2
  88247. */
  88248. subtract(otherVector: Vector2): Vector2;
  88249. /**
  88250. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  88251. * @param otherVector defines the other vector
  88252. * @param result defines the target vector
  88253. * @returns the unmodified current Vector2
  88254. */
  88255. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  88256. /**
  88257. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  88258. * @param otherVector defines the other vector
  88259. * @returns the current updated Vector2
  88260. */
  88261. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  88262. /**
  88263. * Multiplies in place the current Vector2 coordinates by the given ones
  88264. * @param otherVector defines the other vector
  88265. * @returns the current updated Vector2
  88266. */
  88267. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  88268. /**
  88269. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  88270. * @param otherVector defines the other vector
  88271. * @returns a new Vector2
  88272. */
  88273. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  88274. /**
  88275. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  88276. * @param otherVector defines the other vector
  88277. * @param result defines the target vector
  88278. * @returns the unmodified current Vector2
  88279. */
  88280. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  88281. /**
  88282. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  88283. * @param x defines the first coordinate
  88284. * @param y defines the second coordinate
  88285. * @returns a new Vector2
  88286. */
  88287. multiplyByFloats(x: number, y: number): Vector2;
  88288. /**
  88289. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  88290. * @param otherVector defines the other vector
  88291. * @returns a new Vector2
  88292. */
  88293. divide(otherVector: Vector2): Vector2;
  88294. /**
  88295. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  88296. * @param otherVector defines the other vector
  88297. * @param result defines the target vector
  88298. * @returns the unmodified current Vector2
  88299. */
  88300. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  88301. /**
  88302. * Divides the current Vector2 coordinates by the given ones
  88303. * @param otherVector defines the other vector
  88304. * @returns the current updated Vector2
  88305. */
  88306. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  88307. /**
  88308. * Gets a new Vector2 with current Vector2 negated coordinates
  88309. * @returns a new Vector2
  88310. */
  88311. negate(): Vector2;
  88312. /**
  88313. * Negate this vector in place
  88314. * @returns this
  88315. */
  88316. negateInPlace(): Vector2;
  88317. /**
  88318. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  88319. * @param result defines the Vector3 object where to store the result
  88320. * @returns the current Vector2
  88321. */
  88322. negateToRef(result: Vector2): Vector2;
  88323. /**
  88324. * Multiply the Vector2 coordinates by scale
  88325. * @param scale defines the scaling factor
  88326. * @returns the current updated Vector2
  88327. */
  88328. scaleInPlace(scale: number): Vector2;
  88329. /**
  88330. * Returns a new Vector2 scaled by "scale" from the current Vector2
  88331. * @param scale defines the scaling factor
  88332. * @returns a new Vector2
  88333. */
  88334. scale(scale: number): Vector2;
  88335. /**
  88336. * Scale the current Vector2 values by a factor to a given Vector2
  88337. * @param scale defines the scale factor
  88338. * @param result defines the Vector2 object where to store the result
  88339. * @returns the unmodified current Vector2
  88340. */
  88341. scaleToRef(scale: number, result: Vector2): Vector2;
  88342. /**
  88343. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  88344. * @param scale defines the scale factor
  88345. * @param result defines the Vector2 object where to store the result
  88346. * @returns the unmodified current Vector2
  88347. */
  88348. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  88349. /**
  88350. * Gets a boolean if two vectors are equals
  88351. * @param otherVector defines the other vector
  88352. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  88353. */
  88354. equals(otherVector: DeepImmutable<Vector2>): boolean;
  88355. /**
  88356. * Gets a boolean if two vectors are equals (using an epsilon value)
  88357. * @param otherVector defines the other vector
  88358. * @param epsilon defines the minimal distance to consider equality
  88359. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  88360. */
  88361. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  88362. /**
  88363. * Gets a new Vector2 from current Vector2 floored values
  88364. * @returns a new Vector2
  88365. */
  88366. floor(): Vector2;
  88367. /**
  88368. * Gets a new Vector2 from current Vector2 floored values
  88369. * @returns a new Vector2
  88370. */
  88371. fract(): Vector2;
  88372. /**
  88373. * Gets the length of the vector
  88374. * @returns the vector length (float)
  88375. */
  88376. length(): number;
  88377. /**
  88378. * Gets the vector squared length
  88379. * @returns the vector squared length (float)
  88380. */
  88381. lengthSquared(): number;
  88382. /**
  88383. * Normalize the vector
  88384. * @returns the current updated Vector2
  88385. */
  88386. normalize(): Vector2;
  88387. /**
  88388. * Gets a new Vector2 copied from the Vector2
  88389. * @returns a new Vector2
  88390. */
  88391. clone(): Vector2;
  88392. /**
  88393. * Gets a new Vector2(0, 0)
  88394. * @returns a new Vector2
  88395. */
  88396. static Zero(): Vector2;
  88397. /**
  88398. * Gets a new Vector2(1, 1)
  88399. * @returns a new Vector2
  88400. */
  88401. static One(): Vector2;
  88402. /**
  88403. * Gets a new Vector2 set from the given index element of the given array
  88404. * @param array defines the data source
  88405. * @param offset defines the offset in the data source
  88406. * @returns a new Vector2
  88407. */
  88408. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  88409. /**
  88410. * Sets "result" from the given index element of the given array
  88411. * @param array defines the data source
  88412. * @param offset defines the offset in the data source
  88413. * @param result defines the target vector
  88414. */
  88415. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  88416. /**
  88417. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  88418. * @param value1 defines 1st point of control
  88419. * @param value2 defines 2nd point of control
  88420. * @param value3 defines 3rd point of control
  88421. * @param value4 defines 4th point of control
  88422. * @param amount defines the interpolation factor
  88423. * @returns a new Vector2
  88424. */
  88425. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  88426. /**
  88427. * 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".
  88428. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  88429. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  88430. * @param value defines the value to clamp
  88431. * @param min defines the lower limit
  88432. * @param max defines the upper limit
  88433. * @returns a new Vector2
  88434. */
  88435. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  88436. /**
  88437. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  88438. * @param value1 defines the 1st control point
  88439. * @param tangent1 defines the outgoing tangent
  88440. * @param value2 defines the 2nd control point
  88441. * @param tangent2 defines the incoming tangent
  88442. * @param amount defines the interpolation factor
  88443. * @returns a new Vector2
  88444. */
  88445. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  88446. /**
  88447. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  88448. * @param start defines the start vector
  88449. * @param end defines the end vector
  88450. * @param amount defines the interpolation factor
  88451. * @returns a new Vector2
  88452. */
  88453. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  88454. /**
  88455. * Gets the dot product of the vector "left" and the vector "right"
  88456. * @param left defines first vector
  88457. * @param right defines second vector
  88458. * @returns the dot product (float)
  88459. */
  88460. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  88461. /**
  88462. * Returns a new Vector2 equal to the normalized given vector
  88463. * @param vector defines the vector to normalize
  88464. * @returns a new Vector2
  88465. */
  88466. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  88467. /**
  88468. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  88469. * @param left defines 1st vector
  88470. * @param right defines 2nd vector
  88471. * @returns a new Vector2
  88472. */
  88473. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  88474. /**
  88475. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  88476. * @param left defines 1st vector
  88477. * @param right defines 2nd vector
  88478. * @returns a new Vector2
  88479. */
  88480. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  88481. /**
  88482. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  88483. * @param vector defines the vector to transform
  88484. * @param transformation defines the matrix to apply
  88485. * @returns a new Vector2
  88486. */
  88487. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  88488. /**
  88489. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  88490. * @param vector defines the vector to transform
  88491. * @param transformation defines the matrix to apply
  88492. * @param result defines the target vector
  88493. */
  88494. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  88495. /**
  88496. * Determines if a given vector is included in a triangle
  88497. * @param p defines the vector to test
  88498. * @param p0 defines 1st triangle point
  88499. * @param p1 defines 2nd triangle point
  88500. * @param p2 defines 3rd triangle point
  88501. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  88502. */
  88503. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  88504. /**
  88505. * Gets the distance between the vectors "value1" and "value2"
  88506. * @param value1 defines first vector
  88507. * @param value2 defines second vector
  88508. * @returns the distance between vectors
  88509. */
  88510. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  88511. /**
  88512. * Returns the squared distance between the vectors "value1" and "value2"
  88513. * @param value1 defines first vector
  88514. * @param value2 defines second vector
  88515. * @returns the squared distance between vectors
  88516. */
  88517. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  88518. /**
  88519. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  88520. * @param value1 defines first vector
  88521. * @param value2 defines second vector
  88522. * @returns a new Vector2
  88523. */
  88524. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  88525. /**
  88526. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  88527. * @param value1 defines first vector
  88528. * @param value2 defines second vector
  88529. * @param ref defines third vector
  88530. * @returns ref
  88531. */
  88532. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  88533. /**
  88534. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  88535. * @param p defines the middle point
  88536. * @param segA defines one point of the segment
  88537. * @param segB defines the other point of the segment
  88538. * @returns the shortest distance
  88539. */
  88540. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  88541. }
  88542. /**
  88543. * Class used to store (x,y,z) vector representation
  88544. * A Vector3 is the main object used in 3D geometry
  88545. * It can represent etiher the coordinates of a point the space, either a direction
  88546. * Reminder: js uses a left handed forward facing system
  88547. */
  88548. export class Vector3 {
  88549. private static _UpReadOnly;
  88550. private static _ZeroReadOnly;
  88551. /** @hidden */
  88552. _x: number;
  88553. /** @hidden */
  88554. _y: number;
  88555. /** @hidden */
  88556. _z: number;
  88557. /** @hidden */
  88558. _isDirty: boolean;
  88559. /** Gets or sets the x coordinate */
  88560. get x(): number;
  88561. set x(value: number);
  88562. /** Gets or sets the y coordinate */
  88563. get y(): number;
  88564. set y(value: number);
  88565. /** Gets or sets the z coordinate */
  88566. get z(): number;
  88567. set z(value: number);
  88568. /**
  88569. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  88570. * @param x defines the first coordinates (on X axis)
  88571. * @param y defines the second coordinates (on Y axis)
  88572. * @param z defines the third coordinates (on Z axis)
  88573. */
  88574. constructor(x?: number, y?: number, z?: number);
  88575. /**
  88576. * Creates a string representation of the Vector3
  88577. * @returns a string with the Vector3 coordinates.
  88578. */
  88579. toString(): string;
  88580. /**
  88581. * Gets the class name
  88582. * @returns the string "Vector3"
  88583. */
  88584. getClassName(): string;
  88585. /**
  88586. * Creates the Vector3 hash code
  88587. * @returns a number which tends to be unique between Vector3 instances
  88588. */
  88589. getHashCode(): number;
  88590. /**
  88591. * Creates an array containing three elements : the coordinates of the Vector3
  88592. * @returns a new array of numbers
  88593. */
  88594. asArray(): number[];
  88595. /**
  88596. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  88597. * @param array defines the destination array
  88598. * @param index defines the offset in the destination array
  88599. * @returns the current Vector3
  88600. */
  88601. toArray(array: FloatArray, index?: number): Vector3;
  88602. /**
  88603. * Update the current vector from an array
  88604. * @param array defines the destination array
  88605. * @param index defines the offset in the destination array
  88606. * @returns the current Vector3
  88607. */
  88608. fromArray(array: FloatArray, index?: number): Vector3;
  88609. /**
  88610. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  88611. * @returns a new Quaternion object, computed from the Vector3 coordinates
  88612. */
  88613. toQuaternion(): Quaternion;
  88614. /**
  88615. * Adds the given vector to the current Vector3
  88616. * @param otherVector defines the second operand
  88617. * @returns the current updated Vector3
  88618. */
  88619. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88620. /**
  88621. * Adds the given coordinates to the current Vector3
  88622. * @param x defines the x coordinate of the operand
  88623. * @param y defines the y coordinate of the operand
  88624. * @param z defines the z coordinate of the operand
  88625. * @returns the current updated Vector3
  88626. */
  88627. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88628. /**
  88629. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  88630. * @param otherVector defines the second operand
  88631. * @returns the resulting Vector3
  88632. */
  88633. add(otherVector: DeepImmutable<Vector3>): Vector3;
  88634. /**
  88635. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  88636. * @param otherVector defines the second operand
  88637. * @param result defines the Vector3 object where to store the result
  88638. * @returns the current Vector3
  88639. */
  88640. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88641. /**
  88642. * Subtract the given vector from the current Vector3
  88643. * @param otherVector defines the second operand
  88644. * @returns the current updated Vector3
  88645. */
  88646. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88647. /**
  88648. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  88649. * @param otherVector defines the second operand
  88650. * @returns the resulting Vector3
  88651. */
  88652. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  88653. /**
  88654. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  88655. * @param otherVector defines the second operand
  88656. * @param result defines the Vector3 object where to store the result
  88657. * @returns the current Vector3
  88658. */
  88659. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88660. /**
  88661. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  88662. * @param x defines the x coordinate of the operand
  88663. * @param y defines the y coordinate of the operand
  88664. * @param z defines the z coordinate of the operand
  88665. * @returns the resulting Vector3
  88666. */
  88667. subtractFromFloats(x: number, y: number, z: number): Vector3;
  88668. /**
  88669. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  88670. * @param x defines the x coordinate of the operand
  88671. * @param y defines the y coordinate of the operand
  88672. * @param z defines the z coordinate of the operand
  88673. * @param result defines the Vector3 object where to store the result
  88674. * @returns the current Vector3
  88675. */
  88676. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  88677. /**
  88678. * Gets a new Vector3 set with the current Vector3 negated coordinates
  88679. * @returns a new Vector3
  88680. */
  88681. negate(): Vector3;
  88682. /**
  88683. * Negate this vector in place
  88684. * @returns this
  88685. */
  88686. negateInPlace(): Vector3;
  88687. /**
  88688. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  88689. * @param result defines the Vector3 object where to store the result
  88690. * @returns the current Vector3
  88691. */
  88692. negateToRef(result: Vector3): Vector3;
  88693. /**
  88694. * Multiplies the Vector3 coordinates by the float "scale"
  88695. * @param scale defines the multiplier factor
  88696. * @returns the current updated Vector3
  88697. */
  88698. scaleInPlace(scale: number): Vector3;
  88699. /**
  88700. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  88701. * @param scale defines the multiplier factor
  88702. * @returns a new Vector3
  88703. */
  88704. scale(scale: number): Vector3;
  88705. /**
  88706. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  88707. * @param scale defines the multiplier factor
  88708. * @param result defines the Vector3 object where to store the result
  88709. * @returns the current Vector3
  88710. */
  88711. scaleToRef(scale: number, result: Vector3): Vector3;
  88712. /**
  88713. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  88714. * @param scale defines the scale factor
  88715. * @param result defines the Vector3 object where to store the result
  88716. * @returns the unmodified current Vector3
  88717. */
  88718. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  88719. /**
  88720. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  88721. * @param origin defines the origin of the projection ray
  88722. * @param plane defines the plane to project to
  88723. * @returns the projected vector3
  88724. */
  88725. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  88726. /**
  88727. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  88728. * @param origin defines the origin of the projection ray
  88729. * @param plane defines the plane to project to
  88730. * @param result defines the Vector3 where to store the result
  88731. */
  88732. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  88733. /**
  88734. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  88735. * @param otherVector defines the second operand
  88736. * @returns true if both vectors are equals
  88737. */
  88738. equals(otherVector: DeepImmutable<Vector3>): boolean;
  88739. /**
  88740. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  88741. * @param otherVector defines the second operand
  88742. * @param epsilon defines the minimal distance to define values as equals
  88743. * @returns true if both vectors are distant less than epsilon
  88744. */
  88745. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  88746. /**
  88747. * Returns true if the current Vector3 coordinates equals the given floats
  88748. * @param x defines the x coordinate of the operand
  88749. * @param y defines the y coordinate of the operand
  88750. * @param z defines the z coordinate of the operand
  88751. * @returns true if both vectors are equals
  88752. */
  88753. equalsToFloats(x: number, y: number, z: number): boolean;
  88754. /**
  88755. * Multiplies the current Vector3 coordinates by the given ones
  88756. * @param otherVector defines the second operand
  88757. * @returns the current updated Vector3
  88758. */
  88759. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  88760. /**
  88761. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  88762. * @param otherVector defines the second operand
  88763. * @returns the new Vector3
  88764. */
  88765. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  88766. /**
  88767. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  88768. * @param otherVector defines the second operand
  88769. * @param result defines the Vector3 object where to store the result
  88770. * @returns the current Vector3
  88771. */
  88772. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88773. /**
  88774. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  88775. * @param x defines the x coordinate of the operand
  88776. * @param y defines the y coordinate of the operand
  88777. * @param z defines the z coordinate of the operand
  88778. * @returns the new Vector3
  88779. */
  88780. multiplyByFloats(x: number, y: number, z: number): Vector3;
  88781. /**
  88782. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  88783. * @param otherVector defines the second operand
  88784. * @returns the new Vector3
  88785. */
  88786. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  88787. /**
  88788. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  88789. * @param otherVector defines the second operand
  88790. * @param result defines the Vector3 object where to store the result
  88791. * @returns the current Vector3
  88792. */
  88793. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  88794. /**
  88795. * Divides the current Vector3 coordinates by the given ones.
  88796. * @param otherVector defines the second operand
  88797. * @returns the current updated Vector3
  88798. */
  88799. divideInPlace(otherVector: Vector3): Vector3;
  88800. /**
  88801. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  88802. * @param other defines the second operand
  88803. * @returns the current updated Vector3
  88804. */
  88805. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  88806. /**
  88807. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  88808. * @param other defines the second operand
  88809. * @returns the current updated Vector3
  88810. */
  88811. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  88812. /**
  88813. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  88814. * @param x defines the x coordinate of the operand
  88815. * @param y defines the y coordinate of the operand
  88816. * @param z defines the z coordinate of the operand
  88817. * @returns the current updated Vector3
  88818. */
  88819. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88820. /**
  88821. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  88822. * @param x defines the x coordinate of the operand
  88823. * @param y defines the y coordinate of the operand
  88824. * @param z defines the z coordinate of the operand
  88825. * @returns the current updated Vector3
  88826. */
  88827. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  88828. /**
  88829. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  88830. * Check if is non uniform within a certain amount of decimal places to account for this
  88831. * @param epsilon the amount the values can differ
  88832. * @returns if the the vector is non uniform to a certain number of decimal places
  88833. */
  88834. isNonUniformWithinEpsilon(epsilon: number): boolean;
  88835. /**
  88836. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  88837. */
  88838. get isNonUniform(): boolean;
  88839. /**
  88840. * Gets a new Vector3 from current Vector3 floored values
  88841. * @returns a new Vector3
  88842. */
  88843. floor(): Vector3;
  88844. /**
  88845. * Gets a new Vector3 from current Vector3 floored values
  88846. * @returns a new Vector3
  88847. */
  88848. fract(): Vector3;
  88849. /**
  88850. * Gets the length of the Vector3
  88851. * @returns the length of the Vector3
  88852. */
  88853. length(): number;
  88854. /**
  88855. * Gets the squared length of the Vector3
  88856. * @returns squared length of the Vector3
  88857. */
  88858. lengthSquared(): number;
  88859. /**
  88860. * Normalize the current Vector3.
  88861. * Please note that this is an in place operation.
  88862. * @returns the current updated Vector3
  88863. */
  88864. normalize(): Vector3;
  88865. /**
  88866. * Reorders the x y z properties of the vector in place
  88867. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  88868. * @returns the current updated vector
  88869. */
  88870. reorderInPlace(order: string): this;
  88871. /**
  88872. * Rotates the vector around 0,0,0 by a quaternion
  88873. * @param quaternion the rotation quaternion
  88874. * @param result vector to store the result
  88875. * @returns the resulting vector
  88876. */
  88877. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  88878. /**
  88879. * Rotates a vector around a given point
  88880. * @param quaternion the rotation quaternion
  88881. * @param point the point to rotate around
  88882. * @param result vector to store the result
  88883. * @returns the resulting vector
  88884. */
  88885. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  88886. /**
  88887. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  88888. * The cross product is then orthogonal to both current and "other"
  88889. * @param other defines the right operand
  88890. * @returns the cross product
  88891. */
  88892. cross(other: Vector3): Vector3;
  88893. /**
  88894. * Normalize the current Vector3 with the given input length.
  88895. * Please note that this is an in place operation.
  88896. * @param len the length of the vector
  88897. * @returns the current updated Vector3
  88898. */
  88899. normalizeFromLength(len: number): Vector3;
  88900. /**
  88901. * Normalize the current Vector3 to a new vector
  88902. * @returns the new Vector3
  88903. */
  88904. normalizeToNew(): Vector3;
  88905. /**
  88906. * Normalize the current Vector3 to the reference
  88907. * @param reference define the Vector3 to update
  88908. * @returns the updated Vector3
  88909. */
  88910. normalizeToRef(reference: Vector3): Vector3;
  88911. /**
  88912. * Creates a new Vector3 copied from the current Vector3
  88913. * @returns the new Vector3
  88914. */
  88915. clone(): Vector3;
  88916. /**
  88917. * Copies the given vector coordinates to the current Vector3 ones
  88918. * @param source defines the source Vector3
  88919. * @returns the current updated Vector3
  88920. */
  88921. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  88922. /**
  88923. * Copies the given floats to the current Vector3 coordinates
  88924. * @param x defines the x coordinate of the operand
  88925. * @param y defines the y coordinate of the operand
  88926. * @param z defines the z coordinate of the operand
  88927. * @returns the current updated Vector3
  88928. */
  88929. copyFromFloats(x: number, y: number, z: number): Vector3;
  88930. /**
  88931. * Copies the given floats to the current Vector3 coordinates
  88932. * @param x defines the x coordinate of the operand
  88933. * @param y defines the y coordinate of the operand
  88934. * @param z defines the z coordinate of the operand
  88935. * @returns the current updated Vector3
  88936. */
  88937. set(x: number, y: number, z: number): Vector3;
  88938. /**
  88939. * Copies the given float to the current Vector3 coordinates
  88940. * @param v defines the x, y and z coordinates of the operand
  88941. * @returns the current updated Vector3
  88942. */
  88943. setAll(v: number): Vector3;
  88944. /**
  88945. * Get the clip factor between two vectors
  88946. * @param vector0 defines the first operand
  88947. * @param vector1 defines the second operand
  88948. * @param axis defines the axis to use
  88949. * @param size defines the size along the axis
  88950. * @returns the clip factor
  88951. */
  88952. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  88953. /**
  88954. * Get angle between two vectors
  88955. * @param vector0 angle between vector0 and vector1
  88956. * @param vector1 angle between vector0 and vector1
  88957. * @param normal direction of the normal
  88958. * @return the angle between vector0 and vector1
  88959. */
  88960. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  88961. /**
  88962. * Returns a new Vector3 set from the index "offset" of the given array
  88963. * @param array defines the source array
  88964. * @param offset defines the offset in the source array
  88965. * @returns the new Vector3
  88966. */
  88967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  88968. /**
  88969. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  88970. * @param array defines the source array
  88971. * @param offset defines the offset in the source array
  88972. * @returns the new Vector3
  88973. * @deprecated Please use FromArray instead.
  88974. */
  88975. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  88976. /**
  88977. * Sets the given vector "result" with the element values from the index "offset" of the given array
  88978. * @param array defines the source array
  88979. * @param offset defines the offset in the source array
  88980. * @param result defines the Vector3 where to store the result
  88981. */
  88982. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  88983. /**
  88984. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  88985. * @param array defines the source array
  88986. * @param offset defines the offset in the source array
  88987. * @param result defines the Vector3 where to store the result
  88988. * @deprecated Please use FromArrayToRef instead.
  88989. */
  88990. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  88991. /**
  88992. * Sets the given vector "result" with the given floats.
  88993. * @param x defines the x coordinate of the source
  88994. * @param y defines the y coordinate of the source
  88995. * @param z defines the z coordinate of the source
  88996. * @param result defines the Vector3 where to store the result
  88997. */
  88998. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  88999. /**
  89000. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  89001. * @returns a new empty Vector3
  89002. */
  89003. static Zero(): Vector3;
  89004. /**
  89005. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  89006. * @returns a new unit Vector3
  89007. */
  89008. static One(): Vector3;
  89009. /**
  89010. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  89011. * @returns a new up Vector3
  89012. */
  89013. static Up(): Vector3;
  89014. /**
  89015. * Gets a up Vector3 that must not be updated
  89016. */
  89017. static get UpReadOnly(): DeepImmutable<Vector3>;
  89018. /**
  89019. * Gets a zero Vector3 that must not be updated
  89020. */
  89021. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  89022. /**
  89023. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  89024. * @returns a new down Vector3
  89025. */
  89026. static Down(): Vector3;
  89027. /**
  89028. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  89029. * @param rightHandedSystem is the scene right-handed (negative z)
  89030. * @returns a new forward Vector3
  89031. */
  89032. static Forward(rightHandedSystem?: boolean): Vector3;
  89033. /**
  89034. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  89035. * @param rightHandedSystem is the scene right-handed (negative-z)
  89036. * @returns a new forward Vector3
  89037. */
  89038. static Backward(rightHandedSystem?: boolean): Vector3;
  89039. /**
  89040. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  89041. * @returns a new right Vector3
  89042. */
  89043. static Right(): Vector3;
  89044. /**
  89045. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  89046. * @returns a new left Vector3
  89047. */
  89048. static Left(): Vector3;
  89049. /**
  89050. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  89051. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  89052. * @param vector defines the Vector3 to transform
  89053. * @param transformation defines the transformation matrix
  89054. * @returns the transformed Vector3
  89055. */
  89056. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  89057. /**
  89058. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  89059. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  89060. * @param vector defines the Vector3 to transform
  89061. * @param transformation defines the transformation matrix
  89062. * @param result defines the Vector3 where to store the result
  89063. */
  89064. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  89065. /**
  89066. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  89067. * This method computes tranformed coordinates only, not transformed direction vectors
  89068. * @param x define the x coordinate of the source vector
  89069. * @param y define the y coordinate of the source vector
  89070. * @param z define the z coordinate of the source vector
  89071. * @param transformation defines the transformation matrix
  89072. * @param result defines the Vector3 where to store the result
  89073. */
  89074. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  89075. /**
  89076. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  89077. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  89078. * @param vector defines the Vector3 to transform
  89079. * @param transformation defines the transformation matrix
  89080. * @returns the new Vector3
  89081. */
  89082. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  89083. /**
  89084. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  89085. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  89086. * @param vector defines the Vector3 to transform
  89087. * @param transformation defines the transformation matrix
  89088. * @param result defines the Vector3 where to store the result
  89089. */
  89090. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  89091. /**
  89092. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  89093. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  89094. * @param x define the x coordinate of the source vector
  89095. * @param y define the y coordinate of the source vector
  89096. * @param z define the z coordinate of the source vector
  89097. * @param transformation defines the transformation matrix
  89098. * @param result defines the Vector3 where to store the result
  89099. */
  89100. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  89101. /**
  89102. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  89103. * @param value1 defines the first control point
  89104. * @param value2 defines the second control point
  89105. * @param value3 defines the third control point
  89106. * @param value4 defines the fourth control point
  89107. * @param amount defines the amount on the spline to use
  89108. * @returns the new Vector3
  89109. */
  89110. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  89111. /**
  89112. * 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"
  89113. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  89114. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  89115. * @param value defines the current value
  89116. * @param min defines the lower range value
  89117. * @param max defines the upper range value
  89118. * @returns the new Vector3
  89119. */
  89120. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  89121. /**
  89122. * 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"
  89123. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  89124. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  89125. * @param value defines the current value
  89126. * @param min defines the lower range value
  89127. * @param max defines the upper range value
  89128. * @param result defines the Vector3 where to store the result
  89129. */
  89130. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  89131. /**
  89132. * Checks if a given vector is inside a specific range
  89133. * @param v defines the vector to test
  89134. * @param min defines the minimum range
  89135. * @param max defines the maximum range
  89136. */
  89137. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89138. /**
  89139. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  89140. * @param value1 defines the first control point
  89141. * @param tangent1 defines the first tangent vector
  89142. * @param value2 defines the second control point
  89143. * @param tangent2 defines the second tangent vector
  89144. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  89145. * @returns the new Vector3
  89146. */
  89147. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  89148. /**
  89149. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  89150. * @param start defines the start value
  89151. * @param end defines the end value
  89152. * @param amount max defines amount between both (between 0 and 1)
  89153. * @returns the new Vector3
  89154. */
  89155. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  89156. /**
  89157. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  89158. * @param start defines the start value
  89159. * @param end defines the end value
  89160. * @param amount max defines amount between both (between 0 and 1)
  89161. * @param result defines the Vector3 where to store the result
  89162. */
  89163. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  89164. /**
  89165. * Returns the dot product (float) between the vectors "left" and "right"
  89166. * @param left defines the left operand
  89167. * @param right defines the right operand
  89168. * @returns the dot product
  89169. */
  89170. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  89171. /**
  89172. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  89173. * The cross product is then orthogonal to both "left" and "right"
  89174. * @param left defines the left operand
  89175. * @param right defines the right operand
  89176. * @returns the cross product
  89177. */
  89178. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  89179. /**
  89180. * Sets the given vector "result" with the cross product of "left" and "right"
  89181. * The cross product is then orthogonal to both "left" and "right"
  89182. * @param left defines the left operand
  89183. * @param right defines the right operand
  89184. * @param result defines the Vector3 where to store the result
  89185. */
  89186. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  89187. /**
  89188. * Returns a new Vector3 as the normalization of the given vector
  89189. * @param vector defines the Vector3 to normalize
  89190. * @returns the new Vector3
  89191. */
  89192. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  89193. /**
  89194. * Sets the given vector "result" with the normalization of the given first vector
  89195. * @param vector defines the Vector3 to normalize
  89196. * @param result defines the Vector3 where to store the result
  89197. */
  89198. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  89199. /**
  89200. * Project a Vector3 onto screen space
  89201. * @param vector defines the Vector3 to project
  89202. * @param world defines the world matrix to use
  89203. * @param transform defines the transform (view x projection) matrix to use
  89204. * @param viewport defines the screen viewport to use
  89205. * @returns the new Vector3
  89206. */
  89207. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  89208. /**
  89209. * Project a Vector3 onto screen space to reference
  89210. * @param vector defines the Vector3 to project
  89211. * @param world defines the world matrix to use
  89212. * @param transform defines the transform (view x projection) matrix to use
  89213. * @param viewport defines the screen viewport to use
  89214. * @param result the vector in which the screen space will be stored
  89215. * @returns the new Vector3
  89216. */
  89217. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  89218. /** @hidden */
  89219. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  89220. /**
  89221. * Unproject from screen space to object space
  89222. * @param source defines the screen space Vector3 to use
  89223. * @param viewportWidth defines the current width of the viewport
  89224. * @param viewportHeight defines the current height of the viewport
  89225. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89226. * @param transform defines the transform (view x projection) matrix to use
  89227. * @returns the new Vector3
  89228. */
  89229. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  89230. /**
  89231. * Unproject from screen space to object space
  89232. * @param source defines the screen space Vector3 to use
  89233. * @param viewportWidth defines the current width of the viewport
  89234. * @param viewportHeight defines the current height of the viewport
  89235. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89236. * @param view defines the view matrix to use
  89237. * @param projection defines the projection matrix to use
  89238. * @returns the new Vector3
  89239. */
  89240. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  89241. /**
  89242. * Unproject from screen space to object space
  89243. * @param source defines the screen space Vector3 to use
  89244. * @param viewportWidth defines the current width of the viewport
  89245. * @param viewportHeight defines the current height of the viewport
  89246. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89247. * @param view defines the view matrix to use
  89248. * @param projection defines the projection matrix to use
  89249. * @param result defines the Vector3 where to store the result
  89250. */
  89251. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  89252. /**
  89253. * Unproject from screen space to object space
  89254. * @param sourceX defines the screen space x coordinate to use
  89255. * @param sourceY defines the screen space y coordinate to use
  89256. * @param sourceZ defines the screen space z coordinate to use
  89257. * @param viewportWidth defines the current width of the viewport
  89258. * @param viewportHeight defines the current height of the viewport
  89259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89260. * @param view defines the view matrix to use
  89261. * @param projection defines the projection matrix to use
  89262. * @param result defines the Vector3 where to store the result
  89263. */
  89264. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  89265. /**
  89266. * Gets the minimal coordinate values between two Vector3
  89267. * @param left defines the first operand
  89268. * @param right defines the second operand
  89269. * @returns the new Vector3
  89270. */
  89271. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  89272. /**
  89273. * Gets the maximal coordinate values between two Vector3
  89274. * @param left defines the first operand
  89275. * @param right defines the second operand
  89276. * @returns the new Vector3
  89277. */
  89278. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  89279. /**
  89280. * Returns the distance between the vectors "value1" and "value2"
  89281. * @param value1 defines the first operand
  89282. * @param value2 defines the second operand
  89283. * @returns the distance
  89284. */
  89285. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  89286. /**
  89287. * Returns the squared distance between the vectors "value1" and "value2"
  89288. * @param value1 defines the first operand
  89289. * @param value2 defines the second operand
  89290. * @returns the squared distance
  89291. */
  89292. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  89293. /**
  89294. * Returns a new Vector3 located at the center between "value1" and "value2"
  89295. * @param value1 defines the first operand
  89296. * @param value2 defines the second operand
  89297. * @returns the new Vector3
  89298. */
  89299. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  89300. /**
  89301. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  89302. * @param value1 defines first vector
  89303. * @param value2 defines second vector
  89304. * @param ref defines third vector
  89305. * @returns ref
  89306. */
  89307. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  89308. /**
  89309. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  89310. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  89311. * to something in order to rotate it from its local system to the given target system
  89312. * Note: axis1, axis2 and axis3 are normalized during this operation
  89313. * @param axis1 defines the first axis
  89314. * @param axis2 defines the second axis
  89315. * @param axis3 defines the third axis
  89316. * @returns a new Vector3
  89317. */
  89318. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  89319. /**
  89320. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  89321. * @param axis1 defines the first axis
  89322. * @param axis2 defines the second axis
  89323. * @param axis3 defines the third axis
  89324. * @param ref defines the Vector3 where to store the result
  89325. */
  89326. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  89327. }
  89328. /**
  89329. * Vector4 class created for EulerAngle class conversion to Quaternion
  89330. */
  89331. export class Vector4 {
  89332. /** x value of the vector */
  89333. x: number;
  89334. /** y value of the vector */
  89335. y: number;
  89336. /** z value of the vector */
  89337. z: number;
  89338. /** w value of the vector */
  89339. w: number;
  89340. /**
  89341. * Creates a Vector4 object from the given floats.
  89342. * @param x x value of the vector
  89343. * @param y y value of the vector
  89344. * @param z z value of the vector
  89345. * @param w w value of the vector
  89346. */
  89347. constructor(
  89348. /** x value of the vector */
  89349. x: number,
  89350. /** y value of the vector */
  89351. y: number,
  89352. /** z value of the vector */
  89353. z: number,
  89354. /** w value of the vector */
  89355. w: number);
  89356. /**
  89357. * Returns the string with the Vector4 coordinates.
  89358. * @returns a string containing all the vector values
  89359. */
  89360. toString(): string;
  89361. /**
  89362. * Returns the string "Vector4".
  89363. * @returns "Vector4"
  89364. */
  89365. getClassName(): string;
  89366. /**
  89367. * Returns the Vector4 hash code.
  89368. * @returns a unique hash code
  89369. */
  89370. getHashCode(): number;
  89371. /**
  89372. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  89373. * @returns the resulting array
  89374. */
  89375. asArray(): number[];
  89376. /**
  89377. * Populates the given array from the given index with the Vector4 coordinates.
  89378. * @param array array to populate
  89379. * @param index index of the array to start at (default: 0)
  89380. * @returns the Vector4.
  89381. */
  89382. toArray(array: FloatArray, index?: number): Vector4;
  89383. /**
  89384. * Update the current vector from an array
  89385. * @param array defines the destination array
  89386. * @param index defines the offset in the destination array
  89387. * @returns the current Vector3
  89388. */
  89389. fromArray(array: FloatArray, index?: number): Vector4;
  89390. /**
  89391. * Adds the given vector to the current Vector4.
  89392. * @param otherVector the vector to add
  89393. * @returns the updated Vector4.
  89394. */
  89395. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  89396. /**
  89397. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  89398. * @param otherVector the vector to add
  89399. * @returns the resulting vector
  89400. */
  89401. add(otherVector: DeepImmutable<Vector4>): Vector4;
  89402. /**
  89403. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  89404. * @param otherVector the vector to add
  89405. * @param result the vector to store the result
  89406. * @returns the current Vector4.
  89407. */
  89408. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  89409. /**
  89410. * Subtract in place the given vector from the current Vector4.
  89411. * @param otherVector the vector to subtract
  89412. * @returns the updated Vector4.
  89413. */
  89414. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  89415. /**
  89416. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  89417. * @param otherVector the vector to add
  89418. * @returns the new vector with the result
  89419. */
  89420. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  89421. /**
  89422. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  89423. * @param otherVector the vector to subtract
  89424. * @param result the vector to store the result
  89425. * @returns the current Vector4.
  89426. */
  89427. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  89428. /**
  89429. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  89430. */
  89431. /**
  89432. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  89433. * @param x value to subtract
  89434. * @param y value to subtract
  89435. * @param z value to subtract
  89436. * @param w value to subtract
  89437. * @returns new vector containing the result
  89438. */
  89439. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  89440. /**
  89441. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  89442. * @param x value to subtract
  89443. * @param y value to subtract
  89444. * @param z value to subtract
  89445. * @param w value to subtract
  89446. * @param result the vector to store the result in
  89447. * @returns the current Vector4.
  89448. */
  89449. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  89450. /**
  89451. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  89452. * @returns a new vector with the negated values
  89453. */
  89454. negate(): Vector4;
  89455. /**
  89456. * Negate this vector in place
  89457. * @returns this
  89458. */
  89459. negateInPlace(): Vector4;
  89460. /**
  89461. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  89462. * @param result defines the Vector3 object where to store the result
  89463. * @returns the current Vector4
  89464. */
  89465. negateToRef(result: Vector4): Vector4;
  89466. /**
  89467. * Multiplies the current Vector4 coordinates by scale (float).
  89468. * @param scale the number to scale with
  89469. * @returns the updated Vector4.
  89470. */
  89471. scaleInPlace(scale: number): Vector4;
  89472. /**
  89473. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  89474. * @param scale the number to scale with
  89475. * @returns a new vector with the result
  89476. */
  89477. scale(scale: number): Vector4;
  89478. /**
  89479. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  89480. * @param scale the number to scale with
  89481. * @param result a vector to store the result in
  89482. * @returns the current Vector4.
  89483. */
  89484. scaleToRef(scale: number, result: Vector4): Vector4;
  89485. /**
  89486. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  89487. * @param scale defines the scale factor
  89488. * @param result defines the Vector4 object where to store the result
  89489. * @returns the unmodified current Vector4
  89490. */
  89491. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  89492. /**
  89493. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  89494. * @param otherVector the vector to compare against
  89495. * @returns true if they are equal
  89496. */
  89497. equals(otherVector: DeepImmutable<Vector4>): boolean;
  89498. /**
  89499. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  89500. * @param otherVector vector to compare against
  89501. * @param epsilon (Default: very small number)
  89502. * @returns true if they are equal
  89503. */
  89504. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  89505. /**
  89506. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  89507. * @param x x value to compare against
  89508. * @param y y value to compare against
  89509. * @param z z value to compare against
  89510. * @param w w value to compare against
  89511. * @returns true if equal
  89512. */
  89513. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  89514. /**
  89515. * Multiplies in place the current Vector4 by the given one.
  89516. * @param otherVector vector to multiple with
  89517. * @returns the updated Vector4.
  89518. */
  89519. multiplyInPlace(otherVector: Vector4): Vector4;
  89520. /**
  89521. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  89522. * @param otherVector vector to multiple with
  89523. * @returns resulting new vector
  89524. */
  89525. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  89526. /**
  89527. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  89528. * @param otherVector vector to multiple with
  89529. * @param result vector to store the result
  89530. * @returns the current Vector4.
  89531. */
  89532. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  89533. /**
  89534. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  89535. * @param x x value multiply with
  89536. * @param y y value multiply with
  89537. * @param z z value multiply with
  89538. * @param w w value multiply with
  89539. * @returns resulting new vector
  89540. */
  89541. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  89542. /**
  89543. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  89544. * @param otherVector vector to devide with
  89545. * @returns resulting new vector
  89546. */
  89547. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  89548. /**
  89549. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  89550. * @param otherVector vector to devide with
  89551. * @param result vector to store the result
  89552. * @returns the current Vector4.
  89553. */
  89554. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  89555. /**
  89556. * Divides the current Vector3 coordinates by the given ones.
  89557. * @param otherVector vector to devide with
  89558. * @returns the updated Vector3.
  89559. */
  89560. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  89561. /**
  89562. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  89563. * @param other defines the second operand
  89564. * @returns the current updated Vector4
  89565. */
  89566. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  89567. /**
  89568. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  89569. * @param other defines the second operand
  89570. * @returns the current updated Vector4
  89571. */
  89572. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  89573. /**
  89574. * Gets a new Vector4 from current Vector4 floored values
  89575. * @returns a new Vector4
  89576. */
  89577. floor(): Vector4;
  89578. /**
  89579. * Gets a new Vector4 from current Vector3 floored values
  89580. * @returns a new Vector4
  89581. */
  89582. fract(): Vector4;
  89583. /**
  89584. * Returns the Vector4 length (float).
  89585. * @returns the length
  89586. */
  89587. length(): number;
  89588. /**
  89589. * Returns the Vector4 squared length (float).
  89590. * @returns the length squared
  89591. */
  89592. lengthSquared(): number;
  89593. /**
  89594. * Normalizes in place the Vector4.
  89595. * @returns the updated Vector4.
  89596. */
  89597. normalize(): Vector4;
  89598. /**
  89599. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  89600. * @returns this converted to a new vector3
  89601. */
  89602. toVector3(): Vector3;
  89603. /**
  89604. * Returns a new Vector4 copied from the current one.
  89605. * @returns the new cloned vector
  89606. */
  89607. clone(): Vector4;
  89608. /**
  89609. * Updates the current Vector4 with the given one coordinates.
  89610. * @param source the source vector to copy from
  89611. * @returns the updated Vector4.
  89612. */
  89613. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  89614. /**
  89615. * Updates the current Vector4 coordinates with the given floats.
  89616. * @param x float to copy from
  89617. * @param y float to copy from
  89618. * @param z float to copy from
  89619. * @param w float to copy from
  89620. * @returns the updated Vector4.
  89621. */
  89622. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  89623. /**
  89624. * Updates the current Vector4 coordinates with the given floats.
  89625. * @param x float to set from
  89626. * @param y float to set from
  89627. * @param z float to set from
  89628. * @param w float to set from
  89629. * @returns the updated Vector4.
  89630. */
  89631. set(x: number, y: number, z: number, w: number): Vector4;
  89632. /**
  89633. * Copies the given float to the current Vector3 coordinates
  89634. * @param v defines the x, y, z and w coordinates of the operand
  89635. * @returns the current updated Vector3
  89636. */
  89637. setAll(v: number): Vector4;
  89638. /**
  89639. * Returns a new Vector4 set from the starting index of the given array.
  89640. * @param array the array to pull values from
  89641. * @param offset the offset into the array to start at
  89642. * @returns the new vector
  89643. */
  89644. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  89645. /**
  89646. * Updates the given vector "result" from the starting index of the given array.
  89647. * @param array the array to pull values from
  89648. * @param offset the offset into the array to start at
  89649. * @param result the vector to store the result in
  89650. */
  89651. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  89652. /**
  89653. * Updates the given vector "result" from the starting index of the given Float32Array.
  89654. * @param array the array to pull values from
  89655. * @param offset the offset into the array to start at
  89656. * @param result the vector to store the result in
  89657. */
  89658. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  89659. /**
  89660. * Updates the given vector "result" coordinates from the given floats.
  89661. * @param x float to set from
  89662. * @param y float to set from
  89663. * @param z float to set from
  89664. * @param w float to set from
  89665. * @param result the vector to the floats in
  89666. */
  89667. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  89668. /**
  89669. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  89670. * @returns the new vector
  89671. */
  89672. static Zero(): Vector4;
  89673. /**
  89674. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  89675. * @returns the new vector
  89676. */
  89677. static One(): Vector4;
  89678. /**
  89679. * Returns a new normalized Vector4 from the given one.
  89680. * @param vector the vector to normalize
  89681. * @returns the vector
  89682. */
  89683. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  89684. /**
  89685. * Updates the given vector "result" from the normalization of the given one.
  89686. * @param vector the vector to normalize
  89687. * @param result the vector to store the result in
  89688. */
  89689. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  89690. /**
  89691. * Returns a vector with the minimum values from the left and right vectors
  89692. * @param left left vector to minimize
  89693. * @param right right vector to minimize
  89694. * @returns a new vector with the minimum of the left and right vector values
  89695. */
  89696. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  89697. /**
  89698. * Returns a vector with the maximum values from the left and right vectors
  89699. * @param left left vector to maximize
  89700. * @param right right vector to maximize
  89701. * @returns a new vector with the maximum of the left and right vector values
  89702. */
  89703. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  89704. /**
  89705. * Returns the distance (float) between the vectors "value1" and "value2".
  89706. * @param value1 value to calulate the distance between
  89707. * @param value2 value to calulate the distance between
  89708. * @return the distance between the two vectors
  89709. */
  89710. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  89711. /**
  89712. * Returns the squared distance (float) between the vectors "value1" and "value2".
  89713. * @param value1 value to calulate the distance between
  89714. * @param value2 value to calulate the distance between
  89715. * @return the distance between the two vectors squared
  89716. */
  89717. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  89718. /**
  89719. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  89720. * @param value1 value to calulate the center between
  89721. * @param value2 value to calulate the center between
  89722. * @return the center between the two vectors
  89723. */
  89724. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  89725. /**
  89726. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  89727. * @param value1 defines first vector
  89728. * @param value2 defines second vector
  89729. * @param ref defines third vector
  89730. * @returns ref
  89731. */
  89732. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  89733. /**
  89734. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  89735. * This methods computes transformed normalized direction vectors only.
  89736. * @param vector the vector to transform
  89737. * @param transformation the transformation matrix to apply
  89738. * @returns the new vector
  89739. */
  89740. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  89741. /**
  89742. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  89743. * This methods computes transformed normalized direction vectors only.
  89744. * @param vector the vector to transform
  89745. * @param transformation the transformation matrix to apply
  89746. * @param result the vector to store the result in
  89747. */
  89748. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  89749. /**
  89750. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  89751. * This methods computes transformed normalized direction vectors only.
  89752. * @param x value to transform
  89753. * @param y value to transform
  89754. * @param z value to transform
  89755. * @param w value to transform
  89756. * @param transformation the transformation matrix to apply
  89757. * @param result the vector to store the results in
  89758. */
  89759. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  89760. /**
  89761. * Creates a new Vector4 from a Vector3
  89762. * @param source defines the source data
  89763. * @param w defines the 4th component (default is 0)
  89764. * @returns a new Vector4
  89765. */
  89766. static FromVector3(source: Vector3, w?: number): Vector4;
  89767. }
  89768. /**
  89769. * Class used to store quaternion data
  89770. * @see https://en.wikipedia.org/wiki/Quaternion
  89771. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  89772. */
  89773. export class Quaternion {
  89774. /** @hidden */
  89775. _x: number;
  89776. /** @hidden */
  89777. _y: number;
  89778. /** @hidden */
  89779. _z: number;
  89780. /** @hidden */
  89781. _w: number;
  89782. /** @hidden */
  89783. _isDirty: boolean;
  89784. /** Gets or sets the x coordinate */
  89785. get x(): number;
  89786. set x(value: number);
  89787. /** Gets or sets the y coordinate */
  89788. get y(): number;
  89789. set y(value: number);
  89790. /** Gets or sets the z coordinate */
  89791. get z(): number;
  89792. set z(value: number);
  89793. /** Gets or sets the w coordinate */
  89794. get w(): number;
  89795. set w(value: number);
  89796. /**
  89797. * Creates a new Quaternion from the given floats
  89798. * @param x defines the first component (0 by default)
  89799. * @param y defines the second component (0 by default)
  89800. * @param z defines the third component (0 by default)
  89801. * @param w defines the fourth component (1.0 by default)
  89802. */
  89803. constructor(x?: number, y?: number, z?: number, w?: number);
  89804. /**
  89805. * Gets a string representation for the current quaternion
  89806. * @returns a string with the Quaternion coordinates
  89807. */
  89808. toString(): string;
  89809. /**
  89810. * Gets the class name of the quaternion
  89811. * @returns the string "Quaternion"
  89812. */
  89813. getClassName(): string;
  89814. /**
  89815. * Gets a hash code for this quaternion
  89816. * @returns the quaternion hash code
  89817. */
  89818. getHashCode(): number;
  89819. /**
  89820. * Copy the quaternion to an array
  89821. * @returns a new array populated with 4 elements from the quaternion coordinates
  89822. */
  89823. asArray(): number[];
  89824. /**
  89825. * Check if two quaternions are equals
  89826. * @param otherQuaternion defines the second operand
  89827. * @return true if the current quaternion and the given one coordinates are strictly equals
  89828. */
  89829. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  89830. /**
  89831. * Gets a boolean if two quaternions are equals (using an epsilon value)
  89832. * @param otherQuaternion defines the other quaternion
  89833. * @param epsilon defines the minimal distance to consider equality
  89834. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  89835. */
  89836. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  89837. /**
  89838. * Clone the current quaternion
  89839. * @returns a new quaternion copied from the current one
  89840. */
  89841. clone(): Quaternion;
  89842. /**
  89843. * Copy a quaternion to the current one
  89844. * @param other defines the other quaternion
  89845. * @returns the updated current quaternion
  89846. */
  89847. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  89848. /**
  89849. * Updates the current quaternion with the given float coordinates
  89850. * @param x defines the x coordinate
  89851. * @param y defines the y coordinate
  89852. * @param z defines the z coordinate
  89853. * @param w defines the w coordinate
  89854. * @returns the updated current quaternion
  89855. */
  89856. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  89857. /**
  89858. * Updates the current quaternion from the given float coordinates
  89859. * @param x defines the x coordinate
  89860. * @param y defines the y coordinate
  89861. * @param z defines the z coordinate
  89862. * @param w defines the w coordinate
  89863. * @returns the updated current quaternion
  89864. */
  89865. set(x: number, y: number, z: number, w: number): Quaternion;
  89866. /**
  89867. * Adds two quaternions
  89868. * @param other defines the second operand
  89869. * @returns a new quaternion as the addition result of the given one and the current quaternion
  89870. */
  89871. add(other: DeepImmutable<Quaternion>): Quaternion;
  89872. /**
  89873. * Add a quaternion to the current one
  89874. * @param other defines the quaternion to add
  89875. * @returns the current quaternion
  89876. */
  89877. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  89878. /**
  89879. * Subtract two quaternions
  89880. * @param other defines the second operand
  89881. * @returns a new quaternion as the subtraction result of the given one from the current one
  89882. */
  89883. subtract(other: Quaternion): Quaternion;
  89884. /**
  89885. * Multiplies the current quaternion by a scale factor
  89886. * @param value defines the scale factor
  89887. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  89888. */
  89889. scale(value: number): Quaternion;
  89890. /**
  89891. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  89892. * @param scale defines the scale factor
  89893. * @param result defines the Quaternion object where to store the result
  89894. * @returns the unmodified current quaternion
  89895. */
  89896. scaleToRef(scale: number, result: Quaternion): Quaternion;
  89897. /**
  89898. * Multiplies in place the current quaternion by a scale factor
  89899. * @param value defines the scale factor
  89900. * @returns the current modified quaternion
  89901. */
  89902. scaleInPlace(value: number): Quaternion;
  89903. /**
  89904. * Scale the current quaternion values by a factor and add the result to a given quaternion
  89905. * @param scale defines the scale factor
  89906. * @param result defines the Quaternion object where to store the result
  89907. * @returns the unmodified current quaternion
  89908. */
  89909. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  89910. /**
  89911. * Multiplies two quaternions
  89912. * @param q1 defines the second operand
  89913. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  89914. */
  89915. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  89916. /**
  89917. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  89918. * @param q1 defines the second operand
  89919. * @param result defines the target quaternion
  89920. * @returns the current quaternion
  89921. */
  89922. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  89923. /**
  89924. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  89925. * @param q1 defines the second operand
  89926. * @returns the currentupdated quaternion
  89927. */
  89928. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  89929. /**
  89930. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  89931. * @param ref defines the target quaternion
  89932. * @returns the current quaternion
  89933. */
  89934. conjugateToRef(ref: Quaternion): Quaternion;
  89935. /**
  89936. * Conjugates in place (1-q) the current quaternion
  89937. * @returns the current updated quaternion
  89938. */
  89939. conjugateInPlace(): Quaternion;
  89940. /**
  89941. * Conjugates in place (1-q) the current quaternion
  89942. * @returns a new quaternion
  89943. */
  89944. conjugate(): Quaternion;
  89945. /**
  89946. * Gets length of current quaternion
  89947. * @returns the quaternion length (float)
  89948. */
  89949. length(): number;
  89950. /**
  89951. * Normalize in place the current quaternion
  89952. * @returns the current updated quaternion
  89953. */
  89954. normalize(): Quaternion;
  89955. /**
  89956. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  89957. * @param order is a reserved parameter and is ignored for now
  89958. * @returns a new Vector3 containing the Euler angles
  89959. */
  89960. toEulerAngles(order?: string): Vector3;
  89961. /**
  89962. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  89963. * @param result defines the vector which will be filled with the Euler angles
  89964. * @returns the current unchanged quaternion
  89965. */
  89966. toEulerAnglesToRef(result: Vector3): Quaternion;
  89967. /**
  89968. * Updates the given rotation matrix with the current quaternion values
  89969. * @param result defines the target matrix
  89970. * @returns the current unchanged quaternion
  89971. */
  89972. toRotationMatrix(result: Matrix): Quaternion;
  89973. /**
  89974. * Updates the current quaternion from the given rotation matrix values
  89975. * @param matrix defines the source matrix
  89976. * @returns the current updated quaternion
  89977. */
  89978. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89979. /**
  89980. * Creates a new quaternion from a rotation matrix
  89981. * @param matrix defines the source matrix
  89982. * @returns a new quaternion created from the given rotation matrix values
  89983. */
  89984. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89985. /**
  89986. * Updates the given quaternion with the given rotation matrix values
  89987. * @param matrix defines the source matrix
  89988. * @param result defines the target quaternion
  89989. */
  89990. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  89991. /**
  89992. * Returns the dot product (float) between the quaternions "left" and "right"
  89993. * @param left defines the left operand
  89994. * @param right defines the right operand
  89995. * @returns the dot product
  89996. */
  89997. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  89998. /**
  89999. * Checks if the two quaternions are close to each other
  90000. * @param quat0 defines the first quaternion to check
  90001. * @param quat1 defines the second quaternion to check
  90002. * @returns true if the two quaternions are close to each other
  90003. */
  90004. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  90005. /**
  90006. * Creates an empty quaternion
  90007. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  90008. */
  90009. static Zero(): Quaternion;
  90010. /**
  90011. * Inverse a given quaternion
  90012. * @param q defines the source quaternion
  90013. * @returns a new quaternion as the inverted current quaternion
  90014. */
  90015. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  90016. /**
  90017. * Inverse a given quaternion
  90018. * @param q defines the source quaternion
  90019. * @param result the quaternion the result will be stored in
  90020. * @returns the result quaternion
  90021. */
  90022. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  90023. /**
  90024. * Creates an identity quaternion
  90025. * @returns the identity quaternion
  90026. */
  90027. static Identity(): Quaternion;
  90028. /**
  90029. * Gets a boolean indicating if the given quaternion is identity
  90030. * @param quaternion defines the quaternion to check
  90031. * @returns true if the quaternion is identity
  90032. */
  90033. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  90034. /**
  90035. * Creates a quaternion from a rotation around an axis
  90036. * @param axis defines the axis to use
  90037. * @param angle defines the angle to use
  90038. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  90039. */
  90040. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  90041. /**
  90042. * Creates a rotation around an axis and stores it into the given quaternion
  90043. * @param axis defines the axis to use
  90044. * @param angle defines the angle to use
  90045. * @param result defines the target quaternion
  90046. * @returns the target quaternion
  90047. */
  90048. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  90049. /**
  90050. * Creates a new quaternion from data stored into an array
  90051. * @param array defines the data source
  90052. * @param offset defines the offset in the source array where the data starts
  90053. * @returns a new quaternion
  90054. */
  90055. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  90056. /**
  90057. * Updates the given quaternion "result" from the starting index of the given array.
  90058. * @param array the array to pull values from
  90059. * @param offset the offset into the array to start at
  90060. * @param result the quaternion to store the result in
  90061. */
  90062. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  90063. /**
  90064. * Create a quaternion from Euler rotation angles
  90065. * @param x Pitch
  90066. * @param y Yaw
  90067. * @param z Roll
  90068. * @returns the new Quaternion
  90069. */
  90070. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  90071. /**
  90072. * Updates a quaternion from Euler rotation angles
  90073. * @param x Pitch
  90074. * @param y Yaw
  90075. * @param z Roll
  90076. * @param result the quaternion to store the result
  90077. * @returns the updated quaternion
  90078. */
  90079. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  90080. /**
  90081. * Create a quaternion from Euler rotation vector
  90082. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  90083. * @returns the new Quaternion
  90084. */
  90085. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  90086. /**
  90087. * Updates a quaternion from Euler rotation vector
  90088. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  90089. * @param result the quaternion to store the result
  90090. * @returns the updated quaternion
  90091. */
  90092. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  90093. /**
  90094. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  90095. * @param vecFrom defines the direction vector from which to rotate
  90096. * @param vecTo defines the direction vector to which to rotate
  90097. * @param result the quaternion to store the result
  90098. * @returns the updated quaternion
  90099. */
  90100. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  90101. /**
  90102. * Creates a new quaternion from the given Euler float angles (y, x, z)
  90103. * @param yaw defines the rotation around Y axis
  90104. * @param pitch defines the rotation around X axis
  90105. * @param roll defines the rotation around Z axis
  90106. * @returns the new quaternion
  90107. */
  90108. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  90109. /**
  90110. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  90111. * @param yaw defines the rotation around Y axis
  90112. * @param pitch defines the rotation around X axis
  90113. * @param roll defines the rotation around Z axis
  90114. * @param result defines the target quaternion
  90115. */
  90116. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  90117. /**
  90118. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  90119. * @param alpha defines the rotation around first axis
  90120. * @param beta defines the rotation around second axis
  90121. * @param gamma defines the rotation around third axis
  90122. * @returns the new quaternion
  90123. */
  90124. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  90125. /**
  90126. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  90127. * @param alpha defines the rotation around first axis
  90128. * @param beta defines the rotation around second axis
  90129. * @param gamma defines the rotation around third axis
  90130. * @param result defines the target quaternion
  90131. */
  90132. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  90133. /**
  90134. * 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)
  90135. * @param axis1 defines the first axis
  90136. * @param axis2 defines the second axis
  90137. * @param axis3 defines the third axis
  90138. * @returns the new quaternion
  90139. */
  90140. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  90141. /**
  90142. * 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
  90143. * @param axis1 defines the first axis
  90144. * @param axis2 defines the second axis
  90145. * @param axis3 defines the third axis
  90146. * @param ref defines the target quaternion
  90147. */
  90148. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  90149. /**
  90150. * Interpolates between two quaternions
  90151. * @param left defines first quaternion
  90152. * @param right defines second quaternion
  90153. * @param amount defines the gradient to use
  90154. * @returns the new interpolated quaternion
  90155. */
  90156. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  90157. /**
  90158. * Interpolates between two quaternions and stores it into a target quaternion
  90159. * @param left defines first quaternion
  90160. * @param right defines second quaternion
  90161. * @param amount defines the gradient to use
  90162. * @param result defines the target quaternion
  90163. */
  90164. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  90165. /**
  90166. * Interpolate between two quaternions using Hermite interpolation
  90167. * @param value1 defines first quaternion
  90168. * @param tangent1 defines the incoming tangent
  90169. * @param value2 defines second quaternion
  90170. * @param tangent2 defines the outgoing tangent
  90171. * @param amount defines the target quaternion
  90172. * @returns the new interpolated quaternion
  90173. */
  90174. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  90175. }
  90176. /**
  90177. * Class used to store matrix data (4x4)
  90178. */
  90179. export class Matrix {
  90180. /**
  90181. * Gets the precision of matrix computations
  90182. */
  90183. static get Use64Bits(): boolean;
  90184. private static _updateFlagSeed;
  90185. private static _identityReadOnly;
  90186. private _isIdentity;
  90187. private _isIdentityDirty;
  90188. private _isIdentity3x2;
  90189. private _isIdentity3x2Dirty;
  90190. /**
  90191. * Gets the update flag of the matrix which is an unique number for the matrix.
  90192. * It will be incremented every time the matrix data change.
  90193. * You can use it to speed the comparison between two versions of the same matrix.
  90194. */
  90195. updateFlag: number;
  90196. private readonly _m;
  90197. /**
  90198. * Gets the internal data of the matrix
  90199. */
  90200. get m(): DeepImmutable<Float32Array | Array<number>>;
  90201. /** @hidden */
  90202. _markAsUpdated(): void;
  90203. /** @hidden */
  90204. private _updateIdentityStatus;
  90205. /**
  90206. * Creates an empty matrix (filled with zeros)
  90207. */
  90208. constructor();
  90209. /**
  90210. * Check if the current matrix is identity
  90211. * @returns true is the matrix is the identity matrix
  90212. */
  90213. isIdentity(): boolean;
  90214. /**
  90215. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  90216. * @returns true is the matrix is the identity matrix
  90217. */
  90218. isIdentityAs3x2(): boolean;
  90219. /**
  90220. * Gets the determinant of the matrix
  90221. * @returns the matrix determinant
  90222. */
  90223. determinant(): number;
  90224. /**
  90225. * Returns the matrix as a Float32Array or Array<number>
  90226. * @returns the matrix underlying array
  90227. */
  90228. toArray(): DeepImmutable<Float32Array | Array<number>>;
  90229. /**
  90230. * Returns the matrix as a Float32Array or Array<number>
  90231. * @returns the matrix underlying array.
  90232. */
  90233. asArray(): DeepImmutable<Float32Array | Array<number>>;
  90234. /**
  90235. * Inverts the current matrix in place
  90236. * @returns the current inverted matrix
  90237. */
  90238. invert(): Matrix;
  90239. /**
  90240. * Sets all the matrix elements to zero
  90241. * @returns the current matrix
  90242. */
  90243. reset(): Matrix;
  90244. /**
  90245. * Adds the current matrix with a second one
  90246. * @param other defines the matrix to add
  90247. * @returns a new matrix as the addition of the current matrix and the given one
  90248. */
  90249. add(other: DeepImmutable<Matrix>): Matrix;
  90250. /**
  90251. * Sets the given matrix "result" to the addition of the current matrix and the given one
  90252. * @param other defines the matrix to add
  90253. * @param result defines the target matrix
  90254. * @returns the current matrix
  90255. */
  90256. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  90257. /**
  90258. * Adds in place the given matrix to the current matrix
  90259. * @param other defines the second operand
  90260. * @returns the current updated matrix
  90261. */
  90262. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  90263. /**
  90264. * Sets the given matrix to the current inverted Matrix
  90265. * @param other defines the target matrix
  90266. * @returns the unmodified current matrix
  90267. */
  90268. invertToRef(other: Matrix): Matrix;
  90269. /**
  90270. * add a value at the specified position in the current Matrix
  90271. * @param index the index of the value within the matrix. between 0 and 15.
  90272. * @param value the value to be added
  90273. * @returns the current updated matrix
  90274. */
  90275. addAtIndex(index: number, value: number): Matrix;
  90276. /**
  90277. * mutiply the specified position in the current Matrix by a value
  90278. * @param index the index of the value within the matrix. between 0 and 15.
  90279. * @param value the value to be added
  90280. * @returns the current updated matrix
  90281. */
  90282. multiplyAtIndex(index: number, value: number): Matrix;
  90283. /**
  90284. * Inserts the translation vector (using 3 floats) in the current matrix
  90285. * @param x defines the 1st component of the translation
  90286. * @param y defines the 2nd component of the translation
  90287. * @param z defines the 3rd component of the translation
  90288. * @returns the current updated matrix
  90289. */
  90290. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  90291. /**
  90292. * Adds the translation vector (using 3 floats) in the current matrix
  90293. * @param x defines the 1st component of the translation
  90294. * @param y defines the 2nd component of the translation
  90295. * @param z defines the 3rd component of the translation
  90296. * @returns the current updated matrix
  90297. */
  90298. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  90299. /**
  90300. * Inserts the translation vector in the current matrix
  90301. * @param vector3 defines the translation to insert
  90302. * @returns the current updated matrix
  90303. */
  90304. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  90305. /**
  90306. * Gets the translation value of the current matrix
  90307. * @returns a new Vector3 as the extracted translation from the matrix
  90308. */
  90309. getTranslation(): Vector3;
  90310. /**
  90311. * Fill a Vector3 with the extracted translation from the matrix
  90312. * @param result defines the Vector3 where to store the translation
  90313. * @returns the current matrix
  90314. */
  90315. getTranslationToRef(result: Vector3): Matrix;
  90316. /**
  90317. * Remove rotation and scaling part from the matrix
  90318. * @returns the updated matrix
  90319. */
  90320. removeRotationAndScaling(): Matrix;
  90321. /**
  90322. * Multiply two matrices
  90323. * @param other defines the second operand
  90324. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  90325. */
  90326. multiply(other: DeepImmutable<Matrix>): Matrix;
  90327. /**
  90328. * Copy the current matrix from the given one
  90329. * @param other defines the source matrix
  90330. * @returns the current updated matrix
  90331. */
  90332. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  90333. /**
  90334. * Populates the given array from the starting index with the current matrix values
  90335. * @param array defines the target array
  90336. * @param offset defines the offset in the target array where to start storing values
  90337. * @returns the current matrix
  90338. */
  90339. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  90340. /**
  90341. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  90342. * @param other defines the second operand
  90343. * @param result defines the matrix where to store the multiplication
  90344. * @returns the current matrix
  90345. */
  90346. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  90347. /**
  90348. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  90349. * @param other defines the second operand
  90350. * @param result defines the array where to store the multiplication
  90351. * @param offset defines the offset in the target array where to start storing values
  90352. * @returns the current matrix
  90353. */
  90354. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  90355. /**
  90356. * Check equality between this matrix and a second one
  90357. * @param value defines the second matrix to compare
  90358. * @returns true is the current matrix and the given one values are strictly equal
  90359. */
  90360. equals(value: DeepImmutable<Matrix>): boolean;
  90361. /**
  90362. * Clone the current matrix
  90363. * @returns a new matrix from the current matrix
  90364. */
  90365. clone(): Matrix;
  90366. /**
  90367. * Returns the name of the current matrix class
  90368. * @returns the string "Matrix"
  90369. */
  90370. getClassName(): string;
  90371. /**
  90372. * Gets the hash code of the current matrix
  90373. * @returns the hash code
  90374. */
  90375. getHashCode(): number;
  90376. /**
  90377. * Decomposes the current Matrix into a translation, rotation and scaling components
  90378. * @param scale defines the scale vector3 given as a reference to update
  90379. * @param rotation defines the rotation quaternion given as a reference to update
  90380. * @param translation defines the translation vector3 given as a reference to update
  90381. * @returns true if operation was successful
  90382. */
  90383. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  90384. /**
  90385. * Gets specific row of the matrix
  90386. * @param index defines the number of the row to get
  90387. * @returns the index-th row of the current matrix as a new Vector4
  90388. */
  90389. getRow(index: number): Nullable<Vector4>;
  90390. /**
  90391. * Sets the index-th row of the current matrix to the vector4 values
  90392. * @param index defines the number of the row to set
  90393. * @param row defines the target vector4
  90394. * @returns the updated current matrix
  90395. */
  90396. setRow(index: number, row: Vector4): Matrix;
  90397. /**
  90398. * Compute the transpose of the matrix
  90399. * @returns the new transposed matrix
  90400. */
  90401. transpose(): Matrix;
  90402. /**
  90403. * Compute the transpose of the matrix and store it in a given matrix
  90404. * @param result defines the target matrix
  90405. * @returns the current matrix
  90406. */
  90407. transposeToRef(result: Matrix): Matrix;
  90408. /**
  90409. * Sets the index-th row of the current matrix with the given 4 x float values
  90410. * @param index defines the row index
  90411. * @param x defines the x component to set
  90412. * @param y defines the y component to set
  90413. * @param z defines the z component to set
  90414. * @param w defines the w component to set
  90415. * @returns the updated current matrix
  90416. */
  90417. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  90418. /**
  90419. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  90420. * @param scale defines the scale factor
  90421. * @returns a new matrix
  90422. */
  90423. scale(scale: number): Matrix;
  90424. /**
  90425. * Scale the current matrix values by a factor to a given result matrix
  90426. * @param scale defines the scale factor
  90427. * @param result defines the matrix to store the result
  90428. * @returns the current matrix
  90429. */
  90430. scaleToRef(scale: number, result: Matrix): Matrix;
  90431. /**
  90432. * Scale the current matrix values by a factor and add the result to a given matrix
  90433. * @param scale defines the scale factor
  90434. * @param result defines the Matrix to store the result
  90435. * @returns the current matrix
  90436. */
  90437. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  90438. /**
  90439. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  90440. * @param ref matrix to store the result
  90441. */
  90442. toNormalMatrix(ref: Matrix): void;
  90443. /**
  90444. * Gets only rotation part of the current matrix
  90445. * @returns a new matrix sets to the extracted rotation matrix from the current one
  90446. */
  90447. getRotationMatrix(): Matrix;
  90448. /**
  90449. * Extracts the rotation matrix from the current one and sets it as the given "result"
  90450. * @param result defines the target matrix to store data to
  90451. * @returns the current matrix
  90452. */
  90453. getRotationMatrixToRef(result: Matrix): Matrix;
  90454. /**
  90455. * Toggles model matrix from being right handed to left handed in place and vice versa
  90456. */
  90457. toggleModelMatrixHandInPlace(): void;
  90458. /**
  90459. * Toggles projection matrix from being right handed to left handed in place and vice versa
  90460. */
  90461. toggleProjectionMatrixHandInPlace(): void;
  90462. /**
  90463. * Creates a matrix from an array
  90464. * @param array defines the source array
  90465. * @param offset defines an offset in the source array
  90466. * @returns a new Matrix set from the starting index of the given array
  90467. */
  90468. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  90469. /**
  90470. * Copy the content of an array into a given matrix
  90471. * @param array defines the source array
  90472. * @param offset defines an offset in the source array
  90473. * @param result defines the target matrix
  90474. */
  90475. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  90476. /**
  90477. * Stores an array into a matrix after having multiplied each component by a given factor
  90478. * @param array defines the source array
  90479. * @param offset defines the offset in the source array
  90480. * @param scale defines the scaling factor
  90481. * @param result defines the target matrix
  90482. */
  90483. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  90484. /**
  90485. * Gets an identity matrix that must not be updated
  90486. */
  90487. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  90488. /**
  90489. * Stores a list of values (16) inside a given matrix
  90490. * @param initialM11 defines 1st value of 1st row
  90491. * @param initialM12 defines 2nd value of 1st row
  90492. * @param initialM13 defines 3rd value of 1st row
  90493. * @param initialM14 defines 4th value of 1st row
  90494. * @param initialM21 defines 1st value of 2nd row
  90495. * @param initialM22 defines 2nd value of 2nd row
  90496. * @param initialM23 defines 3rd value of 2nd row
  90497. * @param initialM24 defines 4th value of 2nd row
  90498. * @param initialM31 defines 1st value of 3rd row
  90499. * @param initialM32 defines 2nd value of 3rd row
  90500. * @param initialM33 defines 3rd value of 3rd row
  90501. * @param initialM34 defines 4th value of 3rd row
  90502. * @param initialM41 defines 1st value of 4th row
  90503. * @param initialM42 defines 2nd value of 4th row
  90504. * @param initialM43 defines 3rd value of 4th row
  90505. * @param initialM44 defines 4th value of 4th row
  90506. * @param result defines the target matrix
  90507. */
  90508. 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;
  90509. /**
  90510. * Creates new matrix from a list of values (16)
  90511. * @param initialM11 defines 1st value of 1st row
  90512. * @param initialM12 defines 2nd value of 1st row
  90513. * @param initialM13 defines 3rd value of 1st row
  90514. * @param initialM14 defines 4th value of 1st row
  90515. * @param initialM21 defines 1st value of 2nd row
  90516. * @param initialM22 defines 2nd value of 2nd row
  90517. * @param initialM23 defines 3rd value of 2nd row
  90518. * @param initialM24 defines 4th value of 2nd row
  90519. * @param initialM31 defines 1st value of 3rd row
  90520. * @param initialM32 defines 2nd value of 3rd row
  90521. * @param initialM33 defines 3rd value of 3rd row
  90522. * @param initialM34 defines 4th value of 3rd row
  90523. * @param initialM41 defines 1st value of 4th row
  90524. * @param initialM42 defines 2nd value of 4th row
  90525. * @param initialM43 defines 3rd value of 4th row
  90526. * @param initialM44 defines 4th value of 4th row
  90527. * @returns the new matrix
  90528. */
  90529. 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;
  90530. /**
  90531. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  90532. * @param scale defines the scale vector3
  90533. * @param rotation defines the rotation quaternion
  90534. * @param translation defines the translation vector3
  90535. * @returns a new matrix
  90536. */
  90537. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  90538. /**
  90539. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  90540. * @param scale defines the scale vector3
  90541. * @param rotation defines the rotation quaternion
  90542. * @param translation defines the translation vector3
  90543. * @param result defines the target matrix
  90544. */
  90545. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  90546. /**
  90547. * Creates a new identity matrix
  90548. * @returns a new identity matrix
  90549. */
  90550. static Identity(): Matrix;
  90551. /**
  90552. * Creates a new identity matrix and stores the result in a given matrix
  90553. * @param result defines the target matrix
  90554. */
  90555. static IdentityToRef(result: Matrix): void;
  90556. /**
  90557. * Creates a new zero matrix
  90558. * @returns a new zero matrix
  90559. */
  90560. static Zero(): Matrix;
  90561. /**
  90562. * Creates a new rotation matrix for "angle" radians around the X axis
  90563. * @param angle defines the angle (in radians) to use
  90564. * @return the new matrix
  90565. */
  90566. static RotationX(angle: number): Matrix;
  90567. /**
  90568. * Creates a new matrix as the invert of a given matrix
  90569. * @param source defines the source matrix
  90570. * @returns the new matrix
  90571. */
  90572. static Invert(source: DeepImmutable<Matrix>): Matrix;
  90573. /**
  90574. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  90575. * @param angle defines the angle (in radians) to use
  90576. * @param result defines the target matrix
  90577. */
  90578. static RotationXToRef(angle: number, result: Matrix): void;
  90579. /**
  90580. * Creates a new rotation matrix for "angle" radians around the Y axis
  90581. * @param angle defines the angle (in radians) to use
  90582. * @return the new matrix
  90583. */
  90584. static RotationY(angle: number): Matrix;
  90585. /**
  90586. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  90587. * @param angle defines the angle (in radians) to use
  90588. * @param result defines the target matrix
  90589. */
  90590. static RotationYToRef(angle: number, result: Matrix): void;
  90591. /**
  90592. * Creates a new rotation matrix for "angle" radians around the Z axis
  90593. * @param angle defines the angle (in radians) to use
  90594. * @return the new matrix
  90595. */
  90596. static RotationZ(angle: number): Matrix;
  90597. /**
  90598. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  90599. * @param angle defines the angle (in radians) to use
  90600. * @param result defines the target matrix
  90601. */
  90602. static RotationZToRef(angle: number, result: Matrix): void;
  90603. /**
  90604. * Creates a new rotation matrix for "angle" radians around the given axis
  90605. * @param axis defines the axis to use
  90606. * @param angle defines the angle (in radians) to use
  90607. * @return the new matrix
  90608. */
  90609. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  90610. /**
  90611. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  90612. * @param axis defines the axis to use
  90613. * @param angle defines the angle (in radians) to use
  90614. * @param result defines the target matrix
  90615. */
  90616. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  90617. /**
  90618. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  90619. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  90620. * @param from defines the vector to align
  90621. * @param to defines the vector to align to
  90622. * @param result defines the target matrix
  90623. */
  90624. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  90625. /**
  90626. * Creates a rotation matrix
  90627. * @param yaw defines the yaw angle in radians (Y axis)
  90628. * @param pitch defines the pitch angle in radians (X axis)
  90629. * @param roll defines the roll angle in radians (Z axis)
  90630. * @returns the new rotation matrix
  90631. */
  90632. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  90633. /**
  90634. * Creates a rotation matrix and stores it in a given matrix
  90635. * @param yaw defines the yaw angle in radians (Y axis)
  90636. * @param pitch defines the pitch angle in radians (X axis)
  90637. * @param roll defines the roll angle in radians (Z axis)
  90638. * @param result defines the target matrix
  90639. */
  90640. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  90641. /**
  90642. * Creates a scaling matrix
  90643. * @param x defines the scale factor on X axis
  90644. * @param y defines the scale factor on Y axis
  90645. * @param z defines the scale factor on Z axis
  90646. * @returns the new matrix
  90647. */
  90648. static Scaling(x: number, y: number, z: number): Matrix;
  90649. /**
  90650. * Creates a scaling matrix and stores it in a given matrix
  90651. * @param x defines the scale factor on X axis
  90652. * @param y defines the scale factor on Y axis
  90653. * @param z defines the scale factor on Z axis
  90654. * @param result defines the target matrix
  90655. */
  90656. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  90657. /**
  90658. * Creates a translation matrix
  90659. * @param x defines the translation on X axis
  90660. * @param y defines the translation on Y axis
  90661. * @param z defines the translationon Z axis
  90662. * @returns the new matrix
  90663. */
  90664. static Translation(x: number, y: number, z: number): Matrix;
  90665. /**
  90666. * Creates a translation matrix and stores it in a given matrix
  90667. * @param x defines the translation on X axis
  90668. * @param y defines the translation on Y axis
  90669. * @param z defines the translationon Z axis
  90670. * @param result defines the target matrix
  90671. */
  90672. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  90673. /**
  90674. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  90675. * @param startValue defines the start value
  90676. * @param endValue defines the end value
  90677. * @param gradient defines the gradient factor
  90678. * @returns the new matrix
  90679. */
  90680. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  90681. /**
  90682. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  90683. * @param startValue defines the start value
  90684. * @param endValue defines the end value
  90685. * @param gradient defines the gradient factor
  90686. * @param result defines the Matrix object where to store data
  90687. */
  90688. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  90689. /**
  90690. * Builds a new matrix whose values are computed by:
  90691. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  90692. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  90693. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  90694. * @param startValue defines the first matrix
  90695. * @param endValue defines the second matrix
  90696. * @param gradient defines the gradient between the two matrices
  90697. * @returns the new matrix
  90698. */
  90699. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  90700. /**
  90701. * Update a matrix to values which are computed by:
  90702. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  90703. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  90704. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  90705. * @param startValue defines the first matrix
  90706. * @param endValue defines the second matrix
  90707. * @param gradient defines the gradient between the two matrices
  90708. * @param result defines the target matrix
  90709. */
  90710. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  90711. /**
  90712. * 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"
  90713. * This function works in left handed mode
  90714. * @param eye defines the final position of the entity
  90715. * @param target defines where the entity should look at
  90716. * @param up defines the up vector for the entity
  90717. * @returns the new matrix
  90718. */
  90719. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  90720. /**
  90721. * 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".
  90722. * This function works in left handed mode
  90723. * @param eye defines the final position of the entity
  90724. * @param target defines where the entity should look at
  90725. * @param up defines the up vector for the entity
  90726. * @param result defines the target matrix
  90727. */
  90728. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  90729. /**
  90730. * 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"
  90731. * This function works in right handed mode
  90732. * @param eye defines the final position of the entity
  90733. * @param target defines where the entity should look at
  90734. * @param up defines the up vector for the entity
  90735. * @returns the new matrix
  90736. */
  90737. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  90738. /**
  90739. * 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".
  90740. * This function works in right handed mode
  90741. * @param eye defines the final position of the entity
  90742. * @param target defines where the entity should look at
  90743. * @param up defines the up vector for the entity
  90744. * @param result defines the target matrix
  90745. */
  90746. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  90747. /**
  90748. * Create a left-handed orthographic projection matrix
  90749. * @param width defines the viewport width
  90750. * @param height defines the viewport height
  90751. * @param znear defines the near clip plane
  90752. * @param zfar defines the far clip plane
  90753. * @returns a new matrix as a left-handed orthographic projection matrix
  90754. */
  90755. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  90756. /**
  90757. * Store a left-handed orthographic projection to a given matrix
  90758. * @param width defines the viewport width
  90759. * @param height defines the viewport height
  90760. * @param znear defines the near clip plane
  90761. * @param zfar defines the far clip plane
  90762. * @param result defines the target matrix
  90763. */
  90764. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  90765. /**
  90766. * Create a left-handed orthographic projection matrix
  90767. * @param left defines the viewport left coordinate
  90768. * @param right defines the viewport right coordinate
  90769. * @param bottom defines the viewport bottom coordinate
  90770. * @param top defines the viewport top coordinate
  90771. * @param znear defines the near clip plane
  90772. * @param zfar defines the far clip plane
  90773. * @returns a new matrix as a left-handed orthographic projection matrix
  90774. */
  90775. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  90776. /**
  90777. * Stores a left-handed orthographic projection into a given matrix
  90778. * @param left defines the viewport left coordinate
  90779. * @param right defines the viewport right coordinate
  90780. * @param bottom defines the viewport bottom coordinate
  90781. * @param top defines the viewport top coordinate
  90782. * @param znear defines the near clip plane
  90783. * @param zfar defines the far clip plane
  90784. * @param result defines the target matrix
  90785. */
  90786. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  90787. /**
  90788. * Creates a right-handed orthographic projection matrix
  90789. * @param left defines the viewport left coordinate
  90790. * @param right defines the viewport right coordinate
  90791. * @param bottom defines the viewport bottom coordinate
  90792. * @param top defines the viewport top coordinate
  90793. * @param znear defines the near clip plane
  90794. * @param zfar defines the far clip plane
  90795. * @returns a new matrix as a right-handed orthographic projection matrix
  90796. */
  90797. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  90798. /**
  90799. * Stores a right-handed orthographic projection into a given matrix
  90800. * @param left defines the viewport left coordinate
  90801. * @param right defines the viewport right coordinate
  90802. * @param bottom defines the viewport bottom coordinate
  90803. * @param top defines the viewport top coordinate
  90804. * @param znear defines the near clip plane
  90805. * @param zfar defines the far clip plane
  90806. * @param result defines the target matrix
  90807. */
  90808. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  90809. /**
  90810. * Creates a left-handed perspective projection matrix
  90811. * @param width defines the viewport width
  90812. * @param height defines the viewport height
  90813. * @param znear defines the near clip plane
  90814. * @param zfar defines the far clip plane
  90815. * @returns a new matrix as a left-handed perspective projection matrix
  90816. */
  90817. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  90818. /**
  90819. * Creates a left-handed perspective projection matrix
  90820. * @param fov defines the horizontal field of view
  90821. * @param aspect defines the aspect ratio
  90822. * @param znear defines the near clip plane
  90823. * @param zfar defines the far clip plane
  90824. * @returns a new matrix as a left-handed perspective projection matrix
  90825. */
  90826. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  90827. /**
  90828. * Stores a left-handed perspective projection into a given matrix
  90829. * @param fov defines the horizontal field of view
  90830. * @param aspect defines the aspect ratio
  90831. * @param znear defines the near clip plane
  90832. * @param zfar defines the far clip plane
  90833. * @param result defines the target matrix
  90834. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90835. */
  90836. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90837. /**
  90838. * Stores a left-handed perspective projection into a given matrix with depth reversed
  90839. * @param fov defines the horizontal field of view
  90840. * @param aspect defines the aspect ratio
  90841. * @param znear defines the near clip plane
  90842. * @param zfar not used as infinity is used as far clip
  90843. * @param result defines the target matrix
  90844. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90845. */
  90846. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90847. /**
  90848. * Creates a right-handed perspective projection matrix
  90849. * @param fov defines the horizontal field of view
  90850. * @param aspect defines the aspect ratio
  90851. * @param znear defines the near clip plane
  90852. * @param zfar defines the far clip plane
  90853. * @returns a new matrix as a right-handed perspective projection matrix
  90854. */
  90855. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  90856. /**
  90857. * Stores a right-handed perspective projection into a given matrix
  90858. * @param fov defines the horizontal field of view
  90859. * @param aspect defines the aspect ratio
  90860. * @param znear defines the near clip plane
  90861. * @param zfar defines the far clip plane
  90862. * @param result defines the target matrix
  90863. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90864. */
  90865. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90866. /**
  90867. * Stores a right-handed perspective projection into a given matrix
  90868. * @param fov defines the horizontal field of view
  90869. * @param aspect defines the aspect ratio
  90870. * @param znear defines the near clip plane
  90871. * @param zfar not used as infinity is used as far clip
  90872. * @param result defines the target matrix
  90873. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  90874. */
  90875. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  90876. /**
  90877. * Stores a perspective projection for WebVR info a given matrix
  90878. * @param fov defines the field of view
  90879. * @param znear defines the near clip plane
  90880. * @param zfar defines the far clip plane
  90881. * @param result defines the target matrix
  90882. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  90883. */
  90884. static PerspectiveFovWebVRToRef(fov: {
  90885. upDegrees: number;
  90886. downDegrees: number;
  90887. leftDegrees: number;
  90888. rightDegrees: number;
  90889. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  90890. /**
  90891. * Computes a complete transformation matrix
  90892. * @param viewport defines the viewport to use
  90893. * @param world defines the world matrix
  90894. * @param view defines the view matrix
  90895. * @param projection defines the projection matrix
  90896. * @param zmin defines the near clip plane
  90897. * @param zmax defines the far clip plane
  90898. * @returns the transformation matrix
  90899. */
  90900. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  90901. /**
  90902. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  90903. * @param matrix defines the matrix to use
  90904. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  90905. */
  90906. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  90907. /**
  90908. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  90909. * @param matrix defines the matrix to use
  90910. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  90911. */
  90912. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  90913. /**
  90914. * Compute the transpose of a given matrix
  90915. * @param matrix defines the matrix to transpose
  90916. * @returns the new matrix
  90917. */
  90918. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  90919. /**
  90920. * Compute the transpose of a matrix and store it in a target matrix
  90921. * @param matrix defines the matrix to transpose
  90922. * @param result defines the target matrix
  90923. */
  90924. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  90925. /**
  90926. * Computes a reflection matrix from a plane
  90927. * @param plane defines the reflection plane
  90928. * @returns a new matrix
  90929. */
  90930. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  90931. /**
  90932. * Computes a reflection matrix from a plane
  90933. * @param plane defines the reflection plane
  90934. * @param result defines the target matrix
  90935. */
  90936. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  90937. /**
  90938. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  90939. * @param xaxis defines the value of the 1st axis
  90940. * @param yaxis defines the value of the 2nd axis
  90941. * @param zaxis defines the value of the 3rd axis
  90942. * @param result defines the target matrix
  90943. */
  90944. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  90945. /**
  90946. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  90947. * @param quat defines the quaternion to use
  90948. * @param result defines the target matrix
  90949. */
  90950. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  90951. }
  90952. /**
  90953. * @hidden
  90954. */
  90955. export class TmpVectors {
  90956. static Vector2: Vector2[];
  90957. static Vector3: Vector3[];
  90958. static Vector4: Vector4[];
  90959. static Quaternion: Quaternion[];
  90960. static Matrix: Matrix[];
  90961. }
  90962. }
  90963. declare module BABYLON {
  90964. /**
  90965. * Defines potential orientation for back face culling
  90966. */
  90967. export enum Orientation {
  90968. /**
  90969. * Clockwise
  90970. */
  90971. CW = 0,
  90972. /** Counter clockwise */
  90973. CCW = 1
  90974. }
  90975. /** Class used to represent a Bezier curve */
  90976. export class BezierCurve {
  90977. /**
  90978. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  90979. * @param t defines the time
  90980. * @param x1 defines the left coordinate on X axis
  90981. * @param y1 defines the left coordinate on Y axis
  90982. * @param x2 defines the right coordinate on X axis
  90983. * @param y2 defines the right coordinate on Y axis
  90984. * @returns the interpolated value
  90985. */
  90986. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  90987. }
  90988. /**
  90989. * Defines angle representation
  90990. */
  90991. export class Angle {
  90992. private _radians;
  90993. /**
  90994. * Creates an Angle object of "radians" radians (float).
  90995. * @param radians the angle in radians
  90996. */
  90997. constructor(radians: number);
  90998. /**
  90999. * Get value in degrees
  91000. * @returns the Angle value in degrees (float)
  91001. */
  91002. degrees(): number;
  91003. /**
  91004. * Get value in radians
  91005. * @returns the Angle value in radians (float)
  91006. */
  91007. radians(): number;
  91008. /**
  91009. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  91010. * @param a defines first point as the origin
  91011. * @param b defines point
  91012. * @returns a new Angle
  91013. */
  91014. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  91015. /**
  91016. * Gets a new Angle object from the given float in radians
  91017. * @param radians defines the angle value in radians
  91018. * @returns a new Angle
  91019. */
  91020. static FromRadians(radians: number): Angle;
  91021. /**
  91022. * Gets a new Angle object from the given float in degrees
  91023. * @param degrees defines the angle value in degrees
  91024. * @returns a new Angle
  91025. */
  91026. static FromDegrees(degrees: number): Angle;
  91027. }
  91028. /**
  91029. * This represents an arc in a 2d space.
  91030. */
  91031. export class Arc2 {
  91032. /** Defines the start point of the arc */
  91033. startPoint: Vector2;
  91034. /** Defines the mid point of the arc */
  91035. midPoint: Vector2;
  91036. /** Defines the end point of the arc */
  91037. endPoint: Vector2;
  91038. /**
  91039. * Defines the center point of the arc.
  91040. */
  91041. centerPoint: Vector2;
  91042. /**
  91043. * Defines the radius of the arc.
  91044. */
  91045. radius: number;
  91046. /**
  91047. * Defines the angle of the arc (from mid point to end point).
  91048. */
  91049. angle: Angle;
  91050. /**
  91051. * Defines the start angle of the arc (from start point to middle point).
  91052. */
  91053. startAngle: Angle;
  91054. /**
  91055. * Defines the orientation of the arc (clock wise/counter clock wise).
  91056. */
  91057. orientation: Orientation;
  91058. /**
  91059. * Creates an Arc object from the three given points : start, middle and end.
  91060. * @param startPoint Defines the start point of the arc
  91061. * @param midPoint Defines the midlle point of the arc
  91062. * @param endPoint Defines the end point of the arc
  91063. */
  91064. constructor(
  91065. /** Defines the start point of the arc */
  91066. startPoint: Vector2,
  91067. /** Defines the mid point of the arc */
  91068. midPoint: Vector2,
  91069. /** Defines the end point of the arc */
  91070. endPoint: Vector2);
  91071. }
  91072. /**
  91073. * Represents a 2D path made up of multiple 2D points
  91074. */
  91075. export class Path2 {
  91076. private _points;
  91077. private _length;
  91078. /**
  91079. * If the path start and end point are the same
  91080. */
  91081. closed: boolean;
  91082. /**
  91083. * Creates a Path2 object from the starting 2D coordinates x and y.
  91084. * @param x the starting points x value
  91085. * @param y the starting points y value
  91086. */
  91087. constructor(x: number, y: number);
  91088. /**
  91089. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  91090. * @param x the added points x value
  91091. * @param y the added points y value
  91092. * @returns the updated Path2.
  91093. */
  91094. addLineTo(x: number, y: number): Path2;
  91095. /**
  91096. * 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.
  91097. * @param midX middle point x value
  91098. * @param midY middle point y value
  91099. * @param endX end point x value
  91100. * @param endY end point y value
  91101. * @param numberOfSegments (default: 36)
  91102. * @returns the updated Path2.
  91103. */
  91104. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  91105. /**
  91106. * Closes the Path2.
  91107. * @returns the Path2.
  91108. */
  91109. close(): Path2;
  91110. /**
  91111. * Gets the sum of the distance between each sequential point in the path
  91112. * @returns the Path2 total length (float).
  91113. */
  91114. length(): number;
  91115. /**
  91116. * Gets the points which construct the path
  91117. * @returns the Path2 internal array of points.
  91118. */
  91119. getPoints(): Vector2[];
  91120. /**
  91121. * Retreives the point at the distance aways from the starting point
  91122. * @param normalizedLengthPosition the length along the path to retreive the point from
  91123. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  91124. */
  91125. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  91126. /**
  91127. * Creates a new path starting from an x and y position
  91128. * @param x starting x value
  91129. * @param y starting y value
  91130. * @returns a new Path2 starting at the coordinates (x, y).
  91131. */
  91132. static StartingAt(x: number, y: number): Path2;
  91133. }
  91134. /**
  91135. * Represents a 3D path made up of multiple 3D points
  91136. */
  91137. export class Path3D {
  91138. /**
  91139. * an array of Vector3, the curve axis of the Path3D
  91140. */
  91141. path: Vector3[];
  91142. private _curve;
  91143. private _distances;
  91144. private _tangents;
  91145. private _normals;
  91146. private _binormals;
  91147. private _raw;
  91148. private _alignTangentsWithPath;
  91149. private readonly _pointAtData;
  91150. /**
  91151. * new Path3D(path, normal, raw)
  91152. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  91153. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  91154. * @param path an array of Vector3, the curve axis of the Path3D
  91155. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  91156. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  91157. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  91158. */
  91159. constructor(
  91160. /**
  91161. * an array of Vector3, the curve axis of the Path3D
  91162. */
  91163. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  91164. /**
  91165. * Returns the Path3D array of successive Vector3 designing its curve.
  91166. * @returns the Path3D array of successive Vector3 designing its curve.
  91167. */
  91168. getCurve(): Vector3[];
  91169. /**
  91170. * Returns the Path3D array of successive Vector3 designing its curve.
  91171. * @returns the Path3D array of successive Vector3 designing its curve.
  91172. */
  91173. getPoints(): Vector3[];
  91174. /**
  91175. * @returns the computed length (float) of the path.
  91176. */
  91177. length(): number;
  91178. /**
  91179. * Returns an array populated with tangent vectors on each Path3D curve point.
  91180. * @returns an array populated with tangent vectors on each Path3D curve point.
  91181. */
  91182. getTangents(): Vector3[];
  91183. /**
  91184. * Returns an array populated with normal vectors on each Path3D curve point.
  91185. * @returns an array populated with normal vectors on each Path3D curve point.
  91186. */
  91187. getNormals(): Vector3[];
  91188. /**
  91189. * Returns an array populated with binormal vectors on each Path3D curve point.
  91190. * @returns an array populated with binormal vectors on each Path3D curve point.
  91191. */
  91192. getBinormals(): Vector3[];
  91193. /**
  91194. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  91195. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  91196. */
  91197. getDistances(): number[];
  91198. /**
  91199. * Returns an interpolated point along this path
  91200. * @param position the position of the point along this path, from 0.0 to 1.0
  91201. * @returns a new Vector3 as the point
  91202. */
  91203. getPointAt(position: number): Vector3;
  91204. /**
  91205. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  91206. * @param position the position of the point along this path, from 0.0 to 1.0
  91207. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  91208. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  91209. */
  91210. getTangentAt(position: number, interpolated?: boolean): Vector3;
  91211. /**
  91212. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  91213. * @param position the position of the point along this path, from 0.0 to 1.0
  91214. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  91215. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  91216. */
  91217. getNormalAt(position: number, interpolated?: boolean): Vector3;
  91218. /**
  91219. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  91220. * @param position the position of the point along this path, from 0.0 to 1.0
  91221. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  91222. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  91223. */
  91224. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  91225. /**
  91226. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  91227. * @param position the position of the point along this path, from 0.0 to 1.0
  91228. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  91229. */
  91230. getDistanceAt(position: number): number;
  91231. /**
  91232. * Returns the array index of the previous point of an interpolated point along this path
  91233. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  91234. * @returns the array index
  91235. */
  91236. getPreviousPointIndexAt(position: number): number;
  91237. /**
  91238. * 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)
  91239. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  91240. * @returns the sub position
  91241. */
  91242. getSubPositionAt(position: number): number;
  91243. /**
  91244. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  91245. * @param target the vector of which to get the closest position to
  91246. * @returns the position of the closest virtual point on this path to the target vector
  91247. */
  91248. getClosestPositionTo(target: Vector3): number;
  91249. /**
  91250. * Returns a sub path (slice) of this path
  91251. * @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
  91252. * @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
  91253. * @returns a sub path (slice) of this path
  91254. */
  91255. slice(start?: number, end?: number): Path3D;
  91256. /**
  91257. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  91258. * @param path path which all values are copied into the curves points
  91259. * @param firstNormal which should be projected onto the curve
  91260. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  91261. * @returns the same object updated.
  91262. */
  91263. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  91264. private _compute;
  91265. private _getFirstNonNullVector;
  91266. private _getLastNonNullVector;
  91267. private _normalVector;
  91268. /**
  91269. * Updates the point at data for an interpolated point along this curve
  91270. * @param position the position of the point along this curve, from 0.0 to 1.0
  91271. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  91272. * @returns the (updated) point at data
  91273. */
  91274. private _updatePointAtData;
  91275. /**
  91276. * Updates the point at data from the specified parameters
  91277. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  91278. * @param point the interpolated point
  91279. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  91280. */
  91281. private _setPointAtData;
  91282. /**
  91283. * Updates the point at interpolation matrix for the tangents, normals and binormals
  91284. */
  91285. private _updateInterpolationMatrix;
  91286. }
  91287. /**
  91288. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  91289. * A Curve3 is designed from a series of successive Vector3.
  91290. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  91291. */
  91292. export class Curve3 {
  91293. private _points;
  91294. private _length;
  91295. /**
  91296. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  91297. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  91298. * @param v1 (Vector3) the control point
  91299. * @param v2 (Vector3) the end point of the Quadratic Bezier
  91300. * @param nbPoints (integer) the wanted number of points in the curve
  91301. * @returns the created Curve3
  91302. */
  91303. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  91304. /**
  91305. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  91306. * @param v0 (Vector3) the origin point of the Cubic Bezier
  91307. * @param v1 (Vector3) the first control point
  91308. * @param v2 (Vector3) the second control point
  91309. * @param v3 (Vector3) the end point of the Cubic Bezier
  91310. * @param nbPoints (integer) the wanted number of points in the curve
  91311. * @returns the created Curve3
  91312. */
  91313. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  91314. /**
  91315. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  91316. * @param p1 (Vector3) the origin point of the Hermite Spline
  91317. * @param t1 (Vector3) the tangent vector at the origin point
  91318. * @param p2 (Vector3) the end point of the Hermite Spline
  91319. * @param t2 (Vector3) the tangent vector at the end point
  91320. * @param nbPoints (integer) the wanted number of points in the curve
  91321. * @returns the created Curve3
  91322. */
  91323. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  91324. /**
  91325. * Returns a Curve3 object along a CatmullRom Spline curve :
  91326. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  91327. * @param nbPoints (integer) the wanted number of points between each curve control points
  91328. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  91329. * @returns the created Curve3
  91330. */
  91331. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  91332. /**
  91333. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  91334. * A Curve3 is designed from a series of successive Vector3.
  91335. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  91336. * @param points points which make up the curve
  91337. */
  91338. constructor(points: Vector3[]);
  91339. /**
  91340. * @returns the Curve3 stored array of successive Vector3
  91341. */
  91342. getPoints(): Vector3[];
  91343. /**
  91344. * @returns the computed length (float) of the curve.
  91345. */
  91346. length(): number;
  91347. /**
  91348. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  91349. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  91350. * curveA and curveB keep unchanged.
  91351. * @param curve the curve to continue from this curve
  91352. * @returns the newly constructed curve
  91353. */
  91354. continue(curve: DeepImmutable<Curve3>): Curve3;
  91355. private _computeLength;
  91356. }
  91357. }
  91358. declare module BABYLON {
  91359. /**
  91360. * This represents the main contract an easing function should follow.
  91361. * Easing functions are used throughout the animation system.
  91362. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91363. */
  91364. export interface IEasingFunction {
  91365. /**
  91366. * Given an input gradient between 0 and 1, this returns the corresponding value
  91367. * of the easing function.
  91368. * The link below provides some of the most common examples of easing functions.
  91369. * @see https://easings.net/
  91370. * @param gradient Defines the value between 0 and 1 we want the easing value for
  91371. * @returns the corresponding value on the curve defined by the easing function
  91372. */
  91373. ease(gradient: number): number;
  91374. }
  91375. /**
  91376. * Base class used for every default easing function.
  91377. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91378. */
  91379. export class EasingFunction implements IEasingFunction {
  91380. /**
  91381. * Interpolation follows the mathematical formula associated with the easing function.
  91382. */
  91383. static readonly EASINGMODE_EASEIN: number;
  91384. /**
  91385. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  91386. */
  91387. static readonly EASINGMODE_EASEOUT: number;
  91388. /**
  91389. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  91390. */
  91391. static readonly EASINGMODE_EASEINOUT: number;
  91392. private _easingMode;
  91393. /**
  91394. * Sets the easing mode of the current function.
  91395. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  91396. */
  91397. setEasingMode(easingMode: number): void;
  91398. /**
  91399. * Gets the current easing mode.
  91400. * @returns the easing mode
  91401. */
  91402. getEasingMode(): number;
  91403. /**
  91404. * @hidden
  91405. */
  91406. easeInCore(gradient: number): number;
  91407. /**
  91408. * Given an input gradient between 0 and 1, this returns the corresponding value
  91409. * of the easing function.
  91410. * @param gradient Defines the value between 0 and 1 we want the easing value for
  91411. * @returns the corresponding value on the curve defined by the easing function
  91412. */
  91413. ease(gradient: number): number;
  91414. }
  91415. /**
  91416. * Easing function with a circle shape (see link below).
  91417. * @see https://easings.net/#easeInCirc
  91418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91419. */
  91420. export class CircleEase extends EasingFunction implements IEasingFunction {
  91421. /** @hidden */
  91422. easeInCore(gradient: number): number;
  91423. }
  91424. /**
  91425. * Easing function with a ease back shape (see link below).
  91426. * @see https://easings.net/#easeInBack
  91427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91428. */
  91429. export class BackEase extends EasingFunction implements IEasingFunction {
  91430. /** Defines the amplitude of the function */
  91431. amplitude: number;
  91432. /**
  91433. * Instantiates a back ease easing
  91434. * @see https://easings.net/#easeInBack
  91435. * @param amplitude Defines the amplitude of the function
  91436. */
  91437. constructor(
  91438. /** Defines the amplitude of the function */
  91439. amplitude?: number);
  91440. /** @hidden */
  91441. easeInCore(gradient: number): number;
  91442. }
  91443. /**
  91444. * Easing function with a bouncing shape (see link below).
  91445. * @see https://easings.net/#easeInBounce
  91446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91447. */
  91448. export class BounceEase extends EasingFunction implements IEasingFunction {
  91449. /** Defines the number of bounces */
  91450. bounces: number;
  91451. /** Defines the amplitude of the bounce */
  91452. bounciness: number;
  91453. /**
  91454. * Instantiates a bounce easing
  91455. * @see https://easings.net/#easeInBounce
  91456. * @param bounces Defines the number of bounces
  91457. * @param bounciness Defines the amplitude of the bounce
  91458. */
  91459. constructor(
  91460. /** Defines the number of bounces */
  91461. bounces?: number,
  91462. /** Defines the amplitude of the bounce */
  91463. bounciness?: number);
  91464. /** @hidden */
  91465. easeInCore(gradient: number): number;
  91466. }
  91467. /**
  91468. * Easing function with a power of 3 shape (see link below).
  91469. * @see https://easings.net/#easeInCubic
  91470. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91471. */
  91472. export class CubicEase extends EasingFunction implements IEasingFunction {
  91473. /** @hidden */
  91474. easeInCore(gradient: number): number;
  91475. }
  91476. /**
  91477. * Easing function with an elastic shape (see link below).
  91478. * @see https://easings.net/#easeInElastic
  91479. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91480. */
  91481. export class ElasticEase extends EasingFunction implements IEasingFunction {
  91482. /** Defines the number of oscillations*/
  91483. oscillations: number;
  91484. /** Defines the amplitude of the oscillations*/
  91485. springiness: number;
  91486. /**
  91487. * Instantiates an elastic easing function
  91488. * @see https://easings.net/#easeInElastic
  91489. * @param oscillations Defines the number of oscillations
  91490. * @param springiness Defines the amplitude of the oscillations
  91491. */
  91492. constructor(
  91493. /** Defines the number of oscillations*/
  91494. oscillations?: number,
  91495. /** Defines the amplitude of the oscillations*/
  91496. springiness?: number);
  91497. /** @hidden */
  91498. easeInCore(gradient: number): number;
  91499. }
  91500. /**
  91501. * Easing function with an exponential shape (see link below).
  91502. * @see https://easings.net/#easeInExpo
  91503. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91504. */
  91505. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  91506. /** Defines the exponent of the function */
  91507. exponent: number;
  91508. /**
  91509. * Instantiates an exponential easing function
  91510. * @see https://easings.net/#easeInExpo
  91511. * @param exponent Defines the exponent of the function
  91512. */
  91513. constructor(
  91514. /** Defines the exponent of the function */
  91515. exponent?: number);
  91516. /** @hidden */
  91517. easeInCore(gradient: number): number;
  91518. }
  91519. /**
  91520. * Easing function with a power shape (see link below).
  91521. * @see https://easings.net/#easeInQuad
  91522. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91523. */
  91524. export class PowerEase extends EasingFunction implements IEasingFunction {
  91525. /** Defines the power of the function */
  91526. power: number;
  91527. /**
  91528. * Instantiates an power base easing function
  91529. * @see https://easings.net/#easeInQuad
  91530. * @param power Defines the power of the function
  91531. */
  91532. constructor(
  91533. /** Defines the power of the function */
  91534. power?: number);
  91535. /** @hidden */
  91536. easeInCore(gradient: number): number;
  91537. }
  91538. /**
  91539. * Easing function with a power of 2 shape (see link below).
  91540. * @see https://easings.net/#easeInQuad
  91541. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91542. */
  91543. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  91544. /** @hidden */
  91545. easeInCore(gradient: number): number;
  91546. }
  91547. /**
  91548. * Easing function with a power of 4 shape (see link below).
  91549. * @see https://easings.net/#easeInQuart
  91550. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91551. */
  91552. export class QuarticEase extends EasingFunction implements IEasingFunction {
  91553. /** @hidden */
  91554. easeInCore(gradient: number): number;
  91555. }
  91556. /**
  91557. * Easing function with a power of 5 shape (see link below).
  91558. * @see https://easings.net/#easeInQuint
  91559. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91560. */
  91561. export class QuinticEase extends EasingFunction implements IEasingFunction {
  91562. /** @hidden */
  91563. easeInCore(gradient: number): number;
  91564. }
  91565. /**
  91566. * Easing function with a sin shape (see link below).
  91567. * @see https://easings.net/#easeInSine
  91568. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91569. */
  91570. export class SineEase extends EasingFunction implements IEasingFunction {
  91571. /** @hidden */
  91572. easeInCore(gradient: number): number;
  91573. }
  91574. /**
  91575. * Easing function with a bezier shape (see link below).
  91576. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  91577. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  91578. */
  91579. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  91580. /** Defines the x component of the start tangent in the bezier curve */
  91581. x1: number;
  91582. /** Defines the y component of the start tangent in the bezier curve */
  91583. y1: number;
  91584. /** Defines the x component of the end tangent in the bezier curve */
  91585. x2: number;
  91586. /** Defines the y component of the end tangent in the bezier curve */
  91587. y2: number;
  91588. /**
  91589. * Instantiates a bezier function
  91590. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  91591. * @param x1 Defines the x component of the start tangent in the bezier curve
  91592. * @param y1 Defines the y component of the start tangent in the bezier curve
  91593. * @param x2 Defines the x component of the end tangent in the bezier curve
  91594. * @param y2 Defines the y component of the end tangent in the bezier curve
  91595. */
  91596. constructor(
  91597. /** Defines the x component of the start tangent in the bezier curve */
  91598. x1?: number,
  91599. /** Defines the y component of the start tangent in the bezier curve */
  91600. y1?: number,
  91601. /** Defines the x component of the end tangent in the bezier curve */
  91602. x2?: number,
  91603. /** Defines the y component of the end tangent in the bezier curve */
  91604. y2?: number);
  91605. /** @hidden */
  91606. easeInCore(gradient: number): number;
  91607. }
  91608. }
  91609. declare module BABYLON {
  91610. /**
  91611. * Class used to hold a RGB color
  91612. */
  91613. export class Color3 {
  91614. /**
  91615. * Defines the red component (between 0 and 1, default is 0)
  91616. */
  91617. r: number;
  91618. /**
  91619. * Defines the green component (between 0 and 1, default is 0)
  91620. */
  91621. g: number;
  91622. /**
  91623. * Defines the blue component (between 0 and 1, default is 0)
  91624. */
  91625. b: number;
  91626. /**
  91627. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  91628. * @param r defines the red component (between 0 and 1, default is 0)
  91629. * @param g defines the green component (between 0 and 1, default is 0)
  91630. * @param b defines the blue component (between 0 and 1, default is 0)
  91631. */
  91632. constructor(
  91633. /**
  91634. * Defines the red component (between 0 and 1, default is 0)
  91635. */
  91636. r?: number,
  91637. /**
  91638. * Defines the green component (between 0 and 1, default is 0)
  91639. */
  91640. g?: number,
  91641. /**
  91642. * Defines the blue component (between 0 and 1, default is 0)
  91643. */
  91644. b?: number);
  91645. /**
  91646. * Creates a string with the Color3 current values
  91647. * @returns the string representation of the Color3 object
  91648. */
  91649. toString(): string;
  91650. /**
  91651. * Returns the string "Color3"
  91652. * @returns "Color3"
  91653. */
  91654. getClassName(): string;
  91655. /**
  91656. * Compute the Color3 hash code
  91657. * @returns an unique number that can be used to hash Color3 objects
  91658. */
  91659. getHashCode(): number;
  91660. /**
  91661. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  91662. * @param array defines the array where to store the r,g,b components
  91663. * @param index defines an optional index in the target array to define where to start storing values
  91664. * @returns the current Color3 object
  91665. */
  91666. toArray(array: FloatArray, index?: number): Color3;
  91667. /**
  91668. * Update the current color with values stored in an array from the starting index of the given array
  91669. * @param array defines the source array
  91670. * @param offset defines an offset in the source array
  91671. * @returns the current Color3 object
  91672. */
  91673. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  91674. /**
  91675. * Returns a new Color4 object from the current Color3 and the given alpha
  91676. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  91677. * @returns a new Color4 object
  91678. */
  91679. toColor4(alpha?: number): Color4;
  91680. /**
  91681. * Returns a new array populated with 3 numeric elements : red, green and blue values
  91682. * @returns the new array
  91683. */
  91684. asArray(): number[];
  91685. /**
  91686. * Returns the luminance value
  91687. * @returns a float value
  91688. */
  91689. toLuminance(): number;
  91690. /**
  91691. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  91692. * @param otherColor defines the second operand
  91693. * @returns the new Color3 object
  91694. */
  91695. multiply(otherColor: DeepImmutable<Color3>): Color3;
  91696. /**
  91697. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  91698. * @param otherColor defines the second operand
  91699. * @param result defines the Color3 object where to store the result
  91700. * @returns the current Color3
  91701. */
  91702. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91703. /**
  91704. * Determines equality between Color3 objects
  91705. * @param otherColor defines the second operand
  91706. * @returns true if the rgb values are equal to the given ones
  91707. */
  91708. equals(otherColor: DeepImmutable<Color3>): boolean;
  91709. /**
  91710. * Determines equality between the current Color3 object and a set of r,b,g values
  91711. * @param r defines the red component to check
  91712. * @param g defines the green component to check
  91713. * @param b defines the blue component to check
  91714. * @returns true if the rgb values are equal to the given ones
  91715. */
  91716. equalsFloats(r: number, g: number, b: number): boolean;
  91717. /**
  91718. * Multiplies in place each rgb value by scale
  91719. * @param scale defines the scaling factor
  91720. * @returns the updated Color3
  91721. */
  91722. scale(scale: number): Color3;
  91723. /**
  91724. * Multiplies the rgb values by scale and stores the result into "result"
  91725. * @param scale defines the scaling factor
  91726. * @param result defines the Color3 object where to store the result
  91727. * @returns the unmodified current Color3
  91728. */
  91729. scaleToRef(scale: number, result: Color3): Color3;
  91730. /**
  91731. * Scale the current Color3 values by a factor and add the result to a given Color3
  91732. * @param scale defines the scale factor
  91733. * @param result defines color to store the result into
  91734. * @returns the unmodified current Color3
  91735. */
  91736. scaleAndAddToRef(scale: number, result: Color3): Color3;
  91737. /**
  91738. * Clamps the rgb values by the min and max values and stores the result into "result"
  91739. * @param min defines minimum clamping value (default is 0)
  91740. * @param max defines maximum clamping value (default is 1)
  91741. * @param result defines color to store the result into
  91742. * @returns the original Color3
  91743. */
  91744. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  91745. /**
  91746. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  91747. * @param otherColor defines the second operand
  91748. * @returns the new Color3
  91749. */
  91750. add(otherColor: DeepImmutable<Color3>): Color3;
  91751. /**
  91752. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  91753. * @param otherColor defines the second operand
  91754. * @param result defines Color3 object to store the result into
  91755. * @returns the unmodified current Color3
  91756. */
  91757. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91758. /**
  91759. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  91760. * @param otherColor defines the second operand
  91761. * @returns the new Color3
  91762. */
  91763. subtract(otherColor: DeepImmutable<Color3>): Color3;
  91764. /**
  91765. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  91766. * @param otherColor defines the second operand
  91767. * @param result defines Color3 object to store the result into
  91768. * @returns the unmodified current Color3
  91769. */
  91770. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  91771. /**
  91772. * Copy the current object
  91773. * @returns a new Color3 copied the current one
  91774. */
  91775. clone(): Color3;
  91776. /**
  91777. * Copies the rgb values from the source in the current Color3
  91778. * @param source defines the source Color3 object
  91779. * @returns the updated Color3 object
  91780. */
  91781. copyFrom(source: DeepImmutable<Color3>): Color3;
  91782. /**
  91783. * Updates the Color3 rgb values from the given floats
  91784. * @param r defines the red component to read from
  91785. * @param g defines the green component to read from
  91786. * @param b defines the blue component to read from
  91787. * @returns the current Color3 object
  91788. */
  91789. copyFromFloats(r: number, g: number, b: number): Color3;
  91790. /**
  91791. * Updates the Color3 rgb values from the given floats
  91792. * @param r defines the red component to read from
  91793. * @param g defines the green component to read from
  91794. * @param b defines the blue component to read from
  91795. * @returns the current Color3 object
  91796. */
  91797. set(r: number, g: number, b: number): Color3;
  91798. /**
  91799. * Compute the Color3 hexadecimal code as a string
  91800. * @returns a string containing the hexadecimal representation of the Color3 object
  91801. */
  91802. toHexString(): string;
  91803. /**
  91804. * Computes a new Color3 converted from the current one to linear space
  91805. * @returns a new Color3 object
  91806. */
  91807. toLinearSpace(): Color3;
  91808. /**
  91809. * Converts current color in rgb space to HSV values
  91810. * @returns a new color3 representing the HSV values
  91811. */
  91812. toHSV(): Color3;
  91813. /**
  91814. * Converts current color in rgb space to HSV values
  91815. * @param result defines the Color3 where to store the HSV values
  91816. */
  91817. toHSVToRef(result: Color3): void;
  91818. /**
  91819. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  91820. * @param convertedColor defines the Color3 object where to store the linear space version
  91821. * @returns the unmodified Color3
  91822. */
  91823. toLinearSpaceToRef(convertedColor: Color3): Color3;
  91824. /**
  91825. * Computes a new Color3 converted from the current one to gamma space
  91826. * @returns a new Color3 object
  91827. */
  91828. toGammaSpace(): Color3;
  91829. /**
  91830. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  91831. * @param convertedColor defines the Color3 object where to store the gamma space version
  91832. * @returns the unmodified Color3
  91833. */
  91834. toGammaSpaceToRef(convertedColor: Color3): Color3;
  91835. private static _BlackReadOnly;
  91836. /**
  91837. * Convert Hue, saturation and value to a Color3 (RGB)
  91838. * @param hue defines the hue
  91839. * @param saturation defines the saturation
  91840. * @param value defines the value
  91841. * @param result defines the Color3 where to store the RGB values
  91842. */
  91843. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  91844. /**
  91845. * Creates a new Color3 from the string containing valid hexadecimal values
  91846. * @param hex defines a string containing valid hexadecimal values
  91847. * @returns a new Color3 object
  91848. */
  91849. static FromHexString(hex: string): Color3;
  91850. /**
  91851. * Creates a new Color3 from the starting index of the given array
  91852. * @param array defines the source array
  91853. * @param offset defines an offset in the source array
  91854. * @returns a new Color3 object
  91855. */
  91856. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  91857. /**
  91858. * Creates a new Color3 from the starting index element of the given array
  91859. * @param array defines the source array to read from
  91860. * @param offset defines the offset in the source array
  91861. * @param result defines the target Color3 object
  91862. */
  91863. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  91864. /**
  91865. * Creates a new Color3 from integer values (< 256)
  91866. * @param r defines the red component to read from (value between 0 and 255)
  91867. * @param g defines the green component to read from (value between 0 and 255)
  91868. * @param b defines the blue component to read from (value between 0 and 255)
  91869. * @returns a new Color3 object
  91870. */
  91871. static FromInts(r: number, g: number, b: number): Color3;
  91872. /**
  91873. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  91874. * @param start defines the start Color3 value
  91875. * @param end defines the end Color3 value
  91876. * @param amount defines the gradient value between start and end
  91877. * @returns a new Color3 object
  91878. */
  91879. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  91880. /**
  91881. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  91882. * @param left defines the start value
  91883. * @param right defines the end value
  91884. * @param amount defines the gradient factor
  91885. * @param result defines the Color3 object where to store the result
  91886. */
  91887. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  91888. /**
  91889. * Returns a Color3 value containing a red color
  91890. * @returns a new Color3 object
  91891. */
  91892. static Red(): Color3;
  91893. /**
  91894. * Returns a Color3 value containing a green color
  91895. * @returns a new Color3 object
  91896. */
  91897. static Green(): Color3;
  91898. /**
  91899. * Returns a Color3 value containing a blue color
  91900. * @returns a new Color3 object
  91901. */
  91902. static Blue(): Color3;
  91903. /**
  91904. * Returns a Color3 value containing a black color
  91905. * @returns a new Color3 object
  91906. */
  91907. static Black(): Color3;
  91908. /**
  91909. * Gets a Color3 value containing a black color that must not be updated
  91910. */
  91911. static get BlackReadOnly(): DeepImmutable<Color3>;
  91912. /**
  91913. * Returns a Color3 value containing a white color
  91914. * @returns a new Color3 object
  91915. */
  91916. static White(): Color3;
  91917. /**
  91918. * Returns a Color3 value containing a purple color
  91919. * @returns a new Color3 object
  91920. */
  91921. static Purple(): Color3;
  91922. /**
  91923. * Returns a Color3 value containing a magenta color
  91924. * @returns a new Color3 object
  91925. */
  91926. static Magenta(): Color3;
  91927. /**
  91928. * Returns a Color3 value containing a yellow color
  91929. * @returns a new Color3 object
  91930. */
  91931. static Yellow(): Color3;
  91932. /**
  91933. * Returns a Color3 value containing a gray color
  91934. * @returns a new Color3 object
  91935. */
  91936. static Gray(): Color3;
  91937. /**
  91938. * Returns a Color3 value containing a teal color
  91939. * @returns a new Color3 object
  91940. */
  91941. static Teal(): Color3;
  91942. /**
  91943. * Returns a Color3 value containing a random color
  91944. * @returns a new Color3 object
  91945. */
  91946. static Random(): Color3;
  91947. }
  91948. /**
  91949. * Class used to hold a RBGA color
  91950. */
  91951. export class Color4 {
  91952. /**
  91953. * Defines the red component (between 0 and 1, default is 0)
  91954. */
  91955. r: number;
  91956. /**
  91957. * Defines the green component (between 0 and 1, default is 0)
  91958. */
  91959. g: number;
  91960. /**
  91961. * Defines the blue component (between 0 and 1, default is 0)
  91962. */
  91963. b: number;
  91964. /**
  91965. * Defines the alpha component (between 0 and 1, default is 1)
  91966. */
  91967. a: number;
  91968. /**
  91969. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  91970. * @param r defines the red component (between 0 and 1, default is 0)
  91971. * @param g defines the green component (between 0 and 1, default is 0)
  91972. * @param b defines the blue component (between 0 and 1, default is 0)
  91973. * @param a defines the alpha component (between 0 and 1, default is 1)
  91974. */
  91975. constructor(
  91976. /**
  91977. * Defines the red component (between 0 and 1, default is 0)
  91978. */
  91979. r?: number,
  91980. /**
  91981. * Defines the green component (between 0 and 1, default is 0)
  91982. */
  91983. g?: number,
  91984. /**
  91985. * Defines the blue component (between 0 and 1, default is 0)
  91986. */
  91987. b?: number,
  91988. /**
  91989. * Defines the alpha component (between 0 and 1, default is 1)
  91990. */
  91991. a?: number);
  91992. /**
  91993. * Adds in place the given Color4 values to the current Color4 object
  91994. * @param right defines the second operand
  91995. * @returns the current updated Color4 object
  91996. */
  91997. addInPlace(right: DeepImmutable<Color4>): Color4;
  91998. /**
  91999. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  92000. * @returns the new array
  92001. */
  92002. asArray(): number[];
  92003. /**
  92004. * Stores from the starting index in the given array the Color4 successive values
  92005. * @param array defines the array where to store the r,g,b components
  92006. * @param index defines an optional index in the target array to define where to start storing values
  92007. * @returns the current Color4 object
  92008. */
  92009. toArray(array: number[], index?: number): Color4;
  92010. /**
  92011. * Update the current color with values stored in an array from the starting index of the given array
  92012. * @param array defines the source array
  92013. * @param offset defines an offset in the source array
  92014. * @returns the current Color4 object
  92015. */
  92016. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  92017. /**
  92018. * Determines equality between Color4 objects
  92019. * @param otherColor defines the second operand
  92020. * @returns true if the rgba values are equal to the given ones
  92021. */
  92022. equals(otherColor: DeepImmutable<Color4>): boolean;
  92023. /**
  92024. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  92025. * @param right defines the second operand
  92026. * @returns a new Color4 object
  92027. */
  92028. add(right: DeepImmutable<Color4>): Color4;
  92029. /**
  92030. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  92031. * @param right defines the second operand
  92032. * @returns a new Color4 object
  92033. */
  92034. subtract(right: DeepImmutable<Color4>): Color4;
  92035. /**
  92036. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  92037. * @param right defines the second operand
  92038. * @param result defines the Color4 object where to store the result
  92039. * @returns the current Color4 object
  92040. */
  92041. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  92042. /**
  92043. * Creates a new Color4 with the current Color4 values multiplied by scale
  92044. * @param scale defines the scaling factor to apply
  92045. * @returns a new Color4 object
  92046. */
  92047. scale(scale: number): Color4;
  92048. /**
  92049. * Multiplies the current Color4 values by scale and stores the result in "result"
  92050. * @param scale defines the scaling factor to apply
  92051. * @param result defines the Color4 object where to store the result
  92052. * @returns the current unmodified Color4
  92053. */
  92054. scaleToRef(scale: number, result: Color4): Color4;
  92055. /**
  92056. * Scale the current Color4 values by a factor and add the result to a given Color4
  92057. * @param scale defines the scale factor
  92058. * @param result defines the Color4 object where to store the result
  92059. * @returns the unmodified current Color4
  92060. */
  92061. scaleAndAddToRef(scale: number, result: Color4): Color4;
  92062. /**
  92063. * Clamps the rgb values by the min and max values and stores the result into "result"
  92064. * @param min defines minimum clamping value (default is 0)
  92065. * @param max defines maximum clamping value (default is 1)
  92066. * @param result defines color to store the result into.
  92067. * @returns the cuurent Color4
  92068. */
  92069. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  92070. /**
  92071. * Multipy an Color4 value by another and return a new Color4 object
  92072. * @param color defines the Color4 value to multiply by
  92073. * @returns a new Color4 object
  92074. */
  92075. multiply(color: Color4): Color4;
  92076. /**
  92077. * Multipy a Color4 value by another and push the result in a reference value
  92078. * @param color defines the Color4 value to multiply by
  92079. * @param result defines the Color4 to fill the result in
  92080. * @returns the result Color4
  92081. */
  92082. multiplyToRef(color: Color4, result: Color4): Color4;
  92083. /**
  92084. * Creates a string with the Color4 current values
  92085. * @returns the string representation of the Color4 object
  92086. */
  92087. toString(): string;
  92088. /**
  92089. * Returns the string "Color4"
  92090. * @returns "Color4"
  92091. */
  92092. getClassName(): string;
  92093. /**
  92094. * Compute the Color4 hash code
  92095. * @returns an unique number that can be used to hash Color4 objects
  92096. */
  92097. getHashCode(): number;
  92098. /**
  92099. * Creates a new Color4 copied from the current one
  92100. * @returns a new Color4 object
  92101. */
  92102. clone(): Color4;
  92103. /**
  92104. * Copies the given Color4 values into the current one
  92105. * @param source defines the source Color4 object
  92106. * @returns the current updated Color4 object
  92107. */
  92108. copyFrom(source: Color4): Color4;
  92109. /**
  92110. * Copies the given float values into the current one
  92111. * @param r defines the red component to read from
  92112. * @param g defines the green component to read from
  92113. * @param b defines the blue component to read from
  92114. * @param a defines the alpha component to read from
  92115. * @returns the current updated Color4 object
  92116. */
  92117. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  92118. /**
  92119. * Copies the given float values into the current one
  92120. * @param r defines the red component to read from
  92121. * @param g defines the green component to read from
  92122. * @param b defines the blue component to read from
  92123. * @param a defines the alpha component to read from
  92124. * @returns the current updated Color4 object
  92125. */
  92126. set(r: number, g: number, b: number, a: number): Color4;
  92127. /**
  92128. * Compute the Color4 hexadecimal code as a string
  92129. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  92130. * @returns a string containing the hexadecimal representation of the Color4 object
  92131. */
  92132. toHexString(returnAsColor3?: boolean): string;
  92133. /**
  92134. * Computes a new Color4 converted from the current one to linear space
  92135. * @returns a new Color4 object
  92136. */
  92137. toLinearSpace(): Color4;
  92138. /**
  92139. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  92140. * @param convertedColor defines the Color4 object where to store the linear space version
  92141. * @returns the unmodified Color4
  92142. */
  92143. toLinearSpaceToRef(convertedColor: Color4): Color4;
  92144. /**
  92145. * Computes a new Color4 converted from the current one to gamma space
  92146. * @returns a new Color4 object
  92147. */
  92148. toGammaSpace(): Color4;
  92149. /**
  92150. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  92151. * @param convertedColor defines the Color4 object where to store the gamma space version
  92152. * @returns the unmodified Color4
  92153. */
  92154. toGammaSpaceToRef(convertedColor: Color4): Color4;
  92155. /**
  92156. * Creates a new Color4 from the string containing valid hexadecimal values
  92157. * @param hex defines a string containing valid hexadecimal values
  92158. * @returns a new Color4 object
  92159. */
  92160. static FromHexString(hex: string): Color4;
  92161. /**
  92162. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  92163. * @param left defines the start value
  92164. * @param right defines the end value
  92165. * @param amount defines the gradient factor
  92166. * @returns a new Color4 object
  92167. */
  92168. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  92169. /**
  92170. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  92171. * @param left defines the start value
  92172. * @param right defines the end value
  92173. * @param amount defines the gradient factor
  92174. * @param result defines the Color4 object where to store data
  92175. */
  92176. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  92177. /**
  92178. * Creates a new Color4 from a Color3 and an alpha value
  92179. * @param color3 defines the source Color3 to read from
  92180. * @param alpha defines the alpha component (1.0 by default)
  92181. * @returns a new Color4 object
  92182. */
  92183. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  92184. /**
  92185. * Creates a new Color4 from the starting index element of the given array
  92186. * @param array defines the source array to read from
  92187. * @param offset defines the offset in the source array
  92188. * @returns a new Color4 object
  92189. */
  92190. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  92191. /**
  92192. * Creates a new Color4 from the starting index element of the given array
  92193. * @param array defines the source array to read from
  92194. * @param offset defines the offset in the source array
  92195. * @param result defines the target Color4 object
  92196. */
  92197. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  92198. /**
  92199. * Creates a new Color3 from integer values (< 256)
  92200. * @param r defines the red component to read from (value between 0 and 255)
  92201. * @param g defines the green component to read from (value between 0 and 255)
  92202. * @param b defines the blue component to read from (value between 0 and 255)
  92203. * @param a defines the alpha component to read from (value between 0 and 255)
  92204. * @returns a new Color3 object
  92205. */
  92206. static FromInts(r: number, g: number, b: number, a: number): Color4;
  92207. /**
  92208. * Check the content of a given array and convert it to an array containing RGBA data
  92209. * If the original array was already containing count * 4 values then it is returned directly
  92210. * @param colors defines the array to check
  92211. * @param count defines the number of RGBA data to expect
  92212. * @returns an array containing count * 4 values (RGBA)
  92213. */
  92214. static CheckColors4(colors: number[], count: number): number[];
  92215. }
  92216. /**
  92217. * @hidden
  92218. */
  92219. export class TmpColors {
  92220. static Color3: Color3[];
  92221. static Color4: Color4[];
  92222. }
  92223. }
  92224. declare module BABYLON {
  92225. /**
  92226. * Defines an interface which represents an animation key frame
  92227. */
  92228. export interface IAnimationKey {
  92229. /**
  92230. * Frame of the key frame
  92231. */
  92232. frame: number;
  92233. /**
  92234. * Value at the specifies key frame
  92235. */
  92236. value: any;
  92237. /**
  92238. * The input tangent for the cubic hermite spline
  92239. */
  92240. inTangent?: any;
  92241. /**
  92242. * The output tangent for the cubic hermite spline
  92243. */
  92244. outTangent?: any;
  92245. /**
  92246. * The animation interpolation type
  92247. */
  92248. interpolation?: AnimationKeyInterpolation;
  92249. }
  92250. /**
  92251. * Enum for the animation key frame interpolation type
  92252. */
  92253. export enum AnimationKeyInterpolation {
  92254. /**
  92255. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  92256. */
  92257. STEP = 1
  92258. }
  92259. }
  92260. declare module BABYLON {
  92261. /**
  92262. * Represents the range of an animation
  92263. */
  92264. export class AnimationRange {
  92265. /**The name of the animation range**/
  92266. name: string;
  92267. /**The starting frame of the animation */
  92268. from: number;
  92269. /**The ending frame of the animation*/
  92270. to: number;
  92271. /**
  92272. * Initializes the range of an animation
  92273. * @param name The name of the animation range
  92274. * @param from The starting frame of the animation
  92275. * @param to The ending frame of the animation
  92276. */
  92277. constructor(
  92278. /**The name of the animation range**/
  92279. name: string,
  92280. /**The starting frame of the animation */
  92281. from: number,
  92282. /**The ending frame of the animation*/
  92283. to: number);
  92284. /**
  92285. * Makes a copy of the animation range
  92286. * @returns A copy of the animation range
  92287. */
  92288. clone(): AnimationRange;
  92289. }
  92290. }
  92291. declare module BABYLON {
  92292. /**
  92293. * Composed of a frame, and an action function
  92294. */
  92295. export class AnimationEvent {
  92296. /** The frame for which the event is triggered **/
  92297. frame: number;
  92298. /** The event to perform when triggered **/
  92299. action: (currentFrame: number) => void;
  92300. /** Specifies if the event should be triggered only once**/
  92301. onlyOnce?: boolean | undefined;
  92302. /**
  92303. * Specifies if the animation event is done
  92304. */
  92305. isDone: boolean;
  92306. /**
  92307. * Initializes the animation event
  92308. * @param frame The frame for which the event is triggered
  92309. * @param action The event to perform when triggered
  92310. * @param onlyOnce Specifies if the event should be triggered only once
  92311. */
  92312. constructor(
  92313. /** The frame for which the event is triggered **/
  92314. frame: number,
  92315. /** The event to perform when triggered **/
  92316. action: (currentFrame: number) => void,
  92317. /** Specifies if the event should be triggered only once**/
  92318. onlyOnce?: boolean | undefined);
  92319. /** @hidden */
  92320. _clone(): AnimationEvent;
  92321. }
  92322. }
  92323. declare module BABYLON {
  92324. /**
  92325. * Interface used to define a behavior
  92326. */
  92327. export interface Behavior<T> {
  92328. /** gets or sets behavior's name */
  92329. name: string;
  92330. /**
  92331. * Function called when the behavior needs to be initialized (after attaching it to a target)
  92332. */
  92333. init(): void;
  92334. /**
  92335. * Called when the behavior is attached to a target
  92336. * @param target defines the target where the behavior is attached to
  92337. */
  92338. attach(target: T): void;
  92339. /**
  92340. * Called when the behavior is detached from its target
  92341. */
  92342. detach(): void;
  92343. }
  92344. /**
  92345. * Interface implemented by classes supporting behaviors
  92346. */
  92347. export interface IBehaviorAware<T> {
  92348. /**
  92349. * Attach a behavior
  92350. * @param behavior defines the behavior to attach
  92351. * @returns the current host
  92352. */
  92353. addBehavior(behavior: Behavior<T>): T;
  92354. /**
  92355. * Remove a behavior from the current object
  92356. * @param behavior defines the behavior to detach
  92357. * @returns the current host
  92358. */
  92359. removeBehavior(behavior: Behavior<T>): T;
  92360. /**
  92361. * Gets a behavior using its name to search
  92362. * @param name defines the name to search
  92363. * @returns the behavior or null if not found
  92364. */
  92365. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  92366. }
  92367. }
  92368. declare module BABYLON {
  92369. /**
  92370. * Class used to provide helpers for slicing
  92371. */
  92372. export class SliceTools {
  92373. /**
  92374. * Provides a slice function that will work even on IE
  92375. * @param data defines the array to slice
  92376. * @param start defines the start of the data (optional)
  92377. * @param end defines the end of the data (optional)
  92378. * @returns the new sliced array
  92379. */
  92380. static Slice<T>(data: T, start?: number, end?: number): T;
  92381. /**
  92382. * Provides a slice function that will work even on IE
  92383. * The difference between this and Slice is that this will force-convert to array
  92384. * @param data defines the array to slice
  92385. * @param start defines the start of the data (optional)
  92386. * @param end defines the end of the data (optional)
  92387. * @returns the new sliced array
  92388. */
  92389. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  92390. }
  92391. }
  92392. declare module BABYLON {
  92393. /**
  92394. * Class used to store data that will be store in GPU memory
  92395. */
  92396. export class Buffer {
  92397. private _engine;
  92398. private _buffer;
  92399. /** @hidden */
  92400. _data: Nullable<DataArray>;
  92401. private _updatable;
  92402. private _instanced;
  92403. private _divisor;
  92404. private _isAlreadyOwned;
  92405. /**
  92406. * Gets the byte stride.
  92407. */
  92408. readonly byteStride: number;
  92409. /**
  92410. * Constructor
  92411. * @param engine the engine
  92412. * @param data the data to use for this buffer
  92413. * @param updatable whether the data is updatable
  92414. * @param stride the stride (optional)
  92415. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  92416. * @param instanced whether the buffer is instanced (optional)
  92417. * @param useBytes set to true if the stride in in bytes (optional)
  92418. * @param divisor sets an optional divisor for instances (1 by default)
  92419. */
  92420. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  92421. /**
  92422. * Create a new VertexBuffer based on the current buffer
  92423. * @param kind defines the vertex buffer kind (position, normal, etc.)
  92424. * @param offset defines offset in the buffer (0 by default)
  92425. * @param size defines the size in floats of attributes (position is 3 for instance)
  92426. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  92427. * @param instanced defines if the vertex buffer contains indexed data
  92428. * @param useBytes defines if the offset and stride are in bytes *
  92429. * @param divisor sets an optional divisor for instances (1 by default)
  92430. * @returns the new vertex buffer
  92431. */
  92432. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  92433. /**
  92434. * Gets a boolean indicating if the Buffer is updatable?
  92435. * @returns true if the buffer is updatable
  92436. */
  92437. isUpdatable(): boolean;
  92438. /**
  92439. * Gets current buffer's data
  92440. * @returns a DataArray or null
  92441. */
  92442. getData(): Nullable<DataArray>;
  92443. /**
  92444. * Gets underlying native buffer
  92445. * @returns underlying native buffer
  92446. */
  92447. getBuffer(): Nullable<DataBuffer>;
  92448. /**
  92449. * Gets the stride in float32 units (i.e. byte stride / 4).
  92450. * May not be an integer if the byte stride is not divisible by 4.
  92451. * @returns the stride in float32 units
  92452. * @deprecated Please use byteStride instead.
  92453. */
  92454. getStrideSize(): number;
  92455. /**
  92456. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  92457. * @param data defines the data to store
  92458. */
  92459. create(data?: Nullable<DataArray>): void;
  92460. /** @hidden */
  92461. _rebuild(): void;
  92462. /**
  92463. * Update current buffer data
  92464. * @param data defines the data to store
  92465. */
  92466. update(data: DataArray): void;
  92467. /**
  92468. * Updates the data directly.
  92469. * @param data the new data
  92470. * @param offset the new offset
  92471. * @param vertexCount the vertex count (optional)
  92472. * @param useBytes set to true if the offset is in bytes
  92473. */
  92474. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  92475. /** @hidden */
  92476. _increaseReferences(): void;
  92477. /**
  92478. * Release all resources
  92479. */
  92480. dispose(): void;
  92481. }
  92482. /**
  92483. * Specialized buffer used to store vertex data
  92484. */
  92485. export class VertexBuffer {
  92486. private static _Counter;
  92487. /** @hidden */
  92488. _buffer: Buffer;
  92489. private _kind;
  92490. private _size;
  92491. private _ownsBuffer;
  92492. private _instanced;
  92493. private _instanceDivisor;
  92494. /**
  92495. * The byte type.
  92496. */
  92497. static readonly BYTE: number;
  92498. /**
  92499. * The unsigned byte type.
  92500. */
  92501. static readonly UNSIGNED_BYTE: number;
  92502. /**
  92503. * The short type.
  92504. */
  92505. static readonly SHORT: number;
  92506. /**
  92507. * The unsigned short type.
  92508. */
  92509. static readonly UNSIGNED_SHORT: number;
  92510. /**
  92511. * The integer type.
  92512. */
  92513. static readonly INT: number;
  92514. /**
  92515. * The unsigned integer type.
  92516. */
  92517. static readonly UNSIGNED_INT: number;
  92518. /**
  92519. * The float type.
  92520. */
  92521. static readonly FLOAT: number;
  92522. /**
  92523. * Gets or sets the instance divisor when in instanced mode
  92524. */
  92525. get instanceDivisor(): number;
  92526. set instanceDivisor(value: number);
  92527. /**
  92528. * Gets the byte stride.
  92529. */
  92530. readonly byteStride: number;
  92531. /**
  92532. * Gets the byte offset.
  92533. */
  92534. readonly byteOffset: number;
  92535. /**
  92536. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  92537. */
  92538. readonly normalized: boolean;
  92539. /**
  92540. * Gets the data type of each component in the array.
  92541. */
  92542. readonly type: number;
  92543. /**
  92544. * Gets the unique id of this vertex buffer
  92545. */
  92546. readonly uniqueId: number;
  92547. /**
  92548. * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer
  92549. * All buffers with the same format will have the same hash code
  92550. */
  92551. readonly hashCode: number;
  92552. /**
  92553. * Constructor
  92554. * @param engine the engine
  92555. * @param data the data to use for this vertex buffer
  92556. * @param kind the vertex buffer kind
  92557. * @param updatable whether the data is updatable
  92558. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  92559. * @param stride the stride (optional)
  92560. * @param instanced whether the buffer is instanced (optional)
  92561. * @param offset the offset of the data (optional)
  92562. * @param size the number of components (optional)
  92563. * @param type the type of the component (optional)
  92564. * @param normalized whether the data contains normalized data (optional)
  92565. * @param useBytes set to true if stride and offset are in bytes (optional)
  92566. * @param divisor defines the instance divisor to use (1 by default)
  92567. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  92568. */
  92569. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  92570. private _computeHashCode;
  92571. /** @hidden */
  92572. _rebuild(): void;
  92573. /**
  92574. * Returns the kind of the VertexBuffer (string)
  92575. * @returns a string
  92576. */
  92577. getKind(): string;
  92578. /**
  92579. * Gets a boolean indicating if the VertexBuffer is updatable?
  92580. * @returns true if the buffer is updatable
  92581. */
  92582. isUpdatable(): boolean;
  92583. /**
  92584. * Gets current buffer's data
  92585. * @returns a DataArray or null
  92586. */
  92587. getData(): Nullable<DataArray>;
  92588. /**
  92589. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  92590. * @param totalVertices number of vertices in the buffer to take into account
  92591. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92592. * @returns a float array containing vertex data
  92593. */
  92594. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  92595. /**
  92596. * Gets underlying native buffer
  92597. * @returns underlying native buffer
  92598. */
  92599. getBuffer(): Nullable<DataBuffer>;
  92600. /**
  92601. * Gets the stride in float32 units (i.e. byte stride / 4).
  92602. * May not be an integer if the byte stride is not divisible by 4.
  92603. * @returns the stride in float32 units
  92604. * @deprecated Please use byteStride instead.
  92605. */
  92606. getStrideSize(): number;
  92607. /**
  92608. * Returns the offset as a multiple of the type byte length.
  92609. * @returns the offset in bytes
  92610. * @deprecated Please use byteOffset instead.
  92611. */
  92612. getOffset(): number;
  92613. /**
  92614. * Returns the number of components per vertex attribute (integer)
  92615. * @returns the size in float
  92616. */
  92617. getSize(): number;
  92618. /**
  92619. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  92620. * @returns true if this buffer is instanced
  92621. */
  92622. getIsInstanced(): boolean;
  92623. /**
  92624. * Returns the instancing divisor, zero for non-instanced (integer).
  92625. * @returns a number
  92626. */
  92627. getInstanceDivisor(): number;
  92628. /**
  92629. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  92630. * @param data defines the data to store
  92631. */
  92632. create(data?: DataArray): void;
  92633. /**
  92634. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  92635. * This function will create a new buffer if the current one is not updatable
  92636. * @param data defines the data to store
  92637. */
  92638. update(data: DataArray): void;
  92639. /**
  92640. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  92641. * Returns the directly updated WebGLBuffer.
  92642. * @param data the new data
  92643. * @param offset the new offset
  92644. * @param useBytes set to true if the offset is in bytes
  92645. */
  92646. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  92647. /**
  92648. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  92649. */
  92650. dispose(): void;
  92651. /**
  92652. * Enumerates each value of this vertex buffer as numbers.
  92653. * @param count the number of values to enumerate
  92654. * @param callback the callback function called for each value
  92655. */
  92656. forEach(count: number, callback: (value: number, index: number) => void): void;
  92657. /**
  92658. * Positions
  92659. */
  92660. static readonly PositionKind: string;
  92661. /**
  92662. * Normals
  92663. */
  92664. static readonly NormalKind: string;
  92665. /**
  92666. * Tangents
  92667. */
  92668. static readonly TangentKind: string;
  92669. /**
  92670. * Texture coordinates
  92671. */
  92672. static readonly UVKind: string;
  92673. /**
  92674. * Texture coordinates 2
  92675. */
  92676. static readonly UV2Kind: string;
  92677. /**
  92678. * Texture coordinates 3
  92679. */
  92680. static readonly UV3Kind: string;
  92681. /**
  92682. * Texture coordinates 4
  92683. */
  92684. static readonly UV4Kind: string;
  92685. /**
  92686. * Texture coordinates 5
  92687. */
  92688. static readonly UV5Kind: string;
  92689. /**
  92690. * Texture coordinates 6
  92691. */
  92692. static readonly UV6Kind: string;
  92693. /**
  92694. * Colors
  92695. */
  92696. static readonly ColorKind: string;
  92697. /**
  92698. * Matrix indices (for bones)
  92699. */
  92700. static readonly MatricesIndicesKind: string;
  92701. /**
  92702. * Matrix weights (for bones)
  92703. */
  92704. static readonly MatricesWeightsKind: string;
  92705. /**
  92706. * Additional matrix indices (for bones)
  92707. */
  92708. static readonly MatricesIndicesExtraKind: string;
  92709. /**
  92710. * Additional matrix weights (for bones)
  92711. */
  92712. static readonly MatricesWeightsExtraKind: string;
  92713. /**
  92714. * Deduces the stride given a kind.
  92715. * @param kind The kind string to deduce
  92716. * @returns The deduced stride
  92717. */
  92718. static DeduceStride(kind: string): number;
  92719. /**
  92720. * Gets the byte length of the given type.
  92721. * @param type the type
  92722. * @returns the number of bytes
  92723. */
  92724. static GetTypeByteLength(type: number): number;
  92725. /**
  92726. * Enumerates each value of the given parameters as numbers.
  92727. * @param data the data to enumerate
  92728. * @param byteOffset the byte offset of the data
  92729. * @param byteStride the byte stride of the data
  92730. * @param componentCount the number of components per element
  92731. * @param componentType the type of the component
  92732. * @param count the number of values to enumerate
  92733. * @param normalized whether the data is normalized
  92734. * @param callback the callback function called for each value
  92735. */
  92736. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  92737. private static _GetFloatValue;
  92738. }
  92739. }
  92740. declare module BABYLON {
  92741. /**
  92742. * @hidden
  92743. */
  92744. export class IntersectionInfo {
  92745. bu: Nullable<number>;
  92746. bv: Nullable<number>;
  92747. distance: number;
  92748. faceId: number;
  92749. subMeshId: number;
  92750. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  92751. }
  92752. }
  92753. declare module BABYLON {
  92754. /**
  92755. * Class used to store bounding sphere information
  92756. */
  92757. export class BoundingSphere {
  92758. /**
  92759. * Gets the center of the bounding sphere in local space
  92760. */
  92761. readonly center: Vector3;
  92762. /**
  92763. * Radius of the bounding sphere in local space
  92764. */
  92765. radius: number;
  92766. /**
  92767. * Gets the center of the bounding sphere in world space
  92768. */
  92769. readonly centerWorld: Vector3;
  92770. /**
  92771. * Radius of the bounding sphere in world space
  92772. */
  92773. radiusWorld: number;
  92774. /**
  92775. * Gets the minimum vector in local space
  92776. */
  92777. readonly minimum: Vector3;
  92778. /**
  92779. * Gets the maximum vector in local space
  92780. */
  92781. readonly maximum: Vector3;
  92782. private _worldMatrix;
  92783. private static readonly TmpVector3;
  92784. /**
  92785. * Creates a new bounding sphere
  92786. * @param min defines the minimum vector (in local space)
  92787. * @param max defines the maximum vector (in local space)
  92788. * @param worldMatrix defines the new world matrix
  92789. */
  92790. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92791. /**
  92792. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  92793. * @param min defines the new minimum vector (in local space)
  92794. * @param max defines the new maximum vector (in local space)
  92795. * @param worldMatrix defines the new world matrix
  92796. */
  92797. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92798. /**
  92799. * Scale the current bounding sphere by applying a scale factor
  92800. * @param factor defines the scale factor to apply
  92801. * @returns the current bounding box
  92802. */
  92803. scale(factor: number): BoundingSphere;
  92804. /**
  92805. * Gets the world matrix of the bounding box
  92806. * @returns a matrix
  92807. */
  92808. getWorldMatrix(): DeepImmutable<Matrix>;
  92809. /** @hidden */
  92810. _update(worldMatrix: DeepImmutable<Matrix>): void;
  92811. /**
  92812. * Tests if the bounding sphere is intersecting the frustum planes
  92813. * @param frustumPlanes defines the frustum planes to test
  92814. * @returns true if there is an intersection
  92815. */
  92816. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92817. /**
  92818. * Tests if the bounding sphere center is in between the frustum planes.
  92819. * Used for optimistic fast inclusion.
  92820. * @param frustumPlanes defines the frustum planes to test
  92821. * @returns true if the sphere center is in between the frustum planes
  92822. */
  92823. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92824. /**
  92825. * Tests if a point is inside the bounding sphere
  92826. * @param point defines the point to test
  92827. * @returns true if the point is inside the bounding sphere
  92828. */
  92829. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92830. /**
  92831. * Checks if two sphere intersect
  92832. * @param sphere0 sphere 0
  92833. * @param sphere1 sphere 1
  92834. * @returns true if the spheres intersect
  92835. */
  92836. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  92837. }
  92838. }
  92839. declare module BABYLON {
  92840. /**
  92841. * Class used to store bounding box information
  92842. */
  92843. export class BoundingBox implements ICullable {
  92844. /**
  92845. * Gets the 8 vectors representing the bounding box in local space
  92846. */
  92847. readonly vectors: Vector3[];
  92848. /**
  92849. * Gets the center of the bounding box in local space
  92850. */
  92851. readonly center: Vector3;
  92852. /**
  92853. * Gets the center of the bounding box in world space
  92854. */
  92855. readonly centerWorld: Vector3;
  92856. /**
  92857. * Gets the extend size in local space
  92858. */
  92859. readonly extendSize: Vector3;
  92860. /**
  92861. * Gets the extend size in world space
  92862. */
  92863. readonly extendSizeWorld: Vector3;
  92864. /**
  92865. * Gets the OBB (object bounding box) directions
  92866. */
  92867. readonly directions: Vector3[];
  92868. /**
  92869. * Gets the 8 vectors representing the bounding box in world space
  92870. */
  92871. readonly vectorsWorld: Vector3[];
  92872. /**
  92873. * Gets the minimum vector in world space
  92874. */
  92875. readonly minimumWorld: Vector3;
  92876. /**
  92877. * Gets the maximum vector in world space
  92878. */
  92879. readonly maximumWorld: Vector3;
  92880. /**
  92881. * Gets the minimum vector in local space
  92882. */
  92883. readonly minimum: Vector3;
  92884. /**
  92885. * Gets the maximum vector in local space
  92886. */
  92887. readonly maximum: Vector3;
  92888. private _worldMatrix;
  92889. private static readonly TmpVector3;
  92890. /**
  92891. * @hidden
  92892. */
  92893. _tag: number;
  92894. /**
  92895. * Creates a new bounding box
  92896. * @param min defines the minimum vector (in local space)
  92897. * @param max defines the maximum vector (in local space)
  92898. * @param worldMatrix defines the new world matrix
  92899. */
  92900. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92901. /**
  92902. * Recreates the entire bounding box from scratch as if we call the constructor in place
  92903. * @param min defines the new minimum vector (in local space)
  92904. * @param max defines the new maximum vector (in local space)
  92905. * @param worldMatrix defines the new world matrix
  92906. */
  92907. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92908. /**
  92909. * Scale the current bounding box by applying a scale factor
  92910. * @param factor defines the scale factor to apply
  92911. * @returns the current bounding box
  92912. */
  92913. scale(factor: number): BoundingBox;
  92914. /**
  92915. * Gets the world matrix of the bounding box
  92916. * @returns a matrix
  92917. */
  92918. getWorldMatrix(): DeepImmutable<Matrix>;
  92919. /** @hidden */
  92920. _update(world: DeepImmutable<Matrix>): void;
  92921. /**
  92922. * Tests if the bounding box is intersecting the frustum planes
  92923. * @param frustumPlanes defines the frustum planes to test
  92924. * @returns true if there is an intersection
  92925. */
  92926. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92927. /**
  92928. * Tests if the bounding box is entirely inside the frustum planes
  92929. * @param frustumPlanes defines the frustum planes to test
  92930. * @returns true if there is an inclusion
  92931. */
  92932. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92933. /**
  92934. * Tests if a point is inside the bounding box
  92935. * @param point defines the point to test
  92936. * @returns true if the point is inside the bounding box
  92937. */
  92938. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92939. /**
  92940. * Tests if the bounding box intersects with a bounding sphere
  92941. * @param sphere defines the sphere to test
  92942. * @returns true if there is an intersection
  92943. */
  92944. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  92945. /**
  92946. * Tests if the bounding box intersects with a box defined by a min and max vectors
  92947. * @param min defines the min vector to use
  92948. * @param max defines the max vector to use
  92949. * @returns true if there is an intersection
  92950. */
  92951. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  92952. /**
  92953. * Tests if two bounding boxes are intersections
  92954. * @param box0 defines the first box to test
  92955. * @param box1 defines the second box to test
  92956. * @returns true if there is an intersection
  92957. */
  92958. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  92959. /**
  92960. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  92961. * @param minPoint defines the minimum vector of the bounding box
  92962. * @param maxPoint defines the maximum vector of the bounding box
  92963. * @param sphereCenter defines the sphere center
  92964. * @param sphereRadius defines the sphere radius
  92965. * @returns true if there is an intersection
  92966. */
  92967. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  92968. /**
  92969. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  92970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  92971. * @param frustumPlanes defines the frustum planes to test
  92972. * @return true if there is an inclusion
  92973. */
  92974. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92975. /**
  92976. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  92977. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  92978. * @param frustumPlanes defines the frustum planes to test
  92979. * @return true if there is an intersection
  92980. */
  92981. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92982. }
  92983. }
  92984. declare module BABYLON {
  92985. /** @hidden */
  92986. export class Collider {
  92987. /** Define if a collision was found */
  92988. collisionFound: boolean;
  92989. /**
  92990. * Define last intersection point in local space
  92991. */
  92992. intersectionPoint: Vector3;
  92993. /**
  92994. * Define last collided mesh
  92995. */
  92996. collidedMesh: Nullable<AbstractMesh>;
  92997. private _collisionPoint;
  92998. private _planeIntersectionPoint;
  92999. private _tempVector;
  93000. private _tempVector2;
  93001. private _tempVector3;
  93002. private _tempVector4;
  93003. private _edge;
  93004. private _baseToVertex;
  93005. private _destinationPoint;
  93006. private _slidePlaneNormal;
  93007. private _displacementVector;
  93008. /** @hidden */
  93009. _radius: Vector3;
  93010. /** @hidden */
  93011. _retry: number;
  93012. private _velocity;
  93013. private _basePoint;
  93014. private _epsilon;
  93015. /** @hidden */
  93016. _velocityWorldLength: number;
  93017. /** @hidden */
  93018. _basePointWorld: Vector3;
  93019. private _velocityWorld;
  93020. private _normalizedVelocity;
  93021. /** @hidden */
  93022. _initialVelocity: Vector3;
  93023. /** @hidden */
  93024. _initialPosition: Vector3;
  93025. private _nearestDistance;
  93026. private _collisionMask;
  93027. get collisionMask(): number;
  93028. set collisionMask(mask: number);
  93029. /**
  93030. * Gets the plane normal used to compute the sliding response (in local space)
  93031. */
  93032. get slidePlaneNormal(): Vector3;
  93033. /** @hidden */
  93034. _initialize(source: Vector3, dir: Vector3, e: number): void;
  93035. /** @hidden */
  93036. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  93037. /** @hidden */
  93038. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  93039. /** @hidden */
  93040. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  93041. /** @hidden */
  93042. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  93043. /** @hidden */
  93044. _getResponse(pos: Vector3, vel: Vector3): void;
  93045. }
  93046. }
  93047. declare module BABYLON {
  93048. /**
  93049. * Interface for cullable objects
  93050. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  93051. */
  93052. export interface ICullable {
  93053. /**
  93054. * Checks if the object or part of the object is in the frustum
  93055. * @param frustumPlanes Camera near/planes
  93056. * @returns true if the object is in frustum otherwise false
  93057. */
  93058. isInFrustum(frustumPlanes: Plane[]): boolean;
  93059. /**
  93060. * Checks if a cullable object (mesh...) is in the camera frustum
  93061. * Unlike isInFrustum this checks the full bounding box
  93062. * @param frustumPlanes Camera near/planes
  93063. * @returns true if the object is in frustum otherwise false
  93064. */
  93065. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93066. }
  93067. /**
  93068. * Info for a bounding data of a mesh
  93069. */
  93070. export class BoundingInfo implements ICullable {
  93071. /**
  93072. * Bounding box for the mesh
  93073. */
  93074. readonly boundingBox: BoundingBox;
  93075. /**
  93076. * Bounding sphere for the mesh
  93077. */
  93078. readonly boundingSphere: BoundingSphere;
  93079. private _isLocked;
  93080. private static readonly TmpVector3;
  93081. /**
  93082. * Constructs bounding info
  93083. * @param minimum min vector of the bounding box/sphere
  93084. * @param maximum max vector of the bounding box/sphere
  93085. * @param worldMatrix defines the new world matrix
  93086. */
  93087. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  93088. /**
  93089. * Recreates the entire bounding info from scratch as if we call the constructor in place
  93090. * @param min defines the new minimum vector (in local space)
  93091. * @param max defines the new maximum vector (in local space)
  93092. * @param worldMatrix defines the new world matrix
  93093. */
  93094. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  93095. /**
  93096. * min vector of the bounding box/sphere
  93097. */
  93098. get minimum(): Vector3;
  93099. /**
  93100. * max vector of the bounding box/sphere
  93101. */
  93102. get maximum(): Vector3;
  93103. /**
  93104. * If the info is locked and won't be updated to avoid perf overhead
  93105. */
  93106. get isLocked(): boolean;
  93107. set isLocked(value: boolean);
  93108. /**
  93109. * Updates the bounding sphere and box
  93110. * @param world world matrix to be used to update
  93111. */
  93112. update(world: DeepImmutable<Matrix>): void;
  93113. /**
  93114. * Recreate the bounding info to be centered around a specific point given a specific extend.
  93115. * @param center New center of the bounding info
  93116. * @param extend New extend of the bounding info
  93117. * @returns the current bounding info
  93118. */
  93119. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  93120. /**
  93121. * Grows the bounding info to include the given point.
  93122. * @param point The point that will be included in the current bounding info
  93123. * @returns the current bounding info
  93124. */
  93125. encapsulate(point: Vector3): BoundingInfo;
  93126. /**
  93127. * Grows the bounding info to encapsulate the given bounding info.
  93128. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  93129. * @returns the current bounding info
  93130. */
  93131. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  93132. /**
  93133. * Scale the current bounding info by applying a scale factor
  93134. * @param factor defines the scale factor to apply
  93135. * @returns the current bounding info
  93136. */
  93137. scale(factor: number): BoundingInfo;
  93138. /**
  93139. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  93140. * @param frustumPlanes defines the frustum to test
  93141. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  93142. * @returns true if the bounding info is in the frustum planes
  93143. */
  93144. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  93145. /**
  93146. * Gets the world distance between the min and max points of the bounding box
  93147. */
  93148. get diagonalLength(): number;
  93149. /**
  93150. * Checks if a cullable object (mesh...) is in the camera frustum
  93151. * Unlike isInFrustum this checks the full bounding box
  93152. * @param frustumPlanes Camera near/planes
  93153. * @returns true if the object is in frustum otherwise false
  93154. */
  93155. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  93156. /** @hidden */
  93157. _checkCollision(collider: Collider): boolean;
  93158. /**
  93159. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  93160. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93161. * @param point the point to check intersection with
  93162. * @returns if the point intersects
  93163. */
  93164. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  93165. /**
  93166. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  93167. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93168. * @param boundingInfo the bounding info to check intersection with
  93169. * @param precise if the intersection should be done using OBB
  93170. * @returns if the bounding info intersects
  93171. */
  93172. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  93173. }
  93174. }
  93175. declare module BABYLON {
  93176. /**
  93177. * Extracts minimum and maximum values from a list of indexed positions
  93178. * @param positions defines the positions to use
  93179. * @param indices defines the indices to the positions
  93180. * @param indexStart defines the start index
  93181. * @param indexCount defines the end index
  93182. * @param bias defines bias value to add to the result
  93183. * @return minimum and maximum values
  93184. */
  93185. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93186. minimum: Vector3;
  93187. maximum: Vector3;
  93188. };
  93189. /**
  93190. * Extracts minimum and maximum values from a list of positions
  93191. * @param positions defines the positions to use
  93192. * @param start defines the start index in the positions array
  93193. * @param count defines the number of positions to handle
  93194. * @param bias defines bias value to add to the result
  93195. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93196. * @return minimum and maximum values
  93197. */
  93198. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93199. minimum: Vector3;
  93200. maximum: Vector3;
  93201. };
  93202. }
  93203. declare module BABYLON {
  93204. /**
  93205. * Class used to manipulate GUIDs
  93206. */
  93207. export class GUID {
  93208. /**
  93209. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93210. * Be aware Math.random() could cause collisions, but:
  93211. * "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"
  93212. * @returns a pseudo random id
  93213. */
  93214. static RandomId(): string;
  93215. }
  93216. }
  93217. declare module BABYLON {
  93218. /**
  93219. * Base class of all the textures in babylon.
  93220. * It groups all the common properties the materials, post process, lights... might need
  93221. * in order to make a correct use of the texture.
  93222. */
  93223. export class BaseTexture extends ThinTexture implements IAnimatable {
  93224. /**
  93225. * Default anisotropic filtering level for the application.
  93226. * It is set to 4 as a good tradeoff between perf and quality.
  93227. */
  93228. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93229. /**
  93230. * Gets or sets the unique id of the texture
  93231. */
  93232. uniqueId: number;
  93233. /**
  93234. * Define the name of the texture.
  93235. */
  93236. name: string;
  93237. /**
  93238. * Gets or sets an object used to store user defined information.
  93239. */
  93240. metadata: any;
  93241. /**
  93242. * For internal use only. Please do not use.
  93243. */
  93244. reservedDataStore: any;
  93245. private _hasAlpha;
  93246. /**
  93247. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93248. */
  93249. set hasAlpha(value: boolean);
  93250. get hasAlpha(): boolean;
  93251. /**
  93252. * Defines if the alpha value should be determined via the rgb values.
  93253. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93254. */
  93255. getAlphaFromRGB: boolean;
  93256. /**
  93257. * Intensity or strength of the texture.
  93258. * It is commonly used by materials to fine tune the intensity of the texture
  93259. */
  93260. level: number;
  93261. /**
  93262. * Define the UV channel to use starting from 0 and defaulting to 0.
  93263. * This is part of the texture as textures usually maps to one uv set.
  93264. */
  93265. coordinatesIndex: number;
  93266. protected _coordinatesMode: number;
  93267. /**
  93268. * How a texture is mapped.
  93269. *
  93270. * | Value | Type | Description |
  93271. * | ----- | ----------------------------------- | ----------- |
  93272. * | 0 | EXPLICIT_MODE | |
  93273. * | 1 | SPHERICAL_MODE | |
  93274. * | 2 | PLANAR_MODE | |
  93275. * | 3 | CUBIC_MODE | |
  93276. * | 4 | PROJECTION_MODE | |
  93277. * | 5 | SKYBOX_MODE | |
  93278. * | 6 | INVCUBIC_MODE | |
  93279. * | 7 | EQUIRECTANGULAR_MODE | |
  93280. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93281. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93282. */
  93283. set coordinatesMode(value: number);
  93284. get coordinatesMode(): number;
  93285. /**
  93286. * | Value | Type | Description |
  93287. * | ----- | ------------------ | ----------- |
  93288. * | 0 | CLAMP_ADDRESSMODE | |
  93289. * | 1 | WRAP_ADDRESSMODE | |
  93290. * | 2 | MIRROR_ADDRESSMODE | |
  93291. */
  93292. get wrapU(): number;
  93293. set wrapU(value: number);
  93294. /**
  93295. * | Value | Type | Description |
  93296. * | ----- | ------------------ | ----------- |
  93297. * | 0 | CLAMP_ADDRESSMODE | |
  93298. * | 1 | WRAP_ADDRESSMODE | |
  93299. * | 2 | MIRROR_ADDRESSMODE | |
  93300. */
  93301. get wrapV(): number;
  93302. set wrapV(value: number);
  93303. /**
  93304. * | Value | Type | Description |
  93305. * | ----- | ------------------ | ----------- |
  93306. * | 0 | CLAMP_ADDRESSMODE | |
  93307. * | 1 | WRAP_ADDRESSMODE | |
  93308. * | 2 | MIRROR_ADDRESSMODE | |
  93309. */
  93310. wrapR: number;
  93311. /**
  93312. * With compliant hardware and browser (supporting anisotropic filtering)
  93313. * this defines the level of anisotropic filtering in the texture.
  93314. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93315. */
  93316. anisotropicFilteringLevel: number;
  93317. private _isCube;
  93318. /**
  93319. * Define if the texture is a cube texture or if false a 2d texture.
  93320. */
  93321. get isCube(): boolean;
  93322. set isCube(value: boolean);
  93323. /**
  93324. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93325. */
  93326. get is3D(): boolean;
  93327. set is3D(value: boolean);
  93328. /**
  93329. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  93330. */
  93331. get is2DArray(): boolean;
  93332. set is2DArray(value: boolean);
  93333. private _gammaSpace;
  93334. /**
  93335. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93336. * HDR texture are usually stored in linear space.
  93337. * This only impacts the PBR and Background materials
  93338. */
  93339. get gammaSpace(): boolean;
  93340. set gammaSpace(gamma: boolean);
  93341. /**
  93342. * Gets or sets whether or not the texture contains RGBD data.
  93343. */
  93344. get isRGBD(): boolean;
  93345. set isRGBD(value: boolean);
  93346. /**
  93347. * Is Z inverted in the texture (useful in a cube texture).
  93348. */
  93349. invertZ: boolean;
  93350. /**
  93351. * Are mip maps generated for this texture or not.
  93352. */
  93353. get noMipmap(): boolean;
  93354. /**
  93355. * @hidden
  93356. */
  93357. lodLevelInAlpha: boolean;
  93358. /**
  93359. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93360. */
  93361. get lodGenerationOffset(): number;
  93362. set lodGenerationOffset(value: number);
  93363. /**
  93364. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93365. */
  93366. get lodGenerationScale(): number;
  93367. set lodGenerationScale(value: number);
  93368. /**
  93369. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93370. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93371. * average roughness values.
  93372. */
  93373. get linearSpecularLOD(): boolean;
  93374. set linearSpecularLOD(value: boolean);
  93375. /**
  93376. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93377. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93378. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93379. */
  93380. get irradianceTexture(): Nullable<BaseTexture>;
  93381. set irradianceTexture(value: Nullable<BaseTexture>);
  93382. /**
  93383. * Define if the texture is a render target.
  93384. */
  93385. isRenderTarget: boolean;
  93386. /**
  93387. * Define the unique id of the texture in the scene.
  93388. */
  93389. get uid(): string;
  93390. /** @hidden */
  93391. _prefiltered: boolean;
  93392. /**
  93393. * Return a string representation of the texture.
  93394. * @returns the texture as a string
  93395. */
  93396. toString(): string;
  93397. /**
  93398. * Get the class name of the texture.
  93399. * @returns "BaseTexture"
  93400. */
  93401. getClassName(): string;
  93402. /**
  93403. * Define the list of animation attached to the texture.
  93404. */
  93405. animations: Animation[];
  93406. /**
  93407. * An event triggered when the texture is disposed.
  93408. */
  93409. onDisposeObservable: Observable<BaseTexture>;
  93410. private _onDisposeObserver;
  93411. /**
  93412. * Callback triggered when the texture has been disposed.
  93413. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93414. */
  93415. set onDispose(callback: () => void);
  93416. protected _scene: Nullable<Scene>;
  93417. /** @hidden */
  93418. _texture: Nullable<InternalTexture>;
  93419. private _uid;
  93420. /**
  93421. * Define if the texture is preventing a material to render or not.
  93422. * If not and the texture is not ready, the engine will use a default black texture instead.
  93423. */
  93424. get isBlocking(): boolean;
  93425. /**
  93426. * Instantiates a new BaseTexture.
  93427. * Base class of all the textures in babylon.
  93428. * It groups all the common properties the materials, post process, lights... might need
  93429. * in order to make a correct use of the texture.
  93430. * @param sceneOrEngine Define the scene or engine the texture belongs to
  93431. */
  93432. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  93433. /**
  93434. * Get the scene the texture belongs to.
  93435. * @returns the scene or null if undefined
  93436. */
  93437. getScene(): Nullable<Scene>;
  93438. /** @hidden */
  93439. protected _getEngine(): Nullable<ThinEngine>;
  93440. /**
  93441. * Checks if the texture has the same transform matrix than another texture
  93442. * @param texture texture to check against
  93443. * @returns true if the transforms are the same, else false
  93444. */
  93445. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  93446. /**
  93447. * Get the texture transform matrix used to offset tile the texture for instance.
  93448. * @returns the transformation matrix
  93449. */
  93450. getTextureMatrix(): Matrix;
  93451. /**
  93452. * Get the texture reflection matrix used to rotate/transform the reflection.
  93453. * @returns the reflection matrix
  93454. */
  93455. getReflectionTextureMatrix(): Matrix;
  93456. /**
  93457. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93458. * @returns true if ready or not blocking
  93459. */
  93460. isReadyOrNotBlocking(): boolean;
  93461. /**
  93462. * Scales the texture if is `canRescale()`
  93463. * @param ratio the resize factor we want to use to rescale
  93464. */
  93465. scale(ratio: number): void;
  93466. /**
  93467. * Get if the texture can rescale.
  93468. */
  93469. get canRescale(): boolean;
  93470. /** @hidden */
  93471. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93472. /** @hidden */
  93473. _rebuild(): void;
  93474. /**
  93475. * Clones the texture.
  93476. * @returns the cloned texture
  93477. */
  93478. clone(): Nullable<BaseTexture>;
  93479. /**
  93480. * Get the texture underlying type (INT, FLOAT...)
  93481. */
  93482. get textureType(): number;
  93483. /**
  93484. * Get the texture underlying format (RGB, RGBA...)
  93485. */
  93486. get textureFormat(): number;
  93487. /**
  93488. * Indicates that textures need to be re-calculated for all materials
  93489. */
  93490. protected _markAllSubMeshesAsTexturesDirty(): void;
  93491. /**
  93492. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93493. * This will returns an RGBA array buffer containing either in values (0-255) or
  93494. * float values (0-1) depending of the underlying buffer type.
  93495. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93496. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93497. * @param buffer defines a user defined buffer to fill with data (can be null)
  93498. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  93499. * @returns The Array buffer promise containing the pixels data.
  93500. */
  93501. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  93502. /** @hidden */
  93503. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  93504. /** @hidden */
  93505. get _lodTextureHigh(): Nullable<BaseTexture>;
  93506. /** @hidden */
  93507. get _lodTextureMid(): Nullable<BaseTexture>;
  93508. /** @hidden */
  93509. get _lodTextureLow(): Nullable<BaseTexture>;
  93510. /**
  93511. * Dispose the texture and release its associated resources.
  93512. */
  93513. dispose(): void;
  93514. /**
  93515. * Serialize the texture into a JSON representation that can be parsed later on.
  93516. * @returns the JSON representation of the texture
  93517. */
  93518. serialize(): any;
  93519. /**
  93520. * Helper function to be called back once a list of texture contains only ready textures.
  93521. * @param textures Define the list of textures to wait for
  93522. * @param callback Define the callback triggered once the entire list will be ready
  93523. */
  93524. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93525. private static _isScene;
  93526. }
  93527. }
  93528. declare module BABYLON {
  93529. /** @hidden */
  93530. export class WebGLDataBuffer extends DataBuffer {
  93531. private _buffer;
  93532. constructor(resource: WebGLBuffer);
  93533. get underlyingResource(): any;
  93534. }
  93535. }
  93536. declare module BABYLON {
  93537. /** @hidden */
  93538. export class WebGLPipelineContext implements IPipelineContext {
  93539. private _valueCache;
  93540. private _uniforms;
  93541. engine: ThinEngine;
  93542. program: Nullable<WebGLProgram>;
  93543. context?: WebGLRenderingContext;
  93544. vertexShader?: WebGLShader;
  93545. fragmentShader?: WebGLShader;
  93546. isParallelCompiled: boolean;
  93547. onCompiled?: () => void;
  93548. transformFeedback?: WebGLTransformFeedback | null;
  93549. vertexCompilationError: Nullable<string>;
  93550. fragmentCompilationError: Nullable<string>;
  93551. programLinkError: Nullable<string>;
  93552. programValidationError: Nullable<string>;
  93553. get isAsync(): boolean;
  93554. get isReady(): boolean;
  93555. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93556. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  93557. [key: string]: number;
  93558. }, uniformsNames: string[], uniforms: {
  93559. [key: string]: Nullable<WebGLUniformLocation>;
  93560. }, samplerList: string[], samplers: {
  93561. [key: string]: number;
  93562. }, attributesNames: string[], attributes: number[]): void;
  93563. /**
  93564. * Release all associated resources.
  93565. **/
  93566. dispose(): void;
  93567. /** @hidden */
  93568. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93569. /** @hidden */
  93570. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93571. /** @hidden */
  93572. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93573. /** @hidden */
  93574. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93575. /**
  93576. * Sets an integer value on a uniform variable.
  93577. * @param uniformName Name of the variable.
  93578. * @param value Value to be set.
  93579. */
  93580. setInt(uniformName: string, value: number): void;
  93581. /**
  93582. * Sets a int2 on a uniform variable.
  93583. * @param uniformName Name of the variable.
  93584. * @param x First int in int2.
  93585. * @param y Second int in int2.
  93586. */
  93587. setInt2(uniformName: string, x: number, y: number): void;
  93588. /**
  93589. * Sets a int3 on a uniform variable.
  93590. * @param uniformName Name of the variable.
  93591. * @param x First int in int3.
  93592. * @param y Second int in int3.
  93593. * @param y Third int in int3.
  93594. */
  93595. setInt3(uniformName: string, x: number, y: number, z: number): void;
  93596. /**
  93597. * Sets a int4 on a uniform variable.
  93598. * @param uniformName Name of the variable.
  93599. * @param x First int in int4.
  93600. * @param y Second int in int4.
  93601. * @param y Third int in int4.
  93602. * @param w Fourth int in int4.
  93603. */
  93604. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  93605. /**
  93606. * Sets an int array on a uniform variable.
  93607. * @param uniformName Name of the variable.
  93608. * @param array array to be set.
  93609. */
  93610. setIntArray(uniformName: string, array: Int32Array): void;
  93611. /**
  93612. * 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)
  93613. * @param uniformName Name of the variable.
  93614. * @param array array to be set.
  93615. */
  93616. setIntArray2(uniformName: string, array: Int32Array): void;
  93617. /**
  93618. * 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)
  93619. * @param uniformName Name of the variable.
  93620. * @param array array to be set.
  93621. */
  93622. setIntArray3(uniformName: string, array: Int32Array): void;
  93623. /**
  93624. * 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)
  93625. * @param uniformName Name of the variable.
  93626. * @param array array to be set.
  93627. */
  93628. setIntArray4(uniformName: string, array: Int32Array): void;
  93629. /**
  93630. * Sets an array on a uniform variable.
  93631. * @param uniformName Name of the variable.
  93632. * @param array array to be set.
  93633. */
  93634. setArray(uniformName: string, array: number[]): void;
  93635. /**
  93636. * 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)
  93637. * @param uniformName Name of the variable.
  93638. * @param array array to be set.
  93639. */
  93640. setArray2(uniformName: string, array: number[]): void;
  93641. /**
  93642. * 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)
  93643. * @param uniformName Name of the variable.
  93644. * @param array array to be set.
  93645. * @returns this effect.
  93646. */
  93647. setArray3(uniformName: string, array: number[]): void;
  93648. /**
  93649. * 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)
  93650. * @param uniformName Name of the variable.
  93651. * @param array array to be set.
  93652. */
  93653. setArray4(uniformName: string, array: number[]): void;
  93654. /**
  93655. * Sets matrices on a uniform variable.
  93656. * @param uniformName Name of the variable.
  93657. * @param matrices matrices to be set.
  93658. */
  93659. setMatrices(uniformName: string, matrices: Float32Array): void;
  93660. /**
  93661. * Sets matrix on a uniform variable.
  93662. * @param uniformName Name of the variable.
  93663. * @param matrix matrix to be set.
  93664. */
  93665. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  93666. /**
  93667. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  93668. * @param uniformName Name of the variable.
  93669. * @param matrix matrix to be set.
  93670. */
  93671. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  93672. /**
  93673. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93674. * @param uniformName Name of the variable.
  93675. * @param matrix matrix to be set.
  93676. */
  93677. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  93678. /**
  93679. * Sets a float on a uniform variable.
  93680. * @param uniformName Name of the variable.
  93681. * @param value value to be set.
  93682. * @returns this effect.
  93683. */
  93684. setFloat(uniformName: string, value: number): void;
  93685. /**
  93686. * Sets a Vector2 on a uniform variable.
  93687. * @param uniformName Name of the variable.
  93688. * @param vector2 vector2 to be set.
  93689. */
  93690. setVector2(uniformName: string, vector2: IVector2Like): void;
  93691. /**
  93692. * Sets a float2 on a uniform variable.
  93693. * @param uniformName Name of the variable.
  93694. * @param x First float in float2.
  93695. * @param y Second float in float2.
  93696. */
  93697. setFloat2(uniformName: string, x: number, y: number): void;
  93698. /**
  93699. * Sets a Vector3 on a uniform variable.
  93700. * @param uniformName Name of the variable.
  93701. * @param vector3 Value to be set.
  93702. */
  93703. setVector3(uniformName: string, vector3: IVector3Like): void;
  93704. /**
  93705. * Sets a float3 on a uniform variable.
  93706. * @param uniformName Name of the variable.
  93707. * @param x First float in float3.
  93708. * @param y Second float in float3.
  93709. * @param z Third float in float3.
  93710. */
  93711. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  93712. /**
  93713. * Sets a Vector4 on a uniform variable.
  93714. * @param uniformName Name of the variable.
  93715. * @param vector4 Value to be set.
  93716. */
  93717. setVector4(uniformName: string, vector4: IVector4Like): void;
  93718. /**
  93719. * Sets a float4 on a uniform variable.
  93720. * @param uniformName Name of the variable.
  93721. * @param x First float in float4.
  93722. * @param y Second float in float4.
  93723. * @param z Third float in float4.
  93724. * @param w Fourth float in float4.
  93725. * @returns this effect.
  93726. */
  93727. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  93728. /**
  93729. * Sets a Color3 on a uniform variable.
  93730. * @param uniformName Name of the variable.
  93731. * @param color3 Value to be set.
  93732. */
  93733. setColor3(uniformName: string, color3: IColor3Like): void;
  93734. /**
  93735. * Sets a Color4 on a uniform variable.
  93736. * @param uniformName Name of the variable.
  93737. * @param color3 Value to be set.
  93738. * @param alpha Alpha value to be set.
  93739. */
  93740. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  93741. /**
  93742. * Sets a Color4 on a uniform variable
  93743. * @param uniformName defines the name of the variable
  93744. * @param color4 defines the value to be set
  93745. */
  93746. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  93747. _getVertexShaderCode(): string | null;
  93748. _getFragmentShaderCode(): string | null;
  93749. }
  93750. }
  93751. declare module BABYLON {
  93752. interface ThinEngine {
  93753. /**
  93754. * Create an uniform buffer
  93755. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93756. * @param elements defines the content of the uniform buffer
  93757. * @returns the webGL uniform buffer
  93758. */
  93759. createUniformBuffer(elements: FloatArray): DataBuffer;
  93760. /**
  93761. * Create a dynamic uniform buffer
  93762. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93763. * @param elements defines the content of the uniform buffer
  93764. * @returns the webGL uniform buffer
  93765. */
  93766. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  93767. /**
  93768. * Update an existing uniform buffer
  93769. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93770. * @param uniformBuffer defines the target uniform buffer
  93771. * @param elements defines the content to update
  93772. * @param offset defines the offset in the uniform buffer where update should start
  93773. * @param count defines the size of the data to update
  93774. */
  93775. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  93776. /**
  93777. * Bind an uniform buffer to the current webGL context
  93778. * @param buffer defines the buffer to bind
  93779. */
  93780. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  93781. /**
  93782. * Bind a buffer to the current webGL context at a given location
  93783. * @param buffer defines the buffer to bind
  93784. * @param location defines the index where to bind the buffer
  93785. * @param name Name of the uniform variable to bind
  93786. */
  93787. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  93788. /**
  93789. * Bind a specific block at a given index in a specific shader program
  93790. * @param pipelineContext defines the pipeline context to use
  93791. * @param blockName defines the block name
  93792. * @param index defines the index where to bind the block
  93793. */
  93794. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  93795. }
  93796. }
  93797. declare module BABYLON {
  93798. /**
  93799. * Uniform buffer objects.
  93800. *
  93801. * Handles blocks of uniform on the GPU.
  93802. *
  93803. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  93804. *
  93805. * For more information, please refer to :
  93806. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93807. */
  93808. export class UniformBuffer {
  93809. /** @hidden */
  93810. static _updatedUbosInFrame: {
  93811. [name: string]: number;
  93812. };
  93813. private _engine;
  93814. private _buffer;
  93815. private _buffers;
  93816. private _bufferIndex;
  93817. private _createBufferOnWrite;
  93818. private _data;
  93819. private _bufferData;
  93820. private _dynamic?;
  93821. private _uniformLocations;
  93822. private _uniformSizes;
  93823. private _uniformArraySizes;
  93824. private _uniformLocationPointer;
  93825. private _needSync;
  93826. private _noUBO;
  93827. private _currentEffect;
  93828. private _currentEffectName;
  93829. private _name;
  93830. private _currentFrameId;
  93831. /** @hidden */
  93832. _alreadyBound: boolean;
  93833. private static _MAX_UNIFORM_SIZE;
  93834. private static _tempBuffer;
  93835. private static _tempBufferInt32View;
  93836. /**
  93837. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93838. * This is dynamic to allow compat with webgl 1 and 2.
  93839. * You will need to pass the name of the uniform as well as the value.
  93840. */
  93841. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93842. /**
  93843. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93844. * This is dynamic to allow compat with webgl 1 and 2.
  93845. * You will need to pass the name of the uniform as well as the value.
  93846. */
  93847. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93848. /**
  93849. * Lambda to Update a single float in a uniform buffer.
  93850. * This is dynamic to allow compat with webgl 1 and 2.
  93851. * You will need to pass the name of the uniform as well as the value.
  93852. */
  93853. updateFloat: (name: string, x: number) => void;
  93854. /**
  93855. * Lambda to Update a vec2 of float in a uniform buffer.
  93856. * This is dynamic to allow compat with webgl 1 and 2.
  93857. * You will need to pass the name of the uniform as well as the value.
  93858. */
  93859. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93860. /**
  93861. * Lambda to Update a vec3 of float in a uniform buffer.
  93862. * This is dynamic to allow compat with webgl 1 and 2.
  93863. * You will need to pass the name of the uniform as well as the value.
  93864. */
  93865. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93866. /**
  93867. * Lambda to Update a vec4 of float in a uniform buffer.
  93868. * This is dynamic to allow compat with webgl 1 and 2.
  93869. * You will need to pass the name of the uniform as well as the value.
  93870. */
  93871. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93872. /**
  93873. * Lambda to Update an array of float in a uniform buffer.
  93874. * This is dynamic to allow compat with webgl 1 and 2.
  93875. * You will need to pass the name of the uniform as well as the value.
  93876. */
  93877. updateFloatArray: (name: string, array: Float32Array) => void;
  93878. /**
  93879. * Lambda to Update an array of number in a uniform buffer.
  93880. * This is dynamic to allow compat with webgl 1 and 2.
  93881. * You will need to pass the name of the uniform as well as the value.
  93882. */
  93883. updateArray: (name: string, array: number[]) => void;
  93884. /**
  93885. * Lambda to Update an array of number in a uniform buffer.
  93886. * This is dynamic to allow compat with webgl 1 and 2.
  93887. * You will need to pass the name of the uniform as well as the value.
  93888. */
  93889. updateIntArray: (name: string, array: Int32Array) => void;
  93890. /**
  93891. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93892. * This is dynamic to allow compat with webgl 1 and 2.
  93893. * You will need to pass the name of the uniform as well as the value.
  93894. */
  93895. updateMatrix: (name: string, mat: IMatrixLike) => void;
  93896. /**
  93897. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  93898. * This is dynamic to allow compat with webgl 1 and 2.
  93899. * You will need to pass the name of the uniform as well as the value.
  93900. */
  93901. updateMatrices: (name: string, mat: Float32Array) => void;
  93902. /**
  93903. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93904. * This is dynamic to allow compat with webgl 1 and 2.
  93905. * You will need to pass the name of the uniform as well as the value.
  93906. */
  93907. updateVector3: (name: string, vector: Vector3) => void;
  93908. /**
  93909. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93910. * This is dynamic to allow compat with webgl 1 and 2.
  93911. * You will need to pass the name of the uniform as well as the value.
  93912. */
  93913. updateVector4: (name: string, vector: Vector4) => void;
  93914. /**
  93915. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93916. * This is dynamic to allow compat with webgl 1 and 2.
  93917. * You will need to pass the name of the uniform as well as the value.
  93918. */
  93919. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93920. /**
  93921. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93922. * This is dynamic to allow compat with webgl 1 and 2.
  93923. * You will need to pass the name of the uniform as well as the value.
  93924. */
  93925. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93926. /**
  93927. * Lambda to Update a int a uniform buffer.
  93928. * This is dynamic to allow compat with webgl 1 and 2.
  93929. * You will need to pass the name of the uniform as well as the value.
  93930. */
  93931. updateInt: (name: string, x: number, suffix?: string) => void;
  93932. /**
  93933. * Lambda to Update a vec2 of int in a uniform buffer.
  93934. * This is dynamic to allow compat with webgl 1 and 2.
  93935. * You will need to pass the name of the uniform as well as the value.
  93936. */
  93937. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  93938. /**
  93939. * Lambda to Update a vec3 of int in a uniform buffer.
  93940. * This is dynamic to allow compat with webgl 1 and 2.
  93941. * You will need to pass the name of the uniform as well as the value.
  93942. */
  93943. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93944. /**
  93945. * Lambda to Update a vec4 of int in a uniform buffer.
  93946. * This is dynamic to allow compat with webgl 1 and 2.
  93947. * You will need to pass the name of the uniform as well as the value.
  93948. */
  93949. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93950. /**
  93951. * Instantiates a new Uniform buffer objects.
  93952. *
  93953. * Handles blocks of uniform on the GPU.
  93954. *
  93955. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  93956. *
  93957. * For more information, please refer to :
  93958. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93959. * @param engine Define the engine the buffer is associated with
  93960. * @param data Define the data contained in the buffer
  93961. * @param dynamic Define if the buffer is updatable
  93962. * @param name to assign to the buffer (debugging purpose)
  93963. */
  93964. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  93965. /**
  93966. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93967. * or just falling back on setUniformXXX calls.
  93968. */
  93969. get useUbo(): boolean;
  93970. /**
  93971. * Indicates if the WebGL underlying uniform buffer is in sync
  93972. * with the javascript cache data.
  93973. */
  93974. get isSync(): boolean;
  93975. /**
  93976. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93977. * Also, a dynamic UniformBuffer will disable cache verification and always
  93978. * update the underlying WebGL uniform buffer to the GPU.
  93979. * @returns if Dynamic, otherwise false
  93980. */
  93981. isDynamic(): boolean;
  93982. /**
  93983. * The data cache on JS side.
  93984. * @returns the underlying data as a float array
  93985. */
  93986. getData(): Float32Array;
  93987. /**
  93988. * The underlying WebGL Uniform buffer.
  93989. * @returns the webgl buffer
  93990. */
  93991. getBuffer(): Nullable<DataBuffer>;
  93992. /**
  93993. * std140 layout specifies how to align data within an UBO structure.
  93994. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93995. * for specs.
  93996. */
  93997. private _fillAlignment;
  93998. /**
  93999. * Adds an uniform in the buffer.
  94000. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94001. * for the layout to be correct !
  94002. * @param name Name of the uniform, as used in the uniform block in the shader.
  94003. * @param size Data size, or data directly.
  94004. * @param arraySize The number of elements in the array, 0 if not an array.
  94005. */
  94006. addUniform(name: string, size: number | number[], arraySize?: number): void;
  94007. /**
  94008. * Adds a Matrix 4x4 to the uniform buffer.
  94009. * @param name Name of the uniform, as used in the uniform block in the shader.
  94010. * @param mat A 4x4 matrix.
  94011. */
  94012. addMatrix(name: string, mat: Matrix): void;
  94013. /**
  94014. * Adds a vec2 to the uniform buffer.
  94015. * @param name Name of the uniform, as used in the uniform block in the shader.
  94016. * @param x Define the x component value of the vec2
  94017. * @param y Define the y component value of the vec2
  94018. */
  94019. addFloat2(name: string, x: number, y: number): void;
  94020. /**
  94021. * Adds a vec3 to the uniform buffer.
  94022. * @param name Name of the uniform, as used in the uniform block in the shader.
  94023. * @param x Define the x component value of the vec3
  94024. * @param y Define the y component value of the vec3
  94025. * @param z Define the z component value of the vec3
  94026. */
  94027. addFloat3(name: string, x: number, y: number, z: number): void;
  94028. /**
  94029. * Adds a vec3 to the uniform buffer.
  94030. * @param name Name of the uniform, as used in the uniform block in the shader.
  94031. * @param color Define the vec3 from a Color
  94032. */
  94033. addColor3(name: string, color: Color3): void;
  94034. /**
  94035. * Adds a vec4 to the uniform buffer.
  94036. * @param name Name of the uniform, as used in the uniform block in the shader.
  94037. * @param color Define the rgb components from a Color
  94038. * @param alpha Define the a component of the vec4
  94039. */
  94040. addColor4(name: string, color: Color3, alpha: number): void;
  94041. /**
  94042. * Adds a vec3 to the uniform buffer.
  94043. * @param name Name of the uniform, as used in the uniform block in the shader.
  94044. * @param vector Define the vec3 components from a Vector
  94045. */
  94046. addVector3(name: string, vector: Vector3): void;
  94047. /**
  94048. * Adds a Matrix 3x3 to the uniform buffer.
  94049. * @param name Name of the uniform, as used in the uniform block in the shader.
  94050. */
  94051. addMatrix3x3(name: string): void;
  94052. /**
  94053. * Adds a Matrix 2x2 to the uniform buffer.
  94054. * @param name Name of the uniform, as used in the uniform block in the shader.
  94055. */
  94056. addMatrix2x2(name: string): void;
  94057. /**
  94058. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94059. */
  94060. create(): void;
  94061. /** @hidden */
  94062. _rebuild(): void;
  94063. /** @hidden */
  94064. get _numBuffers(): number;
  94065. /** @hidden */
  94066. get _indexBuffer(): number;
  94067. /** Gets the name of this buffer */
  94068. get name(): string;
  94069. /**
  94070. * Updates the WebGL Uniform Buffer on the GPU.
  94071. * If the `dynamic` flag is set to true, no cache comparison is done.
  94072. * Otherwise, the buffer will be updated only if the cache differs.
  94073. */
  94074. update(): void;
  94075. private _createNewBuffer;
  94076. private _checkNewFrame;
  94077. /**
  94078. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94079. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94080. * @param data Define the flattened data
  94081. * @param size Define the size of the data.
  94082. */
  94083. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94084. /**
  94085. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94086. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94087. * @param data Define the flattened data
  94088. * @param size Define the size of the data.
  94089. */
  94090. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  94091. private _valueCache;
  94092. private _cacheMatrix;
  94093. private _updateMatrix3x3ForUniform;
  94094. private _updateMatrix3x3ForEffect;
  94095. private _updateMatrix2x2ForEffect;
  94096. private _updateMatrix2x2ForUniform;
  94097. private _updateFloatForEffect;
  94098. private _updateFloatForUniform;
  94099. private _updateFloat2ForEffect;
  94100. private _updateFloat2ForUniform;
  94101. private _updateFloat3ForEffect;
  94102. private _updateFloat3ForUniform;
  94103. private _updateFloat4ForEffect;
  94104. private _updateFloat4ForUniform;
  94105. private _updateFloatArrayForEffect;
  94106. private _updateFloatArrayForUniform;
  94107. private _updateArrayForEffect;
  94108. private _updateArrayForUniform;
  94109. private _updateIntArrayForEffect;
  94110. private _updateIntArrayForUniform;
  94111. private _updateMatrixForEffect;
  94112. private _updateMatrixForUniform;
  94113. private _updateMatricesForEffect;
  94114. private _updateMatricesForUniform;
  94115. private _updateVector3ForEffect;
  94116. private _updateVector3ForUniform;
  94117. private _updateVector4ForEffect;
  94118. private _updateVector4ForUniform;
  94119. private _updateColor3ForEffect;
  94120. private _updateColor3ForUniform;
  94121. private _updateColor4ForEffect;
  94122. private _updateColor4ForUniform;
  94123. private _updateIntForEffect;
  94124. private _updateIntForUniform;
  94125. private _updateInt2ForEffect;
  94126. private _updateInt2ForUniform;
  94127. private _updateInt3ForEffect;
  94128. private _updateInt3ForUniform;
  94129. private _updateInt4ForEffect;
  94130. private _updateInt4ForUniform;
  94131. /**
  94132. * Sets a sampler uniform on the effect.
  94133. * @param name Define the name of the sampler.
  94134. * @param texture Define the texture to set in the sampler
  94135. */
  94136. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94137. /**
  94138. * Directly updates the value of the uniform in the cache AND on the GPU.
  94139. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94140. * @param data Define the flattened data
  94141. */
  94142. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94143. /**
  94144. * Binds this uniform buffer to an effect.
  94145. * @param effect Define the effect to bind the buffer to
  94146. * @param name Name of the uniform block in the shader.
  94147. */
  94148. bindToEffect(effect: Effect, name: string): void;
  94149. /**
  94150. * Disposes the uniform buffer.
  94151. */
  94152. dispose(): void;
  94153. }
  94154. }
  94155. declare module BABYLON {
  94156. /**
  94157. * Manages the defines for the Material
  94158. */
  94159. export class MaterialDefines {
  94160. /** @hidden */
  94161. protected _keys: string[];
  94162. private _isDirty;
  94163. /** @hidden */
  94164. _renderId: number;
  94165. /** @hidden */
  94166. _areLightsDirty: boolean;
  94167. /** @hidden */
  94168. _areLightsDisposed: boolean;
  94169. /** @hidden */
  94170. _areAttributesDirty: boolean;
  94171. /** @hidden */
  94172. _areTexturesDirty: boolean;
  94173. /** @hidden */
  94174. _areFresnelDirty: boolean;
  94175. /** @hidden */
  94176. _areMiscDirty: boolean;
  94177. /** @hidden */
  94178. _arePrePassDirty: boolean;
  94179. /** @hidden */
  94180. _areImageProcessingDirty: boolean;
  94181. /** @hidden */
  94182. _normals: boolean;
  94183. /** @hidden */
  94184. _uvs: boolean;
  94185. /** @hidden */
  94186. _needNormals: boolean;
  94187. /** @hidden */
  94188. _needUVs: boolean;
  94189. [id: string]: any;
  94190. /**
  94191. * Specifies if the material needs to be re-calculated
  94192. */
  94193. get isDirty(): boolean;
  94194. /**
  94195. * Marks the material to indicate that it has been re-calculated
  94196. */
  94197. markAsProcessed(): void;
  94198. /**
  94199. * Marks the material to indicate that it needs to be re-calculated
  94200. */
  94201. markAsUnprocessed(): void;
  94202. /**
  94203. * Marks the material to indicate all of its defines need to be re-calculated
  94204. */
  94205. markAllAsDirty(): void;
  94206. /**
  94207. * Marks the material to indicate that image processing needs to be re-calculated
  94208. */
  94209. markAsImageProcessingDirty(): void;
  94210. /**
  94211. * Marks the material to indicate the lights need to be re-calculated
  94212. * @param disposed Defines whether the light is dirty due to dispose or not
  94213. */
  94214. markAsLightDirty(disposed?: boolean): void;
  94215. /**
  94216. * Marks the attribute state as changed
  94217. */
  94218. markAsAttributesDirty(): void;
  94219. /**
  94220. * Marks the texture state as changed
  94221. */
  94222. markAsTexturesDirty(): void;
  94223. /**
  94224. * Marks the fresnel state as changed
  94225. */
  94226. markAsFresnelDirty(): void;
  94227. /**
  94228. * Marks the misc state as changed
  94229. */
  94230. markAsMiscDirty(): void;
  94231. /**
  94232. * Marks the prepass state as changed
  94233. */
  94234. markAsPrePassDirty(): void;
  94235. /**
  94236. * Rebuilds the material defines
  94237. */
  94238. rebuild(): void;
  94239. /**
  94240. * Specifies if two material defines are equal
  94241. * @param other - A material define instance to compare to
  94242. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  94243. */
  94244. isEqual(other: MaterialDefines): boolean;
  94245. /**
  94246. * Clones this instance's defines to another instance
  94247. * @param other - material defines to clone values to
  94248. */
  94249. cloneTo(other: MaterialDefines): void;
  94250. /**
  94251. * Resets the material define values
  94252. */
  94253. reset(): void;
  94254. /**
  94255. * Converts the material define values to a string
  94256. * @returns - String of material define information
  94257. */
  94258. toString(): string;
  94259. }
  94260. }
  94261. declare module BABYLON {
  94262. /**
  94263. * Enum that determines the text-wrapping mode to use.
  94264. */
  94265. export enum InspectableType {
  94266. /**
  94267. * Checkbox for booleans
  94268. */
  94269. Checkbox = 0,
  94270. /**
  94271. * Sliders for numbers
  94272. */
  94273. Slider = 1,
  94274. /**
  94275. * Vector3
  94276. */
  94277. Vector3 = 2,
  94278. /**
  94279. * Quaternions
  94280. */
  94281. Quaternion = 3,
  94282. /**
  94283. * Color3
  94284. */
  94285. Color3 = 4,
  94286. /**
  94287. * String
  94288. */
  94289. String = 5
  94290. }
  94291. /**
  94292. * Interface used to define custom inspectable properties.
  94293. * This interface is used by the inspector to display custom property grids
  94294. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94295. */
  94296. export interface IInspectable {
  94297. /**
  94298. * Gets the label to display
  94299. */
  94300. label: string;
  94301. /**
  94302. * Gets the name of the property to edit
  94303. */
  94304. propertyName: string;
  94305. /**
  94306. * Gets the type of the editor to use
  94307. */
  94308. type: InspectableType;
  94309. /**
  94310. * Gets the minimum value of the property when using in "slider" mode
  94311. */
  94312. min?: number;
  94313. /**
  94314. * Gets the maximum value of the property when using in "slider" mode
  94315. */
  94316. max?: number;
  94317. /**
  94318. * Gets the setp to use when using in "slider" mode
  94319. */
  94320. step?: number;
  94321. }
  94322. }
  94323. declare module BABYLON {
  94324. /**
  94325. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  94326. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  94327. * 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.
  94328. */
  94329. export abstract class Light extends Node {
  94330. /**
  94331. * Falloff Default: light is falling off following the material specification:
  94332. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  94333. */
  94334. static readonly FALLOFF_DEFAULT: number;
  94335. /**
  94336. * Falloff Physical: light is falling off following the inverse squared distance law.
  94337. */
  94338. static readonly FALLOFF_PHYSICAL: number;
  94339. /**
  94340. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  94341. * to enhance interoperability with other engines.
  94342. */
  94343. static readonly FALLOFF_GLTF: number;
  94344. /**
  94345. * Falloff Standard: light is falling off like in the standard material
  94346. * to enhance interoperability with other materials.
  94347. */
  94348. static readonly FALLOFF_STANDARD: number;
  94349. /**
  94350. * If every light affecting the material is in this lightmapMode,
  94351. * material.lightmapTexture adds or multiplies
  94352. * (depends on material.useLightmapAsShadowmap)
  94353. * after every other light calculations.
  94354. */
  94355. static readonly LIGHTMAP_DEFAULT: number;
  94356. /**
  94357. * material.lightmapTexture as only diffuse lighting from this light
  94358. * adds only specular lighting from this light
  94359. * adds dynamic shadows
  94360. */
  94361. static readonly LIGHTMAP_SPECULAR: number;
  94362. /**
  94363. * material.lightmapTexture as only lighting
  94364. * no light calculation from this light
  94365. * only adds dynamic shadows from this light
  94366. */
  94367. static readonly LIGHTMAP_SHADOWSONLY: number;
  94368. /**
  94369. * Each light type uses the default quantity according to its type:
  94370. * point/spot lights use luminous intensity
  94371. * directional lights use illuminance
  94372. */
  94373. static readonly INTENSITYMODE_AUTOMATIC: number;
  94374. /**
  94375. * lumen (lm)
  94376. */
  94377. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  94378. /**
  94379. * candela (lm/sr)
  94380. */
  94381. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  94382. /**
  94383. * lux (lm/m^2)
  94384. */
  94385. static readonly INTENSITYMODE_ILLUMINANCE: number;
  94386. /**
  94387. * nit (cd/m^2)
  94388. */
  94389. static readonly INTENSITYMODE_LUMINANCE: number;
  94390. /**
  94391. * Light type const id of the point light.
  94392. */
  94393. static readonly LIGHTTYPEID_POINTLIGHT: number;
  94394. /**
  94395. * Light type const id of the directional light.
  94396. */
  94397. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  94398. /**
  94399. * Light type const id of the spot light.
  94400. */
  94401. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  94402. /**
  94403. * Light type const id of the hemispheric light.
  94404. */
  94405. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  94406. /**
  94407. * Diffuse gives the basic color to an object.
  94408. */
  94409. diffuse: Color3;
  94410. /**
  94411. * Specular produces a highlight color on an object.
  94412. * Note: This is note affecting PBR materials.
  94413. */
  94414. specular: Color3;
  94415. /**
  94416. * Defines the falloff type for this light. This lets overriding how punctual light are
  94417. * falling off base on range or angle.
  94418. * This can be set to any values in Light.FALLOFF_x.
  94419. *
  94420. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  94421. * other types of materials.
  94422. */
  94423. falloffType: number;
  94424. /**
  94425. * Strength of the light.
  94426. * Note: By default it is define in the framework own unit.
  94427. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  94428. */
  94429. intensity: number;
  94430. private _range;
  94431. protected _inverseSquaredRange: number;
  94432. /**
  94433. * Defines how far from the source the light is impacting in scene units.
  94434. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  94435. */
  94436. get range(): number;
  94437. /**
  94438. * Defines how far from the source the light is impacting in scene units.
  94439. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  94440. */
  94441. set range(value: number);
  94442. /**
  94443. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  94444. * of light.
  94445. */
  94446. private _photometricScale;
  94447. private _intensityMode;
  94448. /**
  94449. * Gets the photometric scale used to interpret the intensity.
  94450. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  94451. */
  94452. get intensityMode(): number;
  94453. /**
  94454. * Sets the photometric scale used to interpret the intensity.
  94455. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  94456. */
  94457. set intensityMode(value: number);
  94458. private _radius;
  94459. /**
  94460. * Gets the light radius used by PBR Materials to simulate soft area lights.
  94461. */
  94462. get radius(): number;
  94463. /**
  94464. * sets the light radius used by PBR Materials to simulate soft area lights.
  94465. */
  94466. set radius(value: number);
  94467. private _renderPriority;
  94468. /**
  94469. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  94470. * exceeding the number allowed of the materials.
  94471. */
  94472. renderPriority: number;
  94473. private _shadowEnabled;
  94474. /**
  94475. * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  94476. * the current shadow generator.
  94477. */
  94478. get shadowEnabled(): boolean;
  94479. /**
  94480. * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  94481. * the current shadow generator.
  94482. */
  94483. set shadowEnabled(value: boolean);
  94484. private _includedOnlyMeshes;
  94485. /**
  94486. * Gets the only meshes impacted by this light.
  94487. */
  94488. get includedOnlyMeshes(): AbstractMesh[];
  94489. /**
  94490. * Sets the only meshes impacted by this light.
  94491. */
  94492. set includedOnlyMeshes(value: AbstractMesh[]);
  94493. private _excludedMeshes;
  94494. /**
  94495. * Gets the meshes not impacted by this light.
  94496. */
  94497. get excludedMeshes(): AbstractMesh[];
  94498. /**
  94499. * Sets the meshes not impacted by this light.
  94500. */
  94501. set excludedMeshes(value: AbstractMesh[]);
  94502. private _excludeWithLayerMask;
  94503. /**
  94504. * Gets the layer id use to find what meshes are not impacted by the light.
  94505. * Inactive if 0
  94506. */
  94507. get excludeWithLayerMask(): number;
  94508. /**
  94509. * Sets the layer id use to find what meshes are not impacted by the light.
  94510. * Inactive if 0
  94511. */
  94512. set excludeWithLayerMask(value: number);
  94513. private _includeOnlyWithLayerMask;
  94514. /**
  94515. * Gets the layer id use to find what meshes are impacted by the light.
  94516. * Inactive if 0
  94517. */
  94518. get includeOnlyWithLayerMask(): number;
  94519. /**
  94520. * Sets the layer id use to find what meshes are impacted by the light.
  94521. * Inactive if 0
  94522. */
  94523. set includeOnlyWithLayerMask(value: number);
  94524. private _lightmapMode;
  94525. /**
  94526. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  94527. */
  94528. get lightmapMode(): number;
  94529. /**
  94530. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  94531. */
  94532. set lightmapMode(value: number);
  94533. /**
  94534. * Shadow generator associated to the light.
  94535. * @hidden Internal use only.
  94536. */
  94537. _shadowGenerator: Nullable<IShadowGenerator>;
  94538. /**
  94539. * @hidden Internal use only.
  94540. */
  94541. _excludedMeshesIds: string[];
  94542. /**
  94543. * @hidden Internal use only.
  94544. */
  94545. _includedOnlyMeshesIds: string[];
  94546. /**
  94547. * The current light uniform buffer.
  94548. * @hidden Internal use only.
  94549. */
  94550. _uniformBuffer: UniformBuffer;
  94551. /** @hidden */
  94552. _renderId: number;
  94553. /**
  94554. * Creates a Light object in the scene.
  94555. * Documentation : https://doc.babylonjs.com/babylon101/lights
  94556. * @param name The friendly name of the light
  94557. * @param scene The scene the light belongs too
  94558. */
  94559. constructor(name: string, scene: Scene);
  94560. protected abstract _buildUniformLayout(): void;
  94561. /**
  94562. * Sets the passed Effect "effect" with the Light information.
  94563. * @param effect The effect to update
  94564. * @param lightIndex The index of the light in the effect to update
  94565. * @returns The light
  94566. */
  94567. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  94568. /**
  94569. * Sets the passed Effect "effect" with the Light textures.
  94570. * @param effect The effect to update
  94571. * @param lightIndex The index of the light in the effect to update
  94572. * @returns The light
  94573. */
  94574. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  94575. /**
  94576. * Binds the lights information from the scene to the effect for the given mesh.
  94577. * @param lightIndex Light index
  94578. * @param scene The scene where the light belongs to
  94579. * @param effect The effect we are binding the data to
  94580. * @param useSpecular Defines if specular is supported
  94581. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  94582. */
  94583. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  94584. /**
  94585. * Sets the passed Effect "effect" with the Light information.
  94586. * @param effect The effect to update
  94587. * @param lightDataUniformName The uniform used to store light data (position or direction)
  94588. * @returns The light
  94589. */
  94590. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  94591. /**
  94592. * Returns the string "Light".
  94593. * @returns the class name
  94594. */
  94595. getClassName(): string;
  94596. /** @hidden */
  94597. readonly _isLight: boolean;
  94598. /**
  94599. * Converts the light information to a readable string for debug purpose.
  94600. * @param fullDetails Supports for multiple levels of logging within scene loading
  94601. * @returns the human readable light info
  94602. */
  94603. toString(fullDetails?: boolean): string;
  94604. /** @hidden */
  94605. protected _syncParentEnabledState(): void;
  94606. /**
  94607. * Set the enabled state of this node.
  94608. * @param value - the new enabled state
  94609. */
  94610. setEnabled(value: boolean): void;
  94611. /**
  94612. * Returns the Light associated shadow generator if any.
  94613. * @return the associated shadow generator.
  94614. */
  94615. getShadowGenerator(): Nullable<IShadowGenerator>;
  94616. /**
  94617. * Returns a Vector3, the absolute light position in the World.
  94618. * @returns the world space position of the light
  94619. */
  94620. getAbsolutePosition(): Vector3;
  94621. /**
  94622. * Specifies if the light will affect the passed mesh.
  94623. * @param mesh The mesh to test against the light
  94624. * @return true the mesh is affected otherwise, false.
  94625. */
  94626. canAffectMesh(mesh: AbstractMesh): boolean;
  94627. /**
  94628. * Sort function to order lights for rendering.
  94629. * @param a First Light object to compare to second.
  94630. * @param b Second Light object to compare first.
  94631. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  94632. */
  94633. static CompareLightsPriority(a: Light, b: Light): number;
  94634. /**
  94635. * Releases resources associated with this node.
  94636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94638. */
  94639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94640. /**
  94641. * Returns the light type ID (integer).
  94642. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  94643. */
  94644. getTypeID(): number;
  94645. /**
  94646. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  94647. * @returns the scaled intensity in intensity mode unit
  94648. */
  94649. getScaledIntensity(): number;
  94650. /**
  94651. * Returns a new Light object, named "name", from the current one.
  94652. * @param name The name of the cloned light
  94653. * @param newParent The parent of this light, if it has one
  94654. * @returns the new created light
  94655. */
  94656. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  94657. /**
  94658. * Serializes the current light into a Serialization object.
  94659. * @returns the serialized object.
  94660. */
  94661. serialize(): any;
  94662. /**
  94663. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  94664. * This new light is named "name" and added to the passed scene.
  94665. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  94666. * @param name The friendly name of the light
  94667. * @param scene The scene the new light will belong to
  94668. * @returns the constructor function
  94669. */
  94670. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  94671. /**
  94672. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  94673. * @param parsedLight The JSON representation of the light
  94674. * @param scene The scene to create the parsed light in
  94675. * @returns the created light after parsing
  94676. */
  94677. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  94678. private _hookArrayForExcluded;
  94679. private _hookArrayForIncludedOnly;
  94680. private _resyncMeshes;
  94681. /**
  94682. * Forces the meshes to update their light related information in their rendering used effects
  94683. * @hidden Internal Use Only
  94684. */
  94685. _markMeshesAsLightDirty(): void;
  94686. /**
  94687. * Recomputes the cached photometric scale if needed.
  94688. */
  94689. private _computePhotometricScale;
  94690. /**
  94691. * Returns the Photometric Scale according to the light type and intensity mode.
  94692. */
  94693. private _getPhotometricScale;
  94694. /**
  94695. * Reorder the light in the scene according to their defined priority.
  94696. * @hidden Internal Use Only
  94697. */
  94698. _reorderLightsInScene(): void;
  94699. /**
  94700. * Prepares the list of defines specific to the light type.
  94701. * @param defines the list of defines
  94702. * @param lightIndex defines the index of the light for the effect
  94703. */
  94704. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  94705. }
  94706. }
  94707. declare module BABYLON {
  94708. /** Defines supported spaces */
  94709. export enum Space {
  94710. /** Local (object) space */
  94711. LOCAL = 0,
  94712. /** World space */
  94713. WORLD = 1,
  94714. /** Bone space */
  94715. BONE = 2
  94716. }
  94717. /** Defines the 3 main axes */
  94718. export class Axis {
  94719. /** X axis */
  94720. static X: Vector3;
  94721. /** Y axis */
  94722. static Y: Vector3;
  94723. /** Z axis */
  94724. static Z: Vector3;
  94725. }
  94726. /**
  94727. * Defines cartesian components.
  94728. */
  94729. export enum Coordinate {
  94730. /** X axis */
  94731. X = 0,
  94732. /** Y axis */
  94733. Y = 1,
  94734. /** Z axis */
  94735. Z = 2
  94736. }
  94737. }
  94738. declare module BABYLON {
  94739. /**
  94740. * Interface describing all the common properties and methods a shadow light needs to implement.
  94741. * This helps both the shadow generator and materials to generate the corresponding shadow maps
  94742. * as well as binding the different shadow properties to the effects.
  94743. */
  94744. export interface IShadowLight extends Light {
  94745. /**
  94746. * The light id in the scene (used in scene.findLightById for instance)
  94747. */
  94748. id: string;
  94749. /**
  94750. * The position the shadow will be casted from.
  94751. */
  94752. position: Vector3;
  94753. /**
  94754. * In 2d mode (needCube being false), the direction used to cast the shadow.
  94755. */
  94756. direction: Vector3;
  94757. /**
  94758. * The transformed position. Position of the light in world space taking parenting in account.
  94759. */
  94760. transformedPosition: Vector3;
  94761. /**
  94762. * The transformed direction. Direction of the light in world space taking parenting in account.
  94763. */
  94764. transformedDirection: Vector3;
  94765. /**
  94766. * The friendly name of the light in the scene.
  94767. */
  94768. name: string;
  94769. /**
  94770. * Defines the shadow projection clipping minimum z value.
  94771. */
  94772. shadowMinZ: number;
  94773. /**
  94774. * Defines the shadow projection clipping maximum z value.
  94775. */
  94776. shadowMaxZ: number;
  94777. /**
  94778. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  94779. * @returns true if the information has been computed, false if it does not need to (no parenting)
  94780. */
  94781. computeTransformedInformation(): boolean;
  94782. /**
  94783. * Gets the scene the light belongs to.
  94784. * @returns The scene
  94785. */
  94786. getScene(): Scene;
  94787. /**
  94788. * Callback defining a custom Projection Matrix Builder.
  94789. * This can be used to override the default projection matrix computation.
  94790. */
  94791. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  94792. /**
  94793. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  94794. * @param matrix The matrix to updated with the projection information
  94795. * @param viewMatrix The transform matrix of the light
  94796. * @param renderList The list of mesh to render in the map
  94797. * @returns The current light
  94798. */
  94799. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  94800. /**
  94801. * Gets the current depth scale used in ESM.
  94802. * @returns The scale
  94803. */
  94804. getDepthScale(): number;
  94805. /**
  94806. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  94807. * @returns true if a cube texture needs to be use
  94808. */
  94809. needCube(): boolean;
  94810. /**
  94811. * Detects if the projection matrix requires to be recomputed this frame.
  94812. * @returns true if it requires to be recomputed otherwise, false.
  94813. */
  94814. needProjectionMatrixCompute(): boolean;
  94815. /**
  94816. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  94817. */
  94818. forceProjectionMatrixCompute(): void;
  94819. /**
  94820. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  94821. * @param faceIndex The index of the face we are computed the direction to generate shadow
  94822. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  94823. */
  94824. getShadowDirection(faceIndex?: number): Vector3;
  94825. /**
  94826. * Gets the minZ used for shadow according to both the scene and the light.
  94827. * @param activeCamera The camera we are returning the min for
  94828. * @returns the depth min z
  94829. */
  94830. getDepthMinZ(activeCamera: Camera): number;
  94831. /**
  94832. * Gets the maxZ used for shadow according to both the scene and the light.
  94833. * @param activeCamera The camera we are returning the max for
  94834. * @returns the depth max z
  94835. */
  94836. getDepthMaxZ(activeCamera: Camera): number;
  94837. }
  94838. /**
  94839. * Base implementation IShadowLight
  94840. * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.
  94841. */
  94842. export abstract class ShadowLight extends Light implements IShadowLight {
  94843. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  94844. protected _position: Vector3;
  94845. protected _setPosition(value: Vector3): void;
  94846. /**
  94847. * Sets the position the shadow will be casted from. Also use as the light position for both
  94848. * point and spot lights.
  94849. */
  94850. get position(): Vector3;
  94851. /**
  94852. * Sets the position the shadow will be casted from. Also use as the light position for both
  94853. * point and spot lights.
  94854. */
  94855. set position(value: Vector3);
  94856. protected _direction: Vector3;
  94857. protected _setDirection(value: Vector3): void;
  94858. /**
  94859. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  94860. * Also use as the light direction on spot and directional lights.
  94861. */
  94862. get direction(): Vector3;
  94863. /**
  94864. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  94865. * Also use as the light direction on spot and directional lights.
  94866. */
  94867. set direction(value: Vector3);
  94868. protected _shadowMinZ: number;
  94869. /**
  94870. * Gets the shadow projection clipping minimum z value.
  94871. */
  94872. get shadowMinZ(): number;
  94873. /**
  94874. * Sets the shadow projection clipping minimum z value.
  94875. */
  94876. set shadowMinZ(value: number);
  94877. protected _shadowMaxZ: number;
  94878. /**
  94879. * Sets the shadow projection clipping maximum z value.
  94880. */
  94881. get shadowMaxZ(): number;
  94882. /**
  94883. * Gets the shadow projection clipping maximum z value.
  94884. */
  94885. set shadowMaxZ(value: number);
  94886. /**
  94887. * Callback defining a custom Projection Matrix Builder.
  94888. * This can be used to override the default projection matrix computation.
  94889. */
  94890. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  94891. /**
  94892. * The transformed position. Position of the light in world space taking parenting in account.
  94893. */
  94894. transformedPosition: Vector3;
  94895. /**
  94896. * The transformed direction. Direction of the light in world space taking parenting in account.
  94897. */
  94898. transformedDirection: Vector3;
  94899. private _needProjectionMatrixCompute;
  94900. /**
  94901. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  94902. * @returns true if the information has been computed, false if it does not need to (no parenting)
  94903. */
  94904. computeTransformedInformation(): boolean;
  94905. /**
  94906. * Return the depth scale used for the shadow map.
  94907. * @returns the depth scale.
  94908. */
  94909. getDepthScale(): number;
  94910. /**
  94911. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  94912. * @param faceIndex The index of the face we are computed the direction to generate shadow
  94913. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  94914. */
  94915. getShadowDirection(faceIndex?: number): Vector3;
  94916. /**
  94917. * Returns the ShadowLight absolute position in the World.
  94918. * @returns the position vector in world space
  94919. */
  94920. getAbsolutePosition(): Vector3;
  94921. /**
  94922. * Sets the ShadowLight direction toward the passed target.
  94923. * @param target The point to target in local space
  94924. * @returns the updated ShadowLight direction
  94925. */
  94926. setDirectionToTarget(target: Vector3): Vector3;
  94927. /**
  94928. * Returns the light rotation in euler definition.
  94929. * @returns the x y z rotation in local space.
  94930. */
  94931. getRotation(): Vector3;
  94932. /**
  94933. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  94934. * @returns true if a cube texture needs to be use
  94935. */
  94936. needCube(): boolean;
  94937. /**
  94938. * Detects if the projection matrix requires to be recomputed this frame.
  94939. * @returns true if it requires to be recomputed otherwise, false.
  94940. */
  94941. needProjectionMatrixCompute(): boolean;
  94942. /**
  94943. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  94944. */
  94945. forceProjectionMatrixCompute(): void;
  94946. /** @hidden */
  94947. _initCache(): void;
  94948. /** @hidden */
  94949. _isSynchronized(): boolean;
  94950. /**
  94951. * Computes the world matrix of the node
  94952. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94953. * @returns the world matrix
  94954. */
  94955. computeWorldMatrix(force?: boolean): Matrix;
  94956. /**
  94957. * Gets the minZ used for shadow according to both the scene and the light.
  94958. * @param activeCamera The camera we are returning the min for
  94959. * @returns the depth min z
  94960. */
  94961. getDepthMinZ(activeCamera: Camera): number;
  94962. /**
  94963. * Gets the maxZ used for shadow according to both the scene and the light.
  94964. * @param activeCamera The camera we are returning the max for
  94965. * @returns the depth max z
  94966. */
  94967. getDepthMaxZ(activeCamera: Camera): number;
  94968. /**
  94969. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  94970. * @param matrix The matrix to updated with the projection information
  94971. * @param viewMatrix The transform matrix of the light
  94972. * @param renderList The list of mesh to render in the map
  94973. * @returns The current light
  94974. */
  94975. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  94976. }
  94977. }
  94978. declare module BABYLON {
  94979. /**
  94980. * Configuration needed for prepass-capable materials
  94981. */
  94982. export class PrePassConfiguration {
  94983. /**
  94984. * Previous world matrices of meshes carrying this material
  94985. * Used for computing velocity
  94986. */
  94987. previousWorldMatrices: {
  94988. [index: number]: Matrix;
  94989. };
  94990. /**
  94991. * Previous view project matrix
  94992. * Used for computing velocity
  94993. */
  94994. previousViewProjection: Matrix;
  94995. /**
  94996. * Previous bones of meshes carrying this material
  94997. * Used for computing velocity
  94998. */
  94999. previousBones: {
  95000. [index: number]: Float32Array;
  95001. };
  95002. /**
  95003. * Add the required uniforms to the current list.
  95004. * @param uniforms defines the current uniform list.
  95005. */
  95006. static AddUniforms(uniforms: string[]): void;
  95007. /**
  95008. * Add the required samplers to the current list.
  95009. * @param samplers defines the current sampler list.
  95010. */
  95011. static AddSamplers(samplers: string[]): void;
  95012. /**
  95013. * Binds the material data.
  95014. * @param effect defines the effect to update
  95015. * @param scene defines the scene the material belongs to.
  95016. * @param mesh The mesh
  95017. * @param world World matrix of this mesh
  95018. * @param isFrozen Is the material frozen
  95019. */
  95020. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  95021. }
  95022. }
  95023. declare module BABYLON {
  95024. /**
  95025. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95026. * This is the base of the follow, arc rotate cameras and Free camera
  95027. * @see https://doc.babylonjs.com/features/cameras
  95028. */
  95029. export class TargetCamera extends Camera {
  95030. private static _RigCamTransformMatrix;
  95031. private static _TargetTransformMatrix;
  95032. private static _TargetFocalPoint;
  95033. private _tmpUpVector;
  95034. private _tmpTargetVector;
  95035. /**
  95036. * Define the current direction the camera is moving to
  95037. */
  95038. cameraDirection: Vector3;
  95039. /**
  95040. * Define the current rotation the camera is rotating to
  95041. */
  95042. cameraRotation: Vector2;
  95043. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  95044. ignoreParentScaling: boolean;
  95045. /**
  95046. * When set, the up vector of the camera will be updated by the rotation of the camera
  95047. */
  95048. updateUpVectorFromRotation: boolean;
  95049. private _tmpQuaternion;
  95050. /**
  95051. * Define the current rotation of the camera
  95052. */
  95053. rotation: Vector3;
  95054. /**
  95055. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95056. */
  95057. rotationQuaternion: Quaternion;
  95058. /**
  95059. * Define the current speed of the camera
  95060. */
  95061. speed: number;
  95062. /**
  95063. * Add constraint to the camera to prevent it to move freely in all directions and
  95064. * around all axis.
  95065. */
  95066. noRotationConstraint: boolean;
  95067. /**
  95068. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95069. * panning
  95070. */
  95071. invertRotation: boolean;
  95072. /**
  95073. * Speed multiplier for inverse camera panning
  95074. */
  95075. inverseRotationSpeed: number;
  95076. /**
  95077. * Define the current target of the camera as an object or a position.
  95078. */
  95079. lockedTarget: any;
  95080. /** @hidden */
  95081. _currentTarget: Vector3;
  95082. /** @hidden */
  95083. _initialFocalDistance: number;
  95084. /** @hidden */
  95085. _viewMatrix: Matrix;
  95086. /** @hidden */
  95087. _camMatrix: Matrix;
  95088. /** @hidden */
  95089. _cameraTransformMatrix: Matrix;
  95090. /** @hidden */
  95091. _cameraRotationMatrix: Matrix;
  95092. /** @hidden */
  95093. _referencePoint: Vector3;
  95094. /** @hidden */
  95095. _transformedReferencePoint: Vector3;
  95096. /** @hidden */
  95097. _reset: () => void;
  95098. private _defaultUp;
  95099. /**
  95100. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95101. * This is the base of the follow, arc rotate cameras and Free camera
  95102. * @see https://doc.babylonjs.com/features/cameras
  95103. * @param name Defines the name of the camera in the scene
  95104. * @param position Defines the start position of the camera in the scene
  95105. * @param scene Defines the scene the camera belongs to
  95106. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  95107. */
  95108. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95109. /**
  95110. * Gets the position in front of the camera at a given distance.
  95111. * @param distance The distance from the camera we want the position to be
  95112. * @returns the position
  95113. */
  95114. getFrontPosition(distance: number): Vector3;
  95115. /** @hidden */
  95116. _getLockedTargetPosition(): Nullable<Vector3>;
  95117. private _storedPosition;
  95118. private _storedRotation;
  95119. private _storedRotationQuaternion;
  95120. /**
  95121. * Store current camera state of the camera (fov, position, rotation, etc..)
  95122. * @returns the camera
  95123. */
  95124. storeState(): Camera;
  95125. /**
  95126. * Restored camera state. You must call storeState() first
  95127. * @returns whether it was successful or not
  95128. * @hidden
  95129. */
  95130. _restoreStateValues(): boolean;
  95131. /** @hidden */
  95132. _initCache(): void;
  95133. /** @hidden */
  95134. _updateCache(ignoreParentClass?: boolean): void;
  95135. /** @hidden */
  95136. _isSynchronizedViewMatrix(): boolean;
  95137. /** @hidden */
  95138. _computeLocalCameraSpeed(): number;
  95139. /**
  95140. * Defines the target the camera should look at.
  95141. * @param target Defines the new target as a Vector or a mesh
  95142. */
  95143. setTarget(target: Vector3): void;
  95144. /**
  95145. * Defines the target point of the camera.
  95146. * The camera looks towards it form the radius distance.
  95147. */
  95148. get target(): Vector3;
  95149. set target(value: Vector3);
  95150. /**
  95151. * Return the current target position of the camera. This value is expressed in local space.
  95152. * @returns the target position
  95153. */
  95154. getTarget(): Vector3;
  95155. /** @hidden */
  95156. _decideIfNeedsToMove(): boolean;
  95157. /** @hidden */
  95158. _updatePosition(): void;
  95159. /** @hidden */
  95160. _checkInputs(): void;
  95161. protected _updateCameraRotationMatrix(): void;
  95162. /**
  95163. * 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)
  95164. * @returns the current camera
  95165. */
  95166. private _rotateUpVectorWithCameraRotationMatrix;
  95167. private _cachedRotationZ;
  95168. private _cachedQuaternionRotationZ;
  95169. /** @hidden */
  95170. _getViewMatrix(): Matrix;
  95171. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95172. /**
  95173. * @hidden
  95174. */
  95175. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95176. /**
  95177. * @hidden
  95178. */
  95179. _updateRigCameras(): void;
  95180. private _getRigCamPositionAndTarget;
  95181. /**
  95182. * Gets the current object class name.
  95183. * @return the class name
  95184. */
  95185. getClassName(): string;
  95186. }
  95187. }
  95188. declare module BABYLON {
  95189. /**
  95190. * @ignore
  95191. * This is a list of all the different input types that are available in the application.
  95192. * Fo instance: ArcRotateCameraGamepadInput...
  95193. */
  95194. export var CameraInputTypes: {};
  95195. /**
  95196. * This is the contract to implement in order to create a new input class.
  95197. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  95198. */
  95199. export interface ICameraInput<TCamera extends Camera> {
  95200. /**
  95201. * Defines the camera the input is attached to.
  95202. */
  95203. camera: Nullable<TCamera>;
  95204. /**
  95205. * Gets the class name of the current input.
  95206. * @returns the class name
  95207. */
  95208. getClassName(): string;
  95209. /**
  95210. * Get the friendly name associated with the input class.
  95211. * @returns the input friendly name
  95212. */
  95213. getSimpleName(): string;
  95214. /**
  95215. * Attach the input controls to a specific dom element to get the input from.
  95216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95217. */
  95218. attachControl(noPreventDefault?: boolean): void;
  95219. /**
  95220. * Detach the current controls from the specified dom element.
  95221. */
  95222. detachControl(): void;
  95223. /**
  95224. * Update the current camera state depending on the inputs that have been used this frame.
  95225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95226. */
  95227. checkInputs?: () => void;
  95228. }
  95229. /**
  95230. * Represents a map of input types to input instance or input index to input instance.
  95231. */
  95232. export interface CameraInputsMap<TCamera extends Camera> {
  95233. /**
  95234. * Accessor to the input by input type.
  95235. */
  95236. [name: string]: ICameraInput<TCamera>;
  95237. /**
  95238. * Accessor to the input by input index.
  95239. */
  95240. [idx: number]: ICameraInput<TCamera>;
  95241. }
  95242. /**
  95243. * This represents the input manager used within a camera.
  95244. * It helps dealing with all the different kind of input attached to a camera.
  95245. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  95246. */
  95247. export class CameraInputsManager<TCamera extends Camera> {
  95248. /**
  95249. * Defines the list of inputs attached to the camera.
  95250. */
  95251. attached: CameraInputsMap<TCamera>;
  95252. /**
  95253. * Defines the dom element the camera is collecting inputs from.
  95254. * This is null if the controls have not been attached.
  95255. */
  95256. attachedToElement: boolean;
  95257. /**
  95258. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95259. */
  95260. noPreventDefault: boolean;
  95261. /**
  95262. * Defined the camera the input manager belongs to.
  95263. */
  95264. camera: TCamera;
  95265. /**
  95266. * Update the current camera state depending on the inputs that have been used this frame.
  95267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95268. */
  95269. checkInputs: () => void;
  95270. /**
  95271. * Instantiate a new Camera Input Manager.
  95272. * @param camera Defines the camera the input manager belongs to
  95273. */
  95274. constructor(camera: TCamera);
  95275. /**
  95276. * Add an input method to a camera
  95277. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  95278. * @param input camera input method
  95279. */
  95280. add(input: ICameraInput<TCamera>): void;
  95281. /**
  95282. * Remove a specific input method from a camera
  95283. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  95284. * @param inputToRemove camera input method
  95285. */
  95286. remove(inputToRemove: ICameraInput<TCamera>): void;
  95287. /**
  95288. * Remove a specific input type from a camera
  95289. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  95290. * @param inputType the type of the input to remove
  95291. */
  95292. removeByType(inputType: string): void;
  95293. private _addCheckInputs;
  95294. /**
  95295. * Attach the input controls to the currently attached dom element to listen the events from.
  95296. * @param input Defines the input to attach
  95297. */
  95298. attachInput(input: ICameraInput<TCamera>): void;
  95299. /**
  95300. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  95301. * @param element Defines the dom element to collect the events from
  95302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95303. */
  95304. attachElement(noPreventDefault?: boolean): void;
  95305. /**
  95306. * Detach the current manager inputs controls from a specific dom element.
  95307. * @param element Defines the dom element to collect the events from
  95308. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  95309. */
  95310. detachElement(disconnect?: boolean): void;
  95311. /**
  95312. * Rebuild the dynamic inputCheck function from the current list of
  95313. * defined inputs in the manager.
  95314. */
  95315. rebuildInputCheck(): void;
  95316. /**
  95317. * Remove all attached input methods from a camera
  95318. */
  95319. clear(): void;
  95320. /**
  95321. * Serialize the current input manager attached to a camera.
  95322. * This ensures than once parsed,
  95323. * the input associated to the camera will be identical to the current ones
  95324. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  95325. */
  95326. serialize(serializedCamera: any): void;
  95327. /**
  95328. * Parses an input manager serialized JSON to restore the previous list of inputs
  95329. * and states associated to a camera.
  95330. * @param parsedCamera Defines the JSON to parse
  95331. */
  95332. parse(parsedCamera: any): void;
  95333. }
  95334. }
  95335. declare module BABYLON {
  95336. /**
  95337. * Gather the list of keyboard event types as constants.
  95338. */
  95339. export class KeyboardEventTypes {
  95340. /**
  95341. * The keydown event is fired when a key becomes active (pressed).
  95342. */
  95343. static readonly KEYDOWN: number;
  95344. /**
  95345. * The keyup event is fired when a key has been released.
  95346. */
  95347. static readonly KEYUP: number;
  95348. }
  95349. /**
  95350. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95351. */
  95352. export class KeyboardInfo {
  95353. /**
  95354. * Defines the type of event (KeyboardEventTypes)
  95355. */
  95356. type: number;
  95357. /**
  95358. * Defines the related dom event
  95359. */
  95360. event: KeyboardEvent;
  95361. /**
  95362. * Instantiates a new keyboard info.
  95363. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95364. * @param type Defines the type of event (KeyboardEventTypes)
  95365. * @param event Defines the related dom event
  95366. */
  95367. constructor(
  95368. /**
  95369. * Defines the type of event (KeyboardEventTypes)
  95370. */
  95371. type: number,
  95372. /**
  95373. * Defines the related dom event
  95374. */
  95375. event: KeyboardEvent);
  95376. }
  95377. /**
  95378. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95379. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95380. */
  95381. export class KeyboardInfoPre extends KeyboardInfo {
  95382. /**
  95383. * Defines the type of event (KeyboardEventTypes)
  95384. */
  95385. type: number;
  95386. /**
  95387. * Defines the related dom event
  95388. */
  95389. event: KeyboardEvent;
  95390. /**
  95391. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95392. */
  95393. skipOnPointerObservable: boolean;
  95394. /**
  95395. * Instantiates a new keyboard pre info.
  95396. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95397. * @param type Defines the type of event (KeyboardEventTypes)
  95398. * @param event Defines the related dom event
  95399. */
  95400. constructor(
  95401. /**
  95402. * Defines the type of event (KeyboardEventTypes)
  95403. */
  95404. type: number,
  95405. /**
  95406. * Defines the related dom event
  95407. */
  95408. event: KeyboardEvent);
  95409. }
  95410. }
  95411. declare module BABYLON {
  95412. /**
  95413. * Manage the keyboard inputs to control the movement of a free camera.
  95414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  95415. */
  95416. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  95417. /**
  95418. * Defines the camera the input is attached to.
  95419. */
  95420. camera: FreeCamera;
  95421. /**
  95422. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95423. */
  95424. keysUp: number[];
  95425. /**
  95426. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95427. */
  95428. keysUpward: number[];
  95429. /**
  95430. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95431. */
  95432. keysDown: number[];
  95433. /**
  95434. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95435. */
  95436. keysDownward: number[];
  95437. /**
  95438. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95439. */
  95440. keysLeft: number[];
  95441. /**
  95442. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95443. */
  95444. keysRight: number[];
  95445. private _keys;
  95446. private _onCanvasBlurObserver;
  95447. private _onKeyboardObserver;
  95448. private _engine;
  95449. private _scene;
  95450. /**
  95451. * Attach the input controls to a specific dom element to get the input from.
  95452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95453. */
  95454. attachControl(noPreventDefault?: boolean): void;
  95455. /**
  95456. * Detach the current controls from the specified dom element.
  95457. */
  95458. detachControl(): void;
  95459. /**
  95460. * Update the current camera state depending on the inputs that have been used this frame.
  95461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95462. */
  95463. checkInputs(): void;
  95464. /**
  95465. * Gets the class name of the current input.
  95466. * @returns the class name
  95467. */
  95468. getClassName(): string;
  95469. /** @hidden */
  95470. _onLostFocus(): void;
  95471. /**
  95472. * Get the friendly name associated with the input class.
  95473. * @returns the input friendly name
  95474. */
  95475. getSimpleName(): string;
  95476. }
  95477. }
  95478. declare module BABYLON {
  95479. /**
  95480. * Interface used to define Action
  95481. */
  95482. export interface IAction {
  95483. /**
  95484. * Trigger for the action
  95485. */
  95486. trigger: number;
  95487. /** Options of the trigger */
  95488. triggerOptions: any;
  95489. /**
  95490. * Gets the trigger parameters
  95491. * @returns the trigger parameters
  95492. */
  95493. getTriggerParameter(): any;
  95494. /**
  95495. * Internal only - executes current action event
  95496. * @hidden
  95497. */
  95498. _executeCurrent(evt?: ActionEvent): void;
  95499. /**
  95500. * Serialize placeholder for child classes
  95501. * @param parent of child
  95502. * @returns the serialized object
  95503. */
  95504. serialize(parent: any): any;
  95505. /**
  95506. * Internal only
  95507. * @hidden
  95508. */
  95509. _prepare(): void;
  95510. /**
  95511. * Internal only - manager for action
  95512. * @hidden
  95513. */
  95514. _actionManager: Nullable<AbstractActionManager>;
  95515. /**
  95516. * Adds action to chain of actions, may be a DoNothingAction
  95517. * @param action defines the next action to execute
  95518. * @returns The action passed in
  95519. * @see https://www.babylonjs-playground.com/#1T30HR#0
  95520. */
  95521. then(action: IAction): IAction;
  95522. }
  95523. /**
  95524. * The action to be carried out following a trigger
  95525. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  95526. */
  95527. export class Action implements IAction {
  95528. /** the trigger, with or without parameters, for the action */
  95529. triggerOptions: any;
  95530. /**
  95531. * Trigger for the action
  95532. */
  95533. trigger: number;
  95534. /**
  95535. * Internal only - manager for action
  95536. * @hidden
  95537. */
  95538. _actionManager: ActionManager;
  95539. private _nextActiveAction;
  95540. private _child;
  95541. private _condition?;
  95542. private _triggerParameter;
  95543. /**
  95544. * An event triggered prior to action being executed.
  95545. */
  95546. onBeforeExecuteObservable: Observable<Action>;
  95547. /**
  95548. * Creates a new Action
  95549. * @param triggerOptions the trigger, with or without parameters, for the action
  95550. * @param condition an optional determinant of action
  95551. */
  95552. constructor(
  95553. /** the trigger, with or without parameters, for the action */
  95554. triggerOptions: any, condition?: Condition);
  95555. /**
  95556. * Internal only
  95557. * @hidden
  95558. */
  95559. _prepare(): void;
  95560. /**
  95561. * Gets the trigger parameter
  95562. * @returns the trigger parameter
  95563. */
  95564. getTriggerParameter(): any;
  95565. /**
  95566. * Sets the trigger parameter
  95567. * @param value defines the new trigger parameter
  95568. */
  95569. setTriggerParameter(value: any): void;
  95570. /**
  95571. * Internal only - executes current action event
  95572. * @hidden
  95573. */
  95574. _executeCurrent(evt?: ActionEvent): void;
  95575. /**
  95576. * Execute placeholder for child classes
  95577. * @param evt optional action event
  95578. */
  95579. execute(evt?: ActionEvent): void;
  95580. /**
  95581. * Skips to next active action
  95582. */
  95583. skipToNextActiveAction(): void;
  95584. /**
  95585. * Adds action to chain of actions, may be a DoNothingAction
  95586. * @param action defines the next action to execute
  95587. * @returns The action passed in
  95588. * @see https://www.babylonjs-playground.com/#1T30HR#0
  95589. */
  95590. then(action: Action): Action;
  95591. /**
  95592. * Internal only
  95593. * @hidden
  95594. */
  95595. _getProperty(propertyPath: string): string;
  95596. /**
  95597. * Internal only
  95598. * @hidden
  95599. */
  95600. _getEffectiveTarget(target: any, propertyPath: string): any;
  95601. /**
  95602. * Serialize placeholder for child classes
  95603. * @param parent of child
  95604. * @returns the serialized object
  95605. */
  95606. serialize(parent: any): any;
  95607. /**
  95608. * Internal only called by serialize
  95609. * @hidden
  95610. */
  95611. protected _serialize(serializedAction: any, parent?: any): any;
  95612. /**
  95613. * Internal only
  95614. * @hidden
  95615. */
  95616. static _SerializeValueAsString: (value: any) => string;
  95617. /**
  95618. * Internal only
  95619. * @hidden
  95620. */
  95621. static _GetTargetProperty: (target: Scene | Node) => {
  95622. name: string;
  95623. targetType: string;
  95624. value: string;
  95625. };
  95626. }
  95627. }
  95628. declare module BABYLON {
  95629. /**
  95630. * A Condition applied to an Action
  95631. */
  95632. export class Condition {
  95633. /**
  95634. * Internal only - manager for action
  95635. * @hidden
  95636. */
  95637. _actionManager: ActionManager;
  95638. /**
  95639. * Internal only
  95640. * @hidden
  95641. */
  95642. _evaluationId: number;
  95643. /**
  95644. * Internal only
  95645. * @hidden
  95646. */
  95647. _currentResult: boolean;
  95648. /**
  95649. * Creates a new Condition
  95650. * @param actionManager the manager of the action the condition is applied to
  95651. */
  95652. constructor(actionManager: ActionManager);
  95653. /**
  95654. * Check if the current condition is valid
  95655. * @returns a boolean
  95656. */
  95657. isValid(): boolean;
  95658. /**
  95659. * Internal only
  95660. * @hidden
  95661. */
  95662. _getProperty(propertyPath: string): string;
  95663. /**
  95664. * Internal only
  95665. * @hidden
  95666. */
  95667. _getEffectiveTarget(target: any, propertyPath: string): any;
  95668. /**
  95669. * Serialize placeholder for child classes
  95670. * @returns the serialized object
  95671. */
  95672. serialize(): any;
  95673. /**
  95674. * Internal only
  95675. * @hidden
  95676. */
  95677. protected _serialize(serializedCondition: any): any;
  95678. }
  95679. /**
  95680. * Defines specific conditional operators as extensions of Condition
  95681. */
  95682. export class ValueCondition extends Condition {
  95683. /** path to specify the property of the target the conditional operator uses */
  95684. propertyPath: string;
  95685. /** the value compared by the conditional operator against the current value of the property */
  95686. value: any;
  95687. /** the conditional operator, default ValueCondition.IsEqual */
  95688. operator: number;
  95689. /**
  95690. * Internal only
  95691. * @hidden
  95692. */
  95693. private static _IsEqual;
  95694. /**
  95695. * Internal only
  95696. * @hidden
  95697. */
  95698. private static _IsDifferent;
  95699. /**
  95700. * Internal only
  95701. * @hidden
  95702. */
  95703. private static _IsGreater;
  95704. /**
  95705. * Internal only
  95706. * @hidden
  95707. */
  95708. private static _IsLesser;
  95709. /**
  95710. * returns the number for IsEqual
  95711. */
  95712. static get IsEqual(): number;
  95713. /**
  95714. * Returns the number for IsDifferent
  95715. */
  95716. static get IsDifferent(): number;
  95717. /**
  95718. * Returns the number for IsGreater
  95719. */
  95720. static get IsGreater(): number;
  95721. /**
  95722. * Returns the number for IsLesser
  95723. */
  95724. static get IsLesser(): number;
  95725. /**
  95726. * Internal only The action manager for the condition
  95727. * @hidden
  95728. */
  95729. _actionManager: ActionManager;
  95730. /**
  95731. * Internal only
  95732. * @hidden
  95733. */
  95734. private _target;
  95735. /**
  95736. * Internal only
  95737. * @hidden
  95738. */
  95739. private _effectiveTarget;
  95740. /**
  95741. * Internal only
  95742. * @hidden
  95743. */
  95744. private _property;
  95745. /**
  95746. * Creates a new ValueCondition
  95747. * @param actionManager manager for the action the condition applies to
  95748. * @param target for the action
  95749. * @param propertyPath path to specify the property of the target the conditional operator uses
  95750. * @param value the value compared by the conditional operator against the current value of the property
  95751. * @param operator the conditional operator, default ValueCondition.IsEqual
  95752. */
  95753. constructor(actionManager: ActionManager, target: any,
  95754. /** path to specify the property of the target the conditional operator uses */
  95755. propertyPath: string,
  95756. /** the value compared by the conditional operator against the current value of the property */
  95757. value: any,
  95758. /** the conditional operator, default ValueCondition.IsEqual */
  95759. operator?: number);
  95760. /**
  95761. * Compares the given value with the property value for the specified conditional operator
  95762. * @returns the result of the comparison
  95763. */
  95764. isValid(): boolean;
  95765. /**
  95766. * Serialize the ValueCondition into a JSON compatible object
  95767. * @returns serialization object
  95768. */
  95769. serialize(): any;
  95770. /**
  95771. * Gets the name of the conditional operator for the ValueCondition
  95772. * @param operator the conditional operator
  95773. * @returns the name
  95774. */
  95775. static GetOperatorName(operator: number): string;
  95776. }
  95777. /**
  95778. * Defines a predicate condition as an extension of Condition
  95779. */
  95780. export class PredicateCondition extends Condition {
  95781. /** defines the predicate function used to validate the condition */
  95782. predicate: () => boolean;
  95783. /**
  95784. * Internal only - manager for action
  95785. * @hidden
  95786. */
  95787. _actionManager: ActionManager;
  95788. /**
  95789. * Creates a new PredicateCondition
  95790. * @param actionManager manager for the action the condition applies to
  95791. * @param predicate defines the predicate function used to validate the condition
  95792. */
  95793. constructor(actionManager: ActionManager,
  95794. /** defines the predicate function used to validate the condition */
  95795. predicate: () => boolean);
  95796. /**
  95797. * @returns the validity of the predicate condition
  95798. */
  95799. isValid(): boolean;
  95800. }
  95801. /**
  95802. * Defines a state condition as an extension of Condition
  95803. */
  95804. export class StateCondition extends Condition {
  95805. /** Value to compare with target state */
  95806. value: string;
  95807. /**
  95808. * Internal only - manager for action
  95809. * @hidden
  95810. */
  95811. _actionManager: ActionManager;
  95812. /**
  95813. * Internal only
  95814. * @hidden
  95815. */
  95816. private _target;
  95817. /**
  95818. * Creates a new StateCondition
  95819. * @param actionManager manager for the action the condition applies to
  95820. * @param target of the condition
  95821. * @param value to compare with target state
  95822. */
  95823. constructor(actionManager: ActionManager, target: any,
  95824. /** Value to compare with target state */
  95825. value: string);
  95826. /**
  95827. * Gets a boolean indicating if the current condition is met
  95828. * @returns the validity of the state
  95829. */
  95830. isValid(): boolean;
  95831. /**
  95832. * Serialize the StateCondition into a JSON compatible object
  95833. * @returns serialization object
  95834. */
  95835. serialize(): any;
  95836. }
  95837. }
  95838. declare module BABYLON {
  95839. /**
  95840. * This defines an action responsible to toggle a boolean once triggered.
  95841. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95842. */
  95843. export class SwitchBooleanAction extends Action {
  95844. /**
  95845. * The path to the boolean property in the target object
  95846. */
  95847. propertyPath: string;
  95848. private _target;
  95849. private _effectiveTarget;
  95850. private _property;
  95851. /**
  95852. * Instantiate the action
  95853. * @param triggerOptions defines the trigger options
  95854. * @param target defines the object containing the boolean
  95855. * @param propertyPath defines the path to the boolean property in the target object
  95856. * @param condition defines the trigger related conditions
  95857. */
  95858. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  95859. /** @hidden */
  95860. _prepare(): void;
  95861. /**
  95862. * Execute the action toggle the boolean value.
  95863. */
  95864. execute(): void;
  95865. /**
  95866. * Serializes the actions and its related information.
  95867. * @param parent defines the object to serialize in
  95868. * @returns the serialized object
  95869. */
  95870. serialize(parent: any): any;
  95871. }
  95872. /**
  95873. * This defines an action responsible to set a the state field of the target
  95874. * to a desired value once triggered.
  95875. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95876. */
  95877. export class SetStateAction extends Action {
  95878. /**
  95879. * The value to store in the state field.
  95880. */
  95881. value: string;
  95882. private _target;
  95883. /**
  95884. * Instantiate the action
  95885. * @param triggerOptions defines the trigger options
  95886. * @param target defines the object containing the state property
  95887. * @param value defines the value to store in the state field
  95888. * @param condition defines the trigger related conditions
  95889. */
  95890. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  95891. /**
  95892. * Execute the action and store the value on the target state property.
  95893. */
  95894. execute(): void;
  95895. /**
  95896. * Serializes the actions and its related information.
  95897. * @param parent defines the object to serialize in
  95898. * @returns the serialized object
  95899. */
  95900. serialize(parent: any): any;
  95901. }
  95902. /**
  95903. * This defines an action responsible to set a property of the target
  95904. * to a desired value once triggered.
  95905. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95906. */
  95907. export class SetValueAction extends Action {
  95908. /**
  95909. * The path of the property to set in the target.
  95910. */
  95911. propertyPath: string;
  95912. /**
  95913. * The value to set in the property
  95914. */
  95915. value: any;
  95916. private _target;
  95917. private _effectiveTarget;
  95918. private _property;
  95919. /**
  95920. * Instantiate the action
  95921. * @param triggerOptions defines the trigger options
  95922. * @param target defines the object containing the property
  95923. * @param propertyPath defines the path of the property to set in the target
  95924. * @param value defines the value to set in the property
  95925. * @param condition defines the trigger related conditions
  95926. */
  95927. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  95928. /** @hidden */
  95929. _prepare(): void;
  95930. /**
  95931. * Execute the action and set the targeted property to the desired value.
  95932. */
  95933. execute(): void;
  95934. /**
  95935. * Serializes the actions and its related information.
  95936. * @param parent defines the object to serialize in
  95937. * @returns the serialized object
  95938. */
  95939. serialize(parent: any): any;
  95940. }
  95941. /**
  95942. * This defines an action responsible to increment the target value
  95943. * to a desired value once triggered.
  95944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95945. */
  95946. export class IncrementValueAction extends Action {
  95947. /**
  95948. * The path of the property to increment in the target.
  95949. */
  95950. propertyPath: string;
  95951. /**
  95952. * The value we should increment the property by.
  95953. */
  95954. value: any;
  95955. private _target;
  95956. private _effectiveTarget;
  95957. private _property;
  95958. /**
  95959. * Instantiate the action
  95960. * @param triggerOptions defines the trigger options
  95961. * @param target defines the object containing the property
  95962. * @param propertyPath defines the path of the property to increment in the target
  95963. * @param value defines the value value we should increment the property by
  95964. * @param condition defines the trigger related conditions
  95965. */
  95966. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  95967. /** @hidden */
  95968. _prepare(): void;
  95969. /**
  95970. * Execute the action and increment the target of the value amount.
  95971. */
  95972. execute(): void;
  95973. /**
  95974. * Serializes the actions and its related information.
  95975. * @param parent defines the object to serialize in
  95976. * @returns the serialized object
  95977. */
  95978. serialize(parent: any): any;
  95979. }
  95980. /**
  95981. * This defines an action responsible to start an animation once triggered.
  95982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95983. */
  95984. export class PlayAnimationAction extends Action {
  95985. /**
  95986. * Where the animation should start (animation frame)
  95987. */
  95988. from: number;
  95989. /**
  95990. * Where the animation should stop (animation frame)
  95991. */
  95992. to: number;
  95993. /**
  95994. * Define if the animation should loop or stop after the first play.
  95995. */
  95996. loop?: boolean;
  95997. private _target;
  95998. /**
  95999. * Instantiate the action
  96000. * @param triggerOptions defines the trigger options
  96001. * @param target defines the target animation or animation name
  96002. * @param from defines from where the animation should start (animation frame)
  96003. * @param to defines where the animation should stop (animation frame)
  96004. * @param loop defines if the animation should loop or stop after the first play
  96005. * @param condition defines the trigger related conditions
  96006. */
  96007. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  96008. /** @hidden */
  96009. _prepare(): void;
  96010. /**
  96011. * Execute the action and play the animation.
  96012. */
  96013. execute(): void;
  96014. /**
  96015. * Serializes the actions and its related information.
  96016. * @param parent defines the object to serialize in
  96017. * @returns the serialized object
  96018. */
  96019. serialize(parent: any): any;
  96020. }
  96021. /**
  96022. * This defines an action responsible to stop an animation once triggered.
  96023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  96024. */
  96025. export class StopAnimationAction extends Action {
  96026. private _target;
  96027. /**
  96028. * Instantiate the action
  96029. * @param triggerOptions defines the trigger options
  96030. * @param target defines the target animation or animation name
  96031. * @param condition defines the trigger related conditions
  96032. */
  96033. constructor(triggerOptions: any, target: any, condition?: Condition);
  96034. /** @hidden */
  96035. _prepare(): void;
  96036. /**
  96037. * Execute the action and stop the animation.
  96038. */
  96039. execute(): void;
  96040. /**
  96041. * Serializes the actions and its related information.
  96042. * @param parent defines the object to serialize in
  96043. * @returns the serialized object
  96044. */
  96045. serialize(parent: any): any;
  96046. }
  96047. /**
  96048. * This defines an action responsible that does nothing once triggered.
  96049. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  96050. */
  96051. export class DoNothingAction extends Action {
  96052. /**
  96053. * Instantiate the action
  96054. * @param triggerOptions defines the trigger options
  96055. * @param condition defines the trigger related conditions
  96056. */
  96057. constructor(triggerOptions?: any, condition?: Condition);
  96058. /**
  96059. * Execute the action and do nothing.
  96060. */
  96061. execute(): void;
  96062. /**
  96063. * Serializes the actions and its related information.
  96064. * @param parent defines the object to serialize in
  96065. * @returns the serialized object
  96066. */
  96067. serialize(parent: any): any;
  96068. }
  96069. /**
  96070. * This defines an action responsible to trigger several actions once triggered.
  96071. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  96072. */
  96073. export class CombineAction extends Action {
  96074. /**
  96075. * The list of aggregated animations to run.
  96076. */
  96077. children: Action[];
  96078. /**
  96079. * Instantiate the action
  96080. * @param triggerOptions defines the trigger options
  96081. * @param children defines the list of aggregated animations to run
  96082. * @param condition defines the trigger related conditions
  96083. */
  96084. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  96085. /** @hidden */
  96086. _prepare(): void;
  96087. /**
  96088. * Execute the action and executes all the aggregated actions.
  96089. */
  96090. execute(evt: ActionEvent): void;
  96091. /**
  96092. * Serializes the actions and its related information.
  96093. * @param parent defines the object to serialize in
  96094. * @returns the serialized object
  96095. */
  96096. serialize(parent: any): any;
  96097. }
  96098. /**
  96099. * This defines an action responsible to run code (external event) once triggered.
  96100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  96101. */
  96102. export class ExecuteCodeAction extends Action {
  96103. /**
  96104. * The callback function to run.
  96105. */
  96106. func: (evt: ActionEvent) => void;
  96107. /**
  96108. * Instantiate the action
  96109. * @param triggerOptions defines the trigger options
  96110. * @param func defines the callback function to run
  96111. * @param condition defines the trigger related conditions
  96112. */
  96113. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  96114. /**
  96115. * Execute the action and run the attached code.
  96116. */
  96117. execute(evt: ActionEvent): void;
  96118. }
  96119. /**
  96120. * This defines an action responsible to set the parent property of the target once triggered.
  96121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  96122. */
  96123. export class SetParentAction extends Action {
  96124. private _parent;
  96125. private _target;
  96126. /**
  96127. * Instantiate the action
  96128. * @param triggerOptions defines the trigger options
  96129. * @param target defines the target containing the parent property
  96130. * @param parent defines from where the animation should start (animation frame)
  96131. * @param condition defines the trigger related conditions
  96132. */
  96133. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  96134. /** @hidden */
  96135. _prepare(): void;
  96136. /**
  96137. * Execute the action and set the parent property.
  96138. */
  96139. execute(): void;
  96140. /**
  96141. * Serializes the actions and its related information.
  96142. * @param parent defines the object to serialize in
  96143. * @returns the serialized object
  96144. */
  96145. serialize(parent: any): any;
  96146. }
  96147. }
  96148. declare module BABYLON {
  96149. /**
  96150. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  96151. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  96152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  96153. */
  96154. export class ActionManager extends AbstractActionManager {
  96155. /**
  96156. * Nothing
  96157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96158. */
  96159. static readonly NothingTrigger: number;
  96160. /**
  96161. * On pick
  96162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96163. */
  96164. static readonly OnPickTrigger: number;
  96165. /**
  96166. * On left pick
  96167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96168. */
  96169. static readonly OnLeftPickTrigger: number;
  96170. /**
  96171. * On right pick
  96172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96173. */
  96174. static readonly OnRightPickTrigger: number;
  96175. /**
  96176. * On center pick
  96177. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96178. */
  96179. static readonly OnCenterPickTrigger: number;
  96180. /**
  96181. * On pick down
  96182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96183. */
  96184. static readonly OnPickDownTrigger: number;
  96185. /**
  96186. * On double pick
  96187. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96188. */
  96189. static readonly OnDoublePickTrigger: number;
  96190. /**
  96191. * On pick up
  96192. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96193. */
  96194. static readonly OnPickUpTrigger: number;
  96195. /**
  96196. * On pick out.
  96197. * This trigger will only be raised if you also declared a OnPickDown
  96198. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96199. */
  96200. static readonly OnPickOutTrigger: number;
  96201. /**
  96202. * On long press
  96203. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96204. */
  96205. static readonly OnLongPressTrigger: number;
  96206. /**
  96207. * On pointer over
  96208. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96209. */
  96210. static readonly OnPointerOverTrigger: number;
  96211. /**
  96212. * On pointer out
  96213. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96214. */
  96215. static readonly OnPointerOutTrigger: number;
  96216. /**
  96217. * On every frame
  96218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96219. */
  96220. static readonly OnEveryFrameTrigger: number;
  96221. /**
  96222. * On intersection enter
  96223. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96224. */
  96225. static readonly OnIntersectionEnterTrigger: number;
  96226. /**
  96227. * On intersection exit
  96228. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96229. */
  96230. static readonly OnIntersectionExitTrigger: number;
  96231. /**
  96232. * On key down
  96233. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96234. */
  96235. static readonly OnKeyDownTrigger: number;
  96236. /**
  96237. * On key up
  96238. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  96239. */
  96240. static readonly OnKeyUpTrigger: number;
  96241. private _scene;
  96242. /**
  96243. * Creates a new action manager
  96244. * @param scene defines the hosting scene
  96245. */
  96246. constructor(scene: Scene);
  96247. /**
  96248. * Releases all associated resources
  96249. */
  96250. dispose(): void;
  96251. /**
  96252. * Gets hosting scene
  96253. * @returns the hosting scene
  96254. */
  96255. getScene(): Scene;
  96256. /**
  96257. * Does this action manager handles actions of any of the given triggers
  96258. * @param triggers defines the triggers to be tested
  96259. * @return a boolean indicating whether one (or more) of the triggers is handled
  96260. */
  96261. hasSpecificTriggers(triggers: number[]): boolean;
  96262. /**
  96263. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  96264. * speed.
  96265. * @param triggerA defines the trigger to be tested
  96266. * @param triggerB defines the trigger to be tested
  96267. * @return a boolean indicating whether one (or more) of the triggers is handled
  96268. */
  96269. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  96270. /**
  96271. * Does this action manager handles actions of a given trigger
  96272. * @param trigger defines the trigger to be tested
  96273. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  96274. * @return whether the trigger is handled
  96275. */
  96276. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  96277. /**
  96278. * Does this action manager has pointer triggers
  96279. */
  96280. get hasPointerTriggers(): boolean;
  96281. /**
  96282. * Does this action manager has pick triggers
  96283. */
  96284. get hasPickTriggers(): boolean;
  96285. /**
  96286. * Registers an action to this action manager
  96287. * @param action defines the action to be registered
  96288. * @return the action amended (prepared) after registration
  96289. */
  96290. registerAction(action: IAction): Nullable<IAction>;
  96291. /**
  96292. * Unregisters an action to this action manager
  96293. * @param action defines the action to be unregistered
  96294. * @return a boolean indicating whether the action has been unregistered
  96295. */
  96296. unregisterAction(action: IAction): Boolean;
  96297. /**
  96298. * Process a specific trigger
  96299. * @param trigger defines the trigger to process
  96300. * @param evt defines the event details to be processed
  96301. */
  96302. processTrigger(trigger: number, evt?: IActionEvent): void;
  96303. /** @hidden */
  96304. _getEffectiveTarget(target: any, propertyPath: string): any;
  96305. /** @hidden */
  96306. _getProperty(propertyPath: string): string;
  96307. /**
  96308. * Serialize this manager to a JSON object
  96309. * @param name defines the property name to store this manager
  96310. * @returns a JSON representation of this manager
  96311. */
  96312. serialize(name: string): any;
  96313. /**
  96314. * Creates a new ActionManager from a JSON data
  96315. * @param parsedActions defines the JSON data to read from
  96316. * @param object defines the hosting mesh
  96317. * @param scene defines the hosting scene
  96318. */
  96319. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  96320. /**
  96321. * Get a trigger name by index
  96322. * @param trigger defines the trigger index
  96323. * @returns a trigger name
  96324. */
  96325. static GetTriggerName(trigger: number): string;
  96326. }
  96327. }
  96328. declare module BABYLON {
  96329. /**
  96330. * Class representing a ray with position and direction
  96331. */
  96332. export class Ray {
  96333. /** origin point */
  96334. origin: Vector3;
  96335. /** direction */
  96336. direction: Vector3;
  96337. /** length of the ray */
  96338. length: number;
  96339. private static readonly _TmpVector3;
  96340. private _tmpRay;
  96341. /**
  96342. * Creates a new ray
  96343. * @param origin origin point
  96344. * @param direction direction
  96345. * @param length length of the ray
  96346. */
  96347. constructor(
  96348. /** origin point */
  96349. origin: Vector3,
  96350. /** direction */
  96351. direction: Vector3,
  96352. /** length of the ray */
  96353. length?: number);
  96354. /**
  96355. * Checks if the ray intersects a box
  96356. * This does not account for the ray length by design to improve perfs.
  96357. * @param minimum bound of the box
  96358. * @param maximum bound of the box
  96359. * @param intersectionTreshold extra extend to be added to the box in all direction
  96360. * @returns if the box was hit
  96361. */
  96362. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  96363. /**
  96364. * Checks if the ray intersects a box
  96365. * This does not account for the ray lenght by design to improve perfs.
  96366. * @param box the bounding box to check
  96367. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  96368. * @returns if the box was hit
  96369. */
  96370. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  96371. /**
  96372. * If the ray hits a sphere
  96373. * @param sphere the bounding sphere to check
  96374. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  96375. * @returns true if it hits the sphere
  96376. */
  96377. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  96378. /**
  96379. * If the ray hits a triange
  96380. * @param vertex0 triangle vertex
  96381. * @param vertex1 triangle vertex
  96382. * @param vertex2 triangle vertex
  96383. * @returns intersection information if hit
  96384. */
  96385. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  96386. /**
  96387. * Checks if ray intersects a plane
  96388. * @param plane the plane to check
  96389. * @returns the distance away it was hit
  96390. */
  96391. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  96392. /**
  96393. * Calculate the intercept of a ray on a given axis
  96394. * @param axis to check 'x' | 'y' | 'z'
  96395. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  96396. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  96397. */
  96398. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  96399. /**
  96400. * Checks if ray intersects a mesh
  96401. * @param mesh the mesh to check
  96402. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96403. * @returns picking info of the intersection
  96404. */
  96405. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  96406. /**
  96407. * Checks if ray intersects a mesh
  96408. * @param meshes the meshes to check
  96409. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96410. * @param results array to store result in
  96411. * @returns Array of picking infos
  96412. */
  96413. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  96414. private _comparePickingInfo;
  96415. private static smallnum;
  96416. private static rayl;
  96417. /**
  96418. * Intersection test between the ray and a given segment within a given tolerance (threshold)
  96419. * @param sega the first point of the segment to test the intersection against
  96420. * @param segb the second point of the segment to test the intersection against
  96421. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  96422. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  96423. */
  96424. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  96425. /**
  96426. * Update the ray from viewport position
  96427. * @param x position
  96428. * @param y y position
  96429. * @param viewportWidth viewport width
  96430. * @param viewportHeight viewport height
  96431. * @param world world matrix
  96432. * @param view view matrix
  96433. * @param projection projection matrix
  96434. * @returns this ray updated
  96435. */
  96436. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  96437. /**
  96438. * Creates a ray with origin and direction of 0,0,0
  96439. * @returns the new ray
  96440. */
  96441. static Zero(): Ray;
  96442. /**
  96443. * Creates a new ray from screen space and viewport
  96444. * @param x position
  96445. * @param y y position
  96446. * @param viewportWidth viewport width
  96447. * @param viewportHeight viewport height
  96448. * @param world world matrix
  96449. * @param view view matrix
  96450. * @param projection projection matrix
  96451. * @returns new ray
  96452. */
  96453. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  96454. /**
  96455. * 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
  96456. * transformed to the given world matrix.
  96457. * @param origin The origin point
  96458. * @param end The end point
  96459. * @param world a matrix to transform the ray to. Default is the identity matrix.
  96460. * @returns the new ray
  96461. */
  96462. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  96463. /**
  96464. * Transforms a ray by a matrix
  96465. * @param ray ray to transform
  96466. * @param matrix matrix to apply
  96467. * @returns the resulting new ray
  96468. */
  96469. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  96470. /**
  96471. * Transforms a ray by a matrix
  96472. * @param ray ray to transform
  96473. * @param matrix matrix to apply
  96474. * @param result ray to store result in
  96475. */
  96476. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  96477. /**
  96478. * Unproject a ray from screen space to object space
  96479. * @param sourceX defines the screen space x coordinate to use
  96480. * @param sourceY defines the screen space y coordinate to use
  96481. * @param viewportWidth defines the current width of the viewport
  96482. * @param viewportHeight defines the current height of the viewport
  96483. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  96484. * @param view defines the view matrix to use
  96485. * @param projection defines the projection matrix to use
  96486. */
  96487. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  96488. }
  96489. /**
  96490. * Type used to define predicate used to select faces when a mesh intersection is detected
  96491. */
  96492. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  96493. interface Scene {
  96494. /** @hidden */
  96495. _tempPickingRay: Nullable<Ray>;
  96496. /** @hidden */
  96497. _cachedRayForTransform: Ray;
  96498. /** @hidden */
  96499. _pickWithRayInverseMatrix: Matrix;
  96500. /** @hidden */
  96501. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96502. /** @hidden */
  96503. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96504. /** @hidden */
  96505. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  96506. }
  96507. }
  96508. declare module BABYLON {
  96509. /**
  96510. * Groups all the scene component constants in one place to ease maintenance.
  96511. * @hidden
  96512. */
  96513. export class SceneComponentConstants {
  96514. static readonly NAME_EFFECTLAYER: string;
  96515. static readonly NAME_LAYER: string;
  96516. static readonly NAME_LENSFLARESYSTEM: string;
  96517. static readonly NAME_BOUNDINGBOXRENDERER: string;
  96518. static readonly NAME_PARTICLESYSTEM: string;
  96519. static readonly NAME_GAMEPAD: string;
  96520. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  96521. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  96522. static readonly NAME_PREPASSRENDERER: string;
  96523. static readonly NAME_DEPTHRENDERER: string;
  96524. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  96525. static readonly NAME_SPRITE: string;
  96526. static readonly NAME_SUBSURFACE: string;
  96527. static readonly NAME_OUTLINERENDERER: string;
  96528. static readonly NAME_PROCEDURALTEXTURE: string;
  96529. static readonly NAME_SHADOWGENERATOR: string;
  96530. static readonly NAME_OCTREE: string;
  96531. static readonly NAME_PHYSICSENGINE: string;
  96532. static readonly NAME_AUDIO: string;
  96533. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  96534. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  96535. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  96536. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  96537. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  96538. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  96539. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  96540. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  96541. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS: number;
  96542. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  96543. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  96544. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  96545. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  96546. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  96547. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  96548. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  96549. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  96550. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  96551. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  96552. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS: number;
  96553. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  96554. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  96555. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  96556. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  96557. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  96558. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  96559. static readonly STEP_AFTERRENDER_AUDIO: number;
  96560. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  96561. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  96562. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  96563. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  96564. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  96565. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  96566. static readonly STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS: number;
  96567. static readonly STEP_POINTERMOVE_SPRITE: number;
  96568. static readonly STEP_POINTERDOWN_SPRITE: number;
  96569. static readonly STEP_POINTERUP_SPRITE: number;
  96570. }
  96571. /**
  96572. * This represents a scene component.
  96573. *
  96574. * This is used to decouple the dependency the scene is having on the different workloads like
  96575. * layers, post processes...
  96576. */
  96577. export interface ISceneComponent {
  96578. /**
  96579. * The name of the component. Each component must have a unique name.
  96580. */
  96581. name: string;
  96582. /**
  96583. * The scene the component belongs to.
  96584. */
  96585. scene: Scene;
  96586. /**
  96587. * Register the component to one instance of a scene.
  96588. */
  96589. register(): void;
  96590. /**
  96591. * Rebuilds the elements related to this component in case of
  96592. * context lost for instance.
  96593. */
  96594. rebuild(): void;
  96595. /**
  96596. * Disposes the component and the associated ressources.
  96597. */
  96598. dispose(): void;
  96599. }
  96600. /**
  96601. * This represents a SERIALIZABLE scene component.
  96602. *
  96603. * This extends Scene Component to add Serialization methods on top.
  96604. */
  96605. export interface ISceneSerializableComponent extends ISceneComponent {
  96606. /**
  96607. * Adds all the elements from the container to the scene
  96608. * @param container the container holding the elements
  96609. */
  96610. addFromContainer(container: AbstractScene): void;
  96611. /**
  96612. * Removes all the elements in the container from the scene
  96613. * @param container contains the elements to remove
  96614. * @param dispose if the removed element should be disposed (default: false)
  96615. */
  96616. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  96617. /**
  96618. * Serializes the component data to the specified json object
  96619. * @param serializationObject The object to serialize to
  96620. */
  96621. serialize(serializationObject: any): void;
  96622. }
  96623. /**
  96624. * Strong typing of a Mesh related stage step action
  96625. */
  96626. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  96627. /**
  96628. * Strong typing of a Evaluate Sub Mesh related stage step action
  96629. */
  96630. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  96631. /**
  96632. * Strong typing of a pre active Mesh related stage step action
  96633. */
  96634. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  96635. /**
  96636. * Strong typing of a Camera related stage step action
  96637. */
  96638. export type CameraStageAction = (camera: Camera) => void;
  96639. /**
  96640. * Strong typing of a Camera Frame buffer related stage step action
  96641. */
  96642. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  96643. /**
  96644. * Strong typing of a Render Target related stage step action
  96645. */
  96646. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  96647. /**
  96648. * Strong typing of a RenderingGroup related stage step action
  96649. */
  96650. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  96651. /**
  96652. * Strong typing of a Mesh Render related stage step action
  96653. */
  96654. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  96655. /**
  96656. * Strong typing of a simple stage step action
  96657. */
  96658. export type SimpleStageAction = () => void;
  96659. /**
  96660. * Strong typing of a render target action.
  96661. */
  96662. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  96663. /**
  96664. * Strong typing of a pointer move action.
  96665. */
  96666. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  96667. /**
  96668. * Strong typing of a pointer up/down action.
  96669. */
  96670. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  96671. /**
  96672. * Representation of a stage in the scene (Basically a list of ordered steps)
  96673. * @hidden
  96674. */
  96675. export class Stage<T extends Function> extends Array<{
  96676. index: number;
  96677. component: ISceneComponent;
  96678. action: T;
  96679. }> {
  96680. /**
  96681. * Hide ctor from the rest of the world.
  96682. * @param items The items to add.
  96683. */
  96684. private constructor();
  96685. /**
  96686. * Creates a new Stage.
  96687. * @returns A new instance of a Stage
  96688. */
  96689. static Create<T extends Function>(): Stage<T>;
  96690. /**
  96691. * Registers a step in an ordered way in the targeted stage.
  96692. * @param index Defines the position to register the step in
  96693. * @param component Defines the component attached to the step
  96694. * @param action Defines the action to launch during the step
  96695. */
  96696. registerStep(index: number, component: ISceneComponent, action: T): void;
  96697. /**
  96698. * Clears all the steps from the stage.
  96699. */
  96700. clear(): void;
  96701. }
  96702. }
  96703. declare module BABYLON {
  96704. interface Scene {
  96705. /** @hidden */
  96706. _pointerOverSprite: Nullable<Sprite>;
  96707. /** @hidden */
  96708. _pickedDownSprite: Nullable<Sprite>;
  96709. /** @hidden */
  96710. _tempSpritePickingRay: Nullable<Ray>;
  96711. /**
  96712. * All of the sprite managers added to this scene
  96713. * @see https://doc.babylonjs.com/babylon101/sprites
  96714. */
  96715. spriteManagers: Array<ISpriteManager>;
  96716. /**
  96717. * An event triggered when sprites rendering is about to start
  96718. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  96719. */
  96720. onBeforeSpritesRenderingObservable: Observable<Scene>;
  96721. /**
  96722. * An event triggered when sprites rendering is done
  96723. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  96724. */
  96725. onAfterSpritesRenderingObservable: Observable<Scene>;
  96726. /** @hidden */
  96727. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96728. /** Launch a ray to try to pick a sprite in the scene
  96729. * @param x position on screen
  96730. * @param y position on screen
  96731. * @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
  96732. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96733. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96734. * @returns a PickingInfo
  96735. */
  96736. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96737. /** Use the given ray to pick a sprite in the scene
  96738. * @param ray The ray (in world space) to use to pick meshes
  96739. * @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
  96740. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96741. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  96742. * @returns a PickingInfo
  96743. */
  96744. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  96745. /** @hidden */
  96746. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96747. /** Launch a ray to try to pick sprites in the scene
  96748. * @param x position on screen
  96749. * @param y position on screen
  96750. * @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
  96751. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96752. * @returns a PickingInfo array
  96753. */
  96754. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96755. /** Use the given ray to pick sprites in the scene
  96756. * @param ray The ray (in world space) to use to pick meshes
  96757. * @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
  96758. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  96759. * @returns a PickingInfo array
  96760. */
  96761. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  96762. /**
  96763. * Force the sprite under the pointer
  96764. * @param sprite defines the sprite to use
  96765. */
  96766. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  96767. /**
  96768. * Gets the sprite under the pointer
  96769. * @returns a Sprite or null if no sprite is under the pointer
  96770. */
  96771. getPointerOverSprite(): Nullable<Sprite>;
  96772. }
  96773. /**
  96774. * Defines the sprite scene component responsible to manage sprites
  96775. * in a given scene.
  96776. */
  96777. export class SpriteSceneComponent implements ISceneComponent {
  96778. /**
  96779. * The component name helpfull to identify the component in the list of scene components.
  96780. */
  96781. readonly name: string;
  96782. /**
  96783. * The scene the component belongs to.
  96784. */
  96785. scene: Scene;
  96786. /** @hidden */
  96787. private _spritePredicate;
  96788. /**
  96789. * Creates a new instance of the component for the given scene
  96790. * @param scene Defines the scene to register the component in
  96791. */
  96792. constructor(scene: Scene);
  96793. /**
  96794. * Registers the component in a given scene
  96795. */
  96796. register(): void;
  96797. /**
  96798. * Rebuilds the elements related to this component in case of
  96799. * context lost for instance.
  96800. */
  96801. rebuild(): void;
  96802. /**
  96803. * Disposes the component and the associated resources.
  96804. */
  96805. dispose(): void;
  96806. private _pickSpriteButKeepRay;
  96807. private _pointerMove;
  96808. private _pointerDown;
  96809. private _pointerUp;
  96810. }
  96811. }
  96812. declare module BABYLON {
  96813. /**
  96814. * Class used to provide helper for timing
  96815. */
  96816. export class TimingTools {
  96817. /**
  96818. * Polyfill for setImmediate
  96819. * @param action defines the action to execute after the current execution block
  96820. */
  96821. static SetImmediate(action: () => void): void;
  96822. }
  96823. }
  96824. declare module BABYLON {
  96825. /**
  96826. * Class used to enable instantiation of objects by class name
  96827. */
  96828. export class InstantiationTools {
  96829. /**
  96830. * Use this object to register external classes like custom textures or material
  96831. * to allow the loaders to instantiate them
  96832. */
  96833. static RegisteredExternalClasses: {
  96834. [key: string]: Object;
  96835. };
  96836. /**
  96837. * Tries to instantiate a new object from a given class name
  96838. * @param className defines the class name to instantiate
  96839. * @returns the new object or null if the system was not able to do the instantiation
  96840. */
  96841. static Instantiate(className: string): any;
  96842. }
  96843. }
  96844. declare module BABYLON {
  96845. /**
  96846. * Class used to host copy specific utilities
  96847. */
  96848. export class CopyTools {
  96849. /**
  96850. * Transform some pixel data to a base64 string
  96851. * @param pixels defines the pixel data to transform to base64
  96852. * @param size defines the width and height of the (texture) data
  96853. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  96854. * @returns The base64 encoded string or null
  96855. */
  96856. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  96857. /**
  96858. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  96859. * @param texture defines the texture to read pixels from
  96860. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96861. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96862. * @returns The base64 encoded string or null
  96863. */
  96864. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  96865. /**
  96866. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  96867. * @param texture defines the texture to read pixels from
  96868. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96869. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96870. * @returns The base64 encoded string or null wrapped in a promise
  96871. */
  96872. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  96873. }
  96874. }
  96875. declare module BABYLON {
  96876. /**
  96877. * Define options used to create a depth texture
  96878. */
  96879. export class DepthTextureCreationOptions {
  96880. /** Specifies whether or not a stencil should be allocated in the texture */
  96881. generateStencil?: boolean;
  96882. /** Specifies whether or not bilinear filtering is enable on the texture */
  96883. bilinearFiltering?: boolean;
  96884. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  96885. comparisonFunction?: number;
  96886. /** Specifies if the created texture is a cube texture */
  96887. isCube?: boolean;
  96888. /** Specifies the sample count of the depth/stencil texture texture */
  96889. samples?: number;
  96890. }
  96891. }
  96892. declare module BABYLON {
  96893. interface ThinEngine {
  96894. /**
  96895. * Creates a depth stencil cube texture.
  96896. * This is only available in WebGL 2.
  96897. * @param size The size of face edge in the cube texture.
  96898. * @param options The options defining the cube texture.
  96899. * @returns The cube texture
  96900. */
  96901. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  96902. /**
  96903. * Creates a cube texture
  96904. * @param rootUrl defines the url where the files to load is located
  96905. * @param scene defines the current scene
  96906. * @param files defines the list of files to load (1 per face)
  96907. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96908. * @param onLoad defines an optional callback raised when the texture is loaded
  96909. * @param onError defines an optional callback raised if there is an issue to load the texture
  96910. * @param format defines the format of the data
  96911. * @param forcedExtension defines the extension to use to pick the right loader
  96912. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  96913. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96914. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96915. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  96916. * @param loaderOptions options to be passed to the loader
  96917. * @returns the cube texture as an InternalTexture
  96918. */
  96919. 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;
  96920. /**
  96921. * Creates a cube texture
  96922. * @param rootUrl defines the url where the files to load is located
  96923. * @param scene defines the current scene
  96924. * @param files defines the list of files to load (1 per face)
  96925. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96926. * @param onLoad defines an optional callback raised when the texture is loaded
  96927. * @param onError defines an optional callback raised if there is an issue to load the texture
  96928. * @param format defines the format of the data
  96929. * @param forcedExtension defines the extension to use to pick the right loader
  96930. * @returns the cube texture as an InternalTexture
  96931. */
  96932. 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;
  96933. /**
  96934. * Creates a cube texture
  96935. * @param rootUrl defines the url where the files to load is located
  96936. * @param scene defines the current scene
  96937. * @param files defines the list of files to load (1 per face)
  96938. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  96939. * @param onLoad defines an optional callback raised when the texture is loaded
  96940. * @param onError defines an optional callback raised if there is an issue to load the texture
  96941. * @param format defines the format of the data
  96942. * @param forcedExtension defines the extension to use to pick the right loader
  96943. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  96944. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96945. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96946. * @returns the cube texture as an InternalTexture
  96947. */
  96948. 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;
  96949. /** @hidden */
  96950. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  96951. /** @hidden */
  96952. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  96953. /** @hidden */
  96954. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  96955. /** @hidden */
  96956. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  96957. /** @hidden */
  96958. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  96959. /**
  96960. * @hidden
  96961. */
  96962. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  96963. }
  96964. }
  96965. declare module BABYLON {
  96966. /**
  96967. * Class for creating a cube texture
  96968. */
  96969. export class CubeTexture extends BaseTexture {
  96970. private _delayedOnLoad;
  96971. /**
  96972. * Observable triggered once the texture has been loaded.
  96973. */
  96974. onLoadObservable: Observable<CubeTexture>;
  96975. /**
  96976. * The url of the texture
  96977. */
  96978. url: string;
  96979. /**
  96980. * Gets or sets the center of the bounding box associated with the cube texture.
  96981. * It must define where the camera used to render the texture was set
  96982. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  96983. */
  96984. boundingBoxPosition: Vector3;
  96985. private _boundingBoxSize;
  96986. /**
  96987. * Gets or sets the size of the bounding box associated with the cube texture
  96988. * When defined, the cubemap will switch to local mode
  96989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96990. * @example https://www.babylonjs-playground.com/#RNASML
  96991. */
  96992. set boundingBoxSize(value: Vector3);
  96993. /**
  96994. * Returns the bounding box size
  96995. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  96996. */
  96997. get boundingBoxSize(): Vector3;
  96998. protected _rotationY: number;
  96999. /**
  97000. * Sets texture matrix rotation angle around Y axis in radians.
  97001. */
  97002. set rotationY(value: number);
  97003. /**
  97004. * Gets texture matrix rotation angle around Y axis radians.
  97005. */
  97006. get rotationY(): number;
  97007. /**
  97008. * Are mip maps generated for this texture or not.
  97009. */
  97010. get noMipmap(): boolean;
  97011. private _noMipmap;
  97012. private _files;
  97013. protected _forcedExtension: Nullable<string>;
  97014. private _extensions;
  97015. private _textureMatrix;
  97016. private _format;
  97017. private _createPolynomials;
  97018. private _loaderOptions;
  97019. /**
  97020. * Creates a cube texture from an array of image urls
  97021. * @param files defines an array of image urls
  97022. * @param scene defines the hosting scene
  97023. * @param noMipmap specifies if mip maps are not used
  97024. * @returns a cube texture
  97025. */
  97026. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  97027. /**
  97028. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  97029. * @param url defines the url of the prefiltered texture
  97030. * @param scene defines the scene the texture is attached to
  97031. * @param forcedExtension defines the extension of the file if different from the url
  97032. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  97033. * @return the prefiltered texture
  97034. */
  97035. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  97036. /**
  97037. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  97038. * as prefiltered data.
  97039. * @param rootUrl defines the url of the texture or the root name of the six images
  97040. * @param null defines the scene or engine the texture is attached to
  97041. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  97042. * @param noMipmap defines if mipmaps should be created or not
  97043. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  97044. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  97045. * @param onError defines a callback triggered in case of error during load
  97046. * @param format defines the internal format to use for the texture once loaded
  97047. * @param prefiltered defines whether or not the texture is created from prefiltered data
  97048. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  97049. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  97050. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  97051. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  97052. * @param loaderOptions options to be passed to the loader
  97053. * @return the cube texture
  97054. */
  97055. 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);
  97056. /**
  97057. * Get the current class name of the texture useful for serialization or dynamic coding.
  97058. * @returns "CubeTexture"
  97059. */
  97060. getClassName(): string;
  97061. /**
  97062. * Update the url (and optional buffer) of this texture if url was null during construction.
  97063. * @param url the url of the texture
  97064. * @param forcedExtension defines the extension to use
  97065. * @param onLoad callback called when the texture is loaded (defaults to null)
  97066. * @param prefiltered Defines whether the updated texture is prefiltered or not
  97067. */
  97068. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  97069. /**
  97070. * Delays loading of the cube texture
  97071. * @param forcedExtension defines the extension to use
  97072. */
  97073. delayLoad(forcedExtension?: string): void;
  97074. /**
  97075. * Returns the reflection texture matrix
  97076. * @returns the reflection texture matrix
  97077. */
  97078. getReflectionTextureMatrix(): Matrix;
  97079. /**
  97080. * Sets the reflection texture matrix
  97081. * @param value Reflection texture matrix
  97082. */
  97083. setReflectionTextureMatrix(value: Matrix): void;
  97084. /**
  97085. * Parses text to create a cube texture
  97086. * @param parsedTexture define the serialized text to read from
  97087. * @param scene defines the hosting scene
  97088. * @param rootUrl defines the root url of the cube texture
  97089. * @returns a cube texture
  97090. */
  97091. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  97092. /**
  97093. * Makes a clone, or deep copy, of the cube texture
  97094. * @returns a new cube texture
  97095. */
  97096. clone(): CubeTexture;
  97097. }
  97098. }
  97099. declare module BABYLON {
  97100. /**
  97101. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  97102. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97103. * 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;
  97104. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97105. */
  97106. export class ColorCurves {
  97107. private _dirty;
  97108. private _tempColor;
  97109. private _globalCurve;
  97110. private _highlightsCurve;
  97111. private _midtonesCurve;
  97112. private _shadowsCurve;
  97113. private _positiveCurve;
  97114. private _negativeCurve;
  97115. private _globalHue;
  97116. private _globalDensity;
  97117. private _globalSaturation;
  97118. private _globalExposure;
  97119. /**
  97120. * Gets the global Hue value.
  97121. * 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).
  97122. */
  97123. get globalHue(): number;
  97124. /**
  97125. * Sets the global Hue value.
  97126. * 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).
  97127. */
  97128. set globalHue(value: number);
  97129. /**
  97130. * Gets the global Density value.
  97131. * 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.
  97132. * Values less than zero provide a filter of opposite hue.
  97133. */
  97134. get globalDensity(): number;
  97135. /**
  97136. * Sets the global Density value.
  97137. * 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.
  97138. * Values less than zero provide a filter of opposite hue.
  97139. */
  97140. set globalDensity(value: number);
  97141. /**
  97142. * Gets the global Saturation value.
  97143. * 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.
  97144. */
  97145. get globalSaturation(): number;
  97146. /**
  97147. * Sets the global Saturation value.
  97148. * 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.
  97149. */
  97150. set globalSaturation(value: number);
  97151. /**
  97152. * Gets the global Exposure value.
  97153. * 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.
  97154. */
  97155. get globalExposure(): number;
  97156. /**
  97157. * Sets the global Exposure value.
  97158. * 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.
  97159. */
  97160. set globalExposure(value: number);
  97161. private _highlightsHue;
  97162. private _highlightsDensity;
  97163. private _highlightsSaturation;
  97164. private _highlightsExposure;
  97165. /**
  97166. * Gets the highlights Hue value.
  97167. * 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).
  97168. */
  97169. get highlightsHue(): number;
  97170. /**
  97171. * Sets the highlights Hue value.
  97172. * 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).
  97173. */
  97174. set highlightsHue(value: number);
  97175. /**
  97176. * Gets the highlights Density value.
  97177. * 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.
  97178. * Values less than zero provide a filter of opposite hue.
  97179. */
  97180. get highlightsDensity(): number;
  97181. /**
  97182. * Sets the highlights Density value.
  97183. * 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.
  97184. * Values less than zero provide a filter of opposite hue.
  97185. */
  97186. set highlightsDensity(value: number);
  97187. /**
  97188. * Gets the highlights Saturation value.
  97189. * 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.
  97190. */
  97191. get highlightsSaturation(): number;
  97192. /**
  97193. * Sets the highlights Saturation value.
  97194. * 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.
  97195. */
  97196. set highlightsSaturation(value: number);
  97197. /**
  97198. * Gets the highlights Exposure value.
  97199. * 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.
  97200. */
  97201. get highlightsExposure(): number;
  97202. /**
  97203. * Sets the highlights Exposure value.
  97204. * 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.
  97205. */
  97206. set highlightsExposure(value: number);
  97207. private _midtonesHue;
  97208. private _midtonesDensity;
  97209. private _midtonesSaturation;
  97210. private _midtonesExposure;
  97211. /**
  97212. * Gets the midtones Hue value.
  97213. * 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).
  97214. */
  97215. get midtonesHue(): number;
  97216. /**
  97217. * Sets the midtones Hue value.
  97218. * 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).
  97219. */
  97220. set midtonesHue(value: number);
  97221. /**
  97222. * Gets the midtones Density value.
  97223. * 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.
  97224. * Values less than zero provide a filter of opposite hue.
  97225. */
  97226. get midtonesDensity(): number;
  97227. /**
  97228. * Sets the midtones Density value.
  97229. * 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.
  97230. * Values less than zero provide a filter of opposite hue.
  97231. */
  97232. set midtonesDensity(value: number);
  97233. /**
  97234. * Gets the midtones Saturation value.
  97235. * 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.
  97236. */
  97237. get midtonesSaturation(): number;
  97238. /**
  97239. * Sets the midtones Saturation value.
  97240. * 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.
  97241. */
  97242. set midtonesSaturation(value: number);
  97243. /**
  97244. * Gets the midtones Exposure value.
  97245. * 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.
  97246. */
  97247. get midtonesExposure(): number;
  97248. /**
  97249. * Sets the midtones Exposure value.
  97250. * 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.
  97251. */
  97252. set midtonesExposure(value: number);
  97253. private _shadowsHue;
  97254. private _shadowsDensity;
  97255. private _shadowsSaturation;
  97256. private _shadowsExposure;
  97257. /**
  97258. * Gets the shadows Hue value.
  97259. * 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).
  97260. */
  97261. get shadowsHue(): number;
  97262. /**
  97263. * Sets the shadows Hue value.
  97264. * 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).
  97265. */
  97266. set shadowsHue(value: number);
  97267. /**
  97268. * Gets the shadows Density value.
  97269. * 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.
  97270. * Values less than zero provide a filter of opposite hue.
  97271. */
  97272. get shadowsDensity(): number;
  97273. /**
  97274. * Sets the shadows Density value.
  97275. * 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.
  97276. * Values less than zero provide a filter of opposite hue.
  97277. */
  97278. set shadowsDensity(value: number);
  97279. /**
  97280. * Gets the shadows Saturation value.
  97281. * 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.
  97282. */
  97283. get shadowsSaturation(): number;
  97284. /**
  97285. * Sets the shadows Saturation value.
  97286. * 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.
  97287. */
  97288. set shadowsSaturation(value: number);
  97289. /**
  97290. * Gets the shadows Exposure value.
  97291. * 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.
  97292. */
  97293. get shadowsExposure(): number;
  97294. /**
  97295. * Sets the shadows Exposure value.
  97296. * 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.
  97297. */
  97298. set shadowsExposure(value: number);
  97299. /**
  97300. * Returns the class name
  97301. * @returns The class name
  97302. */
  97303. getClassName(): string;
  97304. /**
  97305. * Binds the color curves to the shader.
  97306. * @param colorCurves The color curve to bind
  97307. * @param effect The effect to bind to
  97308. * @param positiveUniform The positive uniform shader parameter
  97309. * @param neutralUniform The neutral uniform shader parameter
  97310. * @param negativeUniform The negative uniform shader parameter
  97311. */
  97312. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  97313. /**
  97314. * Prepare the list of uniforms associated with the ColorCurves effects.
  97315. * @param uniformsList The list of uniforms used in the effect
  97316. */
  97317. static PrepareUniforms(uniformsList: string[]): void;
  97318. /**
  97319. * Returns color grading data based on a hue, density, saturation and exposure value.
  97320. * @param filterHue The hue of the color filter.
  97321. * @param filterDensity The density of the color filter.
  97322. * @param saturation The saturation.
  97323. * @param exposure The exposure.
  97324. * @param result The result data container.
  97325. */
  97326. private getColorGradingDataToRef;
  97327. /**
  97328. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  97329. * @param value The input slider value in range [-100,100].
  97330. * @returns Adjusted value.
  97331. */
  97332. private static applyColorGradingSliderNonlinear;
  97333. /**
  97334. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  97335. * @param hue The hue (H) input.
  97336. * @param saturation The saturation (S) input.
  97337. * @param brightness The brightness (B) input.
  97338. * @result An RGBA color represented as Vector4.
  97339. */
  97340. private static fromHSBToRef;
  97341. /**
  97342. * Returns a value clamped between min and max
  97343. * @param value The value to clamp
  97344. * @param min The minimum of value
  97345. * @param max The maximum of value
  97346. * @returns The clamped value.
  97347. */
  97348. private static clamp;
  97349. /**
  97350. * Clones the current color curve instance.
  97351. * @return The cloned curves
  97352. */
  97353. clone(): ColorCurves;
  97354. /**
  97355. * Serializes the current color curve instance to a json representation.
  97356. * @return a JSON representation
  97357. */
  97358. serialize(): any;
  97359. /**
  97360. * Parses the color curve from a json representation.
  97361. * @param source the JSON source to parse
  97362. * @return The parsed curves
  97363. */
  97364. static Parse(source: any): ColorCurves;
  97365. }
  97366. }
  97367. declare module BABYLON {
  97368. /**
  97369. * Interface to follow in your material defines to integrate easily the
  97370. * Image processing functions.
  97371. * @hidden
  97372. */
  97373. export interface IImageProcessingConfigurationDefines {
  97374. IMAGEPROCESSING: boolean;
  97375. VIGNETTE: boolean;
  97376. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97377. VIGNETTEBLENDMODEOPAQUE: boolean;
  97378. TONEMAPPING: boolean;
  97379. TONEMAPPING_ACES: boolean;
  97380. CONTRAST: boolean;
  97381. EXPOSURE: boolean;
  97382. COLORCURVES: boolean;
  97383. COLORGRADING: boolean;
  97384. COLORGRADING3D: boolean;
  97385. SAMPLER3DGREENDEPTH: boolean;
  97386. SAMPLER3DBGRMAP: boolean;
  97387. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97388. }
  97389. /**
  97390. * @hidden
  97391. */
  97392. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97393. IMAGEPROCESSING: boolean;
  97394. VIGNETTE: boolean;
  97395. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97396. VIGNETTEBLENDMODEOPAQUE: boolean;
  97397. TONEMAPPING: boolean;
  97398. TONEMAPPING_ACES: boolean;
  97399. CONTRAST: boolean;
  97400. COLORCURVES: boolean;
  97401. COLORGRADING: boolean;
  97402. COLORGRADING3D: boolean;
  97403. SAMPLER3DGREENDEPTH: boolean;
  97404. SAMPLER3DBGRMAP: boolean;
  97405. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97406. EXPOSURE: boolean;
  97407. constructor();
  97408. }
  97409. /**
  97410. * This groups together the common properties used for image processing either in direct forward pass
  97411. * or through post processing effect depending on the use of the image processing pipeline in your scene
  97412. * or not.
  97413. */
  97414. export class ImageProcessingConfiguration {
  97415. /**
  97416. * Default tone mapping applied in BabylonJS.
  97417. */
  97418. static readonly TONEMAPPING_STANDARD: number;
  97419. /**
  97420. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  97421. * to other engines rendering to increase portability.
  97422. */
  97423. static readonly TONEMAPPING_ACES: number;
  97424. /**
  97425. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  97426. */
  97427. colorCurves: Nullable<ColorCurves>;
  97428. private _colorCurvesEnabled;
  97429. /**
  97430. * Gets whether the color curves effect is enabled.
  97431. */
  97432. get colorCurvesEnabled(): boolean;
  97433. /**
  97434. * Sets whether the color curves effect is enabled.
  97435. */
  97436. set colorCurvesEnabled(value: boolean);
  97437. private _colorGradingTexture;
  97438. /**
  97439. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  97440. */
  97441. get colorGradingTexture(): Nullable<BaseTexture>;
  97442. /**
  97443. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  97444. */
  97445. set colorGradingTexture(value: Nullable<BaseTexture>);
  97446. private _colorGradingEnabled;
  97447. /**
  97448. * Gets whether the color grading effect is enabled.
  97449. */
  97450. get colorGradingEnabled(): boolean;
  97451. /**
  97452. * Sets whether the color grading effect is enabled.
  97453. */
  97454. set colorGradingEnabled(value: boolean);
  97455. private _colorGradingWithGreenDepth;
  97456. /**
  97457. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  97458. */
  97459. get colorGradingWithGreenDepth(): boolean;
  97460. /**
  97461. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  97462. */
  97463. set colorGradingWithGreenDepth(value: boolean);
  97464. private _colorGradingBGR;
  97465. /**
  97466. * Gets whether the color grading texture contains BGR values.
  97467. */
  97468. get colorGradingBGR(): boolean;
  97469. /**
  97470. * Sets whether the color grading texture contains BGR values.
  97471. */
  97472. set colorGradingBGR(value: boolean);
  97473. /** @hidden */
  97474. _exposure: number;
  97475. /**
  97476. * Gets the Exposure used in the effect.
  97477. */
  97478. get exposure(): number;
  97479. /**
  97480. * Sets the Exposure used in the effect.
  97481. */
  97482. set exposure(value: number);
  97483. private _toneMappingEnabled;
  97484. /**
  97485. * Gets whether the tone mapping effect is enabled.
  97486. */
  97487. get toneMappingEnabled(): boolean;
  97488. /**
  97489. * Sets whether the tone mapping effect is enabled.
  97490. */
  97491. set toneMappingEnabled(value: boolean);
  97492. private _toneMappingType;
  97493. /**
  97494. * Gets the type of tone mapping effect.
  97495. */
  97496. get toneMappingType(): number;
  97497. /**
  97498. * Sets the type of tone mapping effect used in BabylonJS.
  97499. */
  97500. set toneMappingType(value: number);
  97501. protected _contrast: number;
  97502. /**
  97503. * Gets the contrast used in the effect.
  97504. */
  97505. get contrast(): number;
  97506. /**
  97507. * Sets the contrast used in the effect.
  97508. */
  97509. set contrast(value: number);
  97510. /**
  97511. * Vignette stretch size.
  97512. */
  97513. vignetteStretch: number;
  97514. /**
  97515. * Vignette centre X Offset.
  97516. */
  97517. vignetteCentreX: number;
  97518. /**
  97519. * Vignette centre Y Offset.
  97520. */
  97521. vignetteCentreY: number;
  97522. /**
  97523. * Vignette weight or intensity of the vignette effect.
  97524. */
  97525. vignetteWeight: number;
  97526. /**
  97527. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97528. * if vignetteEnabled is set to true.
  97529. */
  97530. vignetteColor: Color4;
  97531. /**
  97532. * Camera field of view used by the Vignette effect.
  97533. */
  97534. vignetteCameraFov: number;
  97535. private _vignetteBlendMode;
  97536. /**
  97537. * Gets the vignette blend mode allowing different kind of effect.
  97538. */
  97539. get vignetteBlendMode(): number;
  97540. /**
  97541. * Sets the vignette blend mode allowing different kind of effect.
  97542. */
  97543. set vignetteBlendMode(value: number);
  97544. private _vignetteEnabled;
  97545. /**
  97546. * Gets whether the vignette effect is enabled.
  97547. */
  97548. get vignetteEnabled(): boolean;
  97549. /**
  97550. * Sets whether the vignette effect is enabled.
  97551. */
  97552. set vignetteEnabled(value: boolean);
  97553. private _applyByPostProcess;
  97554. /**
  97555. * Gets whether the image processing is applied through a post process or not.
  97556. */
  97557. get applyByPostProcess(): boolean;
  97558. /**
  97559. * Sets whether the image processing is applied through a post process or not.
  97560. */
  97561. set applyByPostProcess(value: boolean);
  97562. private _isEnabled;
  97563. /**
  97564. * Gets whether the image processing is enabled or not.
  97565. */
  97566. get isEnabled(): boolean;
  97567. /**
  97568. * Sets whether the image processing is enabled or not.
  97569. */
  97570. set isEnabled(value: boolean);
  97571. /**
  97572. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  97573. */
  97574. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  97575. /**
  97576. * Method called each time the image processing information changes requires to recompile the effect.
  97577. */
  97578. protected _updateParameters(): void;
  97579. /**
  97580. * Gets the current class name.
  97581. * @return "ImageProcessingConfiguration"
  97582. */
  97583. getClassName(): string;
  97584. /**
  97585. * Prepare the list of uniforms associated with the Image Processing effects.
  97586. * @param uniforms The list of uniforms used in the effect
  97587. * @param defines the list of defines currently in use
  97588. */
  97589. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  97590. /**
  97591. * Prepare the list of samplers associated with the Image Processing effects.
  97592. * @param samplersList The list of uniforms used in the effect
  97593. * @param defines the list of defines currently in use
  97594. */
  97595. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  97596. /**
  97597. * Prepare the list of defines associated to the shader.
  97598. * @param defines the list of defines to complete
  97599. * @param forPostProcess Define if we are currently in post process mode or not
  97600. */
  97601. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  97602. /**
  97603. * Returns true if all the image processing information are ready.
  97604. * @returns True if ready, otherwise, false
  97605. */
  97606. isReady(): boolean;
  97607. /**
  97608. * Binds the image processing to the shader.
  97609. * @param effect The effect to bind to
  97610. * @param overrideAspectRatio Override the aspect ratio of the effect
  97611. */
  97612. bind(effect: Effect, overrideAspectRatio?: number): void;
  97613. /**
  97614. * Clones the current image processing instance.
  97615. * @return The cloned image processing
  97616. */
  97617. clone(): ImageProcessingConfiguration;
  97618. /**
  97619. * Serializes the current image processing instance to a json representation.
  97620. * @return a JSON representation
  97621. */
  97622. serialize(): any;
  97623. /**
  97624. * Parses the image processing from a json representation.
  97625. * @param source the JSON source to parse
  97626. * @return The parsed image processing
  97627. */
  97628. static Parse(source: any): ImageProcessingConfiguration;
  97629. private static _VIGNETTEMODE_MULTIPLY;
  97630. private static _VIGNETTEMODE_OPAQUE;
  97631. /**
  97632. * Used to apply the vignette as a mix with the pixel color.
  97633. */
  97634. static get VIGNETTEMODE_MULTIPLY(): number;
  97635. /**
  97636. * Used to apply the vignette as a replacement of the pixel color.
  97637. */
  97638. static get VIGNETTEMODE_OPAQUE(): number;
  97639. }
  97640. }
  97641. declare module BABYLON {
  97642. /** @hidden */
  97643. export var postprocessVertexShader: {
  97644. name: string;
  97645. shader: string;
  97646. };
  97647. }
  97648. declare module BABYLON {
  97649. /**
  97650. * Type used to define a render target texture size (either with a number or with a rect width and height)
  97651. */
  97652. export type RenderTargetTextureSize = number | {
  97653. width: number;
  97654. height: number;
  97655. layers?: number;
  97656. };
  97657. interface ThinEngine {
  97658. /**
  97659. * Creates a new render target texture
  97660. * @param size defines the size of the texture
  97661. * @param options defines the options used to create the texture
  97662. * @returns a new render target texture stored in an InternalTexture
  97663. */
  97664. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97665. /**
  97666. * Creates a depth stencil texture.
  97667. * This is only available in WebGL 2 or with the depth texture extension available.
  97668. * @param size The size of face edge in the texture.
  97669. * @param options The options defining the texture.
  97670. * @returns The texture
  97671. */
  97672. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  97673. /** @hidden */
  97674. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  97675. }
  97676. }
  97677. declare module BABYLON {
  97678. /**
  97679. * Defines the kind of connection point for node based material
  97680. */
  97681. export enum NodeMaterialBlockConnectionPointTypes {
  97682. /** Float */
  97683. Float = 1,
  97684. /** Int */
  97685. Int = 2,
  97686. /** Vector2 */
  97687. Vector2 = 4,
  97688. /** Vector3 */
  97689. Vector3 = 8,
  97690. /** Vector4 */
  97691. Vector4 = 16,
  97692. /** Color3 */
  97693. Color3 = 32,
  97694. /** Color4 */
  97695. Color4 = 64,
  97696. /** Matrix */
  97697. Matrix = 128,
  97698. /** Custom object */
  97699. Object = 256,
  97700. /** Detect type based on connection */
  97701. AutoDetect = 1024,
  97702. /** Output type that will be defined by input type */
  97703. BasedOnInput = 2048
  97704. }
  97705. }
  97706. declare module BABYLON {
  97707. /**
  97708. * Enum used to define the target of a block
  97709. */
  97710. export enum NodeMaterialBlockTargets {
  97711. /** Vertex shader */
  97712. Vertex = 1,
  97713. /** Fragment shader */
  97714. Fragment = 2,
  97715. /** Neutral */
  97716. Neutral = 4,
  97717. /** Vertex and Fragment */
  97718. VertexAndFragment = 3
  97719. }
  97720. }
  97721. declare module BABYLON {
  97722. /**
  97723. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  97724. */
  97725. export enum NodeMaterialBlockConnectionPointMode {
  97726. /** Value is an uniform */
  97727. Uniform = 0,
  97728. /** Value is a mesh attribute */
  97729. Attribute = 1,
  97730. /** Value is a varying between vertex and fragment shaders */
  97731. Varying = 2,
  97732. /** Mode is undefined */
  97733. Undefined = 3
  97734. }
  97735. }
  97736. declare module BABYLON {
  97737. /**
  97738. * Enum used to define system values e.g. values automatically provided by the system
  97739. */
  97740. export enum NodeMaterialSystemValues {
  97741. /** World */
  97742. World = 1,
  97743. /** View */
  97744. View = 2,
  97745. /** Projection */
  97746. Projection = 3,
  97747. /** ViewProjection */
  97748. ViewProjection = 4,
  97749. /** WorldView */
  97750. WorldView = 5,
  97751. /** WorldViewProjection */
  97752. WorldViewProjection = 6,
  97753. /** CameraPosition */
  97754. CameraPosition = 7,
  97755. /** Fog Color */
  97756. FogColor = 8,
  97757. /** Delta time */
  97758. DeltaTime = 9
  97759. }
  97760. }
  97761. declare module BABYLON {
  97762. /**
  97763. * Represents a camera frustum
  97764. */
  97765. export class Frustum {
  97766. /**
  97767. * Gets the planes representing the frustum
  97768. * @param transform matrix to be applied to the returned planes
  97769. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  97770. */
  97771. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  97772. /**
  97773. * Gets the near frustum plane transformed by the transform matrix
  97774. * @param transform transformation matrix to be applied to the resulting frustum plane
  97775. * @param frustumPlane the resuling frustum plane
  97776. */
  97777. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97778. /**
  97779. * Gets the far frustum plane transformed by the transform matrix
  97780. * @param transform transformation matrix to be applied to the resulting frustum plane
  97781. * @param frustumPlane the resuling frustum plane
  97782. */
  97783. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97784. /**
  97785. * Gets the left frustum plane transformed by the transform matrix
  97786. * @param transform transformation matrix to be applied to the resulting frustum plane
  97787. * @param frustumPlane the resuling frustum plane
  97788. */
  97789. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97790. /**
  97791. * Gets the right frustum plane transformed by the transform matrix
  97792. * @param transform transformation matrix to be applied to the resulting frustum plane
  97793. * @param frustumPlane the resuling frustum plane
  97794. */
  97795. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97796. /**
  97797. * Gets the top frustum plane transformed by the transform matrix
  97798. * @param transform transformation matrix to be applied to the resulting frustum plane
  97799. * @param frustumPlane the resuling frustum plane
  97800. */
  97801. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97802. /**
  97803. * Gets the bottom frustum plane transformed by the transform matrix
  97804. * @param transform transformation matrix to be applied to the resulting frustum plane
  97805. * @param frustumPlane the resuling frustum plane
  97806. */
  97807. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  97808. /**
  97809. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  97810. * @param transform transformation matrix to be applied to the resulting frustum planes
  97811. * @param frustumPlanes the resuling frustum planes
  97812. */
  97813. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  97814. }
  97815. }
  97816. declare module BABYLON {
  97817. /**
  97818. * Contains position and normal vectors for a vertex
  97819. */
  97820. export class PositionNormalVertex {
  97821. /** the position of the vertex (defaut: 0,0,0) */
  97822. position: Vector3;
  97823. /** the normal of the vertex (defaut: 0,1,0) */
  97824. normal: Vector3;
  97825. /**
  97826. * Creates a PositionNormalVertex
  97827. * @param position the position of the vertex (defaut: 0,0,0)
  97828. * @param normal the normal of the vertex (defaut: 0,1,0)
  97829. */
  97830. constructor(
  97831. /** the position of the vertex (defaut: 0,0,0) */
  97832. position?: Vector3,
  97833. /** the normal of the vertex (defaut: 0,1,0) */
  97834. normal?: Vector3);
  97835. /**
  97836. * Clones the PositionNormalVertex
  97837. * @returns the cloned PositionNormalVertex
  97838. */
  97839. clone(): PositionNormalVertex;
  97840. }
  97841. /**
  97842. * Contains position, normal and uv vectors for a vertex
  97843. */
  97844. export class PositionNormalTextureVertex {
  97845. /** the position of the vertex (defaut: 0,0,0) */
  97846. position: Vector3;
  97847. /** the normal of the vertex (defaut: 0,1,0) */
  97848. normal: Vector3;
  97849. /** the uv of the vertex (default: 0,0) */
  97850. uv: Vector2;
  97851. /**
  97852. * Creates a PositionNormalTextureVertex
  97853. * @param position the position of the vertex (defaut: 0,0,0)
  97854. * @param normal the normal of the vertex (defaut: 0,1,0)
  97855. * @param uv the uv of the vertex (default: 0,0)
  97856. */
  97857. constructor(
  97858. /** the position of the vertex (defaut: 0,0,0) */
  97859. position?: Vector3,
  97860. /** the normal of the vertex (defaut: 0,1,0) */
  97861. normal?: Vector3,
  97862. /** the uv of the vertex (default: 0,0) */
  97863. uv?: Vector2);
  97864. /**
  97865. * Clones the PositionNormalTextureVertex
  97866. * @returns the cloned PositionNormalTextureVertex
  97867. */
  97868. clone(): PositionNormalTextureVertex;
  97869. }
  97870. }
  97871. declare module BABYLON {
  97872. /**
  97873. * Enum defining the type of animations supported by InputBlock
  97874. */
  97875. export enum AnimatedInputBlockTypes {
  97876. /** No animation */
  97877. None = 0,
  97878. /** Time based animation. Will only work for floats */
  97879. Time = 1
  97880. }
  97881. }
  97882. declare module BABYLON {
  97883. /**
  97884. * Block used to expose an input value
  97885. */
  97886. export class InputBlock extends NodeMaterialBlock {
  97887. private _mode;
  97888. private _associatedVariableName;
  97889. private _storedValue;
  97890. private _valueCallback;
  97891. private _type;
  97892. private _animationType;
  97893. /** Gets or set a value used to limit the range of float values */
  97894. min: number;
  97895. /** Gets or set a value used to limit the range of float values */
  97896. max: number;
  97897. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97898. isBoolean: boolean;
  97899. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97900. matrixMode: number;
  97901. /** @hidden */
  97902. _systemValue: Nullable<NodeMaterialSystemValues>;
  97903. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97904. isConstant: boolean;
  97905. /** Gets or sets the group to use to display this block in the Inspector */
  97906. groupInInspector: string;
  97907. /** Gets an observable raised when the value is changed */
  97908. onValueChangedObservable: Observable<InputBlock>;
  97909. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  97910. convertToGammaSpace: boolean;
  97911. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  97912. convertToLinearSpace: boolean;
  97913. /**
  97914. * Gets or sets the connection point type (default is float)
  97915. */
  97916. get type(): NodeMaterialBlockConnectionPointTypes;
  97917. /**
  97918. * Creates a new InputBlock
  97919. * @param name defines the block name
  97920. * @param target defines the target of that block (Vertex by default)
  97921. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97922. */
  97923. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97924. /**
  97925. * Validates if a name is a reserve word.
  97926. * @param newName the new name to be given to the node.
  97927. * @returns false if the name is a reserve word, else true.
  97928. */
  97929. validateBlockName(newName: string): boolean;
  97930. /**
  97931. * Gets the output component
  97932. */
  97933. get output(): NodeMaterialConnectionPoint;
  97934. /**
  97935. * Set the source of this connection point to a vertex attribute
  97936. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97937. * @returns the current connection point
  97938. */
  97939. setAsAttribute(attributeName?: string): InputBlock;
  97940. /**
  97941. * Set the source of this connection point to a system value
  97942. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97943. * @returns the current connection point
  97944. */
  97945. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97946. /**
  97947. * Gets or sets the value of that point.
  97948. * Please note that this value will be ignored if valueCallback is defined
  97949. */
  97950. get value(): any;
  97951. set value(value: any);
  97952. /**
  97953. * Gets or sets a callback used to get the value of that point.
  97954. * Please note that setting this value will force the connection point to ignore the value property
  97955. */
  97956. get valueCallback(): () => any;
  97957. set valueCallback(value: () => any);
  97958. /**
  97959. * Gets or sets the associated variable name in the shader
  97960. */
  97961. get associatedVariableName(): string;
  97962. set associatedVariableName(value: string);
  97963. /** Gets or sets the type of animation applied to the input */
  97964. get animationType(): AnimatedInputBlockTypes;
  97965. set animationType(value: AnimatedInputBlockTypes);
  97966. /**
  97967. * Gets a boolean indicating that this connection point not defined yet
  97968. */
  97969. get isUndefined(): boolean;
  97970. /**
  97971. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97972. * In this case the connection point name must be the name of the uniform to use.
  97973. * Can only be set on inputs
  97974. */
  97975. get isUniform(): boolean;
  97976. set isUniform(value: boolean);
  97977. /**
  97978. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97979. * In this case the connection point name must be the name of the attribute to use
  97980. * Can only be set on inputs
  97981. */
  97982. get isAttribute(): boolean;
  97983. set isAttribute(value: boolean);
  97984. /**
  97985. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97986. * Can only be set on exit points
  97987. */
  97988. get isVarying(): boolean;
  97989. set isVarying(value: boolean);
  97990. /**
  97991. * Gets a boolean indicating that the current connection point is a system value
  97992. */
  97993. get isSystemValue(): boolean;
  97994. /**
  97995. * Gets or sets the current well known value or null if not defined as a system value
  97996. */
  97997. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97998. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97999. /**
  98000. * Gets the current class name
  98001. * @returns the class name
  98002. */
  98003. getClassName(): string;
  98004. /**
  98005. * Animate the input if animationType !== None
  98006. * @param scene defines the rendering scene
  98007. */
  98008. animate(scene: Scene): void;
  98009. private _emitDefine;
  98010. initialize(state: NodeMaterialBuildState): void;
  98011. /**
  98012. * Set the input block to its default value (based on its type)
  98013. */
  98014. setDefaultValue(): void;
  98015. private _emitConstant;
  98016. /** @hidden */
  98017. get _noContextSwitch(): boolean;
  98018. private _emit;
  98019. /** @hidden */
  98020. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98021. /** @hidden */
  98022. _transmit(effect: Effect, scene: Scene): void;
  98023. protected _buildBlock(state: NodeMaterialBuildState): void;
  98024. protected _dumpPropertiesCode(): string;
  98025. dispose(): void;
  98026. serialize(): any;
  98027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98028. }
  98029. }
  98030. declare module BABYLON {
  98031. /**
  98032. * Enum used to define the compatibility state between two connection points
  98033. */
  98034. export enum NodeMaterialConnectionPointCompatibilityStates {
  98035. /** Points are compatibles */
  98036. Compatible = 0,
  98037. /** Points are incompatible because of their types */
  98038. TypeIncompatible = 1,
  98039. /** Points are incompatible because of their targets (vertex vs fragment) */
  98040. TargetIncompatible = 2
  98041. }
  98042. /**
  98043. * Defines the direction of a connection point
  98044. */
  98045. export enum NodeMaterialConnectionPointDirection {
  98046. /** Input */
  98047. Input = 0,
  98048. /** Output */
  98049. Output = 1
  98050. }
  98051. /**
  98052. * Defines a connection point for a block
  98053. */
  98054. export class NodeMaterialConnectionPoint {
  98055. /**
  98056. * Checks if two types are equivalent
  98057. * @param type1 type 1 to check
  98058. * @param type2 type 2 to check
  98059. * @returns true if both types are equivalent, else false
  98060. */
  98061. static AreEquivalentTypes(type1: number, type2: number): boolean;
  98062. /** @hidden */
  98063. _ownerBlock: NodeMaterialBlock;
  98064. /** @hidden */
  98065. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98066. private _endpoints;
  98067. private _associatedVariableName;
  98068. private _direction;
  98069. /** @hidden */
  98070. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98071. /** @hidden */
  98072. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98073. /** @hidden */
  98074. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  98075. private _type;
  98076. /** @hidden */
  98077. _enforceAssociatedVariableName: boolean;
  98078. /** Gets the direction of the point */
  98079. get direction(): NodeMaterialConnectionPointDirection;
  98080. /** Indicates that this connection point needs dual validation before being connected to another point */
  98081. needDualDirectionValidation: boolean;
  98082. /**
  98083. * Gets or sets the additional types supported by this connection point
  98084. */
  98085. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98086. /**
  98087. * Gets or sets the additional types excluded by this connection point
  98088. */
  98089. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98090. /**
  98091. * Observable triggered when this point is connected
  98092. */
  98093. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98094. /**
  98095. * Gets or sets the associated variable name in the shader
  98096. */
  98097. get associatedVariableName(): string;
  98098. set associatedVariableName(value: string);
  98099. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98100. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98101. /**
  98102. * Gets or sets the connection point type (default is float)
  98103. */
  98104. get type(): NodeMaterialBlockConnectionPointTypes;
  98105. set type(value: NodeMaterialBlockConnectionPointTypes);
  98106. /**
  98107. * Gets or sets the connection point name
  98108. */
  98109. name: string;
  98110. /**
  98111. * Gets or sets the connection point name
  98112. */
  98113. displayName: string;
  98114. /**
  98115. * Gets or sets a boolean indicating that this connection point can be omitted
  98116. */
  98117. isOptional: boolean;
  98118. /**
  98119. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98120. */
  98121. isExposedOnFrame: boolean;
  98122. /**
  98123. * Gets or sets number indicating the position that the port is exposed to on a frame
  98124. */
  98125. exposedPortPosition: number;
  98126. /**
  98127. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98128. */
  98129. define: string;
  98130. /** @hidden */
  98131. _prioritizeVertex: boolean;
  98132. private _target;
  98133. /** Gets or sets the target of that connection point */
  98134. get target(): NodeMaterialBlockTargets;
  98135. set target(value: NodeMaterialBlockTargets);
  98136. /**
  98137. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98138. */
  98139. get isConnected(): boolean;
  98140. /**
  98141. * Gets a boolean indicating that the current point is connected to an input block
  98142. */
  98143. get isConnectedToInputBlock(): boolean;
  98144. /**
  98145. * Gets a the connected input block (if any)
  98146. */
  98147. get connectInputBlock(): Nullable<InputBlock>;
  98148. /** Get the other side of the connection (if any) */
  98149. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98150. /** Get the block that owns this connection point */
  98151. get ownerBlock(): NodeMaterialBlock;
  98152. /** Get the block connected on the other side of this connection (if any) */
  98153. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98154. /** Get the block connected on the endpoints of this connection (if any) */
  98155. get connectedBlocks(): Array<NodeMaterialBlock>;
  98156. /** Gets the list of connected endpoints */
  98157. get endpoints(): NodeMaterialConnectionPoint[];
  98158. /** Gets a boolean indicating if that output point is connected to at least one input */
  98159. get hasEndpoints(): boolean;
  98160. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98161. get isConnectedInVertexShader(): boolean;
  98162. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98163. get isConnectedInFragmentShader(): boolean;
  98164. /**
  98165. * Creates a block suitable to be used as an input for this input point.
  98166. * If null is returned, a block based on the point type will be created.
  98167. * @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
  98168. */
  98169. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98170. /**
  98171. * Creates a new connection point
  98172. * @param name defines the connection point name
  98173. * @param ownerBlock defines the block hosting this connection point
  98174. * @param direction defines the direction of the connection point
  98175. */
  98176. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98177. /**
  98178. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98179. * @returns the class name
  98180. */
  98181. getClassName(): string;
  98182. /**
  98183. * Gets a boolean indicating if the current point can be connected to another point
  98184. * @param connectionPoint defines the other connection point
  98185. * @returns a boolean
  98186. */
  98187. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98188. /**
  98189. * Gets a number indicating if the current point can be connected to another point
  98190. * @param connectionPoint defines the other connection point
  98191. * @returns a number defining the compatibility state
  98192. */
  98193. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98194. /**
  98195. * Connect this point to another connection point
  98196. * @param connectionPoint defines the other connection point
  98197. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98198. * @returns the current connection point
  98199. */
  98200. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98201. /**
  98202. * Disconnect this point from one of his endpoint
  98203. * @param endpoint defines the other connection point
  98204. * @returns the current connection point
  98205. */
  98206. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98207. /**
  98208. * Serializes this point in a JSON representation
  98209. * @param isInput defines if the connection point is an input (default is true)
  98210. * @returns the serialized point object
  98211. */
  98212. serialize(isInput?: boolean): any;
  98213. /**
  98214. * Release resources
  98215. */
  98216. dispose(): void;
  98217. }
  98218. }
  98219. declare module BABYLON {
  98220. /**
  98221. * Enum used to define the material modes
  98222. */
  98223. export enum NodeMaterialModes {
  98224. /** Regular material */
  98225. Material = 0,
  98226. /** For post process */
  98227. PostProcess = 1,
  98228. /** For particle system */
  98229. Particle = 2,
  98230. /** For procedural texture */
  98231. ProceduralTexture = 3
  98232. }
  98233. }
  98234. declare module BABYLON {
  98235. /** @hidden */
  98236. export var helperFunctions: {
  98237. name: string;
  98238. shader: string;
  98239. };
  98240. }
  98241. declare module BABYLON {
  98242. /**
  98243. * Block used to read a texture from a sampler
  98244. */
  98245. export class TextureBlock extends NodeMaterialBlock {
  98246. private _defineName;
  98247. private _linearDefineName;
  98248. private _gammaDefineName;
  98249. private _tempTextureRead;
  98250. private _samplerName;
  98251. private _transformedUVName;
  98252. private _textureTransformName;
  98253. private _textureInfoName;
  98254. private _mainUVName;
  98255. private _mainUVDefineName;
  98256. private _fragmentOnly;
  98257. /**
  98258. * Gets or sets the texture associated with the node
  98259. */
  98260. texture: Nullable<Texture>;
  98261. /**
  98262. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98263. */
  98264. convertToGammaSpace: boolean;
  98265. /**
  98266. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98267. */
  98268. convertToLinearSpace: boolean;
  98269. /**
  98270. * Create a new TextureBlock
  98271. * @param name defines the block name
  98272. */
  98273. constructor(name: string, fragmentOnly?: boolean);
  98274. /**
  98275. * Gets the current class name
  98276. * @returns the class name
  98277. */
  98278. getClassName(): string;
  98279. /**
  98280. * Gets the uv input component
  98281. */
  98282. get uv(): NodeMaterialConnectionPoint;
  98283. /**
  98284. * Gets the rgba output component
  98285. */
  98286. get rgba(): NodeMaterialConnectionPoint;
  98287. /**
  98288. * Gets the rgb output component
  98289. */
  98290. get rgb(): NodeMaterialConnectionPoint;
  98291. /**
  98292. * Gets the r output component
  98293. */
  98294. get r(): NodeMaterialConnectionPoint;
  98295. /**
  98296. * Gets the g output component
  98297. */
  98298. get g(): NodeMaterialConnectionPoint;
  98299. /**
  98300. * Gets the b output component
  98301. */
  98302. get b(): NodeMaterialConnectionPoint;
  98303. /**
  98304. * Gets the a output component
  98305. */
  98306. get a(): NodeMaterialConnectionPoint;
  98307. get target(): NodeMaterialBlockTargets;
  98308. autoConfigure(material: NodeMaterial): void;
  98309. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98311. isReady(): boolean;
  98312. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98313. private get _isMixed();
  98314. private _injectVertexCode;
  98315. private _writeTextureRead;
  98316. private _generateConversionCode;
  98317. private _writeOutput;
  98318. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98319. protected _dumpPropertiesCode(): string;
  98320. serialize(): any;
  98321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98322. }
  98323. }
  98324. declare module BABYLON {
  98325. /** @hidden */
  98326. export var reflectionFunction: {
  98327. name: string;
  98328. shader: string;
  98329. };
  98330. }
  98331. declare module BABYLON {
  98332. /**
  98333. * Base block used to read a reflection texture from a sampler
  98334. */
  98335. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98336. /** @hidden */
  98337. _define3DName: string;
  98338. /** @hidden */
  98339. _defineCubicName: string;
  98340. /** @hidden */
  98341. _defineExplicitName: string;
  98342. /** @hidden */
  98343. _defineProjectionName: string;
  98344. /** @hidden */
  98345. _defineLocalCubicName: string;
  98346. /** @hidden */
  98347. _defineSphericalName: string;
  98348. /** @hidden */
  98349. _definePlanarName: string;
  98350. /** @hidden */
  98351. _defineEquirectangularName: string;
  98352. /** @hidden */
  98353. _defineMirroredEquirectangularFixedName: string;
  98354. /** @hidden */
  98355. _defineEquirectangularFixedName: string;
  98356. /** @hidden */
  98357. _defineSkyboxName: string;
  98358. /** @hidden */
  98359. _defineOppositeZ: string;
  98360. /** @hidden */
  98361. _cubeSamplerName: string;
  98362. /** @hidden */
  98363. _2DSamplerName: string;
  98364. protected _positionUVWName: string;
  98365. protected _directionWName: string;
  98366. protected _reflectionVectorName: string;
  98367. /** @hidden */
  98368. _reflectionCoordsName: string;
  98369. /** @hidden */
  98370. _reflectionMatrixName: string;
  98371. protected _reflectionColorName: string;
  98372. /**
  98373. * Gets or sets the texture associated with the node
  98374. */
  98375. texture: Nullable<BaseTexture>;
  98376. /**
  98377. * Create a new ReflectionTextureBaseBlock
  98378. * @param name defines the block name
  98379. */
  98380. constructor(name: string);
  98381. /**
  98382. * Gets the current class name
  98383. * @returns the class name
  98384. */
  98385. getClassName(): string;
  98386. /**
  98387. * Gets the world position input component
  98388. */
  98389. abstract get position(): NodeMaterialConnectionPoint;
  98390. /**
  98391. * Gets the world position input component
  98392. */
  98393. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98394. /**
  98395. * Gets the world normal input component
  98396. */
  98397. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98398. /**
  98399. * Gets the world input component
  98400. */
  98401. abstract get world(): NodeMaterialConnectionPoint;
  98402. /**
  98403. * Gets the camera (or eye) position component
  98404. */
  98405. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98406. /**
  98407. * Gets the view input component
  98408. */
  98409. abstract get view(): NodeMaterialConnectionPoint;
  98410. protected _getTexture(): Nullable<BaseTexture>;
  98411. autoConfigure(material: NodeMaterial): void;
  98412. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98413. isReady(): boolean;
  98414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98415. /**
  98416. * Gets the code to inject in the vertex shader
  98417. * @param state current state of the node material building
  98418. * @returns the shader code
  98419. */
  98420. handleVertexSide(state: NodeMaterialBuildState): string;
  98421. /**
  98422. * Handles the inits for the fragment code path
  98423. * @param state node material build state
  98424. */
  98425. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98426. /**
  98427. * Generates the reflection coords code for the fragment code path
  98428. * @param worldNormalVarName name of the world normal variable
  98429. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98430. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98431. * @returns the shader code
  98432. */
  98433. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98434. /**
  98435. * Generates the reflection color code for the fragment code path
  98436. * @param lodVarName name of the lod variable
  98437. * @param swizzleLookupTexture swizzle to use for the final color variable
  98438. * @returns the shader code
  98439. */
  98440. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98441. /**
  98442. * Generates the code corresponding to the connected output points
  98443. * @param state node material build state
  98444. * @param varName name of the variable to output
  98445. * @returns the shader code
  98446. */
  98447. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98448. protected _buildBlock(state: NodeMaterialBuildState): this;
  98449. protected _dumpPropertiesCode(): string;
  98450. serialize(): any;
  98451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98452. }
  98453. }
  98454. declare module BABYLON {
  98455. /**
  98456. * Defines a connection point to be used for points with a custom object type
  98457. */
  98458. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98459. private _blockType;
  98460. private _blockName;
  98461. private _nameForCheking?;
  98462. /**
  98463. * Creates a new connection point
  98464. * @param name defines the connection point name
  98465. * @param ownerBlock defines the block hosting this connection point
  98466. * @param direction defines the direction of the connection point
  98467. */
  98468. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98469. /**
  98470. * Gets a number indicating if the current point can be connected to another point
  98471. * @param connectionPoint defines the other connection point
  98472. * @returns a number defining the compatibility state
  98473. */
  98474. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98475. /**
  98476. * Creates a block suitable to be used as an input for this input point.
  98477. * If null is returned, a block based on the point type will be created.
  98478. * @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
  98479. */
  98480. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98481. }
  98482. }
  98483. declare module BABYLON {
  98484. /**
  98485. * Enum defining the type of properties that can be edited in the property pages in the NME
  98486. */
  98487. export enum PropertyTypeForEdition {
  98488. /** property is a boolean */
  98489. Boolean = 0,
  98490. /** property is a float */
  98491. Float = 1,
  98492. /** property is a Vector2 */
  98493. Vector2 = 2,
  98494. /** property is a list of values */
  98495. List = 3
  98496. }
  98497. /**
  98498. * Interface that defines an option in a variable of type list
  98499. */
  98500. export interface IEditablePropertyListOption {
  98501. /** label of the option */
  98502. "label": string;
  98503. /** value of the option */
  98504. "value": number;
  98505. }
  98506. /**
  98507. * Interface that defines the options available for an editable property
  98508. */
  98509. export interface IEditablePropertyOption {
  98510. /** min value */
  98511. "min"?: number;
  98512. /** max value */
  98513. "max"?: number;
  98514. /** notifiers: indicates which actions to take when the property is changed */
  98515. "notifiers"?: {
  98516. /** the material should be rebuilt */
  98517. "rebuild"?: boolean;
  98518. /** the preview should be updated */
  98519. "update"?: boolean;
  98520. };
  98521. /** list of the options for a variable of type list */
  98522. "options"?: IEditablePropertyListOption[];
  98523. }
  98524. /**
  98525. * Interface that describes an editable property
  98526. */
  98527. export interface IPropertyDescriptionForEdition {
  98528. /** name of the property */
  98529. "propertyName": string;
  98530. /** display name of the property */
  98531. "displayName": string;
  98532. /** type of the property */
  98533. "type": PropertyTypeForEdition;
  98534. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98535. "groupName": string;
  98536. /** options for the property */
  98537. "options": IEditablePropertyOption;
  98538. }
  98539. /**
  98540. * Decorator that flags a property in a node material block as being editable
  98541. */
  98542. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98543. }
  98544. declare module BABYLON {
  98545. /**
  98546. * Block used to implement the refraction part of the sub surface module of the PBR material
  98547. */
  98548. export class RefractionBlock extends NodeMaterialBlock {
  98549. /** @hidden */
  98550. _define3DName: string;
  98551. /** @hidden */
  98552. _refractionMatrixName: string;
  98553. /** @hidden */
  98554. _defineLODRefractionAlpha: string;
  98555. /** @hidden */
  98556. _defineLinearSpecularRefraction: string;
  98557. /** @hidden */
  98558. _defineOppositeZ: string;
  98559. /** @hidden */
  98560. _cubeSamplerName: string;
  98561. /** @hidden */
  98562. _2DSamplerName: string;
  98563. /** @hidden */
  98564. _vRefractionMicrosurfaceInfosName: string;
  98565. /** @hidden */
  98566. _vRefractionInfosName: string;
  98567. /** @hidden */
  98568. _vRefractionFilteringInfoName: string;
  98569. private _scene;
  98570. /**
  98571. * The properties below are set by the main PBR block prior to calling methods of this class.
  98572. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  98573. * It's less burden on the user side in the editor part.
  98574. */
  98575. /** @hidden */
  98576. viewConnectionPoint: NodeMaterialConnectionPoint;
  98577. /** @hidden */
  98578. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  98579. /**
  98580. * This parameters will make the material used its opacity to control how much it is refracting against not.
  98581. * Materials half opaque for instance using refraction could benefit from this control.
  98582. */
  98583. linkRefractionWithTransparency: boolean;
  98584. /**
  98585. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98586. */
  98587. invertRefractionY: boolean;
  98588. /**
  98589. * Gets or sets the texture associated with the node
  98590. */
  98591. texture: Nullable<BaseTexture>;
  98592. /**
  98593. * Create a new RefractionBlock
  98594. * @param name defines the block name
  98595. */
  98596. constructor(name: string);
  98597. /**
  98598. * Gets the current class name
  98599. * @returns the class name
  98600. */
  98601. getClassName(): string;
  98602. /**
  98603. * Gets the intensity input component
  98604. */
  98605. get intensity(): NodeMaterialConnectionPoint;
  98606. /**
  98607. * Gets the tint at distance input component
  98608. */
  98609. get tintAtDistance(): NodeMaterialConnectionPoint;
  98610. /**
  98611. * Gets the view input component
  98612. */
  98613. get view(): NodeMaterialConnectionPoint;
  98614. /**
  98615. * Gets the refraction object output component
  98616. */
  98617. get refraction(): NodeMaterialConnectionPoint;
  98618. /**
  98619. * Returns true if the block has a texture
  98620. */
  98621. get hasTexture(): boolean;
  98622. protected _getTexture(): Nullable<BaseTexture>;
  98623. autoConfigure(material: NodeMaterial): void;
  98624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98625. isReady(): boolean;
  98626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98627. /**
  98628. * Gets the main code of the block (fragment side)
  98629. * @param state current state of the node material building
  98630. * @returns the shader code
  98631. */
  98632. getCode(state: NodeMaterialBuildState): string;
  98633. protected _buildBlock(state: NodeMaterialBuildState): this;
  98634. protected _dumpPropertiesCode(): string;
  98635. serialize(): any;
  98636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98637. }
  98638. }
  98639. declare module BABYLON {
  98640. /**
  98641. * Base block used as input for post process
  98642. */
  98643. export class CurrentScreenBlock extends NodeMaterialBlock {
  98644. private _samplerName;
  98645. private _linearDefineName;
  98646. private _gammaDefineName;
  98647. private _mainUVName;
  98648. private _tempTextureRead;
  98649. /**
  98650. * Gets or sets the texture associated with the node
  98651. */
  98652. texture: Nullable<BaseTexture>;
  98653. /**
  98654. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98655. */
  98656. convertToGammaSpace: boolean;
  98657. /**
  98658. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98659. */
  98660. convertToLinearSpace: boolean;
  98661. /**
  98662. * Create a new CurrentScreenBlock
  98663. * @param name defines the block name
  98664. */
  98665. constructor(name: string);
  98666. /**
  98667. * Gets the current class name
  98668. * @returns the class name
  98669. */
  98670. getClassName(): string;
  98671. /**
  98672. * Gets the uv input component
  98673. */
  98674. get uv(): NodeMaterialConnectionPoint;
  98675. /**
  98676. * Gets the rgba output component
  98677. */
  98678. get rgba(): NodeMaterialConnectionPoint;
  98679. /**
  98680. * Gets the rgb output component
  98681. */
  98682. get rgb(): NodeMaterialConnectionPoint;
  98683. /**
  98684. * Gets the r output component
  98685. */
  98686. get r(): NodeMaterialConnectionPoint;
  98687. /**
  98688. * Gets the g output component
  98689. */
  98690. get g(): NodeMaterialConnectionPoint;
  98691. /**
  98692. * Gets the b output component
  98693. */
  98694. get b(): NodeMaterialConnectionPoint;
  98695. /**
  98696. * Gets the a output component
  98697. */
  98698. get a(): NodeMaterialConnectionPoint;
  98699. /**
  98700. * Initialize the block and prepare the context for build
  98701. * @param state defines the state that will be used for the build
  98702. */
  98703. initialize(state: NodeMaterialBuildState): void;
  98704. get target(): NodeMaterialBlockTargets;
  98705. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98706. isReady(): boolean;
  98707. private _injectVertexCode;
  98708. private _writeTextureRead;
  98709. private _writeOutput;
  98710. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98711. serialize(): any;
  98712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98713. }
  98714. }
  98715. declare module BABYLON {
  98716. /**
  98717. * Base block used for the particle texture
  98718. */
  98719. export class ParticleTextureBlock extends NodeMaterialBlock {
  98720. private _samplerName;
  98721. private _linearDefineName;
  98722. private _gammaDefineName;
  98723. private _tempTextureRead;
  98724. /**
  98725. * Gets or sets the texture associated with the node
  98726. */
  98727. texture: Nullable<BaseTexture>;
  98728. /**
  98729. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98730. */
  98731. convertToGammaSpace: boolean;
  98732. /**
  98733. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98734. */
  98735. convertToLinearSpace: boolean;
  98736. /**
  98737. * Create a new ParticleTextureBlock
  98738. * @param name defines the block name
  98739. */
  98740. constructor(name: string);
  98741. /**
  98742. * Gets the current class name
  98743. * @returns the class name
  98744. */
  98745. getClassName(): string;
  98746. /**
  98747. * Gets the uv input component
  98748. */
  98749. get uv(): NodeMaterialConnectionPoint;
  98750. /**
  98751. * Gets the rgba output component
  98752. */
  98753. get rgba(): NodeMaterialConnectionPoint;
  98754. /**
  98755. * Gets the rgb output component
  98756. */
  98757. get rgb(): NodeMaterialConnectionPoint;
  98758. /**
  98759. * Gets the r output component
  98760. */
  98761. get r(): NodeMaterialConnectionPoint;
  98762. /**
  98763. * Gets the g output component
  98764. */
  98765. get g(): NodeMaterialConnectionPoint;
  98766. /**
  98767. * Gets the b output component
  98768. */
  98769. get b(): NodeMaterialConnectionPoint;
  98770. /**
  98771. * Gets the a output component
  98772. */
  98773. get a(): NodeMaterialConnectionPoint;
  98774. /**
  98775. * Initialize the block and prepare the context for build
  98776. * @param state defines the state that will be used for the build
  98777. */
  98778. initialize(state: NodeMaterialBuildState): void;
  98779. autoConfigure(material: NodeMaterial): void;
  98780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98781. isReady(): boolean;
  98782. private _writeOutput;
  98783. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98784. serialize(): any;
  98785. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98786. }
  98787. }
  98788. declare module BABYLON {
  98789. /**
  98790. * Class used to store shared data between 2 NodeMaterialBuildState
  98791. */
  98792. export class NodeMaterialBuildStateSharedData {
  98793. /**
  98794. * Gets the list of emitted varyings
  98795. */
  98796. temps: string[];
  98797. /**
  98798. * Gets the list of emitted varyings
  98799. */
  98800. varyings: string[];
  98801. /**
  98802. * Gets the varying declaration string
  98803. */
  98804. varyingDeclaration: string;
  98805. /**
  98806. * Input blocks
  98807. */
  98808. inputBlocks: InputBlock[];
  98809. /**
  98810. * Input blocks
  98811. */
  98812. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98813. /**
  98814. * Bindable blocks (Blocks that need to set data to the effect)
  98815. */
  98816. bindableBlocks: NodeMaterialBlock[];
  98817. /**
  98818. * List of blocks that can provide a compilation fallback
  98819. */
  98820. blocksWithFallbacks: NodeMaterialBlock[];
  98821. /**
  98822. * List of blocks that can provide a define update
  98823. */
  98824. blocksWithDefines: NodeMaterialBlock[];
  98825. /**
  98826. * List of blocks that can provide a repeatable content
  98827. */
  98828. repeatableContentBlocks: NodeMaterialBlock[];
  98829. /**
  98830. * List of blocks that can provide a dynamic list of uniforms
  98831. */
  98832. dynamicUniformBlocks: NodeMaterialBlock[];
  98833. /**
  98834. * List of blocks that can block the isReady function for the material
  98835. */
  98836. blockingBlocks: NodeMaterialBlock[];
  98837. /**
  98838. * Gets the list of animated inputs
  98839. */
  98840. animatedInputs: InputBlock[];
  98841. /**
  98842. * Build Id used to avoid multiple recompilations
  98843. */
  98844. buildId: number;
  98845. /** List of emitted variables */
  98846. variableNames: {
  98847. [key: string]: number;
  98848. };
  98849. /** List of emitted defines */
  98850. defineNames: {
  98851. [key: string]: number;
  98852. };
  98853. /** Should emit comments? */
  98854. emitComments: boolean;
  98855. /** Emit build activity */
  98856. verbose: boolean;
  98857. /** Gets or sets the hosting scene */
  98858. scene: Scene;
  98859. /**
  98860. * Gets the compilation hints emitted at compilation time
  98861. */
  98862. hints: {
  98863. needWorldViewMatrix: boolean;
  98864. needWorldViewProjectionMatrix: boolean;
  98865. needAlphaBlending: boolean;
  98866. needAlphaTesting: boolean;
  98867. };
  98868. /**
  98869. * List of compilation checks
  98870. */
  98871. checks: {
  98872. emitVertex: boolean;
  98873. emitFragment: boolean;
  98874. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98875. };
  98876. /**
  98877. * Is vertex program allowed to be empty?
  98878. */
  98879. allowEmptyVertexProgram: boolean;
  98880. /** Creates a new shared data */
  98881. constructor();
  98882. /**
  98883. * Emits console errors and exceptions if there is a failing check
  98884. */
  98885. emitErrors(): void;
  98886. }
  98887. }
  98888. declare module BABYLON {
  98889. /**
  98890. * Class used to store node based material build state
  98891. */
  98892. export class NodeMaterialBuildState {
  98893. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98894. supportUniformBuffers: boolean;
  98895. /**
  98896. * Gets the list of emitted attributes
  98897. */
  98898. attributes: string[];
  98899. /**
  98900. * Gets the list of emitted uniforms
  98901. */
  98902. uniforms: string[];
  98903. /**
  98904. * Gets the list of emitted constants
  98905. */
  98906. constants: string[];
  98907. /**
  98908. * Gets the list of emitted samplers
  98909. */
  98910. samplers: string[];
  98911. /**
  98912. * Gets the list of emitted functions
  98913. */
  98914. functions: {
  98915. [key: string]: string;
  98916. };
  98917. /**
  98918. * Gets the list of emitted extensions
  98919. */
  98920. extensions: {
  98921. [key: string]: string;
  98922. };
  98923. /**
  98924. * Gets the target of the compilation state
  98925. */
  98926. target: NodeMaterialBlockTargets;
  98927. /**
  98928. * Gets the list of emitted counters
  98929. */
  98930. counters: {
  98931. [key: string]: number;
  98932. };
  98933. /**
  98934. * Shared data between multiple NodeMaterialBuildState instances
  98935. */
  98936. sharedData: NodeMaterialBuildStateSharedData;
  98937. /** @hidden */
  98938. _vertexState: NodeMaterialBuildState;
  98939. /** @hidden */
  98940. _attributeDeclaration: string;
  98941. /** @hidden */
  98942. _uniformDeclaration: string;
  98943. /** @hidden */
  98944. _constantDeclaration: string;
  98945. /** @hidden */
  98946. _samplerDeclaration: string;
  98947. /** @hidden */
  98948. _varyingTransfer: string;
  98949. /** @hidden */
  98950. _injectAtEnd: string;
  98951. private _repeatableContentAnchorIndex;
  98952. /** @hidden */
  98953. _builtCompilationString: string;
  98954. /**
  98955. * Gets the emitted compilation strings
  98956. */
  98957. compilationString: string;
  98958. /**
  98959. * Finalize the compilation strings
  98960. * @param state defines the current compilation state
  98961. */
  98962. finalize(state: NodeMaterialBuildState): void;
  98963. /** @hidden */
  98964. get _repeatableContentAnchor(): string;
  98965. /** @hidden */
  98966. _getFreeVariableName(prefix: string): string;
  98967. /** @hidden */
  98968. _getFreeDefineName(prefix: string): string;
  98969. /** @hidden */
  98970. _excludeVariableName(name: string): void;
  98971. /** @hidden */
  98972. _emit2DSampler(name: string): void;
  98973. /** @hidden */
  98974. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98975. /** @hidden */
  98976. _emitExtension(name: string, extension: string, define?: string): void;
  98977. /** @hidden */
  98978. _emitFunction(name: string, code: string, comments: string): void;
  98979. /** @hidden */
  98980. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98981. replaceStrings?: {
  98982. search: RegExp;
  98983. replace: string;
  98984. }[];
  98985. repeatKey?: string;
  98986. }): string;
  98987. /** @hidden */
  98988. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98989. repeatKey?: string;
  98990. removeAttributes?: boolean;
  98991. removeUniforms?: boolean;
  98992. removeVaryings?: boolean;
  98993. removeIfDef?: boolean;
  98994. replaceStrings?: {
  98995. search: RegExp;
  98996. replace: string;
  98997. }[];
  98998. }, storeKey?: string): void;
  98999. /** @hidden */
  99000. _registerTempVariable(name: string): boolean;
  99001. /** @hidden */
  99002. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99003. /** @hidden */
  99004. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99005. /** @hidden */
  99006. _emitFloat(value: number): string;
  99007. }
  99008. }
  99009. declare module BABYLON {
  99010. /**
  99011. * Helper class used to generate session unique ID
  99012. */
  99013. export class UniqueIdGenerator {
  99014. private static _UniqueIdCounter;
  99015. /**
  99016. * Gets an unique (relatively to the current scene) Id
  99017. */
  99018. static get UniqueId(): number;
  99019. }
  99020. }
  99021. declare module BABYLON {
  99022. /**
  99023. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  99024. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  99025. */
  99026. export class EffectFallbacks implements IEffectFallbacks {
  99027. private _defines;
  99028. private _currentRank;
  99029. private _maxRank;
  99030. private _mesh;
  99031. /**
  99032. * Removes the fallback from the bound mesh.
  99033. */
  99034. unBindMesh(): void;
  99035. /**
  99036. * Adds a fallback on the specified property.
  99037. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  99038. * @param define The name of the define in the shader
  99039. */
  99040. addFallback(rank: number, define: string): void;
  99041. /**
  99042. * Sets the mesh to use CPU skinning when needing to fallback.
  99043. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  99044. * @param mesh The mesh to use the fallbacks.
  99045. */
  99046. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  99047. /**
  99048. * Checks to see if more fallbacks are still available.
  99049. */
  99050. get hasMoreFallbacks(): boolean;
  99051. /**
  99052. * Removes the defines that should be removed when falling back.
  99053. * @param currentDefines defines the current define statements for the shader.
  99054. * @param effect defines the current effect we try to compile
  99055. * @returns The resulting defines with defines of the current rank removed.
  99056. */
  99057. reduce(currentDefines: string, effect: Effect): string;
  99058. }
  99059. }
  99060. declare module BABYLON {
  99061. /**
  99062. * Defines a block that can be used inside a node based material
  99063. */
  99064. export class NodeMaterialBlock {
  99065. private _buildId;
  99066. private _buildTarget;
  99067. private _target;
  99068. private _isFinalMerger;
  99069. private _isInput;
  99070. private _name;
  99071. protected _isUnique: boolean;
  99072. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99073. inputsAreExclusive: boolean;
  99074. /** @hidden */
  99075. _codeVariableName: string;
  99076. /** @hidden */
  99077. _inputs: NodeMaterialConnectionPoint[];
  99078. /** @hidden */
  99079. _outputs: NodeMaterialConnectionPoint[];
  99080. /** @hidden */
  99081. _preparationId: number;
  99082. /** @hidden */
  99083. readonly _originalTargetIsNeutral: boolean;
  99084. /**
  99085. * Gets the name of the block
  99086. */
  99087. get name(): string;
  99088. /**
  99089. * Sets the name of the block. Will check if the name is valid.
  99090. */
  99091. set name(newName: string);
  99092. /**
  99093. * Gets or sets the unique id of the node
  99094. */
  99095. uniqueId: number;
  99096. /**
  99097. * Gets or sets the comments associated with this block
  99098. */
  99099. comments: string;
  99100. /**
  99101. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99102. */
  99103. get isUnique(): boolean;
  99104. /**
  99105. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99106. */
  99107. get isFinalMerger(): boolean;
  99108. /**
  99109. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99110. */
  99111. get isInput(): boolean;
  99112. /**
  99113. * Gets or sets the build Id
  99114. */
  99115. get buildId(): number;
  99116. set buildId(value: number);
  99117. /**
  99118. * Gets or sets the target of the block
  99119. */
  99120. get target(): NodeMaterialBlockTargets;
  99121. set target(value: NodeMaterialBlockTargets);
  99122. /**
  99123. * Gets the list of input points
  99124. */
  99125. get inputs(): NodeMaterialConnectionPoint[];
  99126. /** Gets the list of output points */
  99127. get outputs(): NodeMaterialConnectionPoint[];
  99128. /**
  99129. * Find an input by its name
  99130. * @param name defines the name of the input to look for
  99131. * @returns the input or null if not found
  99132. */
  99133. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99134. /**
  99135. * Find an output by its name
  99136. * @param name defines the name of the output to look for
  99137. * @returns the output or null if not found
  99138. */
  99139. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99140. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99141. visibleInInspector: boolean;
  99142. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  99143. visibleOnFrame: boolean;
  99144. /**
  99145. * Creates a new NodeMaterialBlock
  99146. * @param name defines the block name
  99147. * @param target defines the target of that block (Vertex by default)
  99148. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99149. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99150. */
  99151. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99152. /**
  99153. * Initialize the block and prepare the context for build
  99154. * @param state defines the state that will be used for the build
  99155. */
  99156. initialize(state: NodeMaterialBuildState): void;
  99157. /**
  99158. * Bind data to effect. Will only be called for blocks with isBindable === true
  99159. * @param effect defines the effect to bind data to
  99160. * @param nodeMaterial defines the hosting NodeMaterial
  99161. * @param mesh defines the mesh that will be rendered
  99162. * @param subMesh defines the submesh that will be rendered
  99163. */
  99164. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99165. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99166. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99167. protected _writeFloat(value: number): string;
  99168. /**
  99169. * Gets the current class name e.g. "NodeMaterialBlock"
  99170. * @returns the class name
  99171. */
  99172. getClassName(): string;
  99173. /**
  99174. * Register a new input. Must be called inside a block constructor
  99175. * @param name defines the connection point name
  99176. * @param type defines the connection point type
  99177. * @param isOptional defines a boolean indicating that this input can be omitted
  99178. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99179. * @param point an already created connection point. If not provided, create a new one
  99180. * @returns the current block
  99181. */
  99182. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99183. /**
  99184. * Register a new output. Must be called inside a block constructor
  99185. * @param name defines the connection point name
  99186. * @param type defines the connection point type
  99187. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99188. * @param point an already created connection point. If not provided, create a new one
  99189. * @returns the current block
  99190. */
  99191. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99192. /**
  99193. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99194. * @param forOutput defines an optional connection point to check compatibility with
  99195. * @returns the first available input or null
  99196. */
  99197. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99198. /**
  99199. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99200. * @param forBlock defines an optional block to check compatibility with
  99201. * @returns the first available input or null
  99202. */
  99203. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99204. /**
  99205. * Gets the sibling of the given output
  99206. * @param current defines the current output
  99207. * @returns the next output in the list or null
  99208. */
  99209. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99210. /**
  99211. * Connect current block with another block
  99212. * @param other defines the block to connect with
  99213. * @param options define the various options to help pick the right connections
  99214. * @returns the current block
  99215. */
  99216. connectTo(other: NodeMaterialBlock, options?: {
  99217. input?: string;
  99218. output?: string;
  99219. outputSwizzle?: string;
  99220. }): this | undefined;
  99221. protected _buildBlock(state: NodeMaterialBuildState): void;
  99222. /**
  99223. * Add uniforms, samplers and uniform buffers at compilation time
  99224. * @param state defines the state to update
  99225. * @param nodeMaterial defines the node material requesting the update
  99226. * @param defines defines the material defines to update
  99227. * @param uniformBuffers defines the list of uniform buffer names
  99228. */
  99229. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99230. /**
  99231. * Add potential fallbacks if shader compilation fails
  99232. * @param mesh defines the mesh to be rendered
  99233. * @param fallbacks defines the current prioritized list of fallbacks
  99234. */
  99235. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99236. /**
  99237. * Initialize defines for shader compilation
  99238. * @param mesh defines the mesh to be rendered
  99239. * @param nodeMaterial defines the node material requesting the update
  99240. * @param defines defines the material defines to update
  99241. * @param useInstances specifies that instances should be used
  99242. */
  99243. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99244. /**
  99245. * Update defines for shader compilation
  99246. * @param mesh defines the mesh to be rendered
  99247. * @param nodeMaterial defines the node material requesting the update
  99248. * @param defines defines the material defines to update
  99249. * @param useInstances specifies that instances should be used
  99250. * @param subMesh defines which submesh to render
  99251. */
  99252. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99253. /**
  99254. * Lets the block try to connect some inputs automatically
  99255. * @param material defines the hosting NodeMaterial
  99256. */
  99257. autoConfigure(material: NodeMaterial): void;
  99258. /**
  99259. * Function called when a block is declared as repeatable content generator
  99260. * @param vertexShaderState defines the current compilation state for the vertex shader
  99261. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99262. * @param mesh defines the mesh to be rendered
  99263. * @param defines defines the material defines to update
  99264. */
  99265. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99266. /**
  99267. * Checks if the block is ready
  99268. * @param mesh defines the mesh to be rendered
  99269. * @param nodeMaterial defines the node material requesting the update
  99270. * @param defines defines the material defines to update
  99271. * @param useInstances specifies that instances should be used
  99272. * @returns true if the block is ready
  99273. */
  99274. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99275. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  99276. private _processBuild;
  99277. /**
  99278. * Validates the new name for the block node.
  99279. * @param newName the new name to be given to the node.
  99280. * @returns false if the name is a reserve word, else true.
  99281. */
  99282. validateBlockName(newName: string): boolean;
  99283. /**
  99284. * Compile the current node and generate the shader code
  99285. * @param state defines the current compilation state (uniforms, samplers, current string)
  99286. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99287. * @returns true if already built
  99288. */
  99289. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99290. protected _inputRename(name: string): string;
  99291. protected _outputRename(name: string): string;
  99292. protected _dumpPropertiesCode(): string;
  99293. /** @hidden */
  99294. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99295. /** @hidden */
  99296. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99297. /**
  99298. * Clone the current block to a new identical block
  99299. * @param scene defines the hosting scene
  99300. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99301. * @returns a copy of the current block
  99302. */
  99303. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99304. /**
  99305. * Serializes this block in a JSON representation
  99306. * @returns the serialized block object
  99307. */
  99308. serialize(): any;
  99309. /** @hidden */
  99310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99311. private _deserializePortDisplayNamesAndExposedOnFrame;
  99312. /**
  99313. * Release resources
  99314. */
  99315. dispose(): void;
  99316. }
  99317. }
  99318. declare module BABYLON {
  99319. /**
  99320. * Base class of materials working in push mode in babylon JS
  99321. * @hidden
  99322. */
  99323. export class PushMaterial extends Material {
  99324. protected _activeEffect: Effect;
  99325. protected _normalMatrix: Matrix;
  99326. constructor(name: string, scene: Scene);
  99327. getEffect(): Effect;
  99328. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99329. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99330. /**
  99331. * Binds the given world matrix to the active effect
  99332. *
  99333. * @param world the matrix to bind
  99334. */
  99335. bindOnlyWorldMatrix(world: Matrix): void;
  99336. /**
  99337. * Binds the given normal matrix to the active effect
  99338. *
  99339. * @param normalMatrix the matrix to bind
  99340. */
  99341. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99342. bind(world: Matrix, mesh?: Mesh): void;
  99343. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99344. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99345. }
  99346. }
  99347. declare module BABYLON {
  99348. /**
  99349. * Root class for all node material optimizers
  99350. */
  99351. export class NodeMaterialOptimizer {
  99352. /**
  99353. * Function used to optimize a NodeMaterial graph
  99354. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99355. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99356. */
  99357. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99358. }
  99359. }
  99360. declare module BABYLON {
  99361. /**
  99362. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99363. */
  99364. export class TransformBlock extends NodeMaterialBlock {
  99365. /**
  99366. * Defines the value to use to complement W value to transform it to a Vector4
  99367. */
  99368. complementW: number;
  99369. /**
  99370. * Defines the value to use to complement z value to transform it to a Vector4
  99371. */
  99372. complementZ: number;
  99373. /**
  99374. * Creates a new TransformBlock
  99375. * @param name defines the block name
  99376. */
  99377. constructor(name: string);
  99378. /**
  99379. * Gets the current class name
  99380. * @returns the class name
  99381. */
  99382. getClassName(): string;
  99383. /**
  99384. * Gets the vector input
  99385. */
  99386. get vector(): NodeMaterialConnectionPoint;
  99387. /**
  99388. * Gets the output component
  99389. */
  99390. get output(): NodeMaterialConnectionPoint;
  99391. /**
  99392. * Gets the xyz output component
  99393. */
  99394. get xyz(): NodeMaterialConnectionPoint;
  99395. /**
  99396. * Gets the matrix transform input
  99397. */
  99398. get transform(): NodeMaterialConnectionPoint;
  99399. protected _buildBlock(state: NodeMaterialBuildState): this;
  99400. /**
  99401. * Update defines for shader compilation
  99402. * @param mesh defines the mesh to be rendered
  99403. * @param nodeMaterial defines the node material requesting the update
  99404. * @param defines defines the material defines to update
  99405. * @param useInstances specifies that instances should be used
  99406. * @param subMesh defines which submesh to render
  99407. */
  99408. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99409. serialize(): any;
  99410. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99411. protected _dumpPropertiesCode(): string;
  99412. }
  99413. }
  99414. declare module BABYLON {
  99415. /**
  99416. * Block used to output the vertex position
  99417. */
  99418. export class VertexOutputBlock extends NodeMaterialBlock {
  99419. /**
  99420. * Creates a new VertexOutputBlock
  99421. * @param name defines the block name
  99422. */
  99423. constructor(name: string);
  99424. /**
  99425. * Gets the current class name
  99426. * @returns the class name
  99427. */
  99428. getClassName(): string;
  99429. /**
  99430. * Gets the vector input component
  99431. */
  99432. get vector(): NodeMaterialConnectionPoint;
  99433. protected _buildBlock(state: NodeMaterialBuildState): this;
  99434. }
  99435. }
  99436. declare module BABYLON {
  99437. /**
  99438. * Block used to output the final color
  99439. */
  99440. export class FragmentOutputBlock extends NodeMaterialBlock {
  99441. /**
  99442. * Create a new FragmentOutputBlock
  99443. * @param name defines the block name
  99444. */
  99445. constructor(name: string);
  99446. /**
  99447. * Gets the current class name
  99448. * @returns the class name
  99449. */
  99450. getClassName(): string;
  99451. /**
  99452. * Gets the rgba input component
  99453. */
  99454. get rgba(): NodeMaterialConnectionPoint;
  99455. /**
  99456. * Gets the rgb input component
  99457. */
  99458. get rgb(): NodeMaterialConnectionPoint;
  99459. /**
  99460. * Gets the a input component
  99461. */
  99462. get a(): NodeMaterialConnectionPoint;
  99463. protected _buildBlock(state: NodeMaterialBuildState): this;
  99464. }
  99465. }
  99466. declare module BABYLON {
  99467. /**
  99468. * Block used for the particle ramp gradient section
  99469. */
  99470. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99471. /**
  99472. * Create a new ParticleRampGradientBlock
  99473. * @param name defines the block name
  99474. */
  99475. constructor(name: string);
  99476. /**
  99477. * Gets the current class name
  99478. * @returns the class name
  99479. */
  99480. getClassName(): string;
  99481. /**
  99482. * Gets the color input component
  99483. */
  99484. get color(): NodeMaterialConnectionPoint;
  99485. /**
  99486. * Gets the rampColor output component
  99487. */
  99488. get rampColor(): NodeMaterialConnectionPoint;
  99489. /**
  99490. * Initialize the block and prepare the context for build
  99491. * @param state defines the state that will be used for the build
  99492. */
  99493. initialize(state: NodeMaterialBuildState): void;
  99494. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99495. }
  99496. }
  99497. declare module BABYLON {
  99498. /**
  99499. * Block used for the particle blend multiply section
  99500. */
  99501. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99502. /**
  99503. * Create a new ParticleBlendMultiplyBlock
  99504. * @param name defines the block name
  99505. */
  99506. constructor(name: string);
  99507. /**
  99508. * Gets the current class name
  99509. * @returns the class name
  99510. */
  99511. getClassName(): string;
  99512. /**
  99513. * Gets the color input component
  99514. */
  99515. get color(): NodeMaterialConnectionPoint;
  99516. /**
  99517. * Gets the alphaTexture input component
  99518. */
  99519. get alphaTexture(): NodeMaterialConnectionPoint;
  99520. /**
  99521. * Gets the alphaColor input component
  99522. */
  99523. get alphaColor(): NodeMaterialConnectionPoint;
  99524. /**
  99525. * Gets the blendColor output component
  99526. */
  99527. get blendColor(): NodeMaterialConnectionPoint;
  99528. /**
  99529. * Initialize the block and prepare the context for build
  99530. * @param state defines the state that will be used for the build
  99531. */
  99532. initialize(state: NodeMaterialBuildState): void;
  99533. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99534. }
  99535. }
  99536. declare module BABYLON {
  99537. /**
  99538. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99539. */
  99540. export class VectorMergerBlock extends NodeMaterialBlock {
  99541. /**
  99542. * Create a new VectorMergerBlock
  99543. * @param name defines the block name
  99544. */
  99545. constructor(name: string);
  99546. /**
  99547. * Gets the current class name
  99548. * @returns the class name
  99549. */
  99550. getClassName(): string;
  99551. /**
  99552. * Gets the xyz component (input)
  99553. */
  99554. get xyzIn(): NodeMaterialConnectionPoint;
  99555. /**
  99556. * Gets the xy component (input)
  99557. */
  99558. get xyIn(): NodeMaterialConnectionPoint;
  99559. /**
  99560. * Gets the x component (input)
  99561. */
  99562. get x(): NodeMaterialConnectionPoint;
  99563. /**
  99564. * Gets the y component (input)
  99565. */
  99566. get y(): NodeMaterialConnectionPoint;
  99567. /**
  99568. * Gets the z component (input)
  99569. */
  99570. get z(): NodeMaterialConnectionPoint;
  99571. /**
  99572. * Gets the w component (input)
  99573. */
  99574. get w(): NodeMaterialConnectionPoint;
  99575. /**
  99576. * Gets the xyzw component (output)
  99577. */
  99578. get xyzw(): NodeMaterialConnectionPoint;
  99579. /**
  99580. * Gets the xyz component (output)
  99581. */
  99582. get xyzOut(): NodeMaterialConnectionPoint;
  99583. /**
  99584. * Gets the xy component (output)
  99585. */
  99586. get xyOut(): NodeMaterialConnectionPoint;
  99587. /**
  99588. * Gets the xy component (output)
  99589. * @deprecated Please use xyOut instead.
  99590. */
  99591. get xy(): NodeMaterialConnectionPoint;
  99592. /**
  99593. * Gets the xyz component (output)
  99594. * @deprecated Please use xyzOut instead.
  99595. */
  99596. get xyz(): NodeMaterialConnectionPoint;
  99597. protected _buildBlock(state: NodeMaterialBuildState): this;
  99598. }
  99599. }
  99600. declare module BABYLON {
  99601. /**
  99602. * Block used to remap a float from a range to a new one
  99603. */
  99604. export class RemapBlock extends NodeMaterialBlock {
  99605. /**
  99606. * Gets or sets the source range
  99607. */
  99608. sourceRange: Vector2;
  99609. /**
  99610. * Gets or sets the target range
  99611. */
  99612. targetRange: Vector2;
  99613. /**
  99614. * Creates a new RemapBlock
  99615. * @param name defines the block name
  99616. */
  99617. constructor(name: string);
  99618. /**
  99619. * Gets the current class name
  99620. * @returns the class name
  99621. */
  99622. getClassName(): string;
  99623. /**
  99624. * Gets the input component
  99625. */
  99626. get input(): NodeMaterialConnectionPoint;
  99627. /**
  99628. * Gets the source min input component
  99629. */
  99630. get sourceMin(): NodeMaterialConnectionPoint;
  99631. /**
  99632. * Gets the source max input component
  99633. */
  99634. get sourceMax(): NodeMaterialConnectionPoint;
  99635. /**
  99636. * Gets the target min input component
  99637. */
  99638. get targetMin(): NodeMaterialConnectionPoint;
  99639. /**
  99640. * Gets the target max input component
  99641. */
  99642. get targetMax(): NodeMaterialConnectionPoint;
  99643. /**
  99644. * Gets the output component
  99645. */
  99646. get output(): NodeMaterialConnectionPoint;
  99647. protected _buildBlock(state: NodeMaterialBuildState): this;
  99648. protected _dumpPropertiesCode(): string;
  99649. serialize(): any;
  99650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99651. }
  99652. }
  99653. declare module BABYLON {
  99654. /**
  99655. * Block used to multiply 2 values
  99656. */
  99657. export class MultiplyBlock extends NodeMaterialBlock {
  99658. /**
  99659. * Creates a new MultiplyBlock
  99660. * @param name defines the block name
  99661. */
  99662. constructor(name: string);
  99663. /**
  99664. * Gets the current class name
  99665. * @returns the class name
  99666. */
  99667. getClassName(): string;
  99668. /**
  99669. * Gets the left operand input component
  99670. */
  99671. get left(): NodeMaterialConnectionPoint;
  99672. /**
  99673. * Gets the right operand input component
  99674. */
  99675. get right(): NodeMaterialConnectionPoint;
  99676. /**
  99677. * Gets the output component
  99678. */
  99679. get output(): NodeMaterialConnectionPoint;
  99680. protected _buildBlock(state: NodeMaterialBuildState): this;
  99681. }
  99682. }
  99683. declare module BABYLON {
  99684. /** Interface used by value gradients (color, factor, ...) */
  99685. export interface IValueGradient {
  99686. /**
  99687. * Gets or sets the gradient value (between 0 and 1)
  99688. */
  99689. gradient: number;
  99690. }
  99691. /** Class used to store color4 gradient */
  99692. export class ColorGradient implements IValueGradient {
  99693. /**
  99694. * Gets or sets the gradient value (between 0 and 1)
  99695. */
  99696. gradient: number;
  99697. /**
  99698. * Gets or sets first associated color
  99699. */
  99700. color1: Color4;
  99701. /**
  99702. * Gets or sets second associated color
  99703. */
  99704. color2?: Color4 | undefined;
  99705. /**
  99706. * Creates a new color4 gradient
  99707. * @param gradient gets or sets the gradient value (between 0 and 1)
  99708. * @param color1 gets or sets first associated color
  99709. * @param color2 gets or sets first second color
  99710. */
  99711. constructor(
  99712. /**
  99713. * Gets or sets the gradient value (between 0 and 1)
  99714. */
  99715. gradient: number,
  99716. /**
  99717. * Gets or sets first associated color
  99718. */
  99719. color1: Color4,
  99720. /**
  99721. * Gets or sets second associated color
  99722. */
  99723. color2?: Color4 | undefined);
  99724. /**
  99725. * Will get a color picked randomly between color1 and color2.
  99726. * If color2 is undefined then color1 will be used
  99727. * @param result defines the target Color4 to store the result in
  99728. */
  99729. getColorToRef(result: Color4): void;
  99730. }
  99731. /** Class used to store color 3 gradient */
  99732. export class Color3Gradient implements IValueGradient {
  99733. /**
  99734. * Gets or sets the gradient value (between 0 and 1)
  99735. */
  99736. gradient: number;
  99737. /**
  99738. * Gets or sets the associated color
  99739. */
  99740. color: Color3;
  99741. /**
  99742. * Creates a new color3 gradient
  99743. * @param gradient gets or sets the gradient value (between 0 and 1)
  99744. * @param color gets or sets associated color
  99745. */
  99746. constructor(
  99747. /**
  99748. * Gets or sets the gradient value (between 0 and 1)
  99749. */
  99750. gradient: number,
  99751. /**
  99752. * Gets or sets the associated color
  99753. */
  99754. color: Color3);
  99755. }
  99756. /** Class used to store factor gradient */
  99757. export class FactorGradient implements IValueGradient {
  99758. /**
  99759. * Gets or sets the gradient value (between 0 and 1)
  99760. */
  99761. gradient: number;
  99762. /**
  99763. * Gets or sets first associated factor
  99764. */
  99765. factor1: number;
  99766. /**
  99767. * Gets or sets second associated factor
  99768. */
  99769. factor2?: number | undefined;
  99770. /**
  99771. * Creates a new factor gradient
  99772. * @param gradient gets or sets the gradient value (between 0 and 1)
  99773. * @param factor1 gets or sets first associated factor
  99774. * @param factor2 gets or sets second associated factor
  99775. */
  99776. constructor(
  99777. /**
  99778. * Gets or sets the gradient value (between 0 and 1)
  99779. */
  99780. gradient: number,
  99781. /**
  99782. * Gets or sets first associated factor
  99783. */
  99784. factor1: number,
  99785. /**
  99786. * Gets or sets second associated factor
  99787. */
  99788. factor2?: number | undefined);
  99789. /**
  99790. * Will get a number picked randomly between factor1 and factor2.
  99791. * If factor2 is undefined then factor1 will be used
  99792. * @returns the picked number
  99793. */
  99794. getFactor(): number;
  99795. }
  99796. /**
  99797. * Helper used to simplify some generic gradient tasks
  99798. */
  99799. export class GradientHelper {
  99800. /**
  99801. * Gets the current gradient from an array of IValueGradient
  99802. * @param ratio defines the current ratio to get
  99803. * @param gradients defines the array of IValueGradient
  99804. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  99805. */
  99806. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  99807. }
  99808. }
  99809. declare module BABYLON {
  99810. interface ThinEngine {
  99811. /**
  99812. * Creates a raw texture
  99813. * @param data defines the data to store in the texture
  99814. * @param width defines the width of the texture
  99815. * @param height defines the height of the texture
  99816. * @param format defines the format of the data
  99817. * @param generateMipMaps defines if the engine should generate the mip levels
  99818. * @param invertY defines if data must be stored with Y axis inverted
  99819. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  99820. * @param compression defines the compression used (null by default)
  99821. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99822. * @returns the raw texture inside an InternalTexture
  99823. */
  99824. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  99825. /**
  99826. * Update a raw texture
  99827. * @param texture defines the texture to update
  99828. * @param data defines the data to store in the texture
  99829. * @param format defines the format of the data
  99830. * @param invertY defines if data must be stored with Y axis inverted
  99831. */
  99832. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99833. /**
  99834. * Update a raw texture
  99835. * @param texture defines the texture to update
  99836. * @param data defines the data to store in the texture
  99837. * @param format defines the format of the data
  99838. * @param invertY defines if data must be stored with Y axis inverted
  99839. * @param compression defines the compression used (null by default)
  99840. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99841. */
  99842. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  99843. /**
  99844. * Creates a new raw cube texture
  99845. * @param data defines the array of data to use to create each face
  99846. * @param size defines the size of the textures
  99847. * @param format defines the format of the data
  99848. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99849. * @param generateMipMaps defines if the engine should generate the mip levels
  99850. * @param invertY defines if data must be stored with Y axis inverted
  99851. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99852. * @param compression defines the compression used (null by default)
  99853. * @returns the cube texture as an InternalTexture
  99854. */
  99855. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  99856. /**
  99857. * Update a raw cube texture
  99858. * @param texture defines the texture to update
  99859. * @param data defines the data to store
  99860. * @param format defines the data format
  99861. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99862. * @param invertY defines if data must be stored with Y axis inverted
  99863. */
  99864. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  99865. /**
  99866. * Update a raw cube texture
  99867. * @param texture defines the texture to update
  99868. * @param data defines the data to store
  99869. * @param format defines the data format
  99870. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99871. * @param invertY defines if data must be stored with Y axis inverted
  99872. * @param compression defines the compression used (null by default)
  99873. */
  99874. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  99875. /**
  99876. * Update a raw cube texture
  99877. * @param texture defines the texture to update
  99878. * @param data defines the data to store
  99879. * @param format defines the data format
  99880. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  99881. * @param invertY defines if data must be stored with Y axis inverted
  99882. * @param compression defines the compression used (null by default)
  99883. * @param level defines which level of the texture to update
  99884. */
  99885. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  99886. /**
  99887. * Creates a new raw cube texture from a specified url
  99888. * @param url defines the url where the data is located
  99889. * @param scene defines the current scene
  99890. * @param size defines the size of the textures
  99891. * @param format defines the format of the data
  99892. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99893. * @param noMipmap defines if the engine should avoid generating the mip levels
  99894. * @param callback defines a callback used to extract texture data from loaded data
  99895. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  99896. * @param onLoad defines a callback called when texture is loaded
  99897. * @param onError defines a callback called if there is an error
  99898. * @returns the cube texture as an InternalTexture
  99899. */
  99900. 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;
  99901. /**
  99902. * Creates a new raw cube texture from a specified url
  99903. * @param url defines the url where the data is located
  99904. * @param scene defines the current scene
  99905. * @param size defines the size of the textures
  99906. * @param format defines the format of the data
  99907. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  99908. * @param noMipmap defines if the engine should avoid generating the mip levels
  99909. * @param callback defines a callback used to extract texture data from loaded data
  99910. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  99911. * @param onLoad defines a callback called when texture is loaded
  99912. * @param onError defines a callback called if there is an error
  99913. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99914. * @param invertY defines if data must be stored with Y axis inverted
  99915. * @returns the cube texture as an InternalTexture
  99916. */
  99917. 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;
  99918. /**
  99919. * Creates a new raw 3D texture
  99920. * @param data defines the data used to create the texture
  99921. * @param width defines the width of the texture
  99922. * @param height defines the height of the texture
  99923. * @param depth defines the depth of the texture
  99924. * @param format defines the format of the texture
  99925. * @param generateMipMaps defines if the engine must generate mip levels
  99926. * @param invertY defines if data must be stored with Y axis inverted
  99927. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99928. * @param compression defines the compressed used (can be null)
  99929. * @param textureType defines the compressed used (can be null)
  99930. * @returns a new raw 3D texture (stored in an InternalTexture)
  99931. */
  99932. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  99933. /**
  99934. * Update a raw 3D texture
  99935. * @param texture defines the texture to update
  99936. * @param data defines the data to store
  99937. * @param format defines the data format
  99938. * @param invertY defines if data must be stored with Y axis inverted
  99939. */
  99940. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99941. /**
  99942. * Update a raw 3D texture
  99943. * @param texture defines the texture to update
  99944. * @param data defines the data to store
  99945. * @param format defines the data format
  99946. * @param invertY defines if data must be stored with Y axis inverted
  99947. * @param compression defines the used compression (can be null)
  99948. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  99949. */
  99950. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  99951. /**
  99952. * Creates a new raw 2D array texture
  99953. * @param data defines the data used to create the texture
  99954. * @param width defines the width of the texture
  99955. * @param height defines the height of the texture
  99956. * @param depth defines the number of layers of the texture
  99957. * @param format defines the format of the texture
  99958. * @param generateMipMaps defines if the engine must generate mip levels
  99959. * @param invertY defines if data must be stored with Y axis inverted
  99960. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  99961. * @param compression defines the compressed used (can be null)
  99962. * @param textureType defines the compressed used (can be null)
  99963. * @returns a new raw 2D array texture (stored in an InternalTexture)
  99964. */
  99965. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  99966. /**
  99967. * Update a raw 2D array texture
  99968. * @param texture defines the texture to update
  99969. * @param data defines the data to store
  99970. * @param format defines the data format
  99971. * @param invertY defines if data must be stored with Y axis inverted
  99972. */
  99973. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  99974. /**
  99975. * Update a raw 2D array texture
  99976. * @param texture defines the texture to update
  99977. * @param data defines the data to store
  99978. * @param format defines the data format
  99979. * @param invertY defines if data must be stored with Y axis inverted
  99980. * @param compression defines the used compression (can be null)
  99981. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  99982. */
  99983. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  99984. }
  99985. }
  99986. declare module BABYLON {
  99987. /**
  99988. * Raw texture can help creating a texture directly from an array of data.
  99989. * This can be super useful if you either get the data from an uncompressed source or
  99990. * if you wish to create your texture pixel by pixel.
  99991. */
  99992. export class RawTexture extends Texture {
  99993. /**
  99994. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  99995. */
  99996. format: number;
  99997. /**
  99998. * Instantiates a new RawTexture.
  99999. * Raw texture can help creating a texture directly from an array of data.
  100000. * This can be super useful if you either get the data from an uncompressed source or
  100001. * if you wish to create your texture pixel by pixel.
  100002. * @param data define the array of data to use to create the texture
  100003. * @param width define the width of the texture
  100004. * @param height define the height of the texture
  100005. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  100006. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100007. * @param generateMipMaps define whether mip maps should be generated or not
  100008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  100009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  100010. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  100011. */
  100012. constructor(data: ArrayBufferView, width: number, height: number,
  100013. /**
  100014. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  100015. */
  100016. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  100017. /**
  100018. * Updates the texture underlying data.
  100019. * @param data Define the new data of the texture
  100020. */
  100021. update(data: ArrayBufferView): void;
  100022. /**
  100023. * Creates a luminance texture from some data.
  100024. * @param data Define the texture data
  100025. * @param width Define the width of the texture
  100026. * @param height Define the height of the texture
  100027. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100028. * @param generateMipMaps Define whether or not to create mip maps for the texture
  100029. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  100030. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  100031. * @returns the luminance texture
  100032. */
  100033. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  100034. /**
  100035. * Creates a luminance alpha texture from some data.
  100036. * @param data Define the texture data
  100037. * @param width Define the width of the texture
  100038. * @param height Define the height of the texture
  100039. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100040. * @param generateMipMaps Define whether or not to create mip maps for the texture
  100041. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  100042. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  100043. * @returns the luminance alpha texture
  100044. */
  100045. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  100046. /**
  100047. * Creates an alpha texture from some data.
  100048. * @param data Define the texture data
  100049. * @param width Define the width of the texture
  100050. * @param height Define the height of the texture
  100051. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100052. * @param generateMipMaps Define whether or not to create mip maps for the texture
  100053. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  100054. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  100055. * @returns the alpha texture
  100056. */
  100057. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  100058. /**
  100059. * Creates a RGB texture from some data.
  100060. * @param data Define the texture data
  100061. * @param width Define the width of the texture
  100062. * @param height Define the height of the texture
  100063. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100064. * @param generateMipMaps Define whether or not to create mip maps for the texture
  100065. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  100066. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  100067. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  100068. * @returns the RGB alpha texture
  100069. */
  100070. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  100071. /**
  100072. * Creates a RGBA texture from some data.
  100073. * @param data Define the texture data
  100074. * @param width Define the width of the texture
  100075. * @param height Define the height of the texture
  100076. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100077. * @param generateMipMaps Define whether or not to create mip maps for the texture
  100078. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  100079. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  100080. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  100081. * @returns the RGBA texture
  100082. */
  100083. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  100084. /**
  100085. * Creates a R texture from some data.
  100086. * @param data Define the texture data
  100087. * @param width Define the width of the texture
  100088. * @param height Define the height of the texture
  100089. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100090. * @param generateMipMaps Define whether or not to create mip maps for the texture
  100091. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  100092. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  100093. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  100094. * @returns the R texture
  100095. */
  100096. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  100097. }
  100098. }
  100099. declare module BABYLON {
  100100. interface ThinEngine {
  100101. /**
  100102. * Update a dynamic index buffer
  100103. * @param indexBuffer defines the target index buffer
  100104. * @param indices defines the data to update
  100105. * @param offset defines the offset in the target index buffer where update should start
  100106. */
  100107. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100108. /**
  100109. * Updates a dynamic vertex buffer.
  100110. * @param vertexBuffer the vertex buffer to update
  100111. * @param data the data used to update the vertex buffer
  100112. * @param byteOffset the byte offset of the data
  100113. * @param byteLength the byte length of the data
  100114. */
  100115. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100116. }
  100117. }
  100118. declare module BABYLON {
  100119. interface AbstractScene {
  100120. /**
  100121. * The list of procedural textures added to the scene
  100122. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  100123. */
  100124. proceduralTextures: Array<ProceduralTexture>;
  100125. }
  100126. /**
  100127. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  100128. * in a given scene.
  100129. */
  100130. export class ProceduralTextureSceneComponent implements ISceneComponent {
  100131. /**
  100132. * The component name helpful to identify the component in the list of scene components.
  100133. */
  100134. readonly name: string;
  100135. /**
  100136. * The scene the component belongs to.
  100137. */
  100138. scene: Scene;
  100139. /**
  100140. * Creates a new instance of the component for the given scene
  100141. * @param scene Defines the scene to register the component in
  100142. */
  100143. constructor(scene: Scene);
  100144. /**
  100145. * Registers the component in a given scene
  100146. */
  100147. register(): void;
  100148. /**
  100149. * Rebuilds the elements related to this component in case of
  100150. * context lost for instance.
  100151. */
  100152. rebuild(): void;
  100153. /**
  100154. * Disposes the component and the associated resources.
  100155. */
  100156. dispose(): void;
  100157. private _beforeClear;
  100158. }
  100159. }
  100160. declare module BABYLON {
  100161. interface ThinEngine {
  100162. /**
  100163. * Creates a new render target cube texture
  100164. * @param size defines the size of the texture
  100165. * @param options defines the options used to create the texture
  100166. * @returns a new render target cube texture stored in an InternalTexture
  100167. */
  100168. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  100169. }
  100170. }
  100171. declare module BABYLON {
  100172. /** @hidden */
  100173. export var proceduralVertexShader: {
  100174. name: string;
  100175. shader: string;
  100176. };
  100177. }
  100178. declare module BABYLON {
  100179. /**
  100180. * 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.
  100181. * This is the base class of any Procedural texture and contains most of the shareable code.
  100182. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  100183. */
  100184. export class ProceduralTexture extends Texture {
  100185. /**
  100186. * Define if the texture is enabled or not (disabled texture will not render)
  100187. */
  100188. isEnabled: boolean;
  100189. /**
  100190. * Define if the texture must be cleared before rendering (default is true)
  100191. */
  100192. autoClear: boolean;
  100193. /**
  100194. * Callback called when the texture is generated
  100195. */
  100196. onGenerated: () => void;
  100197. /**
  100198. * Event raised when the texture is generated
  100199. */
  100200. onGeneratedObservable: Observable<ProceduralTexture>;
  100201. /**
  100202. * Event raised before the texture is generated
  100203. */
  100204. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  100205. /**
  100206. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  100207. */
  100208. nodeMaterialSource: Nullable<NodeMaterial>;
  100209. /** @hidden */
  100210. _generateMipMaps: boolean;
  100211. /** @hidden **/
  100212. _effect: Effect;
  100213. /** @hidden */
  100214. _textures: {
  100215. [key: string]: Texture;
  100216. };
  100217. /** @hidden */
  100218. protected _fallbackTexture: Nullable<Texture>;
  100219. private _size;
  100220. private _textureType;
  100221. private _currentRefreshId;
  100222. private _frameId;
  100223. private _refreshRate;
  100224. private _vertexBuffers;
  100225. private _indexBuffer;
  100226. private _uniforms;
  100227. private _samplers;
  100228. private _fragment;
  100229. private _floats;
  100230. private _ints;
  100231. private _floatsArrays;
  100232. private _colors3;
  100233. private _colors4;
  100234. private _vectors2;
  100235. private _vectors3;
  100236. private _matrices;
  100237. private _fallbackTextureUsed;
  100238. private _fullEngine;
  100239. private _cachedDefines;
  100240. private _contentUpdateId;
  100241. private _contentData;
  100242. /**
  100243. * Instantiates a new procedural texture.
  100244. * 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.
  100245. * This is the base class of any Procedural texture and contains most of the shareable code.
  100246. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  100247. * @param name Define the name of the texture
  100248. * @param size Define the size of the texture to create
  100249. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  100250. * @param scene Define the scene the texture belongs to
  100251. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  100252. * @param generateMipMaps Define if the texture should creates mip maps or not
  100253. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  100254. * @param textureType The FBO internal texture type
  100255. */
  100256. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  100257. /**
  100258. * The effect that is created when initializing the post process.
  100259. * @returns The created effect corresponding the the postprocess.
  100260. */
  100261. getEffect(): Effect;
  100262. /**
  100263. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  100264. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  100265. */
  100266. getContent(): Nullable<Promise<ArrayBufferView>>;
  100267. private _createIndexBuffer;
  100268. /** @hidden */
  100269. _rebuild(): void;
  100270. /**
  100271. * Resets the texture in order to recreate its associated resources.
  100272. * This can be called in case of context loss
  100273. */
  100274. reset(): void;
  100275. protected _getDefines(): string;
  100276. /**
  100277. * Is the texture ready to be used ? (rendered at least once)
  100278. * @returns true if ready, otherwise, false.
  100279. */
  100280. isReady(): boolean;
  100281. /**
  100282. * Resets the refresh counter of the texture and start bak from scratch.
  100283. * Could be useful to regenerate the texture if it is setup to render only once.
  100284. */
  100285. resetRefreshCounter(): void;
  100286. /**
  100287. * Set the fragment shader to use in order to render the texture.
  100288. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  100289. */
  100290. setFragment(fragment: any): void;
  100291. /**
  100292. * Define the refresh rate of the texture or the rendering frequency.
  100293. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  100294. */
  100295. get refreshRate(): number;
  100296. set refreshRate(value: number);
  100297. /** @hidden */
  100298. _shouldRender(): boolean;
  100299. /**
  100300. * Get the size the texture is rendering at.
  100301. * @returns the size (on cube texture it is always squared)
  100302. */
  100303. getRenderSize(): RenderTargetTextureSize;
  100304. /**
  100305. * Resize the texture to new value.
  100306. * @param size Define the new size the texture should have
  100307. * @param generateMipMaps Define whether the new texture should create mip maps
  100308. */
  100309. resize(size: number, generateMipMaps: boolean): void;
  100310. private _checkUniform;
  100311. /**
  100312. * Set a texture in the shader program used to render.
  100313. * @param name Define the name of the uniform samplers as defined in the shader
  100314. * @param texture Define the texture to bind to this sampler
  100315. * @return the texture itself allowing "fluent" like uniform updates
  100316. */
  100317. setTexture(name: string, texture: Texture): ProceduralTexture;
  100318. /**
  100319. * Set a float in the shader.
  100320. * @param name Define the name of the uniform as defined in the shader
  100321. * @param value Define the value to give to the uniform
  100322. * @return the texture itself allowing "fluent" like uniform updates
  100323. */
  100324. setFloat(name: string, value: number): ProceduralTexture;
  100325. /**
  100326. * Set a int in the shader.
  100327. * @param name Define the name of the uniform as defined in the shader
  100328. * @param value Define the value to give to the uniform
  100329. * @return the texture itself allowing "fluent" like uniform updates
  100330. */
  100331. setInt(name: string, value: number): ProceduralTexture;
  100332. /**
  100333. * Set an array of floats in the shader.
  100334. * @param name Define the name of the uniform as defined in the shader
  100335. * @param value Define the value to give to the uniform
  100336. * @return the texture itself allowing "fluent" like uniform updates
  100337. */
  100338. setFloats(name: string, value: number[]): ProceduralTexture;
  100339. /**
  100340. * Set a vec3 in the shader from a Color3.
  100341. * @param name Define the name of the uniform as defined in the shader
  100342. * @param value Define the value to give to the uniform
  100343. * @return the texture itself allowing "fluent" like uniform updates
  100344. */
  100345. setColor3(name: string, value: Color3): ProceduralTexture;
  100346. /**
  100347. * Set a vec4 in the shader from a Color4.
  100348. * @param name Define the name of the uniform as defined in the shader
  100349. * @param value Define the value to give to the uniform
  100350. * @return the texture itself allowing "fluent" like uniform updates
  100351. */
  100352. setColor4(name: string, value: Color4): ProceduralTexture;
  100353. /**
  100354. * Set a vec2 in the shader from a Vector2.
  100355. * @param name Define the name of the uniform as defined in the shader
  100356. * @param value Define the value to give to the uniform
  100357. * @return the texture itself allowing "fluent" like uniform updates
  100358. */
  100359. setVector2(name: string, value: Vector2): ProceduralTexture;
  100360. /**
  100361. * Set a vec3 in the shader from a Vector3.
  100362. * @param name Define the name of the uniform as defined in the shader
  100363. * @param value Define the value to give to the uniform
  100364. * @return the texture itself allowing "fluent" like uniform updates
  100365. */
  100366. setVector3(name: string, value: Vector3): ProceduralTexture;
  100367. /**
  100368. * Set a mat4 in the shader from a MAtrix.
  100369. * @param name Define the name of the uniform as defined in the shader
  100370. * @param value Define the value to give to the uniform
  100371. * @return the texture itself allowing "fluent" like uniform updates
  100372. */
  100373. setMatrix(name: string, value: Matrix): ProceduralTexture;
  100374. /**
  100375. * Render the texture to its associated render target.
  100376. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  100377. */
  100378. render(useCameraPostProcess?: boolean): void;
  100379. /**
  100380. * Clone the texture.
  100381. * @returns the cloned texture
  100382. */
  100383. clone(): ProceduralTexture;
  100384. /**
  100385. * Dispose the texture and release its associated resources.
  100386. */
  100387. dispose(): void;
  100388. }
  100389. }
  100390. declare module BABYLON {
  100391. /**
  100392. * This represents the base class for particle system in Babylon.
  100393. * 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.
  100394. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  100395. * @example https://doc.babylonjs.com/babylon101/particles
  100396. */
  100397. export class BaseParticleSystem {
  100398. /**
  100399. * Source color is added to the destination color without alpha affecting the result
  100400. */
  100401. static BLENDMODE_ONEONE: number;
  100402. /**
  100403. * Blend current color and particle color using particle’s alpha
  100404. */
  100405. static BLENDMODE_STANDARD: number;
  100406. /**
  100407. * Add current color and particle color multiplied by particle’s alpha
  100408. */
  100409. static BLENDMODE_ADD: number;
  100410. /**
  100411. * Multiply current color with particle color
  100412. */
  100413. static BLENDMODE_MULTIPLY: number;
  100414. /**
  100415. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  100416. */
  100417. static BLENDMODE_MULTIPLYADD: number;
  100418. /**
  100419. * List of animations used by the particle system.
  100420. */
  100421. animations: Animation[];
  100422. /**
  100423. * Gets or sets the unique id of the particle system
  100424. */
  100425. uniqueId: number;
  100426. /**
  100427. * The id of the Particle system.
  100428. */
  100429. id: string;
  100430. /**
  100431. * The friendly name of the Particle system.
  100432. */
  100433. name: string;
  100434. /**
  100435. * Snippet ID if the particle system was created from the snippet server
  100436. */
  100437. snippetId: string;
  100438. /**
  100439. * The rendering group used by the Particle system to chose when to render.
  100440. */
  100441. renderingGroupId: number;
  100442. /**
  100443. * The emitter represents the Mesh or position we are attaching the particle system to.
  100444. */
  100445. emitter: Nullable<AbstractMesh | Vector3>;
  100446. /**
  100447. * The maximum number of particles to emit per frame
  100448. */
  100449. emitRate: number;
  100450. /**
  100451. * If you want to launch only a few particles at once, that can be done, as well.
  100452. */
  100453. manualEmitCount: number;
  100454. /**
  100455. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  100456. */
  100457. updateSpeed: number;
  100458. /**
  100459. * The amount of time the particle system is running (depends of the overall update speed).
  100460. */
  100461. targetStopDuration: number;
  100462. /**
  100463. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  100464. */
  100465. disposeOnStop: boolean;
  100466. /**
  100467. * Minimum power of emitting particles.
  100468. */
  100469. minEmitPower: number;
  100470. /**
  100471. * Maximum power of emitting particles.
  100472. */
  100473. maxEmitPower: number;
  100474. /**
  100475. * Minimum life time of emitting particles.
  100476. */
  100477. minLifeTime: number;
  100478. /**
  100479. * Maximum life time of emitting particles.
  100480. */
  100481. maxLifeTime: number;
  100482. /**
  100483. * Minimum Size of emitting particles.
  100484. */
  100485. minSize: number;
  100486. /**
  100487. * Maximum Size of emitting particles.
  100488. */
  100489. maxSize: number;
  100490. /**
  100491. * Minimum scale of emitting particles on X axis.
  100492. */
  100493. minScaleX: number;
  100494. /**
  100495. * Maximum scale of emitting particles on X axis.
  100496. */
  100497. maxScaleX: number;
  100498. /**
  100499. * Minimum scale of emitting particles on Y axis.
  100500. */
  100501. minScaleY: number;
  100502. /**
  100503. * Maximum scale of emitting particles on Y axis.
  100504. */
  100505. maxScaleY: number;
  100506. /**
  100507. * Gets or sets the minimal initial rotation in radians.
  100508. */
  100509. minInitialRotation: number;
  100510. /**
  100511. * Gets or sets the maximal initial rotation in radians.
  100512. */
  100513. maxInitialRotation: number;
  100514. /**
  100515. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  100516. */
  100517. minAngularSpeed: number;
  100518. /**
  100519. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  100520. */
  100521. maxAngularSpeed: number;
  100522. /**
  100523. * The texture used to render each particle. (this can be a spritesheet)
  100524. */
  100525. particleTexture: Nullable<BaseTexture>;
  100526. /**
  100527. * The layer mask we are rendering the particles through.
  100528. */
  100529. layerMask: number;
  100530. /**
  100531. * This can help using your own shader to render the particle system.
  100532. * The according effect will be created
  100533. */
  100534. customShader: any;
  100535. /**
  100536. * By default particle system starts as soon as they are created. This prevents the
  100537. * automatic start to happen and let you decide when to start emitting particles.
  100538. */
  100539. preventAutoStart: boolean;
  100540. protected _rootUrl: string;
  100541. private _noiseTexture;
  100542. /**
  100543. * Gets or sets a texture used to add random noise to particle positions
  100544. */
  100545. get noiseTexture(): Nullable<ProceduralTexture>;
  100546. set noiseTexture(value: Nullable<ProceduralTexture>);
  100547. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  100548. noiseStrength: Vector3;
  100549. /**
  100550. * Callback triggered when the particle animation is ending.
  100551. */
  100552. onAnimationEnd: Nullable<() => void>;
  100553. /**
  100554. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  100555. */
  100556. blendMode: number;
  100557. /**
  100558. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  100559. * to override the particles.
  100560. */
  100561. forceDepthWrite: boolean;
  100562. /** 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 */
  100563. preWarmCycles: number;
  100564. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  100565. preWarmStepOffset: number;
  100566. /**
  100567. * 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)
  100568. */
  100569. spriteCellChangeSpeed: number;
  100570. /**
  100571. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  100572. */
  100573. startSpriteCellID: number;
  100574. /**
  100575. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  100576. */
  100577. endSpriteCellID: number;
  100578. /**
  100579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  100580. */
  100581. spriteCellWidth: number;
  100582. /**
  100583. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  100584. */
  100585. spriteCellHeight: number;
  100586. /**
  100587. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  100588. */
  100589. spriteRandomStartCell: boolean;
  100590. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  100591. translationPivot: Vector2;
  100592. /** @hidden */
  100593. protected _isAnimationSheetEnabled: boolean;
  100594. /**
  100595. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  100596. */
  100597. beginAnimationOnStart: boolean;
  100598. /**
  100599. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  100600. */
  100601. beginAnimationFrom: number;
  100602. /**
  100603. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  100604. */
  100605. beginAnimationTo: number;
  100606. /**
  100607. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  100608. */
  100609. beginAnimationLoop: boolean;
  100610. /**
  100611. * Gets or sets a world offset applied to all particles
  100612. */
  100613. worldOffset: Vector3;
  100614. /**
  100615. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  100616. */
  100617. get isAnimationSheetEnabled(): boolean;
  100618. set isAnimationSheetEnabled(value: boolean);
  100619. /**
  100620. * Get hosting scene
  100621. * @returns the scene
  100622. */
  100623. getScene(): Nullable<Scene>;
  100624. /**
  100625. * You can use gravity if you want to give an orientation to your particles.
  100626. */
  100627. gravity: Vector3;
  100628. protected _colorGradients: Nullable<Array<ColorGradient>>;
  100629. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  100630. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  100631. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  100632. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  100633. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  100634. protected _dragGradients: Nullable<Array<FactorGradient>>;
  100635. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  100636. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  100637. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  100638. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  100639. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  100640. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  100641. /**
  100642. * Defines the delay in milliseconds before starting the system (0 by default)
  100643. */
  100644. startDelay: number;
  100645. /**
  100646. * Gets the current list of drag gradients.
  100647. * You must use addDragGradient and removeDragGradient to update this list
  100648. * @returns the list of drag gradients
  100649. */
  100650. getDragGradients(): Nullable<Array<FactorGradient>>;
  100651. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  100652. limitVelocityDamping: number;
  100653. /**
  100654. * Gets the current list of limit velocity gradients.
  100655. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  100656. * @returns the list of limit velocity gradients
  100657. */
  100658. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  100659. /**
  100660. * Gets the current list of color gradients.
  100661. * You must use addColorGradient and removeColorGradient to update this list
  100662. * @returns the list of color gradients
  100663. */
  100664. getColorGradients(): Nullable<Array<ColorGradient>>;
  100665. /**
  100666. * Gets the current list of size gradients.
  100667. * You must use addSizeGradient and removeSizeGradient to update this list
  100668. * @returns the list of size gradients
  100669. */
  100670. getSizeGradients(): Nullable<Array<FactorGradient>>;
  100671. /**
  100672. * Gets the current list of color remap gradients.
  100673. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  100674. * @returns the list of color remap gradients
  100675. */
  100676. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  100677. /**
  100678. * Gets the current list of alpha remap gradients.
  100679. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  100680. * @returns the list of alpha remap gradients
  100681. */
  100682. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  100683. /**
  100684. * Gets the current list of life time gradients.
  100685. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  100686. * @returns the list of life time gradients
  100687. */
  100688. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  100689. /**
  100690. * Gets the current list of angular speed gradients.
  100691. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  100692. * @returns the list of angular speed gradients
  100693. */
  100694. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  100695. /**
  100696. * Gets the current list of velocity gradients.
  100697. * You must use addVelocityGradient and removeVelocityGradient to update this list
  100698. * @returns the list of velocity gradients
  100699. */
  100700. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  100701. /**
  100702. * Gets the current list of start size gradients.
  100703. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  100704. * @returns the list of start size gradients
  100705. */
  100706. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  100707. /**
  100708. * Gets the current list of emit rate gradients.
  100709. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  100710. * @returns the list of emit rate gradients
  100711. */
  100712. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  100713. /**
  100714. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100715. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100716. */
  100717. get direction1(): Vector3;
  100718. set direction1(value: Vector3);
  100719. /**
  100720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100721. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100722. */
  100723. get direction2(): Vector3;
  100724. set direction2(value: Vector3);
  100725. /**
  100726. * 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.
  100727. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100728. */
  100729. get minEmitBox(): Vector3;
  100730. set minEmitBox(value: Vector3);
  100731. /**
  100732. * 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.
  100733. * This only works when particleEmitterTyps is a BoxParticleEmitter
  100734. */
  100735. get maxEmitBox(): Vector3;
  100736. set maxEmitBox(value: Vector3);
  100737. /**
  100738. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  100739. */
  100740. color1: Color4;
  100741. /**
  100742. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  100743. */
  100744. color2: Color4;
  100745. /**
  100746. * Color the particle will have at the end of its lifetime
  100747. */
  100748. colorDead: Color4;
  100749. /**
  100750. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  100751. */
  100752. textureMask: Color4;
  100753. /**
  100754. * The particle emitter type defines the emitter used by the particle system.
  100755. * It can be for example box, sphere, or cone...
  100756. */
  100757. particleEmitterType: IParticleEmitterType;
  100758. /** @hidden */
  100759. _isSubEmitter: boolean;
  100760. /**
  100761. * Gets or sets the billboard mode to use when isBillboardBased = true.
  100762. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  100763. */
  100764. billboardMode: number;
  100765. protected _isBillboardBased: boolean;
  100766. /**
  100767. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  100768. */
  100769. get isBillboardBased(): boolean;
  100770. set isBillboardBased(value: boolean);
  100771. /**
  100772. * The scene the particle system belongs to.
  100773. */
  100774. protected _scene: Nullable<Scene>;
  100775. /**
  100776. * The engine the particle system belongs to.
  100777. */
  100778. protected _engine: ThinEngine;
  100779. /**
  100780. * Local cache of defines for image processing.
  100781. */
  100782. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  100783. /**
  100784. * Default configuration related to image processing available in the standard Material.
  100785. */
  100786. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100787. /**
  100788. * Gets the image processing configuration used either in this material.
  100789. */
  100790. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  100791. /**
  100792. * Sets the Default image processing configuration used either in the this material.
  100793. *
  100794. * If sets to null, the scene one is in use.
  100795. */
  100796. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  100797. /**
  100798. * Attaches a new image processing configuration to the Standard Material.
  100799. * @param configuration
  100800. */
  100801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100802. /** @hidden */
  100803. protected _reset(): void;
  100804. /** @hidden */
  100805. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  100806. /**
  100807. * Instantiates a particle system.
  100808. * 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.
  100809. * @param name The name of the particle system
  100810. */
  100811. constructor(name: string);
  100812. /**
  100813. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  100814. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  100815. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  100816. * @returns the emitter
  100817. */
  100818. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  100819. /**
  100820. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  100821. * @param radius The radius of the hemisphere to emit from
  100822. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  100823. * @returns the emitter
  100824. */
  100825. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  100826. /**
  100827. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  100828. * @param radius The radius of the sphere to emit from
  100829. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  100830. * @returns the emitter
  100831. */
  100832. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  100833. /**
  100834. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  100835. * @param radius The radius of the sphere to emit from
  100836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  100837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  100838. * @returns the emitter
  100839. */
  100840. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  100841. /**
  100842. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  100843. * @param radius The radius of the emission cylinder
  100844. * @param height The height of the emission cylinder
  100845. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  100846. * @param directionRandomizer How much to randomize the particle direction [0-1]
  100847. * @returns the emitter
  100848. */
  100849. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  100850. /**
  100851. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  100852. * @param radius The radius of the cylinder to emit from
  100853. * @param height The height of the emission cylinder
  100854. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100855. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  100856. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  100857. * @returns the emitter
  100858. */
  100859. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  100860. /**
  100861. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  100862. * @param radius The radius of the cone to emit from
  100863. * @param angle The base angle of the cone
  100864. * @returns the emitter
  100865. */
  100866. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  100867. /**
  100868. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  100869. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  100870. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  100871. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  100872. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  100873. * @returns the emitter
  100874. */
  100875. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  100876. }
  100877. }
  100878. declare module BABYLON {
  100879. /**
  100880. * Type of sub emitter
  100881. */
  100882. export enum SubEmitterType {
  100883. /**
  100884. * Attached to the particle over it's lifetime
  100885. */
  100886. ATTACHED = 0,
  100887. /**
  100888. * Created when the particle dies
  100889. */
  100890. END = 1
  100891. }
  100892. /**
  100893. * Sub emitter class used to emit particles from an existing particle
  100894. */
  100895. export class SubEmitter {
  100896. /**
  100897. * the particle system to be used by the sub emitter
  100898. */
  100899. particleSystem: ParticleSystem;
  100900. /**
  100901. * Type of the submitter (Default: END)
  100902. */
  100903. type: SubEmitterType;
  100904. /**
  100905. * 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)
  100906. * Note: This only is supported when using an emitter of type Mesh
  100907. */
  100908. inheritDirection: boolean;
  100909. /**
  100910. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  100911. */
  100912. inheritedVelocityAmount: number;
  100913. /**
  100914. * Creates a sub emitter
  100915. * @param particleSystem the particle system to be used by the sub emitter
  100916. */
  100917. constructor(
  100918. /**
  100919. * the particle system to be used by the sub emitter
  100920. */
  100921. particleSystem: ParticleSystem);
  100922. /**
  100923. * Clones the sub emitter
  100924. * @returns the cloned sub emitter
  100925. */
  100926. clone(): SubEmitter;
  100927. /**
  100928. * Serialize current object to a JSON object
  100929. * @returns the serialized object
  100930. */
  100931. serialize(): any;
  100932. /** @hidden */
  100933. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  100934. /**
  100935. * Creates a new SubEmitter from a serialized JSON version
  100936. * @param serializationObject defines the JSON object to read from
  100937. * @param sceneOrEngine defines the hosting scene or the hosting engine
  100938. * @param rootUrl defines the rootUrl for data loading
  100939. * @returns a new SubEmitter
  100940. */
  100941. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  100942. /** Release associated resources */
  100943. dispose(): void;
  100944. }
  100945. }
  100946. declare module BABYLON {
  100947. /** @hidden */
  100948. export var clipPlaneFragmentDeclaration: {
  100949. name: string;
  100950. shader: string;
  100951. };
  100952. }
  100953. declare module BABYLON {
  100954. /** @hidden */
  100955. export var imageProcessingDeclaration: {
  100956. name: string;
  100957. shader: string;
  100958. };
  100959. }
  100960. declare module BABYLON {
  100961. /** @hidden */
  100962. export var imageProcessingFunctions: {
  100963. name: string;
  100964. shader: string;
  100965. };
  100966. }
  100967. declare module BABYLON {
  100968. /** @hidden */
  100969. export var clipPlaneFragment: {
  100970. name: string;
  100971. shader: string;
  100972. };
  100973. }
  100974. declare module BABYLON {
  100975. /** @hidden */
  100976. export var particlesPixelShader: {
  100977. name: string;
  100978. shader: string;
  100979. };
  100980. }
  100981. declare module BABYLON {
  100982. /** @hidden */
  100983. export var clipPlaneVertexDeclaration: {
  100984. name: string;
  100985. shader: string;
  100986. };
  100987. }
  100988. declare module BABYLON {
  100989. /** @hidden */
  100990. export var clipPlaneVertex: {
  100991. name: string;
  100992. shader: string;
  100993. };
  100994. }
  100995. declare module BABYLON {
  100996. /** @hidden */
  100997. export var particlesVertexShader: {
  100998. name: string;
  100999. shader: string;
  101000. };
  101001. }
  101002. declare module BABYLON {
  101003. /**
  101004. * Interface used to define entities containing multiple clip planes
  101005. */
  101006. export interface IClipPlanesHolder {
  101007. /**
  101008. * Gets or sets the active clipplane 1
  101009. */
  101010. clipPlane: Nullable<Plane>;
  101011. /**
  101012. * Gets or sets the active clipplane 2
  101013. */
  101014. clipPlane2: Nullable<Plane>;
  101015. /**
  101016. * Gets or sets the active clipplane 3
  101017. */
  101018. clipPlane3: Nullable<Plane>;
  101019. /**
  101020. * Gets or sets the active clipplane 4
  101021. */
  101022. clipPlane4: Nullable<Plane>;
  101023. /**
  101024. * Gets or sets the active clipplane 5
  101025. */
  101026. clipPlane5: Nullable<Plane>;
  101027. /**
  101028. * Gets or sets the active clipplane 6
  101029. */
  101030. clipPlane6: Nullable<Plane>;
  101031. }
  101032. }
  101033. declare module BABYLON {
  101034. /**
  101035. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  101036. *
  101037. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  101038. *
  101039. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101040. */
  101041. export class ThinMaterialHelper {
  101042. /**
  101043. * Binds the clip plane information from the holder to the effect.
  101044. * @param effect The effect we are binding the data to
  101045. * @param holder The entity containing the clip plane information
  101046. */
  101047. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  101048. }
  101049. }
  101050. declare module BABYLON {
  101051. interface ThinEngine {
  101052. /**
  101053. * Sets alpha constants used by some alpha blending modes
  101054. * @param r defines the red component
  101055. * @param g defines the green component
  101056. * @param b defines the blue component
  101057. * @param a defines the alpha component
  101058. */
  101059. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  101060. /**
  101061. * Sets the current alpha mode
  101062. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  101063. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  101064. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101065. */
  101066. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101067. /**
  101068. * Gets the current alpha mode
  101069. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101070. * @returns the current alpha mode
  101071. */
  101072. getAlphaMode(): number;
  101073. /**
  101074. * Sets the current alpha equation
  101075. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  101076. */
  101077. setAlphaEquation(equation: number): void;
  101078. /**
  101079. * Gets the current alpha equation.
  101080. * @returns the current alpha equation
  101081. */
  101082. getAlphaEquation(): number;
  101083. }
  101084. }
  101085. declare module BABYLON {
  101086. /**
  101087. * This represents a particle system in Babylon.
  101088. * 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.
  101089. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  101090. * @example https://doc.babylonjs.com/babylon101/particles
  101091. */
  101092. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  101093. /**
  101094. * Billboard mode will only apply to Y axis
  101095. */
  101096. static readonly BILLBOARDMODE_Y: number;
  101097. /**
  101098. * Billboard mode will apply to all axes
  101099. */
  101100. static readonly BILLBOARDMODE_ALL: number;
  101101. /**
  101102. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  101103. */
  101104. static readonly BILLBOARDMODE_STRETCHED: number;
  101105. /**
  101106. * This function can be defined to provide custom update for active particles.
  101107. * This function will be called instead of regular update (age, position, color, etc.).
  101108. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  101109. */
  101110. updateFunction: (particles: Particle[]) => void;
  101111. private _emitterWorldMatrix;
  101112. /**
  101113. * This function can be defined to specify initial direction for every new particle.
  101114. * It by default use the emitterType defined function
  101115. */
  101116. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  101117. /**
  101118. * This function can be defined to specify initial position for every new particle.
  101119. * It by default use the emitterType defined function
  101120. */
  101121. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  101122. /**
  101123. * @hidden
  101124. */
  101125. _inheritedVelocityOffset: Vector3;
  101126. /**
  101127. * An event triggered when the system is disposed
  101128. */
  101129. onDisposeObservable: Observable<IParticleSystem>;
  101130. /**
  101131. * An event triggered when the system is stopped
  101132. */
  101133. onStoppedObservable: Observable<IParticleSystem>;
  101134. private _onDisposeObserver;
  101135. /**
  101136. * Sets a callback that will be triggered when the system is disposed
  101137. */
  101138. set onDispose(callback: () => void);
  101139. private _particles;
  101140. private _epsilon;
  101141. private _capacity;
  101142. private _stockParticles;
  101143. private _newPartsExcess;
  101144. private _vertexData;
  101145. private _vertexBuffer;
  101146. private _vertexBuffers;
  101147. private _spriteBuffer;
  101148. private _indexBuffer;
  101149. private _effect;
  101150. private _customEffect;
  101151. private _cachedDefines;
  101152. private _scaledColorStep;
  101153. private _colorDiff;
  101154. private _scaledDirection;
  101155. private _scaledGravity;
  101156. private _currentRenderId;
  101157. private _alive;
  101158. private _useInstancing;
  101159. private _vertexArrayObject;
  101160. private _started;
  101161. private _stopped;
  101162. private _actualFrame;
  101163. private _scaledUpdateSpeed;
  101164. private _vertexBufferSize;
  101165. /** @hidden */
  101166. _currentEmitRateGradient: Nullable<FactorGradient>;
  101167. /** @hidden */
  101168. _currentEmitRate1: number;
  101169. /** @hidden */
  101170. _currentEmitRate2: number;
  101171. /** @hidden */
  101172. _currentStartSizeGradient: Nullable<FactorGradient>;
  101173. /** @hidden */
  101174. _currentStartSize1: number;
  101175. /** @hidden */
  101176. _currentStartSize2: number;
  101177. private readonly _rawTextureWidth;
  101178. private _rampGradientsTexture;
  101179. private _useRampGradients;
  101180. /** Gets or sets a matrix to use to compute projection */
  101181. defaultProjectionMatrix: Matrix;
  101182. /** Gets or sets a matrix to use to compute view */
  101183. defaultViewMatrix: Matrix;
  101184. /** Gets or sets a boolean indicating that ramp gradients must be used
  101185. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  101186. */
  101187. get useRampGradients(): boolean;
  101188. set useRampGradients(value: boolean);
  101189. /**
  101190. * 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.
  101191. * 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: [])
  101192. */
  101193. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  101194. private _subEmitters;
  101195. /**
  101196. * @hidden
  101197. * If the particle systems emitter should be disposed when the particle system is disposed
  101198. */
  101199. _disposeEmitterOnDispose: boolean;
  101200. /**
  101201. * The current active Sub-systems, this property is used by the root particle system only.
  101202. */
  101203. activeSubSystems: Array<ParticleSystem>;
  101204. /**
  101205. * Specifies if the particles are updated in emitter local space or world space
  101206. */
  101207. isLocal: boolean;
  101208. private _rootParticleSystem;
  101209. /**
  101210. * Gets the current list of active particles
  101211. */
  101212. get particles(): Particle[];
  101213. /**
  101214. * Gets the number of particles active at the same time.
  101215. * @returns The number of active particles.
  101216. */
  101217. getActiveCount(): number;
  101218. /**
  101219. * Returns the string "ParticleSystem"
  101220. * @returns a string containing the class name
  101221. */
  101222. getClassName(): string;
  101223. /**
  101224. * Gets a boolean indicating that the system is stopping
  101225. * @returns true if the system is currently stopping
  101226. */
  101227. isStopping(): boolean;
  101228. /**
  101229. * Gets the custom effect used to render the particles
  101230. * @param blendMode Blend mode for which the effect should be retrieved
  101231. * @returns The effect
  101232. */
  101233. getCustomEffect(blendMode?: number): Nullable<Effect>;
  101234. /**
  101235. * Sets the custom effect used to render the particles
  101236. * @param effect The effect to set
  101237. * @param blendMode Blend mode for which the effect should be set
  101238. */
  101239. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  101240. /** @hidden */
  101241. private _onBeforeDrawParticlesObservable;
  101242. /**
  101243. * Observable that will be called just before the particles are drawn
  101244. */
  101245. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  101246. /**
  101247. * Gets the name of the particle vertex shader
  101248. */
  101249. get vertexShaderName(): string;
  101250. /**
  101251. * Instantiates a particle system.
  101252. * 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.
  101253. * @param name The name of the particle system
  101254. * @param capacity The max number of particles alive at the same time
  101255. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  101256. * @param customEffect a custom effect used to change the way particles are rendered by default
  101257. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  101258. * @param epsilon Offset used to render the particles
  101259. */
  101260. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  101261. private _addFactorGradient;
  101262. private _removeFactorGradient;
  101263. /**
  101264. * Adds a new life time gradient
  101265. * @param gradient defines the gradient to use (between 0 and 1)
  101266. * @param factor defines the life time factor to affect to the specified gradient
  101267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101268. * @returns the current particle system
  101269. */
  101270. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101271. /**
  101272. * Remove a specific life time gradient
  101273. * @param gradient defines the gradient to remove
  101274. * @returns the current particle system
  101275. */
  101276. removeLifeTimeGradient(gradient: number): IParticleSystem;
  101277. /**
  101278. * Adds a new size gradient
  101279. * @param gradient defines the gradient to use (between 0 and 1)
  101280. * @param factor defines the size factor to affect to the specified gradient
  101281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101282. * @returns the current particle system
  101283. */
  101284. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101285. /**
  101286. * Remove a specific size gradient
  101287. * @param gradient defines the gradient to remove
  101288. * @returns the current particle system
  101289. */
  101290. removeSizeGradient(gradient: number): IParticleSystem;
  101291. /**
  101292. * Adds a new color remap gradient
  101293. * @param gradient defines the gradient to use (between 0 and 1)
  101294. * @param min defines the color remap minimal range
  101295. * @param max defines the color remap maximal range
  101296. * @returns the current particle system
  101297. */
  101298. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  101299. /**
  101300. * Remove a specific color remap gradient
  101301. * @param gradient defines the gradient to remove
  101302. * @returns the current particle system
  101303. */
  101304. removeColorRemapGradient(gradient: number): IParticleSystem;
  101305. /**
  101306. * Adds a new alpha remap gradient
  101307. * @param gradient defines the gradient to use (between 0 and 1)
  101308. * @param min defines the alpha remap minimal range
  101309. * @param max defines the alpha remap maximal range
  101310. * @returns the current particle system
  101311. */
  101312. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  101313. /**
  101314. * Remove a specific alpha remap gradient
  101315. * @param gradient defines the gradient to remove
  101316. * @returns the current particle system
  101317. */
  101318. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  101319. /**
  101320. * Adds a new angular speed gradient
  101321. * @param gradient defines the gradient to use (between 0 and 1)
  101322. * @param factor defines the angular speed to affect to the specified gradient
  101323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101324. * @returns the current particle system
  101325. */
  101326. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101327. /**
  101328. * Remove a specific angular speed gradient
  101329. * @param gradient defines the gradient to remove
  101330. * @returns the current particle system
  101331. */
  101332. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  101333. /**
  101334. * Adds a new velocity gradient
  101335. * @param gradient defines the gradient to use (between 0 and 1)
  101336. * @param factor defines the velocity to affect to the specified gradient
  101337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101338. * @returns the current particle system
  101339. */
  101340. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101341. /**
  101342. * Remove a specific velocity gradient
  101343. * @param gradient defines the gradient to remove
  101344. * @returns the current particle system
  101345. */
  101346. removeVelocityGradient(gradient: number): IParticleSystem;
  101347. /**
  101348. * Adds a new limit velocity gradient
  101349. * @param gradient defines the gradient to use (between 0 and 1)
  101350. * @param factor defines the limit velocity value to affect to the specified gradient
  101351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101352. * @returns the current particle system
  101353. */
  101354. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101355. /**
  101356. * Remove a specific limit velocity gradient
  101357. * @param gradient defines the gradient to remove
  101358. * @returns the current particle system
  101359. */
  101360. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  101361. /**
  101362. * Adds a new drag gradient
  101363. * @param gradient defines the gradient to use (between 0 and 1)
  101364. * @param factor defines the drag value to affect to the specified gradient
  101365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101366. * @returns the current particle system
  101367. */
  101368. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101369. /**
  101370. * Remove a specific drag gradient
  101371. * @param gradient defines the gradient to remove
  101372. * @returns the current particle system
  101373. */
  101374. removeDragGradient(gradient: number): IParticleSystem;
  101375. /**
  101376. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  101377. * @param gradient defines the gradient to use (between 0 and 1)
  101378. * @param factor defines the emit rate value to affect to the specified gradient
  101379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101380. * @returns the current particle system
  101381. */
  101382. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101383. /**
  101384. * Remove a specific emit rate gradient
  101385. * @param gradient defines the gradient to remove
  101386. * @returns the current particle system
  101387. */
  101388. removeEmitRateGradient(gradient: number): IParticleSystem;
  101389. /**
  101390. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  101391. * @param gradient defines the gradient to use (between 0 and 1)
  101392. * @param factor defines the start size value to affect to the specified gradient
  101393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101394. * @returns the current particle system
  101395. */
  101396. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101397. /**
  101398. * Remove a specific start size gradient
  101399. * @param gradient defines the gradient to remove
  101400. * @returns the current particle system
  101401. */
  101402. removeStartSizeGradient(gradient: number): IParticleSystem;
  101403. private _createRampGradientTexture;
  101404. /**
  101405. * Gets the current list of ramp gradients.
  101406. * You must use addRampGradient and removeRampGradient to update this list
  101407. * @returns the list of ramp gradients
  101408. */
  101409. getRampGradients(): Nullable<Array<Color3Gradient>>;
  101410. /** Force the system to rebuild all gradients that need to be resync */
  101411. forceRefreshGradients(): void;
  101412. private _syncRampGradientTexture;
  101413. /**
  101414. * Adds a new ramp gradient used to remap particle colors
  101415. * @param gradient defines the gradient to use (between 0 and 1)
  101416. * @param color defines the color to affect to the specified gradient
  101417. * @returns the current particle system
  101418. */
  101419. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  101420. /**
  101421. * Remove a specific ramp gradient
  101422. * @param gradient defines the gradient to remove
  101423. * @returns the current particle system
  101424. */
  101425. removeRampGradient(gradient: number): ParticleSystem;
  101426. /**
  101427. * Adds a new color gradient
  101428. * @param gradient defines the gradient to use (between 0 and 1)
  101429. * @param color1 defines the color to affect to the specified gradient
  101430. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  101431. * @returns this particle system
  101432. */
  101433. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  101434. /**
  101435. * Remove a specific color gradient
  101436. * @param gradient defines the gradient to remove
  101437. * @returns this particle system
  101438. */
  101439. removeColorGradient(gradient: number): IParticleSystem;
  101440. private _fetchR;
  101441. protected _reset(): void;
  101442. private _resetEffect;
  101443. private _createVertexBuffers;
  101444. private _createIndexBuffer;
  101445. /**
  101446. * Gets the maximum number of particles active at the same time.
  101447. * @returns The max number of active particles.
  101448. */
  101449. getCapacity(): number;
  101450. /**
  101451. * Gets whether there are still active particles in the system.
  101452. * @returns True if it is alive, otherwise false.
  101453. */
  101454. isAlive(): boolean;
  101455. /**
  101456. * Gets if the system has been started. (Note: this will still be true after stop is called)
  101457. * @returns True if it has been started, otherwise false.
  101458. */
  101459. isStarted(): boolean;
  101460. private _prepareSubEmitterInternalArray;
  101461. /**
  101462. * Starts the particle system and begins to emit
  101463. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  101464. */
  101465. start(delay?: number): void;
  101466. /**
  101467. * Stops the particle system.
  101468. * @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.
  101469. */
  101470. stop(stopSubEmitters?: boolean): void;
  101471. /**
  101472. * Remove all active particles
  101473. */
  101474. reset(): void;
  101475. /**
  101476. * @hidden (for internal use only)
  101477. */
  101478. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  101479. /**
  101480. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  101481. * Its lifetime will start back at 0.
  101482. */
  101483. recycleParticle: (particle: Particle) => void;
  101484. private _stopSubEmitters;
  101485. private _createParticle;
  101486. private _removeFromRoot;
  101487. private _emitFromParticle;
  101488. private _update;
  101489. /** @hidden */
  101490. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  101491. /** @hidden */
  101492. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  101493. /**
  101494. * Fill the defines array according to the current settings of the particle system
  101495. * @param defines Array to be updated
  101496. * @param blendMode blend mode to take into account when updating the array
  101497. */
  101498. fillDefines(defines: Array<string>, blendMode: number): void;
  101499. /**
  101500. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  101501. * @param uniforms Uniforms array to fill
  101502. * @param attributes Attributes array to fill
  101503. * @param samplers Samplers array to fill
  101504. */
  101505. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  101506. /** @hidden */
  101507. private _getEffect;
  101508. /**
  101509. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  101510. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  101511. */
  101512. animate(preWarmOnly?: boolean): void;
  101513. private _appendParticleVertices;
  101514. /**
  101515. * Rebuilds the particle system.
  101516. */
  101517. rebuild(): void;
  101518. /**
  101519. * Is this system ready to be used/rendered
  101520. * @return true if the system is ready
  101521. */
  101522. isReady(): boolean;
  101523. private _render;
  101524. /**
  101525. * Renders the particle system in its current state.
  101526. * @returns the current number of particles
  101527. */
  101528. render(): number;
  101529. /**
  101530. * Disposes the particle system and free the associated resources
  101531. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  101532. */
  101533. dispose(disposeTexture?: boolean): void;
  101534. /**
  101535. * Clones the particle system.
  101536. * @param name The name of the cloned object
  101537. * @param newEmitter The new emitter to use
  101538. * @returns the cloned particle system
  101539. */
  101540. clone(name: string, newEmitter: any): ParticleSystem;
  101541. /**
  101542. * Serializes the particle system to a JSON object
  101543. * @param serializeTexture defines if the texture must be serialized as well
  101544. * @returns the JSON object
  101545. */
  101546. serialize(serializeTexture?: boolean): any;
  101547. /** @hidden */
  101548. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  101549. /** @hidden */
  101550. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  101551. /**
  101552. * Parses a JSON object to create a particle system.
  101553. * @param parsedParticleSystem The JSON object to parse
  101554. * @param sceneOrEngine The scene or the engine to create the particle system in
  101555. * @param rootUrl The root url to use to load external dependencies like texture
  101556. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  101557. * @returns the Parsed particle system
  101558. */
  101559. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  101560. }
  101561. }
  101562. declare module BABYLON {
  101563. /**
  101564. * A particle represents one of the element emitted by a particle system.
  101565. * This is mainly define by its coordinates, direction, velocity and age.
  101566. */
  101567. export class Particle {
  101568. /**
  101569. * The particle system the particle belongs to.
  101570. */
  101571. particleSystem: ParticleSystem;
  101572. private static _Count;
  101573. /**
  101574. * Unique ID of the particle
  101575. */
  101576. id: number;
  101577. /**
  101578. * The world position of the particle in the scene.
  101579. */
  101580. position: Vector3;
  101581. /**
  101582. * The world direction of the particle in the scene.
  101583. */
  101584. direction: Vector3;
  101585. /**
  101586. * The color of the particle.
  101587. */
  101588. color: Color4;
  101589. /**
  101590. * The color change of the particle per step.
  101591. */
  101592. colorStep: Color4;
  101593. /**
  101594. * Defines how long will the life of the particle be.
  101595. */
  101596. lifeTime: number;
  101597. /**
  101598. * The current age of the particle.
  101599. */
  101600. age: number;
  101601. /**
  101602. * The current size of the particle.
  101603. */
  101604. size: number;
  101605. /**
  101606. * The current scale of the particle.
  101607. */
  101608. scale: Vector2;
  101609. /**
  101610. * The current angle of the particle.
  101611. */
  101612. angle: number;
  101613. /**
  101614. * Defines how fast is the angle changing.
  101615. */
  101616. angularSpeed: number;
  101617. /**
  101618. * Defines the cell index used by the particle to be rendered from a sprite.
  101619. */
  101620. cellIndex: number;
  101621. /**
  101622. * The information required to support color remapping
  101623. */
  101624. remapData: Vector4;
  101625. /** @hidden */
  101626. _randomCellOffset?: number;
  101627. /** @hidden */
  101628. _initialDirection: Nullable<Vector3>;
  101629. /** @hidden */
  101630. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  101631. /** @hidden */
  101632. _initialStartSpriteCellID: number;
  101633. /** @hidden */
  101634. _initialEndSpriteCellID: number;
  101635. /** @hidden */
  101636. _currentColorGradient: Nullable<ColorGradient>;
  101637. /** @hidden */
  101638. _currentColor1: Color4;
  101639. /** @hidden */
  101640. _currentColor2: Color4;
  101641. /** @hidden */
  101642. _currentSizeGradient: Nullable<FactorGradient>;
  101643. /** @hidden */
  101644. _currentSize1: number;
  101645. /** @hidden */
  101646. _currentSize2: number;
  101647. /** @hidden */
  101648. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  101649. /** @hidden */
  101650. _currentAngularSpeed1: number;
  101651. /** @hidden */
  101652. _currentAngularSpeed2: number;
  101653. /** @hidden */
  101654. _currentVelocityGradient: Nullable<FactorGradient>;
  101655. /** @hidden */
  101656. _currentVelocity1: number;
  101657. /** @hidden */
  101658. _currentVelocity2: number;
  101659. /** @hidden */
  101660. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  101661. /** @hidden */
  101662. _currentLimitVelocity1: number;
  101663. /** @hidden */
  101664. _currentLimitVelocity2: number;
  101665. /** @hidden */
  101666. _currentDragGradient: Nullable<FactorGradient>;
  101667. /** @hidden */
  101668. _currentDrag1: number;
  101669. /** @hidden */
  101670. _currentDrag2: number;
  101671. /** @hidden */
  101672. _randomNoiseCoordinates1: Vector3;
  101673. /** @hidden */
  101674. _randomNoiseCoordinates2: Vector3;
  101675. /** @hidden */
  101676. _localPosition?: Vector3;
  101677. /**
  101678. * Creates a new instance Particle
  101679. * @param particleSystem the particle system the particle belongs to
  101680. */
  101681. constructor(
  101682. /**
  101683. * The particle system the particle belongs to.
  101684. */
  101685. particleSystem: ParticleSystem);
  101686. private updateCellInfoFromSystem;
  101687. /**
  101688. * Defines how the sprite cell index is updated for the particle
  101689. */
  101690. updateCellIndex(): void;
  101691. /** @hidden */
  101692. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  101693. /** @hidden */
  101694. _inheritParticleInfoToSubEmitters(): void;
  101695. /** @hidden */
  101696. _reset(): void;
  101697. /**
  101698. * Copy the properties of particle to another one.
  101699. * @param other the particle to copy the information to.
  101700. */
  101701. copyTo(other: Particle): void;
  101702. }
  101703. }
  101704. declare module BABYLON {
  101705. /**
  101706. * Particle emitter represents a volume emitting particles.
  101707. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  101708. */
  101709. export interface IParticleEmitterType {
  101710. /**
  101711. * Called by the particle System when the direction is computed for the created particle.
  101712. * @param worldMatrix is the world matrix of the particle system
  101713. * @param directionToUpdate is the direction vector to update with the result
  101714. * @param particle is the particle we are computed the direction for
  101715. * @param isLocal defines if the direction should be set in local space
  101716. */
  101717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101718. /**
  101719. * Called by the particle System when the position is computed for the created particle.
  101720. * @param worldMatrix is the world matrix of the particle system
  101721. * @param positionToUpdate is the position vector to update with the result
  101722. * @param particle is the particle we are computed the position for
  101723. * @param isLocal defines if the position should be set in local space
  101724. */
  101725. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101726. /**
  101727. * Clones the current emitter and returns a copy of it
  101728. * @returns the new emitter
  101729. */
  101730. clone(): IParticleEmitterType;
  101731. /**
  101732. * Called by the GPUParticleSystem to setup the update shader
  101733. * @param effect defines the update shader
  101734. */
  101735. applyToShader(effect: Effect): void;
  101736. /**
  101737. * Returns a string to use to update the GPU particles update shader
  101738. * @returns the effect defines string
  101739. */
  101740. getEffectDefines(): string;
  101741. /**
  101742. * Returns a string representing the class name
  101743. * @returns a string containing the class name
  101744. */
  101745. getClassName(): string;
  101746. /**
  101747. * Serializes the particle system to a JSON object.
  101748. * @returns the JSON object
  101749. */
  101750. serialize(): any;
  101751. /**
  101752. * Parse properties from a JSON object
  101753. * @param serializationObject defines the JSON object
  101754. * @param scene defines the hosting scene
  101755. */
  101756. parse(serializationObject: any, scene: Nullable<Scene>): void;
  101757. }
  101758. }
  101759. declare module BABYLON {
  101760. /**
  101761. * Particle emitter emitting particles from the inside of a box.
  101762. * It emits the particles randomly between 2 given directions.
  101763. */
  101764. export class BoxParticleEmitter implements IParticleEmitterType {
  101765. /**
  101766. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101767. */
  101768. direction1: Vector3;
  101769. /**
  101770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101771. */
  101772. direction2: Vector3;
  101773. /**
  101774. * 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.
  101775. */
  101776. minEmitBox: Vector3;
  101777. /**
  101778. * 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.
  101779. */
  101780. maxEmitBox: Vector3;
  101781. /**
  101782. * Creates a new instance BoxParticleEmitter
  101783. */
  101784. constructor();
  101785. /**
  101786. * Called by the particle System when the direction is computed for the created particle.
  101787. * @param worldMatrix is the world matrix of the particle system
  101788. * @param directionToUpdate is the direction vector to update with the result
  101789. * @param particle is the particle we are computed the direction for
  101790. * @param isLocal defines if the direction should be set in local space
  101791. */
  101792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101793. /**
  101794. * Called by the particle System when the position is computed for the created particle.
  101795. * @param worldMatrix is the world matrix of the particle system
  101796. * @param positionToUpdate is the position vector to update with the result
  101797. * @param particle is the particle we are computed the position for
  101798. * @param isLocal defines if the position should be set in local space
  101799. */
  101800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101801. /**
  101802. * Clones the current emitter and returns a copy of it
  101803. * @returns the new emitter
  101804. */
  101805. clone(): BoxParticleEmitter;
  101806. /**
  101807. * Called by the GPUParticleSystem to setup the update shader
  101808. * @param effect defines the update shader
  101809. */
  101810. applyToShader(effect: Effect): void;
  101811. /**
  101812. * Returns a string to use to update the GPU particles update shader
  101813. * @returns a string containing the defines string
  101814. */
  101815. getEffectDefines(): string;
  101816. /**
  101817. * Returns the string "BoxParticleEmitter"
  101818. * @returns a string containing the class name
  101819. */
  101820. getClassName(): string;
  101821. /**
  101822. * Serializes the particle system to a JSON object.
  101823. * @returns the JSON object
  101824. */
  101825. serialize(): any;
  101826. /**
  101827. * Parse properties from a JSON object
  101828. * @param serializationObject defines the JSON object
  101829. */
  101830. parse(serializationObject: any): void;
  101831. }
  101832. }
  101833. declare module BABYLON {
  101834. /**
  101835. * Particle emitter emitting particles from the inside of a cone.
  101836. * It emits the particles alongside the cone volume from the base to the particle.
  101837. * The emission direction might be randomized.
  101838. */
  101839. export class ConeParticleEmitter implements IParticleEmitterType {
  101840. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101841. directionRandomizer: number;
  101842. private _radius;
  101843. private _angle;
  101844. private _height;
  101845. /**
  101846. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  101847. */
  101848. radiusRange: number;
  101849. /**
  101850. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  101851. */
  101852. heightRange: number;
  101853. /**
  101854. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  101855. */
  101856. emitFromSpawnPointOnly: boolean;
  101857. /**
  101858. * Gets or sets the radius of the emission cone
  101859. */
  101860. get radius(): number;
  101861. set radius(value: number);
  101862. /**
  101863. * Gets or sets the angle of the emission cone
  101864. */
  101865. get angle(): number;
  101866. set angle(value: number);
  101867. private _buildHeight;
  101868. /**
  101869. * Creates a new instance ConeParticleEmitter
  101870. * @param radius the radius of the emission cone (1 by default)
  101871. * @param angle the cone base angle (PI by default)
  101872. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  101873. */
  101874. constructor(radius?: number, angle?: number,
  101875. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101876. directionRandomizer?: number);
  101877. /**
  101878. * Called by the particle System when the direction is computed for the created particle.
  101879. * @param worldMatrix is the world matrix of the particle system
  101880. * @param directionToUpdate is the direction vector to update with the result
  101881. * @param particle is the particle we are computed the direction for
  101882. * @param isLocal defines if the direction should be set in local space
  101883. */
  101884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101885. /**
  101886. * Called by the particle System when the position is computed for the created particle.
  101887. * @param worldMatrix is the world matrix of the particle system
  101888. * @param positionToUpdate is the position vector to update with the result
  101889. * @param particle is the particle we are computed the position for
  101890. * @param isLocal defines if the position should be set in local space
  101891. */
  101892. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101893. /**
  101894. * Clones the current emitter and returns a copy of it
  101895. * @returns the new emitter
  101896. */
  101897. clone(): ConeParticleEmitter;
  101898. /**
  101899. * Called by the GPUParticleSystem to setup the update shader
  101900. * @param effect defines the update shader
  101901. */
  101902. applyToShader(effect: Effect): void;
  101903. /**
  101904. * Returns a string to use to update the GPU particles update shader
  101905. * @returns a string containing the defines string
  101906. */
  101907. getEffectDefines(): string;
  101908. /**
  101909. * Returns the string "ConeParticleEmitter"
  101910. * @returns a string containing the class name
  101911. */
  101912. getClassName(): string;
  101913. /**
  101914. * Serializes the particle system to a JSON object.
  101915. * @returns the JSON object
  101916. */
  101917. serialize(): any;
  101918. /**
  101919. * Parse properties from a JSON object
  101920. * @param serializationObject defines the JSON object
  101921. */
  101922. parse(serializationObject: any): void;
  101923. }
  101924. }
  101925. declare module BABYLON {
  101926. /**
  101927. * Particle emitter emitting particles from the inside of a cylinder.
  101928. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  101929. */
  101930. export class CylinderParticleEmitter implements IParticleEmitterType {
  101931. /**
  101932. * The radius of the emission cylinder.
  101933. */
  101934. radius: number;
  101935. /**
  101936. * The height of the emission cylinder.
  101937. */
  101938. height: number;
  101939. /**
  101940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101941. */
  101942. radiusRange: number;
  101943. /**
  101944. * How much to randomize the particle direction [0-1].
  101945. */
  101946. directionRandomizer: number;
  101947. /**
  101948. * Creates a new instance CylinderParticleEmitter
  101949. * @param radius the radius of the emission cylinder (1 by default)
  101950. * @param height the height of the emission cylinder (1 by default)
  101951. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101952. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101953. */
  101954. constructor(
  101955. /**
  101956. * The radius of the emission cylinder.
  101957. */
  101958. radius?: number,
  101959. /**
  101960. * The height of the emission cylinder.
  101961. */
  101962. height?: number,
  101963. /**
  101964. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101965. */
  101966. radiusRange?: number,
  101967. /**
  101968. * How much to randomize the particle direction [0-1].
  101969. */
  101970. directionRandomizer?: number);
  101971. /**
  101972. * Called by the particle System when the direction is computed for the created particle.
  101973. * @param worldMatrix is the world matrix of the particle system
  101974. * @param directionToUpdate is the direction vector to update with the result
  101975. * @param particle is the particle we are computed the direction for
  101976. * @param isLocal defines if the direction should be set in local space
  101977. */
  101978. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101979. /**
  101980. * Called by the particle System when the position is computed for the created particle.
  101981. * @param worldMatrix is the world matrix of the particle system
  101982. * @param positionToUpdate is the position vector to update with the result
  101983. * @param particle is the particle we are computed the position for
  101984. * @param isLocal defines if the position should be set in local space
  101985. */
  101986. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101987. /**
  101988. * Clones the current emitter and returns a copy of it
  101989. * @returns the new emitter
  101990. */
  101991. clone(): CylinderParticleEmitter;
  101992. /**
  101993. * Called by the GPUParticleSystem to setup the update shader
  101994. * @param effect defines the update shader
  101995. */
  101996. applyToShader(effect: Effect): void;
  101997. /**
  101998. * Returns a string to use to update the GPU particles update shader
  101999. * @returns a string containing the defines string
  102000. */
  102001. getEffectDefines(): string;
  102002. /**
  102003. * Returns the string "CylinderParticleEmitter"
  102004. * @returns a string containing the class name
  102005. */
  102006. getClassName(): string;
  102007. /**
  102008. * Serializes the particle system to a JSON object.
  102009. * @returns the JSON object
  102010. */
  102011. serialize(): any;
  102012. /**
  102013. * Parse properties from a JSON object
  102014. * @param serializationObject defines the JSON object
  102015. */
  102016. parse(serializationObject: any): void;
  102017. }
  102018. /**
  102019. * Particle emitter emitting particles from the inside of a cylinder.
  102020. * It emits the particles randomly between two vectors.
  102021. */
  102022. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  102023. /**
  102024. * The min limit of the emission direction.
  102025. */
  102026. direction1: Vector3;
  102027. /**
  102028. * The max limit of the emission direction.
  102029. */
  102030. direction2: Vector3;
  102031. /**
  102032. * Creates a new instance CylinderDirectedParticleEmitter
  102033. * @param radius the radius of the emission cylinder (1 by default)
  102034. * @param height the height of the emission cylinder (1 by default)
  102035. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102036. * @param direction1 the min limit of the emission direction (up vector by default)
  102037. * @param direction2 the max limit of the emission direction (up vector by default)
  102038. */
  102039. constructor(radius?: number, height?: number, radiusRange?: number,
  102040. /**
  102041. * The min limit of the emission direction.
  102042. */
  102043. direction1?: Vector3,
  102044. /**
  102045. * The max limit of the emission direction.
  102046. */
  102047. direction2?: Vector3);
  102048. /**
  102049. * Called by the particle System when the direction is computed for the created particle.
  102050. * @param worldMatrix is the world matrix of the particle system
  102051. * @param directionToUpdate is the direction vector to update with the result
  102052. * @param particle is the particle we are computed the direction for
  102053. */
  102054. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  102055. /**
  102056. * Clones the current emitter and returns a copy of it
  102057. * @returns the new emitter
  102058. */
  102059. clone(): CylinderDirectedParticleEmitter;
  102060. /**
  102061. * Called by the GPUParticleSystem to setup the update shader
  102062. * @param effect defines the update shader
  102063. */
  102064. applyToShader(effect: Effect): void;
  102065. /**
  102066. * Returns a string to use to update the GPU particles update shader
  102067. * @returns a string containing the defines string
  102068. */
  102069. getEffectDefines(): string;
  102070. /**
  102071. * Returns the string "CylinderDirectedParticleEmitter"
  102072. * @returns a string containing the class name
  102073. */
  102074. getClassName(): string;
  102075. /**
  102076. * Serializes the particle system to a JSON object.
  102077. * @returns the JSON object
  102078. */
  102079. serialize(): any;
  102080. /**
  102081. * Parse properties from a JSON object
  102082. * @param serializationObject defines the JSON object
  102083. */
  102084. parse(serializationObject: any): void;
  102085. }
  102086. }
  102087. declare module BABYLON {
  102088. /**
  102089. * Particle emitter emitting particles from the inside of a hemisphere.
  102090. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  102091. */
  102092. export class HemisphericParticleEmitter implements IParticleEmitterType {
  102093. /**
  102094. * The radius of the emission hemisphere.
  102095. */
  102096. radius: number;
  102097. /**
  102098. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102099. */
  102100. radiusRange: number;
  102101. /**
  102102. * How much to randomize the particle direction [0-1].
  102103. */
  102104. directionRandomizer: number;
  102105. /**
  102106. * Creates a new instance HemisphericParticleEmitter
  102107. * @param radius the radius of the emission hemisphere (1 by default)
  102108. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102109. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102110. */
  102111. constructor(
  102112. /**
  102113. * The radius of the emission hemisphere.
  102114. */
  102115. radius?: number,
  102116. /**
  102117. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102118. */
  102119. radiusRange?: number,
  102120. /**
  102121. * How much to randomize the particle direction [0-1].
  102122. */
  102123. directionRandomizer?: number);
  102124. /**
  102125. * Called by the particle System when the direction is computed for the created particle.
  102126. * @param worldMatrix is the world matrix of the particle system
  102127. * @param directionToUpdate is the direction vector to update with the result
  102128. * @param particle is the particle we are computed the direction for
  102129. * @param isLocal defines if the direction should be set in local space
  102130. */
  102131. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102132. /**
  102133. * Called by the particle System when the position is computed for the created particle.
  102134. * @param worldMatrix is the world matrix of the particle system
  102135. * @param positionToUpdate is the position vector to update with the result
  102136. * @param particle is the particle we are computed the position for
  102137. * @param isLocal defines if the position should be set in local space
  102138. */
  102139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102140. /**
  102141. * Clones the current emitter and returns a copy of it
  102142. * @returns the new emitter
  102143. */
  102144. clone(): HemisphericParticleEmitter;
  102145. /**
  102146. * Called by the GPUParticleSystem to setup the update shader
  102147. * @param effect defines the update shader
  102148. */
  102149. applyToShader(effect: Effect): void;
  102150. /**
  102151. * Returns a string to use to update the GPU particles update shader
  102152. * @returns a string containing the defines string
  102153. */
  102154. getEffectDefines(): string;
  102155. /**
  102156. * Returns the string "HemisphericParticleEmitter"
  102157. * @returns a string containing the class name
  102158. */
  102159. getClassName(): string;
  102160. /**
  102161. * Serializes the particle system to a JSON object.
  102162. * @returns the JSON object
  102163. */
  102164. serialize(): any;
  102165. /**
  102166. * Parse properties from a JSON object
  102167. * @param serializationObject defines the JSON object
  102168. */
  102169. parse(serializationObject: any): void;
  102170. }
  102171. }
  102172. declare module BABYLON {
  102173. /**
  102174. * Particle emitter emitting particles from a point.
  102175. * It emits the particles randomly between 2 given directions.
  102176. */
  102177. export class PointParticleEmitter implements IParticleEmitterType {
  102178. /**
  102179. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102180. */
  102181. direction1: Vector3;
  102182. /**
  102183. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102184. */
  102185. direction2: Vector3;
  102186. /**
  102187. * Creates a new instance PointParticleEmitter
  102188. */
  102189. constructor();
  102190. /**
  102191. * Called by the particle System when the direction is computed for the created particle.
  102192. * @param worldMatrix is the world matrix of the particle system
  102193. * @param directionToUpdate is the direction vector to update with the result
  102194. * @param particle is the particle we are computed the direction for
  102195. * @param isLocal defines if the direction should be set in local space
  102196. */
  102197. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102198. /**
  102199. * Called by the particle System when the position is computed for the created particle.
  102200. * @param worldMatrix is the world matrix of the particle system
  102201. * @param positionToUpdate is the position vector to update with the result
  102202. * @param particle is the particle we are computed the position for
  102203. * @param isLocal defines if the position should be set in local space
  102204. */
  102205. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102206. /**
  102207. * Clones the current emitter and returns a copy of it
  102208. * @returns the new emitter
  102209. */
  102210. clone(): PointParticleEmitter;
  102211. /**
  102212. * Called by the GPUParticleSystem to setup the update shader
  102213. * @param effect defines the update shader
  102214. */
  102215. applyToShader(effect: Effect): void;
  102216. /**
  102217. * Returns a string to use to update the GPU particles update shader
  102218. * @returns a string containing the defines string
  102219. */
  102220. getEffectDefines(): string;
  102221. /**
  102222. * Returns the string "PointParticleEmitter"
  102223. * @returns a string containing the class name
  102224. */
  102225. getClassName(): string;
  102226. /**
  102227. * Serializes the particle system to a JSON object.
  102228. * @returns the JSON object
  102229. */
  102230. serialize(): any;
  102231. /**
  102232. * Parse properties from a JSON object
  102233. * @param serializationObject defines the JSON object
  102234. */
  102235. parse(serializationObject: any): void;
  102236. }
  102237. }
  102238. declare module BABYLON {
  102239. /**
  102240. * Particle emitter emitting particles from the inside of a sphere.
  102241. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  102242. */
  102243. export class SphereParticleEmitter implements IParticleEmitterType {
  102244. /**
  102245. * The radius of the emission sphere.
  102246. */
  102247. radius: number;
  102248. /**
  102249. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102250. */
  102251. radiusRange: number;
  102252. /**
  102253. * How much to randomize the particle direction [0-1].
  102254. */
  102255. directionRandomizer: number;
  102256. /**
  102257. * Creates a new instance SphereParticleEmitter
  102258. * @param radius the radius of the emission sphere (1 by default)
  102259. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102260. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102261. */
  102262. constructor(
  102263. /**
  102264. * The radius of the emission sphere.
  102265. */
  102266. radius?: number,
  102267. /**
  102268. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102269. */
  102270. radiusRange?: number,
  102271. /**
  102272. * How much to randomize the particle direction [0-1].
  102273. */
  102274. directionRandomizer?: number);
  102275. /**
  102276. * Called by the particle System when the direction is computed for the created particle.
  102277. * @param worldMatrix is the world matrix of the particle system
  102278. * @param directionToUpdate is the direction vector to update with the result
  102279. * @param particle is the particle we are computed the direction for
  102280. * @param isLocal defines if the direction should be set in local space
  102281. */
  102282. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102283. /**
  102284. * Called by the particle System when the position is computed for the created particle.
  102285. * @param worldMatrix is the world matrix of the particle system
  102286. * @param positionToUpdate is the position vector to update with the result
  102287. * @param particle is the particle we are computed the position for
  102288. * @param isLocal defines if the position should be set in local space
  102289. */
  102290. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102291. /**
  102292. * Clones the current emitter and returns a copy of it
  102293. * @returns the new emitter
  102294. */
  102295. clone(): SphereParticleEmitter;
  102296. /**
  102297. * Called by the GPUParticleSystem to setup the update shader
  102298. * @param effect defines the update shader
  102299. */
  102300. applyToShader(effect: Effect): void;
  102301. /**
  102302. * Returns a string to use to update the GPU particles update shader
  102303. * @returns a string containing the defines string
  102304. */
  102305. getEffectDefines(): string;
  102306. /**
  102307. * Returns the string "SphereParticleEmitter"
  102308. * @returns a string containing the class name
  102309. */
  102310. getClassName(): string;
  102311. /**
  102312. * Serializes the particle system to a JSON object.
  102313. * @returns the JSON object
  102314. */
  102315. serialize(): any;
  102316. /**
  102317. * Parse properties from a JSON object
  102318. * @param serializationObject defines the JSON object
  102319. */
  102320. parse(serializationObject: any): void;
  102321. }
  102322. /**
  102323. * Particle emitter emitting particles from the inside of a sphere.
  102324. * It emits the particles randomly between two vectors.
  102325. */
  102326. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  102327. /**
  102328. * The min limit of the emission direction.
  102329. */
  102330. direction1: Vector3;
  102331. /**
  102332. * The max limit of the emission direction.
  102333. */
  102334. direction2: Vector3;
  102335. /**
  102336. * Creates a new instance SphereDirectedParticleEmitter
  102337. * @param radius the radius of the emission sphere (1 by default)
  102338. * @param direction1 the min limit of the emission direction (up vector by default)
  102339. * @param direction2 the max limit of the emission direction (up vector by default)
  102340. */
  102341. constructor(radius?: number,
  102342. /**
  102343. * The min limit of the emission direction.
  102344. */
  102345. direction1?: Vector3,
  102346. /**
  102347. * The max limit of the emission direction.
  102348. */
  102349. direction2?: Vector3);
  102350. /**
  102351. * Called by the particle System when the direction is computed for the created particle.
  102352. * @param worldMatrix is the world matrix of the particle system
  102353. * @param directionToUpdate is the direction vector to update with the result
  102354. * @param particle is the particle we are computed the direction for
  102355. */
  102356. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  102357. /**
  102358. * Clones the current emitter and returns a copy of it
  102359. * @returns the new emitter
  102360. */
  102361. clone(): SphereDirectedParticleEmitter;
  102362. /**
  102363. * Called by the GPUParticleSystem to setup the update shader
  102364. * @param effect defines the update shader
  102365. */
  102366. applyToShader(effect: Effect): void;
  102367. /**
  102368. * Returns a string to use to update the GPU particles update shader
  102369. * @returns a string containing the defines string
  102370. */
  102371. getEffectDefines(): string;
  102372. /**
  102373. * Returns the string "SphereDirectedParticleEmitter"
  102374. * @returns a string containing the class name
  102375. */
  102376. getClassName(): string;
  102377. /**
  102378. * Serializes the particle system to a JSON object.
  102379. * @returns the JSON object
  102380. */
  102381. serialize(): any;
  102382. /**
  102383. * Parse properties from a JSON object
  102384. * @param serializationObject defines the JSON object
  102385. */
  102386. parse(serializationObject: any): void;
  102387. }
  102388. }
  102389. declare module BABYLON {
  102390. /**
  102391. * Particle emitter emitting particles from a custom list of positions.
  102392. */
  102393. export class CustomParticleEmitter implements IParticleEmitterType {
  102394. /**
  102395. * Gets or sets the position generator that will create the initial position of each particle.
  102396. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  102397. */
  102398. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  102399. /**
  102400. * Gets or sets the destination generator that will create the final destination of each particle.
  102401. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  102402. */
  102403. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  102404. /**
  102405. * Creates a new instance CustomParticleEmitter
  102406. */
  102407. constructor();
  102408. /**
  102409. * Called by the particle System when the direction is computed for the created particle.
  102410. * @param worldMatrix is the world matrix of the particle system
  102411. * @param directionToUpdate is the direction vector to update with the result
  102412. * @param particle is the particle we are computed the direction for
  102413. * @param isLocal defines if the direction should be set in local space
  102414. */
  102415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102416. /**
  102417. * Called by the particle System when the position is computed for the created particle.
  102418. * @param worldMatrix is the world matrix of the particle system
  102419. * @param positionToUpdate is the position vector to update with the result
  102420. * @param particle is the particle we are computed the position for
  102421. * @param isLocal defines if the position should be set in local space
  102422. */
  102423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102424. /**
  102425. * Clones the current emitter and returns a copy of it
  102426. * @returns the new emitter
  102427. */
  102428. clone(): CustomParticleEmitter;
  102429. /**
  102430. * Called by the GPUParticleSystem to setup the update shader
  102431. * @param effect defines the update shader
  102432. */
  102433. applyToShader(effect: Effect): void;
  102434. /**
  102435. * Returns a string to use to update the GPU particles update shader
  102436. * @returns a string containing the defines string
  102437. */
  102438. getEffectDefines(): string;
  102439. /**
  102440. * Returns the string "PointParticleEmitter"
  102441. * @returns a string containing the class name
  102442. */
  102443. getClassName(): string;
  102444. /**
  102445. * Serializes the particle system to a JSON object.
  102446. * @returns the JSON object
  102447. */
  102448. serialize(): any;
  102449. /**
  102450. * Parse properties from a JSON object
  102451. * @param serializationObject defines the JSON object
  102452. */
  102453. parse(serializationObject: any): void;
  102454. }
  102455. }
  102456. declare module BABYLON {
  102457. /**
  102458. * Particle emitter emitting particles from the inside of a box.
  102459. * It emits the particles randomly between 2 given directions.
  102460. */
  102461. export class MeshParticleEmitter implements IParticleEmitterType {
  102462. private _indices;
  102463. private _positions;
  102464. private _normals;
  102465. private _storedNormal;
  102466. private _mesh;
  102467. /**
  102468. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102469. */
  102470. direction1: Vector3;
  102471. /**
  102472. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102473. */
  102474. direction2: Vector3;
  102475. /**
  102476. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  102477. */
  102478. useMeshNormalsForDirection: boolean;
  102479. /** Defines the mesh to use as source */
  102480. get mesh(): Nullable<AbstractMesh>;
  102481. set mesh(value: Nullable<AbstractMesh>);
  102482. /**
  102483. * Creates a new instance MeshParticleEmitter
  102484. * @param mesh defines the mesh to use as source
  102485. */
  102486. constructor(mesh?: Nullable<AbstractMesh>);
  102487. /**
  102488. * Called by the particle System when the direction is computed for the created particle.
  102489. * @param worldMatrix is the world matrix of the particle system
  102490. * @param directionToUpdate is the direction vector to update with the result
  102491. * @param particle is the particle we are computed the direction for
  102492. * @param isLocal defines if the direction should be set in local space
  102493. */
  102494. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102495. /**
  102496. * Called by the particle System when the position is computed for the created particle.
  102497. * @param worldMatrix is the world matrix of the particle system
  102498. * @param positionToUpdate is the position vector to update with the result
  102499. * @param particle is the particle we are computed the position for
  102500. * @param isLocal defines if the position should be set in local space
  102501. */
  102502. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  102503. /**
  102504. * Clones the current emitter and returns a copy of it
  102505. * @returns the new emitter
  102506. */
  102507. clone(): MeshParticleEmitter;
  102508. /**
  102509. * Called by the GPUParticleSystem to setup the update shader
  102510. * @param effect defines the update shader
  102511. */
  102512. applyToShader(effect: Effect): void;
  102513. /**
  102514. * Returns a string to use to update the GPU particles update shader
  102515. * @returns a string containing the defines string
  102516. */
  102517. getEffectDefines(): string;
  102518. /**
  102519. * Returns the string "BoxParticleEmitter"
  102520. * @returns a string containing the class name
  102521. */
  102522. getClassName(): string;
  102523. /**
  102524. * Serializes the particle system to a JSON object.
  102525. * @returns the JSON object
  102526. */
  102527. serialize(): any;
  102528. /**
  102529. * Parse properties from a JSON object
  102530. * @param serializationObject defines the JSON object
  102531. * @param scene defines the hosting scene
  102532. */
  102533. parse(serializationObject: any, scene: Nullable<Scene>): void;
  102534. }
  102535. }
  102536. declare module BABYLON {
  102537. /**
  102538. * Interface representing a particle system in Babylon.js.
  102539. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  102540. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  102541. */
  102542. export interface IParticleSystem {
  102543. /**
  102544. * List of animations used by the particle system.
  102545. */
  102546. animations: Animation[];
  102547. /**
  102548. * The id of the Particle system.
  102549. */
  102550. id: string;
  102551. /**
  102552. * The name of the Particle system.
  102553. */
  102554. name: string;
  102555. /**
  102556. * The emitter represents the Mesh or position we are attaching the particle system to.
  102557. */
  102558. emitter: Nullable<AbstractMesh | Vector3>;
  102559. /**
  102560. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  102561. */
  102562. isBillboardBased: boolean;
  102563. /**
  102564. * The rendering group used by the Particle system to chose when to render.
  102565. */
  102566. renderingGroupId: number;
  102567. /**
  102568. * The layer mask we are rendering the particles through.
  102569. */
  102570. layerMask: number;
  102571. /**
  102572. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  102573. */
  102574. updateSpeed: number;
  102575. /**
  102576. * The amount of time the particle system is running (depends of the overall update speed).
  102577. */
  102578. targetStopDuration: number;
  102579. /**
  102580. * The texture used to render each particle. (this can be a spritesheet)
  102581. */
  102582. particleTexture: Nullable<BaseTexture>;
  102583. /**
  102584. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  102585. */
  102586. blendMode: number;
  102587. /**
  102588. * Minimum life time of emitting particles.
  102589. */
  102590. minLifeTime: number;
  102591. /**
  102592. * Maximum life time of emitting particles.
  102593. */
  102594. maxLifeTime: number;
  102595. /**
  102596. * Minimum Size of emitting particles.
  102597. */
  102598. minSize: number;
  102599. /**
  102600. * Maximum Size of emitting particles.
  102601. */
  102602. maxSize: number;
  102603. /**
  102604. * Minimum scale of emitting particles on X axis.
  102605. */
  102606. minScaleX: number;
  102607. /**
  102608. * Maximum scale of emitting particles on X axis.
  102609. */
  102610. maxScaleX: number;
  102611. /**
  102612. * Minimum scale of emitting particles on Y axis.
  102613. */
  102614. minScaleY: number;
  102615. /**
  102616. * Maximum scale of emitting particles on Y axis.
  102617. */
  102618. maxScaleY: number;
  102619. /**
  102620. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  102621. */
  102622. color1: Color4;
  102623. /**
  102624. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  102625. */
  102626. color2: Color4;
  102627. /**
  102628. * Color the particle will have at the end of its lifetime.
  102629. */
  102630. colorDead: Color4;
  102631. /**
  102632. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  102633. */
  102634. emitRate: number;
  102635. /**
  102636. * You can use gravity if you want to give an orientation to your particles.
  102637. */
  102638. gravity: Vector3;
  102639. /**
  102640. * Minimum power of emitting particles.
  102641. */
  102642. minEmitPower: number;
  102643. /**
  102644. * Maximum power of emitting particles.
  102645. */
  102646. maxEmitPower: number;
  102647. /**
  102648. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  102649. */
  102650. minAngularSpeed: number;
  102651. /**
  102652. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  102653. */
  102654. maxAngularSpeed: number;
  102655. /**
  102656. * Gets or sets the minimal initial rotation in radians.
  102657. */
  102658. minInitialRotation: number;
  102659. /**
  102660. * Gets or sets the maximal initial rotation in radians.
  102661. */
  102662. maxInitialRotation: number;
  102663. /**
  102664. * The particle emitter type defines the emitter used by the particle system.
  102665. * It can be for example box, sphere, or cone...
  102666. */
  102667. particleEmitterType: Nullable<IParticleEmitterType>;
  102668. /**
  102669. * Defines the delay in milliseconds before starting the system (0 by default)
  102670. */
  102671. startDelay: number;
  102672. /**
  102673. * 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
  102674. */
  102675. preWarmCycles: number;
  102676. /**
  102677. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  102678. */
  102679. preWarmStepOffset: number;
  102680. /**
  102681. * 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)
  102682. */
  102683. spriteCellChangeSpeed: number;
  102684. /**
  102685. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102686. */
  102687. startSpriteCellID: number;
  102688. /**
  102689. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102690. */
  102691. endSpriteCellID: number;
  102692. /**
  102693. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102694. */
  102695. spriteCellWidth: number;
  102696. /**
  102697. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  102698. */
  102699. spriteCellHeight: number;
  102700. /**
  102701. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  102702. */
  102703. spriteRandomStartCell: boolean;
  102704. /**
  102705. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  102706. */
  102707. isAnimationSheetEnabled: boolean;
  102708. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  102709. translationPivot: Vector2;
  102710. /**
  102711. * Gets or sets a texture used to add random noise to particle positions
  102712. */
  102713. noiseTexture: Nullable<BaseTexture>;
  102714. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102715. noiseStrength: Vector3;
  102716. /**
  102717. * Gets or sets the billboard mode to use when isBillboardBased = true.
  102718. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  102719. */
  102720. billboardMode: number;
  102721. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  102722. limitVelocityDamping: number;
  102723. /**
  102724. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  102725. */
  102726. beginAnimationOnStart: boolean;
  102727. /**
  102728. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  102729. */
  102730. beginAnimationFrom: number;
  102731. /**
  102732. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  102733. */
  102734. beginAnimationTo: number;
  102735. /**
  102736. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  102737. */
  102738. beginAnimationLoop: boolean;
  102739. /**
  102740. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  102741. */
  102742. disposeOnStop: boolean;
  102743. /**
  102744. * If you want to launch only a few particles at once, that can be done, as well.
  102745. */
  102746. manualEmitCount: number;
  102747. /**
  102748. * Specifies if the particles are updated in emitter local space or world space
  102749. */
  102750. isLocal: boolean;
  102751. /** Snippet ID if the particle system was created from the snippet server */
  102752. snippetId: string;
  102753. /** Gets or sets a matrix to use to compute projection */
  102754. defaultProjectionMatrix: Matrix;
  102755. /**
  102756. * Gets the maximum number of particles active at the same time.
  102757. * @returns The max number of active particles.
  102758. */
  102759. getCapacity(): number;
  102760. /**
  102761. * Gets the number of particles active at the same time.
  102762. * @returns The number of active particles.
  102763. */
  102764. getActiveCount(): number;
  102765. /**
  102766. * Gets if the system has been started. (Note: this will still be true after stop is called)
  102767. * @returns True if it has been started, otherwise false.
  102768. */
  102769. isStarted(): boolean;
  102770. /**
  102771. * Animates the particle system for this frame.
  102772. */
  102773. animate(): void;
  102774. /**
  102775. * Renders the particle system in its current state.
  102776. * @returns the current number of particles
  102777. */
  102778. render(): number;
  102779. /**
  102780. * Dispose the particle system and frees its associated resources.
  102781. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  102782. */
  102783. dispose(disposeTexture?: boolean): void;
  102784. /**
  102785. * An event triggered when the system is disposed
  102786. */
  102787. onDisposeObservable: Observable<IParticleSystem>;
  102788. /**
  102789. * An event triggered when the system is stopped
  102790. */
  102791. onStoppedObservable: Observable<IParticleSystem>;
  102792. /**
  102793. * Clones the particle system.
  102794. * @param name The name of the cloned object
  102795. * @param newEmitter The new emitter to use
  102796. * @returns the cloned particle system
  102797. */
  102798. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  102799. /**
  102800. * Serializes the particle system to a JSON object
  102801. * @param serializeTexture defines if the texture must be serialized as well
  102802. * @returns the JSON object
  102803. */
  102804. serialize(serializeTexture: boolean): any;
  102805. /**
  102806. * Rebuild the particle system
  102807. */
  102808. rebuild(): void;
  102809. /** Force the system to rebuild all gradients that need to be resync */
  102810. forceRefreshGradients(): void;
  102811. /**
  102812. * Starts the particle system and begins to emit
  102813. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  102814. */
  102815. start(delay?: number): void;
  102816. /**
  102817. * Stops the particle system.
  102818. */
  102819. stop(): void;
  102820. /**
  102821. * Remove all active particles
  102822. */
  102823. reset(): void;
  102824. /**
  102825. * Gets a boolean indicating that the system is stopping
  102826. * @returns true if the system is currently stopping
  102827. */
  102828. isStopping(): boolean;
  102829. /**
  102830. * Is this system ready to be used/rendered
  102831. * @return true if the system is ready
  102832. */
  102833. isReady(): boolean;
  102834. /**
  102835. * Returns the string "ParticleSystem"
  102836. * @returns a string containing the class name
  102837. */
  102838. getClassName(): string;
  102839. /**
  102840. * Gets the custom effect used to render the particles
  102841. * @param blendMode Blend mode for which the effect should be retrieved
  102842. * @returns The effect
  102843. */
  102844. getCustomEffect(blendMode: number): Nullable<Effect>;
  102845. /**
  102846. * Sets the custom effect used to render the particles
  102847. * @param effect The effect to set
  102848. * @param blendMode Blend mode for which the effect should be set
  102849. */
  102850. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  102851. /**
  102852. * Fill the defines array according to the current settings of the particle system
  102853. * @param defines Array to be updated
  102854. * @param blendMode blend mode to take into account when updating the array
  102855. */
  102856. fillDefines(defines: Array<string>, blendMode: number): void;
  102857. /**
  102858. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  102859. * @param uniforms Uniforms array to fill
  102860. * @param attributes Attributes array to fill
  102861. * @param samplers Samplers array to fill
  102862. */
  102863. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  102864. /**
  102865. * Observable that will be called just before the particles are drawn
  102866. */
  102867. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  102868. /**
  102869. * Gets the name of the particle vertex shader
  102870. */
  102871. vertexShaderName: string;
  102872. /**
  102873. * Adds a new color gradient
  102874. * @param gradient defines the gradient to use (between 0 and 1)
  102875. * @param color1 defines the color to affect to the specified gradient
  102876. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  102877. * @returns the current particle system
  102878. */
  102879. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  102880. /**
  102881. * Remove a specific color gradient
  102882. * @param gradient defines the gradient to remove
  102883. * @returns the current particle system
  102884. */
  102885. removeColorGradient(gradient: number): IParticleSystem;
  102886. /**
  102887. * Adds a new size gradient
  102888. * @param gradient defines the gradient to use (between 0 and 1)
  102889. * @param factor defines the size factor to affect to the specified gradient
  102890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102891. * @returns the current particle system
  102892. */
  102893. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102894. /**
  102895. * Remove a specific size gradient
  102896. * @param gradient defines the gradient to remove
  102897. * @returns the current particle system
  102898. */
  102899. removeSizeGradient(gradient: number): IParticleSystem;
  102900. /**
  102901. * Gets the current list of color gradients.
  102902. * You must use addColorGradient and removeColorGradient to update this list
  102903. * @returns the list of color gradients
  102904. */
  102905. getColorGradients(): Nullable<Array<ColorGradient>>;
  102906. /**
  102907. * Gets the current list of size gradients.
  102908. * You must use addSizeGradient and removeSizeGradient to update this list
  102909. * @returns the list of size gradients
  102910. */
  102911. getSizeGradients(): Nullable<Array<FactorGradient>>;
  102912. /**
  102913. * Gets the current list of angular speed gradients.
  102914. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  102915. * @returns the list of angular speed gradients
  102916. */
  102917. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  102918. /**
  102919. * Adds a new angular speed gradient
  102920. * @param gradient defines the gradient to use (between 0 and 1)
  102921. * @param factor defines the angular speed to affect to the specified gradient
  102922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102923. * @returns the current particle system
  102924. */
  102925. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102926. /**
  102927. * Remove a specific angular speed gradient
  102928. * @param gradient defines the gradient to remove
  102929. * @returns the current particle system
  102930. */
  102931. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  102932. /**
  102933. * Gets the current list of velocity gradients.
  102934. * You must use addVelocityGradient and removeVelocityGradient to update this list
  102935. * @returns the list of velocity gradients
  102936. */
  102937. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  102938. /**
  102939. * Adds a new velocity gradient
  102940. * @param gradient defines the gradient to use (between 0 and 1)
  102941. * @param factor defines the velocity to affect to the specified gradient
  102942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102943. * @returns the current particle system
  102944. */
  102945. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102946. /**
  102947. * Remove a specific velocity gradient
  102948. * @param gradient defines the gradient to remove
  102949. * @returns the current particle system
  102950. */
  102951. removeVelocityGradient(gradient: number): IParticleSystem;
  102952. /**
  102953. * Gets the current list of limit velocity gradients.
  102954. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  102955. * @returns the list of limit velocity gradients
  102956. */
  102957. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  102958. /**
  102959. * Adds a new limit velocity gradient
  102960. * @param gradient defines the gradient to use (between 0 and 1)
  102961. * @param factor defines the limit velocity to affect to the specified gradient
  102962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102963. * @returns the current particle system
  102964. */
  102965. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102966. /**
  102967. * Remove a specific limit velocity gradient
  102968. * @param gradient defines the gradient to remove
  102969. * @returns the current particle system
  102970. */
  102971. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  102972. /**
  102973. * Adds a new drag gradient
  102974. * @param gradient defines the gradient to use (between 0 and 1)
  102975. * @param factor defines the drag to affect to the specified gradient
  102976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102977. * @returns the current particle system
  102978. */
  102979. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102980. /**
  102981. * Remove a specific drag gradient
  102982. * @param gradient defines the gradient to remove
  102983. * @returns the current particle system
  102984. */
  102985. removeDragGradient(gradient: number): IParticleSystem;
  102986. /**
  102987. * Gets the current list of drag gradients.
  102988. * You must use addDragGradient and removeDragGradient to update this list
  102989. * @returns the list of drag gradients
  102990. */
  102991. getDragGradients(): Nullable<Array<FactorGradient>>;
  102992. /**
  102993. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  102994. * @param gradient defines the gradient to use (between 0 and 1)
  102995. * @param factor defines the emit rate to affect to the specified gradient
  102996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102997. * @returns the current particle system
  102998. */
  102999. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  103000. /**
  103001. * Remove a specific emit rate gradient
  103002. * @param gradient defines the gradient to remove
  103003. * @returns the current particle system
  103004. */
  103005. removeEmitRateGradient(gradient: number): IParticleSystem;
  103006. /**
  103007. * Gets the current list of emit rate gradients.
  103008. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  103009. * @returns the list of emit rate gradients
  103010. */
  103011. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  103012. /**
  103013. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  103014. * @param gradient defines the gradient to use (between 0 and 1)
  103015. * @param factor defines the start size to affect to the specified gradient
  103016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103017. * @returns the current particle system
  103018. */
  103019. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  103020. /**
  103021. * Remove a specific start size gradient
  103022. * @param gradient defines the gradient to remove
  103023. * @returns the current particle system
  103024. */
  103025. removeStartSizeGradient(gradient: number): IParticleSystem;
  103026. /**
  103027. * Gets the current list of start size gradients.
  103028. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  103029. * @returns the list of start size gradients
  103030. */
  103031. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  103032. /**
  103033. * Adds a new life time gradient
  103034. * @param gradient defines the gradient to use (between 0 and 1)
  103035. * @param factor defines the life time factor to affect to the specified gradient
  103036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103037. * @returns the current particle system
  103038. */
  103039. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  103040. /**
  103041. * Remove a specific life time gradient
  103042. * @param gradient defines the gradient to remove
  103043. * @returns the current particle system
  103044. */
  103045. removeLifeTimeGradient(gradient: number): IParticleSystem;
  103046. /**
  103047. * Gets the current list of life time gradients.
  103048. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  103049. * @returns the list of life time gradients
  103050. */
  103051. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  103052. /**
  103053. * Gets the current list of color gradients.
  103054. * You must use addColorGradient and removeColorGradient to update this list
  103055. * @returns the list of color gradients
  103056. */
  103057. getColorGradients(): Nullable<Array<ColorGradient>>;
  103058. /**
  103059. * Adds a new ramp gradient used to remap particle colors
  103060. * @param gradient defines the gradient to use (between 0 and 1)
  103061. * @param color defines the color to affect to the specified gradient
  103062. * @returns the current particle system
  103063. */
  103064. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  103065. /**
  103066. * Gets the current list of ramp gradients.
  103067. * You must use addRampGradient and removeRampGradient to update this list
  103068. * @returns the list of ramp gradients
  103069. */
  103070. getRampGradients(): Nullable<Array<Color3Gradient>>;
  103071. /** Gets or sets a boolean indicating that ramp gradients must be used
  103072. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  103073. */
  103074. useRampGradients: boolean;
  103075. /**
  103076. * Adds a new color remap gradient
  103077. * @param gradient defines the gradient to use (between 0 and 1)
  103078. * @param min defines the color remap minimal range
  103079. * @param max defines the color remap maximal range
  103080. * @returns the current particle system
  103081. */
  103082. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  103083. /**
  103084. * Gets the current list of color remap gradients.
  103085. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  103086. * @returns the list of color remap gradients
  103087. */
  103088. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  103089. /**
  103090. * Adds a new alpha remap gradient
  103091. * @param gradient defines the gradient to use (between 0 and 1)
  103092. * @param min defines the alpha remap minimal range
  103093. * @param max defines the alpha remap maximal range
  103094. * @returns the current particle system
  103095. */
  103096. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  103097. /**
  103098. * Gets the current list of alpha remap gradients.
  103099. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  103100. * @returns the list of alpha remap gradients
  103101. */
  103102. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  103103. /**
  103104. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  103105. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103106. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103107. * @returns the emitter
  103108. */
  103109. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  103110. /**
  103111. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  103112. * @param radius The radius of the hemisphere to emit from
  103113. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103114. * @returns the emitter
  103115. */
  103116. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  103117. /**
  103118. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  103119. * @param radius The radius of the sphere to emit from
  103120. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103121. * @returns the emitter
  103122. */
  103123. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  103124. /**
  103125. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  103126. * @param radius The radius of the sphere to emit from
  103127. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  103128. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  103129. * @returns the emitter
  103130. */
  103131. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  103132. /**
  103133. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  103134. * @param radius The radius of the emission cylinder
  103135. * @param height The height of the emission cylinder
  103136. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  103137. * @param directionRandomizer How much to randomize the particle direction [0-1]
  103138. * @returns the emitter
  103139. */
  103140. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  103141. /**
  103142. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  103143. * @param radius The radius of the cylinder to emit from
  103144. * @param height The height of the emission cylinder
  103145. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103146. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  103147. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  103148. * @returns the emitter
  103149. */
  103150. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  103151. /**
  103152. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  103153. * @param radius The radius of the cone to emit from
  103154. * @param angle The base angle of the cone
  103155. * @returns the emitter
  103156. */
  103157. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  103158. /**
  103159. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  103160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103162. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103163. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103164. * @returns the emitter
  103165. */
  103166. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  103167. /**
  103168. * Get hosting scene
  103169. * @returns the scene
  103170. */
  103171. getScene(): Nullable<Scene>;
  103172. }
  103173. }
  103174. declare module BABYLON {
  103175. /**
  103176. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103177. */
  103178. export class ColorSplitterBlock extends NodeMaterialBlock {
  103179. /**
  103180. * Create a new ColorSplitterBlock
  103181. * @param name defines the block name
  103182. */
  103183. constructor(name: string);
  103184. /**
  103185. * Gets the current class name
  103186. * @returns the class name
  103187. */
  103188. getClassName(): string;
  103189. /**
  103190. * Gets the rgba component (input)
  103191. */
  103192. get rgba(): NodeMaterialConnectionPoint;
  103193. /**
  103194. * Gets the rgb component (input)
  103195. */
  103196. get rgbIn(): NodeMaterialConnectionPoint;
  103197. /**
  103198. * Gets the rgb component (output)
  103199. */
  103200. get rgbOut(): NodeMaterialConnectionPoint;
  103201. /**
  103202. * Gets the r component (output)
  103203. */
  103204. get r(): NodeMaterialConnectionPoint;
  103205. /**
  103206. * Gets the g component (output)
  103207. */
  103208. get g(): NodeMaterialConnectionPoint;
  103209. /**
  103210. * Gets the b component (output)
  103211. */
  103212. get b(): NodeMaterialConnectionPoint;
  103213. /**
  103214. * Gets the a component (output)
  103215. */
  103216. get a(): NodeMaterialConnectionPoint;
  103217. protected _inputRename(name: string): string;
  103218. protected _outputRename(name: string): string;
  103219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103220. }
  103221. }
  103222. declare module BABYLON {
  103223. /**
  103224. * Operations supported by the Trigonometry block
  103225. */
  103226. export enum TrigonometryBlockOperations {
  103227. /** Cos */
  103228. Cos = 0,
  103229. /** Sin */
  103230. Sin = 1,
  103231. /** Abs */
  103232. Abs = 2,
  103233. /** Exp */
  103234. Exp = 3,
  103235. /** Exp2 */
  103236. Exp2 = 4,
  103237. /** Round */
  103238. Round = 5,
  103239. /** Floor */
  103240. Floor = 6,
  103241. /** Ceiling */
  103242. Ceiling = 7,
  103243. /** Square root */
  103244. Sqrt = 8,
  103245. /** Log */
  103246. Log = 9,
  103247. /** Tangent */
  103248. Tan = 10,
  103249. /** Arc tangent */
  103250. ArcTan = 11,
  103251. /** Arc cosinus */
  103252. ArcCos = 12,
  103253. /** Arc sinus */
  103254. ArcSin = 13,
  103255. /** Fraction */
  103256. Fract = 14,
  103257. /** Sign */
  103258. Sign = 15,
  103259. /** To radians (from degrees) */
  103260. Radians = 16,
  103261. /** To degrees (from radians) */
  103262. Degrees = 17
  103263. }
  103264. /**
  103265. * Block used to apply trigonometry operation to floats
  103266. */
  103267. export class TrigonometryBlock extends NodeMaterialBlock {
  103268. /**
  103269. * Gets or sets the operation applied by the block
  103270. */
  103271. operation: TrigonometryBlockOperations;
  103272. /**
  103273. * Creates a new TrigonometryBlock
  103274. * @param name defines the block name
  103275. */
  103276. constructor(name: string);
  103277. /**
  103278. * Gets the current class name
  103279. * @returns the class name
  103280. */
  103281. getClassName(): string;
  103282. /**
  103283. * Gets the input component
  103284. */
  103285. get input(): NodeMaterialConnectionPoint;
  103286. /**
  103287. * Gets the output component
  103288. */
  103289. get output(): NodeMaterialConnectionPoint;
  103290. protected _buildBlock(state: NodeMaterialBuildState): this;
  103291. serialize(): any;
  103292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103293. protected _dumpPropertiesCode(): string;
  103294. }
  103295. }
  103296. declare module BABYLON {
  103297. /**
  103298. * Interface used to configure the node material editor
  103299. */
  103300. export interface INodeMaterialEditorOptions {
  103301. /** Define the URl to load node editor script */
  103302. editorURL?: string;
  103303. }
  103304. /** @hidden */
  103305. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103306. NORMAL: boolean;
  103307. TANGENT: boolean;
  103308. UV1: boolean;
  103309. /** BONES */
  103310. NUM_BONE_INFLUENCERS: number;
  103311. BonesPerMesh: number;
  103312. BONETEXTURE: boolean;
  103313. /** MORPH TARGETS */
  103314. MORPHTARGETS: boolean;
  103315. MORPHTARGETS_NORMAL: boolean;
  103316. MORPHTARGETS_TANGENT: boolean;
  103317. MORPHTARGETS_UV: boolean;
  103318. NUM_MORPH_INFLUENCERS: number;
  103319. MORPHTARGETS_TEXTURE: boolean;
  103320. /** IMAGE PROCESSING */
  103321. IMAGEPROCESSING: boolean;
  103322. VIGNETTE: boolean;
  103323. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103324. VIGNETTEBLENDMODEOPAQUE: boolean;
  103325. TONEMAPPING: boolean;
  103326. TONEMAPPING_ACES: boolean;
  103327. CONTRAST: boolean;
  103328. EXPOSURE: boolean;
  103329. COLORCURVES: boolean;
  103330. COLORGRADING: boolean;
  103331. COLORGRADING3D: boolean;
  103332. SAMPLER3DGREENDEPTH: boolean;
  103333. SAMPLER3DBGRMAP: boolean;
  103334. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103335. /** MISC. */
  103336. BUMPDIRECTUV: number;
  103337. constructor();
  103338. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103339. }
  103340. /**
  103341. * Class used to configure NodeMaterial
  103342. */
  103343. export interface INodeMaterialOptions {
  103344. /**
  103345. * Defines if blocks should emit comments
  103346. */
  103347. emitComments: boolean;
  103348. }
  103349. /**
  103350. * Class used to create a node based material built by assembling shader blocks
  103351. */
  103352. export class NodeMaterial extends PushMaterial {
  103353. private static _BuildIdGenerator;
  103354. private _options;
  103355. private _vertexCompilationState;
  103356. private _fragmentCompilationState;
  103357. private _sharedData;
  103358. private _buildId;
  103359. private _buildWasSuccessful;
  103360. private _cachedWorldViewMatrix;
  103361. private _cachedWorldViewProjectionMatrix;
  103362. private _optimizers;
  103363. private _animationFrame;
  103364. /** Define the Url to load node editor script */
  103365. static EditorURL: string;
  103366. /** Define the Url to load snippets */
  103367. static SnippetUrl: string;
  103368. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103369. static IgnoreTexturesAtLoadTime: boolean;
  103370. private BJSNODEMATERIALEDITOR;
  103371. /** Get the inspector from bundle or global */
  103372. private _getGlobalNodeMaterialEditor;
  103373. /**
  103374. * Snippet ID if the material was created from the snippet server
  103375. */
  103376. snippetId: string;
  103377. /**
  103378. * Gets or sets data used by visual editor
  103379. * @see https://nme.babylonjs.com
  103380. */
  103381. editorData: any;
  103382. /**
  103383. * 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)
  103384. */
  103385. ignoreAlpha: boolean;
  103386. /**
  103387. * Defines the maximum number of lights that can be used in the material
  103388. */
  103389. maxSimultaneousLights: number;
  103390. /**
  103391. * Observable raised when the material is built
  103392. */
  103393. onBuildObservable: Observable<NodeMaterial>;
  103394. /**
  103395. * Gets or sets the root nodes of the material vertex shader
  103396. */
  103397. _vertexOutputNodes: NodeMaterialBlock[];
  103398. /**
  103399. * Gets or sets the root nodes of the material fragment (pixel) shader
  103400. */
  103401. _fragmentOutputNodes: NodeMaterialBlock[];
  103402. /** Gets or sets options to control the node material overall behavior */
  103403. get options(): INodeMaterialOptions;
  103404. set options(options: INodeMaterialOptions);
  103405. /**
  103406. * Default configuration related to image processing available in the standard Material.
  103407. */
  103408. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103409. /**
  103410. * Gets the image processing configuration used either in this material.
  103411. */
  103412. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103413. /**
  103414. * Sets the Default image processing configuration used either in the this material.
  103415. *
  103416. * If sets to null, the scene one is in use.
  103417. */
  103418. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103419. /**
  103420. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103421. */
  103422. attachedBlocks: NodeMaterialBlock[];
  103423. /**
  103424. * Specifies the mode of the node material
  103425. * @hidden
  103426. */
  103427. _mode: NodeMaterialModes;
  103428. /**
  103429. * Gets the mode property
  103430. */
  103431. get mode(): NodeMaterialModes;
  103432. /**
  103433. * A free comment about the material
  103434. */
  103435. comment: string;
  103436. /**
  103437. * Create a new node based material
  103438. * @param name defines the material name
  103439. * @param scene defines the hosting scene
  103440. * @param options defines creation option
  103441. */
  103442. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103443. /**
  103444. * Gets the current class name of the material e.g. "NodeMaterial"
  103445. * @returns the class name
  103446. */
  103447. getClassName(): string;
  103448. /**
  103449. * Keep track of the image processing observer to allow dispose and replace.
  103450. */
  103451. private _imageProcessingObserver;
  103452. /**
  103453. * Attaches a new image processing configuration to the Standard Material.
  103454. * @param configuration
  103455. */
  103456. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103457. /**
  103458. * Get a block by its name
  103459. * @param name defines the name of the block to retrieve
  103460. * @returns the required block or null if not found
  103461. */
  103462. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103463. /**
  103464. * Get a block by its name
  103465. * @param predicate defines the predicate used to find the good candidate
  103466. * @returns the required block or null if not found
  103467. */
  103468. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103469. /**
  103470. * Get an input block by its name
  103471. * @param predicate defines the predicate used to find the good candidate
  103472. * @returns the required input block or null if not found
  103473. */
  103474. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103475. /**
  103476. * Gets the list of input blocks attached to this material
  103477. * @returns an array of InputBlocks
  103478. */
  103479. getInputBlocks(): InputBlock[];
  103480. /**
  103481. * Adds a new optimizer to the list of optimizers
  103482. * @param optimizer defines the optimizers to add
  103483. * @returns the current material
  103484. */
  103485. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103486. /**
  103487. * Remove an optimizer from the list of optimizers
  103488. * @param optimizer defines the optimizers to remove
  103489. * @returns the current material
  103490. */
  103491. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103492. /**
  103493. * Add a new block to the list of output nodes
  103494. * @param node defines the node to add
  103495. * @returns the current material
  103496. */
  103497. addOutputNode(node: NodeMaterialBlock): this;
  103498. /**
  103499. * Remove a block from the list of root nodes
  103500. * @param node defines the node to remove
  103501. * @returns the current material
  103502. */
  103503. removeOutputNode(node: NodeMaterialBlock): this;
  103504. private _addVertexOutputNode;
  103505. private _removeVertexOutputNode;
  103506. private _addFragmentOutputNode;
  103507. private _removeFragmentOutputNode;
  103508. /**
  103509. * Specifies if the material will require alpha blending
  103510. * @returns a boolean specifying if alpha blending is needed
  103511. */
  103512. needAlphaBlending(): boolean;
  103513. /**
  103514. * Specifies if this material should be rendered in alpha test mode
  103515. * @returns a boolean specifying if an alpha test is needed.
  103516. */
  103517. needAlphaTesting(): boolean;
  103518. private _initializeBlock;
  103519. private _resetDualBlocks;
  103520. /**
  103521. * Remove a block from the current node material
  103522. * @param block defines the block to remove
  103523. */
  103524. removeBlock(block: NodeMaterialBlock): void;
  103525. /**
  103526. * Build the material and generates the inner effect
  103527. * @param verbose defines if the build should log activity
  103528. */
  103529. build(verbose?: boolean): void;
  103530. /**
  103531. * Runs an otpimization phase to try to improve the shader code
  103532. */
  103533. optimize(): void;
  103534. private _prepareDefinesForAttributes;
  103535. /**
  103536. * Create a post process from the material
  103537. * @param camera The camera to apply the render pass to.
  103538. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103540. * @param engine The engine which the post process will be applied. (default: current engine)
  103541. * @param reusable If the post process can be reused on the same frame. (default: false)
  103542. * @param textureType Type of textures used when performing the post process. (default: 0)
  103543. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103544. * @returns the post process created
  103545. */
  103546. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103547. /**
  103548. * Create the post process effect from the material
  103549. * @param postProcess The post process to create the effect for
  103550. */
  103551. createEffectForPostProcess(postProcess: PostProcess): void;
  103552. private _createEffectForPostProcess;
  103553. /**
  103554. * Create a new procedural texture based on this node material
  103555. * @param size defines the size of the texture
  103556. * @param scene defines the hosting scene
  103557. * @returns the new procedural texture attached to this node material
  103558. */
  103559. createProceduralTexture(size: number | {
  103560. width: number;
  103561. height: number;
  103562. layers?: number;
  103563. }, scene: Scene): Nullable<ProceduralTexture>;
  103564. private _createEffectForParticles;
  103565. private _checkInternals;
  103566. /**
  103567. * Create the effect to be used as the custom effect for a particle system
  103568. * @param particleSystem Particle system to create the effect for
  103569. * @param onCompiled defines a function to call when the effect creation is successful
  103570. * @param onError defines a function to call when the effect creation has failed
  103571. */
  103572. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103573. private _processDefines;
  103574. /**
  103575. * Get if the submesh is ready to be used and all its information available.
  103576. * Child classes can use it to update shaders
  103577. * @param mesh defines the mesh to check
  103578. * @param subMesh defines which submesh to check
  103579. * @param useInstances specifies that instances should be used
  103580. * @returns a boolean indicating that the submesh is ready or not
  103581. */
  103582. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103583. /**
  103584. * Get a string representing the shaders built by the current node graph
  103585. */
  103586. get compiledShaders(): string;
  103587. /**
  103588. * Binds the world matrix to the material
  103589. * @param world defines the world transformation matrix
  103590. */
  103591. bindOnlyWorldMatrix(world: Matrix): void;
  103592. /**
  103593. * Binds the submesh to this material by preparing the effect and shader to draw
  103594. * @param world defines the world transformation matrix
  103595. * @param mesh defines the mesh containing the submesh
  103596. * @param subMesh defines the submesh to bind the material to
  103597. */
  103598. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103599. /**
  103600. * Gets the active textures from the material
  103601. * @returns an array of textures
  103602. */
  103603. getActiveTextures(): BaseTexture[];
  103604. /**
  103605. * Gets the list of texture blocks
  103606. * @returns an array of texture blocks
  103607. */
  103608. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103609. /**
  103610. * Specifies if the material uses a texture
  103611. * @param texture defines the texture to check against the material
  103612. * @returns a boolean specifying if the material uses the texture
  103613. */
  103614. hasTexture(texture: BaseTexture): boolean;
  103615. /**
  103616. * Disposes the material
  103617. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103618. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103619. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103620. */
  103621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103622. /** Creates the node editor window. */
  103623. private _createNodeEditor;
  103624. /**
  103625. * Launch the node material editor
  103626. * @param config Define the configuration of the editor
  103627. * @return a promise fulfilled when the node editor is visible
  103628. */
  103629. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103630. /**
  103631. * Clear the current material
  103632. */
  103633. clear(): void;
  103634. /**
  103635. * Clear the current material and set it to a default state
  103636. */
  103637. setToDefault(): void;
  103638. /**
  103639. * Clear the current material and set it to a default state for post process
  103640. */
  103641. setToDefaultPostProcess(): void;
  103642. /**
  103643. * Clear the current material and set it to a default state for procedural texture
  103644. */
  103645. setToDefaultProceduralTexture(): void;
  103646. /**
  103647. * Clear the current material and set it to a default state for particle
  103648. */
  103649. setToDefaultParticle(): void;
  103650. /**
  103651. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103652. * @param url defines the url to load from
  103653. * @returns a promise that will fulfil when the material is fully loaded
  103654. */
  103655. loadAsync(url: string): Promise<void>;
  103656. private _gatherBlocks;
  103657. /**
  103658. * Generate a string containing the code declaration required to create an equivalent of this material
  103659. * @returns a string
  103660. */
  103661. generateCode(): string;
  103662. /**
  103663. * Serializes this material in a JSON representation
  103664. * @returns the serialized material object
  103665. */
  103666. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103667. private _restoreConnections;
  103668. /**
  103669. * Clear the current graph and load a new one from a serialization object
  103670. * @param source defines the JSON representation of the material
  103671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103672. * @param merge defines whether or not the source must be merged or replace the current content
  103673. */
  103674. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103675. /**
  103676. * Makes a duplicate of the current material.
  103677. * @param name - name to use for the new material.
  103678. */
  103679. clone(name: string): NodeMaterial;
  103680. /**
  103681. * Creates a node material from parsed material data
  103682. * @param source defines the JSON representation of the material
  103683. * @param scene defines the hosting scene
  103684. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103685. * @returns a new node material
  103686. */
  103687. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103688. /**
  103689. * Creates a node material from a snippet saved in a remote file
  103690. * @param name defines the name of the material to create
  103691. * @param url defines the url to load from
  103692. * @param scene defines the hosting scene
  103693. * @returns a promise that will resolve to the new node material
  103694. */
  103695. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103696. /**
  103697. * Creates a node material from a snippet saved by the node material editor
  103698. * @param snippetId defines the snippet to load
  103699. * @param scene defines the hosting scene
  103700. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103701. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103702. * @returns a promise that will resolve to the new node material
  103703. */
  103704. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103705. /**
  103706. * Creates a new node material set to default basic configuration
  103707. * @param name defines the name of the material
  103708. * @param scene defines the hosting scene
  103709. * @returns a new NodeMaterial
  103710. */
  103711. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103712. }
  103713. }
  103714. declare module BABYLON {
  103715. interface ThinEngine {
  103716. /**
  103717. * Unbind a list of render target textures from the webGL context
  103718. * This is used only when drawBuffer extension or webGL2 are active
  103719. * @param textures defines the render target textures to unbind
  103720. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103721. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103722. */
  103723. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103724. /**
  103725. * Create a multi render target texture
  103726. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103727. * @param size defines the size of the texture
  103728. * @param options defines the creation options
  103729. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  103730. * @returns the cube texture as an InternalTexture
  103731. */
  103732. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  103733. /**
  103734. * Update the sample count for a given multiple render target texture
  103735. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103736. * @param textures defines the textures to update
  103737. * @param samples defines the sample count to set
  103738. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  103739. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103740. */
  103741. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  103742. /**
  103743. * Select a subsets of attachments to draw to.
  103744. * @param attachments gl attachments
  103745. */
  103746. bindAttachments(attachments: number[]): void;
  103747. /**
  103748. * Creates a layout object to draw/clear on specific textures in a MRT
  103749. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103750. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103751. */
  103752. buildTextureLayout(textureStatus: boolean[]): number[];
  103753. /**
  103754. * Restores the webgl state to only draw on the main color attachment
  103755. * when the frame buffer associated is the canvas frame buffer
  103756. */
  103757. restoreSingleAttachment(): void;
  103758. /**
  103759. * Restores the webgl state to only draw on the main color attachment
  103760. * when the frame buffer associated is not the canvas frame buffer
  103761. */
  103762. restoreSingleAttachmentForRenderTarget(): void;
  103763. /**
  103764. * Clears a list of attachments
  103765. * @param attachments list of the attachments
  103766. * @param colorMain clear color for the main attachment (the first one)
  103767. * @param colorOthers clear color for the other attachments
  103768. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  103769. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  103770. */
  103771. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  103772. }
  103773. }
  103774. declare module BABYLON {
  103775. /**
  103776. * Creation options of the multi render target texture.
  103777. */
  103778. export interface IMultiRenderTargetOptions {
  103779. /**
  103780. * Define if the texture needs to create mip maps after render.
  103781. */
  103782. generateMipMaps?: boolean;
  103783. /**
  103784. * Define the types of all the draw buffers we want to create
  103785. */
  103786. types?: number[];
  103787. /**
  103788. * Define the sampling modes of all the draw buffers we want to create
  103789. */
  103790. samplingModes?: number[];
  103791. /**
  103792. * Define if a depth buffer is required
  103793. */
  103794. generateDepthBuffer?: boolean;
  103795. /**
  103796. * Define if a stencil buffer is required
  103797. */
  103798. generateStencilBuffer?: boolean;
  103799. /**
  103800. * Define if a depth texture is required instead of a depth buffer
  103801. */
  103802. generateDepthTexture?: boolean;
  103803. /**
  103804. * Define the number of desired draw buffers
  103805. */
  103806. textureCount?: number;
  103807. /**
  103808. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103809. */
  103810. doNotChangeAspectRatio?: boolean;
  103811. /**
  103812. * Define the default type of the buffers we are creating
  103813. */
  103814. defaultType?: number;
  103815. /**
  103816. * Define the default type of the buffers we are creating
  103817. */
  103818. drawOnlyOnFirstAttachmentByDefault?: boolean;
  103819. }
  103820. /**
  103821. * A multi render target, like a render target provides the ability to render to a texture.
  103822. * Unlike the render target, it can render to several draw buffers in one draw.
  103823. * This is specially interesting in deferred rendering or for any effects requiring more than
  103824. * just one color from a single pass.
  103825. */
  103826. export class MultiRenderTarget extends RenderTargetTexture {
  103827. private _internalTextures;
  103828. private _textures;
  103829. private _multiRenderTargetOptions;
  103830. private _count;
  103831. private _drawOnlyOnFirstAttachmentByDefault;
  103832. /**
  103833. * Get if draw buffers are currently supported by the used hardware and browser.
  103834. */
  103835. get isSupported(): boolean;
  103836. /**
  103837. * Get the list of textures generated by the multi render target.
  103838. */
  103839. get textures(): Texture[];
  103840. /**
  103841. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103842. */
  103843. get count(): number;
  103844. /**
  103845. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103846. */
  103847. get depthTexture(): Texture;
  103848. /**
  103849. * Set the wrapping mode on U of all the textures we are rendering to.
  103850. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103851. */
  103852. set wrapU(wrap: number);
  103853. /**
  103854. * Set the wrapping mode on V of all the textures we are rendering to.
  103855. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103856. */
  103857. set wrapV(wrap: number);
  103858. /**
  103859. * Instantiate a new multi render target texture.
  103860. * A multi render target, like a render target provides the ability to render to a texture.
  103861. * Unlike the render target, it can render to several draw buffers in one draw.
  103862. * This is specially interesting in deferred rendering or for any effects requiring more than
  103863. * just one color from a single pass.
  103864. * @param name Define the name of the texture
  103865. * @param size Define the size of the buffers to render to
  103866. * @param count Define the number of target we are rendering into
  103867. * @param scene Define the scene the texture belongs to
  103868. * @param options Define the options used to create the multi render target
  103869. */
  103870. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103871. private _initTypes;
  103872. /** @hidden */
  103873. _rebuild(forceFullRebuild?: boolean): void;
  103874. private _createInternalTextures;
  103875. private _createTextures;
  103876. /**
  103877. * Replaces a texture within the MRT.
  103878. * @param texture The new texture to insert in the MRT
  103879. * @param index The index of the texture to replace
  103880. */
  103881. replaceTexture(texture: Texture, index: number): void;
  103882. /**
  103883. * Define the number of samples used if MSAA is enabled.
  103884. */
  103885. get samples(): number;
  103886. set samples(value: number);
  103887. /**
  103888. * Resize all the textures in the multi render target.
  103889. * Be careful as it will recreate all the data in the new texture.
  103890. * @param size Define the new size
  103891. */
  103892. resize(size: any): void;
  103893. /**
  103894. * Changes the number of render targets in this MRT
  103895. * Be careful as it will recreate all the data in the new texture.
  103896. * @param count new texture count
  103897. * @param options Specifies texture types and sampling modes for new textures
  103898. */
  103899. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103900. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103901. /**
  103902. * Dispose the render targets and their associated resources
  103903. */
  103904. dispose(): void;
  103905. /**
  103906. * Release all the underlying texture used as draw buffers.
  103907. */
  103908. releaseInternalTextures(): void;
  103909. }
  103910. }
  103911. declare module BABYLON {
  103912. /** @hidden */
  103913. export var imageProcessingPixelShader: {
  103914. name: string;
  103915. shader: string;
  103916. };
  103917. }
  103918. declare module BABYLON {
  103919. /**
  103920. * ImageProcessingPostProcess
  103921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103922. */
  103923. export class ImageProcessingPostProcess extends PostProcess {
  103924. /**
  103925. * Default configuration related to image processing available in the PBR Material.
  103926. */
  103927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103928. /**
  103929. * Gets the image processing configuration used either in this material.
  103930. */
  103931. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103932. /**
  103933. * Sets the Default image processing configuration used either in the this material.
  103934. *
  103935. * If sets to null, the scene one is in use.
  103936. */
  103937. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103938. /**
  103939. * Keep track of the image processing observer to allow dispose and replace.
  103940. */
  103941. private _imageProcessingObserver;
  103942. /**
  103943. * Attaches a new image processing configuration to the PBR Material.
  103944. * @param configuration
  103945. */
  103946. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103947. /**
  103948. * If the post process is supported.
  103949. */
  103950. get isSupported(): boolean;
  103951. /**
  103952. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103953. */
  103954. get colorCurves(): Nullable<ColorCurves>;
  103955. /**
  103956. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103957. */
  103958. set colorCurves(value: Nullable<ColorCurves>);
  103959. /**
  103960. * Gets whether the color curves effect is enabled.
  103961. */
  103962. get colorCurvesEnabled(): boolean;
  103963. /**
  103964. * Sets whether the color curves effect is enabled.
  103965. */
  103966. set colorCurvesEnabled(value: boolean);
  103967. /**
  103968. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103969. */
  103970. get colorGradingTexture(): Nullable<BaseTexture>;
  103971. /**
  103972. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103973. */
  103974. set colorGradingTexture(value: Nullable<BaseTexture>);
  103975. /**
  103976. * Gets whether the color grading effect is enabled.
  103977. */
  103978. get colorGradingEnabled(): boolean;
  103979. /**
  103980. * Gets whether the color grading effect is enabled.
  103981. */
  103982. set colorGradingEnabled(value: boolean);
  103983. /**
  103984. * Gets exposure used in the effect.
  103985. */
  103986. get exposure(): number;
  103987. /**
  103988. * Sets exposure used in the effect.
  103989. */
  103990. set exposure(value: number);
  103991. /**
  103992. * Gets whether tonemapping is enabled or not.
  103993. */
  103994. get toneMappingEnabled(): boolean;
  103995. /**
  103996. * Sets whether tonemapping is enabled or not
  103997. */
  103998. set toneMappingEnabled(value: boolean);
  103999. /**
  104000. * Gets the type of tone mapping effect.
  104001. */
  104002. get toneMappingType(): number;
  104003. /**
  104004. * Sets the type of tone mapping effect.
  104005. */
  104006. set toneMappingType(value: number);
  104007. /**
  104008. * Gets contrast used in the effect.
  104009. */
  104010. get contrast(): number;
  104011. /**
  104012. * Sets contrast used in the effect.
  104013. */
  104014. set contrast(value: number);
  104015. /**
  104016. * Gets Vignette stretch size.
  104017. */
  104018. get vignetteStretch(): number;
  104019. /**
  104020. * Sets Vignette stretch size.
  104021. */
  104022. set vignetteStretch(value: number);
  104023. /**
  104024. * Gets Vignette centre X Offset.
  104025. */
  104026. get vignetteCentreX(): number;
  104027. /**
  104028. * Sets Vignette centre X Offset.
  104029. */
  104030. set vignetteCentreX(value: number);
  104031. /**
  104032. * Gets Vignette centre Y Offset.
  104033. */
  104034. get vignetteCentreY(): number;
  104035. /**
  104036. * Sets Vignette centre Y Offset.
  104037. */
  104038. set vignetteCentreY(value: number);
  104039. /**
  104040. * Gets Vignette weight or intensity of the vignette effect.
  104041. */
  104042. get vignetteWeight(): number;
  104043. /**
  104044. * Sets Vignette weight or intensity of the vignette effect.
  104045. */
  104046. set vignetteWeight(value: number);
  104047. /**
  104048. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104049. * if vignetteEnabled is set to true.
  104050. */
  104051. get vignetteColor(): Color4;
  104052. /**
  104053. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104054. * if vignetteEnabled is set to true.
  104055. */
  104056. set vignetteColor(value: Color4);
  104057. /**
  104058. * Gets Camera field of view used by the Vignette effect.
  104059. */
  104060. get vignetteCameraFov(): number;
  104061. /**
  104062. * Sets Camera field of view used by the Vignette effect.
  104063. */
  104064. set vignetteCameraFov(value: number);
  104065. /**
  104066. * Gets the vignette blend mode allowing different kind of effect.
  104067. */
  104068. get vignetteBlendMode(): number;
  104069. /**
  104070. * Sets the vignette blend mode allowing different kind of effect.
  104071. */
  104072. set vignetteBlendMode(value: number);
  104073. /**
  104074. * Gets whether the vignette effect is enabled.
  104075. */
  104076. get vignetteEnabled(): boolean;
  104077. /**
  104078. * Sets whether the vignette effect is enabled.
  104079. */
  104080. set vignetteEnabled(value: boolean);
  104081. private _fromLinearSpace;
  104082. /**
  104083. * Gets whether the input of the processing is in Gamma or Linear Space.
  104084. */
  104085. get fromLinearSpace(): boolean;
  104086. /**
  104087. * Sets whether the input of the processing is in Gamma or Linear Space.
  104088. */
  104089. set fromLinearSpace(value: boolean);
  104090. /**
  104091. * Defines cache preventing GC.
  104092. */
  104093. private _defines;
  104094. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104095. /**
  104096. * "ImageProcessingPostProcess"
  104097. * @returns "ImageProcessingPostProcess"
  104098. */
  104099. getClassName(): string;
  104100. /**
  104101. * @hidden
  104102. */
  104103. _updateParameters(): void;
  104104. dispose(camera?: Camera): void;
  104105. }
  104106. }
  104107. declare module BABYLON {
  104108. /**
  104109. * A multi render target designed to render the prepass.
  104110. * Prepass is a scene component used to render information in multiple textures
  104111. * alongside with the scene materials rendering.
  104112. * Note : This is an internal class, and you should NOT need to instanciate this.
  104113. * Only the `PrePassRenderer` should instanciate this class.
  104114. * It is more likely that you need a regular `MultiRenderTarget`
  104115. * @hidden
  104116. */
  104117. export class PrePassRenderTarget extends MultiRenderTarget {
  104118. /**
  104119. * @hidden
  104120. */
  104121. _beforeCompositionPostProcesses: PostProcess[];
  104122. /**
  104123. * Image processing post process for composition
  104124. */
  104125. imageProcessingPostProcess: ImageProcessingPostProcess;
  104126. /**
  104127. * @hidden
  104128. */
  104129. _engine: Engine;
  104130. /**
  104131. * @hidden
  104132. */
  104133. _scene: Scene;
  104134. /**
  104135. * @hidden
  104136. */
  104137. _outputPostProcess: Nullable<PostProcess>;
  104138. /**
  104139. * @hidden
  104140. */
  104141. _internalTextureDirty: boolean;
  104142. /**
  104143. * Is this render target enabled for prepass rendering
  104144. */
  104145. enabled: boolean;
  104146. /**
  104147. * Render target associated with this prePassRenderTarget
  104148. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  104149. */
  104150. renderTargetTexture: Nullable<RenderTargetTexture>;
  104151. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  104152. /**
  104153. * Creates a composition effect for this RT
  104154. * @hidden
  104155. */
  104156. _createCompositionEffect(): void;
  104157. /**
  104158. * Checks that the size of this RT is still adapted to the desired render size.
  104159. * @hidden
  104160. */
  104161. _checkSize(): void;
  104162. /**
  104163. * Changes the number of render targets in this MRT
  104164. * Be careful as it will recreate all the data in the new texture.
  104165. * @param count new texture count
  104166. * @param options Specifies texture types and sampling modes for new textures
  104167. */
  104168. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104169. /**
  104170. * Resets the post processes chains applied to this RT.
  104171. * @hidden
  104172. */
  104173. _resetPostProcessChain(): void;
  104174. /**
  104175. * Diposes this render target
  104176. */
  104177. dispose(): void;
  104178. }
  104179. }
  104180. declare module BABYLON {
  104181. /**
  104182. * Interface for defining prepass effects in the prepass post-process pipeline
  104183. */
  104184. export interface PrePassEffectConfiguration {
  104185. /**
  104186. * Name of the effect
  104187. */
  104188. name: string;
  104189. /**
  104190. * Post process to attach for this effect
  104191. */
  104192. postProcess?: PostProcess;
  104193. /**
  104194. * Textures required in the MRT
  104195. */
  104196. texturesRequired: number[];
  104197. /**
  104198. * Is the effect enabled
  104199. */
  104200. enabled: boolean;
  104201. /**
  104202. * Does the output of this prepass need to go through imageprocessing
  104203. */
  104204. needsImageProcessing?: boolean;
  104205. /**
  104206. * Disposes the effect configuration
  104207. */
  104208. dispose?: () => void;
  104209. /**
  104210. * Creates the associated post process
  104211. */
  104212. createPostProcess?: () => PostProcess;
  104213. }
  104214. }
  104215. declare module BABYLON {
  104216. /**
  104217. * Options to be used when creating a FresnelParameters.
  104218. */
  104219. export type IFresnelParametersCreationOptions = {
  104220. /**
  104221. * Define the color used on edges (grazing angle)
  104222. */
  104223. leftColor?: Color3;
  104224. /**
  104225. * Define the color used on center
  104226. */
  104227. rightColor?: Color3;
  104228. /**
  104229. * Define bias applied to computed fresnel term
  104230. */
  104231. bias?: number;
  104232. /**
  104233. * Defined the power exponent applied to fresnel term
  104234. */
  104235. power?: number;
  104236. /**
  104237. * Define if the fresnel effect is enable or not.
  104238. */
  104239. isEnabled?: boolean;
  104240. };
  104241. /**
  104242. * Serialized format for FresnelParameters.
  104243. */
  104244. export type IFresnelParametersSerialized = {
  104245. /**
  104246. * Define the color used on edges (grazing angle) [as an array]
  104247. */
  104248. leftColor: number[];
  104249. /**
  104250. * Define the color used on center [as an array]
  104251. */
  104252. rightColor: number[];
  104253. /**
  104254. * Define bias applied to computed fresnel term
  104255. */
  104256. bias: number;
  104257. /**
  104258. * Defined the power exponent applied to fresnel term
  104259. */
  104260. power?: number;
  104261. /**
  104262. * Define if the fresnel effect is enable or not.
  104263. */
  104264. isEnabled: boolean;
  104265. };
  104266. /**
  104267. * This represents all the required information to add a fresnel effect on a material:
  104268. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104269. */
  104270. export class FresnelParameters {
  104271. private _isEnabled;
  104272. /**
  104273. * Define if the fresnel effect is enable or not.
  104274. */
  104275. get isEnabled(): boolean;
  104276. set isEnabled(value: boolean);
  104277. /**
  104278. * Define the color used on edges (grazing angle)
  104279. */
  104280. leftColor: Color3;
  104281. /**
  104282. * Define the color used on center
  104283. */
  104284. rightColor: Color3;
  104285. /**
  104286. * Define bias applied to computed fresnel term
  104287. */
  104288. bias: number;
  104289. /**
  104290. * Defined the power exponent applied to fresnel term
  104291. */
  104292. power: number;
  104293. /**
  104294. * Creates a new FresnelParameters object.
  104295. *
  104296. * @param options provide your own settings to optionally to override defaults
  104297. */
  104298. constructor(options?: IFresnelParametersCreationOptions);
  104299. /**
  104300. * Clones the current fresnel and its values
  104301. * @returns a clone fresnel configuration
  104302. */
  104303. clone(): FresnelParameters;
  104304. /**
  104305. * Determines equality between FresnelParameters objects
  104306. * @param otherFresnelParameters defines the second operand
  104307. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104308. */
  104309. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104310. /**
  104311. * Serializes the current fresnel parameters to a JSON representation.
  104312. * @return the JSON serialization
  104313. */
  104314. serialize(): IFresnelParametersSerialized;
  104315. /**
  104316. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104317. * @param parsedFresnelParameters Define the JSON representation
  104318. * @returns the parsed parameters
  104319. */
  104320. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104321. }
  104322. }
  104323. declare module BABYLON {
  104324. /**
  104325. * This groups all the flags used to control the materials channel.
  104326. */
  104327. export class MaterialFlags {
  104328. private static _DiffuseTextureEnabled;
  104329. /**
  104330. * Are diffuse textures enabled in the application.
  104331. */
  104332. static get DiffuseTextureEnabled(): boolean;
  104333. static set DiffuseTextureEnabled(value: boolean);
  104334. private static _DetailTextureEnabled;
  104335. /**
  104336. * Are detail textures enabled in the application.
  104337. */
  104338. static get DetailTextureEnabled(): boolean;
  104339. static set DetailTextureEnabled(value: boolean);
  104340. private static _AmbientTextureEnabled;
  104341. /**
  104342. * Are ambient textures enabled in the application.
  104343. */
  104344. static get AmbientTextureEnabled(): boolean;
  104345. static set AmbientTextureEnabled(value: boolean);
  104346. private static _OpacityTextureEnabled;
  104347. /**
  104348. * Are opacity textures enabled in the application.
  104349. */
  104350. static get OpacityTextureEnabled(): boolean;
  104351. static set OpacityTextureEnabled(value: boolean);
  104352. private static _ReflectionTextureEnabled;
  104353. /**
  104354. * Are reflection textures enabled in the application.
  104355. */
  104356. static get ReflectionTextureEnabled(): boolean;
  104357. static set ReflectionTextureEnabled(value: boolean);
  104358. private static _EmissiveTextureEnabled;
  104359. /**
  104360. * Are emissive textures enabled in the application.
  104361. */
  104362. static get EmissiveTextureEnabled(): boolean;
  104363. static set EmissiveTextureEnabled(value: boolean);
  104364. private static _SpecularTextureEnabled;
  104365. /**
  104366. * Are specular textures enabled in the application.
  104367. */
  104368. static get SpecularTextureEnabled(): boolean;
  104369. static set SpecularTextureEnabled(value: boolean);
  104370. private static _BumpTextureEnabled;
  104371. /**
  104372. * Are bump textures enabled in the application.
  104373. */
  104374. static get BumpTextureEnabled(): boolean;
  104375. static set BumpTextureEnabled(value: boolean);
  104376. private static _LightmapTextureEnabled;
  104377. /**
  104378. * Are lightmap textures enabled in the application.
  104379. */
  104380. static get LightmapTextureEnabled(): boolean;
  104381. static set LightmapTextureEnabled(value: boolean);
  104382. private static _RefractionTextureEnabled;
  104383. /**
  104384. * Are refraction textures enabled in the application.
  104385. */
  104386. static get RefractionTextureEnabled(): boolean;
  104387. static set RefractionTextureEnabled(value: boolean);
  104388. private static _ColorGradingTextureEnabled;
  104389. /**
  104390. * Are color grading textures enabled in the application.
  104391. */
  104392. static get ColorGradingTextureEnabled(): boolean;
  104393. static set ColorGradingTextureEnabled(value: boolean);
  104394. private static _FresnelEnabled;
  104395. /**
  104396. * Are fresnels enabled in the application.
  104397. */
  104398. static get FresnelEnabled(): boolean;
  104399. static set FresnelEnabled(value: boolean);
  104400. private static _ClearCoatTextureEnabled;
  104401. /**
  104402. * Are clear coat textures enabled in the application.
  104403. */
  104404. static get ClearCoatTextureEnabled(): boolean;
  104405. static set ClearCoatTextureEnabled(value: boolean);
  104406. private static _ClearCoatBumpTextureEnabled;
  104407. /**
  104408. * Are clear coat bump textures enabled in the application.
  104409. */
  104410. static get ClearCoatBumpTextureEnabled(): boolean;
  104411. static set ClearCoatBumpTextureEnabled(value: boolean);
  104412. private static _ClearCoatTintTextureEnabled;
  104413. /**
  104414. * Are clear coat tint textures enabled in the application.
  104415. */
  104416. static get ClearCoatTintTextureEnabled(): boolean;
  104417. static set ClearCoatTintTextureEnabled(value: boolean);
  104418. private static _SheenTextureEnabled;
  104419. /**
  104420. * Are sheen textures enabled in the application.
  104421. */
  104422. static get SheenTextureEnabled(): boolean;
  104423. static set SheenTextureEnabled(value: boolean);
  104424. private static _AnisotropicTextureEnabled;
  104425. /**
  104426. * Are anisotropic textures enabled in the application.
  104427. */
  104428. static get AnisotropicTextureEnabled(): boolean;
  104429. static set AnisotropicTextureEnabled(value: boolean);
  104430. private static _ThicknessTextureEnabled;
  104431. /**
  104432. * Are thickness textures enabled in the application.
  104433. */
  104434. static get ThicknessTextureEnabled(): boolean;
  104435. static set ThicknessTextureEnabled(value: boolean);
  104436. }
  104437. }
  104438. declare module BABYLON {
  104439. /** @hidden */
  104440. export var defaultFragmentDeclaration: {
  104441. name: string;
  104442. shader: string;
  104443. };
  104444. }
  104445. declare module BABYLON {
  104446. /** @hidden */
  104447. export var sceneUboDeclaration: {
  104448. name: string;
  104449. shader: string;
  104450. };
  104451. }
  104452. declare module BABYLON {
  104453. /** @hidden */
  104454. export var meshUboDeclaration: {
  104455. name: string;
  104456. shader: string;
  104457. };
  104458. }
  104459. declare module BABYLON {
  104460. /** @hidden */
  104461. export var defaultUboDeclaration: {
  104462. name: string;
  104463. shader: string;
  104464. };
  104465. }
  104466. declare module BABYLON {
  104467. /** @hidden */
  104468. export var prePassDeclaration: {
  104469. name: string;
  104470. shader: string;
  104471. };
  104472. }
  104473. declare module BABYLON {
  104474. /** @hidden */
  104475. export var lightFragmentDeclaration: {
  104476. name: string;
  104477. shader: string;
  104478. };
  104479. }
  104480. declare module BABYLON {
  104481. /** @hidden */
  104482. export var lightUboDeclaration: {
  104483. name: string;
  104484. shader: string;
  104485. };
  104486. }
  104487. declare module BABYLON {
  104488. /** @hidden */
  104489. export var lightsFragmentFunctions: {
  104490. name: string;
  104491. shader: string;
  104492. };
  104493. }
  104494. declare module BABYLON {
  104495. /** @hidden */
  104496. export var shadowsFragmentFunctions: {
  104497. name: string;
  104498. shader: string;
  104499. };
  104500. }
  104501. declare module BABYLON {
  104502. /** @hidden */
  104503. export var fresnelFunction: {
  104504. name: string;
  104505. shader: string;
  104506. };
  104507. }
  104508. declare module BABYLON {
  104509. /** @hidden */
  104510. export var bumpFragmentMainFunctions: {
  104511. name: string;
  104512. shader: string;
  104513. };
  104514. }
  104515. declare module BABYLON {
  104516. /** @hidden */
  104517. export var bumpFragmentFunctions: {
  104518. name: string;
  104519. shader: string;
  104520. };
  104521. }
  104522. declare module BABYLON {
  104523. /** @hidden */
  104524. export var logDepthDeclaration: {
  104525. name: string;
  104526. shader: string;
  104527. };
  104528. }
  104529. declare module BABYLON {
  104530. /** @hidden */
  104531. export var fogFragmentDeclaration: {
  104532. name: string;
  104533. shader: string;
  104534. };
  104535. }
  104536. declare module BABYLON {
  104537. /** @hidden */
  104538. export var bumpFragment: {
  104539. name: string;
  104540. shader: string;
  104541. };
  104542. }
  104543. declare module BABYLON {
  104544. /** @hidden */
  104545. export var depthPrePass: {
  104546. name: string;
  104547. shader: string;
  104548. };
  104549. }
  104550. declare module BABYLON {
  104551. /** @hidden */
  104552. export var lightFragment: {
  104553. name: string;
  104554. shader: string;
  104555. };
  104556. }
  104557. declare module BABYLON {
  104558. /** @hidden */
  104559. export var logDepthFragment: {
  104560. name: string;
  104561. shader: string;
  104562. };
  104563. }
  104564. declare module BABYLON {
  104565. /** @hidden */
  104566. export var fogFragment: {
  104567. name: string;
  104568. shader: string;
  104569. };
  104570. }
  104571. declare module BABYLON {
  104572. /** @hidden */
  104573. export var defaultPixelShader: {
  104574. name: string;
  104575. shader: string;
  104576. };
  104577. }
  104578. declare module BABYLON {
  104579. /** @hidden */
  104580. export var defaultVertexDeclaration: {
  104581. name: string;
  104582. shader: string;
  104583. };
  104584. }
  104585. declare module BABYLON {
  104586. /** @hidden */
  104587. export var bonesDeclaration: {
  104588. name: string;
  104589. shader: string;
  104590. };
  104591. }
  104592. declare module BABYLON {
  104593. /** @hidden */
  104594. export var prePassVertexDeclaration: {
  104595. name: string;
  104596. shader: string;
  104597. };
  104598. }
  104599. declare module BABYLON {
  104600. /** @hidden */
  104601. export var bumpVertexDeclaration: {
  104602. name: string;
  104603. shader: string;
  104604. };
  104605. }
  104606. declare module BABYLON {
  104607. /** @hidden */
  104608. export var fogVertexDeclaration: {
  104609. name: string;
  104610. shader: string;
  104611. };
  104612. }
  104613. declare module BABYLON {
  104614. /** @hidden */
  104615. export var lightVxFragmentDeclaration: {
  104616. name: string;
  104617. shader: string;
  104618. };
  104619. }
  104620. declare module BABYLON {
  104621. /** @hidden */
  104622. export var lightVxUboDeclaration: {
  104623. name: string;
  104624. shader: string;
  104625. };
  104626. }
  104627. declare module BABYLON {
  104628. /** @hidden */
  104629. export var morphTargetsVertexGlobalDeclaration: {
  104630. name: string;
  104631. shader: string;
  104632. };
  104633. }
  104634. declare module BABYLON {
  104635. /** @hidden */
  104636. export var morphTargetsVertexDeclaration: {
  104637. name: string;
  104638. shader: string;
  104639. };
  104640. }
  104641. declare module BABYLON {
  104642. /** @hidden */
  104643. export var morphTargetsVertexGlobal: {
  104644. name: string;
  104645. shader: string;
  104646. };
  104647. }
  104648. declare module BABYLON {
  104649. /** @hidden */
  104650. export var morphTargetsVertex: {
  104651. name: string;
  104652. shader: string;
  104653. };
  104654. }
  104655. declare module BABYLON {
  104656. /** @hidden */
  104657. export var instancesVertex: {
  104658. name: string;
  104659. shader: string;
  104660. };
  104661. }
  104662. declare module BABYLON {
  104663. /** @hidden */
  104664. export var bonesVertex: {
  104665. name: string;
  104666. shader: string;
  104667. };
  104668. }
  104669. declare module BABYLON {
  104670. /** @hidden */
  104671. export var prePassVertex: {
  104672. name: string;
  104673. shader: string;
  104674. };
  104675. }
  104676. declare module BABYLON {
  104677. /** @hidden */
  104678. export var bumpVertex: {
  104679. name: string;
  104680. shader: string;
  104681. };
  104682. }
  104683. declare module BABYLON {
  104684. /** @hidden */
  104685. export var fogVertex: {
  104686. name: string;
  104687. shader: string;
  104688. };
  104689. }
  104690. declare module BABYLON {
  104691. /** @hidden */
  104692. export var shadowsVertex: {
  104693. name: string;
  104694. shader: string;
  104695. };
  104696. }
  104697. declare module BABYLON {
  104698. /** @hidden */
  104699. export var pointCloudVertex: {
  104700. name: string;
  104701. shader: string;
  104702. };
  104703. }
  104704. declare module BABYLON {
  104705. /** @hidden */
  104706. export var logDepthVertex: {
  104707. name: string;
  104708. shader: string;
  104709. };
  104710. }
  104711. declare module BABYLON {
  104712. /** @hidden */
  104713. export var defaultVertexShader: {
  104714. name: string;
  104715. shader: string;
  104716. };
  104717. }
  104718. declare module BABYLON {
  104719. /**
  104720. * @hidden
  104721. */
  104722. export interface IMaterialDetailMapDefines {
  104723. DETAIL: boolean;
  104724. DETAILDIRECTUV: number;
  104725. DETAIL_NORMALBLENDMETHOD: number;
  104726. /** @hidden */
  104727. _areTexturesDirty: boolean;
  104728. }
  104729. /**
  104730. * Define the code related to the detail map parameters of a material
  104731. *
  104732. * Inspired from:
  104733. * 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
  104734. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104735. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104736. */
  104737. export class DetailMapConfiguration {
  104738. private _texture;
  104739. /**
  104740. * The detail texture of the material.
  104741. */
  104742. texture: Nullable<BaseTexture>;
  104743. /**
  104744. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104745. * Bigger values mean stronger blending
  104746. */
  104747. diffuseBlendLevel: number;
  104748. /**
  104749. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104750. * Bigger values mean stronger blending. Only used with PBR materials
  104751. */
  104752. roughnessBlendLevel: number;
  104753. /**
  104754. * Defines how strong the bump effect from the detail map is
  104755. * Bigger values mean stronger effect
  104756. */
  104757. bumpLevel: number;
  104758. private _normalBlendMethod;
  104759. /**
  104760. * The method used to blend the bump and detail normals together
  104761. */
  104762. normalBlendMethod: number;
  104763. private _isEnabled;
  104764. /**
  104765. * Enable or disable the detail map on this material
  104766. */
  104767. isEnabled: boolean;
  104768. /** @hidden */
  104769. private _internalMarkAllSubMeshesAsTexturesDirty;
  104770. /** @hidden */
  104771. _markAllSubMeshesAsTexturesDirty(): void;
  104772. /**
  104773. * Instantiate a new detail map
  104774. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104775. */
  104776. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104777. /**
  104778. * Gets whether the submesh is ready to be used or not.
  104779. * @param defines the list of "defines" to update.
  104780. * @param scene defines the scene the material belongs to.
  104781. * @returns - boolean indicating that the submesh is ready or not.
  104782. */
  104783. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104784. /**
  104785. * Update the defines for detail map usage
  104786. * @param defines the list of "defines" to update.
  104787. * @param scene defines the scene the material belongs to.
  104788. */
  104789. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104790. /**
  104791. * Binds the material data.
  104792. * @param uniformBuffer defines the Uniform buffer to fill in.
  104793. * @param scene defines the scene the material belongs to.
  104794. * @param isFrozen defines whether the material is frozen or not.
  104795. */
  104796. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104797. /**
  104798. * Checks to see if a texture is used in the material.
  104799. * @param texture - Base texture to use.
  104800. * @returns - Boolean specifying if a texture is used in the material.
  104801. */
  104802. hasTexture(texture: BaseTexture): boolean;
  104803. /**
  104804. * Returns an array of the actively used textures.
  104805. * @param activeTextures Array of BaseTextures
  104806. */
  104807. getActiveTextures(activeTextures: BaseTexture[]): void;
  104808. /**
  104809. * Returns the animatable textures.
  104810. * @param animatables Array of animatable textures.
  104811. */
  104812. getAnimatables(animatables: IAnimatable[]): void;
  104813. /**
  104814. * Disposes the resources of the material.
  104815. * @param forceDisposeTextures - Forces the disposal of all textures.
  104816. */
  104817. dispose(forceDisposeTextures?: boolean): void;
  104818. /**
  104819. * Get the current class name useful for serialization or dynamic coding.
  104820. * @returns "DetailMap"
  104821. */
  104822. getClassName(): string;
  104823. /**
  104824. * Add the required uniforms to the current list.
  104825. * @param uniforms defines the current uniform list.
  104826. */
  104827. static AddUniforms(uniforms: string[]): void;
  104828. /**
  104829. * Add the required samplers to the current list.
  104830. * @param samplers defines the current sampler list.
  104831. */
  104832. static AddSamplers(samplers: string[]): void;
  104833. /**
  104834. * Add the required uniforms to the current buffer.
  104835. * @param uniformBuffer defines the current uniform buffer.
  104836. */
  104837. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104838. /**
  104839. * Makes a duplicate of the current instance into another one.
  104840. * @param detailMap define the instance where to copy the info
  104841. */
  104842. copyTo(detailMap: DetailMapConfiguration): void;
  104843. /**
  104844. * Serializes this detail map instance
  104845. * @returns - An object with the serialized instance.
  104846. */
  104847. serialize(): any;
  104848. /**
  104849. * Parses a detail map setting from a serialized object.
  104850. * @param source - Serialized object.
  104851. * @param scene Defines the scene we are parsing for
  104852. * @param rootUrl Defines the rootUrl to load from
  104853. */
  104854. parse(source: any, scene: Scene, rootUrl: string): void;
  104855. }
  104856. }
  104857. declare module BABYLON {
  104858. /** @hidden */
  104859. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104860. MAINUV1: boolean;
  104861. MAINUV2: boolean;
  104862. DIFFUSE: boolean;
  104863. DIFFUSEDIRECTUV: number;
  104864. DETAIL: boolean;
  104865. DETAILDIRECTUV: number;
  104866. DETAIL_NORMALBLENDMETHOD: number;
  104867. AMBIENT: boolean;
  104868. AMBIENTDIRECTUV: number;
  104869. OPACITY: boolean;
  104870. OPACITYDIRECTUV: number;
  104871. OPACITYRGB: boolean;
  104872. REFLECTION: boolean;
  104873. EMISSIVE: boolean;
  104874. EMISSIVEDIRECTUV: number;
  104875. SPECULAR: boolean;
  104876. SPECULARDIRECTUV: number;
  104877. BUMP: boolean;
  104878. BUMPDIRECTUV: number;
  104879. PARALLAX: boolean;
  104880. PARALLAXOCCLUSION: boolean;
  104881. SPECULAROVERALPHA: boolean;
  104882. CLIPPLANE: boolean;
  104883. CLIPPLANE2: boolean;
  104884. CLIPPLANE3: boolean;
  104885. CLIPPLANE4: boolean;
  104886. CLIPPLANE5: boolean;
  104887. CLIPPLANE6: boolean;
  104888. ALPHATEST: boolean;
  104889. DEPTHPREPASS: boolean;
  104890. ALPHAFROMDIFFUSE: boolean;
  104891. POINTSIZE: boolean;
  104892. FOG: boolean;
  104893. SPECULARTERM: boolean;
  104894. DIFFUSEFRESNEL: boolean;
  104895. OPACITYFRESNEL: boolean;
  104896. REFLECTIONFRESNEL: boolean;
  104897. REFRACTIONFRESNEL: boolean;
  104898. EMISSIVEFRESNEL: boolean;
  104899. FRESNEL: boolean;
  104900. NORMAL: boolean;
  104901. UV1: boolean;
  104902. UV2: boolean;
  104903. VERTEXCOLOR: boolean;
  104904. VERTEXALPHA: boolean;
  104905. NUM_BONE_INFLUENCERS: number;
  104906. BonesPerMesh: number;
  104907. BONETEXTURE: boolean;
  104908. BONES_VELOCITY_ENABLED: boolean;
  104909. INSTANCES: boolean;
  104910. THIN_INSTANCES: boolean;
  104911. GLOSSINESS: boolean;
  104912. ROUGHNESS: boolean;
  104913. EMISSIVEASILLUMINATION: boolean;
  104914. LINKEMISSIVEWITHDIFFUSE: boolean;
  104915. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104916. LIGHTMAP: boolean;
  104917. LIGHTMAPDIRECTUV: number;
  104918. OBJECTSPACE_NORMALMAP: boolean;
  104919. USELIGHTMAPASSHADOWMAP: boolean;
  104920. REFLECTIONMAP_3D: boolean;
  104921. REFLECTIONMAP_SPHERICAL: boolean;
  104922. REFLECTIONMAP_PLANAR: boolean;
  104923. REFLECTIONMAP_CUBIC: boolean;
  104924. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104925. REFLECTIONMAP_PROJECTION: boolean;
  104926. REFLECTIONMAP_SKYBOX: boolean;
  104927. REFLECTIONMAP_EXPLICIT: boolean;
  104928. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104929. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104930. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104931. REFLECTIONMAP_OPPOSITEZ: boolean;
  104932. INVERTCUBICMAP: boolean;
  104933. LOGARITHMICDEPTH: boolean;
  104934. REFRACTION: boolean;
  104935. REFRACTIONMAP_3D: boolean;
  104936. REFLECTIONOVERALPHA: boolean;
  104937. TWOSIDEDLIGHTING: boolean;
  104938. SHADOWFLOAT: boolean;
  104939. MORPHTARGETS: boolean;
  104940. MORPHTARGETS_NORMAL: boolean;
  104941. MORPHTARGETS_TANGENT: boolean;
  104942. MORPHTARGETS_UV: boolean;
  104943. NUM_MORPH_INFLUENCERS: number;
  104944. MORPHTARGETS_TEXTURE: boolean;
  104945. NONUNIFORMSCALING: boolean;
  104946. PREMULTIPLYALPHA: boolean;
  104947. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104948. ALPHABLEND: boolean;
  104949. PREPASS: boolean;
  104950. PREPASS_IRRADIANCE: boolean;
  104951. PREPASS_IRRADIANCE_INDEX: number;
  104952. PREPASS_ALBEDO: boolean;
  104953. PREPASS_ALBEDO_INDEX: number;
  104954. PREPASS_DEPTH: boolean;
  104955. PREPASS_DEPTH_INDEX: number;
  104956. PREPASS_NORMAL: boolean;
  104957. PREPASS_NORMAL_INDEX: number;
  104958. PREPASS_POSITION: boolean;
  104959. PREPASS_POSITION_INDEX: number;
  104960. PREPASS_VELOCITY: boolean;
  104961. PREPASS_VELOCITY_INDEX: number;
  104962. PREPASS_REFLECTIVITY: boolean;
  104963. PREPASS_REFLECTIVITY_INDEX: number;
  104964. SCENE_MRT_COUNT: number;
  104965. RGBDLIGHTMAP: boolean;
  104966. RGBDREFLECTION: boolean;
  104967. RGBDREFRACTION: boolean;
  104968. IMAGEPROCESSING: boolean;
  104969. VIGNETTE: boolean;
  104970. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104971. VIGNETTEBLENDMODEOPAQUE: boolean;
  104972. TONEMAPPING: boolean;
  104973. TONEMAPPING_ACES: boolean;
  104974. CONTRAST: boolean;
  104975. COLORCURVES: boolean;
  104976. COLORGRADING: boolean;
  104977. COLORGRADING3D: boolean;
  104978. SAMPLER3DGREENDEPTH: boolean;
  104979. SAMPLER3DBGRMAP: boolean;
  104980. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104981. MULTIVIEW: boolean;
  104982. /**
  104983. * If the reflection texture on this material is in linear color space
  104984. * @hidden
  104985. */
  104986. IS_REFLECTION_LINEAR: boolean;
  104987. /**
  104988. * If the refraction texture on this material is in linear color space
  104989. * @hidden
  104990. */
  104991. IS_REFRACTION_LINEAR: boolean;
  104992. EXPOSURE: boolean;
  104993. constructor();
  104994. setReflectionMode(modeToEnable: string): void;
  104995. }
  104996. /**
  104997. * This is the default material used in Babylon. It is the best trade off between quality
  104998. * and performances.
  104999. * @see https://doc.babylonjs.com/babylon101/materials
  105000. */
  105001. export class StandardMaterial extends PushMaterial {
  105002. private _diffuseTexture;
  105003. /**
  105004. * The basic texture of the material as viewed under a light.
  105005. */
  105006. diffuseTexture: Nullable<BaseTexture>;
  105007. private _ambientTexture;
  105008. /**
  105009. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105010. */
  105011. ambientTexture: Nullable<BaseTexture>;
  105012. private _opacityTexture;
  105013. /**
  105014. * Define the transparency of the material from a texture.
  105015. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105016. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105017. */
  105018. opacityTexture: Nullable<BaseTexture>;
  105019. private _reflectionTexture;
  105020. /**
  105021. * Define the texture used to display the reflection.
  105022. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105023. */
  105024. reflectionTexture: Nullable<BaseTexture>;
  105025. private _emissiveTexture;
  105026. /**
  105027. * Define texture of the material as if self lit.
  105028. * This will be mixed in the final result even in the absence of light.
  105029. */
  105030. emissiveTexture: Nullable<BaseTexture>;
  105031. private _specularTexture;
  105032. /**
  105033. * Define how the color and intensity of the highlight given by the light in the material.
  105034. */
  105035. specularTexture: Nullable<BaseTexture>;
  105036. private _bumpTexture;
  105037. /**
  105038. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105039. * 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.
  105040. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  105041. */
  105042. bumpTexture: Nullable<BaseTexture>;
  105043. private _lightmapTexture;
  105044. /**
  105045. * Complex lighting can be computationally expensive to compute at runtime.
  105046. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105047. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  105048. */
  105049. lightmapTexture: Nullable<BaseTexture>;
  105050. private _refractionTexture;
  105051. /**
  105052. * Define the texture used to display the refraction.
  105053. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105054. */
  105055. refractionTexture: Nullable<BaseTexture>;
  105056. /**
  105057. * The color of the material lit by the environmental background lighting.
  105058. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105059. */
  105060. ambientColor: Color3;
  105061. /**
  105062. * The basic color of the material as viewed under a light.
  105063. */
  105064. diffuseColor: Color3;
  105065. /**
  105066. * Define how the color and intensity of the highlight given by the light in the material.
  105067. */
  105068. specularColor: Color3;
  105069. /**
  105070. * Define the color of the material as if self lit.
  105071. * This will be mixed in the final result even in the absence of light.
  105072. */
  105073. emissiveColor: Color3;
  105074. /**
  105075. * Defines how sharp are the highlights in the material.
  105076. * The bigger the value the sharper giving a more glossy feeling to the result.
  105077. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105078. */
  105079. specularPower: number;
  105080. private _useAlphaFromDiffuseTexture;
  105081. /**
  105082. * Does the transparency come from the diffuse texture alpha channel.
  105083. */
  105084. useAlphaFromDiffuseTexture: boolean;
  105085. private _useEmissiveAsIllumination;
  105086. /**
  105087. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105088. */
  105089. useEmissiveAsIllumination: boolean;
  105090. private _linkEmissiveWithDiffuse;
  105091. /**
  105092. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105093. * the emissive level when the final color is close to one.
  105094. */
  105095. linkEmissiveWithDiffuse: boolean;
  105096. private _useSpecularOverAlpha;
  105097. /**
  105098. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  105099. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105100. */
  105101. useSpecularOverAlpha: boolean;
  105102. private _useReflectionOverAlpha;
  105103. /**
  105104. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  105105. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105106. */
  105107. useReflectionOverAlpha: boolean;
  105108. private _disableLighting;
  105109. /**
  105110. * Does lights from the scene impacts this material.
  105111. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105112. */
  105113. disableLighting: boolean;
  105114. private _useObjectSpaceNormalMap;
  105115. /**
  105116. * Allows using an object space normal map (instead of tangent space).
  105117. */
  105118. useObjectSpaceNormalMap: boolean;
  105119. private _useParallax;
  105120. /**
  105121. * Is parallax enabled or not.
  105122. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105123. */
  105124. useParallax: boolean;
  105125. private _useParallaxOcclusion;
  105126. /**
  105127. * Is parallax occlusion enabled or not.
  105128. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105129. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105130. */
  105131. useParallaxOcclusion: boolean;
  105132. /**
  105133. * 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.
  105134. */
  105135. parallaxScaleBias: number;
  105136. private _roughness;
  105137. /**
  105138. * Helps to define how blurry the reflections should appears in the material.
  105139. */
  105140. roughness: number;
  105141. /**
  105142. * In case of refraction, define the value of the index of refraction.
  105143. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105144. */
  105145. indexOfRefraction: number;
  105146. /**
  105147. * Invert the refraction texture alongside the y axis.
  105148. * It can be useful with procedural textures or probe for instance.
  105149. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105150. */
  105151. invertRefractionY: boolean;
  105152. /**
  105153. * Defines the alpha limits in alpha test mode.
  105154. */
  105155. alphaCutOff: number;
  105156. private _useLightmapAsShadowmap;
  105157. /**
  105158. * In case of light mapping, define whether the map contains light or shadow informations.
  105159. */
  105160. useLightmapAsShadowmap: boolean;
  105161. private _diffuseFresnelParameters;
  105162. /**
  105163. * Define the diffuse fresnel parameters of the material.
  105164. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105165. */
  105166. diffuseFresnelParameters: FresnelParameters;
  105167. private _opacityFresnelParameters;
  105168. /**
  105169. * Define the opacity fresnel parameters of the material.
  105170. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105171. */
  105172. opacityFresnelParameters: FresnelParameters;
  105173. private _reflectionFresnelParameters;
  105174. /**
  105175. * Define the reflection fresnel parameters of the material.
  105176. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105177. */
  105178. reflectionFresnelParameters: FresnelParameters;
  105179. private _refractionFresnelParameters;
  105180. /**
  105181. * Define the refraction fresnel parameters of the material.
  105182. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105183. */
  105184. refractionFresnelParameters: FresnelParameters;
  105185. private _emissiveFresnelParameters;
  105186. /**
  105187. * Define the emissive fresnel parameters of the material.
  105188. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105189. */
  105190. emissiveFresnelParameters: FresnelParameters;
  105191. private _useReflectionFresnelFromSpecular;
  105192. /**
  105193. * If true automatically deducts the fresnels values from the material specularity.
  105194. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105195. */
  105196. useReflectionFresnelFromSpecular: boolean;
  105197. private _useGlossinessFromSpecularMapAlpha;
  105198. /**
  105199. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105200. */
  105201. useGlossinessFromSpecularMapAlpha: boolean;
  105202. private _maxSimultaneousLights;
  105203. /**
  105204. * Defines the maximum number of lights that can be used in the material
  105205. */
  105206. maxSimultaneousLights: number;
  105207. private _invertNormalMapX;
  105208. /**
  105209. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105210. */
  105211. invertNormalMapX: boolean;
  105212. private _invertNormalMapY;
  105213. /**
  105214. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105215. */
  105216. invertNormalMapY: boolean;
  105217. private _twoSidedLighting;
  105218. /**
  105219. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105220. */
  105221. twoSidedLighting: boolean;
  105222. /**
  105223. * Default configuration related to image processing available in the standard Material.
  105224. */
  105225. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105226. /**
  105227. * Gets the image processing configuration used either in this material.
  105228. */
  105229. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105230. /**
  105231. * Sets the Default image processing configuration used either in the this material.
  105232. *
  105233. * If sets to null, the scene one is in use.
  105234. */
  105235. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  105236. /**
  105237. * Keep track of the image processing observer to allow dispose and replace.
  105238. */
  105239. private _imageProcessingObserver;
  105240. /**
  105241. * Attaches a new image processing configuration to the Standard Material.
  105242. * @param configuration
  105243. */
  105244. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105245. /**
  105246. * Defines additional PrePass parameters for the material.
  105247. */
  105248. readonly prePassConfiguration: PrePassConfiguration;
  105249. /**
  105250. * Can this material render to prepass
  105251. */
  105252. get isPrePassCapable(): boolean;
  105253. /**
  105254. * Gets whether the color curves effect is enabled.
  105255. */
  105256. get cameraColorCurvesEnabled(): boolean;
  105257. /**
  105258. * Sets whether the color curves effect is enabled.
  105259. */
  105260. set cameraColorCurvesEnabled(value: boolean);
  105261. /**
  105262. * Gets whether the color grading effect is enabled.
  105263. */
  105264. get cameraColorGradingEnabled(): boolean;
  105265. /**
  105266. * Gets whether the color grading effect is enabled.
  105267. */
  105268. set cameraColorGradingEnabled(value: boolean);
  105269. /**
  105270. * Gets whether tonemapping is enabled or not.
  105271. */
  105272. get cameraToneMappingEnabled(): boolean;
  105273. /**
  105274. * Sets whether tonemapping is enabled or not
  105275. */
  105276. set cameraToneMappingEnabled(value: boolean);
  105277. /**
  105278. * The camera exposure used on this material.
  105279. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105280. * This corresponds to a photographic exposure.
  105281. */
  105282. get cameraExposure(): number;
  105283. /**
  105284. * The camera exposure used on this material.
  105285. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105286. * This corresponds to a photographic exposure.
  105287. */
  105288. set cameraExposure(value: number);
  105289. /**
  105290. * Gets The camera contrast used on this material.
  105291. */
  105292. get cameraContrast(): number;
  105293. /**
  105294. * Sets The camera contrast used on this material.
  105295. */
  105296. set cameraContrast(value: number);
  105297. /**
  105298. * Gets the Color Grading 2D Lookup Texture.
  105299. */
  105300. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105301. /**
  105302. * Sets the Color Grading 2D Lookup Texture.
  105303. */
  105304. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105305. /**
  105306. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105308. * 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;
  105309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105310. */
  105311. get cameraColorCurves(): Nullable<ColorCurves>;
  105312. /**
  105313. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  105314. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105315. * 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;
  105316. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105317. */
  105318. set cameraColorCurves(value: Nullable<ColorCurves>);
  105319. /**
  105320. * Can this material render to several textures at once
  105321. */
  105322. get canRenderToMRT(): boolean;
  105323. /**
  105324. * Defines the detail map parameters for the material.
  105325. */
  105326. readonly detailMap: DetailMapConfiguration;
  105327. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105328. protected _worldViewProjectionMatrix: Matrix;
  105329. protected _globalAmbientColor: Color3;
  105330. protected _useLogarithmicDepth: boolean;
  105331. protected _rebuildInParallel: boolean;
  105332. /**
  105333. * Instantiates a new standard material.
  105334. * This is the default material used in Babylon. It is the best trade off between quality
  105335. * and performances.
  105336. * @see https://doc.babylonjs.com/babylon101/materials
  105337. * @param name Define the name of the material in the scene
  105338. * @param scene Define the scene the material belong to
  105339. */
  105340. constructor(name: string, scene: Scene);
  105341. /**
  105342. * Gets a boolean indicating that current material needs to register RTT
  105343. */
  105344. get hasRenderTargetTextures(): boolean;
  105345. /**
  105346. * Gets the current class name of the material e.g. "StandardMaterial"
  105347. * Mainly use in serialization.
  105348. * @returns the class name
  105349. */
  105350. getClassName(): string;
  105351. /**
  105352. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105353. * You can try switching to logarithmic depth.
  105354. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105355. */
  105356. get useLogarithmicDepth(): boolean;
  105357. set useLogarithmicDepth(value: boolean);
  105358. /**
  105359. * Specifies if the material will require alpha blending
  105360. * @returns a boolean specifying if alpha blending is needed
  105361. */
  105362. needAlphaBlending(): boolean;
  105363. /**
  105364. * Specifies if this material should be rendered in alpha test mode
  105365. * @returns a boolean specifying if an alpha test is needed.
  105366. */
  105367. needAlphaTesting(): boolean;
  105368. /**
  105369. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105370. */
  105371. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105372. /**
  105373. * Specifies whether or not there is a usable alpha channel for transparency.
  105374. */
  105375. protected _hasAlphaChannel(): boolean;
  105376. /**
  105377. * Get the texture used for alpha test purpose.
  105378. * @returns the diffuse texture in case of the standard material.
  105379. */
  105380. getAlphaTestTexture(): Nullable<BaseTexture>;
  105381. /**
  105382. * Get if the submesh is ready to be used and all its information available.
  105383. * Child classes can use it to update shaders
  105384. * @param mesh defines the mesh to check
  105385. * @param subMesh defines which submesh to check
  105386. * @param useInstances specifies that instances should be used
  105387. * @returns a boolean indicating that the submesh is ready or not
  105388. */
  105389. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105390. /**
  105391. * Builds the material UBO layouts.
  105392. * Used internally during the effect preparation.
  105393. */
  105394. buildUniformLayout(): void;
  105395. /**
  105396. * Unbinds the material from the mesh
  105397. */
  105398. unbind(): void;
  105399. /**
  105400. * Binds the submesh to this material by preparing the effect and shader to draw
  105401. * @param world defines the world transformation matrix
  105402. * @param mesh defines the mesh containing the submesh
  105403. * @param subMesh defines the submesh to bind the material to
  105404. */
  105405. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105406. /**
  105407. * Get the list of animatables in the material.
  105408. * @returns the list of animatables object used in the material
  105409. */
  105410. getAnimatables(): IAnimatable[];
  105411. /**
  105412. * Gets the active textures from the material
  105413. * @returns an array of textures
  105414. */
  105415. getActiveTextures(): BaseTexture[];
  105416. /**
  105417. * Specifies if the material uses a texture
  105418. * @param texture defines the texture to check against the material
  105419. * @returns a boolean specifying if the material uses the texture
  105420. */
  105421. hasTexture(texture: BaseTexture): boolean;
  105422. /**
  105423. * Disposes the material
  105424. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105425. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105426. */
  105427. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105428. /**
  105429. * Makes a duplicate of the material, and gives it a new name
  105430. * @param name defines the new name for the duplicated material
  105431. * @returns the cloned material
  105432. */
  105433. clone(name: string): StandardMaterial;
  105434. /**
  105435. * Serializes this material in a JSON representation
  105436. * @returns the serialized material object
  105437. */
  105438. serialize(): any;
  105439. /**
  105440. * Creates a standard material from parsed material data
  105441. * @param source defines the JSON representation of the material
  105442. * @param scene defines the hosting scene
  105443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105444. * @returns a new standard material
  105445. */
  105446. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105447. /**
  105448. * Are diffuse textures enabled in the application.
  105449. */
  105450. static get DiffuseTextureEnabled(): boolean;
  105451. static set DiffuseTextureEnabled(value: boolean);
  105452. /**
  105453. * Are detail textures enabled in the application.
  105454. */
  105455. static get DetailTextureEnabled(): boolean;
  105456. static set DetailTextureEnabled(value: boolean);
  105457. /**
  105458. * Are ambient textures enabled in the application.
  105459. */
  105460. static get AmbientTextureEnabled(): boolean;
  105461. static set AmbientTextureEnabled(value: boolean);
  105462. /**
  105463. * Are opacity textures enabled in the application.
  105464. */
  105465. static get OpacityTextureEnabled(): boolean;
  105466. static set OpacityTextureEnabled(value: boolean);
  105467. /**
  105468. * Are reflection textures enabled in the application.
  105469. */
  105470. static get ReflectionTextureEnabled(): boolean;
  105471. static set ReflectionTextureEnabled(value: boolean);
  105472. /**
  105473. * Are emissive textures enabled in the application.
  105474. */
  105475. static get EmissiveTextureEnabled(): boolean;
  105476. static set EmissiveTextureEnabled(value: boolean);
  105477. /**
  105478. * Are specular textures enabled in the application.
  105479. */
  105480. static get SpecularTextureEnabled(): boolean;
  105481. static set SpecularTextureEnabled(value: boolean);
  105482. /**
  105483. * Are bump textures enabled in the application.
  105484. */
  105485. static get BumpTextureEnabled(): boolean;
  105486. static set BumpTextureEnabled(value: boolean);
  105487. /**
  105488. * Are lightmap textures enabled in the application.
  105489. */
  105490. static get LightmapTextureEnabled(): boolean;
  105491. static set LightmapTextureEnabled(value: boolean);
  105492. /**
  105493. * Are refraction textures enabled in the application.
  105494. */
  105495. static get RefractionTextureEnabled(): boolean;
  105496. static set RefractionTextureEnabled(value: boolean);
  105497. /**
  105498. * Are color grading textures enabled in the application.
  105499. */
  105500. static get ColorGradingTextureEnabled(): boolean;
  105501. static set ColorGradingTextureEnabled(value: boolean);
  105502. /**
  105503. * Are fresnels enabled in the application.
  105504. */
  105505. static get FresnelEnabled(): boolean;
  105506. static set FresnelEnabled(value: boolean);
  105507. }
  105508. }
  105509. declare module BABYLON {
  105510. /** @hidden */
  105511. export var rgbdDecodePixelShader: {
  105512. name: string;
  105513. shader: string;
  105514. };
  105515. }
  105516. declare module BABYLON {
  105517. /** @hidden */
  105518. export var passPixelShader: {
  105519. name: string;
  105520. shader: string;
  105521. };
  105522. }
  105523. declare module BABYLON {
  105524. /** @hidden */
  105525. export var passCubePixelShader: {
  105526. name: string;
  105527. shader: string;
  105528. };
  105529. }
  105530. declare module BABYLON {
  105531. /**
  105532. * PassPostProcess which produces an output the same as it's input
  105533. */
  105534. export class PassPostProcess extends PostProcess {
  105535. /**
  105536. * Gets a string identifying the name of the class
  105537. * @returns "PassPostProcess" string
  105538. */
  105539. getClassName(): string;
  105540. /**
  105541. * Creates the PassPostProcess
  105542. * @param name The name of the effect.
  105543. * @param options The required width/height ratio to downsize to before computing the render pass.
  105544. * @param camera The camera to apply the render pass to.
  105545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105546. * @param engine The engine which the post process will be applied. (default: current engine)
  105547. * @param reusable If the post process can be reused on the same frame. (default: false)
  105548. * @param textureType The type of texture to be used when performing the post processing.
  105549. * @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)
  105550. */
  105551. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105552. /** @hidden */
  105553. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  105554. }
  105555. /**
  105556. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105557. */
  105558. export class PassCubePostProcess extends PostProcess {
  105559. private _face;
  105560. /**
  105561. * Gets or sets the cube face to display.
  105562. * * 0 is +X
  105563. * * 1 is -X
  105564. * * 2 is +Y
  105565. * * 3 is -Y
  105566. * * 4 is +Z
  105567. * * 5 is -Z
  105568. */
  105569. get face(): number;
  105570. set face(value: number);
  105571. /**
  105572. * Gets a string identifying the name of the class
  105573. * @returns "PassCubePostProcess" string
  105574. */
  105575. getClassName(): string;
  105576. /**
  105577. * Creates the PassCubePostProcess
  105578. * @param name The name of the effect.
  105579. * @param options The required width/height ratio to downsize to before computing the render pass.
  105580. * @param camera The camera to apply the render pass to.
  105581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105582. * @param engine The engine which the post process will be applied. (default: current engine)
  105583. * @param reusable If the post process can be reused on the same frame. (default: false)
  105584. * @param textureType The type of texture to be used when performing the post processing.
  105585. * @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)
  105586. */
  105587. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105588. /** @hidden */
  105589. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  105590. }
  105591. }
  105592. declare module BABYLON {
  105593. /**
  105594. * Class used to host texture specific utilities
  105595. */
  105596. export class TextureTools {
  105597. /**
  105598. * Uses the GPU to create a copy texture rescaled at a given size
  105599. * @param texture Texture to copy from
  105600. * @param width defines the desired width
  105601. * @param height defines the desired height
  105602. * @param useBilinearMode defines if bilinear mode has to be used
  105603. * @return the generated texture
  105604. */
  105605. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  105606. /**
  105607. * Apply a post process to a texture
  105608. * @param postProcessName name of the fragment post process
  105609. * @param internalTexture the texture to encode
  105610. * @param scene the scene hosting the texture
  105611. * @param type type of the output texture. If not provided, use the one from internalTexture
  105612. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  105613. * @param format format of the output texture. If not provided, use the one from internalTexture
  105614. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  105615. */
  105616. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  105617. }
  105618. }
  105619. declare module BABYLON {
  105620. /**
  105621. * Class used to host RGBD texture specific utilities
  105622. */
  105623. export class RGBDTextureTools {
  105624. /**
  105625. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105626. * @param texture the texture to expand.
  105627. */
  105628. static ExpandRGBDTexture(texture: Texture): void;
  105629. /**
  105630. * Encode the texture to RGBD if possible.
  105631. * @param internalTexture the texture to encode
  105632. * @param scene the scene hosting the texture
  105633. * @param outputTextureType type of the texture in which the encoding is performed
  105634. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  105635. */
  105636. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  105637. }
  105638. }
  105639. declare module BABYLON {
  105640. /**
  105641. * Class used to host texture specific utilities
  105642. */
  105643. export class BRDFTextureTools {
  105644. /**
  105645. * Prevents texture cache collision
  105646. */
  105647. private static _instanceNumber;
  105648. /**
  105649. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105650. * @param scene defines the hosting scene
  105651. * @returns the environment BRDF texture
  105652. */
  105653. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105654. private static _environmentBRDFBase64Texture;
  105655. }
  105656. }
  105657. declare module BABYLON {
  105658. /**
  105659. * @hidden
  105660. */
  105661. export interface IMaterialClearCoatDefines {
  105662. CLEARCOAT: boolean;
  105663. CLEARCOAT_DEFAULTIOR: boolean;
  105664. CLEARCOAT_TEXTURE: boolean;
  105665. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105666. CLEARCOAT_TEXTUREDIRECTUV: number;
  105667. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105668. CLEARCOAT_BUMP: boolean;
  105669. CLEARCOAT_BUMPDIRECTUV: number;
  105670. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105671. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105672. CLEARCOAT_REMAP_F0: boolean;
  105673. CLEARCOAT_TINT: boolean;
  105674. CLEARCOAT_TINT_TEXTURE: boolean;
  105675. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105676. /** @hidden */
  105677. _areTexturesDirty: boolean;
  105678. }
  105679. /**
  105680. * Define the code related to the clear coat parameters of the pbr material.
  105681. */
  105682. export class PBRClearCoatConfiguration {
  105683. /**
  105684. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105685. * The default fits with a polyurethane material.
  105686. * @hidden
  105687. */
  105688. static readonly _DefaultIndexOfRefraction: number;
  105689. private _isEnabled;
  105690. /**
  105691. * Defines if the clear coat is enabled in the material.
  105692. */
  105693. isEnabled: boolean;
  105694. /**
  105695. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105696. */
  105697. intensity: number;
  105698. /**
  105699. * Defines the clear coat layer roughness.
  105700. */
  105701. roughness: number;
  105702. private _indexOfRefraction;
  105703. /**
  105704. * Defines the index of refraction of the clear coat.
  105705. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105706. * The default fits with a polyurethane material.
  105707. * Changing the default value is more performance intensive.
  105708. */
  105709. indexOfRefraction: number;
  105710. private _texture;
  105711. /**
  105712. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105713. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105714. * if textureRoughness is not empty, else no texture roughness is used
  105715. */
  105716. texture: Nullable<BaseTexture>;
  105717. private _useRoughnessFromMainTexture;
  105718. /**
  105719. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105720. * If false, the green channel from textureRoughness is used for roughness
  105721. */
  105722. useRoughnessFromMainTexture: boolean;
  105723. private _textureRoughness;
  105724. /**
  105725. * Stores the clear coat roughness in a texture (green channel)
  105726. * Not used if useRoughnessFromMainTexture is true
  105727. */
  105728. textureRoughness: Nullable<BaseTexture>;
  105729. private _remapF0OnInterfaceChange;
  105730. /**
  105731. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105732. */
  105733. remapF0OnInterfaceChange: boolean;
  105734. private _bumpTexture;
  105735. /**
  105736. * Define the clear coat specific bump texture.
  105737. */
  105738. bumpTexture: Nullable<BaseTexture>;
  105739. private _isTintEnabled;
  105740. /**
  105741. * Defines if the clear coat tint is enabled in the material.
  105742. */
  105743. isTintEnabled: boolean;
  105744. /**
  105745. * Defines the clear coat tint of the material.
  105746. * This is only use if tint is enabled
  105747. */
  105748. tintColor: Color3;
  105749. /**
  105750. * Defines the distance at which the tint color should be found in the
  105751. * clear coat media.
  105752. * This is only use if tint is enabled
  105753. */
  105754. tintColorAtDistance: number;
  105755. /**
  105756. * Defines the clear coat layer thickness.
  105757. * This is only use if tint is enabled
  105758. */
  105759. tintThickness: number;
  105760. private _tintTexture;
  105761. /**
  105762. * Stores the clear tint values in a texture.
  105763. * rgb is tint
  105764. * a is a thickness factor
  105765. */
  105766. tintTexture: Nullable<BaseTexture>;
  105767. /** @hidden */
  105768. private _internalMarkAllSubMeshesAsTexturesDirty;
  105769. /** @hidden */
  105770. _markAllSubMeshesAsTexturesDirty(): void;
  105771. /**
  105772. * Instantiate a new instance of clear coat configuration.
  105773. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105774. */
  105775. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105776. /**
  105777. * Gets whether the submesh is ready to be used or not.
  105778. * @param defines the list of "defines" to update.
  105779. * @param scene defines the scene the material belongs to.
  105780. * @param engine defines the engine the material belongs to.
  105781. * @param disableBumpMap defines whether the material disables bump or not.
  105782. * @returns - boolean indicating that the submesh is ready or not.
  105783. */
  105784. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105785. /**
  105786. * Checks to see if a texture is used in the material.
  105787. * @param defines the list of "defines" to update.
  105788. * @param scene defines the scene to the material belongs to.
  105789. */
  105790. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105791. /**
  105792. * Binds the material data.
  105793. * @param uniformBuffer defines the Uniform buffer to fill in.
  105794. * @param scene defines the scene the material belongs to.
  105795. * @param engine defines the engine the material belongs to.
  105796. * @param disableBumpMap defines whether the material disables bump or not.
  105797. * @param isFrozen defines whether the material is frozen or not.
  105798. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105799. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105800. * @param subMesh the submesh to bind data for
  105801. */
  105802. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105803. /**
  105804. * Checks to see if a texture is used in the material.
  105805. * @param texture - Base texture to use.
  105806. * @returns - Boolean specifying if a texture is used in the material.
  105807. */
  105808. hasTexture(texture: BaseTexture): boolean;
  105809. /**
  105810. * Returns an array of the actively used textures.
  105811. * @param activeTextures Array of BaseTextures
  105812. */
  105813. getActiveTextures(activeTextures: BaseTexture[]): void;
  105814. /**
  105815. * Returns the animatable textures.
  105816. * @param animatables Array of animatable textures.
  105817. */
  105818. getAnimatables(animatables: IAnimatable[]): void;
  105819. /**
  105820. * Disposes the resources of the material.
  105821. * @param forceDisposeTextures - Forces the disposal of all textures.
  105822. */
  105823. dispose(forceDisposeTextures?: boolean): void;
  105824. /**
  105825. * Get the current class name of the texture useful for serialization or dynamic coding.
  105826. * @returns "PBRClearCoatConfiguration"
  105827. */
  105828. getClassName(): string;
  105829. /**
  105830. * Add fallbacks to the effect fallbacks list.
  105831. * @param defines defines the Base texture to use.
  105832. * @param fallbacks defines the current fallback list.
  105833. * @param currentRank defines the current fallback rank.
  105834. * @returns the new fallback rank.
  105835. */
  105836. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105837. /**
  105838. * Add the required uniforms to the current list.
  105839. * @param uniforms defines the current uniform list.
  105840. */
  105841. static AddUniforms(uniforms: string[]): void;
  105842. /**
  105843. * Add the required samplers to the current list.
  105844. * @param samplers defines the current sampler list.
  105845. */
  105846. static AddSamplers(samplers: string[]): void;
  105847. /**
  105848. * Add the required uniforms to the current buffer.
  105849. * @param uniformBuffer defines the current uniform buffer.
  105850. */
  105851. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105852. /**
  105853. * Makes a duplicate of the current configuration into another one.
  105854. * @param clearCoatConfiguration define the config where to copy the info
  105855. */
  105856. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105857. /**
  105858. * Serializes this clear coat configuration.
  105859. * @returns - An object with the serialized config.
  105860. */
  105861. serialize(): any;
  105862. /**
  105863. * Parses a anisotropy Configuration from a serialized object.
  105864. * @param source - Serialized object.
  105865. * @param scene Defines the scene we are parsing for
  105866. * @param rootUrl Defines the rootUrl to load from
  105867. */
  105868. parse(source: any, scene: Scene, rootUrl: string): void;
  105869. }
  105870. }
  105871. declare module BABYLON {
  105872. /**
  105873. * @hidden
  105874. */
  105875. export interface IMaterialAnisotropicDefines {
  105876. ANISOTROPIC: boolean;
  105877. ANISOTROPIC_TEXTURE: boolean;
  105878. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105879. MAINUV1: boolean;
  105880. _areTexturesDirty: boolean;
  105881. _needUVs: boolean;
  105882. }
  105883. /**
  105884. * Define the code related to the anisotropic parameters of the pbr material.
  105885. */
  105886. export class PBRAnisotropicConfiguration {
  105887. private _isEnabled;
  105888. /**
  105889. * Defines if the anisotropy is enabled in the material.
  105890. */
  105891. isEnabled: boolean;
  105892. /**
  105893. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105894. */
  105895. intensity: number;
  105896. /**
  105897. * Defines if the effect is along the tangents, bitangents or in between.
  105898. * By default, the effect is "stretching" the highlights along the tangents.
  105899. */
  105900. direction: Vector2;
  105901. private _texture;
  105902. /**
  105903. * Stores the anisotropy values in a texture.
  105904. * rg is direction (like normal from -1 to 1)
  105905. * b is a intensity
  105906. */
  105907. texture: Nullable<BaseTexture>;
  105908. /** @hidden */
  105909. private _internalMarkAllSubMeshesAsTexturesDirty;
  105910. /** @hidden */
  105911. _markAllSubMeshesAsTexturesDirty(): void;
  105912. /**
  105913. * Instantiate a new instance of anisotropy configuration.
  105914. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105915. */
  105916. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105917. /**
  105918. * Specifies that the submesh is ready to be used.
  105919. * @param defines the list of "defines" to update.
  105920. * @param scene defines the scene the material belongs to.
  105921. * @returns - boolean indicating that the submesh is ready or not.
  105922. */
  105923. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105924. /**
  105925. * Checks to see if a texture is used in the material.
  105926. * @param defines the list of "defines" to update.
  105927. * @param mesh the mesh we are preparing the defines for.
  105928. * @param scene defines the scene the material belongs to.
  105929. */
  105930. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105931. /**
  105932. * Binds the material data.
  105933. * @param uniformBuffer defines the Uniform buffer to fill in.
  105934. * @param scene defines the scene the material belongs to.
  105935. * @param isFrozen defines whether the material is frozen or not.
  105936. */
  105937. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105938. /**
  105939. * Checks to see if a texture is used in the material.
  105940. * @param texture - Base texture to use.
  105941. * @returns - Boolean specifying if a texture is used in the material.
  105942. */
  105943. hasTexture(texture: BaseTexture): boolean;
  105944. /**
  105945. * Returns an array of the actively used textures.
  105946. * @param activeTextures Array of BaseTextures
  105947. */
  105948. getActiveTextures(activeTextures: BaseTexture[]): void;
  105949. /**
  105950. * Returns the animatable textures.
  105951. * @param animatables Array of animatable textures.
  105952. */
  105953. getAnimatables(animatables: IAnimatable[]): void;
  105954. /**
  105955. * Disposes the resources of the material.
  105956. * @param forceDisposeTextures - Forces the disposal of all textures.
  105957. */
  105958. dispose(forceDisposeTextures?: boolean): void;
  105959. /**
  105960. * Get the current class name of the texture useful for serialization or dynamic coding.
  105961. * @returns "PBRAnisotropicConfiguration"
  105962. */
  105963. getClassName(): string;
  105964. /**
  105965. * Add fallbacks to the effect fallbacks list.
  105966. * @param defines defines the Base texture to use.
  105967. * @param fallbacks defines the current fallback list.
  105968. * @param currentRank defines the current fallback rank.
  105969. * @returns the new fallback rank.
  105970. */
  105971. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105972. /**
  105973. * Add the required uniforms to the current list.
  105974. * @param uniforms defines the current uniform list.
  105975. */
  105976. static AddUniforms(uniforms: string[]): void;
  105977. /**
  105978. * Add the required uniforms to the current buffer.
  105979. * @param uniformBuffer defines the current uniform buffer.
  105980. */
  105981. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105982. /**
  105983. * Add the required samplers to the current list.
  105984. * @param samplers defines the current sampler list.
  105985. */
  105986. static AddSamplers(samplers: string[]): void;
  105987. /**
  105988. * Makes a duplicate of the current configuration into another one.
  105989. * @param anisotropicConfiguration define the config where to copy the info
  105990. */
  105991. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105992. /**
  105993. * Serializes this anisotropy configuration.
  105994. * @returns - An object with the serialized config.
  105995. */
  105996. serialize(): any;
  105997. /**
  105998. * Parses a anisotropy Configuration from a serialized object.
  105999. * @param source - Serialized object.
  106000. * @param scene Defines the scene we are parsing for
  106001. * @param rootUrl Defines the rootUrl to load from
  106002. */
  106003. parse(source: any, scene: Scene, rootUrl: string): void;
  106004. }
  106005. }
  106006. declare module BABYLON {
  106007. /**
  106008. * @hidden
  106009. */
  106010. export interface IMaterialBRDFDefines {
  106011. BRDF_V_HEIGHT_CORRELATED: boolean;
  106012. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106013. SPHERICAL_HARMONICS: boolean;
  106014. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106015. /** @hidden */
  106016. _areMiscDirty: boolean;
  106017. }
  106018. /**
  106019. * Define the code related to the BRDF parameters of the pbr material.
  106020. */
  106021. export class PBRBRDFConfiguration {
  106022. /**
  106023. * Default value used for the energy conservation.
  106024. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106025. */
  106026. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  106027. /**
  106028. * Default value used for the Smith Visibility Height Correlated mode.
  106029. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106030. */
  106031. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  106032. /**
  106033. * Default value used for the IBL diffuse part.
  106034. * This can help switching back to the polynomials mode globally which is a tiny bit
  106035. * less GPU intensive at the drawback of a lower quality.
  106036. */
  106037. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  106038. /**
  106039. * Default value used for activating energy conservation for the specular workflow.
  106040. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106041. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106042. */
  106043. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  106044. private _useEnergyConservation;
  106045. /**
  106046. * Defines if the material uses energy conservation.
  106047. */
  106048. useEnergyConservation: boolean;
  106049. private _useSmithVisibilityHeightCorrelated;
  106050. /**
  106051. * LEGACY Mode set to false
  106052. * Defines if the material uses height smith correlated visibility term.
  106053. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  106054. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  106055. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  106056. * Not relying on height correlated will also disable energy conservation.
  106057. */
  106058. useSmithVisibilityHeightCorrelated: boolean;
  106059. private _useSphericalHarmonics;
  106060. /**
  106061. * LEGACY Mode set to false
  106062. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  106063. * diffuse part of the IBL.
  106064. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  106065. * to the ground truth.
  106066. */
  106067. useSphericalHarmonics: boolean;
  106068. private _useSpecularGlossinessInputEnergyConservation;
  106069. /**
  106070. * Defines if the material uses energy conservation, when the specular workflow is active.
  106071. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106072. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106073. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  106074. */
  106075. useSpecularGlossinessInputEnergyConservation: boolean;
  106076. /** @hidden */
  106077. private _internalMarkAllSubMeshesAsMiscDirty;
  106078. /** @hidden */
  106079. _markAllSubMeshesAsMiscDirty(): void;
  106080. /**
  106081. * Instantiate a new instance of clear coat configuration.
  106082. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  106083. */
  106084. constructor(markAllSubMeshesAsMiscDirty: () => void);
  106085. /**
  106086. * Checks to see if a texture is used in the material.
  106087. * @param defines the list of "defines" to update.
  106088. */
  106089. prepareDefines(defines: IMaterialBRDFDefines): void;
  106090. /**
  106091. * Get the current class name of the texture useful for serialization or dynamic coding.
  106092. * @returns "PBRClearCoatConfiguration"
  106093. */
  106094. getClassName(): string;
  106095. /**
  106096. * Makes a duplicate of the current configuration into another one.
  106097. * @param brdfConfiguration define the config where to copy the info
  106098. */
  106099. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  106100. /**
  106101. * Serializes this BRDF configuration.
  106102. * @returns - An object with the serialized config.
  106103. */
  106104. serialize(): any;
  106105. /**
  106106. * Parses a anisotropy Configuration from a serialized object.
  106107. * @param source - Serialized object.
  106108. * @param scene Defines the scene we are parsing for
  106109. * @param rootUrl Defines the rootUrl to load from
  106110. */
  106111. parse(source: any, scene: Scene, rootUrl: string): void;
  106112. }
  106113. }
  106114. declare module BABYLON {
  106115. /**
  106116. * @hidden
  106117. */
  106118. export interface IMaterialSheenDefines {
  106119. SHEEN: boolean;
  106120. SHEEN_TEXTURE: boolean;
  106121. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106122. SHEEN_TEXTUREDIRECTUV: number;
  106123. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106124. SHEEN_LINKWITHALBEDO: boolean;
  106125. SHEEN_ROUGHNESS: boolean;
  106126. SHEEN_ALBEDOSCALING: boolean;
  106127. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106128. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106129. /** @hidden */
  106130. _areTexturesDirty: boolean;
  106131. }
  106132. /**
  106133. * Define the code related to the Sheen parameters of the pbr material.
  106134. */
  106135. export class PBRSheenConfiguration {
  106136. private _isEnabled;
  106137. /**
  106138. * Defines if the material uses sheen.
  106139. */
  106140. isEnabled: boolean;
  106141. private _linkSheenWithAlbedo;
  106142. /**
  106143. * Defines if the sheen is linked to the sheen color.
  106144. */
  106145. linkSheenWithAlbedo: boolean;
  106146. /**
  106147. * Defines the sheen intensity.
  106148. */
  106149. intensity: number;
  106150. /**
  106151. * Defines the sheen color.
  106152. */
  106153. color: Color3;
  106154. private _texture;
  106155. /**
  106156. * Stores the sheen tint values in a texture.
  106157. * rgb is tint
  106158. * 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)
  106159. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  106160. */
  106161. texture: Nullable<BaseTexture>;
  106162. private _useRoughnessFromMainTexture;
  106163. /**
  106164. * Indicates that the alpha channel of the texture property will be used for roughness.
  106165. * Has no effect if the roughness (and texture!) property is not defined
  106166. */
  106167. useRoughnessFromMainTexture: boolean;
  106168. private _roughness;
  106169. /**
  106170. * Defines the sheen roughness.
  106171. * It is not taken into account if linkSheenWithAlbedo is true.
  106172. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  106173. */
  106174. roughness: Nullable<number>;
  106175. private _textureRoughness;
  106176. /**
  106177. * Stores the sheen roughness in a texture.
  106178. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  106179. */
  106180. textureRoughness: Nullable<BaseTexture>;
  106181. private _albedoScaling;
  106182. /**
  106183. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  106184. * It allows the strength of the sheen effect to not depend on the base color of the material,
  106185. * making it easier to setup and tweak the effect
  106186. */
  106187. albedoScaling: boolean;
  106188. /** @hidden */
  106189. private _internalMarkAllSubMeshesAsTexturesDirty;
  106190. /** @hidden */
  106191. _markAllSubMeshesAsTexturesDirty(): void;
  106192. /**
  106193. * Instantiate a new instance of clear coat configuration.
  106194. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106195. */
  106196. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106197. /**
  106198. * Specifies that the submesh is ready to be used.
  106199. * @param defines the list of "defines" to update.
  106200. * @param scene defines the scene the material belongs to.
  106201. * @returns - boolean indicating that the submesh is ready or not.
  106202. */
  106203. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  106204. /**
  106205. * Checks to see if a texture is used in the material.
  106206. * @param defines the list of "defines" to update.
  106207. * @param scene defines the scene the material belongs to.
  106208. */
  106209. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  106210. /**
  106211. * Binds the material data.
  106212. * @param uniformBuffer defines the Uniform buffer to fill in.
  106213. * @param scene defines the scene the material belongs to.
  106214. * @param isFrozen defines whether the material is frozen or not.
  106215. * @param subMesh the submesh to bind data for
  106216. */
  106217. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  106218. /**
  106219. * Checks to see if a texture is used in the material.
  106220. * @param texture - Base texture to use.
  106221. * @returns - Boolean specifying if a texture is used in the material.
  106222. */
  106223. hasTexture(texture: BaseTexture): boolean;
  106224. /**
  106225. * Returns an array of the actively used textures.
  106226. * @param activeTextures Array of BaseTextures
  106227. */
  106228. getActiveTextures(activeTextures: BaseTexture[]): void;
  106229. /**
  106230. * Returns the animatable textures.
  106231. * @param animatables Array of animatable textures.
  106232. */
  106233. getAnimatables(animatables: IAnimatable[]): void;
  106234. /**
  106235. * Disposes the resources of the material.
  106236. * @param forceDisposeTextures - Forces the disposal of all textures.
  106237. */
  106238. dispose(forceDisposeTextures?: boolean): void;
  106239. /**
  106240. * Get the current class name of the texture useful for serialization or dynamic coding.
  106241. * @returns "PBRSheenConfiguration"
  106242. */
  106243. getClassName(): string;
  106244. /**
  106245. * Add fallbacks to the effect fallbacks list.
  106246. * @param defines defines the Base texture to use.
  106247. * @param fallbacks defines the current fallback list.
  106248. * @param currentRank defines the current fallback rank.
  106249. * @returns the new fallback rank.
  106250. */
  106251. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106252. /**
  106253. * Add the required uniforms to the current list.
  106254. * @param uniforms defines the current uniform list.
  106255. */
  106256. static AddUniforms(uniforms: string[]): void;
  106257. /**
  106258. * Add the required uniforms to the current buffer.
  106259. * @param uniformBuffer defines the current uniform buffer.
  106260. */
  106261. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106262. /**
  106263. * Add the required samplers to the current list.
  106264. * @param samplers defines the current sampler list.
  106265. */
  106266. static AddSamplers(samplers: string[]): void;
  106267. /**
  106268. * Makes a duplicate of the current configuration into another one.
  106269. * @param sheenConfiguration define the config where to copy the info
  106270. */
  106271. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  106272. /**
  106273. * Serializes this BRDF configuration.
  106274. * @returns - An object with the serialized config.
  106275. */
  106276. serialize(): any;
  106277. /**
  106278. * Parses a anisotropy Configuration from a serialized object.
  106279. * @param source - Serialized object.
  106280. * @param scene Defines the scene we are parsing for
  106281. * @param rootUrl Defines the rootUrl to load from
  106282. */
  106283. parse(source: any, scene: Scene, rootUrl: string): void;
  106284. }
  106285. }
  106286. declare module BABYLON {
  106287. /**
  106288. * @hidden
  106289. */
  106290. export interface IMaterialSubSurfaceDefines {
  106291. SUBSURFACE: boolean;
  106292. SS_REFRACTION: boolean;
  106293. SS_TRANSLUCENCY: boolean;
  106294. SS_SCATTERING: boolean;
  106295. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106296. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106297. SS_REFRACTIONMAP_3D: boolean;
  106298. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106299. SS_LODINREFRACTIONALPHA: boolean;
  106300. SS_GAMMAREFRACTION: boolean;
  106301. SS_RGBDREFRACTION: boolean;
  106302. SS_LINEARSPECULARREFRACTION: boolean;
  106303. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106304. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106305. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106306. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  106307. /** @hidden */
  106308. _areTexturesDirty: boolean;
  106309. }
  106310. /**
  106311. * Define the code related to the sub surface parameters of the pbr material.
  106312. */
  106313. export class PBRSubSurfaceConfiguration {
  106314. private _isRefractionEnabled;
  106315. /**
  106316. * Defines if the refraction is enabled in the material.
  106317. */
  106318. isRefractionEnabled: boolean;
  106319. private _isTranslucencyEnabled;
  106320. /**
  106321. * Defines if the translucency is enabled in the material.
  106322. */
  106323. isTranslucencyEnabled: boolean;
  106324. private _isScatteringEnabled;
  106325. /**
  106326. * Defines if the sub surface scattering is enabled in the material.
  106327. */
  106328. isScatteringEnabled: boolean;
  106329. private _scatteringDiffusionProfileIndex;
  106330. /**
  106331. * Diffusion profile for subsurface scattering.
  106332. * Useful for better scattering in the skins or foliages.
  106333. */
  106334. get scatteringDiffusionProfile(): Nullable<Color3>;
  106335. set scatteringDiffusionProfile(c: Nullable<Color3>);
  106336. /**
  106337. * Defines the refraction intensity of the material.
  106338. * The refraction when enabled replaces the Diffuse part of the material.
  106339. * The intensity helps transitioning between diffuse and refraction.
  106340. */
  106341. refractionIntensity: number;
  106342. /**
  106343. * Defines the translucency intensity of the material.
  106344. * When translucency has been enabled, this defines how much of the "translucency"
  106345. * is added to the diffuse part of the material.
  106346. */
  106347. translucencyIntensity: number;
  106348. /**
  106349. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  106350. */
  106351. useAlbedoToTintRefraction: boolean;
  106352. private _thicknessTexture;
  106353. /**
  106354. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  106355. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  106356. * 0 would mean minimumThickness
  106357. * 1 would mean maximumThickness
  106358. * The other channels might be use as a mask to vary the different effects intensity.
  106359. */
  106360. thicknessTexture: Nullable<BaseTexture>;
  106361. private _refractionTexture;
  106362. /**
  106363. * Defines the texture to use for refraction.
  106364. */
  106365. refractionTexture: Nullable<BaseTexture>;
  106366. private _indexOfRefraction;
  106367. /**
  106368. * Index of refraction of the material base layer.
  106369. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106370. *
  106371. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106372. *
  106373. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106374. */
  106375. indexOfRefraction: number;
  106376. private _volumeIndexOfRefraction;
  106377. /**
  106378. * Index of refraction of the material's volume.
  106379. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106380. *
  106381. * This ONLY impacts refraction. If not provided or given a non-valid value,
  106382. * the volume will use the same IOR as the surface.
  106383. */
  106384. get volumeIndexOfRefraction(): number;
  106385. set volumeIndexOfRefraction(value: number);
  106386. private _invertRefractionY;
  106387. /**
  106388. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106389. */
  106390. invertRefractionY: boolean;
  106391. private _linkRefractionWithTransparency;
  106392. /**
  106393. * This parameters will make the material used its opacity to control how much it is refracting against not.
  106394. * Materials half opaque for instance using refraction could benefit from this control.
  106395. */
  106396. linkRefractionWithTransparency: boolean;
  106397. /**
  106398. * Defines the minimum thickness stored in the thickness map.
  106399. * If no thickness map is defined, this value will be used to simulate thickness.
  106400. */
  106401. minimumThickness: number;
  106402. /**
  106403. * Defines the maximum thickness stored in the thickness map.
  106404. */
  106405. maximumThickness: number;
  106406. /**
  106407. * Defines the volume tint of the material.
  106408. * This is used for both translucency and scattering.
  106409. */
  106410. tintColor: Color3;
  106411. /**
  106412. * Defines the distance at which the tint color should be found in the media.
  106413. * This is used for refraction only.
  106414. */
  106415. tintColorAtDistance: number;
  106416. /**
  106417. * Defines how far each channel transmit through the media.
  106418. * It is defined as a color to simplify it selection.
  106419. */
  106420. diffusionDistance: Color3;
  106421. private _useMaskFromThicknessTexture;
  106422. /**
  106423. * Stores the intensity of the different subsurface effects in the thickness texture.
  106424. * * the green channel is the translucency intensity.
  106425. * * the blue channel is the scattering intensity.
  106426. * * the alpha channel is the refraction intensity.
  106427. */
  106428. useMaskFromThicknessTexture: boolean;
  106429. private _scene;
  106430. private _useMaskFromThicknessTextureGltf;
  106431. /**
  106432. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  106433. * matches the channel-packing that is used by glTF.
  106434. * * the red channel is the transmission/translucency intensity.
  106435. * * the green channel is the thickness.
  106436. */
  106437. useMaskFromThicknessTextureGltf: boolean;
  106438. /** @hidden */
  106439. private _internalMarkAllSubMeshesAsTexturesDirty;
  106440. private _internalMarkScenePrePassDirty;
  106441. /** @hidden */
  106442. _markAllSubMeshesAsTexturesDirty(): void;
  106443. /** @hidden */
  106444. _markScenePrePassDirty(): void;
  106445. /**
  106446. * Instantiate a new instance of sub surface configuration.
  106447. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106448. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106449. * @param scene The scene
  106450. */
  106451. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106452. /**
  106453. * Gets whether the submesh is ready to be used or not.
  106454. * @param defines the list of "defines" to update.
  106455. * @param scene defines the scene the material belongs to.
  106456. * @returns - boolean indicating that the submesh is ready or not.
  106457. */
  106458. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106459. /**
  106460. * Checks to see if a texture is used in the material.
  106461. * @param defines the list of "defines" to update.
  106462. * @param scene defines the scene to the material belongs to.
  106463. */
  106464. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106465. /**
  106466. * Binds the material data.
  106467. * @param uniformBuffer defines the Uniform buffer to fill in.
  106468. * @param scene defines the scene the material belongs to.
  106469. * @param engine defines the engine the material belongs to.
  106470. * @param isFrozen defines whether the material is frozen or not.
  106471. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106472. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106473. */
  106474. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106475. /**
  106476. * Unbinds the material from the mesh.
  106477. * @param activeEffect defines the effect that should be unbound from.
  106478. * @returns true if unbound, otherwise false
  106479. */
  106480. unbind(activeEffect: Effect): boolean;
  106481. /**
  106482. * Returns the texture used for refraction or null if none is used.
  106483. * @param scene defines the scene the material belongs to.
  106484. * @returns - Refraction texture if present. If no refraction texture and refraction
  106485. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106486. */
  106487. private _getRefractionTexture;
  106488. /**
  106489. * Returns true if alpha blending should be disabled.
  106490. */
  106491. get disableAlphaBlending(): boolean;
  106492. /**
  106493. * Fills the list of render target textures.
  106494. * @param renderTargets the list of render targets to update
  106495. */
  106496. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106497. /**
  106498. * Checks to see if a texture is used in the material.
  106499. * @param texture - Base texture to use.
  106500. * @returns - Boolean specifying if a texture is used in the material.
  106501. */
  106502. hasTexture(texture: BaseTexture): boolean;
  106503. /**
  106504. * Gets a boolean indicating that current material needs to register RTT
  106505. * @returns true if this uses a render target otherwise false.
  106506. */
  106507. hasRenderTargetTextures(): boolean;
  106508. /**
  106509. * Returns an array of the actively used textures.
  106510. * @param activeTextures Array of BaseTextures
  106511. */
  106512. getActiveTextures(activeTextures: BaseTexture[]): void;
  106513. /**
  106514. * Returns the animatable textures.
  106515. * @param animatables Array of animatable textures.
  106516. */
  106517. getAnimatables(animatables: IAnimatable[]): void;
  106518. /**
  106519. * Disposes the resources of the material.
  106520. * @param forceDisposeTextures - Forces the disposal of all textures.
  106521. */
  106522. dispose(forceDisposeTextures?: boolean): void;
  106523. /**
  106524. * Get the current class name of the texture useful for serialization or dynamic coding.
  106525. * @returns "PBRSubSurfaceConfiguration"
  106526. */
  106527. getClassName(): string;
  106528. /**
  106529. * Add fallbacks to the effect fallbacks list.
  106530. * @param defines defines the Base texture to use.
  106531. * @param fallbacks defines the current fallback list.
  106532. * @param currentRank defines the current fallback rank.
  106533. * @returns the new fallback rank.
  106534. */
  106535. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106536. /**
  106537. * Add the required uniforms to the current list.
  106538. * @param uniforms defines the current uniform list.
  106539. */
  106540. static AddUniforms(uniforms: string[]): void;
  106541. /**
  106542. * Add the required samplers to the current list.
  106543. * @param samplers defines the current sampler list.
  106544. */
  106545. static AddSamplers(samplers: string[]): void;
  106546. /**
  106547. * Add the required uniforms to the current buffer.
  106548. * @param uniformBuffer defines the current uniform buffer.
  106549. */
  106550. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106551. /**
  106552. * Makes a duplicate of the current configuration into another one.
  106553. * @param configuration define the config where to copy the info
  106554. */
  106555. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106556. /**
  106557. * Serializes this Sub Surface configuration.
  106558. * @returns - An object with the serialized config.
  106559. */
  106560. serialize(): any;
  106561. /**
  106562. * Parses a anisotropy Configuration from a serialized object.
  106563. * @param source - Serialized object.
  106564. * @param scene Defines the scene we are parsing for
  106565. * @param rootUrl Defines the rootUrl to load from
  106566. */
  106567. parse(source: any, scene: Scene, rootUrl: string): void;
  106568. }
  106569. }
  106570. declare module BABYLON {
  106571. /**
  106572. * Class representing spherical harmonics coefficients to the 3rd degree
  106573. */
  106574. export class SphericalHarmonics {
  106575. /**
  106576. * Defines whether or not the harmonics have been prescaled for rendering.
  106577. */
  106578. preScaled: boolean;
  106579. /**
  106580. * The l0,0 coefficients of the spherical harmonics
  106581. */
  106582. l00: Vector3;
  106583. /**
  106584. * The l1,-1 coefficients of the spherical harmonics
  106585. */
  106586. l1_1: Vector3;
  106587. /**
  106588. * The l1,0 coefficients of the spherical harmonics
  106589. */
  106590. l10: Vector3;
  106591. /**
  106592. * The l1,1 coefficients of the spherical harmonics
  106593. */
  106594. l11: Vector3;
  106595. /**
  106596. * The l2,-2 coefficients of the spherical harmonics
  106597. */
  106598. l2_2: Vector3;
  106599. /**
  106600. * The l2,-1 coefficients of the spherical harmonics
  106601. */
  106602. l2_1: Vector3;
  106603. /**
  106604. * The l2,0 coefficients of the spherical harmonics
  106605. */
  106606. l20: Vector3;
  106607. /**
  106608. * The l2,1 coefficients of the spherical harmonics
  106609. */
  106610. l21: Vector3;
  106611. /**
  106612. * The l2,2 coefficients of the spherical harmonics
  106613. */
  106614. l22: Vector3;
  106615. /**
  106616. * Adds a light to the spherical harmonics
  106617. * @param direction the direction of the light
  106618. * @param color the color of the light
  106619. * @param deltaSolidAngle the delta solid angle of the light
  106620. */
  106621. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106622. /**
  106623. * Scales the spherical harmonics by the given amount
  106624. * @param scale the amount to scale
  106625. */
  106626. scaleInPlace(scale: number): void;
  106627. /**
  106628. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106629. *
  106630. * ```
  106631. * E_lm = A_l * L_lm
  106632. * ```
  106633. *
  106634. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106635. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106636. * the scaling factors are given in equation 9.
  106637. */
  106638. convertIncidentRadianceToIrradiance(): void;
  106639. /**
  106640. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106641. *
  106642. * ```
  106643. * L = (1/pi) * E * rho
  106644. * ```
  106645. *
  106646. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106647. */
  106648. convertIrradianceToLambertianRadiance(): void;
  106649. /**
  106650. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106651. * required operations at run time.
  106652. *
  106653. * This is simply done by scaling back the SH with Ylm constants parameter.
  106654. * The trigonometric part being applied by the shader at run time.
  106655. */
  106656. preScaleForRendering(): void;
  106657. /**
  106658. * Constructs a spherical harmonics from an array.
  106659. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106660. * @returns the spherical harmonics
  106661. */
  106662. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106663. /**
  106664. * Gets the spherical harmonics from polynomial
  106665. * @param polynomial the spherical polynomial
  106666. * @returns the spherical harmonics
  106667. */
  106668. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106669. }
  106670. /**
  106671. * Class representing spherical polynomial coefficients to the 3rd degree
  106672. */
  106673. export class SphericalPolynomial {
  106674. private _harmonics;
  106675. /**
  106676. * The spherical harmonics used to create the polynomials.
  106677. */
  106678. get preScaledHarmonics(): SphericalHarmonics;
  106679. /**
  106680. * The x coefficients of the spherical polynomial
  106681. */
  106682. x: Vector3;
  106683. /**
  106684. * The y coefficients of the spherical polynomial
  106685. */
  106686. y: Vector3;
  106687. /**
  106688. * The z coefficients of the spherical polynomial
  106689. */
  106690. z: Vector3;
  106691. /**
  106692. * The xx coefficients of the spherical polynomial
  106693. */
  106694. xx: Vector3;
  106695. /**
  106696. * The yy coefficients of the spherical polynomial
  106697. */
  106698. yy: Vector3;
  106699. /**
  106700. * The zz coefficients of the spherical polynomial
  106701. */
  106702. zz: Vector3;
  106703. /**
  106704. * The xy coefficients of the spherical polynomial
  106705. */
  106706. xy: Vector3;
  106707. /**
  106708. * The yz coefficients of the spherical polynomial
  106709. */
  106710. yz: Vector3;
  106711. /**
  106712. * The zx coefficients of the spherical polynomial
  106713. */
  106714. zx: Vector3;
  106715. /**
  106716. * Adds an ambient color to the spherical polynomial
  106717. * @param color the color to add
  106718. */
  106719. addAmbient(color: Color3): void;
  106720. /**
  106721. * Scales the spherical polynomial by the given amount
  106722. * @param scale the amount to scale
  106723. */
  106724. scaleInPlace(scale: number): void;
  106725. /**
  106726. * Gets the spherical polynomial from harmonics
  106727. * @param harmonics the spherical harmonics
  106728. * @returns the spherical polynomial
  106729. */
  106730. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106731. /**
  106732. * Constructs a spherical polynomial from an array.
  106733. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106734. * @returns the spherical polynomial
  106735. */
  106736. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106737. }
  106738. }
  106739. declare module BABYLON {
  106740. /**
  106741. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106742. */
  106743. export interface CubeMapInfo {
  106744. /**
  106745. * The pixel array for the front face.
  106746. * This is stored in format, left to right, up to down format.
  106747. */
  106748. front: Nullable<ArrayBufferView>;
  106749. /**
  106750. * The pixel array for the back face.
  106751. * This is stored in format, left to right, up to down format.
  106752. */
  106753. back: Nullable<ArrayBufferView>;
  106754. /**
  106755. * The pixel array for the left face.
  106756. * This is stored in format, left to right, up to down format.
  106757. */
  106758. left: Nullable<ArrayBufferView>;
  106759. /**
  106760. * The pixel array for the right face.
  106761. * This is stored in format, left to right, up to down format.
  106762. */
  106763. right: Nullable<ArrayBufferView>;
  106764. /**
  106765. * The pixel array for the up face.
  106766. * This is stored in format, left to right, up to down format.
  106767. */
  106768. up: Nullable<ArrayBufferView>;
  106769. /**
  106770. * The pixel array for the down face.
  106771. * This is stored in format, left to right, up to down format.
  106772. */
  106773. down: Nullable<ArrayBufferView>;
  106774. /**
  106775. * The size of the cubemap stored.
  106776. *
  106777. * Each faces will be size * size pixels.
  106778. */
  106779. size: number;
  106780. /**
  106781. * The format of the texture.
  106782. *
  106783. * RGBA, RGB.
  106784. */
  106785. format: number;
  106786. /**
  106787. * The type of the texture data.
  106788. *
  106789. * UNSIGNED_INT, FLOAT.
  106790. */
  106791. type: number;
  106792. /**
  106793. * Specifies whether the texture is in gamma space.
  106794. */
  106795. gammaSpace: boolean;
  106796. }
  106797. /**
  106798. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106799. */
  106800. export class PanoramaToCubeMapTools {
  106801. private static FACE_LEFT;
  106802. private static FACE_RIGHT;
  106803. private static FACE_FRONT;
  106804. private static FACE_BACK;
  106805. private static FACE_DOWN;
  106806. private static FACE_UP;
  106807. /**
  106808. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  106809. *
  106810. * @param float32Array The source data.
  106811. * @param inputWidth The width of the input panorama.
  106812. * @param inputHeight The height of the input panorama.
  106813. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106814. * @return The cubemap data
  106815. */
  106816. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106817. private static CreateCubemapTexture;
  106818. private static CalcProjectionSpherical;
  106819. }
  106820. }
  106821. declare module BABYLON {
  106822. /**
  106823. * Helper class dealing with the extraction of spherical polynomial dataArray
  106824. * from a cube map.
  106825. */
  106826. export class CubeMapToSphericalPolynomialTools {
  106827. private static FileFaces;
  106828. /**
  106829. * Converts a texture to the according Spherical Polynomial data.
  106830. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106831. *
  106832. * @param texture The texture to extract the information from.
  106833. * @return The Spherical Polynomial data.
  106834. */
  106835. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  106836. /**
  106837. * Converts a cubemap to the according Spherical Polynomial data.
  106838. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106839. *
  106840. * @param cubeInfo The Cube map to extract the information from.
  106841. * @return The Spherical Polynomial data.
  106842. */
  106843. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106844. }
  106845. }
  106846. declare module BABYLON {
  106847. interface BaseTexture {
  106848. /**
  106849. * Get the polynomial representation of the texture data.
  106850. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106851. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106852. */
  106853. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106854. }
  106855. }
  106856. declare module BABYLON {
  106857. /** @hidden */
  106858. export var pbrFragmentDeclaration: {
  106859. name: string;
  106860. shader: string;
  106861. };
  106862. }
  106863. declare module BABYLON {
  106864. /** @hidden */
  106865. export var pbrUboDeclaration: {
  106866. name: string;
  106867. shader: string;
  106868. };
  106869. }
  106870. declare module BABYLON {
  106871. /** @hidden */
  106872. export var pbrFragmentExtraDeclaration: {
  106873. name: string;
  106874. shader: string;
  106875. };
  106876. }
  106877. declare module BABYLON {
  106878. /** @hidden */
  106879. export var pbrFragmentSamplersDeclaration: {
  106880. name: string;
  106881. shader: string;
  106882. };
  106883. }
  106884. declare module BABYLON {
  106885. /** @hidden */
  106886. export var subSurfaceScatteringFunctions: {
  106887. name: string;
  106888. shader: string;
  106889. };
  106890. }
  106891. declare module BABYLON {
  106892. /** @hidden */
  106893. export var importanceSampling: {
  106894. name: string;
  106895. shader: string;
  106896. };
  106897. }
  106898. declare module BABYLON {
  106899. /** @hidden */
  106900. export var pbrHelperFunctions: {
  106901. name: string;
  106902. shader: string;
  106903. };
  106904. }
  106905. declare module BABYLON {
  106906. /** @hidden */
  106907. export var harmonicsFunctions: {
  106908. name: string;
  106909. shader: string;
  106910. };
  106911. }
  106912. declare module BABYLON {
  106913. /** @hidden */
  106914. export var pbrDirectLightingSetupFunctions: {
  106915. name: string;
  106916. shader: string;
  106917. };
  106918. }
  106919. declare module BABYLON {
  106920. /** @hidden */
  106921. export var pbrDirectLightingFalloffFunctions: {
  106922. name: string;
  106923. shader: string;
  106924. };
  106925. }
  106926. declare module BABYLON {
  106927. /** @hidden */
  106928. export var pbrBRDFFunctions: {
  106929. name: string;
  106930. shader: string;
  106931. };
  106932. }
  106933. declare module BABYLON {
  106934. /** @hidden */
  106935. export var hdrFilteringFunctions: {
  106936. name: string;
  106937. shader: string;
  106938. };
  106939. }
  106940. declare module BABYLON {
  106941. /** @hidden */
  106942. export var pbrDirectLightingFunctions: {
  106943. name: string;
  106944. shader: string;
  106945. };
  106946. }
  106947. declare module BABYLON {
  106948. /** @hidden */
  106949. export var pbrIBLFunctions: {
  106950. name: string;
  106951. shader: string;
  106952. };
  106953. }
  106954. declare module BABYLON {
  106955. /** @hidden */
  106956. export var pbrBlockAlbedoOpacity: {
  106957. name: string;
  106958. shader: string;
  106959. };
  106960. }
  106961. declare module BABYLON {
  106962. /** @hidden */
  106963. export var pbrBlockReflectivity: {
  106964. name: string;
  106965. shader: string;
  106966. };
  106967. }
  106968. declare module BABYLON {
  106969. /** @hidden */
  106970. export var pbrBlockAmbientOcclusion: {
  106971. name: string;
  106972. shader: string;
  106973. };
  106974. }
  106975. declare module BABYLON {
  106976. /** @hidden */
  106977. export var pbrBlockAlphaFresnel: {
  106978. name: string;
  106979. shader: string;
  106980. };
  106981. }
  106982. declare module BABYLON {
  106983. /** @hidden */
  106984. export var pbrBlockAnisotropic: {
  106985. name: string;
  106986. shader: string;
  106987. };
  106988. }
  106989. declare module BABYLON {
  106990. /** @hidden */
  106991. export var pbrBlockReflection: {
  106992. name: string;
  106993. shader: string;
  106994. };
  106995. }
  106996. declare module BABYLON {
  106997. /** @hidden */
  106998. export var pbrBlockSheen: {
  106999. name: string;
  107000. shader: string;
  107001. };
  107002. }
  107003. declare module BABYLON {
  107004. /** @hidden */
  107005. export var pbrBlockClearcoat: {
  107006. name: string;
  107007. shader: string;
  107008. };
  107009. }
  107010. declare module BABYLON {
  107011. /** @hidden */
  107012. export var pbrBlockSubSurface: {
  107013. name: string;
  107014. shader: string;
  107015. };
  107016. }
  107017. declare module BABYLON {
  107018. /** @hidden */
  107019. export var pbrBlockNormalGeometric: {
  107020. name: string;
  107021. shader: string;
  107022. };
  107023. }
  107024. declare module BABYLON {
  107025. /** @hidden */
  107026. export var pbrBlockNormalFinal: {
  107027. name: string;
  107028. shader: string;
  107029. };
  107030. }
  107031. declare module BABYLON {
  107032. /** @hidden */
  107033. export var pbrBlockLightmapInit: {
  107034. name: string;
  107035. shader: string;
  107036. };
  107037. }
  107038. declare module BABYLON {
  107039. /** @hidden */
  107040. export var pbrBlockGeometryInfo: {
  107041. name: string;
  107042. shader: string;
  107043. };
  107044. }
  107045. declare module BABYLON {
  107046. /** @hidden */
  107047. export var pbrBlockReflectance0: {
  107048. name: string;
  107049. shader: string;
  107050. };
  107051. }
  107052. declare module BABYLON {
  107053. /** @hidden */
  107054. export var pbrBlockReflectance: {
  107055. name: string;
  107056. shader: string;
  107057. };
  107058. }
  107059. declare module BABYLON {
  107060. /** @hidden */
  107061. export var pbrBlockDirectLighting: {
  107062. name: string;
  107063. shader: string;
  107064. };
  107065. }
  107066. declare module BABYLON {
  107067. /** @hidden */
  107068. export var pbrBlockFinalLitComponents: {
  107069. name: string;
  107070. shader: string;
  107071. };
  107072. }
  107073. declare module BABYLON {
  107074. /** @hidden */
  107075. export var pbrBlockFinalUnlitComponents: {
  107076. name: string;
  107077. shader: string;
  107078. };
  107079. }
  107080. declare module BABYLON {
  107081. /** @hidden */
  107082. export var pbrBlockFinalColorComposition: {
  107083. name: string;
  107084. shader: string;
  107085. };
  107086. }
  107087. declare module BABYLON {
  107088. /** @hidden */
  107089. export var pbrBlockImageProcessing: {
  107090. name: string;
  107091. shader: string;
  107092. };
  107093. }
  107094. declare module BABYLON {
  107095. /** @hidden */
  107096. export var pbrDebug: {
  107097. name: string;
  107098. shader: string;
  107099. };
  107100. }
  107101. declare module BABYLON {
  107102. /** @hidden */
  107103. export var pbrPixelShader: {
  107104. name: string;
  107105. shader: string;
  107106. };
  107107. }
  107108. declare module BABYLON {
  107109. /** @hidden */
  107110. export var pbrVertexDeclaration: {
  107111. name: string;
  107112. shader: string;
  107113. };
  107114. }
  107115. declare module BABYLON {
  107116. /** @hidden */
  107117. export var pbrVertexShader: {
  107118. name: string;
  107119. shader: string;
  107120. };
  107121. }
  107122. declare module BABYLON {
  107123. /**
  107124. * Manages the defines for the PBR Material.
  107125. * @hidden
  107126. */
  107127. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  107128. PBR: boolean;
  107129. NUM_SAMPLES: string;
  107130. REALTIME_FILTERING: boolean;
  107131. MAINUV1: boolean;
  107132. MAINUV2: boolean;
  107133. UV1: boolean;
  107134. UV2: boolean;
  107135. ALBEDO: boolean;
  107136. GAMMAALBEDO: boolean;
  107137. ALBEDODIRECTUV: number;
  107138. VERTEXCOLOR: boolean;
  107139. DETAIL: boolean;
  107140. DETAILDIRECTUV: number;
  107141. DETAIL_NORMALBLENDMETHOD: number;
  107142. AMBIENT: boolean;
  107143. AMBIENTDIRECTUV: number;
  107144. AMBIENTINGRAYSCALE: boolean;
  107145. OPACITY: boolean;
  107146. VERTEXALPHA: boolean;
  107147. OPACITYDIRECTUV: number;
  107148. OPACITYRGB: boolean;
  107149. ALPHATEST: boolean;
  107150. DEPTHPREPASS: boolean;
  107151. ALPHABLEND: boolean;
  107152. ALPHAFROMALBEDO: boolean;
  107153. ALPHATESTVALUE: string;
  107154. SPECULAROVERALPHA: boolean;
  107155. RADIANCEOVERALPHA: boolean;
  107156. ALPHAFRESNEL: boolean;
  107157. LINEARALPHAFRESNEL: boolean;
  107158. PREMULTIPLYALPHA: boolean;
  107159. EMISSIVE: boolean;
  107160. EMISSIVEDIRECTUV: number;
  107161. REFLECTIVITY: boolean;
  107162. REFLECTIVITYDIRECTUV: number;
  107163. SPECULARTERM: boolean;
  107164. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107165. MICROSURFACEAUTOMATIC: boolean;
  107166. LODBASEDMICROSFURACE: boolean;
  107167. MICROSURFACEMAP: boolean;
  107168. MICROSURFACEMAPDIRECTUV: number;
  107169. METALLICWORKFLOW: boolean;
  107170. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107171. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107172. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107173. AOSTOREINMETALMAPRED: boolean;
  107174. METALLIC_REFLECTANCE: boolean;
  107175. METALLIC_REFLECTANCEDIRECTUV: number;
  107176. ENVIRONMENTBRDF: boolean;
  107177. ENVIRONMENTBRDF_RGBD: boolean;
  107178. NORMAL: boolean;
  107179. TANGENT: boolean;
  107180. BUMP: boolean;
  107181. BUMPDIRECTUV: number;
  107182. OBJECTSPACE_NORMALMAP: boolean;
  107183. PARALLAX: boolean;
  107184. PARALLAXOCCLUSION: boolean;
  107185. NORMALXYSCALE: boolean;
  107186. LIGHTMAP: boolean;
  107187. LIGHTMAPDIRECTUV: number;
  107188. USELIGHTMAPASSHADOWMAP: boolean;
  107189. GAMMALIGHTMAP: boolean;
  107190. RGBDLIGHTMAP: boolean;
  107191. REFLECTION: boolean;
  107192. REFLECTIONMAP_3D: boolean;
  107193. REFLECTIONMAP_SPHERICAL: boolean;
  107194. REFLECTIONMAP_PLANAR: boolean;
  107195. REFLECTIONMAP_CUBIC: boolean;
  107196. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107197. REFLECTIONMAP_PROJECTION: boolean;
  107198. REFLECTIONMAP_SKYBOX: boolean;
  107199. REFLECTIONMAP_EXPLICIT: boolean;
  107200. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107201. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107202. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107203. INVERTCUBICMAP: boolean;
  107204. USESPHERICALFROMREFLECTIONMAP: boolean;
  107205. USEIRRADIANCEMAP: boolean;
  107206. SPHERICAL_HARMONICS: boolean;
  107207. USESPHERICALINVERTEX: boolean;
  107208. REFLECTIONMAP_OPPOSITEZ: boolean;
  107209. LODINREFLECTIONALPHA: boolean;
  107210. GAMMAREFLECTION: boolean;
  107211. RGBDREFLECTION: boolean;
  107212. LINEARSPECULARREFLECTION: boolean;
  107213. RADIANCEOCCLUSION: boolean;
  107214. HORIZONOCCLUSION: boolean;
  107215. INSTANCES: boolean;
  107216. THIN_INSTANCES: boolean;
  107217. PREPASS: boolean;
  107218. PREPASS_IRRADIANCE: boolean;
  107219. PREPASS_IRRADIANCE_INDEX: number;
  107220. PREPASS_ALBEDO: boolean;
  107221. PREPASS_ALBEDO_INDEX: number;
  107222. PREPASS_DEPTH: boolean;
  107223. PREPASS_DEPTH_INDEX: number;
  107224. PREPASS_NORMAL: boolean;
  107225. PREPASS_NORMAL_INDEX: number;
  107226. PREPASS_POSITION: boolean;
  107227. PREPASS_POSITION_INDEX: number;
  107228. PREPASS_VELOCITY: boolean;
  107229. PREPASS_VELOCITY_INDEX: number;
  107230. PREPASS_REFLECTIVITY: boolean;
  107231. PREPASS_REFLECTIVITY_INDEX: number;
  107232. SCENE_MRT_COUNT: number;
  107233. NUM_BONE_INFLUENCERS: number;
  107234. BonesPerMesh: number;
  107235. BONETEXTURE: boolean;
  107236. BONES_VELOCITY_ENABLED: boolean;
  107237. NONUNIFORMSCALING: boolean;
  107238. MORPHTARGETS: boolean;
  107239. MORPHTARGETS_NORMAL: boolean;
  107240. MORPHTARGETS_TANGENT: boolean;
  107241. MORPHTARGETS_UV: boolean;
  107242. NUM_MORPH_INFLUENCERS: number;
  107243. MORPHTARGETS_TEXTURE: boolean;
  107244. IMAGEPROCESSING: boolean;
  107245. VIGNETTE: boolean;
  107246. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107247. VIGNETTEBLENDMODEOPAQUE: boolean;
  107248. TONEMAPPING: boolean;
  107249. TONEMAPPING_ACES: boolean;
  107250. CONTRAST: boolean;
  107251. COLORCURVES: boolean;
  107252. COLORGRADING: boolean;
  107253. COLORGRADING3D: boolean;
  107254. SAMPLER3DGREENDEPTH: boolean;
  107255. SAMPLER3DBGRMAP: boolean;
  107256. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107257. EXPOSURE: boolean;
  107258. MULTIVIEW: boolean;
  107259. USEPHYSICALLIGHTFALLOFF: boolean;
  107260. USEGLTFLIGHTFALLOFF: boolean;
  107261. TWOSIDEDLIGHTING: boolean;
  107262. SHADOWFLOAT: boolean;
  107263. CLIPPLANE: boolean;
  107264. CLIPPLANE2: boolean;
  107265. CLIPPLANE3: boolean;
  107266. CLIPPLANE4: boolean;
  107267. CLIPPLANE5: boolean;
  107268. CLIPPLANE6: boolean;
  107269. POINTSIZE: boolean;
  107270. FOG: boolean;
  107271. LOGARITHMICDEPTH: boolean;
  107272. FORCENORMALFORWARD: boolean;
  107273. SPECULARAA: boolean;
  107274. CLEARCOAT: boolean;
  107275. CLEARCOAT_DEFAULTIOR: boolean;
  107276. CLEARCOAT_TEXTURE: boolean;
  107277. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  107278. CLEARCOAT_TEXTUREDIRECTUV: number;
  107279. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  107280. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107281. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107282. CLEARCOAT_BUMP: boolean;
  107283. CLEARCOAT_BUMPDIRECTUV: number;
  107284. CLEARCOAT_REMAP_F0: boolean;
  107285. CLEARCOAT_TINT: boolean;
  107286. CLEARCOAT_TINT_TEXTURE: boolean;
  107287. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107288. ANISOTROPIC: boolean;
  107289. ANISOTROPIC_TEXTURE: boolean;
  107290. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107291. BRDF_V_HEIGHT_CORRELATED: boolean;
  107292. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107293. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  107294. SHEEN: boolean;
  107295. SHEEN_TEXTURE: boolean;
  107296. SHEEN_TEXTURE_ROUGHNESS: boolean;
  107297. SHEEN_TEXTUREDIRECTUV: number;
  107298. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  107299. SHEEN_LINKWITHALBEDO: boolean;
  107300. SHEEN_ROUGHNESS: boolean;
  107301. SHEEN_ALBEDOSCALING: boolean;
  107302. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107303. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107304. SUBSURFACE: boolean;
  107305. SS_REFRACTION: boolean;
  107306. SS_TRANSLUCENCY: boolean;
  107307. SS_SCATTERING: boolean;
  107308. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107309. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107310. SS_REFRACTIONMAP_3D: boolean;
  107311. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107312. SS_LODINREFRACTIONALPHA: boolean;
  107313. SS_GAMMAREFRACTION: boolean;
  107314. SS_RGBDREFRACTION: boolean;
  107315. SS_LINEARSPECULARREFRACTION: boolean;
  107316. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107317. SS_ALBEDOFORREFRACTIONTINT: boolean;
  107318. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107319. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  107320. UNLIT: boolean;
  107321. DEBUGMODE: number;
  107322. /**
  107323. * Initializes the PBR Material defines.
  107324. */
  107325. constructor();
  107326. /**
  107327. * Resets the PBR Material defines.
  107328. */
  107329. reset(): void;
  107330. }
  107331. /**
  107332. * The Physically based material base class of BJS.
  107333. *
  107334. * This offers the main features of a standard PBR material.
  107335. * For more information, please refer to the documentation :
  107336. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107337. */
  107338. export abstract class PBRBaseMaterial extends PushMaterial {
  107339. /**
  107340. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107341. */
  107342. static readonly PBRMATERIAL_OPAQUE: number;
  107343. /**
  107344. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107345. */
  107346. static readonly PBRMATERIAL_ALPHATEST: number;
  107347. /**
  107348. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107349. */
  107350. static readonly PBRMATERIAL_ALPHABLEND: number;
  107351. /**
  107352. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107353. * They are also discarded below the alpha cutoff threshold to improve performances.
  107354. */
  107355. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107356. /**
  107357. * Defines the default value of how much AO map is occluding the analytical lights
  107358. * (point spot...).
  107359. */
  107360. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107361. /**
  107362. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107363. */
  107364. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107365. /**
  107366. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107367. * to enhance interoperability with other engines.
  107368. */
  107369. static readonly LIGHTFALLOFF_GLTF: number;
  107370. /**
  107371. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107372. * to enhance interoperability with other materials.
  107373. */
  107374. static readonly LIGHTFALLOFF_STANDARD: number;
  107375. /**
  107376. * Intensity of the direct lights e.g. the four lights available in your scene.
  107377. * This impacts both the direct diffuse and specular highlights.
  107378. */
  107379. protected _directIntensity: number;
  107380. /**
  107381. * Intensity of the emissive part of the material.
  107382. * This helps controlling the emissive effect without modifying the emissive color.
  107383. */
  107384. protected _emissiveIntensity: number;
  107385. /**
  107386. * Intensity of the environment e.g. how much the environment will light the object
  107387. * either through harmonics for rough material or through the reflection for shiny ones.
  107388. */
  107389. protected _environmentIntensity: number;
  107390. /**
  107391. * This is a special control allowing the reduction of the specular highlights coming from the
  107392. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107393. */
  107394. protected _specularIntensity: number;
  107395. /**
  107396. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107397. */
  107398. private _lightingInfos;
  107399. /**
  107400. * Debug Control allowing disabling the bump map on this material.
  107401. */
  107402. protected _disableBumpMap: boolean;
  107403. /**
  107404. * AKA Diffuse Texture in standard nomenclature.
  107405. */
  107406. protected _albedoTexture: Nullable<BaseTexture>;
  107407. /**
  107408. * AKA Occlusion Texture in other nomenclature.
  107409. */
  107410. protected _ambientTexture: Nullable<BaseTexture>;
  107411. /**
  107412. * AKA Occlusion Texture Intensity in other nomenclature.
  107413. */
  107414. protected _ambientTextureStrength: number;
  107415. /**
  107416. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107417. * 1 means it completely occludes it
  107418. * 0 mean it has no impact
  107419. */
  107420. protected _ambientTextureImpactOnAnalyticalLights: number;
  107421. /**
  107422. * Stores the alpha values in a texture.
  107423. */
  107424. protected _opacityTexture: Nullable<BaseTexture>;
  107425. /**
  107426. * Stores the reflection values in a texture.
  107427. */
  107428. protected _reflectionTexture: Nullable<BaseTexture>;
  107429. /**
  107430. * Stores the emissive values in a texture.
  107431. */
  107432. protected _emissiveTexture: Nullable<BaseTexture>;
  107433. /**
  107434. * AKA Specular texture in other nomenclature.
  107435. */
  107436. protected _reflectivityTexture: Nullable<BaseTexture>;
  107437. /**
  107438. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107439. */
  107440. protected _metallicTexture: Nullable<BaseTexture>;
  107441. /**
  107442. * Specifies the metallic scalar of the metallic/roughness workflow.
  107443. * Can also be used to scale the metalness values of the metallic texture.
  107444. */
  107445. protected _metallic: Nullable<number>;
  107446. /**
  107447. * Specifies the roughness scalar of the metallic/roughness workflow.
  107448. * Can also be used to scale the roughness values of the metallic texture.
  107449. */
  107450. protected _roughness: Nullable<number>;
  107451. /**
  107452. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107453. * By default the indexOfrefraction is used to compute F0;
  107454. *
  107455. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107456. *
  107457. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107458. * F90 = metallicReflectanceColor;
  107459. */
  107460. protected _metallicF0Factor: number;
  107461. /**
  107462. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107463. * By default the F90 is always 1;
  107464. *
  107465. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107466. *
  107467. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107468. * F90 = metallicReflectanceColor;
  107469. */
  107470. protected _metallicReflectanceColor: Color3;
  107471. /**
  107472. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107473. * This is multiply against the scalar values defined in the material.
  107474. */
  107475. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107476. /**
  107477. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107478. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107479. */
  107480. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107481. /**
  107482. * Stores surface normal data used to displace a mesh in a texture.
  107483. */
  107484. protected _bumpTexture: Nullable<BaseTexture>;
  107485. /**
  107486. * Stores the pre-calculated light information of a mesh in a texture.
  107487. */
  107488. protected _lightmapTexture: Nullable<BaseTexture>;
  107489. /**
  107490. * The color of a material in ambient lighting.
  107491. */
  107492. protected _ambientColor: Color3;
  107493. /**
  107494. * AKA Diffuse Color in other nomenclature.
  107495. */
  107496. protected _albedoColor: Color3;
  107497. /**
  107498. * AKA Specular Color in other nomenclature.
  107499. */
  107500. protected _reflectivityColor: Color3;
  107501. /**
  107502. * The color applied when light is reflected from a material.
  107503. */
  107504. protected _reflectionColor: Color3;
  107505. /**
  107506. * The color applied when light is emitted from a material.
  107507. */
  107508. protected _emissiveColor: Color3;
  107509. /**
  107510. * AKA Glossiness in other nomenclature.
  107511. */
  107512. protected _microSurface: number;
  107513. /**
  107514. * Specifies that the material will use the light map as a show map.
  107515. */
  107516. protected _useLightmapAsShadowmap: boolean;
  107517. /**
  107518. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107519. * makes the reflect vector face the model (under horizon).
  107520. */
  107521. protected _useHorizonOcclusion: boolean;
  107522. /**
  107523. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107524. * too much the area relying on ambient texture to define their ambient occlusion.
  107525. */
  107526. protected _useRadianceOcclusion: boolean;
  107527. /**
  107528. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107529. */
  107530. protected _useAlphaFromAlbedoTexture: boolean;
  107531. /**
  107532. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  107533. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  107534. */
  107535. protected _useSpecularOverAlpha: boolean;
  107536. /**
  107537. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107538. */
  107539. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107540. /**
  107541. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107542. */
  107543. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107544. /**
  107545. * Specifies if the metallic texture contains the roughness information in its green channel.
  107546. */
  107547. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107548. /**
  107549. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107550. */
  107551. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107552. /**
  107553. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107554. */
  107555. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107556. /**
  107557. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107558. */
  107559. protected _useAmbientInGrayScale: boolean;
  107560. /**
  107561. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107562. * The material will try to infer what glossiness each pixel should be.
  107563. */
  107564. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107565. /**
  107566. * Defines the falloff type used in this material.
  107567. * It by default is Physical.
  107568. */
  107569. protected _lightFalloff: number;
  107570. /**
  107571. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  107572. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  107573. */
  107574. protected _useRadianceOverAlpha: boolean;
  107575. /**
  107576. * Allows using an object space normal map (instead of tangent space).
  107577. */
  107578. protected _useObjectSpaceNormalMap: boolean;
  107579. /**
  107580. * Allows using the bump map in parallax mode.
  107581. */
  107582. protected _useParallax: boolean;
  107583. /**
  107584. * Allows using the bump map in parallax occlusion mode.
  107585. */
  107586. protected _useParallaxOcclusion: boolean;
  107587. /**
  107588. * Controls the scale bias of the parallax mode.
  107589. */
  107590. protected _parallaxScaleBias: number;
  107591. /**
  107592. * If sets to true, disables all the lights affecting the material.
  107593. */
  107594. protected _disableLighting: boolean;
  107595. /**
  107596. * Number of Simultaneous lights allowed on the material.
  107597. */
  107598. protected _maxSimultaneousLights: number;
  107599. /**
  107600. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107601. */
  107602. protected _invertNormalMapX: boolean;
  107603. /**
  107604. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107605. */
  107606. protected _invertNormalMapY: boolean;
  107607. /**
  107608. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107609. */
  107610. protected _twoSidedLighting: boolean;
  107611. /**
  107612. * Defines the alpha limits in alpha test mode.
  107613. */
  107614. protected _alphaCutOff: number;
  107615. /**
  107616. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107617. */
  107618. protected _forceAlphaTest: boolean;
  107619. /**
  107620. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107621. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107622. */
  107623. protected _useAlphaFresnel: boolean;
  107624. /**
  107625. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107626. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107627. */
  107628. protected _useLinearAlphaFresnel: boolean;
  107629. /**
  107630. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  107631. * from cos theta and roughness:
  107632. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107633. */
  107634. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107635. /**
  107636. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107637. */
  107638. protected _forceIrradianceInFragment: boolean;
  107639. private _realTimeFiltering;
  107640. /**
  107641. * Enables realtime filtering on the texture.
  107642. */
  107643. get realTimeFiltering(): boolean;
  107644. set realTimeFiltering(b: boolean);
  107645. private _realTimeFilteringQuality;
  107646. /**
  107647. * Quality switch for realtime filtering
  107648. */
  107649. get realTimeFilteringQuality(): number;
  107650. set realTimeFilteringQuality(n: number);
  107651. /**
  107652. * Can this material render to several textures at once
  107653. */
  107654. get canRenderToMRT(): boolean;
  107655. /**
  107656. * Force normal to face away from face.
  107657. */
  107658. protected _forceNormalForward: boolean;
  107659. /**
  107660. * Enables specular anti aliasing in the PBR shader.
  107661. * It will both interacts on the Geometry for analytical and IBL lighting.
  107662. * It also prefilter the roughness map based on the bump values.
  107663. */
  107664. protected _enableSpecularAntiAliasing: boolean;
  107665. /**
  107666. * Default configuration related to image processing available in the PBR Material.
  107667. */
  107668. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107669. /**
  107670. * Keep track of the image processing observer to allow dispose and replace.
  107671. */
  107672. private _imageProcessingObserver;
  107673. /**
  107674. * Attaches a new image processing configuration to the PBR Material.
  107675. * @param configuration
  107676. */
  107677. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107678. /**
  107679. * Stores the available render targets.
  107680. */
  107681. private _renderTargets;
  107682. /**
  107683. * Sets the global ambient color for the material used in lighting calculations.
  107684. */
  107685. private _globalAmbientColor;
  107686. /**
  107687. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107688. */
  107689. private _useLogarithmicDepth;
  107690. /**
  107691. * If set to true, no lighting calculations will be applied.
  107692. */
  107693. private _unlit;
  107694. private _debugMode;
  107695. /**
  107696. * @hidden
  107697. * This is reserved for the inspector.
  107698. * Defines the material debug mode.
  107699. * It helps seeing only some components of the material while troubleshooting.
  107700. */
  107701. debugMode: number;
  107702. /**
  107703. * @hidden
  107704. * This is reserved for the inspector.
  107705. * Specify from where on screen the debug mode should start.
  107706. * The value goes from -1 (full screen) to 1 (not visible)
  107707. * It helps with side by side comparison against the final render
  107708. * This defaults to -1
  107709. */
  107710. private debugLimit;
  107711. /**
  107712. * @hidden
  107713. * This is reserved for the inspector.
  107714. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107715. * You can use the factor to better multiply the final value.
  107716. */
  107717. private debugFactor;
  107718. /**
  107719. * Defines the clear coat layer parameters for the material.
  107720. */
  107721. readonly clearCoat: PBRClearCoatConfiguration;
  107722. /**
  107723. * Defines the anisotropic parameters for the material.
  107724. */
  107725. readonly anisotropy: PBRAnisotropicConfiguration;
  107726. /**
  107727. * Defines the BRDF parameters for the material.
  107728. */
  107729. readonly brdf: PBRBRDFConfiguration;
  107730. /**
  107731. * Defines the Sheen parameters for the material.
  107732. */
  107733. readonly sheen: PBRSheenConfiguration;
  107734. /**
  107735. * Defines the SubSurface parameters for the material.
  107736. */
  107737. readonly subSurface: PBRSubSurfaceConfiguration;
  107738. /**
  107739. * Defines additional PrePass parameters for the material.
  107740. */
  107741. readonly prePassConfiguration: PrePassConfiguration;
  107742. /**
  107743. * Defines the detail map parameters for the material.
  107744. */
  107745. readonly detailMap: DetailMapConfiguration;
  107746. protected _rebuildInParallel: boolean;
  107747. /**
  107748. * Instantiates a new PBRMaterial instance.
  107749. *
  107750. * @param name The material name
  107751. * @param scene The scene the material will be use in.
  107752. */
  107753. constructor(name: string, scene: Scene);
  107754. /**
  107755. * Gets a boolean indicating that current material needs to register RTT
  107756. */
  107757. get hasRenderTargetTextures(): boolean;
  107758. /**
  107759. * Can this material render to prepass
  107760. */
  107761. get isPrePassCapable(): boolean;
  107762. /**
  107763. * Gets the name of the material class.
  107764. */
  107765. getClassName(): string;
  107766. /**
  107767. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107768. */
  107769. get useLogarithmicDepth(): boolean;
  107770. /**
  107771. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107772. */
  107773. set useLogarithmicDepth(value: boolean);
  107774. /**
  107775. * Returns true if alpha blending should be disabled.
  107776. */
  107777. protected get _disableAlphaBlending(): boolean;
  107778. /**
  107779. * Specifies whether or not this material should be rendered in alpha blend mode.
  107780. */
  107781. needAlphaBlending(): boolean;
  107782. /**
  107783. * Specifies whether or not this material should be rendered in alpha test mode.
  107784. */
  107785. needAlphaTesting(): boolean;
  107786. /**
  107787. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107788. */
  107789. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107790. /**
  107791. * Specifies whether or not there is a usable alpha channel for transparency.
  107792. */
  107793. protected _hasAlphaChannel(): boolean;
  107794. /**
  107795. * Gets the texture used for the alpha test.
  107796. */
  107797. getAlphaTestTexture(): Nullable<BaseTexture>;
  107798. /**
  107799. * Specifies that the submesh is ready to be used.
  107800. * @param mesh - BJS mesh.
  107801. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107802. * @param useInstances - Specifies that instances should be used.
  107803. * @returns - boolean indicating that the submesh is ready or not.
  107804. */
  107805. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107806. /**
  107807. * Specifies if the material uses metallic roughness workflow.
  107808. * @returns boolean specifying if the material uses metallic roughness workflow.
  107809. */
  107810. isMetallicWorkflow(): boolean;
  107811. private _prepareEffect;
  107812. private _prepareDefines;
  107813. /**
  107814. * Force shader compilation
  107815. */
  107816. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107817. /**
  107818. * Initializes the uniform buffer layout for the shader.
  107819. */
  107820. buildUniformLayout(): void;
  107821. /**
  107822. * Unbinds the material from the mesh
  107823. */
  107824. unbind(): void;
  107825. /**
  107826. * Binds the submesh data.
  107827. * @param world - The world matrix.
  107828. * @param mesh - The BJS mesh.
  107829. * @param subMesh - A submesh of the BJS mesh.
  107830. */
  107831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107832. /**
  107833. * Returns the animatable textures.
  107834. * @returns - Array of animatable textures.
  107835. */
  107836. getAnimatables(): IAnimatable[];
  107837. /**
  107838. * Returns the texture used for reflections.
  107839. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107840. */
  107841. private _getReflectionTexture;
  107842. /**
  107843. * Returns an array of the actively used textures.
  107844. * @returns - Array of BaseTextures
  107845. */
  107846. getActiveTextures(): BaseTexture[];
  107847. /**
  107848. * Checks to see if a texture is used in the material.
  107849. * @param texture - Base texture to use.
  107850. * @returns - Boolean specifying if a texture is used in the material.
  107851. */
  107852. hasTexture(texture: BaseTexture): boolean;
  107853. /**
  107854. * Sets the required values to the prepass renderer.
  107855. * @param prePassRenderer defines the prepass renderer to setup
  107856. */
  107857. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107858. /**
  107859. * Disposes the resources of the material.
  107860. * @param forceDisposeEffect - Forces the disposal of effects.
  107861. * @param forceDisposeTextures - Forces the disposal of all textures.
  107862. */
  107863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107864. }
  107865. }
  107866. declare module BABYLON {
  107867. /**
  107868. * The Physically based material of BJS.
  107869. *
  107870. * This offers the main features of a standard PBR material.
  107871. * For more information, please refer to the documentation :
  107872. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107873. */
  107874. export class PBRMaterial extends PBRBaseMaterial {
  107875. /**
  107876. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107877. */
  107878. static readonly PBRMATERIAL_OPAQUE: number;
  107879. /**
  107880. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107881. */
  107882. static readonly PBRMATERIAL_ALPHATEST: number;
  107883. /**
  107884. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107885. */
  107886. static readonly PBRMATERIAL_ALPHABLEND: number;
  107887. /**
  107888. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107889. * They are also discarded below the alpha cutoff threshold to improve performances.
  107890. */
  107891. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107892. /**
  107893. * Defines the default value of how much AO map is occluding the analytical lights
  107894. * (point spot...).
  107895. */
  107896. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107897. /**
  107898. * Intensity of the direct lights e.g. the four lights available in your scene.
  107899. * This impacts both the direct diffuse and specular highlights.
  107900. */
  107901. directIntensity: number;
  107902. /**
  107903. * Intensity of the emissive part of the material.
  107904. * This helps controlling the emissive effect without modifying the emissive color.
  107905. */
  107906. emissiveIntensity: number;
  107907. /**
  107908. * Intensity of the environment e.g. how much the environment will light the object
  107909. * either through harmonics for rough material or through the reflection for shiny ones.
  107910. */
  107911. environmentIntensity: number;
  107912. /**
  107913. * This is a special control allowing the reduction of the specular highlights coming from the
  107914. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107915. */
  107916. specularIntensity: number;
  107917. /**
  107918. * Debug Control allowing disabling the bump map on this material.
  107919. */
  107920. disableBumpMap: boolean;
  107921. /**
  107922. * AKA Diffuse Texture in standard nomenclature.
  107923. */
  107924. albedoTexture: BaseTexture;
  107925. /**
  107926. * AKA Occlusion Texture in other nomenclature.
  107927. */
  107928. ambientTexture: BaseTexture;
  107929. /**
  107930. * AKA Occlusion Texture Intensity in other nomenclature.
  107931. */
  107932. ambientTextureStrength: number;
  107933. /**
  107934. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107935. * 1 means it completely occludes it
  107936. * 0 mean it has no impact
  107937. */
  107938. ambientTextureImpactOnAnalyticalLights: number;
  107939. /**
  107940. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107941. */
  107942. opacityTexture: BaseTexture;
  107943. /**
  107944. * Stores the reflection values in a texture.
  107945. */
  107946. reflectionTexture: Nullable<BaseTexture>;
  107947. /**
  107948. * Stores the emissive values in a texture.
  107949. */
  107950. emissiveTexture: BaseTexture;
  107951. /**
  107952. * AKA Specular texture in other nomenclature.
  107953. */
  107954. reflectivityTexture: BaseTexture;
  107955. /**
  107956. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107957. */
  107958. metallicTexture: BaseTexture;
  107959. /**
  107960. * Specifies the metallic scalar of the metallic/roughness workflow.
  107961. * Can also be used to scale the metalness values of the metallic texture.
  107962. */
  107963. metallic: Nullable<number>;
  107964. /**
  107965. * Specifies the roughness scalar of the metallic/roughness workflow.
  107966. * Can also be used to scale the roughness values of the metallic texture.
  107967. */
  107968. roughness: Nullable<number>;
  107969. /**
  107970. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107971. * By default the indexOfrefraction is used to compute F0;
  107972. *
  107973. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107974. *
  107975. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107976. * F90 = metallicReflectanceColor;
  107977. */
  107978. metallicF0Factor: number;
  107979. /**
  107980. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107981. * By default the F90 is always 1;
  107982. *
  107983. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107984. *
  107985. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107986. * F90 = metallicReflectanceColor;
  107987. */
  107988. metallicReflectanceColor: Color3;
  107989. /**
  107990. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107991. * This is multiply against the scalar values defined in the material.
  107992. */
  107993. metallicReflectanceTexture: Nullable<BaseTexture>;
  107994. /**
  107995. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107996. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107997. */
  107998. microSurfaceTexture: BaseTexture;
  107999. /**
  108000. * Stores surface normal data used to displace a mesh in a texture.
  108001. */
  108002. bumpTexture: BaseTexture;
  108003. /**
  108004. * Stores the pre-calculated light information of a mesh in a texture.
  108005. */
  108006. lightmapTexture: BaseTexture;
  108007. /**
  108008. * Stores the refracted light information in a texture.
  108009. */
  108010. get refractionTexture(): Nullable<BaseTexture>;
  108011. set refractionTexture(value: Nullable<BaseTexture>);
  108012. /**
  108013. * The color of a material in ambient lighting.
  108014. */
  108015. ambientColor: Color3;
  108016. /**
  108017. * AKA Diffuse Color in other nomenclature.
  108018. */
  108019. albedoColor: Color3;
  108020. /**
  108021. * AKA Specular Color in other nomenclature.
  108022. */
  108023. reflectivityColor: Color3;
  108024. /**
  108025. * The color reflected from the material.
  108026. */
  108027. reflectionColor: Color3;
  108028. /**
  108029. * The color emitted from the material.
  108030. */
  108031. emissiveColor: Color3;
  108032. /**
  108033. * AKA Glossiness in other nomenclature.
  108034. */
  108035. microSurface: number;
  108036. /**
  108037. * Index of refraction of the material base layer.
  108038. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108039. *
  108040. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  108041. *
  108042. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  108043. */
  108044. get indexOfRefraction(): number;
  108045. set indexOfRefraction(value: number);
  108046. /**
  108047. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108048. */
  108049. get invertRefractionY(): boolean;
  108050. set invertRefractionY(value: boolean);
  108051. /**
  108052. * This parameters will make the material used its opacity to control how much it is refracting against not.
  108053. * Materials half opaque for instance using refraction could benefit from this control.
  108054. */
  108055. get linkRefractionWithTransparency(): boolean;
  108056. set linkRefractionWithTransparency(value: boolean);
  108057. /**
  108058. * If true, the light map contains occlusion information instead of lighting info.
  108059. */
  108060. useLightmapAsShadowmap: boolean;
  108061. /**
  108062. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108063. */
  108064. useAlphaFromAlbedoTexture: boolean;
  108065. /**
  108066. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108067. */
  108068. forceAlphaTest: boolean;
  108069. /**
  108070. * Defines the alpha limits in alpha test mode.
  108071. */
  108072. alphaCutOff: number;
  108073. /**
  108074. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  108075. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  108076. */
  108077. useSpecularOverAlpha: boolean;
  108078. /**
  108079. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108080. */
  108081. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108082. /**
  108083. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108084. */
  108085. useRoughnessFromMetallicTextureAlpha: boolean;
  108086. /**
  108087. * Specifies if the metallic texture contains the roughness information in its green channel.
  108088. */
  108089. useRoughnessFromMetallicTextureGreen: boolean;
  108090. /**
  108091. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108092. */
  108093. useMetallnessFromMetallicTextureBlue: boolean;
  108094. /**
  108095. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108096. */
  108097. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108098. /**
  108099. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108100. */
  108101. useAmbientInGrayScale: boolean;
  108102. /**
  108103. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108104. * The material will try to infer what glossiness each pixel should be.
  108105. */
  108106. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108107. /**
  108108. * BJS is using an hardcoded light falloff based on a manually sets up range.
  108109. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  108110. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108111. */
  108112. get usePhysicalLightFalloff(): boolean;
  108113. /**
  108114. * BJS is using an hardcoded light falloff based on a manually sets up range.
  108115. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  108116. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108117. */
  108118. set usePhysicalLightFalloff(value: boolean);
  108119. /**
  108120. * In order to support the falloff compatibility with gltf, a special mode has been added
  108121. * to reproduce the gltf light falloff.
  108122. */
  108123. get useGLTFLightFalloff(): boolean;
  108124. /**
  108125. * In order to support the falloff compatibility with gltf, a special mode has been added
  108126. * to reproduce the gltf light falloff.
  108127. */
  108128. set useGLTFLightFalloff(value: boolean);
  108129. /**
  108130. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  108131. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  108132. */
  108133. useRadianceOverAlpha: boolean;
  108134. /**
  108135. * Allows using an object space normal map (instead of tangent space).
  108136. */
  108137. useObjectSpaceNormalMap: boolean;
  108138. /**
  108139. * Allows using the bump map in parallax mode.
  108140. */
  108141. useParallax: boolean;
  108142. /**
  108143. * Allows using the bump map in parallax occlusion mode.
  108144. */
  108145. useParallaxOcclusion: boolean;
  108146. /**
  108147. * Controls the scale bias of the parallax mode.
  108148. */
  108149. parallaxScaleBias: number;
  108150. /**
  108151. * If sets to true, disables all the lights affecting the material.
  108152. */
  108153. disableLighting: boolean;
  108154. /**
  108155. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108156. */
  108157. forceIrradianceInFragment: boolean;
  108158. /**
  108159. * Number of Simultaneous lights allowed on the material.
  108160. */
  108161. maxSimultaneousLights: number;
  108162. /**
  108163. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108164. */
  108165. invertNormalMapX: boolean;
  108166. /**
  108167. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108168. */
  108169. invertNormalMapY: boolean;
  108170. /**
  108171. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108172. */
  108173. twoSidedLighting: boolean;
  108174. /**
  108175. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108176. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108177. */
  108178. useAlphaFresnel: boolean;
  108179. /**
  108180. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108181. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108182. */
  108183. useLinearAlphaFresnel: boolean;
  108184. /**
  108185. * Let user defines the brdf lookup texture used for IBL.
  108186. * A default 8bit version is embedded but you could point at :
  108187. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  108188. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108189. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  108190. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108191. */
  108192. environmentBRDFTexture: Nullable<BaseTexture>;
  108193. /**
  108194. * Force normal to face away from face.
  108195. */
  108196. forceNormalForward: boolean;
  108197. /**
  108198. * Enables specular anti aliasing in the PBR shader.
  108199. * It will both interacts on the Geometry for analytical and IBL lighting.
  108200. * It also prefilter the roughness map based on the bump values.
  108201. */
  108202. enableSpecularAntiAliasing: boolean;
  108203. /**
  108204. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108205. * makes the reflect vector face the model (under horizon).
  108206. */
  108207. useHorizonOcclusion: boolean;
  108208. /**
  108209. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108210. * too much the area relying on ambient texture to define their ambient occlusion.
  108211. */
  108212. useRadianceOcclusion: boolean;
  108213. /**
  108214. * If set to true, no lighting calculations will be applied.
  108215. */
  108216. unlit: boolean;
  108217. /**
  108218. * Gets the image processing configuration used either in this material.
  108219. */
  108220. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108221. /**
  108222. * Sets the Default image processing configuration used either in the this material.
  108223. *
  108224. * If sets to null, the scene one is in use.
  108225. */
  108226. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108227. /**
  108228. * Gets whether the color curves effect is enabled.
  108229. */
  108230. get cameraColorCurvesEnabled(): boolean;
  108231. /**
  108232. * Sets whether the color curves effect is enabled.
  108233. */
  108234. set cameraColorCurvesEnabled(value: boolean);
  108235. /**
  108236. * Gets whether the color grading effect is enabled.
  108237. */
  108238. get cameraColorGradingEnabled(): boolean;
  108239. /**
  108240. * Gets whether the color grading effect is enabled.
  108241. */
  108242. set cameraColorGradingEnabled(value: boolean);
  108243. /**
  108244. * Gets whether tonemapping is enabled or not.
  108245. */
  108246. get cameraToneMappingEnabled(): boolean;
  108247. /**
  108248. * Sets whether tonemapping is enabled or not
  108249. */
  108250. set cameraToneMappingEnabled(value: boolean);
  108251. /**
  108252. * The camera exposure used on this material.
  108253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108254. * This corresponds to a photographic exposure.
  108255. */
  108256. get cameraExposure(): number;
  108257. /**
  108258. * The camera exposure used on this material.
  108259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108260. * This corresponds to a photographic exposure.
  108261. */
  108262. set cameraExposure(value: number);
  108263. /**
  108264. * Gets The camera contrast used on this material.
  108265. */
  108266. get cameraContrast(): number;
  108267. /**
  108268. * Sets The camera contrast used on this material.
  108269. */
  108270. set cameraContrast(value: number);
  108271. /**
  108272. * Gets the Color Grading 2D Lookup Texture.
  108273. */
  108274. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108275. /**
  108276. * Sets the Color Grading 2D Lookup Texture.
  108277. */
  108278. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108279. /**
  108280. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  108281. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108282. * 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;
  108283. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108284. */
  108285. get cameraColorCurves(): Nullable<ColorCurves>;
  108286. /**
  108287. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  108288. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108289. * 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;
  108290. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108291. */
  108292. set cameraColorCurves(value: Nullable<ColorCurves>);
  108293. /**
  108294. * Instantiates a new PBRMaterial instance.
  108295. *
  108296. * @param name The material name
  108297. * @param scene The scene the material will be use in.
  108298. */
  108299. constructor(name: string, scene: Scene);
  108300. /**
  108301. * Returns the name of this material class.
  108302. */
  108303. getClassName(): string;
  108304. /**
  108305. * Makes a duplicate of the current material.
  108306. * @param name - name to use for the new material.
  108307. */
  108308. clone(name: string): PBRMaterial;
  108309. /**
  108310. * Serializes this PBR Material.
  108311. * @returns - An object with the serialized material.
  108312. */
  108313. serialize(): any;
  108314. /**
  108315. * Parses a PBR Material from a serialized object.
  108316. * @param source - Serialized object.
  108317. * @param scene - BJS scene instance.
  108318. * @param rootUrl - url for the scene object
  108319. * @returns - PBRMaterial
  108320. */
  108321. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108322. }
  108323. }
  108324. declare module BABYLON {
  108325. /** @hidden */
  108326. export var mrtFragmentDeclaration: {
  108327. name: string;
  108328. shader: string;
  108329. };
  108330. }
  108331. declare module BABYLON {
  108332. /** @hidden */
  108333. export var geometryPixelShader: {
  108334. name: string;
  108335. shader: string;
  108336. };
  108337. }
  108338. declare module BABYLON {
  108339. /** @hidden */
  108340. export var instancesDeclaration: {
  108341. name: string;
  108342. shader: string;
  108343. };
  108344. }
  108345. declare module BABYLON {
  108346. /** @hidden */
  108347. export var geometryVertexDeclaration: {
  108348. name: string;
  108349. shader: string;
  108350. };
  108351. }
  108352. declare module BABYLON {
  108353. /** @hidden */
  108354. export var geometryUboDeclaration: {
  108355. name: string;
  108356. shader: string;
  108357. };
  108358. }
  108359. declare module BABYLON {
  108360. /** @hidden */
  108361. export var geometryVertexShader: {
  108362. name: string;
  108363. shader: string;
  108364. };
  108365. }
  108366. declare module BABYLON {
  108367. /** @hidden */
  108368. interface ISavedTransformationMatrix {
  108369. world: Matrix;
  108370. viewProjection: Matrix;
  108371. }
  108372. /**
  108373. * This renderer is helpful to fill one of the render target with a geometry buffer.
  108374. */
  108375. export class GeometryBufferRenderer {
  108376. /**
  108377. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  108378. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  108379. */
  108380. static readonly DEPTH_TEXTURE_TYPE: number;
  108381. /**
  108382. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  108383. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  108384. */
  108385. static readonly NORMAL_TEXTURE_TYPE: number;
  108386. /**
  108387. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108388. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108389. */
  108390. static readonly POSITION_TEXTURE_TYPE: number;
  108391. /**
  108392. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108393. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108394. */
  108395. static readonly VELOCITY_TEXTURE_TYPE: number;
  108396. /**
  108397. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  108398. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  108399. */
  108400. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  108401. /**
  108402. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108403. * in order to compute objects velocities when enableVelocity is set to "true"
  108404. * @hidden
  108405. */
  108406. _previousTransformationMatrices: {
  108407. [index: number]: ISavedTransformationMatrix;
  108408. };
  108409. /**
  108410. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  108411. * in order to compute objects velocities when enableVelocity is set to "true"
  108412. * @hidden
  108413. */
  108414. _previousBonesTransformationMatrices: {
  108415. [index: number]: Float32Array;
  108416. };
  108417. /**
  108418. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  108419. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  108420. */
  108421. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  108422. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  108423. renderTransparentMeshes: boolean;
  108424. private _scene;
  108425. private _resizeObserver;
  108426. private _multiRenderTarget;
  108427. private _ratio;
  108428. private _enablePosition;
  108429. private _enableVelocity;
  108430. private _enableReflectivity;
  108431. private _positionIndex;
  108432. private _velocityIndex;
  108433. private _reflectivityIndex;
  108434. private _depthIndex;
  108435. private _normalIndex;
  108436. private _linkedWithPrePass;
  108437. private _prePassRenderer;
  108438. private _attachments;
  108439. private _useUbo;
  108440. protected _effect: Effect;
  108441. protected _cachedDefines: string;
  108442. /**
  108443. * @hidden
  108444. * Sets up internal structures to share outputs with PrePassRenderer
  108445. * This method should only be called by the PrePassRenderer itself
  108446. */
  108447. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108448. /**
  108449. * @hidden
  108450. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108451. * This method should only be called by the PrePassRenderer itself
  108452. */
  108453. _unlinkPrePassRenderer(): void;
  108454. /**
  108455. * @hidden
  108456. * Resets the geometry buffer layout
  108457. */
  108458. _resetLayout(): void;
  108459. /**
  108460. * @hidden
  108461. * Replaces a texture in the geometry buffer renderer
  108462. * Useful when linking textures of the prepass renderer
  108463. */
  108464. _forceTextureType(geometryBufferType: number, index: number): void;
  108465. /**
  108466. * @hidden
  108467. * Sets texture attachments
  108468. * Useful when linking textures of the prepass renderer
  108469. */
  108470. _setAttachments(attachments: number[]): void;
  108471. /**
  108472. * @hidden
  108473. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108474. * Useful when linking textures of the prepass renderer
  108475. */
  108476. _linkInternalTexture(internalTexture: InternalTexture): void;
  108477. /**
  108478. * Gets the render list (meshes to be rendered) used in the G buffer.
  108479. */
  108480. get renderList(): Nullable<AbstractMesh[]>;
  108481. /**
  108482. * Set the render list (meshes to be rendered) used in the G buffer.
  108483. */
  108484. set renderList(meshes: Nullable<AbstractMesh[]>);
  108485. /**
  108486. * Gets whether or not G buffer are supported by the running hardware.
  108487. * This requires draw buffer supports
  108488. */
  108489. get isSupported(): boolean;
  108490. /**
  108491. * Returns the index of the given texture type in the G-Buffer textures array
  108492. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108493. * @returns the index of the given texture type in the G-Buffer textures array
  108494. */
  108495. getTextureIndex(textureType: number): number;
  108496. /**
  108497. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108498. */
  108499. get enablePosition(): boolean;
  108500. /**
  108501. * Sets whether or not objects positions are enabled for the G buffer.
  108502. */
  108503. set enablePosition(enable: boolean);
  108504. /**
  108505. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108506. */
  108507. get enableVelocity(): boolean;
  108508. /**
  108509. * Sets whether or not objects velocities are enabled for the G buffer.
  108510. */
  108511. set enableVelocity(enable: boolean);
  108512. /**
  108513. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108514. */
  108515. get enableReflectivity(): boolean;
  108516. /**
  108517. * Sets whether or not objects roughness are enabled for the G buffer.
  108518. */
  108519. set enableReflectivity(enable: boolean);
  108520. /**
  108521. * Gets the scene associated with the buffer.
  108522. */
  108523. get scene(): Scene;
  108524. /**
  108525. * Gets the ratio used by the buffer during its creation.
  108526. * How big is the buffer related to the main canvas.
  108527. */
  108528. get ratio(): number;
  108529. /** @hidden */
  108530. static _SceneComponentInitialization: (scene: Scene) => void;
  108531. /**
  108532. * Creates a new G Buffer for the scene
  108533. * @param scene The scene the buffer belongs to
  108534. * @param ratio How big is the buffer related to the main canvas.
  108535. */
  108536. constructor(scene: Scene, ratio?: number);
  108537. /**
  108538. * Checks whether everything is ready to render a submesh to the G buffer.
  108539. * @param subMesh the submesh to check readiness for
  108540. * @param useInstances is the mesh drawn using instance or not
  108541. * @returns true if ready otherwise false
  108542. */
  108543. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108544. /**
  108545. * Gets the current underlying G Buffer.
  108546. * @returns the buffer
  108547. */
  108548. getGBuffer(): MultiRenderTarget;
  108549. /**
  108550. * Gets the number of samples used to render the buffer (anti aliasing).
  108551. */
  108552. get samples(): number;
  108553. /**
  108554. * Sets the number of samples used to render the buffer (anti aliasing).
  108555. */
  108556. set samples(value: number);
  108557. /**
  108558. * Disposes the renderer and frees up associated resources.
  108559. */
  108560. dispose(): void;
  108561. private _assignRenderTargetIndices;
  108562. protected _createRenderTargets(): void;
  108563. private _copyBonesTransformationMatrices;
  108564. }
  108565. }
  108566. declare module BABYLON {
  108567. /**
  108568. * Renders a pre pass of the scene
  108569. * This means every mesh in the scene will be rendered to a render target texture
  108570. * And then this texture will be composited to the rendering canvas with post processes
  108571. * It is necessary for effects like subsurface scattering or deferred shading
  108572. */
  108573. export class PrePassRenderer {
  108574. /** @hidden */
  108575. static _SceneComponentInitialization: (scene: Scene) => void;
  108576. /**
  108577. * To save performance, we can excluded skinned meshes from the prepass
  108578. */
  108579. excludedSkinnedMesh: AbstractMesh[];
  108580. /**
  108581. * Force material to be excluded from the prepass
  108582. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108583. * and you don't want a material to show in the effect.
  108584. */
  108585. excludedMaterials: Material[];
  108586. private _scene;
  108587. private _engine;
  108588. /**
  108589. * Number of textures in the multi render target texture where the scene is directly rendered
  108590. */
  108591. mrtCount: number;
  108592. private _mrtFormats;
  108593. private _mrtLayout;
  108594. private _textureIndices;
  108595. private _multiRenderAttachments;
  108596. private _defaultAttachments;
  108597. private _clearAttachments;
  108598. /**
  108599. * Returns the index of a texture in the multi render target texture array.
  108600. * @param type Texture type
  108601. * @return The index
  108602. */
  108603. getIndex(type: number): number;
  108604. /**
  108605. * How many samples are used for MSAA of the scene render target
  108606. */
  108607. get samples(): number;
  108608. set samples(n: number);
  108609. private static _textureFormats;
  108610. private _isDirty;
  108611. /**
  108612. * The render target where the scene is directly rendered
  108613. */
  108614. defaultRT: PrePassRenderTarget;
  108615. /**
  108616. * Configuration for prepass effects
  108617. */
  108618. private _effectConfigurations;
  108619. /**
  108620. * @return the prepass render target for the rendering pass.
  108621. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  108622. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  108623. */
  108624. getRenderTarget(): PrePassRenderTarget;
  108625. /**
  108626. * @hidden
  108627. * Managed by the scene component
  108628. * @param prePassRenderTarget
  108629. */
  108630. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  108631. /**
  108632. * Returns true if the currently rendered prePassRenderTarget is the one
  108633. * associated with the scene.
  108634. */
  108635. get currentRTisSceneRT(): boolean;
  108636. private _geometryBuffer;
  108637. /**
  108638. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  108639. */
  108640. doNotUseGeometryRendererFallback: boolean;
  108641. private _refreshGeometryBufferRendererLink;
  108642. private _currentTarget;
  108643. /**
  108644. * All the render targets generated by prepass
  108645. */
  108646. renderTargets: PrePassRenderTarget[];
  108647. private readonly _clearColor;
  108648. private _enabled;
  108649. private _needsCompositionForThisPass;
  108650. private _postProcessesSourceForThisPass;
  108651. /**
  108652. * Indicates if the prepass is enabled
  108653. */
  108654. get enabled(): boolean;
  108655. /**
  108656. * Set to true to disable gamma transform in PrePass.
  108657. * Can be useful in case you already proceed to gamma transform on a material level
  108658. * and your post processes don't need to be in linear color space.
  108659. */
  108660. disableGammaTransform: boolean;
  108661. /**
  108662. * Instanciates a prepass renderer
  108663. * @param scene The scene
  108664. */
  108665. constructor(scene: Scene);
  108666. /**
  108667. * Creates a new PrePassRenderTarget
  108668. * This should be the only way to instanciate a `PrePassRenderTarget`
  108669. * @param name Name of the `PrePassRenderTarget`
  108670. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  108671. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  108672. * @hidden
  108673. */
  108674. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  108675. /**
  108676. * Indicates if rendering a prepass is supported
  108677. */
  108678. get isSupported(): boolean;
  108679. /**
  108680. * Sets the proper output textures to draw in the engine.
  108681. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108682. * @param subMesh Submesh on which the effect is applied
  108683. */
  108684. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108685. private _reinitializeAttachments;
  108686. private _resetLayout;
  108687. private _updateGeometryBufferLayout;
  108688. /**
  108689. * Restores attachments for single texture draw.
  108690. */
  108691. restoreAttachments(): void;
  108692. /**
  108693. * @hidden
  108694. */
  108695. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  108696. private _prepareFrame;
  108697. private _renderPostProcesses;
  108698. /**
  108699. * @hidden
  108700. */
  108701. _afterDraw(faceIndex?: number, layer?: number): void;
  108702. /**
  108703. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  108704. * @hidden
  108705. */
  108706. _clear(): void;
  108707. private _bindFrameBuffer;
  108708. private _setEnabled;
  108709. private _setRenderTargetEnabled;
  108710. /**
  108711. * Adds an effect configuration to the prepass render target.
  108712. * If an effect has already been added, it won't add it twice and will return the configuration
  108713. * already present.
  108714. * @param cfg the effect configuration
  108715. * @return the effect configuration now used by the prepass
  108716. */
  108717. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108718. private _enable;
  108719. private _disable;
  108720. private _getPostProcessesSource;
  108721. private _setupOutputForThisPass;
  108722. private _linkInternalTexture;
  108723. private _needsImageProcessing;
  108724. private _hasImageProcessing;
  108725. /**
  108726. * Internal, gets the first post proces.
  108727. * @returns the first post process to be run on this camera.
  108728. */
  108729. private _getFirstPostProcess;
  108730. /**
  108731. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108732. */
  108733. markAsDirty(): void;
  108734. /**
  108735. * Enables a texture on the MultiRenderTarget for prepass
  108736. */
  108737. private _enableTextures;
  108738. private _update;
  108739. private _markAllMaterialsAsPrePassDirty;
  108740. /**
  108741. * Disposes the prepass renderer.
  108742. */
  108743. dispose(): void;
  108744. }
  108745. }
  108746. declare module BABYLON {
  108747. /**
  108748. * Size options for a post process
  108749. */
  108750. export type PostProcessOptions = {
  108751. width: number;
  108752. height: number;
  108753. };
  108754. /**
  108755. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108756. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108757. */
  108758. export class PostProcess {
  108759. /**
  108760. * Gets or sets the unique id of the post process
  108761. */
  108762. uniqueId: number;
  108763. /** Name of the PostProcess. */
  108764. name: string;
  108765. /**
  108766. * Width of the texture to apply the post process on
  108767. */
  108768. width: number;
  108769. /**
  108770. * Height of the texture to apply the post process on
  108771. */
  108772. height: number;
  108773. /**
  108774. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108775. */
  108776. nodeMaterialSource: Nullable<NodeMaterial>;
  108777. /**
  108778. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108779. * @hidden
  108780. */
  108781. _outputTexture: Nullable<InternalTexture>;
  108782. /**
  108783. * Sampling mode used by the shader
  108784. * See https://doc.babylonjs.com/classes/3.1/texture
  108785. */
  108786. renderTargetSamplingMode: number;
  108787. /**
  108788. * Clear color to use when screen clearing
  108789. */
  108790. clearColor: Color4;
  108791. /**
  108792. * If the buffer needs to be cleared before applying the post process. (default: true)
  108793. * Should be set to false if shader will overwrite all previous pixels.
  108794. */
  108795. autoClear: boolean;
  108796. /**
  108797. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108798. */
  108799. alphaMode: number;
  108800. /**
  108801. * Sets the setAlphaBlendConstants of the babylon engine
  108802. */
  108803. alphaConstants: Color4;
  108804. /**
  108805. * Animations to be used for the post processing
  108806. */
  108807. animations: Animation[];
  108808. /**
  108809. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108810. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108811. */
  108812. enablePixelPerfectMode: boolean;
  108813. /**
  108814. * Force the postprocess to be applied without taking in account viewport
  108815. */
  108816. forceFullscreenViewport: boolean;
  108817. /**
  108818. * List of inspectable custom properties (used by the Inspector)
  108819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108820. */
  108821. inspectableCustomProperties: IInspectable[];
  108822. /**
  108823. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108824. *
  108825. * | Value | Type | Description |
  108826. * | ----- | ----------------------------------- | ----------- |
  108827. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108828. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108829. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108830. *
  108831. */
  108832. scaleMode: number;
  108833. /**
  108834. * Force textures to be a power of two (default: false)
  108835. */
  108836. alwaysForcePOT: boolean;
  108837. private _samples;
  108838. /**
  108839. * Number of sample textures (default: 1)
  108840. */
  108841. get samples(): number;
  108842. set samples(n: number);
  108843. /**
  108844. * Modify the scale of the post process to be the same as the viewport (default: false)
  108845. */
  108846. adaptScaleToCurrentViewport: boolean;
  108847. private _camera;
  108848. protected _scene: Scene;
  108849. private _engine;
  108850. private _options;
  108851. private _reusable;
  108852. private _renderId;
  108853. private _textureType;
  108854. private _textureFormat;
  108855. /**
  108856. * Smart array of input and output textures for the post process.
  108857. * @hidden
  108858. */
  108859. _textures: SmartArray<InternalTexture>;
  108860. /**
  108861. * Smart array of input and output textures for the post process.
  108862. * @hidden
  108863. */
  108864. private _textureCache;
  108865. /**
  108866. * The index in _textures that corresponds to the output texture.
  108867. * @hidden
  108868. */
  108869. _currentRenderTextureInd: number;
  108870. private _effect;
  108871. private _samplers;
  108872. private _fragmentUrl;
  108873. private _vertexUrl;
  108874. private _parameters;
  108875. protected _postProcessDefines: Nullable<string>;
  108876. private _scaleRatio;
  108877. protected _indexParameters: any;
  108878. private _shareOutputWithPostProcess;
  108879. private _texelSize;
  108880. /** @hidden */
  108881. _forcedOutputTexture: Nullable<InternalTexture>;
  108882. /**
  108883. * Prepass configuration in case this post process needs a texture from prepass
  108884. * @hidden
  108885. */
  108886. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108887. /**
  108888. * Returns the fragment url or shader name used in the post process.
  108889. * @returns the fragment url or name in the shader store.
  108890. */
  108891. getEffectName(): string;
  108892. /**
  108893. * An event triggered when the postprocess is activated.
  108894. */
  108895. onActivateObservable: Observable<Camera>;
  108896. private _onActivateObserver;
  108897. /**
  108898. * A function that is added to the onActivateObservable
  108899. */
  108900. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108901. /**
  108902. * An event triggered when the postprocess changes its size.
  108903. */
  108904. onSizeChangedObservable: Observable<PostProcess>;
  108905. private _onSizeChangedObserver;
  108906. /**
  108907. * A function that is added to the onSizeChangedObservable
  108908. */
  108909. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108910. /**
  108911. * An event triggered when the postprocess applies its effect.
  108912. */
  108913. onApplyObservable: Observable<Effect>;
  108914. private _onApplyObserver;
  108915. /**
  108916. * A function that is added to the onApplyObservable
  108917. */
  108918. set onApply(callback: (effect: Effect) => void);
  108919. /**
  108920. * An event triggered before rendering the postprocess
  108921. */
  108922. onBeforeRenderObservable: Observable<Effect>;
  108923. private _onBeforeRenderObserver;
  108924. /**
  108925. * A function that is added to the onBeforeRenderObservable
  108926. */
  108927. set onBeforeRender(callback: (effect: Effect) => void);
  108928. /**
  108929. * An event triggered after rendering the postprocess
  108930. */
  108931. onAfterRenderObservable: Observable<Effect>;
  108932. private _onAfterRenderObserver;
  108933. /**
  108934. * A function that is added to the onAfterRenderObservable
  108935. */
  108936. set onAfterRender(callback: (efect: Effect) => void);
  108937. /**
  108938. * 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
  108939. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108940. */
  108941. get inputTexture(): InternalTexture;
  108942. set inputTexture(value: InternalTexture);
  108943. /**
  108944. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108945. * the only way to unset it is to use this function to restore its internal state
  108946. */
  108947. restoreDefaultInputTexture(): void;
  108948. /**
  108949. * Gets the camera which post process is applied to.
  108950. * @returns The camera the post process is applied to.
  108951. */
  108952. getCamera(): Camera;
  108953. /**
  108954. * Gets the texel size of the postprocess.
  108955. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108956. */
  108957. get texelSize(): Vector2;
  108958. /**
  108959. * Creates a new instance PostProcess
  108960. * @param name The name of the PostProcess.
  108961. * @param fragmentUrl The url of the fragment shader to be used.
  108962. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108963. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108964. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108965. * @param camera The camera to apply the render pass to.
  108966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108967. * @param engine The engine which the post process will be applied. (default: current engine)
  108968. * @param reusable If the post process can be reused on the same frame. (default: false)
  108969. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108970. * @param textureType Type of textures used when performing the post process. (default: 0)
  108971. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108972. * @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
  108973. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108974. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108975. */
  108976. 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);
  108977. /**
  108978. * Gets a string identifying the name of the class
  108979. * @returns "PostProcess" string
  108980. */
  108981. getClassName(): string;
  108982. /**
  108983. * Gets the engine which this post process belongs to.
  108984. * @returns The engine the post process was enabled with.
  108985. */
  108986. getEngine(): Engine;
  108987. /**
  108988. * The effect that is created when initializing the post process.
  108989. * @returns The created effect corresponding the the postprocess.
  108990. */
  108991. getEffect(): Effect;
  108992. /**
  108993. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108994. * @param postProcess The post process to share the output with.
  108995. * @returns This post process.
  108996. */
  108997. shareOutputWith(postProcess: PostProcess): PostProcess;
  108998. /**
  108999. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  109000. * This should be called if the post process that shares output with this post process is disabled/disposed.
  109001. */
  109002. useOwnOutput(): void;
  109003. /**
  109004. * Updates the effect with the current post process compile time values and recompiles the shader.
  109005. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109006. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109007. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109008. * @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
  109009. * @param onCompiled Called when the shader has been compiled.
  109010. * @param onError Called if there is an error when compiling a shader.
  109011. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  109012. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  109013. */
  109014. 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;
  109015. /**
  109016. * The post process is reusable if it can be used multiple times within one frame.
  109017. * @returns If the post process is reusable
  109018. */
  109019. isReusable(): boolean;
  109020. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  109021. markTextureDirty(): void;
  109022. private _createRenderTargetTexture;
  109023. private _flushTextureCache;
  109024. private _resize;
  109025. /**
  109026. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  109027. * 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.
  109028. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  109029. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  109030. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  109031. * @returns The target texture that was bound to be written to.
  109032. */
  109033. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  109034. /**
  109035. * If the post process is supported.
  109036. */
  109037. get isSupported(): boolean;
  109038. /**
  109039. * The aspect ratio of the output texture.
  109040. */
  109041. get aspectRatio(): number;
  109042. /**
  109043. * Get a value indicating if the post-process is ready to be used
  109044. * @returns true if the post-process is ready (shader is compiled)
  109045. */
  109046. isReady(): boolean;
  109047. /**
  109048. * Binds all textures and uniforms to the shader, this will be run on every pass.
  109049. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  109050. */
  109051. apply(): Nullable<Effect>;
  109052. private _disposeTextures;
  109053. private _disposeTextureCache;
  109054. /**
  109055. * Sets the required values to the prepass renderer.
  109056. * @param prePassRenderer defines the prepass renderer to setup.
  109057. * @returns true if the pre pass is needed.
  109058. */
  109059. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  109060. /**
  109061. * Disposes the post process.
  109062. * @param camera The camera to dispose the post process on.
  109063. */
  109064. dispose(camera?: Camera): void;
  109065. /**
  109066. * Serializes the particle system to a JSON object
  109067. * @returns the JSON object
  109068. */
  109069. serialize(): any;
  109070. /**
  109071. * Clones this post process
  109072. * @returns a new post process similar to this one
  109073. */
  109074. clone(): Nullable<PostProcess>;
  109075. /**
  109076. * Creates a material from parsed material data
  109077. * @param parsedPostProcess defines parsed post process data
  109078. * @param scene defines the hosting scene
  109079. * @param rootUrl defines the root URL to use to load textures
  109080. * @returns a new post process
  109081. */
  109082. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  109083. /** @hidden */
  109084. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  109085. }
  109086. }
  109087. declare module BABYLON {
  109088. /** @hidden */
  109089. export var kernelBlurVaryingDeclaration: {
  109090. name: string;
  109091. shader: string;
  109092. };
  109093. }
  109094. declare module BABYLON {
  109095. /** @hidden */
  109096. export var packingFunctions: {
  109097. name: string;
  109098. shader: string;
  109099. };
  109100. }
  109101. declare module BABYLON {
  109102. /** @hidden */
  109103. export var kernelBlurFragment: {
  109104. name: string;
  109105. shader: string;
  109106. };
  109107. }
  109108. declare module BABYLON {
  109109. /** @hidden */
  109110. export var kernelBlurFragment2: {
  109111. name: string;
  109112. shader: string;
  109113. };
  109114. }
  109115. declare module BABYLON {
  109116. /** @hidden */
  109117. export var kernelBlurPixelShader: {
  109118. name: string;
  109119. shader: string;
  109120. };
  109121. }
  109122. declare module BABYLON {
  109123. /** @hidden */
  109124. export var kernelBlurVertex: {
  109125. name: string;
  109126. shader: string;
  109127. };
  109128. }
  109129. declare module BABYLON {
  109130. /** @hidden */
  109131. export var kernelBlurVertexShader: {
  109132. name: string;
  109133. shader: string;
  109134. };
  109135. }
  109136. declare module BABYLON {
  109137. /**
  109138. * The Blur Post Process which blurs an image based on a kernel and direction.
  109139. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  109140. */
  109141. export class BlurPostProcess extends PostProcess {
  109142. private blockCompilation;
  109143. protected _kernel: number;
  109144. protected _idealKernel: number;
  109145. protected _packedFloat: boolean;
  109146. private _staticDefines;
  109147. /** The direction in which to blur the image. */
  109148. direction: Vector2;
  109149. /**
  109150. * Sets the length in pixels of the blur sample region
  109151. */
  109152. set kernel(v: number);
  109153. /**
  109154. * Gets the length in pixels of the blur sample region
  109155. */
  109156. get kernel(): number;
  109157. /**
  109158. * Sets whether or not the blur needs to unpack/repack floats
  109159. */
  109160. set packedFloat(v: boolean);
  109161. /**
  109162. * Gets whether or not the blur is unpacking/repacking floats
  109163. */
  109164. get packedFloat(): boolean;
  109165. /**
  109166. * Gets a string identifying the name of the class
  109167. * @returns "BlurPostProcess" string
  109168. */
  109169. getClassName(): string;
  109170. /**
  109171. * Creates a new instance BlurPostProcess
  109172. * @param name The name of the effect.
  109173. * @param direction The direction in which to blur the image.
  109174. * @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.
  109175. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109176. * @param camera The camera to apply the render pass to.
  109177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109178. * @param engine The engine which the post process will be applied. (default: current engine)
  109179. * @param reusable If the post process can be reused on the same frame. (default: false)
  109180. * @param textureType Type of textures used when performing the post process. (default: 0)
  109181. * @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)
  109182. */
  109183. 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);
  109184. /**
  109185. * Updates the effect with the current post process compile time values and recompiles the shader.
  109186. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109187. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109188. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109189. * @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
  109190. * @param onCompiled Called when the shader has been compiled.
  109191. * @param onError Called if there is an error when compiling a shader.
  109192. */
  109193. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109194. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109195. /**
  109196. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  109197. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  109198. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  109199. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  109200. * The gaps between physical kernels are compensated for in the weighting of the samples
  109201. * @param idealKernel Ideal blur kernel.
  109202. * @return Nearest best kernel.
  109203. */
  109204. protected _nearestBestKernel(idealKernel: number): number;
  109205. /**
  109206. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  109207. * @param x The point on the Gaussian distribution to sample.
  109208. * @return the value of the Gaussian function at x.
  109209. */
  109210. protected _gaussianWeight(x: number): number;
  109211. /**
  109212. * Generates a string that can be used as a floating point number in GLSL.
  109213. * @param x Value to print.
  109214. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  109215. * @return GLSL float string.
  109216. */
  109217. protected _glslFloat(x: number, decimalFigures?: number): string;
  109218. /** @hidden */
  109219. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  109220. }
  109221. }
  109222. declare module BABYLON {
  109223. /**
  109224. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109225. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109226. * You can then easily use it as a reflectionTexture on a flat surface.
  109227. * In case the surface is not a plane, please consider relying on reflection probes.
  109228. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109229. */
  109230. export class MirrorTexture extends RenderTargetTexture {
  109231. private scene;
  109232. /**
  109233. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  109234. * 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.
  109235. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109236. */
  109237. mirrorPlane: Plane;
  109238. /**
  109239. * Define the blur ratio used to blur the reflection if needed.
  109240. */
  109241. set blurRatio(value: number);
  109242. get blurRatio(): number;
  109243. /**
  109244. * Define the adaptive blur kernel used to blur the reflection if needed.
  109245. * This will autocompute the closest best match for the `blurKernel`
  109246. */
  109247. set adaptiveBlurKernel(value: number);
  109248. /**
  109249. * Define the blur kernel used to blur the reflection if needed.
  109250. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109251. */
  109252. set blurKernel(value: number);
  109253. /**
  109254. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  109255. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109256. */
  109257. set blurKernelX(value: number);
  109258. get blurKernelX(): number;
  109259. /**
  109260. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  109261. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109262. */
  109263. set blurKernelY(value: number);
  109264. get blurKernelY(): number;
  109265. private _autoComputeBlurKernel;
  109266. protected _onRatioRescale(): void;
  109267. private _updateGammaSpace;
  109268. private _imageProcessingConfigChangeObserver;
  109269. private _transformMatrix;
  109270. private _mirrorMatrix;
  109271. private _blurX;
  109272. private _blurY;
  109273. private _adaptiveBlurKernel;
  109274. private _blurKernelX;
  109275. private _blurKernelY;
  109276. private _blurRatio;
  109277. /**
  109278. * Instantiates a Mirror Texture.
  109279. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109280. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109281. * You can then easily use it as a reflectionTexture on a flat surface.
  109282. * In case the surface is not a plane, please consider relying on reflection probes.
  109283. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109284. * @param name
  109285. * @param size
  109286. * @param scene
  109287. * @param generateMipMaps
  109288. * @param type
  109289. * @param samplingMode
  109290. * @param generateDepthBuffer
  109291. */
  109292. constructor(name: string, size: number | {
  109293. width: number;
  109294. height: number;
  109295. } | {
  109296. ratio: number;
  109297. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  109298. private _preparePostProcesses;
  109299. /**
  109300. * Clone the mirror texture.
  109301. * @returns the cloned texture
  109302. */
  109303. clone(): MirrorTexture;
  109304. /**
  109305. * Serialize the texture to a JSON representation you could use in Parse later on
  109306. * @returns the serialized JSON representation
  109307. */
  109308. serialize(): any;
  109309. /**
  109310. * Dispose the texture and release its associated resources.
  109311. */
  109312. dispose(): void;
  109313. }
  109314. }
  109315. declare module BABYLON {
  109316. /**
  109317. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109318. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109319. */
  109320. export class Texture extends BaseTexture {
  109321. /**
  109322. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  109323. */
  109324. static SerializeBuffers: boolean;
  109325. /**
  109326. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  109327. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  109328. */
  109329. static ForceSerializeBuffers: boolean;
  109330. /** @hidden */
  109331. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  109332. /** @hidden */
  109333. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  109334. /** @hidden */
  109335. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  109336. /** nearest is mag = nearest and min = nearest and mip = linear */
  109337. static readonly NEAREST_SAMPLINGMODE: number;
  109338. /** nearest is mag = nearest and min = nearest and mip = linear */
  109339. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  109340. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109341. static readonly BILINEAR_SAMPLINGMODE: number;
  109342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109343. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  109344. /** Trilinear is mag = linear and min = linear and mip = linear */
  109345. static readonly TRILINEAR_SAMPLINGMODE: number;
  109346. /** Trilinear is mag = linear and min = linear and mip = linear */
  109347. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  109348. /** mag = nearest and min = nearest and mip = nearest */
  109349. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  109350. /** mag = nearest and min = linear and mip = nearest */
  109351. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  109352. /** mag = nearest and min = linear and mip = linear */
  109353. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  109354. /** mag = nearest and min = linear and mip = none */
  109355. static readonly NEAREST_LINEAR: number;
  109356. /** mag = nearest and min = nearest and mip = none */
  109357. static readonly NEAREST_NEAREST: number;
  109358. /** mag = linear and min = nearest and mip = nearest */
  109359. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  109360. /** mag = linear and min = nearest and mip = linear */
  109361. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  109362. /** mag = linear and min = linear and mip = none */
  109363. static readonly LINEAR_LINEAR: number;
  109364. /** mag = linear and min = nearest and mip = none */
  109365. static readonly LINEAR_NEAREST: number;
  109366. /** Explicit coordinates mode */
  109367. static readonly EXPLICIT_MODE: number;
  109368. /** Spherical coordinates mode */
  109369. static readonly SPHERICAL_MODE: number;
  109370. /** Planar coordinates mode */
  109371. static readonly PLANAR_MODE: number;
  109372. /** Cubic coordinates mode */
  109373. static readonly CUBIC_MODE: number;
  109374. /** Projection coordinates mode */
  109375. static readonly PROJECTION_MODE: number;
  109376. /** Inverse Cubic coordinates mode */
  109377. static readonly SKYBOX_MODE: number;
  109378. /** Inverse Cubic coordinates mode */
  109379. static readonly INVCUBIC_MODE: number;
  109380. /** Equirectangular coordinates mode */
  109381. static readonly EQUIRECTANGULAR_MODE: number;
  109382. /** Equirectangular Fixed coordinates mode */
  109383. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  109384. /** Equirectangular Fixed Mirrored coordinates mode */
  109385. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109386. /** Texture is not repeating outside of 0..1 UVs */
  109387. static readonly CLAMP_ADDRESSMODE: number;
  109388. /** Texture is repeating outside of 0..1 UVs */
  109389. static readonly WRAP_ADDRESSMODE: number;
  109390. /** Texture is repeating and mirrored */
  109391. static readonly MIRROR_ADDRESSMODE: number;
  109392. /**
  109393. * 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
  109394. */
  109395. static UseSerializedUrlIfAny: boolean;
  109396. /**
  109397. * Define the url of the texture.
  109398. */
  109399. url: Nullable<string>;
  109400. /**
  109401. * Define an offset on the texture to offset the u coordinates of the UVs
  109402. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109403. */
  109404. uOffset: number;
  109405. /**
  109406. * Define an offset on the texture to offset the v coordinates of the UVs
  109407. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109408. */
  109409. vOffset: number;
  109410. /**
  109411. * Define an offset on the texture to scale the u coordinates of the UVs
  109412. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109413. */
  109414. uScale: number;
  109415. /**
  109416. * Define an offset on the texture to scale the v coordinates of the UVs
  109417. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109418. */
  109419. vScale: number;
  109420. /**
  109421. * Define an offset on the texture to rotate around the u coordinates of the UVs
  109422. * @see https://doc.babylonjs.com/how_to/more_materials
  109423. */
  109424. uAng: number;
  109425. /**
  109426. * Define an offset on the texture to rotate around the v coordinates of the UVs
  109427. * @see https://doc.babylonjs.com/how_to/more_materials
  109428. */
  109429. vAng: number;
  109430. /**
  109431. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  109432. * @see https://doc.babylonjs.com/how_to/more_materials
  109433. */
  109434. wAng: number;
  109435. /**
  109436. * Defines the center of rotation (U)
  109437. */
  109438. uRotationCenter: number;
  109439. /**
  109440. * Defines the center of rotation (V)
  109441. */
  109442. vRotationCenter: number;
  109443. /**
  109444. * Defines the center of rotation (W)
  109445. */
  109446. wRotationCenter: number;
  109447. /**
  109448. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  109449. */
  109450. homogeneousRotationInUVTransform: boolean;
  109451. /**
  109452. * Are mip maps generated for this texture or not.
  109453. */
  109454. get noMipmap(): boolean;
  109455. /**
  109456. * List of inspectable custom properties (used by the Inspector)
  109457. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109458. */
  109459. inspectableCustomProperties: Nullable<IInspectable[]>;
  109460. private _noMipmap;
  109461. /** @hidden */
  109462. _invertY: boolean;
  109463. private _rowGenerationMatrix;
  109464. private _cachedTextureMatrix;
  109465. private _projectionModeMatrix;
  109466. private _t0;
  109467. private _t1;
  109468. private _t2;
  109469. private _cachedUOffset;
  109470. private _cachedVOffset;
  109471. private _cachedUScale;
  109472. private _cachedVScale;
  109473. private _cachedUAng;
  109474. private _cachedVAng;
  109475. private _cachedWAng;
  109476. private _cachedProjectionMatrixId;
  109477. private _cachedURotationCenter;
  109478. private _cachedVRotationCenter;
  109479. private _cachedWRotationCenter;
  109480. private _cachedHomogeneousRotationInUVTransform;
  109481. private _cachedCoordinatesMode;
  109482. /** @hidden */
  109483. protected _initialSamplingMode: number;
  109484. /** @hidden */
  109485. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  109486. private _deleteBuffer;
  109487. protected _format: Nullable<number>;
  109488. private _delayedOnLoad;
  109489. private _delayedOnError;
  109490. private _mimeType?;
  109491. private _loaderOptions?;
  109492. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  109493. get mimeType(): string | undefined;
  109494. /**
  109495. * Observable triggered once the texture has been loaded.
  109496. */
  109497. onLoadObservable: Observable<Texture>;
  109498. protected _isBlocking: boolean;
  109499. /**
  109500. * Is the texture preventing material to render while loading.
  109501. * If false, a default texture will be used instead of the loading one during the preparation step.
  109502. */
  109503. set isBlocking(value: boolean);
  109504. get isBlocking(): boolean;
  109505. /**
  109506. * Get the current sampling mode associated with the texture.
  109507. */
  109508. get samplingMode(): number;
  109509. /**
  109510. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  109511. */
  109512. get invertY(): boolean;
  109513. /**
  109514. * Instantiates a new texture.
  109515. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109516. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109517. * @param url defines the url of the picture to load as a texture
  109518. * @param sceneOrEngine defines the scene or engine the texture will belong to
  109519. * @param noMipmap defines if the texture will require mip maps or not
  109520. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  109521. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  109522. * @param onLoad defines a callback triggered when the texture has been loaded
  109523. * @param onError defines a callback triggered when an error occurred during the loading session
  109524. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109525. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109526. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109527. * @param mimeType defines an optional mime type information
  109528. * @param loaderOptions options to be passed to the loader
  109529. */
  109530. 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);
  109531. /**
  109532. * Update the url (and optional buffer) of this texture if url was null during construction.
  109533. * @param url the url of the texture
  109534. * @param buffer the buffer of the texture (defaults to null)
  109535. * @param onLoad callback called when the texture is loaded (defaults to null)
  109536. */
  109537. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109538. /**
  109539. * Finish the loading sequence of a texture flagged as delayed load.
  109540. * @hidden
  109541. */
  109542. delayLoad(): void;
  109543. private _prepareRowForTextureGeneration;
  109544. /**
  109545. * Checks if the texture has the same transform matrix than another texture
  109546. * @param texture texture to check against
  109547. * @returns true if the transforms are the same, else false
  109548. */
  109549. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109550. /**
  109551. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109552. * @returns the transform matrix of the texture.
  109553. */
  109554. getTextureMatrix(uBase?: number): Matrix;
  109555. /**
  109556. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109557. * @returns The reflection texture transform
  109558. */
  109559. getReflectionTextureMatrix(): Matrix;
  109560. /**
  109561. * Clones the texture.
  109562. * @returns the cloned texture
  109563. */
  109564. clone(): Texture;
  109565. /**
  109566. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  109567. * @returns The JSON representation of the texture
  109568. */
  109569. serialize(): any;
  109570. /**
  109571. * Get the current class name of the texture useful for serialization or dynamic coding.
  109572. * @returns "Texture"
  109573. */
  109574. getClassName(): string;
  109575. /**
  109576. * Dispose the texture and release its associated resources.
  109577. */
  109578. dispose(): void;
  109579. /**
  109580. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109581. * @param parsedTexture Define the JSON representation of the texture
  109582. * @param scene Define the scene the parsed texture should be instantiated in
  109583. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109584. * @returns The parsed texture if successful
  109585. */
  109586. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109587. /**
  109588. * Creates a texture from its base 64 representation.
  109589. * @param data Define the base64 payload without the data: prefix
  109590. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109591. * @param scene Define the scene the texture should belong to
  109592. * @param noMipmap Forces the texture to not create mip map information if true
  109593. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109594. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  109595. * @param onLoad define a callback triggered when the texture has been loaded
  109596. * @param onError define a callback triggered when an error occurred during the loading session
  109597. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109598. * @returns the created texture
  109599. */
  109600. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109601. /**
  109602. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109603. * @param data Define the base64 payload without the data: prefix
  109604. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109605. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109606. * @param scene Define the scene the texture should belong to
  109607. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109608. * @param noMipmap Forces the texture to not create mip map information if true
  109609. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109610. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  109611. * @param onLoad define a callback triggered when the texture has been loaded
  109612. * @param onError define a callback triggered when an error occurred during the loading session
  109613. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109614. * @returns the created texture
  109615. */
  109616. 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;
  109617. }
  109618. }
  109619. declare module BABYLON {
  109620. /**
  109621. * ThinSprite Class used to represent a thin sprite
  109622. * This is the base class for sprites but can also directly be used with ThinEngine
  109623. * @see https://doc.babylonjs.com/babylon101/sprites
  109624. */
  109625. export class ThinSprite {
  109626. /** Gets or sets the cell index in the sprite sheet */
  109627. cellIndex: number;
  109628. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  109629. cellRef: string;
  109630. /** Gets or sets the current world position */
  109631. position: IVector3Like;
  109632. /** Gets or sets the main color */
  109633. color: IColor4Like;
  109634. /** Gets or sets the width */
  109635. width: number;
  109636. /** Gets or sets the height */
  109637. height: number;
  109638. /** Gets or sets rotation angle */
  109639. angle: number;
  109640. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  109641. invertU: boolean;
  109642. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  109643. invertV: boolean;
  109644. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  109645. isVisible: boolean;
  109646. /**
  109647. * Returns a boolean indicating if the animation is started
  109648. */
  109649. get animationStarted(): boolean;
  109650. /** Gets the initial key for the animation (setting it will restart the animation) */
  109651. get fromIndex(): number;
  109652. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  109653. get toIndex(): number;
  109654. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  109655. get loopAnimation(): boolean;
  109656. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  109657. get delay(): number;
  109658. /** @hidden */
  109659. _xOffset: number;
  109660. /** @hidden */
  109661. _yOffset: number;
  109662. /** @hidden */
  109663. _xSize: number;
  109664. /** @hidden */
  109665. _ySize: number;
  109666. private _animationStarted;
  109667. protected _loopAnimation: boolean;
  109668. protected _fromIndex: number;
  109669. protected _toIndex: number;
  109670. protected _delay: number;
  109671. private _direction;
  109672. private _time;
  109673. private _onBaseAnimationEnd;
  109674. /**
  109675. * Creates a new Thin Sprite
  109676. */
  109677. constructor();
  109678. /**
  109679. * Starts an animation
  109680. * @param from defines the initial key
  109681. * @param to defines the end key
  109682. * @param loop defines if the animation must loop
  109683. * @param delay defines the start delay (in ms)
  109684. * @param onAnimationEnd defines a callback for when the animation ends
  109685. */
  109686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  109687. /** Stops current animation (if any) */
  109688. stopAnimation(): void;
  109689. /** @hidden */
  109690. _animate(deltaTime: number): void;
  109691. }
  109692. }
  109693. declare module BABYLON {
  109694. /** @hidden */
  109695. export var imageProcessingCompatibility: {
  109696. name: string;
  109697. shader: string;
  109698. };
  109699. }
  109700. declare module BABYLON {
  109701. /** @hidden */
  109702. export var spritesPixelShader: {
  109703. name: string;
  109704. shader: string;
  109705. };
  109706. }
  109707. declare module BABYLON {
  109708. /** @hidden */
  109709. export var spritesVertexShader: {
  109710. name: string;
  109711. shader: string;
  109712. };
  109713. }
  109714. declare module BABYLON {
  109715. /**
  109716. * Class used to render sprites.
  109717. *
  109718. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  109719. */
  109720. export class SpriteRenderer {
  109721. /**
  109722. * Defines the texture of the spritesheet
  109723. */
  109724. texture: Nullable<ThinTexture>;
  109725. /**
  109726. * Defines the default width of a cell in the spritesheet
  109727. */
  109728. cellWidth: number;
  109729. /**
  109730. * Defines the default height of a cell in the spritesheet
  109731. */
  109732. cellHeight: number;
  109733. /**
  109734. * Blend mode use to render the particle, it can be any of
  109735. * the static Constants.ALPHA_x properties provided in this class.
  109736. * Default value is Constants.ALPHA_COMBINE
  109737. */
  109738. blendMode: number;
  109739. /**
  109740. * Gets or sets a boolean indicating if alpha mode is automatically
  109741. * reset.
  109742. */
  109743. autoResetAlpha: boolean;
  109744. /**
  109745. * Disables writing to the depth buffer when rendering the sprites.
  109746. * It can be handy to disable depth writing when using textures without alpha channel
  109747. * and setting some specific blend modes.
  109748. */
  109749. disableDepthWrite: boolean;
  109750. /**
  109751. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  109752. */
  109753. fogEnabled: boolean;
  109754. /**
  109755. * Gets the capacity of the manager
  109756. */
  109757. get capacity(): number;
  109758. private readonly _engine;
  109759. private readonly _useVAO;
  109760. private readonly _useInstancing;
  109761. private readonly _scene;
  109762. private readonly _capacity;
  109763. private readonly _epsilon;
  109764. private _vertexBufferSize;
  109765. private _vertexData;
  109766. private _buffer;
  109767. private _vertexBuffers;
  109768. private _spriteBuffer;
  109769. private _indexBuffer;
  109770. private _effectBase;
  109771. private _effectFog;
  109772. private _vertexArrayObject;
  109773. /**
  109774. * Creates a new sprite Renderer
  109775. * @param engine defines the engine the renderer works with
  109776. * @param capacity defines the maximum allowed number of sprites
  109777. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  109778. * @param scene defines the hosting scene
  109779. */
  109780. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  109781. /**
  109782. * Render all child sprites
  109783. * @param sprites defines the list of sprites to render
  109784. * @param deltaTime defines the time since last frame
  109785. * @param viewMatrix defines the viewMatrix to use to render the sprites
  109786. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  109787. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  109788. */
  109789. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  109790. private _appendSpriteVertex;
  109791. /**
  109792. * Release associated resources
  109793. */
  109794. dispose(): void;
  109795. }
  109796. }
  109797. declare module BABYLON {
  109798. /**
  109799. * Defines the minimum interface to fulfill in order to be a sprite manager.
  109800. */
  109801. export interface ISpriteManager extends IDisposable {
  109802. /**
  109803. * Gets manager's name
  109804. */
  109805. name: string;
  109806. /**
  109807. * Restricts the camera to viewing objects with the same layerMask.
  109808. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  109809. */
  109810. layerMask: number;
  109811. /**
  109812. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109813. */
  109814. isPickable: boolean;
  109815. /**
  109816. * Gets the hosting scene
  109817. */
  109818. scene: Scene;
  109819. /**
  109820. * Specifies the rendering group id for this mesh (0 by default)
  109821. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109822. */
  109823. renderingGroupId: number;
  109824. /**
  109825. * Defines the list of sprites managed by the manager.
  109826. */
  109827. sprites: Array<Sprite>;
  109828. /**
  109829. * Gets or sets the spritesheet texture
  109830. */
  109831. texture: Texture;
  109832. /** Defines the default width of a cell in the spritesheet */
  109833. cellWidth: number;
  109834. /** Defines the default height of a cell in the spritesheet */
  109835. cellHeight: number;
  109836. /**
  109837. * Tests the intersection of a sprite with a specific ray.
  109838. * @param ray The ray we are sending to test the collision
  109839. * @param camera The camera space we are sending rays in
  109840. * @param predicate A predicate allowing excluding sprites from the list of object to test
  109841. * @param fastCheck defines if the first intersection will be used (and not the closest)
  109842. * @returns picking info or null.
  109843. */
  109844. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  109845. /**
  109846. * Intersects the sprites with a ray
  109847. * @param ray defines the ray to intersect with
  109848. * @param camera defines the current active camera
  109849. * @param predicate defines a predicate used to select candidate sprites
  109850. * @returns null if no hit or a PickingInfo array
  109851. */
  109852. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  109853. /**
  109854. * Renders the list of sprites on screen.
  109855. */
  109856. render(): void;
  109857. }
  109858. /**
  109859. * Class used to manage multiple sprites on the same spritesheet
  109860. * @see https://doc.babylonjs.com/babylon101/sprites
  109861. */
  109862. export class SpriteManager implements ISpriteManager {
  109863. /** defines the manager's name */
  109864. name: string;
  109865. /** Define the Url to load snippets */
  109866. static SnippetUrl: string;
  109867. /** Snippet ID if the manager was created from the snippet server */
  109868. snippetId: string;
  109869. /** Gets the list of sprites */
  109870. sprites: Sprite[];
  109871. /** Gets or sets the rendering group id (0 by default) */
  109872. renderingGroupId: number;
  109873. /** Gets or sets camera layer mask */
  109874. layerMask: number;
  109875. /** Gets or sets a boolean indicating if the sprites are pickable */
  109876. isPickable: boolean;
  109877. /**
  109878. * An event triggered when the manager is disposed.
  109879. */
  109880. onDisposeObservable: Observable<SpriteManager>;
  109881. /**
  109882. * Callback called when the manager is disposed
  109883. */
  109884. set onDispose(callback: () => void);
  109885. /**
  109886. * Gets or sets the unique id of the sprite
  109887. */
  109888. uniqueId: number;
  109889. /**
  109890. * Gets the array of sprites
  109891. */
  109892. get children(): Sprite[];
  109893. /**
  109894. * Gets the hosting scene
  109895. */
  109896. get scene(): Scene;
  109897. /**
  109898. * Gets the capacity of the manager
  109899. */
  109900. get capacity(): number;
  109901. /**
  109902. * Gets or sets the spritesheet texture
  109903. */
  109904. get texture(): Texture;
  109905. set texture(value: Texture);
  109906. /** Defines the default width of a cell in the spritesheet */
  109907. get cellWidth(): number;
  109908. set cellWidth(value: number);
  109909. /** Defines the default height of a cell in the spritesheet */
  109910. get cellHeight(): number;
  109911. set cellHeight(value: number);
  109912. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  109913. get fogEnabled(): boolean;
  109914. set fogEnabled(value: boolean);
  109915. /**
  109916. * Blend mode use to render the particle, it can be any of
  109917. * the static Constants.ALPHA_x properties provided in this class.
  109918. * Default value is Constants.ALPHA_COMBINE
  109919. */
  109920. get blendMode(): number;
  109921. set blendMode(blendMode: number);
  109922. /** Disables writing to the depth buffer when rendering the sprites.
  109923. * It can be handy to disable depth writing when using textures without alpha channel
  109924. * and setting some specific blend modes.
  109925. */
  109926. disableDepthWrite: boolean;
  109927. private _spriteRenderer;
  109928. /** Associative array from JSON sprite data file */
  109929. private _cellData;
  109930. /** Array of sprite names from JSON sprite data file */
  109931. private _spriteMap;
  109932. /** True when packed cell data from JSON file is ready*/
  109933. private _packedAndReady;
  109934. private _textureContent;
  109935. private _onDisposeObserver;
  109936. private _fromPacked;
  109937. private _scene;
  109938. /**
  109939. * Creates a new sprite manager
  109940. * @param name defines the manager's name
  109941. * @param imgUrl defines the sprite sheet url
  109942. * @param capacity defines the maximum allowed number of sprites
  109943. * @param cellSize defines the size of a sprite cell
  109944. * @param scene defines the hosting scene
  109945. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  109946. * @param samplingMode defines the sampling mode to use with spritesheet
  109947. * @param fromPacked set to false; do not alter
  109948. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  109949. */
  109950. constructor(
  109951. /** defines the manager's name */
  109952. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  109953. /**
  109954. * Returns the string "SpriteManager"
  109955. * @returns "SpriteManager"
  109956. */
  109957. getClassName(): string;
  109958. private _makePacked;
  109959. private _checkTextureAlpha;
  109960. /**
  109961. * Intersects the sprites with a ray
  109962. * @param ray defines the ray to intersect with
  109963. * @param camera defines the current active camera
  109964. * @param predicate defines a predicate used to select candidate sprites
  109965. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  109966. * @returns null if no hit or a PickingInfo
  109967. */
  109968. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  109969. /**
  109970. * Intersects the sprites with a ray
  109971. * @param ray defines the ray to intersect with
  109972. * @param camera defines the current active camera
  109973. * @param predicate defines a predicate used to select candidate sprites
  109974. * @returns null if no hit or a PickingInfo array
  109975. */
  109976. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  109977. /**
  109978. * Render all child sprites
  109979. */
  109980. render(): void;
  109981. private _customUpdate;
  109982. /**
  109983. * Release associated resources
  109984. */
  109985. dispose(): void;
  109986. /**
  109987. * Serializes the sprite manager to a JSON object
  109988. * @param serializeTexture defines if the texture must be serialized as well
  109989. * @returns the JSON object
  109990. */
  109991. serialize(serializeTexture?: boolean): any;
  109992. /**
  109993. * Parses a JSON object to create a new sprite manager.
  109994. * @param parsedManager The JSON object to parse
  109995. * @param scene The scene to create the sprite manager
  109996. * @param rootUrl The root url to use to load external dependencies like texture
  109997. * @returns the new sprite manager
  109998. */
  109999. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  110000. /**
  110001. * Creates a sprite manager from a snippet saved in a remote file
  110002. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  110003. * @param url defines the url to load from
  110004. * @param scene defines the hosting scene
  110005. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110006. * @returns a promise that will resolve to the new sprite manager
  110007. */
  110008. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  110009. /**
  110010. * Creates a sprite manager from a snippet saved by the sprite editor
  110011. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  110012. * @param scene defines the hosting scene
  110013. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110014. * @returns a promise that will resolve to the new sprite manager
  110015. */
  110016. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  110017. }
  110018. }
  110019. declare module BABYLON {
  110020. /**
  110021. * Class used to represent a sprite
  110022. * @see https://doc.babylonjs.com/babylon101/sprites
  110023. */
  110024. export class Sprite extends ThinSprite implements IAnimatable {
  110025. /** defines the name */
  110026. name: string;
  110027. /** Gets or sets the current world position */
  110028. position: Vector3;
  110029. /** Gets or sets the main color */
  110030. color: Color4;
  110031. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  110032. disposeWhenFinishedAnimating: boolean;
  110033. /** Gets the list of attached animations */
  110034. animations: Nullable<Array<Animation>>;
  110035. /** Gets or sets a boolean indicating if the sprite can be picked */
  110036. isPickable: boolean;
  110037. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  110038. useAlphaForPicking: boolean;
  110039. /**
  110040. * Gets or sets the associated action manager
  110041. */
  110042. actionManager: Nullable<ActionManager>;
  110043. /**
  110044. * An event triggered when the control has been disposed
  110045. */
  110046. onDisposeObservable: Observable<Sprite>;
  110047. private _manager;
  110048. private _onAnimationEnd;
  110049. /**
  110050. * Gets or sets the sprite size
  110051. */
  110052. get size(): number;
  110053. set size(value: number);
  110054. /**
  110055. * Gets or sets the unique id of the sprite
  110056. */
  110057. uniqueId: number;
  110058. /**
  110059. * Gets the manager of this sprite
  110060. */
  110061. get manager(): ISpriteManager;
  110062. /**
  110063. * Creates a new Sprite
  110064. * @param name defines the name
  110065. * @param manager defines the manager
  110066. */
  110067. constructor(
  110068. /** defines the name */
  110069. name: string, manager: ISpriteManager);
  110070. /**
  110071. * Returns the string "Sprite"
  110072. * @returns "Sprite"
  110073. */
  110074. getClassName(): string;
  110075. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  110076. get fromIndex(): number;
  110077. set fromIndex(value: number);
  110078. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  110079. get toIndex(): number;
  110080. set toIndex(value: number);
  110081. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  110082. get loopAnimation(): boolean;
  110083. set loopAnimation(value: boolean);
  110084. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  110085. get delay(): number;
  110086. set delay(value: number);
  110087. /**
  110088. * Starts an animation
  110089. * @param from defines the initial key
  110090. * @param to defines the end key
  110091. * @param loop defines if the animation must loop
  110092. * @param delay defines the start delay (in ms)
  110093. * @param onAnimationEnd defines a callback to call when animation ends
  110094. */
  110095. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  110096. private _endAnimation;
  110097. /** Release associated resources */
  110098. dispose(): void;
  110099. /**
  110100. * Serializes the sprite to a JSON object
  110101. * @returns the JSON object
  110102. */
  110103. serialize(): any;
  110104. /**
  110105. * Parses a JSON object to create a new sprite
  110106. * @param parsedSprite The JSON object to parse
  110107. * @param manager defines the hosting manager
  110108. * @returns the new sprite
  110109. */
  110110. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  110111. }
  110112. }
  110113. declare module BABYLON {
  110114. /**
  110115. * Information about the result of picking within a scene
  110116. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  110117. */
  110118. export class PickingInfo {
  110119. /** @hidden */
  110120. _pickingUnavailable: boolean;
  110121. /**
  110122. * If the pick collided with an object
  110123. */
  110124. hit: boolean;
  110125. /**
  110126. * Distance away where the pick collided
  110127. */
  110128. distance: number;
  110129. /**
  110130. * The location of pick collision
  110131. */
  110132. pickedPoint: Nullable<Vector3>;
  110133. /**
  110134. * The mesh corresponding the the pick collision
  110135. */
  110136. pickedMesh: Nullable<AbstractMesh>;
  110137. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  110138. bu: number;
  110139. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  110140. bv: number;
  110141. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  110142. faceId: number;
  110143. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  110144. subMeshFaceId: number;
  110145. /** Id of the the submesh that was picked */
  110146. subMeshId: number;
  110147. /** If a sprite was picked, this will be the sprite the pick collided with */
  110148. pickedSprite: Nullable<Sprite>;
  110149. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  110150. thinInstanceIndex: number;
  110151. /**
  110152. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  110153. */
  110154. originMesh: Nullable<AbstractMesh>;
  110155. /**
  110156. * The ray that was used to perform the picking.
  110157. */
  110158. ray: Nullable<Ray>;
  110159. /**
  110160. * Gets the normal corresponding to the face the pick collided with
  110161. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  110162. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  110163. * @returns The normal corresponding to the face the pick collided with
  110164. */
  110165. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  110166. /**
  110167. * Gets the texture coordinates of where the pick occurred
  110168. * @returns the vector containing the coordinates of the texture
  110169. */
  110170. getTextureCoordinates(): Nullable<Vector2>;
  110171. }
  110172. }
  110173. declare module BABYLON {
  110174. /**
  110175. * Gather the list of pointer event types as constants.
  110176. */
  110177. export class PointerEventTypes {
  110178. /**
  110179. * 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.
  110180. */
  110181. static readonly POINTERDOWN: number;
  110182. /**
  110183. * The pointerup event is fired when a pointer is no longer active.
  110184. */
  110185. static readonly POINTERUP: number;
  110186. /**
  110187. * The pointermove event is fired when a pointer changes coordinates.
  110188. */
  110189. static readonly POINTERMOVE: number;
  110190. /**
  110191. * The pointerwheel event is fired when a mouse wheel has been rotated.
  110192. */
  110193. static readonly POINTERWHEEL: number;
  110194. /**
  110195. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  110196. */
  110197. static readonly POINTERPICK: number;
  110198. /**
  110199. * The pointertap event is fired when a the object has been touched and released without drag.
  110200. */
  110201. static readonly POINTERTAP: number;
  110202. /**
  110203. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  110204. */
  110205. static readonly POINTERDOUBLETAP: number;
  110206. }
  110207. /**
  110208. * Base class of pointer info types.
  110209. */
  110210. export class PointerInfoBase {
  110211. /**
  110212. * Defines the type of event (PointerEventTypes)
  110213. */
  110214. type: number;
  110215. /**
  110216. * Defines the related dom event
  110217. */
  110218. event: PointerEvent | MouseWheelEvent;
  110219. /**
  110220. * Instantiates the base class of pointers info.
  110221. * @param type Defines the type of event (PointerEventTypes)
  110222. * @param event Defines the related dom event
  110223. */
  110224. constructor(
  110225. /**
  110226. * Defines the type of event (PointerEventTypes)
  110227. */
  110228. type: number,
  110229. /**
  110230. * Defines the related dom event
  110231. */
  110232. event: PointerEvent | MouseWheelEvent);
  110233. }
  110234. /**
  110235. * This class is used to store pointer related info for the onPrePointerObservable event.
  110236. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  110237. */
  110238. export class PointerInfoPre extends PointerInfoBase {
  110239. /**
  110240. * Ray from a pointer if availible (eg. 6dof controller)
  110241. */
  110242. ray: Nullable<Ray>;
  110243. /**
  110244. * Defines the local position of the pointer on the canvas.
  110245. */
  110246. localPosition: Vector2;
  110247. /**
  110248. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  110249. */
  110250. skipOnPointerObservable: boolean;
  110251. /**
  110252. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  110253. * @param type Defines the type of event (PointerEventTypes)
  110254. * @param event Defines the related dom event
  110255. * @param localX Defines the local x coordinates of the pointer when the event occured
  110256. * @param localY Defines the local y coordinates of the pointer when the event occured
  110257. */
  110258. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  110259. }
  110260. /**
  110261. * This type contains all the data related to a pointer event in Babylon.js.
  110262. * 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.
  110263. */
  110264. export class PointerInfo extends PointerInfoBase {
  110265. /**
  110266. * Defines the picking info associated to the info (if any)\
  110267. */
  110268. pickInfo: Nullable<PickingInfo>;
  110269. /**
  110270. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  110271. * @param type Defines the type of event (PointerEventTypes)
  110272. * @param event Defines the related dom event
  110273. * @param pickInfo Defines the picking info associated to the info (if any)\
  110274. */
  110275. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  110276. /**
  110277. * Defines the picking info associated to the info (if any)\
  110278. */
  110279. pickInfo: Nullable<PickingInfo>);
  110280. }
  110281. /**
  110282. * Data relating to a touch event on the screen.
  110283. */
  110284. export interface PointerTouch {
  110285. /**
  110286. * X coordinate of touch.
  110287. */
  110288. x: number;
  110289. /**
  110290. * Y coordinate of touch.
  110291. */
  110292. y: number;
  110293. /**
  110294. * Id of touch. Unique for each finger.
  110295. */
  110296. pointerId: number;
  110297. /**
  110298. * Event type passed from DOM.
  110299. */
  110300. type: any;
  110301. }
  110302. }
  110303. declare module BABYLON {
  110304. /**
  110305. * Manage the mouse inputs to control the movement of a free camera.
  110306. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110307. */
  110308. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  110309. /**
  110310. * Define if touch is enabled in the mouse input
  110311. */
  110312. touchEnabled: boolean;
  110313. /**
  110314. * Defines the camera the input is attached to.
  110315. */
  110316. camera: FreeCamera;
  110317. /**
  110318. * Defines the buttons associated with the input to handle camera move.
  110319. */
  110320. buttons: number[];
  110321. /**
  110322. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  110323. */
  110324. angularSensibility: number;
  110325. private _pointerInput;
  110326. private _onMouseMove;
  110327. private _observer;
  110328. private previousPosition;
  110329. /**
  110330. * Observable for when a pointer move event occurs containing the move offset
  110331. */
  110332. onPointerMovedObservable: Observable<{
  110333. offsetX: number;
  110334. offsetY: number;
  110335. }>;
  110336. /**
  110337. * @hidden
  110338. * If the camera should be rotated automatically based on pointer movement
  110339. */
  110340. _allowCameraRotation: boolean;
  110341. /**
  110342. * Manage the mouse inputs to control the movement of a free camera.
  110343. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110344. * @param touchEnabled Defines if touch is enabled or not
  110345. */
  110346. constructor(
  110347. /**
  110348. * Define if touch is enabled in the mouse input
  110349. */
  110350. touchEnabled?: boolean);
  110351. /**
  110352. * Attach the input controls to a specific dom element to get the input from.
  110353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110354. */
  110355. attachControl(noPreventDefault?: boolean): void;
  110356. /**
  110357. * Called on JS contextmenu event.
  110358. * Override this method to provide functionality.
  110359. */
  110360. protected onContextMenu(evt: PointerEvent): void;
  110361. /**
  110362. * Detach the current controls from the specified dom element.
  110363. */
  110364. detachControl(): void;
  110365. /**
  110366. * Gets the class name of the current input.
  110367. * @returns the class name
  110368. */
  110369. getClassName(): string;
  110370. /**
  110371. * Get the friendly name associated with the input class.
  110372. * @returns the input friendly name
  110373. */
  110374. getSimpleName(): string;
  110375. }
  110376. }
  110377. declare module BABYLON {
  110378. /**
  110379. * Base class for mouse wheel input..
  110380. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  110381. * for example usage.
  110382. */
  110383. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  110384. /**
  110385. * Defines the camera the input is attached to.
  110386. */
  110387. abstract camera: Camera;
  110388. /**
  110389. * How fast is the camera moves in relation to X axis mouseWheel events.
  110390. * Use negative value to reverse direction.
  110391. */
  110392. wheelPrecisionX: number;
  110393. /**
  110394. * How fast is the camera moves in relation to Y axis mouseWheel events.
  110395. * Use negative value to reverse direction.
  110396. */
  110397. wheelPrecisionY: number;
  110398. /**
  110399. * How fast is the camera moves in relation to Z axis mouseWheel events.
  110400. * Use negative value to reverse direction.
  110401. */
  110402. wheelPrecisionZ: number;
  110403. /**
  110404. * Observable for when a mouse wheel move event occurs.
  110405. */
  110406. onChangedObservable: Observable<{
  110407. wheelDeltaX: number;
  110408. wheelDeltaY: number;
  110409. wheelDeltaZ: number;
  110410. }>;
  110411. private _wheel;
  110412. private _observer;
  110413. /**
  110414. * Attach the input controls to a specific dom element to get the input from.
  110415. * @param noPreventDefault Defines whether event caught by the controls
  110416. * should call preventdefault().
  110417. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110418. */
  110419. attachControl(noPreventDefault?: boolean): void;
  110420. /**
  110421. * Detach the current controls from the specified dom element.
  110422. */
  110423. detachControl(): void;
  110424. /**
  110425. * Called for each rendered frame.
  110426. */
  110427. checkInputs(): void;
  110428. /**
  110429. * Gets the class name of the current input.
  110430. * @returns the class name
  110431. */
  110432. getClassName(): string;
  110433. /**
  110434. * Get the friendly name associated with the input class.
  110435. * @returns the input friendly name
  110436. */
  110437. getSimpleName(): string;
  110438. /**
  110439. * Incremental value of multiple mouse wheel movements of the X axis.
  110440. * Should be zero-ed when read.
  110441. */
  110442. protected _wheelDeltaX: number;
  110443. /**
  110444. * Incremental value of multiple mouse wheel movements of the Y axis.
  110445. * Should be zero-ed when read.
  110446. */
  110447. protected _wheelDeltaY: number;
  110448. /**
  110449. * Incremental value of multiple mouse wheel movements of the Z axis.
  110450. * Should be zero-ed when read.
  110451. */
  110452. protected _wheelDeltaZ: number;
  110453. /**
  110454. * Firefox uses a different scheme to report scroll distances to other
  110455. * browsers. Rather than use complicated methods to calculate the exact
  110456. * multiple we need to apply, let's just cheat and use a constant.
  110457. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  110458. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  110459. */
  110460. private readonly _ffMultiplier;
  110461. /**
  110462. * Different event attributes for wheel data fall into a few set ranges.
  110463. * Some relevant but dated date here:
  110464. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  110465. */
  110466. private readonly _normalize;
  110467. }
  110468. }
  110469. declare module BABYLON {
  110470. /**
  110471. * Manage the mouse wheel inputs to control a free camera.
  110472. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110473. */
  110474. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  110475. /**
  110476. * Defines the camera the input is attached to.
  110477. */
  110478. camera: FreeCamera;
  110479. /**
  110480. * Gets the class name of the current input.
  110481. * @returns the class name
  110482. */
  110483. getClassName(): string;
  110484. /**
  110485. * Set which movement axis (relative to camera's orientation) the mouse
  110486. * wheel's X axis controls.
  110487. * @param axis The axis to be moved. Set null to clear.
  110488. */
  110489. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  110490. /**
  110491. * Get the configured movement axis (relative to camera's orientation) the
  110492. * mouse wheel's X axis controls.
  110493. * @returns The configured axis or null if none.
  110494. */
  110495. get wheelXMoveRelative(): Nullable<Coordinate>;
  110496. /**
  110497. * Set which movement axis (relative to camera's orientation) the mouse
  110498. * wheel's Y axis controls.
  110499. * @param axis The axis to be moved. Set null to clear.
  110500. */
  110501. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  110502. /**
  110503. * Get the configured movement axis (relative to camera's orientation) the
  110504. * mouse wheel's Y axis controls.
  110505. * @returns The configured axis or null if none.
  110506. */
  110507. get wheelYMoveRelative(): Nullable<Coordinate>;
  110508. /**
  110509. * Set which movement axis (relative to camera's orientation) the mouse
  110510. * wheel's Z axis controls.
  110511. * @param axis The axis to be moved. Set null to clear.
  110512. */
  110513. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  110514. /**
  110515. * Get the configured movement axis (relative to camera's orientation) the
  110516. * mouse wheel's Z axis controls.
  110517. * @returns The configured axis or null if none.
  110518. */
  110519. get wheelZMoveRelative(): Nullable<Coordinate>;
  110520. /**
  110521. * Set which rotation axis (relative to camera's orientation) the mouse
  110522. * wheel's X axis controls.
  110523. * @param axis The axis to be moved. Set null to clear.
  110524. */
  110525. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  110526. /**
  110527. * Get the configured rotation axis (relative to camera's orientation) the
  110528. * mouse wheel's X axis controls.
  110529. * @returns The configured axis or null if none.
  110530. */
  110531. get wheelXRotateRelative(): Nullable<Coordinate>;
  110532. /**
  110533. * Set which rotation axis (relative to camera's orientation) the mouse
  110534. * wheel's Y axis controls.
  110535. * @param axis The axis to be moved. Set null to clear.
  110536. */
  110537. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  110538. /**
  110539. * Get the configured rotation axis (relative to camera's orientation) the
  110540. * mouse wheel's Y axis controls.
  110541. * @returns The configured axis or null if none.
  110542. */
  110543. get wheelYRotateRelative(): Nullable<Coordinate>;
  110544. /**
  110545. * Set which rotation axis (relative to camera's orientation) the mouse
  110546. * wheel's Z axis controls.
  110547. * @param axis The axis to be moved. Set null to clear.
  110548. */
  110549. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  110550. /**
  110551. * Get the configured rotation axis (relative to camera's orientation) the
  110552. * mouse wheel's Z axis controls.
  110553. * @returns The configured axis or null if none.
  110554. */
  110555. get wheelZRotateRelative(): Nullable<Coordinate>;
  110556. /**
  110557. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  110558. * controls.
  110559. * @param axis The axis to be moved. Set null to clear.
  110560. */
  110561. set wheelXMoveScene(axis: Nullable<Coordinate>);
  110562. /**
  110563. * Get the configured movement axis (relative to the scene) the mouse wheel's
  110564. * X axis controls.
  110565. * @returns The configured axis or null if none.
  110566. */
  110567. get wheelXMoveScene(): Nullable<Coordinate>;
  110568. /**
  110569. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  110570. * controls.
  110571. * @param axis The axis to be moved. Set null to clear.
  110572. */
  110573. set wheelYMoveScene(axis: Nullable<Coordinate>);
  110574. /**
  110575. * Get the configured movement axis (relative to the scene) the mouse wheel's
  110576. * Y axis controls.
  110577. * @returns The configured axis or null if none.
  110578. */
  110579. get wheelYMoveScene(): Nullable<Coordinate>;
  110580. /**
  110581. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  110582. * controls.
  110583. * @param axis The axis to be moved. Set null to clear.
  110584. */
  110585. set wheelZMoveScene(axis: Nullable<Coordinate>);
  110586. /**
  110587. * Get the configured movement axis (relative to the scene) the mouse wheel's
  110588. * Z axis controls.
  110589. * @returns The configured axis or null if none.
  110590. */
  110591. get wheelZMoveScene(): Nullable<Coordinate>;
  110592. /**
  110593. * Called for each rendered frame.
  110594. */
  110595. checkInputs(): void;
  110596. private _moveRelative;
  110597. private _rotateRelative;
  110598. private _moveScene;
  110599. /**
  110600. * These are set to the desired default behaviour.
  110601. */
  110602. private _wheelXAction;
  110603. private _wheelXActionCoordinate;
  110604. private _wheelYAction;
  110605. private _wheelYActionCoordinate;
  110606. private _wheelZAction;
  110607. private _wheelZActionCoordinate;
  110608. /**
  110609. * Update the camera according to any configured properties for the 3
  110610. * mouse-wheel axis.
  110611. */
  110612. private _updateCamera;
  110613. /**
  110614. * Update one property of the camera.
  110615. */
  110616. private _updateCameraProperty;
  110617. }
  110618. }
  110619. declare module BABYLON {
  110620. /**
  110621. * Manage the touch inputs to control the movement of a free camera.
  110622. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110623. */
  110624. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  110625. /**
  110626. * Define if mouse events can be treated as touch events
  110627. */
  110628. allowMouse: boolean;
  110629. /**
  110630. * Defines the camera the input is attached to.
  110631. */
  110632. camera: FreeCamera;
  110633. /**
  110634. * Defines the touch sensibility for rotation.
  110635. * The higher the faster.
  110636. */
  110637. touchAngularSensibility: number;
  110638. /**
  110639. * Defines the touch sensibility for move.
  110640. * The higher the faster.
  110641. */
  110642. touchMoveSensibility: number;
  110643. private _offsetX;
  110644. private _offsetY;
  110645. private _pointerPressed;
  110646. private _pointerInput?;
  110647. private _observer;
  110648. private _onLostFocus;
  110649. /**
  110650. * Manage the touch inputs to control the movement of a free camera.
  110651. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110652. * @param allowMouse Defines if mouse events can be treated as touch events
  110653. */
  110654. constructor(
  110655. /**
  110656. * Define if mouse events can be treated as touch events
  110657. */
  110658. allowMouse?: boolean);
  110659. /**
  110660. * Attach the input controls to a specific dom element to get the input from.
  110661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110662. */
  110663. attachControl(noPreventDefault?: boolean): void;
  110664. /**
  110665. * Detach the current controls from the specified dom element.
  110666. */
  110667. detachControl(): void;
  110668. /**
  110669. * Update the current camera state depending on the inputs that have been used this frame.
  110670. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110671. */
  110672. checkInputs(): void;
  110673. /**
  110674. * Gets the class name of the current input.
  110675. * @returns the class name
  110676. */
  110677. getClassName(): string;
  110678. /**
  110679. * Get the friendly name associated with the input class.
  110680. * @returns the input friendly name
  110681. */
  110682. getSimpleName(): string;
  110683. }
  110684. }
  110685. declare module BABYLON {
  110686. /**
  110687. * Default Inputs manager for the FreeCamera.
  110688. * It groups all the default supported inputs for ease of use.
  110689. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  110690. */
  110691. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  110692. /**
  110693. * @hidden
  110694. */
  110695. _mouseInput: Nullable<FreeCameraMouseInput>;
  110696. /**
  110697. * @hidden
  110698. */
  110699. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  110700. /**
  110701. * Instantiates a new FreeCameraInputsManager.
  110702. * @param camera Defines the camera the inputs belong to
  110703. */
  110704. constructor(camera: FreeCamera);
  110705. /**
  110706. * Add keyboard input support to the input manager.
  110707. * @returns the current input manager
  110708. */
  110709. addKeyboard(): FreeCameraInputsManager;
  110710. /**
  110711. * Add mouse input support to the input manager.
  110712. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  110713. * @returns the current input manager
  110714. */
  110715. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  110716. /**
  110717. * Removes the mouse input support from the manager
  110718. * @returns the current input manager
  110719. */
  110720. removeMouse(): FreeCameraInputsManager;
  110721. /**
  110722. * Add mouse wheel input support to the input manager.
  110723. * @returns the current input manager
  110724. */
  110725. addMouseWheel(): FreeCameraInputsManager;
  110726. /**
  110727. * Removes the mouse wheel input support from the manager
  110728. * @returns the current input manager
  110729. */
  110730. removeMouseWheel(): FreeCameraInputsManager;
  110731. /**
  110732. * Add touch input support to the input manager.
  110733. * @returns the current input manager
  110734. */
  110735. addTouch(): FreeCameraInputsManager;
  110736. /**
  110737. * Remove all attached input methods from a camera
  110738. */
  110739. clear(): void;
  110740. }
  110741. }
  110742. declare module BABYLON {
  110743. /**
  110744. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110745. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  110746. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  110747. */
  110748. export class FreeCamera extends TargetCamera {
  110749. /**
  110750. * Define the collision ellipsoid of the camera.
  110751. * This is helpful to simulate a camera body like the player body around the camera
  110752. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110753. */
  110754. ellipsoid: Vector3;
  110755. /**
  110756. * Define an offset for the position of the ellipsoid around the camera.
  110757. * This can be helpful to determine the center of the body near the gravity center of the body
  110758. * instead of its head.
  110759. */
  110760. ellipsoidOffset: Vector3;
  110761. /**
  110762. * Enable or disable collisions of the camera with the rest of the scene objects.
  110763. */
  110764. checkCollisions: boolean;
  110765. /**
  110766. * Enable or disable gravity on the camera.
  110767. */
  110768. applyGravity: boolean;
  110769. /**
  110770. * Define the input manager associated to the camera.
  110771. */
  110772. inputs: FreeCameraInputsManager;
  110773. /**
  110774. * Gets the input sensibility for a mouse input. (default is 2000.0)
  110775. * Higher values reduce sensitivity.
  110776. */
  110777. get angularSensibility(): number;
  110778. /**
  110779. * Sets the input sensibility for a mouse input. (default is 2000.0)
  110780. * Higher values reduce sensitivity.
  110781. */
  110782. set angularSensibility(value: number);
  110783. /**
  110784. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  110785. */
  110786. get keysUp(): number[];
  110787. set keysUp(value: number[]);
  110788. /**
  110789. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  110790. */
  110791. get keysUpward(): number[];
  110792. set keysUpward(value: number[]);
  110793. /**
  110794. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  110795. */
  110796. get keysDown(): number[];
  110797. set keysDown(value: number[]);
  110798. /**
  110799. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  110800. */
  110801. get keysDownward(): number[];
  110802. set keysDownward(value: number[]);
  110803. /**
  110804. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  110805. */
  110806. get keysLeft(): number[];
  110807. set keysLeft(value: number[]);
  110808. /**
  110809. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  110810. */
  110811. get keysRight(): number[];
  110812. set keysRight(value: number[]);
  110813. /**
  110814. * Event raised when the camera collide with a mesh in the scene.
  110815. */
  110816. onCollide: (collidedMesh: AbstractMesh) => void;
  110817. private _collider;
  110818. private _needMoveForGravity;
  110819. private _oldPosition;
  110820. private _diffPosition;
  110821. private _newPosition;
  110822. /** @hidden */
  110823. _localDirection: Vector3;
  110824. /** @hidden */
  110825. _transformedDirection: Vector3;
  110826. /**
  110827. * Instantiates a Free Camera.
  110828. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110829. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  110830. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  110831. * @param name Define the name of the camera in the scene
  110832. * @param position Define the start position of the camera in the scene
  110833. * @param scene Define the scene the camera belongs to
  110834. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  110835. */
  110836. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110837. /**
  110838. * Attach the input controls to a specific dom element to get the input from.
  110839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110840. */
  110841. attachControl(noPreventDefault?: boolean): void;
  110842. /**
  110843. * Attach the input controls to a specific dom element to get the input from.
  110844. * @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
  110845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110846. * BACK COMPAT SIGNATURE ONLY.
  110847. */
  110848. attachControl(ignored: any, noPreventDefault?: boolean): void;
  110849. /**
  110850. * Detach the current controls from the specified dom element.
  110851. */
  110852. detachControl(): void;
  110853. /**
  110854. * Detach the current controls from the specified dom element.
  110855. * @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
  110856. */
  110857. detachControl(ignored: any): void;
  110858. private _collisionMask;
  110859. /**
  110860. * Define a collision mask to limit the list of object the camera can collide with
  110861. */
  110862. get collisionMask(): number;
  110863. set collisionMask(mask: number);
  110864. /** @hidden */
  110865. _collideWithWorld(displacement: Vector3): void;
  110866. private _onCollisionPositionChange;
  110867. /** @hidden */
  110868. _checkInputs(): void;
  110869. /** @hidden */
  110870. _decideIfNeedsToMove(): boolean;
  110871. /** @hidden */
  110872. _updatePosition(): void;
  110873. /**
  110874. * Destroy the camera and release the current resources hold by it.
  110875. */
  110876. dispose(): void;
  110877. /**
  110878. * Gets the current object class name.
  110879. * @return the class name
  110880. */
  110881. getClassName(): string;
  110882. }
  110883. }
  110884. declare module BABYLON {
  110885. /**
  110886. * Represents a gamepad control stick position
  110887. */
  110888. export class StickValues {
  110889. /**
  110890. * The x component of the control stick
  110891. */
  110892. x: number;
  110893. /**
  110894. * The y component of the control stick
  110895. */
  110896. y: number;
  110897. /**
  110898. * Initializes the gamepad x and y control stick values
  110899. * @param x The x component of the gamepad control stick value
  110900. * @param y The y component of the gamepad control stick value
  110901. */
  110902. constructor(
  110903. /**
  110904. * The x component of the control stick
  110905. */
  110906. x: number,
  110907. /**
  110908. * The y component of the control stick
  110909. */
  110910. y: number);
  110911. }
  110912. /**
  110913. * An interface which manages callbacks for gamepad button changes
  110914. */
  110915. export interface GamepadButtonChanges {
  110916. /**
  110917. * Called when a gamepad has been changed
  110918. */
  110919. changed: boolean;
  110920. /**
  110921. * Called when a gamepad press event has been triggered
  110922. */
  110923. pressChanged: boolean;
  110924. /**
  110925. * Called when a touch event has been triggered
  110926. */
  110927. touchChanged: boolean;
  110928. /**
  110929. * Called when a value has changed
  110930. */
  110931. valueChanged: boolean;
  110932. }
  110933. /**
  110934. * Represents a gamepad
  110935. */
  110936. export class Gamepad {
  110937. /**
  110938. * The id of the gamepad
  110939. */
  110940. id: string;
  110941. /**
  110942. * The index of the gamepad
  110943. */
  110944. index: number;
  110945. /**
  110946. * The browser gamepad
  110947. */
  110948. browserGamepad: any;
  110949. /**
  110950. * Specifies what type of gamepad this represents
  110951. */
  110952. type: number;
  110953. private _leftStick;
  110954. private _rightStick;
  110955. /** @hidden */
  110956. _isConnected: boolean;
  110957. private _leftStickAxisX;
  110958. private _leftStickAxisY;
  110959. private _rightStickAxisX;
  110960. private _rightStickAxisY;
  110961. /**
  110962. * Triggered when the left control stick has been changed
  110963. */
  110964. private _onleftstickchanged;
  110965. /**
  110966. * Triggered when the right control stick has been changed
  110967. */
  110968. private _onrightstickchanged;
  110969. /**
  110970. * Represents a gamepad controller
  110971. */
  110972. static GAMEPAD: number;
  110973. /**
  110974. * Represents a generic controller
  110975. */
  110976. static GENERIC: number;
  110977. /**
  110978. * Represents an XBox controller
  110979. */
  110980. static XBOX: number;
  110981. /**
  110982. * Represents a pose-enabled controller
  110983. */
  110984. static POSE_ENABLED: number;
  110985. /**
  110986. * Represents an Dual Shock controller
  110987. */
  110988. static DUALSHOCK: number;
  110989. /**
  110990. * Specifies whether the left control stick should be Y-inverted
  110991. */
  110992. protected _invertLeftStickY: boolean;
  110993. /**
  110994. * Specifies if the gamepad has been connected
  110995. */
  110996. get isConnected(): boolean;
  110997. /**
  110998. * Initializes the gamepad
  110999. * @param id The id of the gamepad
  111000. * @param index The index of the gamepad
  111001. * @param browserGamepad The browser gamepad
  111002. * @param leftStickX The x component of the left joystick
  111003. * @param leftStickY The y component of the left joystick
  111004. * @param rightStickX The x component of the right joystick
  111005. * @param rightStickY The y component of the right joystick
  111006. */
  111007. constructor(
  111008. /**
  111009. * The id of the gamepad
  111010. */
  111011. id: string,
  111012. /**
  111013. * The index of the gamepad
  111014. */
  111015. index: number,
  111016. /**
  111017. * The browser gamepad
  111018. */
  111019. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  111020. /**
  111021. * Callback triggered when the left joystick has changed
  111022. * @param callback
  111023. */
  111024. onleftstickchanged(callback: (values: StickValues) => void): void;
  111025. /**
  111026. * Callback triggered when the right joystick has changed
  111027. * @param callback
  111028. */
  111029. onrightstickchanged(callback: (values: StickValues) => void): void;
  111030. /**
  111031. * Gets the left joystick
  111032. */
  111033. get leftStick(): StickValues;
  111034. /**
  111035. * Sets the left joystick values
  111036. */
  111037. set leftStick(newValues: StickValues);
  111038. /**
  111039. * Gets the right joystick
  111040. */
  111041. get rightStick(): StickValues;
  111042. /**
  111043. * Sets the right joystick value
  111044. */
  111045. set rightStick(newValues: StickValues);
  111046. /**
  111047. * Updates the gamepad joystick positions
  111048. */
  111049. update(): void;
  111050. /**
  111051. * Disposes the gamepad
  111052. */
  111053. dispose(): void;
  111054. }
  111055. /**
  111056. * Represents a generic gamepad
  111057. */
  111058. export class GenericPad extends Gamepad {
  111059. private _buttons;
  111060. private _onbuttondown;
  111061. private _onbuttonup;
  111062. /**
  111063. * Observable triggered when a button has been pressed
  111064. */
  111065. onButtonDownObservable: Observable<number>;
  111066. /**
  111067. * Observable triggered when a button has been released
  111068. */
  111069. onButtonUpObservable: Observable<number>;
  111070. /**
  111071. * Callback triggered when a button has been pressed
  111072. * @param callback Called when a button has been pressed
  111073. */
  111074. onbuttondown(callback: (buttonPressed: number) => void): void;
  111075. /**
  111076. * Callback triggered when a button has been released
  111077. * @param callback Called when a button has been released
  111078. */
  111079. onbuttonup(callback: (buttonReleased: number) => void): void;
  111080. /**
  111081. * Initializes the generic gamepad
  111082. * @param id The id of the generic gamepad
  111083. * @param index The index of the generic gamepad
  111084. * @param browserGamepad The browser gamepad
  111085. */
  111086. constructor(id: string, index: number, browserGamepad: any);
  111087. private _setButtonValue;
  111088. /**
  111089. * Updates the generic gamepad
  111090. */
  111091. update(): void;
  111092. /**
  111093. * Disposes the generic gamepad
  111094. */
  111095. dispose(): void;
  111096. }
  111097. }
  111098. declare module BABYLON {
  111099. /**
  111100. * Defines a runtime animation
  111101. */
  111102. export class RuntimeAnimation {
  111103. private _events;
  111104. /**
  111105. * The current frame of the runtime animation
  111106. */
  111107. private _currentFrame;
  111108. /**
  111109. * The animation used by the runtime animation
  111110. */
  111111. private _animation;
  111112. /**
  111113. * The target of the runtime animation
  111114. */
  111115. private _target;
  111116. /**
  111117. * The initiating animatable
  111118. */
  111119. private _host;
  111120. /**
  111121. * The original value of the runtime animation
  111122. */
  111123. private _originalValue;
  111124. /**
  111125. * The original blend value of the runtime animation
  111126. */
  111127. private _originalBlendValue;
  111128. /**
  111129. * The offsets cache of the runtime animation
  111130. */
  111131. private _offsetsCache;
  111132. /**
  111133. * The high limits cache of the runtime animation
  111134. */
  111135. private _highLimitsCache;
  111136. /**
  111137. * Specifies if the runtime animation has been stopped
  111138. */
  111139. private _stopped;
  111140. /**
  111141. * The blending factor of the runtime animation
  111142. */
  111143. private _blendingFactor;
  111144. /**
  111145. * The BabylonJS scene
  111146. */
  111147. private _scene;
  111148. /**
  111149. * The current value of the runtime animation
  111150. */
  111151. private _currentValue;
  111152. /** @hidden */
  111153. _animationState: _IAnimationState;
  111154. /**
  111155. * The active target of the runtime animation
  111156. */
  111157. private _activeTargets;
  111158. private _currentActiveTarget;
  111159. private _directTarget;
  111160. /**
  111161. * The target path of the runtime animation
  111162. */
  111163. private _targetPath;
  111164. /**
  111165. * The weight of the runtime animation
  111166. */
  111167. private _weight;
  111168. /**
  111169. * The ratio offset of the runtime animation
  111170. */
  111171. private _ratioOffset;
  111172. /**
  111173. * The previous delay of the runtime animation
  111174. */
  111175. private _previousDelay;
  111176. /**
  111177. * The previous ratio of the runtime animation
  111178. */
  111179. private _previousRatio;
  111180. private _enableBlending;
  111181. private _keys;
  111182. private _minFrame;
  111183. private _maxFrame;
  111184. private _minValue;
  111185. private _maxValue;
  111186. private _targetIsArray;
  111187. /**
  111188. * Gets the current frame of the runtime animation
  111189. */
  111190. get currentFrame(): number;
  111191. /**
  111192. * Gets the weight of the runtime animation
  111193. */
  111194. get weight(): number;
  111195. /**
  111196. * Gets the current value of the runtime animation
  111197. */
  111198. get currentValue(): any;
  111199. /**
  111200. * Gets the target path of the runtime animation
  111201. */
  111202. get targetPath(): string;
  111203. /**
  111204. * Gets the actual target of the runtime animation
  111205. */
  111206. get target(): any;
  111207. /**
  111208. * Gets the additive state of the runtime animation
  111209. */
  111210. get isAdditive(): boolean;
  111211. /** @hidden */
  111212. _onLoop: () => void;
  111213. /**
  111214. * Create a new RuntimeAnimation object
  111215. * @param target defines the target of the animation
  111216. * @param animation defines the source animation object
  111217. * @param scene defines the hosting scene
  111218. * @param host defines the initiating Animatable
  111219. */
  111220. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  111221. private _preparePath;
  111222. /**
  111223. * Gets the animation from the runtime animation
  111224. */
  111225. get animation(): Animation;
  111226. /**
  111227. * Resets the runtime animation to the beginning
  111228. * @param restoreOriginal defines whether to restore the target property to the original value
  111229. */
  111230. reset(restoreOriginal?: boolean): void;
  111231. /**
  111232. * Specifies if the runtime animation is stopped
  111233. * @returns Boolean specifying if the runtime animation is stopped
  111234. */
  111235. isStopped(): boolean;
  111236. /**
  111237. * Disposes of the runtime animation
  111238. */
  111239. dispose(): void;
  111240. /**
  111241. * Apply the interpolated value to the target
  111242. * @param currentValue defines the value computed by the animation
  111243. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  111244. */
  111245. setValue(currentValue: any, weight: number): void;
  111246. private _getOriginalValues;
  111247. private _setValue;
  111248. /**
  111249. * Gets the loop pmode of the runtime animation
  111250. * @returns Loop Mode
  111251. */
  111252. private _getCorrectLoopMode;
  111253. /**
  111254. * Move the current animation to a given frame
  111255. * @param frame defines the frame to move to
  111256. */
  111257. goToFrame(frame: number): void;
  111258. /**
  111259. * @hidden Internal use only
  111260. */
  111261. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  111262. /**
  111263. * Execute the current animation
  111264. * @param delay defines the delay to add to the current frame
  111265. * @param from defines the lower bound of the animation range
  111266. * @param to defines the upper bound of the animation range
  111267. * @param loop defines if the current animation must loop
  111268. * @param speedRatio defines the current speed ratio
  111269. * @param weight defines the weight of the animation (default is -1 so no weight)
  111270. * @param onLoop optional callback called when animation loops
  111271. * @returns a boolean indicating if the animation is running
  111272. */
  111273. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  111274. }
  111275. }
  111276. declare module BABYLON {
  111277. /**
  111278. * Class used to store an actual running animation
  111279. */
  111280. export class Animatable {
  111281. /** defines the target object */
  111282. target: any;
  111283. /** defines the starting frame number (default is 0) */
  111284. fromFrame: number;
  111285. /** defines the ending frame number (default is 100) */
  111286. toFrame: number;
  111287. /** defines if the animation must loop (default is false) */
  111288. loopAnimation: boolean;
  111289. /** defines a callback to call when animation ends if it is not looping */
  111290. onAnimationEnd?: (() => void) | null | undefined;
  111291. /** defines a callback to call when animation loops */
  111292. onAnimationLoop?: (() => void) | null | undefined;
  111293. /** defines whether the animation should be evaluated additively */
  111294. isAdditive: boolean;
  111295. private _localDelayOffset;
  111296. private _pausedDelay;
  111297. private _runtimeAnimations;
  111298. private _paused;
  111299. private _scene;
  111300. private _speedRatio;
  111301. private _weight;
  111302. private _syncRoot;
  111303. /**
  111304. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  111305. * This will only apply for non looping animation (default is true)
  111306. */
  111307. disposeOnEnd: boolean;
  111308. /**
  111309. * Gets a boolean indicating if the animation has started
  111310. */
  111311. animationStarted: boolean;
  111312. /**
  111313. * Observer raised when the animation ends
  111314. */
  111315. onAnimationEndObservable: Observable<Animatable>;
  111316. /**
  111317. * Observer raised when the animation loops
  111318. */
  111319. onAnimationLoopObservable: Observable<Animatable>;
  111320. /**
  111321. * Gets the root Animatable used to synchronize and normalize animations
  111322. */
  111323. get syncRoot(): Nullable<Animatable>;
  111324. /**
  111325. * Gets the current frame of the first RuntimeAnimation
  111326. * Used to synchronize Animatables
  111327. */
  111328. get masterFrame(): number;
  111329. /**
  111330. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  111331. */
  111332. get weight(): number;
  111333. set weight(value: number);
  111334. /**
  111335. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  111336. */
  111337. get speedRatio(): number;
  111338. set speedRatio(value: number);
  111339. /**
  111340. * Creates a new Animatable
  111341. * @param scene defines the hosting scene
  111342. * @param target defines the target object
  111343. * @param fromFrame defines the starting frame number (default is 0)
  111344. * @param toFrame defines the ending frame number (default is 100)
  111345. * @param loopAnimation defines if the animation must loop (default is false)
  111346. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  111347. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  111348. * @param animations defines a group of animation to add to the new Animatable
  111349. * @param onAnimationLoop defines a callback to call when animation loops
  111350. * @param isAdditive defines whether the animation should be evaluated additively
  111351. */
  111352. constructor(scene: Scene,
  111353. /** defines the target object */
  111354. target: any,
  111355. /** defines the starting frame number (default is 0) */
  111356. fromFrame?: number,
  111357. /** defines the ending frame number (default is 100) */
  111358. toFrame?: number,
  111359. /** defines if the animation must loop (default is false) */
  111360. loopAnimation?: boolean, speedRatio?: number,
  111361. /** defines a callback to call when animation ends if it is not looping */
  111362. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  111363. /** defines a callback to call when animation loops */
  111364. onAnimationLoop?: (() => void) | null | undefined,
  111365. /** defines whether the animation should be evaluated additively */
  111366. isAdditive?: boolean);
  111367. /**
  111368. * Synchronize and normalize current Animatable with a source Animatable
  111369. * This is useful when using animation weights and when animations are not of the same length
  111370. * @param root defines the root Animatable to synchronize with
  111371. * @returns the current Animatable
  111372. */
  111373. syncWith(root: Animatable): Animatable;
  111374. /**
  111375. * Gets the list of runtime animations
  111376. * @returns an array of RuntimeAnimation
  111377. */
  111378. getAnimations(): RuntimeAnimation[];
  111379. /**
  111380. * Adds more animations to the current animatable
  111381. * @param target defines the target of the animations
  111382. * @param animations defines the new animations to add
  111383. */
  111384. appendAnimations(target: any, animations: Animation[]): void;
  111385. /**
  111386. * Gets the source animation for a specific property
  111387. * @param property defines the property to look for
  111388. * @returns null or the source animation for the given property
  111389. */
  111390. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  111391. /**
  111392. * Gets the runtime animation for a specific property
  111393. * @param property defines the property to look for
  111394. * @returns null or the runtime animation for the given property
  111395. */
  111396. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  111397. /**
  111398. * Resets the animatable to its original state
  111399. */
  111400. reset(): void;
  111401. /**
  111402. * Allows the animatable to blend with current running animations
  111403. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  111404. * @param blendingSpeed defines the blending speed to use
  111405. */
  111406. enableBlending(blendingSpeed: number): void;
  111407. /**
  111408. * Disable animation blending
  111409. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  111410. */
  111411. disableBlending(): void;
  111412. /**
  111413. * Jump directly to a given frame
  111414. * @param frame defines the frame to jump to
  111415. */
  111416. goToFrame(frame: number): void;
  111417. /**
  111418. * Pause the animation
  111419. */
  111420. pause(): void;
  111421. /**
  111422. * Restart the animation
  111423. */
  111424. restart(): void;
  111425. private _raiseOnAnimationEnd;
  111426. /**
  111427. * Stop and delete the current animation
  111428. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  111429. * @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)
  111430. */
  111431. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  111432. /**
  111433. * Wait asynchronously for the animation to end
  111434. * @returns a promise which will be fulfilled when the animation ends
  111435. */
  111436. waitAsync(): Promise<Animatable>;
  111437. /** @hidden */
  111438. _animate(delay: number): boolean;
  111439. }
  111440. interface Scene {
  111441. /** @hidden */
  111442. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  111443. /** @hidden */
  111444. _processLateAnimationBindingsForMatrices(holder: {
  111445. totalWeight: number;
  111446. totalAdditiveWeight: number;
  111447. animations: RuntimeAnimation[];
  111448. additiveAnimations: RuntimeAnimation[];
  111449. originalValue: Matrix;
  111450. }): any;
  111451. /** @hidden */
  111452. _processLateAnimationBindingsForQuaternions(holder: {
  111453. totalWeight: number;
  111454. totalAdditiveWeight: number;
  111455. animations: RuntimeAnimation[];
  111456. additiveAnimations: RuntimeAnimation[];
  111457. originalValue: Quaternion;
  111458. }, refQuaternion: Quaternion): Quaternion;
  111459. /** @hidden */
  111460. _processLateAnimationBindings(): void;
  111461. /**
  111462. * Will start the animation sequence of a given target
  111463. * @param target defines the target
  111464. * @param from defines from which frame should animation start
  111465. * @param to defines until which frame should animation run.
  111466. * @param weight defines the weight to apply to the animation (1.0 by default)
  111467. * @param loop defines if the animation loops
  111468. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  111469. * @param onAnimationEnd defines the function to be executed when the animation ends
  111470. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  111471. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  111472. * @param onAnimationLoop defines the callback to call when an animation loops
  111473. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  111474. * @returns the animatable object created for this animation
  111475. */
  111476. 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;
  111477. /**
  111478. * Will start the animation sequence of a given target
  111479. * @param target defines the target
  111480. * @param from defines from which frame should animation start
  111481. * @param to defines until which frame should animation run.
  111482. * @param loop defines if the animation loops
  111483. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  111484. * @param onAnimationEnd defines the function to be executed when the animation ends
  111485. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  111486. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  111487. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  111488. * @param onAnimationLoop defines the callback to call when an animation loops
  111489. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  111490. * @returns the animatable object created for this animation
  111491. */
  111492. 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;
  111493. /**
  111494. * Will start the animation sequence of a given target and its hierarchy
  111495. * @param target defines the target
  111496. * @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.
  111497. * @param from defines from which frame should animation start
  111498. * @param to defines until which frame should animation run.
  111499. * @param loop defines if the animation loops
  111500. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  111501. * @param onAnimationEnd defines the function to be executed when the animation ends
  111502. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  111503. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  111504. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  111505. * @param onAnimationLoop defines the callback to call when an animation loops
  111506. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  111507. * @returns the list of created animatables
  111508. */
  111509. 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[];
  111510. /**
  111511. * Begin a new animation on a given node
  111512. * @param target defines the target where the animation will take place
  111513. * @param animations defines the list of animations to start
  111514. * @param from defines the initial value
  111515. * @param to defines the final value
  111516. * @param loop defines if you want animation to loop (off by default)
  111517. * @param speedRatio defines the speed ratio to apply to all animations
  111518. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  111519. * @param onAnimationLoop defines the callback to call when an animation loops
  111520. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  111521. * @returns the list of created animatables
  111522. */
  111523. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  111524. /**
  111525. * Begin a new animation on a given node and its hierarchy
  111526. * @param target defines the root node where the animation will take place
  111527. * @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.
  111528. * @param animations defines the list of animations to start
  111529. * @param from defines the initial value
  111530. * @param to defines the final value
  111531. * @param loop defines if you want animation to loop (off by default)
  111532. * @param speedRatio defines the speed ratio to apply to all animations
  111533. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  111534. * @param onAnimationLoop defines the callback to call when an animation loops
  111535. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  111536. * @returns the list of animatables created for all nodes
  111537. */
  111538. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  111539. /**
  111540. * Gets the animatable associated with a specific target
  111541. * @param target defines the target of the animatable
  111542. * @returns the required animatable if found
  111543. */
  111544. getAnimatableByTarget(target: any): Nullable<Animatable>;
  111545. /**
  111546. * Gets all animatables associated with a given target
  111547. * @param target defines the target to look animatables for
  111548. * @returns an array of Animatables
  111549. */
  111550. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  111551. /**
  111552. * Stops and removes all animations that have been applied to the scene
  111553. */
  111554. stopAllAnimations(): void;
  111555. /**
  111556. * Gets the current delta time used by animation engine
  111557. */
  111558. deltaTime: number;
  111559. }
  111560. interface Bone {
  111561. /**
  111562. * Copy an animation range from another bone
  111563. * @param source defines the source bone
  111564. * @param rangeName defines the range name to copy
  111565. * @param frameOffset defines the frame offset
  111566. * @param rescaleAsRequired defines if rescaling must be applied if required
  111567. * @param skelDimensionsRatio defines the scaling ratio
  111568. * @returns true if operation was successful
  111569. */
  111570. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  111571. }
  111572. }
  111573. declare module BABYLON {
  111574. /**
  111575. * Class used to override all child animations of a given target
  111576. */
  111577. export class AnimationPropertiesOverride {
  111578. /**
  111579. * Gets or sets a value indicating if animation blending must be used
  111580. */
  111581. enableBlending: boolean;
  111582. /**
  111583. * Gets or sets the blending speed to use when enableBlending is true
  111584. */
  111585. blendingSpeed: number;
  111586. /**
  111587. * Gets or sets the default loop mode to use
  111588. */
  111589. loopMode: number;
  111590. }
  111591. }
  111592. declare module BABYLON {
  111593. /**
  111594. * Class used to handle skinning animations
  111595. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111596. */
  111597. export class Skeleton implements IAnimatable {
  111598. /** defines the skeleton name */
  111599. name: string;
  111600. /** defines the skeleton Id */
  111601. id: string;
  111602. /**
  111603. * Defines the list of child bones
  111604. */
  111605. bones: Bone[];
  111606. /**
  111607. * Defines an estimate of the dimension of the skeleton at rest
  111608. */
  111609. dimensionsAtRest: Vector3;
  111610. /**
  111611. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  111612. */
  111613. needInitialSkinMatrix: boolean;
  111614. /**
  111615. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  111616. */
  111617. overrideMesh: Nullable<AbstractMesh>;
  111618. /**
  111619. * Gets the list of animations attached to this skeleton
  111620. */
  111621. animations: Array<Animation>;
  111622. private _scene;
  111623. private _isDirty;
  111624. private _transformMatrices;
  111625. private _transformMatrixTexture;
  111626. private _meshesWithPoseMatrix;
  111627. private _animatables;
  111628. private _identity;
  111629. private _synchronizedWithMesh;
  111630. private _ranges;
  111631. private _lastAbsoluteTransformsUpdateId;
  111632. private _canUseTextureForBones;
  111633. private _uniqueId;
  111634. /** @hidden */
  111635. _numBonesWithLinkedTransformNode: number;
  111636. /** @hidden */
  111637. _hasWaitingData: Nullable<boolean>;
  111638. /** @hidden */
  111639. _waitingOverrideMeshId: Nullable<string>;
  111640. /**
  111641. * Specifies if the skeleton should be serialized
  111642. */
  111643. doNotSerialize: boolean;
  111644. private _useTextureToStoreBoneMatrices;
  111645. /**
  111646. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  111647. * Please note that this option is not available if the hardware does not support it
  111648. */
  111649. get useTextureToStoreBoneMatrices(): boolean;
  111650. set useTextureToStoreBoneMatrices(value: boolean);
  111651. private _animationPropertiesOverride;
  111652. /**
  111653. * Gets or sets the animation properties override
  111654. */
  111655. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111656. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111657. /**
  111658. * List of inspectable custom properties (used by the Inspector)
  111659. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111660. */
  111661. inspectableCustomProperties: IInspectable[];
  111662. /**
  111663. * An observable triggered before computing the skeleton's matrices
  111664. */
  111665. onBeforeComputeObservable: Observable<Skeleton>;
  111666. /**
  111667. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  111668. */
  111669. get isUsingTextureForMatrices(): boolean;
  111670. /**
  111671. * Gets the unique ID of this skeleton
  111672. */
  111673. get uniqueId(): number;
  111674. /**
  111675. * Creates a new skeleton
  111676. * @param name defines the skeleton name
  111677. * @param id defines the skeleton Id
  111678. * @param scene defines the hosting scene
  111679. */
  111680. constructor(
  111681. /** defines the skeleton name */
  111682. name: string,
  111683. /** defines the skeleton Id */
  111684. id: string, scene: Scene);
  111685. /**
  111686. * Gets the current object class name.
  111687. * @return the class name
  111688. */
  111689. getClassName(): string;
  111690. /**
  111691. * Returns an array containing the root bones
  111692. * @returns an array containing the root bones
  111693. */
  111694. getChildren(): Array<Bone>;
  111695. /**
  111696. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  111697. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  111698. * @returns a Float32Array containing matrices data
  111699. */
  111700. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  111701. /**
  111702. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  111703. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  111704. * @returns a raw texture containing the data
  111705. */
  111706. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  111707. /**
  111708. * Gets the current hosting scene
  111709. * @returns a scene object
  111710. */
  111711. getScene(): Scene;
  111712. /**
  111713. * Gets a string representing the current skeleton data
  111714. * @param fullDetails defines a boolean indicating if we want a verbose version
  111715. * @returns a string representing the current skeleton data
  111716. */
  111717. toString(fullDetails?: boolean): string;
  111718. /**
  111719. * Get bone's index searching by name
  111720. * @param name defines bone's name to search for
  111721. * @return the indice of the bone. Returns -1 if not found
  111722. */
  111723. getBoneIndexByName(name: string): number;
  111724. /**
  111725. * Create a new animation range
  111726. * @param name defines the name of the range
  111727. * @param from defines the start key
  111728. * @param to defines the end key
  111729. */
  111730. createAnimationRange(name: string, from: number, to: number): void;
  111731. /**
  111732. * Delete a specific animation range
  111733. * @param name defines the name of the range
  111734. * @param deleteFrames defines if frames must be removed as well
  111735. */
  111736. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  111737. /**
  111738. * Gets a specific animation range
  111739. * @param name defines the name of the range to look for
  111740. * @returns the requested animation range or null if not found
  111741. */
  111742. getAnimationRange(name: string): Nullable<AnimationRange>;
  111743. /**
  111744. * Gets the list of all animation ranges defined on this skeleton
  111745. * @returns an array
  111746. */
  111747. getAnimationRanges(): Nullable<AnimationRange>[];
  111748. /**
  111749. * Copy animation range from a source skeleton.
  111750. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  111751. * @param source defines the source skeleton
  111752. * @param name defines the name of the range to copy
  111753. * @param rescaleAsRequired defines if rescaling must be applied if required
  111754. * @returns true if operation was successful
  111755. */
  111756. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  111757. /**
  111758. * Forces the skeleton to go to rest pose
  111759. */
  111760. returnToRest(): void;
  111761. private _getHighestAnimationFrame;
  111762. /**
  111763. * Begin a specific animation range
  111764. * @param name defines the name of the range to start
  111765. * @param loop defines if looping must be turned on (false by default)
  111766. * @param speedRatio defines the speed ratio to apply (1 by default)
  111767. * @param onAnimationEnd defines a callback which will be called when animation will end
  111768. * @returns a new animatable
  111769. */
  111770. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  111771. /**
  111772. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  111773. * @param skeleton defines the Skeleton containing the animation range to convert
  111774. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111775. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  111776. * @returns the original skeleton
  111777. */
  111778. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  111779. /** @hidden */
  111780. _markAsDirty(): void;
  111781. /** @hidden */
  111782. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  111783. /** @hidden */
  111784. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  111785. private _computeTransformMatrices;
  111786. /**
  111787. * Build all resources required to render a skeleton
  111788. */
  111789. prepare(): void;
  111790. /**
  111791. * Gets the list of animatables currently running for this skeleton
  111792. * @returns an array of animatables
  111793. */
  111794. getAnimatables(): IAnimatable[];
  111795. /**
  111796. * Clone the current skeleton
  111797. * @param name defines the name of the new skeleton
  111798. * @param id defines the id of the new skeleton
  111799. * @returns the new skeleton
  111800. */
  111801. clone(name: string, id?: string): Skeleton;
  111802. /**
  111803. * Enable animation blending for this skeleton
  111804. * @param blendingSpeed defines the blending speed to apply
  111805. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  111806. */
  111807. enableBlending(blendingSpeed?: number): void;
  111808. /**
  111809. * Releases all resources associated with the current skeleton
  111810. */
  111811. dispose(): void;
  111812. /**
  111813. * Serialize the skeleton in a JSON object
  111814. * @returns a JSON object
  111815. */
  111816. serialize(): any;
  111817. /**
  111818. * Creates a new skeleton from serialized data
  111819. * @param parsedSkeleton defines the serialized data
  111820. * @param scene defines the hosting scene
  111821. * @returns a new skeleton
  111822. */
  111823. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  111824. /**
  111825. * Compute all node absolute transforms
  111826. * @param forceUpdate defines if computation must be done even if cache is up to date
  111827. */
  111828. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  111829. /**
  111830. * Gets the root pose matrix
  111831. * @returns a matrix
  111832. */
  111833. getPoseMatrix(): Nullable<Matrix>;
  111834. /**
  111835. * Sorts bones per internal index
  111836. */
  111837. sortBones(): void;
  111838. private _sortBones;
  111839. /**
  111840. * Set the current local matrix as the restPose for all bones in the skeleton.
  111841. */
  111842. setCurrentPoseAsRest(): void;
  111843. }
  111844. }
  111845. declare module BABYLON {
  111846. /**
  111847. * Class used to store bone information
  111848. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111849. */
  111850. export class Bone extends Node {
  111851. /**
  111852. * defines the bone name
  111853. */
  111854. name: string;
  111855. private static _tmpVecs;
  111856. private static _tmpQuat;
  111857. private static _tmpMats;
  111858. /**
  111859. * Gets the list of child bones
  111860. */
  111861. children: Bone[];
  111862. /** Gets the animations associated with this bone */
  111863. animations: Animation[];
  111864. /**
  111865. * Gets or sets bone length
  111866. */
  111867. length: number;
  111868. /**
  111869. * @hidden Internal only
  111870. * Set this value to map this bone to a different index in the transform matrices
  111871. * Set this value to -1 to exclude the bone from the transform matrices
  111872. */
  111873. _index: Nullable<number>;
  111874. private _skeleton;
  111875. private _localMatrix;
  111876. private _restPose;
  111877. private _bindPose;
  111878. private _baseMatrix;
  111879. private _absoluteTransform;
  111880. private _invertedAbsoluteTransform;
  111881. private _parent;
  111882. private _scalingDeterminant;
  111883. private _worldTransform;
  111884. private _localScaling;
  111885. private _localRotation;
  111886. private _localPosition;
  111887. private _needToDecompose;
  111888. private _needToCompose;
  111889. /** @hidden */
  111890. _linkedTransformNode: Nullable<TransformNode>;
  111891. /** @hidden */
  111892. _waitingTransformNodeId: Nullable<string>;
  111893. /** @hidden */
  111894. get _matrix(): Matrix;
  111895. /** @hidden */
  111896. set _matrix(value: Matrix);
  111897. /**
  111898. * Create a new bone
  111899. * @param name defines the bone name
  111900. * @param skeleton defines the parent skeleton
  111901. * @param parentBone defines the parent (can be null if the bone is the root)
  111902. * @param localMatrix defines the local matrix
  111903. * @param restPose defines the rest pose matrix
  111904. * @param baseMatrix defines the base matrix
  111905. * @param index defines index of the bone in the hierarchy
  111906. */
  111907. constructor(
  111908. /**
  111909. * defines the bone name
  111910. */
  111911. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  111912. /**
  111913. * Gets the current object class name.
  111914. * @return the class name
  111915. */
  111916. getClassName(): string;
  111917. /**
  111918. * Gets the parent skeleton
  111919. * @returns a skeleton
  111920. */
  111921. getSkeleton(): Skeleton;
  111922. /**
  111923. * Gets parent bone
  111924. * @returns a bone or null if the bone is the root of the bone hierarchy
  111925. */
  111926. getParent(): Nullable<Bone>;
  111927. /**
  111928. * Returns an array containing the root bones
  111929. * @returns an array containing the root bones
  111930. */
  111931. getChildren(): Array<Bone>;
  111932. /**
  111933. * Gets the node index in matrix array generated for rendering
  111934. * @returns the node index
  111935. */
  111936. getIndex(): number;
  111937. /**
  111938. * Sets the parent bone
  111939. * @param parent defines the parent (can be null if the bone is the root)
  111940. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  111941. */
  111942. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  111943. /**
  111944. * Gets the local matrix
  111945. * @returns a matrix
  111946. */
  111947. getLocalMatrix(): Matrix;
  111948. /**
  111949. * Gets the base matrix (initial matrix which remains unchanged)
  111950. * @returns a matrix
  111951. */
  111952. getBaseMatrix(): Matrix;
  111953. /**
  111954. * Gets the rest pose matrix
  111955. * @returns a matrix
  111956. */
  111957. getRestPose(): Matrix;
  111958. /**
  111959. * Sets the rest pose matrix
  111960. * @param matrix the local-space rest pose to set for this bone
  111961. */
  111962. setRestPose(matrix: Matrix): void;
  111963. /**
  111964. * Gets the bind pose matrix
  111965. * @returns the bind pose matrix
  111966. */
  111967. getBindPose(): Matrix;
  111968. /**
  111969. * Sets the bind pose matrix
  111970. * @param matrix the local-space bind pose to set for this bone
  111971. */
  111972. setBindPose(matrix: Matrix): void;
  111973. /**
  111974. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  111975. */
  111976. getWorldMatrix(): Matrix;
  111977. /**
  111978. * Sets the local matrix to rest pose matrix
  111979. */
  111980. returnToRest(): void;
  111981. /**
  111982. * Gets the inverse of the absolute transform matrix.
  111983. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  111984. * @returns a matrix
  111985. */
  111986. getInvertedAbsoluteTransform(): Matrix;
  111987. /**
  111988. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  111989. * @returns a matrix
  111990. */
  111991. getAbsoluteTransform(): Matrix;
  111992. /**
  111993. * Links with the given transform node.
  111994. * The local matrix of this bone is copied from the transform node every frame.
  111995. * @param transformNode defines the transform node to link to
  111996. */
  111997. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  111998. /**
  111999. * Gets the node used to drive the bone's transformation
  112000. * @returns a transform node or null
  112001. */
  112002. getTransformNode(): Nullable<TransformNode>;
  112003. /** Gets or sets current position (in local space) */
  112004. get position(): Vector3;
  112005. set position(newPosition: Vector3);
  112006. /** Gets or sets current rotation (in local space) */
  112007. get rotation(): Vector3;
  112008. set rotation(newRotation: Vector3);
  112009. /** Gets or sets current rotation quaternion (in local space) */
  112010. get rotationQuaternion(): Quaternion;
  112011. set rotationQuaternion(newRotation: Quaternion);
  112012. /** Gets or sets current scaling (in local space) */
  112013. get scaling(): Vector3;
  112014. set scaling(newScaling: Vector3);
  112015. /**
  112016. * Gets the animation properties override
  112017. */
  112018. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112019. private _decompose;
  112020. private _compose;
  112021. /**
  112022. * Update the base and local matrices
  112023. * @param matrix defines the new base or local matrix
  112024. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  112025. * @param updateLocalMatrix defines if the local matrix should be updated
  112026. */
  112027. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  112028. /** @hidden */
  112029. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  112030. /**
  112031. * Flag the bone as dirty (Forcing it to update everything)
  112032. */
  112033. markAsDirty(): void;
  112034. /** @hidden */
  112035. _markAsDirtyAndCompose(): void;
  112036. private _markAsDirtyAndDecompose;
  112037. /**
  112038. * Translate the bone in local or world space
  112039. * @param vec The amount to translate the bone
  112040. * @param space The space that the translation is in
  112041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112042. */
  112043. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  112044. /**
  112045. * Set the position of the bone in local or world space
  112046. * @param position The position to set the bone
  112047. * @param space The space that the position is in
  112048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112049. */
  112050. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  112051. /**
  112052. * Set the absolute position of the bone (world space)
  112053. * @param position The position to set the bone
  112054. * @param mesh The mesh that this bone is attached to
  112055. */
  112056. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  112057. /**
  112058. * Scale the bone on the x, y and z axes (in local space)
  112059. * @param x The amount to scale the bone on the x axis
  112060. * @param y The amount to scale the bone on the y axis
  112061. * @param z The amount to scale the bone on the z axis
  112062. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  112063. */
  112064. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  112065. /**
  112066. * Set the bone scaling in local space
  112067. * @param scale defines the scaling vector
  112068. */
  112069. setScale(scale: Vector3): void;
  112070. /**
  112071. * Gets the current scaling in local space
  112072. * @returns the current scaling vector
  112073. */
  112074. getScale(): Vector3;
  112075. /**
  112076. * Gets the current scaling in local space and stores it in a target vector
  112077. * @param result defines the target vector
  112078. */
  112079. getScaleToRef(result: Vector3): void;
  112080. /**
  112081. * Set the yaw, pitch, and roll of the bone in local or world space
  112082. * @param yaw The rotation of the bone on the y axis
  112083. * @param pitch The rotation of the bone on the x axis
  112084. * @param roll The rotation of the bone on the z axis
  112085. * @param space The space that the axes of rotation are in
  112086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112087. */
  112088. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  112089. /**
  112090. * Add a rotation to the bone on an axis in local or world space
  112091. * @param axis The axis to rotate the bone on
  112092. * @param amount The amount to rotate the bone
  112093. * @param space The space that the axis is in
  112094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112095. */
  112096. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  112097. /**
  112098. * Set the rotation of the bone to a particular axis angle in local or world space
  112099. * @param axis The axis to rotate the bone on
  112100. * @param angle The angle that the bone should be rotated to
  112101. * @param space The space that the axis is in
  112102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112103. */
  112104. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  112105. /**
  112106. * Set the euler rotation of the bone in local or world space
  112107. * @param rotation The euler rotation that the bone should be set to
  112108. * @param space The space that the rotation is in
  112109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112110. */
  112111. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  112112. /**
  112113. * Set the quaternion rotation of the bone in local or world space
  112114. * @param quat The quaternion rotation that the bone should be set to
  112115. * @param space The space that the rotation is in
  112116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112117. */
  112118. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  112119. /**
  112120. * Set the rotation matrix of the bone in local or world space
  112121. * @param rotMat The rotation matrix that the bone should be set to
  112122. * @param space The space that the rotation is in
  112123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112124. */
  112125. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  112126. private _rotateWithMatrix;
  112127. private _getNegativeRotationToRef;
  112128. /**
  112129. * Get the position of the bone in local or world space
  112130. * @param space The space that the returned position is in
  112131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112132. * @returns The position of the bone
  112133. */
  112134. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  112135. /**
  112136. * Copy the position of the bone to a vector3 in local or world space
  112137. * @param space The space that the returned position is in
  112138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112139. * @param result The vector3 to copy the position to
  112140. */
  112141. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  112142. /**
  112143. * Get the absolute position of the bone (world space)
  112144. * @param mesh The mesh that this bone is attached to
  112145. * @returns The absolute position of the bone
  112146. */
  112147. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  112148. /**
  112149. * Copy the absolute position of the bone (world space) to the result param
  112150. * @param mesh The mesh that this bone is attached to
  112151. * @param result The vector3 to copy the absolute position to
  112152. */
  112153. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  112154. /**
  112155. * Compute the absolute transforms of this bone and its children
  112156. */
  112157. computeAbsoluteTransforms(): void;
  112158. /**
  112159. * Get the world direction from an axis that is in the local space of the bone
  112160. * @param localAxis The local direction that is used to compute the world direction
  112161. * @param mesh The mesh that this bone is attached to
  112162. * @returns The world direction
  112163. */
  112164. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  112165. /**
  112166. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  112167. * @param localAxis The local direction that is used to compute the world direction
  112168. * @param mesh The mesh that this bone is attached to
  112169. * @param result The vector3 that the world direction will be copied to
  112170. */
  112171. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  112172. /**
  112173. * Get the euler rotation of the bone in local or world space
  112174. * @param space The space that the rotation should be in
  112175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112176. * @returns The euler rotation
  112177. */
  112178. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  112179. /**
  112180. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  112181. * @param space The space that the rotation should be in
  112182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112183. * @param result The vector3 that the rotation should be copied to
  112184. */
  112185. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  112186. /**
  112187. * Get the quaternion rotation of the bone in either local or world space
  112188. * @param space The space that the rotation should be in
  112189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112190. * @returns The quaternion rotation
  112191. */
  112192. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  112193. /**
  112194. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  112195. * @param space The space that the rotation should be in
  112196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112197. * @param result The quaternion that the rotation should be copied to
  112198. */
  112199. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  112200. /**
  112201. * Get the rotation matrix of the bone in local or world space
  112202. * @param space The space that the rotation should be in
  112203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112204. * @returns The rotation matrix
  112205. */
  112206. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  112207. /**
  112208. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  112209. * @param space The space that the rotation should be in
  112210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  112211. * @param result The quaternion that the rotation should be copied to
  112212. */
  112213. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  112214. /**
  112215. * Get the world position of a point that is in the local space of the bone
  112216. * @param position The local position
  112217. * @param mesh The mesh that this bone is attached to
  112218. * @returns The world position
  112219. */
  112220. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  112221. /**
  112222. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  112223. * @param position The local position
  112224. * @param mesh The mesh that this bone is attached to
  112225. * @param result The vector3 that the world position should be copied to
  112226. */
  112227. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  112228. /**
  112229. * Get the local position of a point that is in world space
  112230. * @param position The world position
  112231. * @param mesh The mesh that this bone is attached to
  112232. * @returns The local position
  112233. */
  112234. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  112235. /**
  112236. * Get the local position of a point that is in world space and copy it to the result param
  112237. * @param position The world position
  112238. * @param mesh The mesh that this bone is attached to
  112239. * @param result The vector3 that the local position should be copied to
  112240. */
  112241. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  112242. /**
  112243. * Set the current local matrix as the restPose for this bone.
  112244. */
  112245. setCurrentPoseAsRest(): void;
  112246. }
  112247. }
  112248. declare module BABYLON {
  112249. /**
  112250. * 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.
  112251. * @see https://doc.babylonjs.com/how_to/transformnode
  112252. */
  112253. export class TransformNode extends Node {
  112254. /**
  112255. * Object will not rotate to face the camera
  112256. */
  112257. static BILLBOARDMODE_NONE: number;
  112258. /**
  112259. * Object will rotate to face the camera but only on the x axis
  112260. */
  112261. static BILLBOARDMODE_X: number;
  112262. /**
  112263. * Object will rotate to face the camera but only on the y axis
  112264. */
  112265. static BILLBOARDMODE_Y: number;
  112266. /**
  112267. * Object will rotate to face the camera but only on the z axis
  112268. */
  112269. static BILLBOARDMODE_Z: number;
  112270. /**
  112271. * Object will rotate to face the camera
  112272. */
  112273. static BILLBOARDMODE_ALL: number;
  112274. /**
  112275. * Object will rotate to face the camera's position instead of orientation
  112276. */
  112277. static BILLBOARDMODE_USE_POSITION: number;
  112278. private static _TmpRotation;
  112279. private static _TmpScaling;
  112280. private static _TmpTranslation;
  112281. private _forward;
  112282. private _forwardInverted;
  112283. private _up;
  112284. private _right;
  112285. private _rightInverted;
  112286. private _position;
  112287. private _rotation;
  112288. private _rotationQuaternion;
  112289. protected _scaling: Vector3;
  112290. protected _isDirty: boolean;
  112291. private _transformToBoneReferal;
  112292. private _isAbsoluteSynced;
  112293. private _billboardMode;
  112294. /**
  112295. * Gets or sets the billboard mode. Default is 0.
  112296. *
  112297. * | Value | Type | Description |
  112298. * | --- | --- | --- |
  112299. * | 0 | BILLBOARDMODE_NONE | |
  112300. * | 1 | BILLBOARDMODE_X | |
  112301. * | 2 | BILLBOARDMODE_Y | |
  112302. * | 4 | BILLBOARDMODE_Z | |
  112303. * | 7 | BILLBOARDMODE_ALL | |
  112304. *
  112305. */
  112306. get billboardMode(): number;
  112307. set billboardMode(value: number);
  112308. private _preserveParentRotationForBillboard;
  112309. /**
  112310. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  112311. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  112312. */
  112313. get preserveParentRotationForBillboard(): boolean;
  112314. set preserveParentRotationForBillboard(value: boolean);
  112315. /**
  112316. * 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
  112317. */
  112318. scalingDeterminant: number;
  112319. private _infiniteDistance;
  112320. /**
  112321. * Gets or sets the distance of the object to max, often used by skybox
  112322. */
  112323. get infiniteDistance(): boolean;
  112324. set infiniteDistance(value: boolean);
  112325. /**
  112326. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  112327. * By default the system will update normals to compensate
  112328. */
  112329. ignoreNonUniformScaling: boolean;
  112330. /**
  112331. * 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
  112332. */
  112333. reIntegrateRotationIntoRotationQuaternion: boolean;
  112334. /** @hidden */
  112335. _poseMatrix: Nullable<Matrix>;
  112336. /** @hidden */
  112337. _localMatrix: Matrix;
  112338. private _usePivotMatrix;
  112339. private _absolutePosition;
  112340. private _absoluteScaling;
  112341. private _absoluteRotationQuaternion;
  112342. private _pivotMatrix;
  112343. private _pivotMatrixInverse;
  112344. /** @hidden */
  112345. _postMultiplyPivotMatrix: boolean;
  112346. protected _isWorldMatrixFrozen: boolean;
  112347. /** @hidden */
  112348. _indexInSceneTransformNodesArray: number;
  112349. /**
  112350. * An event triggered after the world matrix is updated
  112351. */
  112352. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  112353. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  112354. /**
  112355. * Gets a string identifying the name of the class
  112356. * @returns "TransformNode" string
  112357. */
  112358. getClassName(): string;
  112359. /**
  112360. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  112361. */
  112362. get position(): Vector3;
  112363. set position(newPosition: Vector3);
  112364. /**
  112365. * 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)).
  112366. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  112367. */
  112368. get rotation(): Vector3;
  112369. set rotation(newRotation: Vector3);
  112370. /**
  112371. * 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)).
  112372. */
  112373. get scaling(): Vector3;
  112374. set scaling(newScaling: Vector3);
  112375. /**
  112376. * 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).
  112377. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  112378. */
  112379. get rotationQuaternion(): Nullable<Quaternion>;
  112380. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  112381. /**
  112382. * The forward direction of that transform in world space.
  112383. */
  112384. get forward(): Vector3;
  112385. /**
  112386. * The up direction of that transform in world space.
  112387. */
  112388. get up(): Vector3;
  112389. /**
  112390. * The right direction of that transform in world space.
  112391. */
  112392. get right(): Vector3;
  112393. /**
  112394. * Copies the parameter passed Matrix into the mesh Pose matrix.
  112395. * @param matrix the matrix to copy the pose from
  112396. * @returns this TransformNode.
  112397. */
  112398. updatePoseMatrix(matrix: Matrix): TransformNode;
  112399. /**
  112400. * Returns the mesh Pose matrix.
  112401. * @returns the pose matrix
  112402. */
  112403. getPoseMatrix(): Matrix;
  112404. /** @hidden */
  112405. _isSynchronized(): boolean;
  112406. /** @hidden */
  112407. _initCache(): void;
  112408. /**
  112409. * Flag the transform node as dirty (Forcing it to update everything)
  112410. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  112411. * @returns this transform node
  112412. */
  112413. markAsDirty(property: string): TransformNode;
  112414. /**
  112415. * Returns the current mesh absolute position.
  112416. * Returns a Vector3.
  112417. */
  112418. get absolutePosition(): Vector3;
  112419. /**
  112420. * Returns the current mesh absolute scaling.
  112421. * Returns a Vector3.
  112422. */
  112423. get absoluteScaling(): Vector3;
  112424. /**
  112425. * Returns the current mesh absolute rotation.
  112426. * Returns a Quaternion.
  112427. */
  112428. get absoluteRotationQuaternion(): Quaternion;
  112429. /**
  112430. * Sets a new matrix to apply before all other transformation
  112431. * @param matrix defines the transform matrix
  112432. * @returns the current TransformNode
  112433. */
  112434. setPreTransformMatrix(matrix: Matrix): TransformNode;
  112435. /**
  112436. * Sets a new pivot matrix to the current node
  112437. * @param matrix defines the new pivot matrix to use
  112438. * @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
  112439. * @returns the current TransformNode
  112440. */
  112441. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  112442. /**
  112443. * Returns the mesh pivot matrix.
  112444. * Default : Identity.
  112445. * @returns the matrix
  112446. */
  112447. getPivotMatrix(): Matrix;
  112448. /**
  112449. * Instantiate (when possible) or clone that node with its hierarchy
  112450. * @param newParent defines the new parent to use for the instance (or clone)
  112451. * @param options defines options to configure how copy is done
  112452. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  112453. * @returns an instance (or a clone) of the current node with its hiearchy
  112454. */
  112455. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  112456. doNotInstantiate: boolean;
  112457. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  112458. /**
  112459. * Prevents the World matrix to be computed any longer
  112460. * @param newWorldMatrix defines an optional matrix to use as world matrix
  112461. * @returns the TransformNode.
  112462. */
  112463. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  112464. /**
  112465. * Allows back the World matrix computation.
  112466. * @returns the TransformNode.
  112467. */
  112468. unfreezeWorldMatrix(): this;
  112469. /**
  112470. * True if the World matrix has been frozen.
  112471. */
  112472. get isWorldMatrixFrozen(): boolean;
  112473. /**
  112474. * Returns the mesh absolute position in the World.
  112475. * @returns a Vector3.
  112476. */
  112477. getAbsolutePosition(): Vector3;
  112478. /**
  112479. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  112480. * @param absolutePosition the absolute position to set
  112481. * @returns the TransformNode.
  112482. */
  112483. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112484. /**
  112485. * Sets the mesh position in its local space.
  112486. * @param vector3 the position to set in localspace
  112487. * @returns the TransformNode.
  112488. */
  112489. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  112490. /**
  112491. * Returns the mesh position in the local space from the current World matrix values.
  112492. * @returns a new Vector3.
  112493. */
  112494. getPositionExpressedInLocalSpace(): Vector3;
  112495. /**
  112496. * Translates the mesh along the passed Vector3 in its local space.
  112497. * @param vector3 the distance to translate in localspace
  112498. * @returns the TransformNode.
  112499. */
  112500. locallyTranslate(vector3: Vector3): TransformNode;
  112501. private static _lookAtVectorCache;
  112502. /**
  112503. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  112504. * @param targetPoint the position (must be in same space as current mesh) to look at
  112505. * @param yawCor optional yaw (y-axis) correction in radians
  112506. * @param pitchCor optional pitch (x-axis) correction in radians
  112507. * @param rollCor optional roll (z-axis) correction in radians
  112508. * @param space the chosen space of the target
  112509. * @returns the TransformNode.
  112510. */
  112511. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  112512. /**
  112513. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  112514. * This Vector3 is expressed in the World space.
  112515. * @param localAxis axis to rotate
  112516. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  112517. */
  112518. getDirection(localAxis: Vector3): Vector3;
  112519. /**
  112520. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  112521. * localAxis is expressed in the mesh local space.
  112522. * result is computed in the Wordl space from the mesh World matrix.
  112523. * @param localAxis axis to rotate
  112524. * @param result the resulting transformnode
  112525. * @returns this TransformNode.
  112526. */
  112527. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  112528. /**
  112529. * Sets this transform node rotation to the given local axis.
  112530. * @param localAxis the axis in local space
  112531. * @param yawCor optional yaw (y-axis) correction in radians
  112532. * @param pitchCor optional pitch (x-axis) correction in radians
  112533. * @param rollCor optional roll (z-axis) correction in radians
  112534. * @returns this TransformNode
  112535. */
  112536. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  112537. /**
  112538. * Sets a new pivot point to the current node
  112539. * @param point defines the new pivot point to use
  112540. * @param space defines if the point is in world or local space (local by default)
  112541. * @returns the current TransformNode
  112542. */
  112543. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  112544. /**
  112545. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  112546. * @returns the pivot point
  112547. */
  112548. getPivotPoint(): Vector3;
  112549. /**
  112550. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  112551. * @param result the vector3 to store the result
  112552. * @returns this TransformNode.
  112553. */
  112554. getPivotPointToRef(result: Vector3): TransformNode;
  112555. /**
  112556. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  112557. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  112558. */
  112559. getAbsolutePivotPoint(): Vector3;
  112560. /**
  112561. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  112562. * @param result vector3 to store the result
  112563. * @returns this TransformNode.
  112564. */
  112565. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  112566. /**
  112567. * Defines the passed node as the parent of the current node.
  112568. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  112569. * @see https://doc.babylonjs.com/how_to/parenting
  112570. * @param node the node ot set as the parent
  112571. * @returns this TransformNode.
  112572. */
  112573. setParent(node: Nullable<Node>): TransformNode;
  112574. private _nonUniformScaling;
  112575. /**
  112576. * True if the scaling property of this object is non uniform eg. (1,2,1)
  112577. */
  112578. get nonUniformScaling(): boolean;
  112579. /** @hidden */
  112580. _updateNonUniformScalingState(value: boolean): boolean;
  112581. /**
  112582. * Attach the current TransformNode to another TransformNode associated with a bone
  112583. * @param bone Bone affecting the TransformNode
  112584. * @param affectedTransformNode TransformNode associated with the bone
  112585. * @returns this object
  112586. */
  112587. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  112588. /**
  112589. * Detach the transform node if its associated with a bone
  112590. * @returns this object
  112591. */
  112592. detachFromBone(): TransformNode;
  112593. private static _rotationAxisCache;
  112594. /**
  112595. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  112596. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  112597. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  112598. * The passed axis is also normalized.
  112599. * @param axis the axis to rotate around
  112600. * @param amount the amount to rotate in radians
  112601. * @param space Space to rotate in (Default: local)
  112602. * @returns the TransformNode.
  112603. */
  112604. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112605. /**
  112606. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  112607. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  112608. * The passed axis is also normalized. .
  112609. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  112610. * @param point the point to rotate around
  112611. * @param axis the axis to rotate around
  112612. * @param amount the amount to rotate in radians
  112613. * @returns the TransformNode
  112614. */
  112615. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  112616. /**
  112617. * Translates the mesh along the axis vector for the passed distance in the given space.
  112618. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  112619. * @param axis the axis to translate in
  112620. * @param distance the distance to translate
  112621. * @param space Space to rotate in (Default: local)
  112622. * @returns the TransformNode.
  112623. */
  112624. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112625. /**
  112626. * Adds a rotation step to the mesh current rotation.
  112627. * x, y, z are Euler angles expressed in radians.
  112628. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  112629. * This means this rotation is made in the mesh local space only.
  112630. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  112631. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  112632. * ```javascript
  112633. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  112634. * ```
  112635. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  112636. * 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.
  112637. * @param x Rotation to add
  112638. * @param y Rotation to add
  112639. * @param z Rotation to add
  112640. * @returns the TransformNode.
  112641. */
  112642. addRotation(x: number, y: number, z: number): TransformNode;
  112643. /**
  112644. * @hidden
  112645. */
  112646. protected _getEffectiveParent(): Nullable<Node>;
  112647. /**
  112648. * Computes the world matrix of the node
  112649. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112650. * @returns the world matrix
  112651. */
  112652. computeWorldMatrix(force?: boolean): Matrix;
  112653. /**
  112654. * Resets this nodeTransform's local matrix to Matrix.Identity().
  112655. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  112656. */
  112657. resetLocalMatrix(independentOfChildren?: boolean): void;
  112658. protected _afterComputeWorldMatrix(): void;
  112659. /**
  112660. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  112661. * @param func callback function to add
  112662. *
  112663. * @returns the TransformNode.
  112664. */
  112665. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  112666. /**
  112667. * Removes a registered callback function.
  112668. * @param func callback function to remove
  112669. * @returns the TransformNode.
  112670. */
  112671. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  112672. /**
  112673. * Gets the position of the current mesh in camera space
  112674. * @param camera defines the camera to use
  112675. * @returns a position
  112676. */
  112677. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  112678. /**
  112679. * Returns the distance from the mesh to the active camera
  112680. * @param camera defines the camera to use
  112681. * @returns the distance
  112682. */
  112683. getDistanceToCamera(camera?: Nullable<Camera>): number;
  112684. /**
  112685. * Clone the current transform node
  112686. * @param name Name of the new clone
  112687. * @param newParent New parent for the clone
  112688. * @param doNotCloneChildren Do not clone children hierarchy
  112689. * @returns the new transform node
  112690. */
  112691. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  112692. /**
  112693. * Serializes the objects information.
  112694. * @param currentSerializationObject defines the object to serialize in
  112695. * @returns the serialized object
  112696. */
  112697. serialize(currentSerializationObject?: any): any;
  112698. /**
  112699. * Returns a new TransformNode object parsed from the source provided.
  112700. * @param parsedTransformNode is the source.
  112701. * @param scene the scene the object belongs to
  112702. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  112703. * @returns a new TransformNode object parsed from the source provided.
  112704. */
  112705. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  112706. /**
  112707. * Get all child-transformNodes of this node
  112708. * @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
  112709. * @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
  112710. * @returns an array of TransformNode
  112711. */
  112712. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  112713. /**
  112714. * Releases resources associated with this transform node.
  112715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112717. */
  112718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112719. /**
  112720. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112721. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112722. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112723. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112724. * @returns the current mesh
  112725. */
  112726. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  112727. private _syncAbsoluteScalingAndRotation;
  112728. }
  112729. }
  112730. declare module BABYLON {
  112731. /**
  112732. * Defines the types of pose enabled controllers that are supported
  112733. */
  112734. export enum PoseEnabledControllerType {
  112735. /**
  112736. * HTC Vive
  112737. */
  112738. VIVE = 0,
  112739. /**
  112740. * Oculus Rift
  112741. */
  112742. OCULUS = 1,
  112743. /**
  112744. * Windows mixed reality
  112745. */
  112746. WINDOWS = 2,
  112747. /**
  112748. * Samsung gear VR
  112749. */
  112750. GEAR_VR = 3,
  112751. /**
  112752. * Google Daydream
  112753. */
  112754. DAYDREAM = 4,
  112755. /**
  112756. * Generic
  112757. */
  112758. GENERIC = 5
  112759. }
  112760. /**
  112761. * Defines the MutableGamepadButton interface for the state of a gamepad button
  112762. */
  112763. export interface MutableGamepadButton {
  112764. /**
  112765. * Value of the button/trigger
  112766. */
  112767. value: number;
  112768. /**
  112769. * If the button/trigger is currently touched
  112770. */
  112771. touched: boolean;
  112772. /**
  112773. * If the button/trigger is currently pressed
  112774. */
  112775. pressed: boolean;
  112776. }
  112777. /**
  112778. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  112779. * @hidden
  112780. */
  112781. export interface ExtendedGamepadButton extends GamepadButton {
  112782. /**
  112783. * If the button/trigger is currently pressed
  112784. */
  112785. readonly pressed: boolean;
  112786. /**
  112787. * If the button/trigger is currently touched
  112788. */
  112789. readonly touched: boolean;
  112790. /**
  112791. * Value of the button/trigger
  112792. */
  112793. readonly value: number;
  112794. }
  112795. /** @hidden */
  112796. export interface _GamePadFactory {
  112797. /**
  112798. * Returns whether or not the current gamepad can be created for this type of controller.
  112799. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  112800. * @returns true if it can be created, otherwise false
  112801. */
  112802. canCreate(gamepadInfo: any): boolean;
  112803. /**
  112804. * Creates a new instance of the Gamepad.
  112805. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  112806. * @returns the new gamepad instance
  112807. */
  112808. create(gamepadInfo: any): Gamepad;
  112809. }
  112810. /**
  112811. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  112812. */
  112813. export class PoseEnabledControllerHelper {
  112814. /** @hidden */
  112815. static _ControllerFactories: _GamePadFactory[];
  112816. /** @hidden */
  112817. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  112818. /**
  112819. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  112820. * @param vrGamepad the gamepad to initialized
  112821. * @returns a vr controller of the type the gamepad identified as
  112822. */
  112823. static InitiateController(vrGamepad: any): Gamepad;
  112824. }
  112825. /**
  112826. * Defines the PoseEnabledController object that contains state of a vr capable controller
  112827. */
  112828. export class PoseEnabledController extends Gamepad implements PoseControlled {
  112829. /**
  112830. * If the controller is used in a webXR session
  112831. */
  112832. isXR: boolean;
  112833. private _deviceRoomPosition;
  112834. private _deviceRoomRotationQuaternion;
  112835. /**
  112836. * The device position in babylon space
  112837. */
  112838. devicePosition: Vector3;
  112839. /**
  112840. * The device rotation in babylon space
  112841. */
  112842. deviceRotationQuaternion: Quaternion;
  112843. /**
  112844. * The scale factor of the device in babylon space
  112845. */
  112846. deviceScaleFactor: number;
  112847. /**
  112848. * (Likely devicePosition should be used instead) The device position in its room space
  112849. */
  112850. position: Vector3;
  112851. /**
  112852. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  112853. */
  112854. rotationQuaternion: Quaternion;
  112855. /**
  112856. * The type of controller (Eg. Windows mixed reality)
  112857. */
  112858. controllerType: PoseEnabledControllerType;
  112859. protected _calculatedPosition: Vector3;
  112860. private _calculatedRotation;
  112861. /**
  112862. * The raw pose from the device
  112863. */
  112864. rawPose: DevicePose;
  112865. private _trackPosition;
  112866. private _maxRotationDistFromHeadset;
  112867. private _draggedRoomRotation;
  112868. /**
  112869. * @hidden
  112870. */
  112871. _disableTrackPosition(fixedPosition: Vector3): void;
  112872. /**
  112873. * Internal, the mesh attached to the controller
  112874. * @hidden
  112875. */
  112876. _mesh: Nullable<AbstractMesh>;
  112877. private _poseControlledCamera;
  112878. private _leftHandSystemQuaternion;
  112879. /**
  112880. * Internal, matrix used to convert room space to babylon space
  112881. * @hidden
  112882. */
  112883. _deviceToWorld: Matrix;
  112884. /**
  112885. * Node to be used when casting a ray from the controller
  112886. * @hidden
  112887. */
  112888. _pointingPoseNode: Nullable<TransformNode>;
  112889. /**
  112890. * Name of the child mesh that can be used to cast a ray from the controller
  112891. */
  112892. static readonly POINTING_POSE: string;
  112893. /**
  112894. * Creates a new PoseEnabledController from a gamepad
  112895. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  112896. */
  112897. constructor(browserGamepad: any);
  112898. private _workingMatrix;
  112899. /**
  112900. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  112901. */
  112902. update(): void;
  112903. /**
  112904. * Updates only the pose device and mesh without doing any button event checking
  112905. */
  112906. protected _updatePoseAndMesh(): void;
  112907. /**
  112908. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  112909. * @param poseData raw pose fromthe device
  112910. */
  112911. updateFromDevice(poseData: DevicePose): void;
  112912. /**
  112913. * @hidden
  112914. */
  112915. _meshAttachedObservable: Observable<AbstractMesh>;
  112916. /**
  112917. * Attaches a mesh to the controller
  112918. * @param mesh the mesh to be attached
  112919. */
  112920. attachToMesh(mesh: AbstractMesh): void;
  112921. /**
  112922. * Attaches the controllers mesh to a camera
  112923. * @param camera the camera the mesh should be attached to
  112924. */
  112925. attachToPoseControlledCamera(camera: TargetCamera): void;
  112926. /**
  112927. * Disposes of the controller
  112928. */
  112929. dispose(): void;
  112930. /**
  112931. * The mesh that is attached to the controller
  112932. */
  112933. get mesh(): Nullable<AbstractMesh>;
  112934. /**
  112935. * Gets the ray of the controller in the direction the controller is pointing
  112936. * @param length the length the resulting ray should be
  112937. * @returns a ray in the direction the controller is pointing
  112938. */
  112939. getForwardRay(length?: number): Ray;
  112940. }
  112941. }
  112942. declare module BABYLON {
  112943. /**
  112944. * Defines the WebVRController object that represents controllers tracked in 3D space
  112945. */
  112946. export abstract class WebVRController extends PoseEnabledController {
  112947. /**
  112948. * Internal, the default controller model for the controller
  112949. */
  112950. protected _defaultModel: Nullable<AbstractMesh>;
  112951. /**
  112952. * Fired when the trigger state has changed
  112953. */
  112954. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  112955. /**
  112956. * Fired when the main button state has changed
  112957. */
  112958. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112959. /**
  112960. * Fired when the secondary button state has changed
  112961. */
  112962. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112963. /**
  112964. * Fired when the pad state has changed
  112965. */
  112966. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  112967. /**
  112968. * Fired when controllers stick values have changed
  112969. */
  112970. onPadValuesChangedObservable: Observable<StickValues>;
  112971. /**
  112972. * Array of button availible on the controller
  112973. */
  112974. protected _buttons: Array<MutableGamepadButton>;
  112975. private _onButtonStateChange;
  112976. /**
  112977. * Fired when a controller button's state has changed
  112978. * @param callback the callback containing the button that was modified
  112979. */
  112980. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  112981. /**
  112982. * X and Y axis corresponding to the controllers joystick
  112983. */
  112984. pad: StickValues;
  112985. /**
  112986. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  112987. */
  112988. hand: string;
  112989. /**
  112990. * The default controller model for the controller
  112991. */
  112992. get defaultModel(): Nullable<AbstractMesh>;
  112993. /**
  112994. * Creates a new WebVRController from a gamepad
  112995. * @param vrGamepad the gamepad that the WebVRController should be created from
  112996. */
  112997. constructor(vrGamepad: any);
  112998. /**
  112999. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  113000. */
  113001. update(): void;
  113002. /**
  113003. * Function to be called when a button is modified
  113004. */
  113005. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113006. /**
  113007. * Loads a mesh and attaches it to the controller
  113008. * @param scene the scene the mesh should be added to
  113009. * @param meshLoaded callback for when the mesh has been loaded
  113010. */
  113011. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113012. private _setButtonValue;
  113013. private _changes;
  113014. private _checkChanges;
  113015. /**
  113016. * Disposes of th webVRCOntroller
  113017. */
  113018. dispose(): void;
  113019. }
  113020. }
  113021. declare module BABYLON {
  113022. /**
  113023. * The HemisphericLight simulates the ambient environment light,
  113024. * so the passed direction is the light reflection direction, not the incoming direction.
  113025. */
  113026. export class HemisphericLight extends Light {
  113027. /**
  113028. * The groundColor is the light in the opposite direction to the one specified during creation.
  113029. * 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.
  113030. */
  113031. groundColor: Color3;
  113032. /**
  113033. * The light reflection direction, not the incoming direction.
  113034. */
  113035. direction: Vector3;
  113036. /**
  113037. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  113038. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  113039. * The HemisphericLight can't cast shadows.
  113040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113041. * @param name The friendly name of the light
  113042. * @param direction The direction of the light reflection
  113043. * @param scene The scene the light belongs to
  113044. */
  113045. constructor(name: string, direction: Vector3, scene: Scene);
  113046. protected _buildUniformLayout(): void;
  113047. /**
  113048. * Returns the string "HemisphericLight".
  113049. * @return The class name
  113050. */
  113051. getClassName(): string;
  113052. /**
  113053. * Sets the HemisphericLight direction towards the passed target (Vector3).
  113054. * Returns the updated direction.
  113055. * @param target The target the direction should point to
  113056. * @return The computed direction
  113057. */
  113058. setDirectionToTarget(target: Vector3): Vector3;
  113059. /**
  113060. * Returns the shadow generator associated to the light.
  113061. * @returns Always null for hemispheric lights because it does not support shadows.
  113062. */
  113063. getShadowGenerator(): Nullable<IShadowGenerator>;
  113064. /**
  113065. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  113066. * @param effect The effect to update
  113067. * @param lightIndex The index of the light in the effect to update
  113068. * @returns The hemispheric light
  113069. */
  113070. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  113071. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113072. /**
  113073. * Computes the world matrix of the node
  113074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113075. * @param useWasUpdatedFlag defines a reserved property
  113076. * @returns the world matrix
  113077. */
  113078. computeWorldMatrix(): Matrix;
  113079. /**
  113080. * Returns the integer 3.
  113081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113082. */
  113083. getTypeID(): number;
  113084. /**
  113085. * Prepares the list of defines specific to the light type.
  113086. * @param defines the list of defines
  113087. * @param lightIndex defines the index of the light for the effect
  113088. */
  113089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113090. }
  113091. }
  113092. declare module BABYLON {
  113093. /** @hidden */
  113094. export var vrMultiviewToSingleviewPixelShader: {
  113095. name: string;
  113096. shader: string;
  113097. };
  113098. }
  113099. declare module BABYLON {
  113100. /**
  113101. * Renders to multiple views with a single draw call
  113102. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  113103. */
  113104. export class MultiviewRenderTarget extends RenderTargetTexture {
  113105. /**
  113106. * Creates a multiview render target
  113107. * @param scene scene used with the render target
  113108. * @param size the size of the render target (used for each view)
  113109. */
  113110. constructor(scene: Scene, size?: number | {
  113111. width: number;
  113112. height: number;
  113113. } | {
  113114. ratio: number;
  113115. });
  113116. /**
  113117. * @hidden
  113118. * @param faceIndex the face index, if its a cube texture
  113119. */
  113120. _bindFrameBuffer(faceIndex?: number): void;
  113121. /**
  113122. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  113123. * @returns the view count
  113124. */
  113125. getViewCount(): number;
  113126. }
  113127. }
  113128. declare module BABYLON {
  113129. interface Engine {
  113130. /**
  113131. * Creates a new multiview render target
  113132. * @param width defines the width of the texture
  113133. * @param height defines the height of the texture
  113134. * @returns the created multiview texture
  113135. */
  113136. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  113137. /**
  113138. * Binds a multiview framebuffer to be drawn to
  113139. * @param multiviewTexture texture to bind
  113140. */
  113141. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  113142. }
  113143. interface Camera {
  113144. /**
  113145. * @hidden
  113146. * 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)
  113147. */
  113148. _useMultiviewToSingleView: boolean;
  113149. /**
  113150. * @hidden
  113151. * 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)
  113152. */
  113153. _multiviewTexture: Nullable<RenderTargetTexture>;
  113154. /**
  113155. * @hidden
  113156. * ensures the multiview texture of the camera exists and has the specified width/height
  113157. * @param width height to set on the multiview texture
  113158. * @param height width to set on the multiview texture
  113159. */
  113160. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  113161. }
  113162. interface Scene {
  113163. /** @hidden */
  113164. _transformMatrixR: Matrix;
  113165. /** @hidden */
  113166. _multiviewSceneUbo: Nullable<UniformBuffer>;
  113167. /** @hidden */
  113168. _createMultiviewUbo(): void;
  113169. /** @hidden */
  113170. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  113171. /** @hidden */
  113172. _renderMultiviewToSingleView(camera: Camera): void;
  113173. }
  113174. }
  113175. declare module BABYLON {
  113176. /**
  113177. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  113178. * This will not be used for webXR as it supports displaying texture arrays directly
  113179. */
  113180. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  113181. /**
  113182. * Gets a string identifying the name of the class
  113183. * @returns "VRMultiviewToSingleviewPostProcess" string
  113184. */
  113185. getClassName(): string;
  113186. /**
  113187. * Initializes a VRMultiviewToSingleview
  113188. * @param name name of the post process
  113189. * @param camera camera to be applied to
  113190. * @param scaleFactor scaling factor to the size of the output texture
  113191. */
  113192. constructor(name: string, camera: Camera, scaleFactor: number);
  113193. }
  113194. }
  113195. declare module BABYLON {
  113196. /**
  113197. * Interface used to define additional presentation attributes
  113198. */
  113199. export interface IVRPresentationAttributes {
  113200. /**
  113201. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  113202. */
  113203. highRefreshRate: boolean;
  113204. /**
  113205. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  113206. */
  113207. foveationLevel: number;
  113208. }
  113209. interface Engine {
  113210. /** @hidden */
  113211. _vrDisplay: any;
  113212. /** @hidden */
  113213. _vrSupported: boolean;
  113214. /** @hidden */
  113215. _oldSize: Size;
  113216. /** @hidden */
  113217. _oldHardwareScaleFactor: number;
  113218. /** @hidden */
  113219. _vrExclusivePointerMode: boolean;
  113220. /** @hidden */
  113221. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  113222. /** @hidden */
  113223. _onVRDisplayPointerRestricted: () => void;
  113224. /** @hidden */
  113225. _onVRDisplayPointerUnrestricted: () => void;
  113226. /** @hidden */
  113227. _onVrDisplayConnect: Nullable<(display: any) => void>;
  113228. /** @hidden */
  113229. _onVrDisplayDisconnect: Nullable<() => void>;
  113230. /** @hidden */
  113231. _onVrDisplayPresentChange: Nullable<() => void>;
  113232. /**
  113233. * Observable signaled when VR display mode changes
  113234. */
  113235. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  113236. /**
  113237. * Observable signaled when VR request present is complete
  113238. */
  113239. onVRRequestPresentComplete: Observable<boolean>;
  113240. /**
  113241. * Observable signaled when VR request present starts
  113242. */
  113243. onVRRequestPresentStart: Observable<Engine>;
  113244. /**
  113245. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  113246. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  113247. */
  113248. isInVRExclusivePointerMode: boolean;
  113249. /**
  113250. * Gets a boolean indicating if a webVR device was detected
  113251. * @returns true if a webVR device was detected
  113252. */
  113253. isVRDevicePresent(): boolean;
  113254. /**
  113255. * Gets the current webVR device
  113256. * @returns the current webVR device (or null)
  113257. */
  113258. getVRDevice(): any;
  113259. /**
  113260. * Initializes a webVR display and starts listening to display change events
  113261. * The onVRDisplayChangedObservable will be notified upon these changes
  113262. * @returns A promise containing a VRDisplay and if vr is supported
  113263. */
  113264. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  113265. /** @hidden */
  113266. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  113267. /**
  113268. * Gets or sets the presentation attributes used to configure VR rendering
  113269. */
  113270. vrPresentationAttributes?: IVRPresentationAttributes;
  113271. /**
  113272. * Call this function to switch to webVR mode
  113273. * Will do nothing if webVR is not supported or if there is no webVR device
  113274. * @param options the webvr options provided to the camera. mainly used for multiview
  113275. * @see https://doc.babylonjs.com/how_to/webvr_camera
  113276. */
  113277. enableVR(options: WebVROptions): void;
  113278. /** @hidden */
  113279. _onVRFullScreenTriggered(): void;
  113280. }
  113281. }
  113282. declare module BABYLON {
  113283. /**
  113284. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  113285. * IMPORTANT!! The data is right-hand data.
  113286. * @export
  113287. * @interface DevicePose
  113288. */
  113289. export interface DevicePose {
  113290. /**
  113291. * The position of the device, values in array are [x,y,z].
  113292. */
  113293. readonly position: Nullable<Float32Array>;
  113294. /**
  113295. * The linearVelocity of the device, values in array are [x,y,z].
  113296. */
  113297. readonly linearVelocity: Nullable<Float32Array>;
  113298. /**
  113299. * The linearAcceleration of the device, values in array are [x,y,z].
  113300. */
  113301. readonly linearAcceleration: Nullable<Float32Array>;
  113302. /**
  113303. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  113304. */
  113305. readonly orientation: Nullable<Float32Array>;
  113306. /**
  113307. * The angularVelocity of the device, values in array are [x,y,z].
  113308. */
  113309. readonly angularVelocity: Nullable<Float32Array>;
  113310. /**
  113311. * The angularAcceleration of the device, values in array are [x,y,z].
  113312. */
  113313. readonly angularAcceleration: Nullable<Float32Array>;
  113314. }
  113315. /**
  113316. * Interface representing a pose controlled object in Babylon.
  113317. * A pose controlled object has both regular pose values as well as pose values
  113318. * from an external device such as a VR head mounted display
  113319. */
  113320. export interface PoseControlled {
  113321. /**
  113322. * The position of the object in babylon space.
  113323. */
  113324. position: Vector3;
  113325. /**
  113326. * The rotation quaternion of the object in babylon space.
  113327. */
  113328. rotationQuaternion: Quaternion;
  113329. /**
  113330. * The position of the device in babylon space.
  113331. */
  113332. devicePosition?: Vector3;
  113333. /**
  113334. * The rotation quaternion of the device in babylon space.
  113335. */
  113336. deviceRotationQuaternion: Quaternion;
  113337. /**
  113338. * The raw pose coming from the device.
  113339. */
  113340. rawPose: Nullable<DevicePose>;
  113341. /**
  113342. * The scale of the device to be used when translating from device space to babylon space.
  113343. */
  113344. deviceScaleFactor: number;
  113345. /**
  113346. * Updates the poseControlled values based on the input device pose.
  113347. * @param poseData the pose data to update the object with
  113348. */
  113349. updateFromDevice(poseData: DevicePose): void;
  113350. }
  113351. /**
  113352. * Set of options to customize the webVRCamera
  113353. */
  113354. export interface WebVROptions {
  113355. /**
  113356. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  113357. */
  113358. trackPosition?: boolean;
  113359. /**
  113360. * Sets the scale of the vrDevice in babylon space. (default: 1)
  113361. */
  113362. positionScale?: number;
  113363. /**
  113364. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  113365. */
  113366. displayName?: string;
  113367. /**
  113368. * Should the native controller meshes be initialized. (default: true)
  113369. */
  113370. controllerMeshes?: boolean;
  113371. /**
  113372. * Creating a default HemiLight only on controllers. (default: true)
  113373. */
  113374. defaultLightingOnControllers?: boolean;
  113375. /**
  113376. * If you don't want to use the default VR button of the helper. (default: false)
  113377. */
  113378. useCustomVRButton?: boolean;
  113379. /**
  113380. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  113381. */
  113382. customVRButton?: HTMLButtonElement;
  113383. /**
  113384. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  113385. */
  113386. rayLength?: number;
  113387. /**
  113388. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  113389. */
  113390. defaultHeight?: number;
  113391. /**
  113392. * If multiview should be used if available (default: false)
  113393. */
  113394. useMultiview?: boolean;
  113395. }
  113396. /**
  113397. * This represents a WebVR camera.
  113398. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  113399. * @example https://doc.babylonjs.com/how_to/webvr_camera
  113400. */
  113401. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  113402. private webVROptions;
  113403. /**
  113404. * @hidden
  113405. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  113406. */
  113407. _vrDevice: any;
  113408. /**
  113409. * The rawPose of the vrDevice.
  113410. */
  113411. rawPose: Nullable<DevicePose>;
  113412. private _onVREnabled;
  113413. private _specsVersion;
  113414. private _attached;
  113415. private _frameData;
  113416. protected _descendants: Array<Node>;
  113417. private _deviceRoomPosition;
  113418. /** @hidden */
  113419. _deviceRoomRotationQuaternion: Quaternion;
  113420. private _standingMatrix;
  113421. /**
  113422. * Represents device position in babylon space.
  113423. */
  113424. devicePosition: Vector3;
  113425. /**
  113426. * Represents device rotation in babylon space.
  113427. */
  113428. deviceRotationQuaternion: Quaternion;
  113429. /**
  113430. * The scale of the device to be used when translating from device space to babylon space.
  113431. */
  113432. deviceScaleFactor: number;
  113433. private _deviceToWorld;
  113434. private _worldToDevice;
  113435. /**
  113436. * References to the webVR controllers for the vrDevice.
  113437. */
  113438. controllers: Array<WebVRController>;
  113439. /**
  113440. * Emits an event when a controller is attached.
  113441. */
  113442. onControllersAttachedObservable: Observable<WebVRController[]>;
  113443. /**
  113444. * Emits an event when a controller's mesh has been loaded;
  113445. */
  113446. onControllerMeshLoadedObservable: Observable<WebVRController>;
  113447. /**
  113448. * Emits an event when the HMD's pose has been updated.
  113449. */
  113450. onPoseUpdatedFromDeviceObservable: Observable<any>;
  113451. private _poseSet;
  113452. /**
  113453. * If the rig cameras be used as parent instead of this camera.
  113454. */
  113455. rigParenting: boolean;
  113456. private _lightOnControllers;
  113457. private _defaultHeight?;
  113458. /**
  113459. * Instantiates a WebVRFreeCamera.
  113460. * @param name The name of the WebVRFreeCamera
  113461. * @param position The starting anchor position for the camera
  113462. * @param scene The scene the camera belongs to
  113463. * @param webVROptions a set of customizable options for the webVRCamera
  113464. */
  113465. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  113466. /**
  113467. * Gets the device distance from the ground in meters.
  113468. * @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.
  113469. */
  113470. deviceDistanceToRoomGround(): number;
  113471. /**
  113472. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  113473. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  113474. */
  113475. useStandingMatrix(callback?: (bool: boolean) => void): void;
  113476. /**
  113477. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  113478. * @returns A promise with a boolean set to if the standing matrix is supported.
  113479. */
  113480. useStandingMatrixAsync(): Promise<boolean>;
  113481. /**
  113482. * Disposes the camera
  113483. */
  113484. dispose(): void;
  113485. /**
  113486. * Gets a vrController by name.
  113487. * @param name The name of the controller to retreive
  113488. * @returns the controller matching the name specified or null if not found
  113489. */
  113490. getControllerByName(name: string): Nullable<WebVRController>;
  113491. private _leftController;
  113492. /**
  113493. * The controller corresponding to the users left hand.
  113494. */
  113495. get leftController(): Nullable<WebVRController>;
  113496. private _rightController;
  113497. /**
  113498. * The controller corresponding to the users right hand.
  113499. */
  113500. get rightController(): Nullable<WebVRController>;
  113501. /**
  113502. * Casts a ray forward from the vrCamera's gaze.
  113503. * @param length Length of the ray (default: 100)
  113504. * @returns the ray corresponding to the gaze
  113505. */
  113506. getForwardRay(length?: number): Ray;
  113507. /**
  113508. * @hidden
  113509. * Updates the camera based on device's frame data
  113510. */
  113511. _checkInputs(): void;
  113512. /**
  113513. * Updates the poseControlled values based on the input device pose.
  113514. * @param poseData Pose coming from the device
  113515. */
  113516. updateFromDevice(poseData: DevicePose): void;
  113517. private _detachIfAttached;
  113518. /**
  113519. * WebVR's attach control will start broadcasting frames to the device.
  113520. * Note that in certain browsers (chrome for example) this function must be called
  113521. * within a user-interaction callback. Example:
  113522. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  113523. *
  113524. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  113525. */
  113526. attachControl(noPreventDefault?: boolean): void;
  113527. /**
  113528. * Detach the current controls from the specified dom element.
  113529. */
  113530. detachControl(): void;
  113531. /**
  113532. * @returns the name of this class
  113533. */
  113534. getClassName(): string;
  113535. /**
  113536. * Calls resetPose on the vrDisplay
  113537. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  113538. */
  113539. resetToCurrentRotation(): void;
  113540. /**
  113541. * @hidden
  113542. * Updates the rig cameras (left and right eye)
  113543. */
  113544. _updateRigCameras(): void;
  113545. private _workingVector;
  113546. private _oneVector;
  113547. private _workingMatrix;
  113548. private updateCacheCalled;
  113549. private _correctPositionIfNotTrackPosition;
  113550. /**
  113551. * @hidden
  113552. * Updates the cached values of the camera
  113553. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  113554. */
  113555. _updateCache(ignoreParentClass?: boolean): void;
  113556. /**
  113557. * @hidden
  113558. * Get current device position in babylon world
  113559. */
  113560. _computeDevicePosition(): void;
  113561. /**
  113562. * Updates the current device position and rotation in the babylon world
  113563. */
  113564. update(): void;
  113565. /**
  113566. * @hidden
  113567. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  113568. * @returns an identity matrix
  113569. */
  113570. _getViewMatrix(): Matrix;
  113571. private _tmpMatrix;
  113572. /**
  113573. * This function is called by the two RIG cameras.
  113574. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  113575. * @hidden
  113576. */
  113577. _getWebVRViewMatrix(): Matrix;
  113578. /** @hidden */
  113579. _getWebVRProjectionMatrix(): Matrix;
  113580. private _onGamepadConnectedObserver;
  113581. private _onGamepadDisconnectedObserver;
  113582. private _updateCacheWhenTrackingDisabledObserver;
  113583. /**
  113584. * Initializes the controllers and their meshes
  113585. */
  113586. initControllers(): void;
  113587. }
  113588. }
  113589. declare module BABYLON {
  113590. /**
  113591. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  113592. *
  113593. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  113594. *
  113595. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  113596. */
  113597. export class MaterialHelper {
  113598. /**
  113599. * Bind the current view position to an effect.
  113600. * @param effect The effect to be bound
  113601. * @param scene The scene the eyes position is used from
  113602. * @param variableName name of the shader variable that will hold the eye position
  113603. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  113604. * @return the computed eye position
  113605. */
  113606. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  113607. /**
  113608. * Update the scene ubo before it can be used in rendering processing
  113609. * @param scene the scene to retrieve the ubo from
  113610. * @returns the scene UniformBuffer
  113611. */
  113612. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  113613. /**
  113614. * Binds the scene's uniform buffer to the effect.
  113615. * @param effect defines the effect to bind to the scene uniform buffer
  113616. * @param sceneUbo defines the uniform buffer storing scene data
  113617. */
  113618. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  113619. /**
  113620. * Helps preparing the defines values about the UVs in used in the effect.
  113621. * UVs are shared as much as we can across channels in the shaders.
  113622. * @param texture The texture we are preparing the UVs for
  113623. * @param defines The defines to update
  113624. * @param key The channel key "diffuse", "specular"... used in the shader
  113625. */
  113626. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  113627. /**
  113628. * Binds a texture matrix value to its corresponding uniform
  113629. * @param texture The texture to bind the matrix for
  113630. * @param uniformBuffer The uniform buffer receiving the data
  113631. * @param key The channel key "diffuse", "specular"... used in the shader
  113632. */
  113633. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  113634. /**
  113635. * Gets the current status of the fog (should it be enabled?)
  113636. * @param mesh defines the mesh to evaluate for fog support
  113637. * @param scene defines the hosting scene
  113638. * @returns true if fog must be enabled
  113639. */
  113640. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  113641. /**
  113642. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  113643. * @param mesh defines the current mesh
  113644. * @param scene defines the current scene
  113645. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  113646. * @param pointsCloud defines if point cloud rendering has to be turned on
  113647. * @param fogEnabled defines if fog has to be turned on
  113648. * @param alphaTest defines if alpha testing has to be turned on
  113649. * @param defines defines the current list of defines
  113650. */
  113651. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  113652. /**
  113653. * Helper used to prepare the list of defines associated with frame values for shader compilation
  113654. * @param scene defines the current scene
  113655. * @param engine defines the current engine
  113656. * @param defines specifies the list of active defines
  113657. * @param useInstances defines if instances have to be turned on
  113658. * @param useClipPlane defines if clip plane have to be turned on
  113659. * @param useInstances defines if instances have to be turned on
  113660. * @param useThinInstances defines if thin instances have to be turned on
  113661. */
  113662. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  113663. /**
  113664. * Prepares the defines for bones
  113665. * @param mesh The mesh containing the geometry data we will draw
  113666. * @param defines The defines to update
  113667. */
  113668. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  113669. /**
  113670. * Prepares the defines for morph targets
  113671. * @param mesh The mesh containing the geometry data we will draw
  113672. * @param defines The defines to update
  113673. */
  113674. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  113675. /**
  113676. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  113677. * @param mesh The mesh containing the geometry data we will draw
  113678. * @param defines The defines to update
  113679. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  113680. * @param useBones Precise whether bones should be used or not (override mesh info)
  113681. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  113682. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  113683. * @returns false if defines are considered not dirty and have not been checked
  113684. */
  113685. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  113686. /**
  113687. * Prepares the defines related to multiview
  113688. * @param scene The scene we are intending to draw
  113689. * @param defines The defines to update
  113690. */
  113691. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  113692. /**
  113693. * Prepares the defines related to the prepass
  113694. * @param scene The scene we are intending to draw
  113695. * @param defines The defines to update
  113696. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  113697. */
  113698. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  113699. /**
  113700. * Prepares the defines related to the light information passed in parameter
  113701. * @param scene The scene we are intending to draw
  113702. * @param mesh The mesh the effect is compiling for
  113703. * @param light The light the effect is compiling for
  113704. * @param lightIndex The index of the light
  113705. * @param defines The defines to update
  113706. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  113707. * @param state Defines the current state regarding what is needed (normals, etc...)
  113708. */
  113709. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  113710. needNormals: boolean;
  113711. needRebuild: boolean;
  113712. shadowEnabled: boolean;
  113713. specularEnabled: boolean;
  113714. lightmapMode: boolean;
  113715. }): void;
  113716. /**
  113717. * Prepares the defines related to the light information passed in parameter
  113718. * @param scene The scene we are intending to draw
  113719. * @param mesh The mesh the effect is compiling for
  113720. * @param defines The defines to update
  113721. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  113722. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  113723. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  113724. * @returns true if normals will be required for the rest of the effect
  113725. */
  113726. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  113727. /**
  113728. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  113729. * @param lightIndex defines the light index
  113730. * @param uniformsList The uniform list
  113731. * @param samplersList The sampler list
  113732. * @param projectedLightTexture defines if projected texture must be used
  113733. * @param uniformBuffersList defines an optional list of uniform buffers
  113734. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  113735. */
  113736. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  113737. /**
  113738. * Prepares the uniforms and samplers list to be used in the effect
  113739. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  113740. * @param samplersList The sampler list
  113741. * @param defines The defines helping in the list generation
  113742. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  113743. */
  113744. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  113745. /**
  113746. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  113747. * @param defines The defines to update while falling back
  113748. * @param fallbacks The authorized effect fallbacks
  113749. * @param maxSimultaneousLights The maximum number of lights allowed
  113750. * @param rank the current rank of the Effect
  113751. * @returns The newly affected rank
  113752. */
  113753. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  113754. private static _TmpMorphInfluencers;
  113755. /**
  113756. * Prepares the list of attributes required for morph targets according to the effect defines.
  113757. * @param attribs The current list of supported attribs
  113758. * @param mesh The mesh to prepare the morph targets attributes for
  113759. * @param influencers The number of influencers
  113760. */
  113761. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  113762. /**
  113763. * Prepares the list of attributes required for morph targets according to the effect defines.
  113764. * @param attribs The current list of supported attribs
  113765. * @param mesh The mesh to prepare the morph targets attributes for
  113766. * @param defines The current Defines of the effect
  113767. */
  113768. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  113769. /**
  113770. * Prepares the list of attributes required for bones according to the effect defines.
  113771. * @param attribs The current list of supported attribs
  113772. * @param mesh The mesh to prepare the bones attributes for
  113773. * @param defines The current Defines of the effect
  113774. * @param fallbacks The current effect fallback strategy
  113775. */
  113776. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  113777. /**
  113778. * Check and prepare the list of attributes required for instances according to the effect defines.
  113779. * @param attribs The current list of supported attribs
  113780. * @param defines The current MaterialDefines of the effect
  113781. */
  113782. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  113783. /**
  113784. * Add the list of attributes required for instances to the attribs array.
  113785. * @param attribs The current list of supported attribs
  113786. */
  113787. static PushAttributesForInstances(attribs: string[]): void;
  113788. /**
  113789. * Binds the light information to the effect.
  113790. * @param light The light containing the generator
  113791. * @param effect The effect we are binding the data to
  113792. * @param lightIndex The light index in the effect used to render
  113793. */
  113794. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  113795. /**
  113796. * Binds the lights information from the scene to the effect for the given mesh.
  113797. * @param light Light to bind
  113798. * @param lightIndex Light index
  113799. * @param scene The scene where the light belongs to
  113800. * @param effect The effect we are binding the data to
  113801. * @param useSpecular Defines if specular is supported
  113802. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  113803. */
  113804. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  113805. /**
  113806. * Binds the lights information from the scene to the effect for the given mesh.
  113807. * @param scene The scene the lights belongs to
  113808. * @param mesh The mesh we are binding the information to render
  113809. * @param effect The effect we are binding the data to
  113810. * @param defines The generated defines for the effect
  113811. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  113812. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  113813. */
  113814. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  113815. private static _tempFogColor;
  113816. /**
  113817. * Binds the fog information from the scene to the effect for the given mesh.
  113818. * @param scene The scene the lights belongs to
  113819. * @param mesh The mesh we are binding the information to render
  113820. * @param effect The effect we are binding the data to
  113821. * @param linearSpace Defines if the fog effect is applied in linear space
  113822. */
  113823. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  113824. /**
  113825. * Binds the bones information from the mesh to the effect.
  113826. * @param mesh The mesh we are binding the information to render
  113827. * @param effect The effect we are binding the data to
  113828. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  113829. */
  113830. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  113831. private static _CopyBonesTransformationMatrices;
  113832. /**
  113833. * Binds the morph targets information from the mesh to the effect.
  113834. * @param abstractMesh The mesh we are binding the information to render
  113835. * @param effect The effect we are binding the data to
  113836. */
  113837. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  113838. /**
  113839. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  113840. * @param defines The generated defines used in the effect
  113841. * @param effect The effect we are binding the data to
  113842. * @param scene The scene we are willing to render with logarithmic scale for
  113843. */
  113844. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  113845. /**
  113846. * Binds the clip plane information from the scene to the effect.
  113847. * @param scene The scene the clip plane information are extracted from
  113848. * @param effect The effect we are binding the data to
  113849. */
  113850. static BindClipPlane(effect: Effect, scene: Scene): void;
  113851. }
  113852. }
  113853. declare module BABYLON {
  113854. /** @hidden */
  113855. export var bayerDitherFunctions: {
  113856. name: string;
  113857. shader: string;
  113858. };
  113859. }
  113860. declare module BABYLON {
  113861. /** @hidden */
  113862. export var shadowMapFragmentDeclaration: {
  113863. name: string;
  113864. shader: string;
  113865. };
  113866. }
  113867. declare module BABYLON {
  113868. /** @hidden */
  113869. export var shadowMapFragment: {
  113870. name: string;
  113871. shader: string;
  113872. };
  113873. }
  113874. declare module BABYLON {
  113875. /** @hidden */
  113876. export var shadowMapPixelShader: {
  113877. name: string;
  113878. shader: string;
  113879. };
  113880. }
  113881. declare module BABYLON {
  113882. /** @hidden */
  113883. export var shadowMapVertexDeclaration: {
  113884. name: string;
  113885. shader: string;
  113886. };
  113887. }
  113888. declare module BABYLON {
  113889. /** @hidden */
  113890. export var shadowMapVertexNormalBias: {
  113891. name: string;
  113892. shader: string;
  113893. };
  113894. }
  113895. declare module BABYLON {
  113896. /** @hidden */
  113897. export var shadowMapVertexMetric: {
  113898. name: string;
  113899. shader: string;
  113900. };
  113901. }
  113902. declare module BABYLON {
  113903. /** @hidden */
  113904. export var shadowMapVertexShader: {
  113905. name: string;
  113906. shader: string;
  113907. };
  113908. }
  113909. declare module BABYLON {
  113910. /** @hidden */
  113911. export var depthBoxBlurPixelShader: {
  113912. name: string;
  113913. shader: string;
  113914. };
  113915. }
  113916. declare module BABYLON {
  113917. /** @hidden */
  113918. export var shadowMapFragmentSoftTransparentShadow: {
  113919. name: string;
  113920. shader: string;
  113921. };
  113922. }
  113923. declare module BABYLON {
  113924. /**
  113925. * Creates an instance based on a source mesh.
  113926. */
  113927. export class InstancedMesh extends AbstractMesh {
  113928. private _sourceMesh;
  113929. private _currentLOD;
  113930. /** @hidden */
  113931. _indexInSourceMeshInstanceArray: number;
  113932. constructor(name: string, source: Mesh);
  113933. /**
  113934. * Returns the string "InstancedMesh".
  113935. */
  113936. getClassName(): string;
  113937. /** Gets the list of lights affecting that mesh */
  113938. get lightSources(): Light[];
  113939. _resyncLightSources(): void;
  113940. _resyncLightSource(light: Light): void;
  113941. _removeLightSource(light: Light, dispose: boolean): void;
  113942. /**
  113943. * If the source mesh receives shadows
  113944. */
  113945. get receiveShadows(): boolean;
  113946. /**
  113947. * The material of the source mesh
  113948. */
  113949. get material(): Nullable<Material>;
  113950. /**
  113951. * Visibility of the source mesh
  113952. */
  113953. get visibility(): number;
  113954. /**
  113955. * Skeleton of the source mesh
  113956. */
  113957. get skeleton(): Nullable<Skeleton>;
  113958. /**
  113959. * Rendering ground id of the source mesh
  113960. */
  113961. get renderingGroupId(): number;
  113962. set renderingGroupId(value: number);
  113963. /**
  113964. * Returns the total number of vertices (integer).
  113965. */
  113966. getTotalVertices(): number;
  113967. /**
  113968. * Returns a positive integer : the total number of indices in this mesh geometry.
  113969. * @returns the numner of indices or zero if the mesh has no geometry.
  113970. */
  113971. getTotalIndices(): number;
  113972. /**
  113973. * The source mesh of the instance
  113974. */
  113975. get sourceMesh(): Mesh;
  113976. /**
  113977. * Creates a new InstancedMesh object from the mesh model.
  113978. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113979. * @param name defines the name of the new instance
  113980. * @returns a new InstancedMesh
  113981. */
  113982. createInstance(name: string): InstancedMesh;
  113983. /**
  113984. * Is this node ready to be used/rendered
  113985. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113986. * @return {boolean} is it ready
  113987. */
  113988. isReady(completeCheck?: boolean): boolean;
  113989. /**
  113990. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113991. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  113992. * @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.
  113993. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  113994. */
  113995. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  113996. /**
  113997. * Sets the vertex data of the mesh geometry for the requested `kind`.
  113998. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  113999. * The `data` are either a numeric array either a Float32Array.
  114000. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  114001. * 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).
  114002. * Note that a new underlying VertexBuffer object is created each call.
  114003. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  114004. *
  114005. * Possible `kind` values :
  114006. * - VertexBuffer.PositionKind
  114007. * - VertexBuffer.UVKind
  114008. * - VertexBuffer.UV2Kind
  114009. * - VertexBuffer.UV3Kind
  114010. * - VertexBuffer.UV4Kind
  114011. * - VertexBuffer.UV5Kind
  114012. * - VertexBuffer.UV6Kind
  114013. * - VertexBuffer.ColorKind
  114014. * - VertexBuffer.MatricesIndicesKind
  114015. * - VertexBuffer.MatricesIndicesExtraKind
  114016. * - VertexBuffer.MatricesWeightsKind
  114017. * - VertexBuffer.MatricesWeightsExtraKind
  114018. *
  114019. * Returns the Mesh.
  114020. */
  114021. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114022. /**
  114023. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  114024. * If the mesh has no geometry, it is simply returned as it is.
  114025. * The `data` are either a numeric array either a Float32Array.
  114026. * No new underlying VertexBuffer object is created.
  114027. * 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.
  114028. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  114029. *
  114030. * Possible `kind` values :
  114031. * - VertexBuffer.PositionKind
  114032. * - VertexBuffer.UVKind
  114033. * - VertexBuffer.UV2Kind
  114034. * - VertexBuffer.UV3Kind
  114035. * - VertexBuffer.UV4Kind
  114036. * - VertexBuffer.UV5Kind
  114037. * - VertexBuffer.UV6Kind
  114038. * - VertexBuffer.ColorKind
  114039. * - VertexBuffer.MatricesIndicesKind
  114040. * - VertexBuffer.MatricesIndicesExtraKind
  114041. * - VertexBuffer.MatricesWeightsKind
  114042. * - VertexBuffer.MatricesWeightsExtraKind
  114043. *
  114044. * Returns the Mesh.
  114045. */
  114046. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  114047. /**
  114048. * Sets the mesh indices.
  114049. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  114050. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  114051. * This method creates a new index buffer each call.
  114052. * Returns the Mesh.
  114053. */
  114054. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  114055. /**
  114056. * Boolean : True if the mesh owns the requested kind of data.
  114057. */
  114058. isVerticesDataPresent(kind: string): boolean;
  114059. /**
  114060. * Returns an array of indices (IndicesArray).
  114061. */
  114062. getIndices(): Nullable<IndicesArray>;
  114063. get _positions(): Nullable<Vector3[]>;
  114064. /**
  114065. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114066. * This means the mesh underlying bounding box and sphere are recomputed.
  114067. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114068. * @returns the current mesh
  114069. */
  114070. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  114071. /** @hidden */
  114072. _preActivate(): InstancedMesh;
  114073. /** @hidden */
  114074. _activate(renderId: number, intermediateRendering: boolean): boolean;
  114075. /** @hidden */
  114076. _postActivate(): void;
  114077. getWorldMatrix(): Matrix;
  114078. get isAnInstance(): boolean;
  114079. /**
  114080. * Returns the current associated LOD AbstractMesh.
  114081. */
  114082. getLOD(camera: Camera): AbstractMesh;
  114083. /** @hidden */
  114084. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114085. /** @hidden */
  114086. _syncSubMeshes(): InstancedMesh;
  114087. /** @hidden */
  114088. _generatePointsArray(): boolean;
  114089. /** @hidden */
  114090. _updateBoundingInfo(): AbstractMesh;
  114091. /**
  114092. * Creates a new InstancedMesh from the current mesh.
  114093. * - name (string) : the cloned mesh name
  114094. * - newParent (optional Node) : the optional Node to parent the clone to.
  114095. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  114096. *
  114097. * Returns the clone.
  114098. */
  114099. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  114100. /**
  114101. * Disposes the InstancedMesh.
  114102. * Returns nothing.
  114103. */
  114104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114105. }
  114106. interface Mesh {
  114107. /**
  114108. * Register a custom buffer that will be instanced
  114109. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  114110. * @param kind defines the buffer kind
  114111. * @param stride defines the stride in floats
  114112. */
  114113. registerInstancedBuffer(kind: string, stride: number): void;
  114114. /**
  114115. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  114116. */
  114117. _invalidateInstanceVertexArrayObject(): void;
  114118. /**
  114119. * true to use the edge renderer for all instances of this mesh
  114120. */
  114121. edgesShareWithInstances: boolean;
  114122. /** @hidden */
  114123. _userInstancedBuffersStorage: {
  114124. data: {
  114125. [key: string]: Float32Array;
  114126. };
  114127. sizes: {
  114128. [key: string]: number;
  114129. };
  114130. vertexBuffers: {
  114131. [key: string]: Nullable<VertexBuffer>;
  114132. };
  114133. strides: {
  114134. [key: string]: number;
  114135. };
  114136. vertexArrayObjects?: {
  114137. [key: string]: WebGLVertexArrayObject;
  114138. };
  114139. };
  114140. }
  114141. interface AbstractMesh {
  114142. /**
  114143. * Object used to store instanced buffers defined by user
  114144. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  114145. */
  114146. instancedBuffers: {
  114147. [key: string]: any;
  114148. };
  114149. }
  114150. }
  114151. declare module BABYLON {
  114152. /**
  114153. * Defines the options associated with the creation of a shader material.
  114154. */
  114155. export interface IShaderMaterialOptions {
  114156. /**
  114157. * Does the material work in alpha blend mode
  114158. */
  114159. needAlphaBlending: boolean;
  114160. /**
  114161. * Does the material work in alpha test mode
  114162. */
  114163. needAlphaTesting: boolean;
  114164. /**
  114165. * The list of attribute names used in the shader
  114166. */
  114167. attributes: string[];
  114168. /**
  114169. * The list of uniform names used in the shader
  114170. */
  114171. uniforms: string[];
  114172. /**
  114173. * The list of UBO names used in the shader
  114174. */
  114175. uniformBuffers: string[];
  114176. /**
  114177. * The list of sampler names used in the shader
  114178. */
  114179. samplers: string[];
  114180. /**
  114181. * The list of defines used in the shader
  114182. */
  114183. defines: string[];
  114184. }
  114185. /**
  114186. * 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.
  114187. *
  114188. * This returned material effects how the mesh will look based on the code in the shaders.
  114189. *
  114190. * @see https://doc.babylonjs.com/how_to/shader_material
  114191. */
  114192. export class ShaderMaterial extends Material {
  114193. private _shaderPath;
  114194. private _options;
  114195. private _textures;
  114196. private _textureArrays;
  114197. private _floats;
  114198. private _ints;
  114199. private _floatsArrays;
  114200. private _colors3;
  114201. private _colors3Arrays;
  114202. private _colors4;
  114203. private _colors4Arrays;
  114204. private _vectors2;
  114205. private _vectors3;
  114206. private _vectors4;
  114207. private _matrices;
  114208. private _matrixArrays;
  114209. private _matrices3x3;
  114210. private _matrices2x2;
  114211. private _vectors2Arrays;
  114212. private _vectors3Arrays;
  114213. private _vectors4Arrays;
  114214. private _cachedWorldViewMatrix;
  114215. private _cachedWorldViewProjectionMatrix;
  114216. private _renderId;
  114217. private _multiview;
  114218. private _cachedDefines;
  114219. /** Define the Url to load snippets */
  114220. static SnippetUrl: string;
  114221. /** Snippet ID if the material was created from the snippet server */
  114222. snippetId: string;
  114223. /**
  114224. * Instantiate a new shader material.
  114225. * 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.
  114226. * This returned material effects how the mesh will look based on the code in the shaders.
  114227. * @see https://doc.babylonjs.com/how_to/shader_material
  114228. * @param name Define the name of the material in the scene
  114229. * @param scene Define the scene the material belongs to
  114230. * @param shaderPath Defines the route to the shader code in one of three ways:
  114231. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  114232. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  114233. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  114234. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  114235. * @param options Define the options used to create the shader
  114236. */
  114237. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  114238. /**
  114239. * Gets the shader path used to define the shader code
  114240. * It can be modified to trigger a new compilation
  114241. */
  114242. get shaderPath(): any;
  114243. /**
  114244. * Sets the shader path used to define the shader code
  114245. * It can be modified to trigger a new compilation
  114246. */
  114247. set shaderPath(shaderPath: any);
  114248. /**
  114249. * Gets the options used to compile the shader.
  114250. * They can be modified to trigger a new compilation
  114251. */
  114252. get options(): IShaderMaterialOptions;
  114253. /**
  114254. * Gets the current class name of the material e.g. "ShaderMaterial"
  114255. * Mainly use in serialization.
  114256. * @returns the class name
  114257. */
  114258. getClassName(): string;
  114259. /**
  114260. * Specifies if the material will require alpha blending
  114261. * @returns a boolean specifying if alpha blending is needed
  114262. */
  114263. needAlphaBlending(): boolean;
  114264. /**
  114265. * Specifies if this material should be rendered in alpha test mode
  114266. * @returns a boolean specifying if an alpha test is needed.
  114267. */
  114268. needAlphaTesting(): boolean;
  114269. private _checkUniform;
  114270. /**
  114271. * Set a texture in the shader.
  114272. * @param name Define the name of the uniform samplers as defined in the shader
  114273. * @param texture Define the texture to bind to this sampler
  114274. * @return the material itself allowing "fluent" like uniform updates
  114275. */
  114276. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  114277. /**
  114278. * Set a texture array in the shader.
  114279. * @param name Define the name of the uniform sampler array as defined in the shader
  114280. * @param textures Define the list of textures to bind to this sampler
  114281. * @return the material itself allowing "fluent" like uniform updates
  114282. */
  114283. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  114284. /**
  114285. * Set a float in the shader.
  114286. * @param name Define the name of the uniform as defined in the shader
  114287. * @param value Define the value to give to the uniform
  114288. * @return the material itself allowing "fluent" like uniform updates
  114289. */
  114290. setFloat(name: string, value: number): ShaderMaterial;
  114291. /**
  114292. * Set a int in the shader.
  114293. * @param name Define the name of the uniform as defined in the shader
  114294. * @param value Define the value to give to the uniform
  114295. * @return the material itself allowing "fluent" like uniform updates
  114296. */
  114297. setInt(name: string, value: number): ShaderMaterial;
  114298. /**
  114299. * Set an array of floats in the shader.
  114300. * @param name Define the name of the uniform as defined in the shader
  114301. * @param value Define the value to give to the uniform
  114302. * @return the material itself allowing "fluent" like uniform updates
  114303. */
  114304. setFloats(name: string, value: number[]): ShaderMaterial;
  114305. /**
  114306. * Set a vec3 in the shader from a Color3.
  114307. * @param name Define the name of the uniform as defined in the shader
  114308. * @param value Define the value to give to the uniform
  114309. * @return the material itself allowing "fluent" like uniform updates
  114310. */
  114311. setColor3(name: string, value: Color3): ShaderMaterial;
  114312. /**
  114313. * Set a vec3 array in the shader from a Color3 array.
  114314. * @param name Define the name of the uniform as defined in the shader
  114315. * @param value Define the value to give to the uniform
  114316. * @return the material itself allowing "fluent" like uniform updates
  114317. */
  114318. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  114319. /**
  114320. * Set a vec4 in the shader from a Color4.
  114321. * @param name Define the name of the uniform as defined in the shader
  114322. * @param value Define the value to give to the uniform
  114323. * @return the material itself allowing "fluent" like uniform updates
  114324. */
  114325. setColor4(name: string, value: Color4): ShaderMaterial;
  114326. /**
  114327. * Set a vec4 array in the shader from a Color4 array.
  114328. * @param name Define the name of the uniform as defined in the shader
  114329. * @param value Define the value to give to the uniform
  114330. * @return the material itself allowing "fluent" like uniform updates
  114331. */
  114332. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  114333. /**
  114334. * Set a vec2 in the shader from a Vector2.
  114335. * @param name Define the name of the uniform as defined in the shader
  114336. * @param value Define the value to give to the uniform
  114337. * @return the material itself allowing "fluent" like uniform updates
  114338. */
  114339. setVector2(name: string, value: Vector2): ShaderMaterial;
  114340. /**
  114341. * Set a vec3 in the shader from a Vector3.
  114342. * @param name Define the name of the uniform as defined in the shader
  114343. * @param value Define the value to give to the uniform
  114344. * @return the material itself allowing "fluent" like uniform updates
  114345. */
  114346. setVector3(name: string, value: Vector3): ShaderMaterial;
  114347. /**
  114348. * Set a vec4 in the shader from a Vector4.
  114349. * @param name Define the name of the uniform as defined in the shader
  114350. * @param value Define the value to give to the uniform
  114351. * @return the material itself allowing "fluent" like uniform updates
  114352. */
  114353. setVector4(name: string, value: Vector4): ShaderMaterial;
  114354. /**
  114355. * Set a mat4 in the shader from a Matrix.
  114356. * @param name Define the name of the uniform as defined in the shader
  114357. * @param value Define the value to give to the uniform
  114358. * @return the material itself allowing "fluent" like uniform updates
  114359. */
  114360. setMatrix(name: string, value: Matrix): ShaderMaterial;
  114361. /**
  114362. * Set a float32Array in the shader from a matrix array.
  114363. * @param name Define the name of the uniform as defined in the shader
  114364. * @param value Define the value to give to the uniform
  114365. * @return the material itself allowing "fluent" like uniform updates
  114366. */
  114367. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  114368. /**
  114369. * Set a mat3 in the shader from a Float32Array.
  114370. * @param name Define the name of the uniform as defined in the shader
  114371. * @param value Define the value to give to the uniform
  114372. * @return the material itself allowing "fluent" like uniform updates
  114373. */
  114374. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  114375. /**
  114376. * Set a mat2 in the shader from a Float32Array.
  114377. * @param name Define the name of the uniform as defined in the shader
  114378. * @param value Define the value to give to the uniform
  114379. * @return the material itself allowing "fluent" like uniform updates
  114380. */
  114381. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  114382. /**
  114383. * Set a vec2 array in the shader from a number array.
  114384. * @param name Define the name of the uniform as defined in the shader
  114385. * @param value Define the value to give to the uniform
  114386. * @return the material itself allowing "fluent" like uniform updates
  114387. */
  114388. setArray2(name: string, value: number[]): ShaderMaterial;
  114389. /**
  114390. * Set a vec3 array in the shader from a number array.
  114391. * @param name Define the name of the uniform as defined in the shader
  114392. * @param value Define the value to give to the uniform
  114393. * @return the material itself allowing "fluent" like uniform updates
  114394. */
  114395. setArray3(name: string, value: number[]): ShaderMaterial;
  114396. /**
  114397. * Set a vec4 array in the shader from a number array.
  114398. * @param name Define the name of the uniform as defined in the shader
  114399. * @param value Define the value to give to the uniform
  114400. * @return the material itself allowing "fluent" like uniform updates
  114401. */
  114402. setArray4(name: string, value: number[]): ShaderMaterial;
  114403. private _checkCache;
  114404. /**
  114405. * Specifies that the submesh is ready to be used
  114406. * @param mesh defines the mesh to check
  114407. * @param subMesh defines which submesh to check
  114408. * @param useInstances specifies that instances should be used
  114409. * @returns a boolean indicating that the submesh is ready or not
  114410. */
  114411. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114412. /**
  114413. * Checks if the material is ready to render the requested mesh
  114414. * @param mesh Define the mesh to render
  114415. * @param useInstances Define whether or not the material is used with instances
  114416. * @returns true if ready, otherwise false
  114417. */
  114418. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  114419. /**
  114420. * Binds the world matrix to the material
  114421. * @param world defines the world transformation matrix
  114422. * @param effectOverride - If provided, use this effect instead of internal effect
  114423. */
  114424. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  114425. /**
  114426. * Binds the submesh to this material by preparing the effect and shader to draw
  114427. * @param world defines the world transformation matrix
  114428. * @param mesh defines the mesh containing the submesh
  114429. * @param subMesh defines the submesh to bind the material to
  114430. */
  114431. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114432. /**
  114433. * Binds the material to the mesh
  114434. * @param world defines the world transformation matrix
  114435. * @param mesh defines the mesh to bind the material to
  114436. * @param effectOverride - If provided, use this effect instead of internal effect
  114437. */
  114438. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  114439. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  114440. /**
  114441. * Gets the active textures from the material
  114442. * @returns an array of textures
  114443. */
  114444. getActiveTextures(): BaseTexture[];
  114445. /**
  114446. * Specifies if the material uses a texture
  114447. * @param texture defines the texture to check against the material
  114448. * @returns a boolean specifying if the material uses the texture
  114449. */
  114450. hasTexture(texture: BaseTexture): boolean;
  114451. /**
  114452. * Makes a duplicate of the material, and gives it a new name
  114453. * @param name defines the new name for the duplicated material
  114454. * @returns the cloned material
  114455. */
  114456. clone(name: string): ShaderMaterial;
  114457. /**
  114458. * Disposes the material
  114459. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  114460. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  114461. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  114462. */
  114463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  114464. /**
  114465. * Serializes this material in a JSON representation
  114466. * @returns the serialized material object
  114467. */
  114468. serialize(): any;
  114469. /**
  114470. * Creates a shader material from parsed shader material data
  114471. * @param source defines the JSON representation of the material
  114472. * @param scene defines the hosting scene
  114473. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  114474. * @returns a new material
  114475. */
  114476. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  114477. /**
  114478. * Creates a new ShaderMaterial from a snippet saved in a remote file
  114479. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  114480. * @param url defines the url to load from
  114481. * @param scene defines the hosting scene
  114482. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  114483. * @returns a promise that will resolve to the new ShaderMaterial
  114484. */
  114485. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  114486. /**
  114487. * Creates a ShaderMaterial from a snippet saved by the Inspector
  114488. * @param snippetId defines the snippet to load
  114489. * @param scene defines the hosting scene
  114490. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  114491. * @returns a promise that will resolve to the new ShaderMaterial
  114492. */
  114493. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  114494. }
  114495. }
  114496. declare module BABYLON {
  114497. /** @hidden */
  114498. export var colorPixelShader: {
  114499. name: string;
  114500. shader: string;
  114501. };
  114502. }
  114503. declare module BABYLON {
  114504. /** @hidden */
  114505. export var colorVertexShader: {
  114506. name: string;
  114507. shader: string;
  114508. };
  114509. }
  114510. declare module BABYLON {
  114511. /**
  114512. * Line mesh
  114513. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  114514. */
  114515. export class LinesMesh extends Mesh {
  114516. /**
  114517. * If vertex color should be applied to the mesh
  114518. */
  114519. readonly useVertexColor?: boolean | undefined;
  114520. /**
  114521. * If vertex alpha should be applied to the mesh
  114522. */
  114523. readonly useVertexAlpha?: boolean | undefined;
  114524. /**
  114525. * Color of the line (Default: White)
  114526. */
  114527. color: Color3;
  114528. /**
  114529. * Alpha of the line (Default: 1)
  114530. */
  114531. alpha: number;
  114532. /**
  114533. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  114534. * This margin is expressed in world space coordinates, so its value may vary.
  114535. * Default value is 0.1
  114536. */
  114537. intersectionThreshold: number;
  114538. private _colorShader;
  114539. private color4;
  114540. /**
  114541. * Creates a new LinesMesh
  114542. * @param name defines the name
  114543. * @param scene defines the hosting scene
  114544. * @param parent defines the parent mesh if any
  114545. * @param source defines the optional source LinesMesh used to clone data from
  114546. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  114547. * When false, achieved by calling a clone(), also passing False.
  114548. * This will make creation of children, recursive.
  114549. * @param useVertexColor defines if this LinesMesh supports vertex color
  114550. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  114551. */
  114552. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  114553. /**
  114554. * If vertex color should be applied to the mesh
  114555. */
  114556. useVertexColor?: boolean | undefined,
  114557. /**
  114558. * If vertex alpha should be applied to the mesh
  114559. */
  114560. useVertexAlpha?: boolean | undefined);
  114561. private _addClipPlaneDefine;
  114562. private _removeClipPlaneDefine;
  114563. isReady(): boolean;
  114564. /**
  114565. * Returns the string "LineMesh"
  114566. */
  114567. getClassName(): string;
  114568. /**
  114569. * @hidden
  114570. */
  114571. get material(): Material;
  114572. /**
  114573. * @hidden
  114574. */
  114575. set material(value: Material);
  114576. /**
  114577. * @hidden
  114578. */
  114579. get checkCollisions(): boolean;
  114580. set checkCollisions(value: boolean);
  114581. /** @hidden */
  114582. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114583. /** @hidden */
  114584. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114585. /**
  114586. * Disposes of the line mesh
  114587. * @param doNotRecurse If children should be disposed
  114588. */
  114589. dispose(doNotRecurse?: boolean): void;
  114590. /**
  114591. * Returns a new LineMesh object cloned from the current one.
  114592. */
  114593. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  114594. /**
  114595. * Creates a new InstancedLinesMesh object from the mesh model.
  114596. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114597. * @param name defines the name of the new instance
  114598. * @returns a new InstancedLinesMesh
  114599. */
  114600. createInstance(name: string): InstancedLinesMesh;
  114601. }
  114602. /**
  114603. * Creates an instance based on a source LinesMesh
  114604. */
  114605. export class InstancedLinesMesh extends InstancedMesh {
  114606. /**
  114607. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  114608. * This margin is expressed in world space coordinates, so its value may vary.
  114609. * Initialized with the intersectionThreshold value of the source LinesMesh
  114610. */
  114611. intersectionThreshold: number;
  114612. constructor(name: string, source: LinesMesh);
  114613. /**
  114614. * Returns the string "InstancedLinesMesh".
  114615. */
  114616. getClassName(): string;
  114617. }
  114618. }
  114619. declare module BABYLON {
  114620. /** @hidden */
  114621. export var linePixelShader: {
  114622. name: string;
  114623. shader: string;
  114624. };
  114625. }
  114626. declare module BABYLON {
  114627. /** @hidden */
  114628. export var lineVertexShader: {
  114629. name: string;
  114630. shader: string;
  114631. };
  114632. }
  114633. declare module BABYLON {
  114634. interface Scene {
  114635. /** @hidden */
  114636. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  114637. }
  114638. interface AbstractMesh {
  114639. /**
  114640. * Gets the edgesRenderer associated with the mesh
  114641. */
  114642. edgesRenderer: Nullable<EdgesRenderer>;
  114643. }
  114644. interface LinesMesh {
  114645. /**
  114646. * Enables the edge rendering mode on the mesh.
  114647. * This mode makes the mesh edges visible
  114648. * @param epsilon defines the maximal distance between two angles to detect a face
  114649. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  114650. * @returns the currentAbstractMesh
  114651. * @see https://www.babylonjs-playground.com/#19O9TU#0
  114652. */
  114653. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  114654. }
  114655. interface InstancedLinesMesh {
  114656. /**
  114657. * Enables the edge rendering mode on the mesh.
  114658. * This mode makes the mesh edges visible
  114659. * @param epsilon defines the maximal distance between two angles to detect a face
  114660. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  114661. * @returns the current InstancedLinesMesh
  114662. * @see https://www.babylonjs-playground.com/#19O9TU#0
  114663. */
  114664. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  114665. }
  114666. /**
  114667. * Defines the minimum contract an Edges renderer should follow.
  114668. */
  114669. export interface IEdgesRenderer extends IDisposable {
  114670. /**
  114671. * Gets or sets a boolean indicating if the edgesRenderer is active
  114672. */
  114673. isEnabled: boolean;
  114674. /**
  114675. * Renders the edges of the attached mesh,
  114676. */
  114677. render(): void;
  114678. /**
  114679. * Checks whether or not the edges renderer is ready to render.
  114680. * @return true if ready, otherwise false.
  114681. */
  114682. isReady(): boolean;
  114683. /**
  114684. * List of instances to render in case the source mesh has instances
  114685. */
  114686. customInstances: SmartArray<Matrix>;
  114687. }
  114688. /**
  114689. * Defines the additional options of the edges renderer
  114690. */
  114691. export interface IEdgesRendererOptions {
  114692. /**
  114693. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  114694. * If not defined, the default value is true
  114695. */
  114696. useAlternateEdgeFinder?: boolean;
  114697. /**
  114698. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  114699. * If not defined, the default value is true.
  114700. * 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)
  114701. * This option is used only if useAlternateEdgeFinder = true
  114702. */
  114703. useFastVertexMerger?: boolean;
  114704. /**
  114705. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  114706. * The default value is 1e-6
  114707. * This option is used only if useAlternateEdgeFinder = true
  114708. */
  114709. epsilonVertexMerge?: number;
  114710. /**
  114711. * 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
  114712. * 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.
  114713. * This option is used only if useAlternateEdgeFinder = true
  114714. */
  114715. applyTessellation?: boolean;
  114716. /**
  114717. * 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
  114718. * The default value is 1e-6
  114719. * This option is used only if useAlternateEdgeFinder = true
  114720. */
  114721. epsilonVertexAligned?: number;
  114722. }
  114723. /**
  114724. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  114725. */
  114726. export class EdgesRenderer implements IEdgesRenderer {
  114727. /**
  114728. * Define the size of the edges with an orthographic camera
  114729. */
  114730. edgesWidthScalerForOrthographic: number;
  114731. /**
  114732. * Define the size of the edges with a perspective camera
  114733. */
  114734. edgesWidthScalerForPerspective: number;
  114735. protected _source: AbstractMesh;
  114736. protected _linesPositions: number[];
  114737. protected _linesNormals: number[];
  114738. protected _linesIndices: number[];
  114739. protected _epsilon: number;
  114740. protected _indicesCount: number;
  114741. protected _lineShader: ShaderMaterial;
  114742. protected _ib: DataBuffer;
  114743. protected _buffers: {
  114744. [key: string]: Nullable<VertexBuffer>;
  114745. };
  114746. protected _buffersForInstances: {
  114747. [key: string]: Nullable<VertexBuffer>;
  114748. };
  114749. protected _checkVerticesInsteadOfIndices: boolean;
  114750. protected _options: Nullable<IEdgesRendererOptions>;
  114751. private _meshRebuildObserver;
  114752. private _meshDisposeObserver;
  114753. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  114754. isEnabled: boolean;
  114755. /** Gets the vertices generated by the edge renderer */
  114756. get linesPositions(): Immutable<Array<number>>;
  114757. /** Gets the normals generated by the edge renderer */
  114758. get linesNormals(): Immutable<Array<number>>;
  114759. /** Gets the indices generated by the edge renderer */
  114760. get linesIndices(): Immutable<Array<number>>;
  114761. /**
  114762. * List of instances to render in case the source mesh has instances
  114763. */
  114764. customInstances: SmartArray<Matrix>;
  114765. private static GetShader;
  114766. /**
  114767. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  114768. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  114769. * @param source Mesh used to create edges
  114770. * @param epsilon sum of angles in adjacency to check for edge
  114771. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  114772. * @param generateEdgesLines - should generate Lines or only prepare resources.
  114773. * @param options The options to apply when generating the edges
  114774. */
  114775. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  114776. protected _prepareRessources(): void;
  114777. /** @hidden */
  114778. _rebuild(): void;
  114779. /**
  114780. * Releases the required resources for the edges renderer
  114781. */
  114782. dispose(): void;
  114783. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  114784. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  114785. /**
  114786. * Checks if the pair of p0 and p1 is en edge
  114787. * @param faceIndex
  114788. * @param edge
  114789. * @param faceNormals
  114790. * @param p0
  114791. * @param p1
  114792. * @private
  114793. */
  114794. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  114795. /**
  114796. * push line into the position, normal and index buffer
  114797. * @protected
  114798. */
  114799. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  114800. /**
  114801. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  114802. */
  114803. private _tessellateTriangle;
  114804. private _generateEdgesLinesAlternate;
  114805. /**
  114806. * Generates lines edges from adjacencjes
  114807. * @private
  114808. */
  114809. _generateEdgesLines(): void;
  114810. /**
  114811. * Checks whether or not the edges renderer is ready to render.
  114812. * @return true if ready, otherwise false.
  114813. */
  114814. isReady(): boolean;
  114815. /**
  114816. * Renders the edges of the attached mesh,
  114817. */
  114818. render(): void;
  114819. }
  114820. /**
  114821. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  114822. */
  114823. export class LineEdgesRenderer extends EdgesRenderer {
  114824. /**
  114825. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  114826. * @param source LineMesh used to generate edges
  114827. * @param epsilon not important (specified angle for edge detection)
  114828. * @param checkVerticesInsteadOfIndices not important for LineMesh
  114829. */
  114830. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  114831. /**
  114832. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  114833. */
  114834. _generateEdgesLines(): void;
  114835. }
  114836. }
  114837. declare module BABYLON {
  114838. /**
  114839. * This represents the object necessary to create a rendering group.
  114840. * This is exclusively used and created by the rendering manager.
  114841. * To modify the behavior, you use the available helpers in your scene or meshes.
  114842. * @hidden
  114843. */
  114844. export class RenderingGroup {
  114845. index: number;
  114846. private static _zeroVector;
  114847. private _scene;
  114848. private _opaqueSubMeshes;
  114849. private _transparentSubMeshes;
  114850. private _alphaTestSubMeshes;
  114851. private _depthOnlySubMeshes;
  114852. private _particleSystems;
  114853. private _spriteManagers;
  114854. private _opaqueSortCompareFn;
  114855. private _alphaTestSortCompareFn;
  114856. private _transparentSortCompareFn;
  114857. private _renderOpaque;
  114858. private _renderAlphaTest;
  114859. private _renderTransparent;
  114860. /** @hidden */
  114861. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  114862. onBeforeTransparentRendering: () => void;
  114863. /**
  114864. * Set the opaque sort comparison function.
  114865. * If null the sub meshes will be render in the order they were created
  114866. */
  114867. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114868. /**
  114869. * Set the alpha test sort comparison function.
  114870. * If null the sub meshes will be render in the order they were created
  114871. */
  114872. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114873. /**
  114874. * Set the transparent sort comparison function.
  114875. * If null the sub meshes will be render in the order they were created
  114876. */
  114877. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  114878. /**
  114879. * Creates a new rendering group.
  114880. * @param index The rendering group index
  114881. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  114882. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  114883. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  114884. */
  114885. 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>);
  114886. /**
  114887. * Render all the sub meshes contained in the group.
  114888. * @param customRenderFunction Used to override the default render behaviour of the group.
  114889. * @returns true if rendered some submeshes.
  114890. */
  114891. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  114892. /**
  114893. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  114894. * @param subMeshes The submeshes to render
  114895. */
  114896. private renderOpaqueSorted;
  114897. /**
  114898. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  114899. * @param subMeshes The submeshes to render
  114900. */
  114901. private renderAlphaTestSorted;
  114902. /**
  114903. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  114904. * @param subMeshes The submeshes to render
  114905. */
  114906. private renderTransparentSorted;
  114907. /**
  114908. * Renders the submeshes in a specified order.
  114909. * @param subMeshes The submeshes to sort before render
  114910. * @param sortCompareFn The comparison function use to sort
  114911. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  114912. * @param transparent Specifies to activate blending if true
  114913. */
  114914. private static renderSorted;
  114915. /**
  114916. * Renders the submeshes in the order they were dispatched (no sort applied).
  114917. * @param subMeshes The submeshes to render
  114918. */
  114919. private static renderUnsorted;
  114920. /**
  114921. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114922. * are rendered back to front if in the same alpha index.
  114923. *
  114924. * @param a The first submesh
  114925. * @param b The second submesh
  114926. * @returns The result of the comparison
  114927. */
  114928. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  114929. /**
  114930. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114931. * are rendered back to front.
  114932. *
  114933. * @param a The first submesh
  114934. * @param b The second submesh
  114935. * @returns The result of the comparison
  114936. */
  114937. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  114938. /**
  114939. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  114940. * are rendered front to back (prevent overdraw).
  114941. *
  114942. * @param a The first submesh
  114943. * @param b The second submesh
  114944. * @returns The result of the comparison
  114945. */
  114946. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  114947. /**
  114948. * Resets the different lists of submeshes to prepare a new frame.
  114949. */
  114950. prepare(): void;
  114951. dispose(): void;
  114952. /**
  114953. * Inserts the submesh in its correct queue depending on its material.
  114954. * @param subMesh The submesh to dispatch
  114955. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  114956. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  114957. */
  114958. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  114959. dispatchSprites(spriteManager: ISpriteManager): void;
  114960. dispatchParticles(particleSystem: IParticleSystem): void;
  114961. private _renderParticles;
  114962. private _renderSprites;
  114963. }
  114964. }
  114965. declare module BABYLON {
  114966. /**
  114967. * Interface describing the different options available in the rendering manager
  114968. * regarding Auto Clear between groups.
  114969. */
  114970. export interface IRenderingManagerAutoClearSetup {
  114971. /**
  114972. * Defines whether or not autoclear is enable.
  114973. */
  114974. autoClear: boolean;
  114975. /**
  114976. * Defines whether or not to autoclear the depth buffer.
  114977. */
  114978. depth: boolean;
  114979. /**
  114980. * Defines whether or not to autoclear the stencil buffer.
  114981. */
  114982. stencil: boolean;
  114983. }
  114984. /**
  114985. * This class is used by the onRenderingGroupObservable
  114986. */
  114987. export class RenderingGroupInfo {
  114988. /**
  114989. * The Scene that being rendered
  114990. */
  114991. scene: Scene;
  114992. /**
  114993. * The camera currently used for the rendering pass
  114994. */
  114995. camera: Nullable<Camera>;
  114996. /**
  114997. * The ID of the renderingGroup being processed
  114998. */
  114999. renderingGroupId: number;
  115000. }
  115001. /**
  115002. * This is the manager responsible of all the rendering for meshes sprites and particles.
  115003. * It is enable to manage the different groups as well as the different necessary sort functions.
  115004. * This should not be used directly aside of the few static configurations
  115005. */
  115006. export class RenderingManager {
  115007. /**
  115008. * The max id used for rendering groups (not included)
  115009. */
  115010. static MAX_RENDERINGGROUPS: number;
  115011. /**
  115012. * The min id used for rendering groups (included)
  115013. */
  115014. static MIN_RENDERINGGROUPS: number;
  115015. /**
  115016. * Used to globally prevent autoclearing scenes.
  115017. */
  115018. static AUTOCLEAR: boolean;
  115019. /**
  115020. * @hidden
  115021. */
  115022. _useSceneAutoClearSetup: boolean;
  115023. private _scene;
  115024. private _renderingGroups;
  115025. private _depthStencilBufferAlreadyCleaned;
  115026. private _autoClearDepthStencil;
  115027. private _customOpaqueSortCompareFn;
  115028. private _customAlphaTestSortCompareFn;
  115029. private _customTransparentSortCompareFn;
  115030. private _renderingGroupInfo;
  115031. /**
  115032. * Instantiates a new rendering group for a particular scene
  115033. * @param scene Defines the scene the groups belongs to
  115034. */
  115035. constructor(scene: Scene);
  115036. private _clearDepthStencilBuffer;
  115037. /**
  115038. * Renders the entire managed groups. This is used by the scene or the different render targets.
  115039. * @hidden
  115040. */
  115041. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  115042. /**
  115043. * Resets the different information of the group to prepare a new frame
  115044. * @hidden
  115045. */
  115046. reset(): void;
  115047. /**
  115048. * Dispose and release the group and its associated resources.
  115049. * @hidden
  115050. */
  115051. dispose(): void;
  115052. /**
  115053. * Clear the info related to rendering groups preventing retention points during dispose.
  115054. */
  115055. freeRenderingGroups(): void;
  115056. private _prepareRenderingGroup;
  115057. /**
  115058. * Add a sprite manager to the rendering manager in order to render it this frame.
  115059. * @param spriteManager Define the sprite manager to render
  115060. */
  115061. dispatchSprites(spriteManager: ISpriteManager): void;
  115062. /**
  115063. * Add a particle system to the rendering manager in order to render it this frame.
  115064. * @param particleSystem Define the particle system to render
  115065. */
  115066. dispatchParticles(particleSystem: IParticleSystem): void;
  115067. /**
  115068. * Add a submesh to the manager in order to render it this frame
  115069. * @param subMesh The submesh to dispatch
  115070. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  115071. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  115072. */
  115073. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  115074. /**
  115075. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  115076. * This allowed control for front to back rendering or reversely depending of the special needs.
  115077. *
  115078. * @param renderingGroupId The rendering group id corresponding to its index
  115079. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  115080. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  115081. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  115082. */
  115083. 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;
  115084. /**
  115085. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  115086. *
  115087. * @param renderingGroupId The rendering group id corresponding to its index
  115088. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115089. * @param depth Automatically clears depth between groups if true and autoClear is true.
  115090. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  115091. */
  115092. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  115093. /**
  115094. * Gets the current auto clear configuration for one rendering group of the rendering
  115095. * manager.
  115096. * @param index the rendering group index to get the information for
  115097. * @returns The auto clear setup for the requested rendering group
  115098. */
  115099. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  115100. }
  115101. }
  115102. declare module BABYLON {
  115103. /**
  115104. * Defines the options associated with the creation of a custom shader for a shadow generator.
  115105. */
  115106. export interface ICustomShaderOptions {
  115107. /**
  115108. * Gets or sets the custom shader name to use
  115109. */
  115110. shaderName: string;
  115111. /**
  115112. * The list of attribute names used in the shader
  115113. */
  115114. attributes?: string[];
  115115. /**
  115116. * The list of uniform names used in the shader
  115117. */
  115118. uniforms?: string[];
  115119. /**
  115120. * The list of sampler names used in the shader
  115121. */
  115122. samplers?: string[];
  115123. /**
  115124. * The list of defines used in the shader
  115125. */
  115126. defines?: string[];
  115127. }
  115128. /**
  115129. * Interface to implement to create a shadow generator compatible with BJS.
  115130. */
  115131. export interface IShadowGenerator {
  115132. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  115133. id: string;
  115134. /**
  115135. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  115136. * @returns The render target texture if present otherwise, null
  115137. */
  115138. getShadowMap(): Nullable<RenderTargetTexture>;
  115139. /**
  115140. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  115141. * @param subMesh The submesh we want to render in the shadow map
  115142. * @param useInstances Defines whether will draw in the map using instances
  115143. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  115144. * @returns true if ready otherwise, false
  115145. */
  115146. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  115147. /**
  115148. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  115149. * @param defines Defines of the material we want to update
  115150. * @param lightIndex Index of the light in the enabled light list of the material
  115151. */
  115152. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  115153. /**
  115154. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  115155. * defined in the generator but impacting the effect).
  115156. * It implies the uniforms available on the materials are the standard BJS ones.
  115157. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  115158. * @param effect The effect we are binding the information for
  115159. */
  115160. bindShadowLight(lightIndex: string, effect: Effect): void;
  115161. /**
  115162. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  115163. * (eq to shadow projection matrix * light transform matrix)
  115164. * @returns The transform matrix used to create the shadow map
  115165. */
  115166. getTransformMatrix(): Matrix;
  115167. /**
  115168. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  115169. * Cube and 2D textures for instance.
  115170. */
  115171. recreateShadowMap(): void;
  115172. /**
  115173. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  115174. * @param onCompiled Callback triggered at the and of the effects compilation
  115175. * @param options Sets of optional options forcing the compilation with different modes
  115176. */
  115177. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  115178. useInstances: boolean;
  115179. }>): void;
  115180. /**
  115181. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  115182. * @param options Sets of optional options forcing the compilation with different modes
  115183. * @returns A promise that resolves when the compilation completes
  115184. */
  115185. forceCompilationAsync(options?: Partial<{
  115186. useInstances: boolean;
  115187. }>): Promise<void>;
  115188. /**
  115189. * Serializes the shadow generator setup to a json object.
  115190. * @returns The serialized JSON object
  115191. */
  115192. serialize(): any;
  115193. /**
  115194. * Disposes the Shadow map and related Textures and effects.
  115195. */
  115196. dispose(): void;
  115197. }
  115198. /**
  115199. * Default implementation IShadowGenerator.
  115200. * This is the main object responsible of generating shadows in the framework.
  115201. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  115202. */
  115203. export class ShadowGenerator implements IShadowGenerator {
  115204. private static _Counter;
  115205. /**
  115206. * Name of the shadow generator class
  115207. */
  115208. static CLASSNAME: string;
  115209. /**
  115210. * Shadow generator mode None: no filtering applied.
  115211. */
  115212. static readonly FILTER_NONE: number;
  115213. /**
  115214. * Shadow generator mode ESM: Exponential Shadow Mapping.
  115215. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  115216. */
  115217. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  115218. /**
  115219. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  115220. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  115221. */
  115222. static readonly FILTER_POISSONSAMPLING: number;
  115223. /**
  115224. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  115225. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  115226. */
  115227. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  115228. /**
  115229. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  115230. * edge artifacts on steep falloff.
  115231. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  115232. */
  115233. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  115234. /**
  115235. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  115236. * edge artifacts on steep falloff.
  115237. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  115238. */
  115239. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  115240. /**
  115241. * Shadow generator mode PCF: Percentage Closer Filtering
  115242. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  115243. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  115244. */
  115245. static readonly FILTER_PCF: number;
  115246. /**
  115247. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  115248. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  115249. * Contact Hardening
  115250. */
  115251. static readonly FILTER_PCSS: number;
  115252. /**
  115253. * Reserved for PCF and PCSS
  115254. * Highest Quality.
  115255. *
  115256. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  115257. *
  115258. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  115259. */
  115260. static readonly QUALITY_HIGH: number;
  115261. /**
  115262. * Reserved for PCF and PCSS
  115263. * Good tradeoff for quality/perf cross devices
  115264. *
  115265. * Execute PCF on a 3*3 kernel.
  115266. *
  115267. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  115268. */
  115269. static readonly QUALITY_MEDIUM: number;
  115270. /**
  115271. * Reserved for PCF and PCSS
  115272. * The lowest quality but the fastest.
  115273. *
  115274. * Execute PCF on a 1*1 kernel.
  115275. *
  115276. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  115277. */
  115278. static readonly QUALITY_LOW: number;
  115279. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  115280. id: string;
  115281. /** Gets or sets the custom shader name to use */
  115282. customShaderOptions: ICustomShaderOptions;
  115283. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  115284. customAllowRendering: (subMesh: SubMesh) => boolean;
  115285. /**
  115286. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  115287. */
  115288. onBeforeShadowMapRenderObservable: Observable<Effect>;
  115289. /**
  115290. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  115291. */
  115292. onAfterShadowMapRenderObservable: Observable<Effect>;
  115293. /**
  115294. * Observable triggered before a mesh is rendered in the shadow map.
  115295. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  115296. */
  115297. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  115298. /**
  115299. * Observable triggered after a mesh is rendered in the shadow map.
  115300. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  115301. */
  115302. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  115303. protected _bias: number;
  115304. /**
  115305. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  115306. */
  115307. get bias(): number;
  115308. /**
  115309. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  115310. */
  115311. set bias(bias: number);
  115312. protected _normalBias: number;
  115313. /**
  115314. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  115315. */
  115316. get normalBias(): number;
  115317. /**
  115318. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  115319. */
  115320. set normalBias(normalBias: number);
  115321. protected _blurBoxOffset: number;
  115322. /**
  115323. * Gets the blur box offset: offset applied during the blur pass.
  115324. * Only useful if useKernelBlur = false
  115325. */
  115326. get blurBoxOffset(): number;
  115327. /**
  115328. * Sets the blur box offset: offset applied during the blur pass.
  115329. * Only useful if useKernelBlur = false
  115330. */
  115331. set blurBoxOffset(value: number);
  115332. protected _blurScale: number;
  115333. /**
  115334. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  115335. * 2 means half of the size.
  115336. */
  115337. get blurScale(): number;
  115338. /**
  115339. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  115340. * 2 means half of the size.
  115341. */
  115342. set blurScale(value: number);
  115343. protected _blurKernel: number;
  115344. /**
  115345. * Gets the blur kernel: kernel size of the blur pass.
  115346. * Only useful if useKernelBlur = true
  115347. */
  115348. get blurKernel(): number;
  115349. /**
  115350. * Sets the blur kernel: kernel size of the blur pass.
  115351. * Only useful if useKernelBlur = true
  115352. */
  115353. set blurKernel(value: number);
  115354. protected _useKernelBlur: boolean;
  115355. /**
  115356. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  115357. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  115358. */
  115359. get useKernelBlur(): boolean;
  115360. /**
  115361. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  115362. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  115363. */
  115364. set useKernelBlur(value: boolean);
  115365. protected _depthScale: number;
  115366. /**
  115367. * Gets the depth scale used in ESM mode.
  115368. */
  115369. get depthScale(): number;
  115370. /**
  115371. * Sets the depth scale used in ESM mode.
  115372. * This can override the scale stored on the light.
  115373. */
  115374. set depthScale(value: number);
  115375. protected _validateFilter(filter: number): number;
  115376. protected _filter: number;
  115377. /**
  115378. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  115379. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  115380. */
  115381. get filter(): number;
  115382. /**
  115383. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  115384. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  115385. */
  115386. set filter(value: number);
  115387. /**
  115388. * Gets if the current filter is set to Poisson Sampling.
  115389. */
  115390. get usePoissonSampling(): boolean;
  115391. /**
  115392. * Sets the current filter to Poisson Sampling.
  115393. */
  115394. set usePoissonSampling(value: boolean);
  115395. /**
  115396. * Gets if the current filter is set to ESM.
  115397. */
  115398. get useExponentialShadowMap(): boolean;
  115399. /**
  115400. * Sets the current filter is to ESM.
  115401. */
  115402. set useExponentialShadowMap(value: boolean);
  115403. /**
  115404. * Gets if the current filter is set to filtered ESM.
  115405. */
  115406. get useBlurExponentialShadowMap(): boolean;
  115407. /**
  115408. * Gets if the current filter is set to filtered ESM.
  115409. */
  115410. set useBlurExponentialShadowMap(value: boolean);
  115411. /**
  115412. * Gets if the current filter is set to "close ESM" (using the inverse of the
  115413. * exponential to prevent steep falloff artifacts).
  115414. */
  115415. get useCloseExponentialShadowMap(): boolean;
  115416. /**
  115417. * Sets the current filter to "close ESM" (using the inverse of the
  115418. * exponential to prevent steep falloff artifacts).
  115419. */
  115420. set useCloseExponentialShadowMap(value: boolean);
  115421. /**
  115422. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  115423. * exponential to prevent steep falloff artifacts).
  115424. */
  115425. get useBlurCloseExponentialShadowMap(): boolean;
  115426. /**
  115427. * Sets the current filter to filtered "close ESM" (using the inverse of the
  115428. * exponential to prevent steep falloff artifacts).
  115429. */
  115430. set useBlurCloseExponentialShadowMap(value: boolean);
  115431. /**
  115432. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  115433. */
  115434. get usePercentageCloserFiltering(): boolean;
  115435. /**
  115436. * Sets the current filter to "PCF" (percentage closer filtering).
  115437. */
  115438. set usePercentageCloserFiltering(value: boolean);
  115439. protected _filteringQuality: number;
  115440. /**
  115441. * Gets the PCF or PCSS Quality.
  115442. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  115443. */
  115444. get filteringQuality(): number;
  115445. /**
  115446. * Sets the PCF or PCSS Quality.
  115447. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  115448. */
  115449. set filteringQuality(filteringQuality: number);
  115450. /**
  115451. * Gets if the current filter is set to "PCSS" (contact hardening).
  115452. */
  115453. get useContactHardeningShadow(): boolean;
  115454. /**
  115455. * Sets the current filter to "PCSS" (contact hardening).
  115456. */
  115457. set useContactHardeningShadow(value: boolean);
  115458. protected _contactHardeningLightSizeUVRatio: number;
  115459. /**
  115460. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  115461. * Using a ratio helps keeping shape stability independently of the map size.
  115462. *
  115463. * It does not account for the light projection as it was having too much
  115464. * instability during the light setup or during light position changes.
  115465. *
  115466. * Only valid if useContactHardeningShadow is true.
  115467. */
  115468. get contactHardeningLightSizeUVRatio(): number;
  115469. /**
  115470. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  115471. * Using a ratio helps keeping shape stability independently of the map size.
  115472. *
  115473. * It does not account for the light projection as it was having too much
  115474. * instability during the light setup or during light position changes.
  115475. *
  115476. * Only valid if useContactHardeningShadow is true.
  115477. */
  115478. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  115479. protected _darkness: number;
  115480. /** Gets or sets the actual darkness of a shadow */
  115481. get darkness(): number;
  115482. set darkness(value: number);
  115483. /**
  115484. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  115485. * 0 means strongest and 1 would means no shadow.
  115486. * @returns the darkness.
  115487. */
  115488. getDarkness(): number;
  115489. /**
  115490. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  115491. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  115492. * @returns the shadow generator allowing fluent coding.
  115493. */
  115494. setDarkness(darkness: number): ShadowGenerator;
  115495. protected _transparencyShadow: boolean;
  115496. /** Gets or sets the ability to have transparent shadow */
  115497. get transparencyShadow(): boolean;
  115498. set transparencyShadow(value: boolean);
  115499. /**
  115500. * Sets the ability to have transparent shadow (boolean).
  115501. * @param transparent True if transparent else False
  115502. * @returns the shadow generator allowing fluent coding
  115503. */
  115504. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  115505. /**
  115506. * Enables or disables shadows with varying strength based on the transparency
  115507. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  115508. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  115509. * mesh.visibility * alphaTexture.a
  115510. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  115511. */
  115512. enableSoftTransparentShadow: boolean;
  115513. protected _shadowMap: Nullable<RenderTargetTexture>;
  115514. protected _shadowMap2: Nullable<RenderTargetTexture>;
  115515. /**
  115516. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  115517. * @returns The render target texture if present otherwise, null
  115518. */
  115519. getShadowMap(): Nullable<RenderTargetTexture>;
  115520. /**
  115521. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  115522. * @returns The render target texture if the shadow map is present otherwise, null
  115523. */
  115524. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  115525. /**
  115526. * Gets the class name of that object
  115527. * @returns "ShadowGenerator"
  115528. */
  115529. getClassName(): string;
  115530. /**
  115531. * Helper function to add a mesh and its descendants to the list of shadow casters.
  115532. * @param mesh Mesh to add
  115533. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  115534. * @returns the Shadow Generator itself
  115535. */
  115536. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  115537. /**
  115538. * Helper function to remove a mesh and its descendants from the list of shadow casters
  115539. * @param mesh Mesh to remove
  115540. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  115541. * @returns the Shadow Generator itself
  115542. */
  115543. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  115544. /**
  115545. * Controls the extent to which the shadows fade out at the edge of the frustum
  115546. */
  115547. frustumEdgeFalloff: number;
  115548. protected _light: IShadowLight;
  115549. /**
  115550. * Returns the associated light object.
  115551. * @returns the light generating the shadow
  115552. */
  115553. getLight(): IShadowLight;
  115554. /**
  115555. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  115556. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  115557. * It might on the other hand introduce peter panning.
  115558. */
  115559. forceBackFacesOnly: boolean;
  115560. protected _scene: Scene;
  115561. protected _lightDirection: Vector3;
  115562. protected _viewMatrix: Matrix;
  115563. protected _projectionMatrix: Matrix;
  115564. protected _transformMatrix: Matrix;
  115565. protected _cachedPosition: Vector3;
  115566. protected _cachedDirection: Vector3;
  115567. protected _cachedDefines: string;
  115568. protected _currentRenderID: number;
  115569. protected _boxBlurPostprocess: Nullable<PostProcess>;
  115570. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  115571. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  115572. protected _blurPostProcesses: PostProcess[];
  115573. protected _mapSize: number;
  115574. protected _currentFaceIndex: number;
  115575. protected _currentFaceIndexCache: number;
  115576. protected _textureType: number;
  115577. protected _defaultTextureMatrix: Matrix;
  115578. protected _storedUniqueId: Nullable<number>;
  115579. protected _nameForCustomEffect: string;
  115580. /** @hidden */
  115581. static _SceneComponentInitialization: (scene: Scene) => void;
  115582. /**
  115583. * Gets or sets the size of the texture what stores the shadows
  115584. */
  115585. get mapSize(): number;
  115586. set mapSize(size: number);
  115587. /**
  115588. * Creates a ShadowGenerator object.
  115589. * A ShadowGenerator is the required tool to use the shadows.
  115590. * Each light casting shadows needs to use its own ShadowGenerator.
  115591. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  115592. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  115593. * @param light The light object generating the shadows.
  115594. * @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.
  115595. */
  115596. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  115597. protected _initializeGenerator(): void;
  115598. protected _createTargetRenderTexture(): void;
  115599. protected _initializeShadowMap(): void;
  115600. protected _initializeBlurRTTAndPostProcesses(): void;
  115601. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  115602. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  115603. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  115604. protected _applyFilterValues(): void;
  115605. /**
  115606. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  115607. * @param onCompiled Callback triggered at the and of the effects compilation
  115608. * @param options Sets of optional options forcing the compilation with different modes
  115609. */
  115610. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  115611. useInstances: boolean;
  115612. }>): void;
  115613. /**
  115614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  115615. * @param options Sets of optional options forcing the compilation with different modes
  115616. * @returns A promise that resolves when the compilation completes
  115617. */
  115618. forceCompilationAsync(options?: Partial<{
  115619. useInstances: boolean;
  115620. }>): Promise<void>;
  115621. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  115622. private _prepareShadowDefines;
  115623. /**
  115624. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  115625. * @param subMesh The submesh we want to render in the shadow map
  115626. * @param useInstances Defines whether will draw in the map using instances
  115627. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  115628. * @returns true if ready otherwise, false
  115629. */
  115630. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  115631. /**
  115632. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  115633. * @param defines Defines of the material we want to update
  115634. * @param lightIndex Index of the light in the enabled light list of the material
  115635. */
  115636. prepareDefines(defines: any, lightIndex: number): void;
  115637. /**
  115638. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  115639. * defined in the generator but impacting the effect).
  115640. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  115641. * @param effect The effect we are binding the information for
  115642. */
  115643. bindShadowLight(lightIndex: string, effect: Effect): void;
  115644. /**
  115645. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  115646. * (eq to shadow projection matrix * light transform matrix)
  115647. * @returns The transform matrix used to create the shadow map
  115648. */
  115649. getTransformMatrix(): Matrix;
  115650. /**
  115651. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  115652. * Cube and 2D textures for instance.
  115653. */
  115654. recreateShadowMap(): void;
  115655. protected _disposeBlurPostProcesses(): void;
  115656. protected _disposeRTTandPostProcesses(): void;
  115657. /**
  115658. * Disposes the ShadowGenerator.
  115659. * Returns nothing.
  115660. */
  115661. dispose(): void;
  115662. /**
  115663. * Serializes the shadow generator setup to a json object.
  115664. * @returns The serialized JSON object
  115665. */
  115666. serialize(): any;
  115667. /**
  115668. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  115669. * @param parsedShadowGenerator The JSON object to parse
  115670. * @param scene The scene to create the shadow map for
  115671. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  115672. * @returns The parsed shadow generator
  115673. */
  115674. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  115675. }
  115676. }
  115677. declare module BABYLON {
  115678. /**
  115679. * Options to be used when creating a shadow depth material
  115680. */
  115681. export interface IIOptionShadowDepthMaterial {
  115682. /** Variables in the vertex shader code that need to have their names remapped.
  115683. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  115684. * "var_name" should be either: worldPos or vNormalW
  115685. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  115686. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  115687. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  115688. */
  115689. remappedVariables?: string[];
  115690. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  115691. standalone?: boolean;
  115692. }
  115693. /**
  115694. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  115695. */
  115696. export class ShadowDepthWrapper {
  115697. private _scene;
  115698. private _options?;
  115699. private _baseMaterial;
  115700. private _onEffectCreatedObserver;
  115701. private _subMeshToEffect;
  115702. private _subMeshToDepthEffect;
  115703. private _meshes;
  115704. /** @hidden */
  115705. _matriceNames: any;
  115706. /** Gets the standalone status of the wrapper */
  115707. get standalone(): boolean;
  115708. /** Gets the base material the wrapper is built upon */
  115709. get baseMaterial(): Material;
  115710. /**
  115711. * Instantiate a new shadow depth wrapper.
  115712. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  115713. * generate the shadow depth map. For more information, please refer to the documentation:
  115714. * https://doc.babylonjs.com/babylon101/shadows
  115715. * @param baseMaterial Material to wrap
  115716. * @param scene Define the scene the material belongs to
  115717. * @param options Options used to create the wrapper
  115718. */
  115719. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  115720. /**
  115721. * Gets the effect to use to generate the depth map
  115722. * @param subMesh subMesh to get the effect for
  115723. * @param shadowGenerator shadow generator to get the effect for
  115724. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  115725. */
  115726. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  115727. /**
  115728. * Specifies that the submesh is ready to be used for depth rendering
  115729. * @param subMesh submesh to check
  115730. * @param defines the list of defines to take into account when checking the effect
  115731. * @param shadowGenerator combined with subMesh, it defines the effect to check
  115732. * @param useInstances specifies that instances should be used
  115733. * @returns a boolean indicating that the submesh is ready or not
  115734. */
  115735. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  115736. /**
  115737. * Disposes the resources
  115738. */
  115739. dispose(): void;
  115740. private _makeEffect;
  115741. }
  115742. }
  115743. declare module BABYLON {
  115744. /**
  115745. * Options for compiling materials.
  115746. */
  115747. export interface IMaterialCompilationOptions {
  115748. /**
  115749. * Defines whether clip planes are enabled.
  115750. */
  115751. clipPlane: boolean;
  115752. /**
  115753. * Defines whether instances are enabled.
  115754. */
  115755. useInstances: boolean;
  115756. }
  115757. /**
  115758. * Options passed when calling customShaderNameResolve
  115759. */
  115760. export interface ICustomShaderNameResolveOptions {
  115761. /**
  115762. * 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
  115763. */
  115764. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  115765. }
  115766. /**
  115767. * Base class for the main features of a material in Babylon.js
  115768. */
  115769. export class Material implements IAnimatable {
  115770. /**
  115771. * Returns the triangle fill mode
  115772. */
  115773. static readonly TriangleFillMode: number;
  115774. /**
  115775. * Returns the wireframe mode
  115776. */
  115777. static readonly WireFrameFillMode: number;
  115778. /**
  115779. * Returns the point fill mode
  115780. */
  115781. static readonly PointFillMode: number;
  115782. /**
  115783. * Returns the point list draw mode
  115784. */
  115785. static readonly PointListDrawMode: number;
  115786. /**
  115787. * Returns the line list draw mode
  115788. */
  115789. static readonly LineListDrawMode: number;
  115790. /**
  115791. * Returns the line loop draw mode
  115792. */
  115793. static readonly LineLoopDrawMode: number;
  115794. /**
  115795. * Returns the line strip draw mode
  115796. */
  115797. static readonly LineStripDrawMode: number;
  115798. /**
  115799. * Returns the triangle strip draw mode
  115800. */
  115801. static readonly TriangleStripDrawMode: number;
  115802. /**
  115803. * Returns the triangle fan draw mode
  115804. */
  115805. static readonly TriangleFanDrawMode: number;
  115806. /**
  115807. * Stores the clock-wise side orientation
  115808. */
  115809. static readonly ClockWiseSideOrientation: number;
  115810. /**
  115811. * Stores the counter clock-wise side orientation
  115812. */
  115813. static readonly CounterClockWiseSideOrientation: number;
  115814. /**
  115815. * The dirty texture flag value
  115816. */
  115817. static readonly TextureDirtyFlag: number;
  115818. /**
  115819. * The dirty light flag value
  115820. */
  115821. static readonly LightDirtyFlag: number;
  115822. /**
  115823. * The dirty fresnel flag value
  115824. */
  115825. static readonly FresnelDirtyFlag: number;
  115826. /**
  115827. * The dirty attribute flag value
  115828. */
  115829. static readonly AttributesDirtyFlag: number;
  115830. /**
  115831. * The dirty misc flag value
  115832. */
  115833. static readonly MiscDirtyFlag: number;
  115834. /**
  115835. * The dirty prepass flag value
  115836. */
  115837. static readonly PrePassDirtyFlag: number;
  115838. /**
  115839. * The all dirty flag value
  115840. */
  115841. static readonly AllDirtyFlag: number;
  115842. /**
  115843. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115844. */
  115845. static readonly MATERIAL_OPAQUE: number;
  115846. /**
  115847. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115848. */
  115849. static readonly MATERIAL_ALPHATEST: number;
  115850. /**
  115851. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115852. */
  115853. static readonly MATERIAL_ALPHABLEND: number;
  115854. /**
  115855. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115856. * They are also discarded below the alpha cutoff threshold to improve performances.
  115857. */
  115858. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  115859. /**
  115860. * The Whiteout method is used to blend normals.
  115861. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  115862. */
  115863. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  115864. /**
  115865. * The Reoriented Normal Mapping method is used to blend normals.
  115866. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  115867. */
  115868. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  115869. /**
  115870. * Custom callback helping to override the default shader used in the material.
  115871. */
  115872. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  115873. /**
  115874. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  115875. */
  115876. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  115877. /**
  115878. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  115879. * This means that the material can keep using a previous shader while a new one is being compiled.
  115880. * This is mostly used when shader parallel compilation is supported (true by default)
  115881. */
  115882. allowShaderHotSwapping: boolean;
  115883. /**
  115884. * The ID of the material
  115885. */
  115886. id: string;
  115887. /**
  115888. * Gets or sets the unique id of the material
  115889. */
  115890. uniqueId: number;
  115891. /**
  115892. * The name of the material
  115893. */
  115894. name: string;
  115895. /**
  115896. * Gets or sets user defined metadata
  115897. */
  115898. metadata: any;
  115899. /**
  115900. * For internal use only. Please do not use.
  115901. */
  115902. reservedDataStore: any;
  115903. /**
  115904. * Specifies if the ready state should be checked on each call
  115905. */
  115906. checkReadyOnEveryCall: boolean;
  115907. /**
  115908. * Specifies if the ready state should be checked once
  115909. */
  115910. checkReadyOnlyOnce: boolean;
  115911. /**
  115912. * The state of the material
  115913. */
  115914. state: string;
  115915. /**
  115916. * If the material can be rendered to several textures with MRT extension
  115917. */
  115918. get canRenderToMRT(): boolean;
  115919. /**
  115920. * The alpha value of the material
  115921. */
  115922. protected _alpha: number;
  115923. /**
  115924. * List of inspectable custom properties (used by the Inspector)
  115925. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  115926. */
  115927. inspectableCustomProperties: IInspectable[];
  115928. /**
  115929. * Sets the alpha value of the material
  115930. */
  115931. set alpha(value: number);
  115932. /**
  115933. * Gets the alpha value of the material
  115934. */
  115935. get alpha(): number;
  115936. /**
  115937. * Specifies if back face culling is enabled
  115938. */
  115939. protected _backFaceCulling: boolean;
  115940. /**
  115941. * Sets the back-face culling state
  115942. */
  115943. set backFaceCulling(value: boolean);
  115944. /**
  115945. * Gets the back-face culling state
  115946. */
  115947. get backFaceCulling(): boolean;
  115948. /**
  115949. * Stores the value for side orientation
  115950. */
  115951. sideOrientation: number;
  115952. /**
  115953. * Callback triggered when the material is compiled
  115954. */
  115955. onCompiled: Nullable<(effect: Effect) => void>;
  115956. /**
  115957. * Callback triggered when an error occurs
  115958. */
  115959. onError: Nullable<(effect: Effect, errors: string) => void>;
  115960. /**
  115961. * Callback triggered to get the render target textures
  115962. */
  115963. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  115964. /**
  115965. * Gets a boolean indicating that current material needs to register RTT
  115966. */
  115967. get hasRenderTargetTextures(): boolean;
  115968. /**
  115969. * Specifies if the material should be serialized
  115970. */
  115971. doNotSerialize: boolean;
  115972. /**
  115973. * @hidden
  115974. */
  115975. _storeEffectOnSubMeshes: boolean;
  115976. /**
  115977. * Stores the animations for the material
  115978. */
  115979. animations: Nullable<Array<Animation>>;
  115980. /**
  115981. * An event triggered when the material is disposed
  115982. */
  115983. onDisposeObservable: Observable<Material>;
  115984. /**
  115985. * An observer which watches for dispose events
  115986. */
  115987. private _onDisposeObserver;
  115988. private _onUnBindObservable;
  115989. /**
  115990. * Called during a dispose event
  115991. */
  115992. set onDispose(callback: () => void);
  115993. private _onBindObservable;
  115994. /**
  115995. * An event triggered when the material is bound
  115996. */
  115997. get onBindObservable(): Observable<AbstractMesh>;
  115998. /**
  115999. * An observer which watches for bind events
  116000. */
  116001. private _onBindObserver;
  116002. /**
  116003. * Called during a bind event
  116004. */
  116005. set onBind(callback: (Mesh: AbstractMesh) => void);
  116006. /**
  116007. * An event triggered when the material is unbound
  116008. */
  116009. get onUnBindObservable(): Observable<Material>;
  116010. protected _onEffectCreatedObservable: Nullable<Observable<{
  116011. effect: Effect;
  116012. subMesh: Nullable<SubMesh>;
  116013. }>>;
  116014. /**
  116015. * An event triggered when the effect is (re)created
  116016. */
  116017. get onEffectCreatedObservable(): Observable<{
  116018. effect: Effect;
  116019. subMesh: Nullable<SubMesh>;
  116020. }>;
  116021. /**
  116022. * Stores the value of the alpha mode
  116023. */
  116024. private _alphaMode;
  116025. /**
  116026. * Sets the value of the alpha mode.
  116027. *
  116028. * | Value | Type | Description |
  116029. * | --- | --- | --- |
  116030. * | 0 | ALPHA_DISABLE | |
  116031. * | 1 | ALPHA_ADD | |
  116032. * | 2 | ALPHA_COMBINE | |
  116033. * | 3 | ALPHA_SUBTRACT | |
  116034. * | 4 | ALPHA_MULTIPLY | |
  116035. * | 5 | ALPHA_MAXIMIZED | |
  116036. * | 6 | ALPHA_ONEONE | |
  116037. * | 7 | ALPHA_PREMULTIPLIED | |
  116038. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  116039. * | 9 | ALPHA_INTERPOLATE | |
  116040. * | 10 | ALPHA_SCREENMODE | |
  116041. *
  116042. */
  116043. set alphaMode(value: number);
  116044. /**
  116045. * Gets the value of the alpha mode
  116046. */
  116047. get alphaMode(): number;
  116048. /**
  116049. * Stores the state of the need depth pre-pass value
  116050. */
  116051. private _needDepthPrePass;
  116052. /**
  116053. * Sets the need depth pre-pass value
  116054. */
  116055. set needDepthPrePass(value: boolean);
  116056. /**
  116057. * Gets the depth pre-pass value
  116058. */
  116059. get needDepthPrePass(): boolean;
  116060. /**
  116061. * Can this material render to prepass
  116062. */
  116063. get isPrePassCapable(): boolean;
  116064. /**
  116065. * Specifies if depth writing should be disabled
  116066. */
  116067. disableDepthWrite: boolean;
  116068. /**
  116069. * Specifies if color writing should be disabled
  116070. */
  116071. disableColorWrite: boolean;
  116072. /**
  116073. * Specifies if depth writing should be forced
  116074. */
  116075. forceDepthWrite: boolean;
  116076. /**
  116077. * Specifies the depth function that should be used. 0 means the default engine function
  116078. */
  116079. depthFunction: number;
  116080. /**
  116081. * Specifies if there should be a separate pass for culling
  116082. */
  116083. separateCullingPass: boolean;
  116084. /**
  116085. * Stores the state specifying if fog should be enabled
  116086. */
  116087. private _fogEnabled;
  116088. /**
  116089. * Sets the state for enabling fog
  116090. */
  116091. set fogEnabled(value: boolean);
  116092. /**
  116093. * Gets the value of the fog enabled state
  116094. */
  116095. get fogEnabled(): boolean;
  116096. /**
  116097. * Stores the size of points
  116098. */
  116099. pointSize: number;
  116100. /**
  116101. * Stores the z offset value
  116102. */
  116103. zOffset: number;
  116104. get wireframe(): boolean;
  116105. /**
  116106. * Sets the state of wireframe mode
  116107. */
  116108. set wireframe(value: boolean);
  116109. /**
  116110. * Gets the value specifying if point clouds are enabled
  116111. */
  116112. get pointsCloud(): boolean;
  116113. /**
  116114. * Sets the state of point cloud mode
  116115. */
  116116. set pointsCloud(value: boolean);
  116117. /**
  116118. * Gets the material fill mode
  116119. */
  116120. get fillMode(): number;
  116121. /**
  116122. * Sets the material fill mode
  116123. */
  116124. set fillMode(value: number);
  116125. /**
  116126. * @hidden
  116127. * Stores the effects for the material
  116128. */
  116129. _effect: Nullable<Effect>;
  116130. /**
  116131. * Specifies if uniform buffers should be used
  116132. */
  116133. private _useUBO;
  116134. /**
  116135. * Stores a reference to the scene
  116136. */
  116137. private _scene;
  116138. private _needToBindSceneUbo;
  116139. /**
  116140. * Stores the fill mode state
  116141. */
  116142. private _fillMode;
  116143. /**
  116144. * Specifies if the depth write state should be cached
  116145. */
  116146. private _cachedDepthWriteState;
  116147. /**
  116148. * Specifies if the color write state should be cached
  116149. */
  116150. private _cachedColorWriteState;
  116151. /**
  116152. * Specifies if the depth function state should be cached
  116153. */
  116154. private _cachedDepthFunctionState;
  116155. /**
  116156. * Stores the uniform buffer
  116157. */
  116158. protected _uniformBuffer: UniformBuffer;
  116159. /** @hidden */
  116160. _indexInSceneMaterialArray: number;
  116161. /** @hidden */
  116162. meshMap: Nullable<{
  116163. [id: string]: AbstractMesh | undefined;
  116164. }>;
  116165. /**
  116166. * Creates a material instance
  116167. * @param name defines the name of the material
  116168. * @param scene defines the scene to reference
  116169. * @param doNotAdd specifies if the material should be added to the scene
  116170. */
  116171. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  116172. /**
  116173. * Returns a string representation of the current material
  116174. * @param fullDetails defines a boolean indicating which levels of logging is desired
  116175. * @returns a string with material information
  116176. */
  116177. toString(fullDetails?: boolean): string;
  116178. /**
  116179. * Gets the class name of the material
  116180. * @returns a string with the class name of the material
  116181. */
  116182. getClassName(): string;
  116183. /**
  116184. * Specifies if updates for the material been locked
  116185. */
  116186. get isFrozen(): boolean;
  116187. /**
  116188. * Locks updates for the material
  116189. */
  116190. freeze(): void;
  116191. /**
  116192. * Unlocks updates for the material
  116193. */
  116194. unfreeze(): void;
  116195. /**
  116196. * Specifies if the material is ready to be used
  116197. * @param mesh defines the mesh to check
  116198. * @param useInstances specifies if instances should be used
  116199. * @returns a boolean indicating if the material is ready to be used
  116200. */
  116201. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  116202. /**
  116203. * Specifies that the submesh is ready to be used
  116204. * @param mesh defines the mesh to check
  116205. * @param subMesh defines which submesh to check
  116206. * @param useInstances specifies that instances should be used
  116207. * @returns a boolean indicating that the submesh is ready or not
  116208. */
  116209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116210. /**
  116211. * Returns the material effect
  116212. * @returns the effect associated with the material
  116213. */
  116214. getEffect(): Nullable<Effect>;
  116215. /**
  116216. * Returns the current scene
  116217. * @returns a Scene
  116218. */
  116219. getScene(): Scene;
  116220. /**
  116221. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116222. */
  116223. protected _forceAlphaTest: boolean;
  116224. /**
  116225. * The transparency mode of the material.
  116226. */
  116227. protected _transparencyMode: Nullable<number>;
  116228. /**
  116229. * Gets the current transparency mode.
  116230. */
  116231. get transparencyMode(): Nullable<number>;
  116232. /**
  116233. * Sets the transparency mode of the material.
  116234. *
  116235. * | Value | Type | Description |
  116236. * | ----- | ----------------------------------- | ----------- |
  116237. * | 0 | OPAQUE | |
  116238. * | 1 | ALPHATEST | |
  116239. * | 2 | ALPHABLEND | |
  116240. * | 3 | ALPHATESTANDBLEND | |
  116241. *
  116242. */
  116243. set transparencyMode(value: Nullable<number>);
  116244. /**
  116245. * Returns true if alpha blending should be disabled.
  116246. */
  116247. protected get _disableAlphaBlending(): boolean;
  116248. /**
  116249. * Specifies whether or not this material should be rendered in alpha blend mode.
  116250. * @returns a boolean specifying if alpha blending is needed
  116251. */
  116252. needAlphaBlending(): boolean;
  116253. /**
  116254. * Specifies if the mesh will require alpha blending
  116255. * @param mesh defines the mesh to check
  116256. * @returns a boolean specifying if alpha blending is needed for the mesh
  116257. */
  116258. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116259. /**
  116260. * Specifies whether or not this material should be rendered in alpha test mode.
  116261. * @returns a boolean specifying if an alpha test is needed.
  116262. */
  116263. needAlphaTesting(): boolean;
  116264. /**
  116265. * Specifies if material alpha testing should be turned on for the mesh
  116266. * @param mesh defines the mesh to check
  116267. */
  116268. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  116269. /**
  116270. * Gets the texture used for the alpha test
  116271. * @returns the texture to use for alpha testing
  116272. */
  116273. getAlphaTestTexture(): Nullable<BaseTexture>;
  116274. /**
  116275. * Marks the material to indicate that it needs to be re-calculated
  116276. */
  116277. markDirty(): void;
  116278. /** @hidden */
  116279. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  116280. /**
  116281. * Binds the material to the mesh
  116282. * @param world defines the world transformation matrix
  116283. * @param mesh defines the mesh to bind the material to
  116284. */
  116285. bind(world: Matrix, mesh?: Mesh): void;
  116286. /**
  116287. * Binds the submesh to the material
  116288. * @param world defines the world transformation matrix
  116289. * @param mesh defines the mesh containing the submesh
  116290. * @param subMesh defines the submesh to bind the material to
  116291. */
  116292. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116293. /**
  116294. * Binds the world matrix to the material
  116295. * @param world defines the world transformation matrix
  116296. */
  116297. bindOnlyWorldMatrix(world: Matrix): void;
  116298. /**
  116299. * Binds the view matrix to the effect
  116300. * @param effect defines the effect to bind the view matrix to
  116301. */
  116302. bindView(effect: Effect): void;
  116303. /**
  116304. * Binds the view projection and projection matrices to the effect
  116305. * @param effect defines the effect to bind the view projection and projection matrices to
  116306. */
  116307. bindViewProjection(effect: Effect): void;
  116308. /**
  116309. * Binds the view matrix to the effect
  116310. * @param effect defines the effect to bind the view matrix to
  116311. * @param variableName name of the shader variable that will hold the eye position
  116312. */
  116313. bindEyePosition(effect: Effect, variableName?: string): void;
  116314. /**
  116315. * Processes to execute after binding the material to a mesh
  116316. * @param mesh defines the rendered mesh
  116317. */
  116318. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  116319. /**
  116320. * Unbinds the material from the mesh
  116321. */
  116322. unbind(): void;
  116323. /**
  116324. * Gets the active textures from the material
  116325. * @returns an array of textures
  116326. */
  116327. getActiveTextures(): BaseTexture[];
  116328. /**
  116329. * Specifies if the material uses a texture
  116330. * @param texture defines the texture to check against the material
  116331. * @returns a boolean specifying if the material uses the texture
  116332. */
  116333. hasTexture(texture: BaseTexture): boolean;
  116334. /**
  116335. * Makes a duplicate of the material, and gives it a new name
  116336. * @param name defines the new name for the duplicated material
  116337. * @returns the cloned material
  116338. */
  116339. clone(name: string): Nullable<Material>;
  116340. /**
  116341. * Gets the meshes bound to the material
  116342. * @returns an array of meshes bound to the material
  116343. */
  116344. getBindedMeshes(): AbstractMesh[];
  116345. /**
  116346. * Force shader compilation
  116347. * @param mesh defines the mesh associated with this material
  116348. * @param onCompiled defines a function to execute once the material is compiled
  116349. * @param options defines the options to configure the compilation
  116350. * @param onError defines a function to execute if the material fails compiling
  116351. */
  116352. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  116353. /**
  116354. * Force shader compilation
  116355. * @param mesh defines the mesh that will use this material
  116356. * @param options defines additional options for compiling the shaders
  116357. * @returns a promise that resolves when the compilation completes
  116358. */
  116359. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  116360. private static readonly _AllDirtyCallBack;
  116361. private static readonly _ImageProcessingDirtyCallBack;
  116362. private static readonly _TextureDirtyCallBack;
  116363. private static readonly _FresnelDirtyCallBack;
  116364. private static readonly _MiscDirtyCallBack;
  116365. private static readonly _PrePassDirtyCallBack;
  116366. private static readonly _LightsDirtyCallBack;
  116367. private static readonly _AttributeDirtyCallBack;
  116368. private static _FresnelAndMiscDirtyCallBack;
  116369. private static _TextureAndMiscDirtyCallBack;
  116370. private static readonly _DirtyCallbackArray;
  116371. private static readonly _RunDirtyCallBacks;
  116372. /**
  116373. * Marks a define in the material to indicate that it needs to be re-computed
  116374. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  116375. */
  116376. markAsDirty(flag: number): void;
  116377. /**
  116378. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  116379. * @param func defines a function which checks material defines against the submeshes
  116380. */
  116381. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  116382. /**
  116383. * Indicates that the scene should check if the rendering now needs a prepass
  116384. */
  116385. protected _markScenePrePassDirty(): void;
  116386. /**
  116387. * Indicates that we need to re-calculated for all submeshes
  116388. */
  116389. protected _markAllSubMeshesAsAllDirty(): void;
  116390. /**
  116391. * Indicates that image processing needs to be re-calculated for all submeshes
  116392. */
  116393. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  116394. /**
  116395. * Indicates that textures need to be re-calculated for all submeshes
  116396. */
  116397. protected _markAllSubMeshesAsTexturesDirty(): void;
  116398. /**
  116399. * Indicates that fresnel needs to be re-calculated for all submeshes
  116400. */
  116401. protected _markAllSubMeshesAsFresnelDirty(): void;
  116402. /**
  116403. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  116404. */
  116405. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  116406. /**
  116407. * Indicates that lights need to be re-calculated for all submeshes
  116408. */
  116409. protected _markAllSubMeshesAsLightsDirty(): void;
  116410. /**
  116411. * Indicates that attributes need to be re-calculated for all submeshes
  116412. */
  116413. protected _markAllSubMeshesAsAttributesDirty(): void;
  116414. /**
  116415. * Indicates that misc needs to be re-calculated for all submeshes
  116416. */
  116417. protected _markAllSubMeshesAsMiscDirty(): void;
  116418. /**
  116419. * Indicates that prepass needs to be re-calculated for all submeshes
  116420. */
  116421. protected _markAllSubMeshesAsPrePassDirty(): void;
  116422. /**
  116423. * Indicates that textures and misc need to be re-calculated for all submeshes
  116424. */
  116425. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  116426. /**
  116427. * Sets the required values to the prepass renderer.
  116428. * @param prePassRenderer defines the prepass renderer to setup.
  116429. * @returns true if the pre pass is needed.
  116430. */
  116431. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  116432. /**
  116433. * Disposes the material
  116434. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  116435. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  116436. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  116437. */
  116438. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  116439. /** @hidden */
  116440. private releaseVertexArrayObject;
  116441. /**
  116442. * Serializes this material
  116443. * @returns the serialized material object
  116444. */
  116445. serialize(): any;
  116446. /**
  116447. * Creates a material from parsed material data
  116448. * @param parsedMaterial defines parsed material data
  116449. * @param scene defines the hosting scene
  116450. * @param rootUrl defines the root URL to use to load textures
  116451. * @returns a new material
  116452. */
  116453. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  116454. }
  116455. }
  116456. declare module BABYLON {
  116457. /**
  116458. * A multi-material is used to apply different materials to different parts of the same object without the need of
  116459. * separate meshes. This can be use to improve performances.
  116460. * @see https://doc.babylonjs.com/how_to/multi_materials
  116461. */
  116462. export class MultiMaterial extends Material {
  116463. private _subMaterials;
  116464. /**
  116465. * Gets or Sets the list of Materials used within the multi material.
  116466. * They need to be ordered according to the submeshes order in the associated mesh
  116467. */
  116468. get subMaterials(): Nullable<Material>[];
  116469. set subMaterials(value: Nullable<Material>[]);
  116470. /**
  116471. * Function used to align with Node.getChildren()
  116472. * @returns the list of Materials used within the multi material
  116473. */
  116474. getChildren(): Nullable<Material>[];
  116475. /**
  116476. * Instantiates a new Multi Material
  116477. * A multi-material is used to apply different materials to different parts of the same object without the need of
  116478. * separate meshes. This can be use to improve performances.
  116479. * @see https://doc.babylonjs.com/how_to/multi_materials
  116480. * @param name Define the name in the scene
  116481. * @param scene Define the scene the material belongs to
  116482. */
  116483. constructor(name: string, scene: Scene);
  116484. private _hookArray;
  116485. /**
  116486. * Get one of the submaterial by its index in the submaterials array
  116487. * @param index The index to look the sub material at
  116488. * @returns The Material if the index has been defined
  116489. */
  116490. getSubMaterial(index: number): Nullable<Material>;
  116491. /**
  116492. * Get the list of active textures for the whole sub materials list.
  116493. * @returns All the textures that will be used during the rendering
  116494. */
  116495. getActiveTextures(): BaseTexture[];
  116496. /**
  116497. * Specifies if any sub-materials of this multi-material use a given texture.
  116498. * @param texture Defines the texture to check against this multi-material's sub-materials.
  116499. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  116500. */
  116501. hasTexture(texture: BaseTexture): boolean;
  116502. /**
  116503. * Gets the current class name of the material e.g. "MultiMaterial"
  116504. * Mainly use in serialization.
  116505. * @returns the class name
  116506. */
  116507. getClassName(): string;
  116508. /**
  116509. * Checks if the material is ready to render the requested sub mesh
  116510. * @param mesh Define the mesh the submesh belongs to
  116511. * @param subMesh Define the sub mesh to look readiness for
  116512. * @param useInstances Define whether or not the material is used with instances
  116513. * @returns true if ready, otherwise false
  116514. */
  116515. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116516. /**
  116517. * Clones the current material and its related sub materials
  116518. * @param name Define the name of the newly cloned material
  116519. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  116520. * @returns the cloned material
  116521. */
  116522. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  116523. /**
  116524. * Serializes the materials into a JSON representation.
  116525. * @returns the JSON representation
  116526. */
  116527. serialize(): any;
  116528. /**
  116529. * Dispose the material and release its associated resources
  116530. * @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)
  116531. * @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)
  116532. * @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)
  116533. */
  116534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  116535. /**
  116536. * Creates a MultiMaterial from parsed MultiMaterial data.
  116537. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  116538. * @param scene defines the hosting scene
  116539. * @returns a new MultiMaterial
  116540. */
  116541. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  116542. }
  116543. }
  116544. declare module BABYLON {
  116545. /** @hidden */
  116546. export interface ICustomEffect {
  116547. effect: Effect;
  116548. defines: string;
  116549. }
  116550. /**
  116551. * Defines a subdivision inside a mesh
  116552. */
  116553. export class SubMesh implements ICullable {
  116554. /** the material index to use */
  116555. materialIndex: number;
  116556. /** vertex index start */
  116557. verticesStart: number;
  116558. /** vertices count */
  116559. verticesCount: number;
  116560. /** index start */
  116561. indexStart: number;
  116562. /** indices count */
  116563. indexCount: number;
  116564. /** @hidden */
  116565. _materialDefines: Nullable<MaterialDefines>;
  116566. /** @hidden */
  116567. _materialEffect: Nullable<Effect>;
  116568. /** @hidden */
  116569. _effectOverride: Nullable<Effect>;
  116570. private _customEffects;
  116571. /**
  116572. * Gets material defines used by the effect associated to the sub mesh
  116573. */
  116574. get materialDefines(): Nullable<MaterialDefines>;
  116575. /**
  116576. * Sets material defines used by the effect associated to the sub mesh
  116577. */
  116578. set materialDefines(defines: Nullable<MaterialDefines>);
  116579. /** @hidden */
  116580. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  116581. /** @hidden */
  116582. _removeCustomEffect(name: string): void;
  116583. /**
  116584. * Gets associated effect
  116585. */
  116586. get effect(): Nullable<Effect>;
  116587. /**
  116588. * Sets associated effect (effect used to render this submesh)
  116589. * @param effect defines the effect to associate with
  116590. * @param defines defines the set of defines used to compile this effect
  116591. */
  116592. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  116593. /** @hidden */
  116594. _linesIndexCount: number;
  116595. private _mesh;
  116596. private _renderingMesh;
  116597. private _boundingInfo;
  116598. private _linesIndexBuffer;
  116599. /** @hidden */
  116600. _lastColliderWorldVertices: Nullable<Vector3[]>;
  116601. /** @hidden */
  116602. _trianglePlanes: Plane[];
  116603. /** @hidden */
  116604. _lastColliderTransformMatrix: Nullable<Matrix>;
  116605. /** @hidden */
  116606. _renderId: number;
  116607. /** @hidden */
  116608. _alphaIndex: number;
  116609. /** @hidden */
  116610. _distanceToCamera: number;
  116611. /** @hidden */
  116612. _id: number;
  116613. private _currentMaterial;
  116614. /**
  116615. * Add a new submesh to a mesh
  116616. * @param materialIndex defines the material index to use
  116617. * @param verticesStart defines vertex index start
  116618. * @param verticesCount defines vertices count
  116619. * @param indexStart defines index start
  116620. * @param indexCount defines indices count
  116621. * @param mesh defines the parent mesh
  116622. * @param renderingMesh defines an optional rendering mesh
  116623. * @param createBoundingBox defines if bounding box should be created for this submesh
  116624. * @returns the new submesh
  116625. */
  116626. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  116627. /**
  116628. * Creates a new submesh
  116629. * @param materialIndex defines the material index to use
  116630. * @param verticesStart defines vertex index start
  116631. * @param verticesCount defines vertices count
  116632. * @param indexStart defines index start
  116633. * @param indexCount defines indices count
  116634. * @param mesh defines the parent mesh
  116635. * @param renderingMesh defines an optional rendering mesh
  116636. * @param createBoundingBox defines if bounding box should be created for this submesh
  116637. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  116638. */
  116639. constructor(
  116640. /** the material index to use */
  116641. materialIndex: number,
  116642. /** vertex index start */
  116643. verticesStart: number,
  116644. /** vertices count */
  116645. verticesCount: number,
  116646. /** index start */
  116647. indexStart: number,
  116648. /** indices count */
  116649. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  116650. /**
  116651. * Returns true if this submesh covers the entire parent mesh
  116652. * @ignorenaming
  116653. */
  116654. get IsGlobal(): boolean;
  116655. /**
  116656. * Returns the submesh BoundingInfo object
  116657. * @returns current bounding info (or mesh's one if the submesh is global)
  116658. */
  116659. getBoundingInfo(): BoundingInfo;
  116660. /**
  116661. * Sets the submesh BoundingInfo
  116662. * @param boundingInfo defines the new bounding info to use
  116663. * @returns the SubMesh
  116664. */
  116665. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  116666. /**
  116667. * Returns the mesh of the current submesh
  116668. * @return the parent mesh
  116669. */
  116670. getMesh(): AbstractMesh;
  116671. /**
  116672. * Returns the rendering mesh of the submesh
  116673. * @returns the rendering mesh (could be different from parent mesh)
  116674. */
  116675. getRenderingMesh(): Mesh;
  116676. /**
  116677. * Returns the replacement mesh of the submesh
  116678. * @returns the replacement mesh (could be different from parent mesh)
  116679. */
  116680. getReplacementMesh(): Nullable<AbstractMesh>;
  116681. /**
  116682. * Returns the effective mesh of the submesh
  116683. * @returns the effective mesh (could be different from parent mesh)
  116684. */
  116685. getEffectiveMesh(): AbstractMesh;
  116686. /**
  116687. * Returns the submesh material
  116688. * @returns null or the current material
  116689. */
  116690. getMaterial(): Nullable<Material>;
  116691. private _IsMultiMaterial;
  116692. /**
  116693. * Sets a new updated BoundingInfo object to the submesh
  116694. * @param data defines an optional position array to use to determine the bounding info
  116695. * @returns the SubMesh
  116696. */
  116697. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  116698. /** @hidden */
  116699. _checkCollision(collider: Collider): boolean;
  116700. /**
  116701. * Updates the submesh BoundingInfo
  116702. * @param world defines the world matrix to use to update the bounding info
  116703. * @returns the submesh
  116704. */
  116705. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  116706. /**
  116707. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  116708. * @param frustumPlanes defines the frustum planes
  116709. * @returns true if the submesh is intersecting with the frustum
  116710. */
  116711. isInFrustum(frustumPlanes: Plane[]): boolean;
  116712. /**
  116713. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  116714. * @param frustumPlanes defines the frustum planes
  116715. * @returns true if the submesh is inside the frustum
  116716. */
  116717. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116718. /**
  116719. * Renders the submesh
  116720. * @param enableAlphaMode defines if alpha needs to be used
  116721. * @returns the submesh
  116722. */
  116723. render(enableAlphaMode: boolean): SubMesh;
  116724. /**
  116725. * @hidden
  116726. */
  116727. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  116728. /**
  116729. * Checks if the submesh intersects with a ray
  116730. * @param ray defines the ray to test
  116731. * @returns true is the passed ray intersects the submesh bounding box
  116732. */
  116733. canIntersects(ray: Ray): boolean;
  116734. /**
  116735. * Intersects current submesh with a ray
  116736. * @param ray defines the ray to test
  116737. * @param positions defines mesh's positions array
  116738. * @param indices defines mesh's indices array
  116739. * @param fastCheck defines if the first intersection will be used (and not the closest)
  116740. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116741. * @returns intersection info or null if no intersection
  116742. */
  116743. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  116744. /** @hidden */
  116745. private _intersectLines;
  116746. /** @hidden */
  116747. private _intersectUnIndexedLines;
  116748. /** @hidden */
  116749. private _intersectTriangles;
  116750. /** @hidden */
  116751. private _intersectUnIndexedTriangles;
  116752. /** @hidden */
  116753. _rebuild(): void;
  116754. /**
  116755. * Creates a new submesh from the passed mesh
  116756. * @param newMesh defines the new hosting mesh
  116757. * @param newRenderingMesh defines an optional rendering mesh
  116758. * @returns the new submesh
  116759. */
  116760. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  116761. /**
  116762. * Release associated resources
  116763. */
  116764. dispose(): void;
  116765. /**
  116766. * Gets the class name
  116767. * @returns the string "SubMesh".
  116768. */
  116769. getClassName(): string;
  116770. /**
  116771. * Creates a new submesh from indices data
  116772. * @param materialIndex the index of the main mesh material
  116773. * @param startIndex the index where to start the copy in the mesh indices array
  116774. * @param indexCount the number of indices to copy then from the startIndex
  116775. * @param mesh the main mesh to create the submesh from
  116776. * @param renderingMesh the optional rendering mesh
  116777. * @returns a new submesh
  116778. */
  116779. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  116780. }
  116781. }
  116782. declare module BABYLON {
  116783. /**
  116784. * Class used to represent data loading progression
  116785. */
  116786. export class SceneLoaderFlags {
  116787. private static _ForceFullSceneLoadingForIncremental;
  116788. private static _ShowLoadingScreen;
  116789. private static _CleanBoneMatrixWeights;
  116790. private static _loggingLevel;
  116791. /**
  116792. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116793. */
  116794. static get ForceFullSceneLoadingForIncremental(): boolean;
  116795. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116796. /**
  116797. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116798. */
  116799. static get ShowLoadingScreen(): boolean;
  116800. static set ShowLoadingScreen(value: boolean);
  116801. /**
  116802. * Defines the current logging level (while loading the scene)
  116803. * @ignorenaming
  116804. */
  116805. static get loggingLevel(): number;
  116806. static set loggingLevel(value: number);
  116807. /**
  116808. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116809. */
  116810. static get CleanBoneMatrixWeights(): boolean;
  116811. static set CleanBoneMatrixWeights(value: boolean);
  116812. }
  116813. }
  116814. declare module BABYLON {
  116815. /**
  116816. * Class used to store geometry data (vertex buffers + index buffer)
  116817. */
  116818. export class Geometry implements IGetSetVerticesData {
  116819. /**
  116820. * Gets or sets the ID of the geometry
  116821. */
  116822. id: string;
  116823. /**
  116824. * Gets or sets the unique ID of the geometry
  116825. */
  116826. uniqueId: number;
  116827. /**
  116828. * Gets the delay loading state of the geometry (none by default which means not delayed)
  116829. */
  116830. delayLoadState: number;
  116831. /**
  116832. * Gets the file containing the data to load when running in delay load state
  116833. */
  116834. delayLoadingFile: Nullable<string>;
  116835. /**
  116836. * Callback called when the geometry is updated
  116837. */
  116838. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  116839. private _scene;
  116840. private _engine;
  116841. private _meshes;
  116842. private _totalVertices;
  116843. /** @hidden */
  116844. _indices: IndicesArray;
  116845. /** @hidden */
  116846. _vertexBuffers: {
  116847. [key: string]: VertexBuffer;
  116848. };
  116849. private _isDisposed;
  116850. private _extend;
  116851. private _boundingBias;
  116852. /** @hidden */
  116853. _delayInfo: Array<string>;
  116854. private _indexBuffer;
  116855. private _indexBufferIsUpdatable;
  116856. /** @hidden */
  116857. _boundingInfo: Nullable<BoundingInfo>;
  116858. /** @hidden */
  116859. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  116860. /** @hidden */
  116861. _softwareSkinningFrameId: number;
  116862. private _vertexArrayObjects;
  116863. private _updatable;
  116864. /** @hidden */
  116865. _positions: Nullable<Vector3[]>;
  116866. private _positionsCache;
  116867. /**
  116868. * 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
  116869. */
  116870. get boundingBias(): Vector2;
  116871. /**
  116872. * 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
  116873. */
  116874. set boundingBias(value: Vector2);
  116875. /**
  116876. * Static function used to attach a new empty geometry to a mesh
  116877. * @param mesh defines the mesh to attach the geometry to
  116878. * @returns the new Geometry
  116879. */
  116880. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  116881. /** Get the list of meshes using this geometry */
  116882. get meshes(): Mesh[];
  116883. /**
  116884. * If set to true (false by default), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  116885. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  116886. */
  116887. useBoundingInfoFromGeometry: boolean;
  116888. /**
  116889. * Creates a new geometry
  116890. * @param id defines the unique ID
  116891. * @param scene defines the hosting scene
  116892. * @param vertexData defines the VertexData used to get geometry data
  116893. * @param updatable defines if geometry must be updatable (false by default)
  116894. * @param mesh defines the mesh that will be associated with the geometry
  116895. */
  116896. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  116897. /**
  116898. * Gets the current extend of the geometry
  116899. */
  116900. get extend(): {
  116901. minimum: Vector3;
  116902. maximum: Vector3;
  116903. };
  116904. /**
  116905. * Gets the hosting scene
  116906. * @returns the hosting Scene
  116907. */
  116908. getScene(): Scene;
  116909. /**
  116910. * Gets the hosting engine
  116911. * @returns the hosting Engine
  116912. */
  116913. getEngine(): Engine;
  116914. /**
  116915. * Defines if the geometry is ready to use
  116916. * @returns true if the geometry is ready to be used
  116917. */
  116918. isReady(): boolean;
  116919. /**
  116920. * Gets a value indicating that the geometry should not be serialized
  116921. */
  116922. get doNotSerialize(): boolean;
  116923. /** @hidden */
  116924. _rebuild(): void;
  116925. /**
  116926. * Affects all geometry data in one call
  116927. * @param vertexData defines the geometry data
  116928. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  116929. */
  116930. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  116931. /**
  116932. * Set specific vertex data
  116933. * @param kind defines the data kind (Position, normal, etc...)
  116934. * @param data defines the vertex data to use
  116935. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  116936. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  116937. */
  116938. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  116939. /**
  116940. * Removes a specific vertex data
  116941. * @param kind defines the data kind (Position, normal, etc...)
  116942. */
  116943. removeVerticesData(kind: string): void;
  116944. /**
  116945. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  116946. * @param buffer defines the vertex buffer to use
  116947. * @param totalVertices defines the total number of vertices for position kind (could be null)
  116948. */
  116949. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  116950. /**
  116951. * Update a specific vertex buffer
  116952. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  116953. * It will do nothing if the buffer is not updatable
  116954. * @param kind defines the data kind (Position, normal, etc...)
  116955. * @param data defines the data to use
  116956. * @param offset defines the offset in the target buffer where to store the data
  116957. * @param useBytes set to true if the offset is in bytes
  116958. */
  116959. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  116960. /**
  116961. * Update a specific vertex buffer
  116962. * This function will create a new buffer if the current one is not updatable
  116963. * @param kind defines the data kind (Position, normal, etc...)
  116964. * @param data defines the data to use
  116965. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  116966. */
  116967. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  116968. private _updateBoundingInfo;
  116969. /** @hidden */
  116970. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  116971. [kind: string]: Nullable<VertexBuffer>;
  116972. }, overrideVertexArrayObjects?: {
  116973. [key: string]: WebGLVertexArrayObject;
  116974. }): void;
  116975. /**
  116976. * Gets total number of vertices
  116977. * @returns the total number of vertices
  116978. */
  116979. getTotalVertices(): number;
  116980. /**
  116981. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  116982. * @param kind defines the data kind (Position, normal, etc...)
  116983. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  116984. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  116985. * @returns a float array containing vertex data
  116986. */
  116987. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  116988. /**
  116989. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  116990. * @param kind defines the data kind (Position, normal, etc...)
  116991. * @returns true if the vertex buffer with the specified kind is updatable
  116992. */
  116993. isVertexBufferUpdatable(kind: string): boolean;
  116994. /**
  116995. * Gets a specific vertex buffer
  116996. * @param kind defines the data kind (Position, normal, etc...)
  116997. * @returns a VertexBuffer
  116998. */
  116999. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  117000. /**
  117001. * Returns all vertex buffers
  117002. * @return an object holding all vertex buffers indexed by kind
  117003. */
  117004. getVertexBuffers(): Nullable<{
  117005. [key: string]: VertexBuffer;
  117006. }>;
  117007. /**
  117008. * Gets a boolean indicating if specific vertex buffer is present
  117009. * @param kind defines the data kind (Position, normal, etc...)
  117010. * @returns true if data is present
  117011. */
  117012. isVerticesDataPresent(kind: string): boolean;
  117013. /**
  117014. * Gets a list of all attached data kinds (Position, normal, etc...)
  117015. * @returns a list of string containing all kinds
  117016. */
  117017. getVerticesDataKinds(): string[];
  117018. /**
  117019. * Update index buffer
  117020. * @param indices defines the indices to store in the index buffer
  117021. * @param offset defines the offset in the target buffer where to store the data
  117022. * @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)
  117023. */
  117024. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  117025. /**
  117026. * Creates a new index buffer
  117027. * @param indices defines the indices to store in the index buffer
  117028. * @param totalVertices defines the total number of vertices (could be null)
  117029. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  117030. */
  117031. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  117032. /**
  117033. * Return the total number of indices
  117034. * @returns the total number of indices
  117035. */
  117036. getTotalIndices(): number;
  117037. /**
  117038. * Gets the index buffer array
  117039. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  117040. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  117041. * @returns the index buffer array
  117042. */
  117043. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  117044. /**
  117045. * Gets the index buffer
  117046. * @return the index buffer
  117047. */
  117048. getIndexBuffer(): Nullable<DataBuffer>;
  117049. /** @hidden */
  117050. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  117051. /**
  117052. * Release the associated resources for a specific mesh
  117053. * @param mesh defines the source mesh
  117054. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  117055. */
  117056. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  117057. /**
  117058. * Apply current geometry to a given mesh
  117059. * @param mesh defines the mesh to apply geometry to
  117060. */
  117061. applyToMesh(mesh: Mesh): void;
  117062. private _updateExtend;
  117063. private _applyToMesh;
  117064. private notifyUpdate;
  117065. /**
  117066. * Load the geometry if it was flagged as delay loaded
  117067. * @param scene defines the hosting scene
  117068. * @param onLoaded defines a callback called when the geometry is loaded
  117069. */
  117070. load(scene: Scene, onLoaded?: () => void): void;
  117071. private _queueLoad;
  117072. /**
  117073. * Invert the geometry to move from a right handed system to a left handed one.
  117074. */
  117075. toLeftHanded(): void;
  117076. /** @hidden */
  117077. _resetPointsArrayCache(): void;
  117078. /** @hidden */
  117079. _generatePointsArray(): boolean;
  117080. /**
  117081. * Gets a value indicating if the geometry is disposed
  117082. * @returns true if the geometry was disposed
  117083. */
  117084. isDisposed(): boolean;
  117085. private _disposeVertexArrayObjects;
  117086. /**
  117087. * Free all associated resources
  117088. */
  117089. dispose(): void;
  117090. /**
  117091. * Clone the current geometry into a new geometry
  117092. * @param id defines the unique ID of the new geometry
  117093. * @returns a new geometry object
  117094. */
  117095. copy(id: string): Geometry;
  117096. /**
  117097. * Serialize the current geometry info (and not the vertices data) into a JSON object
  117098. * @return a JSON representation of the current geometry data (without the vertices data)
  117099. */
  117100. serialize(): any;
  117101. private toNumberArray;
  117102. /**
  117103. * Serialize all vertices data into a JSON object
  117104. * @returns a JSON representation of the current geometry data
  117105. */
  117106. serializeVerticeData(): any;
  117107. /**
  117108. * Extracts a clone of a mesh geometry
  117109. * @param mesh defines the source mesh
  117110. * @param id defines the unique ID of the new geometry object
  117111. * @returns the new geometry object
  117112. */
  117113. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  117114. /**
  117115. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  117116. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117117. * Be aware Math.random() could cause collisions, but:
  117118. * "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"
  117119. * @returns a string containing a new GUID
  117120. */
  117121. static RandomId(): string;
  117122. /** @hidden */
  117123. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  117124. private static _CleanMatricesWeights;
  117125. /**
  117126. * Create a new geometry from persisted data (Using .babylon file format)
  117127. * @param parsedVertexData defines the persisted data
  117128. * @param scene defines the hosting scene
  117129. * @param rootUrl defines the root url to use to load assets (like delayed data)
  117130. * @returns the new geometry object
  117131. */
  117132. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  117133. }
  117134. }
  117135. declare module BABYLON {
  117136. /**
  117137. * Defines a target to use with MorphTargetManager
  117138. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  117139. */
  117140. export class MorphTarget implements IAnimatable {
  117141. /** defines the name of the target */
  117142. name: string;
  117143. /**
  117144. * Gets or sets the list of animations
  117145. */
  117146. animations: Animation[];
  117147. private _scene;
  117148. private _positions;
  117149. private _normals;
  117150. private _tangents;
  117151. private _uvs;
  117152. private _influence;
  117153. private _uniqueId;
  117154. /**
  117155. * Observable raised when the influence changes
  117156. */
  117157. onInfluenceChanged: Observable<boolean>;
  117158. /** @hidden */
  117159. _onDataLayoutChanged: Observable<void>;
  117160. /**
  117161. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  117162. */
  117163. get influence(): number;
  117164. set influence(influence: number);
  117165. /**
  117166. * Gets or sets the id of the morph Target
  117167. */
  117168. id: string;
  117169. private _animationPropertiesOverride;
  117170. /**
  117171. * Gets or sets the animation properties override
  117172. */
  117173. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117174. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117175. /**
  117176. * Creates a new MorphTarget
  117177. * @param name defines the name of the target
  117178. * @param influence defines the influence to use
  117179. * @param scene defines the scene the morphtarget belongs to
  117180. */
  117181. constructor(
  117182. /** defines the name of the target */
  117183. name: string, influence?: number, scene?: Nullable<Scene>);
  117184. /**
  117185. * Gets the unique ID of this manager
  117186. */
  117187. get uniqueId(): number;
  117188. /**
  117189. * Gets a boolean defining if the target contains position data
  117190. */
  117191. get hasPositions(): boolean;
  117192. /**
  117193. * Gets a boolean defining if the target contains normal data
  117194. */
  117195. get hasNormals(): boolean;
  117196. /**
  117197. * Gets a boolean defining if the target contains tangent data
  117198. */
  117199. get hasTangents(): boolean;
  117200. /**
  117201. * Gets a boolean defining if the target contains texture coordinates data
  117202. */
  117203. get hasUVs(): boolean;
  117204. /**
  117205. * Affects position data to this target
  117206. * @param data defines the position data to use
  117207. */
  117208. setPositions(data: Nullable<FloatArray>): void;
  117209. /**
  117210. * Gets the position data stored in this target
  117211. * @returns a FloatArray containing the position data (or null if not present)
  117212. */
  117213. getPositions(): Nullable<FloatArray>;
  117214. /**
  117215. * Affects normal data to this target
  117216. * @param data defines the normal data to use
  117217. */
  117218. setNormals(data: Nullable<FloatArray>): void;
  117219. /**
  117220. * Gets the normal data stored in this target
  117221. * @returns a FloatArray containing the normal data (or null if not present)
  117222. */
  117223. getNormals(): Nullable<FloatArray>;
  117224. /**
  117225. * Affects tangent data to this target
  117226. * @param data defines the tangent data to use
  117227. */
  117228. setTangents(data: Nullable<FloatArray>): void;
  117229. /**
  117230. * Gets the tangent data stored in this target
  117231. * @returns a FloatArray containing the tangent data (or null if not present)
  117232. */
  117233. getTangents(): Nullable<FloatArray>;
  117234. /**
  117235. * Affects texture coordinates data to this target
  117236. * @param data defines the texture coordinates data to use
  117237. */
  117238. setUVs(data: Nullable<FloatArray>): void;
  117239. /**
  117240. * Gets the texture coordinates data stored in this target
  117241. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  117242. */
  117243. getUVs(): Nullable<FloatArray>;
  117244. /**
  117245. * Clone the current target
  117246. * @returns a new MorphTarget
  117247. */
  117248. clone(): MorphTarget;
  117249. /**
  117250. * Serializes the current target into a Serialization object
  117251. * @returns the serialized object
  117252. */
  117253. serialize(): any;
  117254. /**
  117255. * Returns the string "MorphTarget"
  117256. * @returns "MorphTarget"
  117257. */
  117258. getClassName(): string;
  117259. /**
  117260. * Creates a new target from serialized data
  117261. * @param serializationObject defines the serialized data to use
  117262. * @returns a new MorphTarget
  117263. */
  117264. static Parse(serializationObject: any): MorphTarget;
  117265. /**
  117266. * Creates a MorphTarget from mesh data
  117267. * @param mesh defines the source mesh
  117268. * @param name defines the name to use for the new target
  117269. * @param influence defines the influence to attach to the target
  117270. * @returns a new MorphTarget
  117271. */
  117272. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  117273. }
  117274. }
  117275. declare module BABYLON {
  117276. /**
  117277. * Class used to store 2D array textures containing user data
  117278. */
  117279. export class RawTexture2DArray extends Texture {
  117280. /** Gets or sets the texture format to use */
  117281. format: number;
  117282. private _depth;
  117283. /**
  117284. * Gets the number of layers of the texture
  117285. */
  117286. get depth(): number;
  117287. /**
  117288. * Create a new RawTexture2DArray
  117289. * @param data defines the data of the texture
  117290. * @param width defines the width of the texture
  117291. * @param height defines the height of the texture
  117292. * @param depth defines the number of layers of the texture
  117293. * @param format defines the texture format to use
  117294. * @param scene defines the hosting scene
  117295. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117296. * @param invertY defines if texture must be stored with Y axis inverted
  117297. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117298. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117299. */
  117300. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117301. /** Gets or sets the texture format to use */
  117302. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117303. /**
  117304. * Update the texture with new data
  117305. * @param data defines the data to store in the texture
  117306. */
  117307. update(data: ArrayBufferView): void;
  117308. /**
  117309. * Creates a RGBA texture from some data.
  117310. * @param data Define the texture data
  117311. * @param width Define the width of the texture
  117312. * @param height Define the height of the texture
  117313. * @param depth defines the number of layers of the texture
  117314. * @param scene defines the scene the texture will belong to
  117315. * @param generateMipMaps Define whether or not to create mip maps for the texture
  117316. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  117317. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  117318. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  117319. * @returns the RGBA texture
  117320. */
  117321. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, depth: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture2DArray;
  117322. }
  117323. }
  117324. declare module BABYLON {
  117325. /**
  117326. * This class is used to deform meshes using morphing between different targets
  117327. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  117328. */
  117329. export class MorphTargetManager implements IDisposable {
  117330. private _targets;
  117331. private _targetInfluenceChangedObservers;
  117332. private _targetDataLayoutChangedObservers;
  117333. private _activeTargets;
  117334. private _scene;
  117335. private _influences;
  117336. private _supportsNormals;
  117337. private _supportsTangents;
  117338. private _supportsUVs;
  117339. private _vertexCount;
  117340. private _textureVertexStride;
  117341. private _textureWidth;
  117342. private _textureHeight;
  117343. private _uniqueId;
  117344. private _tempInfluences;
  117345. private _canUseTextureForTargets;
  117346. /** @hidden */
  117347. _targetStoreTexture: Nullable<RawTexture2DArray>;
  117348. /**
  117349. * Gets or sets a boolean indicating if normals must be morphed
  117350. */
  117351. enableNormalMorphing: boolean;
  117352. /**
  117353. * Gets or sets a boolean indicating if tangents must be morphed
  117354. */
  117355. enableTangentMorphing: boolean;
  117356. /**
  117357. * Gets or sets a boolean indicating if UV must be morphed
  117358. */
  117359. enableUVMorphing: boolean;
  117360. /**
  117361. * Creates a new MorphTargetManager
  117362. * @param scene defines the current scene
  117363. */
  117364. constructor(scene?: Nullable<Scene>);
  117365. /**
  117366. * Gets the unique ID of this manager
  117367. */
  117368. get uniqueId(): number;
  117369. /**
  117370. * Gets the number of vertices handled by this manager
  117371. */
  117372. get vertexCount(): number;
  117373. /**
  117374. * Gets a boolean indicating if this manager supports morphing of normals
  117375. */
  117376. get supportsNormals(): boolean;
  117377. /**
  117378. * Gets a boolean indicating if this manager supports morphing of tangents
  117379. */
  117380. get supportsTangents(): boolean;
  117381. /**
  117382. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  117383. */
  117384. get supportsUVs(): boolean;
  117385. /**
  117386. * Gets the number of targets stored in this manager
  117387. */
  117388. get numTargets(): number;
  117389. /**
  117390. * Gets the number of influencers (ie. the number of targets with influences > 0)
  117391. */
  117392. get numInfluencers(): number;
  117393. /**
  117394. * Gets the list of influences (one per target)
  117395. */
  117396. get influences(): Float32Array;
  117397. private _useTextureToStoreTargets;
  117398. /**
  117399. * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).
  117400. * Please note that this option is not available if the hardware does not support it
  117401. */
  117402. get useTextureToStoreTargets(): boolean;
  117403. set useTextureToStoreTargets(value: boolean);
  117404. /**
  117405. * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
  117406. */
  117407. get isUsingTextureForTargets(): boolean;
  117408. /**
  117409. * Gets the active target at specified index. An active target is a target with an influence > 0
  117410. * @param index defines the index to check
  117411. * @returns the requested target
  117412. */
  117413. getActiveTarget(index: number): MorphTarget;
  117414. /**
  117415. * Gets the target at specified index
  117416. * @param index defines the index to check
  117417. * @returns the requested target
  117418. */
  117419. getTarget(index: number): MorphTarget;
  117420. /**
  117421. * Add a new target to this manager
  117422. * @param target defines the target to add
  117423. */
  117424. addTarget(target: MorphTarget): void;
  117425. /**
  117426. * Removes a target from the manager
  117427. * @param target defines the target to remove
  117428. */
  117429. removeTarget(target: MorphTarget): void;
  117430. /** @hidden */
  117431. _bind(effect: Effect): void;
  117432. /**
  117433. * Clone the current manager
  117434. * @returns a new MorphTargetManager
  117435. */
  117436. clone(): MorphTargetManager;
  117437. /**
  117438. * Serializes the current manager into a Serialization object
  117439. * @returns the serialized object
  117440. */
  117441. serialize(): any;
  117442. private _syncActiveTargets;
  117443. /**
  117444. * Synchronize the targets with all the meshes using this morph target manager
  117445. */
  117446. synchronize(): void;
  117447. /**
  117448. * Release all resources
  117449. */
  117450. dispose(): void;
  117451. /**
  117452. * Creates a new MorphTargetManager from serialized data
  117453. * @param serializationObject defines the serialized data
  117454. * @param scene defines the hosting scene
  117455. * @returns the new MorphTargetManager
  117456. */
  117457. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  117458. }
  117459. }
  117460. declare module BABYLON {
  117461. /**
  117462. * Class used to represent a specific level of detail of a mesh
  117463. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117464. */
  117465. export class MeshLODLevel {
  117466. /** Defines the distance where this level should start being displayed */
  117467. distance: number;
  117468. /** Defines the mesh to use to render this level */
  117469. mesh: Nullable<Mesh>;
  117470. /**
  117471. * Creates a new LOD level
  117472. * @param distance defines the distance where this level should star being displayed
  117473. * @param mesh defines the mesh to use to render this level
  117474. */
  117475. constructor(
  117476. /** Defines the distance where this level should start being displayed */
  117477. distance: number,
  117478. /** Defines the mesh to use to render this level */
  117479. mesh: Nullable<Mesh>);
  117480. }
  117481. }
  117482. declare module BABYLON {
  117483. /**
  117484. * Helper class used to generate a canvas to manipulate images
  117485. */
  117486. export class CanvasGenerator {
  117487. /**
  117488. * Create a new canvas (or offscreen canvas depending on the context)
  117489. * @param width defines the expected width
  117490. * @param height defines the expected height
  117491. * @return a new canvas or offscreen canvas
  117492. */
  117493. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  117494. }
  117495. }
  117496. declare module BABYLON {
  117497. /**
  117498. * Mesh representing the ground
  117499. */
  117500. export class GroundMesh extends Mesh {
  117501. /** If octree should be generated */
  117502. generateOctree: boolean;
  117503. private _heightQuads;
  117504. /** @hidden */
  117505. _subdivisionsX: number;
  117506. /** @hidden */
  117507. _subdivisionsY: number;
  117508. /** @hidden */
  117509. _width: number;
  117510. /** @hidden */
  117511. _height: number;
  117512. /** @hidden */
  117513. _minX: number;
  117514. /** @hidden */
  117515. _maxX: number;
  117516. /** @hidden */
  117517. _minZ: number;
  117518. /** @hidden */
  117519. _maxZ: number;
  117520. constructor(name: string, scene: Scene);
  117521. /**
  117522. * "GroundMesh"
  117523. * @returns "GroundMesh"
  117524. */
  117525. getClassName(): string;
  117526. /**
  117527. * The minimum of x and y subdivisions
  117528. */
  117529. get subdivisions(): number;
  117530. /**
  117531. * X subdivisions
  117532. */
  117533. get subdivisionsX(): number;
  117534. /**
  117535. * Y subdivisions
  117536. */
  117537. get subdivisionsY(): number;
  117538. /**
  117539. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  117540. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  117541. * @param chunksCount the number of subdivisions for x and y
  117542. * @param octreeBlocksSize (Default: 32)
  117543. */
  117544. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  117545. /**
  117546. * Returns a height (y) value in the World system :
  117547. * the ground altitude at the coordinates (x, z) expressed in the World system.
  117548. * @param x x coordinate
  117549. * @param z z coordinate
  117550. * @returns the ground y position if (x, z) are outside the ground surface.
  117551. */
  117552. getHeightAtCoordinates(x: number, z: number): number;
  117553. /**
  117554. * Returns a normalized vector (Vector3) orthogonal to the ground
  117555. * at the ground coordinates (x, z) expressed in the World system.
  117556. * @param x x coordinate
  117557. * @param z z coordinate
  117558. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  117559. */
  117560. getNormalAtCoordinates(x: number, z: number): Vector3;
  117561. /**
  117562. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  117563. * at the ground coordinates (x, z) expressed in the World system.
  117564. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  117565. * @param x x coordinate
  117566. * @param z z coordinate
  117567. * @param ref vector to store the result
  117568. * @returns the GroundMesh.
  117569. */
  117570. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  117571. /**
  117572. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  117573. * if the ground has been updated.
  117574. * This can be used in the render loop.
  117575. * @returns the GroundMesh.
  117576. */
  117577. updateCoordinateHeights(): GroundMesh;
  117578. private _getFacetAt;
  117579. private _initHeightQuads;
  117580. private _computeHeightQuads;
  117581. /**
  117582. * Serializes this ground mesh
  117583. * @param serializationObject object to write serialization to
  117584. */
  117585. serialize(serializationObject: any): void;
  117586. /**
  117587. * Parses a serialized ground mesh
  117588. * @param parsedMesh the serialized mesh
  117589. * @param scene the scene to create the ground mesh in
  117590. * @returns the created ground mesh
  117591. */
  117592. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  117593. }
  117594. }
  117595. declare module BABYLON {
  117596. /**
  117597. * Interface for Physics-Joint data
  117598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117599. */
  117600. export interface PhysicsJointData {
  117601. /**
  117602. * The main pivot of the joint
  117603. */
  117604. mainPivot?: Vector3;
  117605. /**
  117606. * The connected pivot of the joint
  117607. */
  117608. connectedPivot?: Vector3;
  117609. /**
  117610. * The main axis of the joint
  117611. */
  117612. mainAxis?: Vector3;
  117613. /**
  117614. * The connected axis of the joint
  117615. */
  117616. connectedAxis?: Vector3;
  117617. /**
  117618. * The collision of the joint
  117619. */
  117620. collision?: boolean;
  117621. /**
  117622. * Native Oimo/Cannon/Energy data
  117623. */
  117624. nativeParams?: any;
  117625. }
  117626. /**
  117627. * This is a holder class for the physics joint created by the physics plugin
  117628. * It holds a set of functions to control the underlying joint
  117629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117630. */
  117631. export class PhysicsJoint {
  117632. /**
  117633. * The type of the physics joint
  117634. */
  117635. type: number;
  117636. /**
  117637. * The data for the physics joint
  117638. */
  117639. jointData: PhysicsJointData;
  117640. private _physicsJoint;
  117641. protected _physicsPlugin: IPhysicsEnginePlugin;
  117642. /**
  117643. * Initializes the physics joint
  117644. * @param type The type of the physics joint
  117645. * @param jointData The data for the physics joint
  117646. */
  117647. constructor(
  117648. /**
  117649. * The type of the physics joint
  117650. */
  117651. type: number,
  117652. /**
  117653. * The data for the physics joint
  117654. */
  117655. jointData: PhysicsJointData);
  117656. /**
  117657. * Gets the physics joint
  117658. */
  117659. get physicsJoint(): any;
  117660. /**
  117661. * Sets the physics joint
  117662. */
  117663. set physicsJoint(newJoint: any);
  117664. /**
  117665. * Sets the physics plugin
  117666. */
  117667. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  117668. /**
  117669. * Execute a function that is physics-plugin specific.
  117670. * @param {Function} func the function that will be executed.
  117671. * It accepts two parameters: the physics world and the physics joint
  117672. */
  117673. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  117674. /**
  117675. * Distance-Joint type
  117676. */
  117677. static DistanceJoint: number;
  117678. /**
  117679. * Hinge-Joint type
  117680. */
  117681. static HingeJoint: number;
  117682. /**
  117683. * Ball-and-Socket joint type
  117684. */
  117685. static BallAndSocketJoint: number;
  117686. /**
  117687. * Wheel-Joint type
  117688. */
  117689. static WheelJoint: number;
  117690. /**
  117691. * Slider-Joint type
  117692. */
  117693. static SliderJoint: number;
  117694. /**
  117695. * Prismatic-Joint type
  117696. */
  117697. static PrismaticJoint: number;
  117698. /**
  117699. * Universal-Joint type
  117700. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  117701. */
  117702. static UniversalJoint: number;
  117703. /**
  117704. * Hinge-Joint 2 type
  117705. */
  117706. static Hinge2Joint: number;
  117707. /**
  117708. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  117709. */
  117710. static PointToPointJoint: number;
  117711. /**
  117712. * Spring-Joint type
  117713. */
  117714. static SpringJoint: number;
  117715. /**
  117716. * Lock-Joint type
  117717. */
  117718. static LockJoint: number;
  117719. }
  117720. /**
  117721. * A class representing a physics distance joint
  117722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117723. */
  117724. export class DistanceJoint extends PhysicsJoint {
  117725. /**
  117726. *
  117727. * @param jointData The data for the Distance-Joint
  117728. */
  117729. constructor(jointData: DistanceJointData);
  117730. /**
  117731. * Update the predefined distance.
  117732. * @param maxDistance The maximum preferred distance
  117733. * @param minDistance The minimum preferred distance
  117734. */
  117735. updateDistance(maxDistance: number, minDistance?: number): void;
  117736. }
  117737. /**
  117738. * Represents a Motor-Enabled Joint
  117739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117740. */
  117741. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  117742. /**
  117743. * Initializes the Motor-Enabled Joint
  117744. * @param type The type of the joint
  117745. * @param jointData The physical joint data for the joint
  117746. */
  117747. constructor(type: number, jointData: PhysicsJointData);
  117748. /**
  117749. * Set the motor values.
  117750. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117751. * @param force the force to apply
  117752. * @param maxForce max force for this motor.
  117753. */
  117754. setMotor(force?: number, maxForce?: number): void;
  117755. /**
  117756. * Set the motor's limits.
  117757. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117758. * @param upperLimit The upper limit of the motor
  117759. * @param lowerLimit The lower limit of the motor
  117760. */
  117761. setLimit(upperLimit: number, lowerLimit?: number): void;
  117762. }
  117763. /**
  117764. * This class represents a single physics Hinge-Joint
  117765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117766. */
  117767. export class HingeJoint extends MotorEnabledJoint {
  117768. /**
  117769. * Initializes the Hinge-Joint
  117770. * @param jointData The joint data for the Hinge-Joint
  117771. */
  117772. constructor(jointData: PhysicsJointData);
  117773. /**
  117774. * Set the motor values.
  117775. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117776. * @param {number} force the force to apply
  117777. * @param {number} maxForce max force for this motor.
  117778. */
  117779. setMotor(force?: number, maxForce?: number): void;
  117780. /**
  117781. * Set the motor's limits.
  117782. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117783. * @param upperLimit The upper limit of the motor
  117784. * @param lowerLimit The lower limit of the motor
  117785. */
  117786. setLimit(upperLimit: number, lowerLimit?: number): void;
  117787. }
  117788. /**
  117789. * This class represents a dual hinge physics joint (same as wheel joint)
  117790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117791. */
  117792. export class Hinge2Joint extends MotorEnabledJoint {
  117793. /**
  117794. * Initializes the Hinge2-Joint
  117795. * @param jointData The joint data for the Hinge2-Joint
  117796. */
  117797. constructor(jointData: PhysicsJointData);
  117798. /**
  117799. * Set the motor values.
  117800. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117801. * @param {number} targetSpeed the speed the motor is to reach
  117802. * @param {number} maxForce max force for this motor.
  117803. * @param {motorIndex} the motor's index, 0 or 1.
  117804. */
  117805. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  117806. /**
  117807. * Set the motor limits.
  117808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  117809. * @param {number} upperLimit the upper limit
  117810. * @param {number} lowerLimit lower limit
  117811. * @param {motorIndex} the motor's index, 0 or 1.
  117812. */
  117813. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117814. }
  117815. /**
  117816. * Interface for a motor enabled joint
  117817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117818. */
  117819. export interface IMotorEnabledJoint {
  117820. /**
  117821. * Physics joint
  117822. */
  117823. physicsJoint: any;
  117824. /**
  117825. * Sets the motor of the motor-enabled joint
  117826. * @param force The force of the motor
  117827. * @param maxForce The maximum force of the motor
  117828. * @param motorIndex The index of the motor
  117829. */
  117830. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  117831. /**
  117832. * Sets the limit of the motor
  117833. * @param upperLimit The upper limit of the motor
  117834. * @param lowerLimit The lower limit of the motor
  117835. * @param motorIndex The index of the motor
  117836. */
  117837. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117838. }
  117839. /**
  117840. * Joint data for a Distance-Joint
  117841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117842. */
  117843. export interface DistanceJointData extends PhysicsJointData {
  117844. /**
  117845. * Max distance the 2 joint objects can be apart
  117846. */
  117847. maxDistance: number;
  117848. }
  117849. /**
  117850. * Joint data from a spring joint
  117851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117852. */
  117853. export interface SpringJointData extends PhysicsJointData {
  117854. /**
  117855. * Length of the spring
  117856. */
  117857. length: number;
  117858. /**
  117859. * Stiffness of the spring
  117860. */
  117861. stiffness: number;
  117862. /**
  117863. * Damping of the spring
  117864. */
  117865. damping: number;
  117866. /** this callback will be called when applying the force to the impostors. */
  117867. forceApplicationCallback: () => void;
  117868. }
  117869. }
  117870. declare module BABYLON {
  117871. /**
  117872. * Holds the data for the raycast result
  117873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117874. */
  117875. export class PhysicsRaycastResult {
  117876. private _hasHit;
  117877. private _hitDistance;
  117878. private _hitNormalWorld;
  117879. private _hitPointWorld;
  117880. private _rayFromWorld;
  117881. private _rayToWorld;
  117882. /**
  117883. * Gets if there was a hit
  117884. */
  117885. get hasHit(): boolean;
  117886. /**
  117887. * Gets the distance from the hit
  117888. */
  117889. get hitDistance(): number;
  117890. /**
  117891. * Gets the hit normal/direction in the world
  117892. */
  117893. get hitNormalWorld(): Vector3;
  117894. /**
  117895. * Gets the hit point in the world
  117896. */
  117897. get hitPointWorld(): Vector3;
  117898. /**
  117899. * Gets the ray "start point" of the ray in the world
  117900. */
  117901. get rayFromWorld(): Vector3;
  117902. /**
  117903. * Gets the ray "end point" of the ray in the world
  117904. */
  117905. get rayToWorld(): Vector3;
  117906. /**
  117907. * Sets the hit data (normal & point in world space)
  117908. * @param hitNormalWorld defines the normal in world space
  117909. * @param hitPointWorld defines the point in world space
  117910. */
  117911. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  117912. /**
  117913. * Sets the distance from the start point to the hit point
  117914. * @param distance
  117915. */
  117916. setHitDistance(distance: number): void;
  117917. /**
  117918. * Calculates the distance manually
  117919. */
  117920. calculateHitDistance(): void;
  117921. /**
  117922. * Resets all the values to default
  117923. * @param from The from point on world space
  117924. * @param to The to point on world space
  117925. */
  117926. reset(from?: Vector3, to?: Vector3): void;
  117927. }
  117928. /**
  117929. * Interface for the size containing width and height
  117930. */
  117931. interface IXYZ {
  117932. /**
  117933. * X
  117934. */
  117935. x: number;
  117936. /**
  117937. * Y
  117938. */
  117939. y: number;
  117940. /**
  117941. * Z
  117942. */
  117943. z: number;
  117944. }
  117945. }
  117946. declare module BABYLON {
  117947. /**
  117948. * Interface used to describe a physics joint
  117949. */
  117950. export interface PhysicsImpostorJoint {
  117951. /** Defines the main impostor to which the joint is linked */
  117952. mainImpostor: PhysicsImpostor;
  117953. /** Defines the impostor that is connected to the main impostor using this joint */
  117954. connectedImpostor: PhysicsImpostor;
  117955. /** Defines the joint itself */
  117956. joint: PhysicsJoint;
  117957. }
  117958. /** @hidden */
  117959. export interface IPhysicsEnginePlugin {
  117960. world: any;
  117961. name: string;
  117962. setGravity(gravity: Vector3): void;
  117963. setTimeStep(timeStep: number): void;
  117964. getTimeStep(): number;
  117965. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117966. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117967. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117968. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117969. removePhysicsBody(impostor: PhysicsImpostor): void;
  117970. generateJoint(joint: PhysicsImpostorJoint): void;
  117971. removeJoint(joint: PhysicsImpostorJoint): void;
  117972. isSupported(): boolean;
  117973. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117974. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117975. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  117976. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  117977. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117978. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117979. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117980. getBodyMass(impostor: PhysicsImpostor): number;
  117981. getBodyFriction(impostor: PhysicsImpostor): number;
  117982. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117983. getBodyRestitution(impostor: PhysicsImpostor): number;
  117984. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117985. getBodyPressure?(impostor: PhysicsImpostor): number;
  117986. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  117987. getBodyStiffness?(impostor: PhysicsImpostor): number;
  117988. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  117989. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  117990. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  117991. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  117992. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  117993. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  117994. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  117995. sleepBody(impostor: PhysicsImpostor): void;
  117996. wakeUpBody(impostor: PhysicsImpostor): void;
  117997. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117998. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117999. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  118000. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  118001. getRadius(impostor: PhysicsImpostor): number;
  118002. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118003. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118004. dispose(): void;
  118005. }
  118006. /**
  118007. * Interface used to define a physics engine
  118008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118009. */
  118010. export interface IPhysicsEngine {
  118011. /**
  118012. * Gets the gravity vector used by the simulation
  118013. */
  118014. gravity: Vector3;
  118015. /**
  118016. * Sets the gravity vector used by the simulation
  118017. * @param gravity defines the gravity vector to use
  118018. */
  118019. setGravity(gravity: Vector3): void;
  118020. /**
  118021. * Set the time step of the physics engine.
  118022. * Default is 1/60.
  118023. * To slow it down, enter 1/600 for example.
  118024. * To speed it up, 1/30
  118025. * @param newTimeStep the new timestep to apply to this world.
  118026. */
  118027. setTimeStep(newTimeStep: number): void;
  118028. /**
  118029. * Get the time step of the physics engine.
  118030. * @returns the current time step
  118031. */
  118032. getTimeStep(): number;
  118033. /**
  118034. * Set the sub time step of the physics engine.
  118035. * Default is 0 meaning there is no sub steps
  118036. * To increase physics resolution precision, set a small value (like 1 ms)
  118037. * @param subTimeStep defines the new sub timestep used for physics resolution.
  118038. */
  118039. setSubTimeStep(subTimeStep: number): void;
  118040. /**
  118041. * Get the sub time step of the physics engine.
  118042. * @returns the current sub time step
  118043. */
  118044. getSubTimeStep(): number;
  118045. /**
  118046. * Release all resources
  118047. */
  118048. dispose(): void;
  118049. /**
  118050. * Gets the name of the current physics plugin
  118051. * @returns the name of the plugin
  118052. */
  118053. getPhysicsPluginName(): string;
  118054. /**
  118055. * Adding a new impostor for the impostor tracking.
  118056. * This will be done by the impostor itself.
  118057. * @param impostor the impostor to add
  118058. */
  118059. addImpostor(impostor: PhysicsImpostor): void;
  118060. /**
  118061. * Remove an impostor from the engine.
  118062. * This impostor and its mesh will not longer be updated by the physics engine.
  118063. * @param impostor the impostor to remove
  118064. */
  118065. removeImpostor(impostor: PhysicsImpostor): void;
  118066. /**
  118067. * Add a joint to the physics engine
  118068. * @param mainImpostor defines the main impostor to which the joint is added.
  118069. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118070. * @param joint defines the joint that will connect both impostors.
  118071. */
  118072. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118073. /**
  118074. * Removes a joint from the simulation
  118075. * @param mainImpostor defines the impostor used with the joint
  118076. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118077. * @param joint defines the joint to remove
  118078. */
  118079. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118080. /**
  118081. * Gets the current plugin used to run the simulation
  118082. * @returns current plugin
  118083. */
  118084. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118085. /**
  118086. * Gets the list of physic impostors
  118087. * @returns an array of PhysicsImpostor
  118088. */
  118089. getImpostors(): Array<PhysicsImpostor>;
  118090. /**
  118091. * Gets the impostor for a physics enabled object
  118092. * @param object defines the object impersonated by the impostor
  118093. * @returns the PhysicsImpostor or null if not found
  118094. */
  118095. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118096. /**
  118097. * Gets the impostor for a physics body object
  118098. * @param body defines physics body used by the impostor
  118099. * @returns the PhysicsImpostor or null if not found
  118100. */
  118101. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118102. /**
  118103. * Does a raycast in the physics world
  118104. * @param from when should the ray start?
  118105. * @param to when should the ray end?
  118106. * @returns PhysicsRaycastResult
  118107. */
  118108. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118109. /**
  118110. * Called by the scene. No need to call it.
  118111. * @param delta defines the timespan between frames
  118112. */
  118113. _step(delta: number): void;
  118114. }
  118115. }
  118116. declare module BABYLON {
  118117. /**
  118118. * The interface for the physics imposter parameters
  118119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118120. */
  118121. export interface PhysicsImpostorParameters {
  118122. /**
  118123. * The mass of the physics imposter
  118124. */
  118125. mass: number;
  118126. /**
  118127. * The friction of the physics imposter
  118128. */
  118129. friction?: number;
  118130. /**
  118131. * The coefficient of restitution of the physics imposter
  118132. */
  118133. restitution?: number;
  118134. /**
  118135. * The native options of the physics imposter
  118136. */
  118137. nativeOptions?: any;
  118138. /**
  118139. * Specifies if the parent should be ignored
  118140. */
  118141. ignoreParent?: boolean;
  118142. /**
  118143. * Specifies if bi-directional transformations should be disabled
  118144. */
  118145. disableBidirectionalTransformation?: boolean;
  118146. /**
  118147. * The pressure inside the physics imposter, soft object only
  118148. */
  118149. pressure?: number;
  118150. /**
  118151. * The stiffness the physics imposter, soft object only
  118152. */
  118153. stiffness?: number;
  118154. /**
  118155. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  118156. */
  118157. velocityIterations?: number;
  118158. /**
  118159. * The number of iterations used in maintaining consistent vertex positions, soft object only
  118160. */
  118161. positionIterations?: number;
  118162. /**
  118163. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  118164. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  118165. * Add to fix multiple points
  118166. */
  118167. fixedPoints?: number;
  118168. /**
  118169. * The collision margin around a soft object
  118170. */
  118171. margin?: number;
  118172. /**
  118173. * The collision margin around a soft object
  118174. */
  118175. damping?: number;
  118176. /**
  118177. * The path for a rope based on an extrusion
  118178. */
  118179. path?: any;
  118180. /**
  118181. * The shape of an extrusion used for a rope based on an extrusion
  118182. */
  118183. shape?: any;
  118184. }
  118185. /**
  118186. * Interface for a physics-enabled object
  118187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118188. */
  118189. export interface IPhysicsEnabledObject {
  118190. /**
  118191. * The position of the physics-enabled object
  118192. */
  118193. position: Vector3;
  118194. /**
  118195. * The rotation of the physics-enabled object
  118196. */
  118197. rotationQuaternion: Nullable<Quaternion>;
  118198. /**
  118199. * The scale of the physics-enabled object
  118200. */
  118201. scaling: Vector3;
  118202. /**
  118203. * The rotation of the physics-enabled object
  118204. */
  118205. rotation?: Vector3;
  118206. /**
  118207. * The parent of the physics-enabled object
  118208. */
  118209. parent?: any;
  118210. /**
  118211. * The bounding info of the physics-enabled object
  118212. * @returns The bounding info of the physics-enabled object
  118213. */
  118214. getBoundingInfo(): BoundingInfo;
  118215. /**
  118216. * Computes the world matrix
  118217. * @param force Specifies if the world matrix should be computed by force
  118218. * @returns A world matrix
  118219. */
  118220. computeWorldMatrix(force: boolean): Matrix;
  118221. /**
  118222. * Gets the world matrix
  118223. * @returns A world matrix
  118224. */
  118225. getWorldMatrix?(): Matrix;
  118226. /**
  118227. * Gets the child meshes
  118228. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  118229. * @returns An array of abstract meshes
  118230. */
  118231. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  118232. /**
  118233. * Gets the vertex data
  118234. * @param kind The type of vertex data
  118235. * @returns A nullable array of numbers, or a float32 array
  118236. */
  118237. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  118238. /**
  118239. * Gets the indices from the mesh
  118240. * @returns A nullable array of index arrays
  118241. */
  118242. getIndices?(): Nullable<IndicesArray>;
  118243. /**
  118244. * Gets the scene from the mesh
  118245. * @returns the indices array or null
  118246. */
  118247. getScene?(): Scene;
  118248. /**
  118249. * Gets the absolute position from the mesh
  118250. * @returns the absolute position
  118251. */
  118252. getAbsolutePosition(): Vector3;
  118253. /**
  118254. * Gets the absolute pivot point from the mesh
  118255. * @returns the absolute pivot point
  118256. */
  118257. getAbsolutePivotPoint(): Vector3;
  118258. /**
  118259. * Rotates the mesh
  118260. * @param axis The axis of rotation
  118261. * @param amount The amount of rotation
  118262. * @param space The space of the rotation
  118263. * @returns The rotation transform node
  118264. */
  118265. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  118266. /**
  118267. * Translates the mesh
  118268. * @param axis The axis of translation
  118269. * @param distance The distance of translation
  118270. * @param space The space of the translation
  118271. * @returns The transform node
  118272. */
  118273. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  118274. /**
  118275. * Sets the absolute position of the mesh
  118276. * @param absolutePosition The absolute position of the mesh
  118277. * @returns The transform node
  118278. */
  118279. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  118280. /**
  118281. * Gets the class name of the mesh
  118282. * @returns The class name
  118283. */
  118284. getClassName(): string;
  118285. }
  118286. /**
  118287. * Represents a physics imposter
  118288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118289. */
  118290. export class PhysicsImpostor {
  118291. /**
  118292. * The physics-enabled object used as the physics imposter
  118293. */
  118294. object: IPhysicsEnabledObject;
  118295. /**
  118296. * The type of the physics imposter
  118297. */
  118298. type: number;
  118299. private _options;
  118300. private _scene?;
  118301. /**
  118302. * The default object size of the imposter
  118303. */
  118304. static DEFAULT_OBJECT_SIZE: Vector3;
  118305. /**
  118306. * The identity quaternion of the imposter
  118307. */
  118308. static IDENTITY_QUATERNION: Quaternion;
  118309. /** @hidden */
  118310. _pluginData: any;
  118311. private _physicsEngine;
  118312. private _physicsBody;
  118313. private _bodyUpdateRequired;
  118314. private _onBeforePhysicsStepCallbacks;
  118315. private _onAfterPhysicsStepCallbacks;
  118316. /** @hidden */
  118317. _onPhysicsCollideCallbacks: Array<{
  118318. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  118319. otherImpostors: Array<PhysicsImpostor>;
  118320. }>;
  118321. private _deltaPosition;
  118322. private _deltaRotation;
  118323. private _deltaRotationConjugated;
  118324. /** @hidden */
  118325. _isFromLine: boolean;
  118326. private _parent;
  118327. private _isDisposed;
  118328. private static _tmpVecs;
  118329. private static _tmpQuat;
  118330. /**
  118331. * Specifies if the physics imposter is disposed
  118332. */
  118333. get isDisposed(): boolean;
  118334. /**
  118335. * Gets the mass of the physics imposter
  118336. */
  118337. get mass(): number;
  118338. set mass(value: number);
  118339. /**
  118340. * Gets the coefficient of friction
  118341. */
  118342. get friction(): number;
  118343. /**
  118344. * Sets the coefficient of friction
  118345. */
  118346. set friction(value: number);
  118347. /**
  118348. * Gets the coefficient of restitution
  118349. */
  118350. get restitution(): number;
  118351. /**
  118352. * Sets the coefficient of restitution
  118353. */
  118354. set restitution(value: number);
  118355. /**
  118356. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  118357. */
  118358. get pressure(): number;
  118359. /**
  118360. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  118361. */
  118362. set pressure(value: number);
  118363. /**
  118364. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  118365. */
  118366. get stiffness(): number;
  118367. /**
  118368. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  118369. */
  118370. set stiffness(value: number);
  118371. /**
  118372. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  118373. */
  118374. get velocityIterations(): number;
  118375. /**
  118376. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  118377. */
  118378. set velocityIterations(value: number);
  118379. /**
  118380. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  118381. */
  118382. get positionIterations(): number;
  118383. /**
  118384. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  118385. */
  118386. set positionIterations(value: number);
  118387. /**
  118388. * The unique id of the physics imposter
  118389. * set by the physics engine when adding this impostor to the array
  118390. */
  118391. uniqueId: number;
  118392. /**
  118393. * @hidden
  118394. */
  118395. soft: boolean;
  118396. /**
  118397. * @hidden
  118398. */
  118399. segments: number;
  118400. private _joints;
  118401. /**
  118402. * Initializes the physics imposter
  118403. * @param object The physics-enabled object used as the physics imposter
  118404. * @param type The type of the physics imposter
  118405. * @param _options The options for the physics imposter
  118406. * @param _scene The Babylon scene
  118407. */
  118408. constructor(
  118409. /**
  118410. * The physics-enabled object used as the physics imposter
  118411. */
  118412. object: IPhysicsEnabledObject,
  118413. /**
  118414. * The type of the physics imposter
  118415. */
  118416. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  118417. /**
  118418. * This function will completely initialize this impostor.
  118419. * It will create a new body - but only if this mesh has no parent.
  118420. * If it has, this impostor will not be used other than to define the impostor
  118421. * of the child mesh.
  118422. * @hidden
  118423. */
  118424. _init(): void;
  118425. private _getPhysicsParent;
  118426. /**
  118427. * Should a new body be generated.
  118428. * @returns boolean specifying if body initialization is required
  118429. */
  118430. isBodyInitRequired(): boolean;
  118431. /**
  118432. * Sets the updated scaling
  118433. * @param updated Specifies if the scaling is updated
  118434. */
  118435. setScalingUpdated(): void;
  118436. /**
  118437. * Force a regeneration of this or the parent's impostor's body.
  118438. * Use under cautious - This will remove all joints already implemented.
  118439. */
  118440. forceUpdate(): void;
  118441. /**
  118442. * Gets the body that holds this impostor. Either its own, or its parent.
  118443. */
  118444. get physicsBody(): any;
  118445. /**
  118446. * Get the parent of the physics imposter
  118447. * @returns Physics imposter or null
  118448. */
  118449. get parent(): Nullable<PhysicsImpostor>;
  118450. /**
  118451. * Sets the parent of the physics imposter
  118452. */
  118453. set parent(value: Nullable<PhysicsImpostor>);
  118454. /**
  118455. * Set the physics body. Used mainly by the physics engine/plugin
  118456. */
  118457. set physicsBody(physicsBody: any);
  118458. /**
  118459. * Resets the update flags
  118460. */
  118461. resetUpdateFlags(): void;
  118462. /**
  118463. * Gets the object extend size
  118464. * @returns the object extend size
  118465. */
  118466. getObjectExtendSize(): Vector3;
  118467. /**
  118468. * Gets the object center
  118469. * @returns The object center
  118470. */
  118471. getObjectCenter(): Vector3;
  118472. /**
  118473. * Get a specific parameter from the options parameters
  118474. * @param paramName The object parameter name
  118475. * @returns The object parameter
  118476. */
  118477. getParam(paramName: string): any;
  118478. /**
  118479. * Sets a specific parameter in the options given to the physics plugin
  118480. * @param paramName The parameter name
  118481. * @param value The value of the parameter
  118482. */
  118483. setParam(paramName: string, value: number): void;
  118484. /**
  118485. * Specifically change the body's mass option. Won't recreate the physics body object
  118486. * @param mass The mass of the physics imposter
  118487. */
  118488. setMass(mass: number): void;
  118489. /**
  118490. * Gets the linear velocity
  118491. * @returns linear velocity or null
  118492. */
  118493. getLinearVelocity(): Nullable<Vector3>;
  118494. /**
  118495. * Sets the linear velocity
  118496. * @param velocity linear velocity or null
  118497. */
  118498. setLinearVelocity(velocity: Nullable<Vector3>): void;
  118499. /**
  118500. * Gets the angular velocity
  118501. * @returns angular velocity or null
  118502. */
  118503. getAngularVelocity(): Nullable<Vector3>;
  118504. /**
  118505. * Sets the angular velocity
  118506. * @param velocity The velocity or null
  118507. */
  118508. setAngularVelocity(velocity: Nullable<Vector3>): void;
  118509. /**
  118510. * Execute a function with the physics plugin native code
  118511. * Provide a function the will have two variables - the world object and the physics body object
  118512. * @param func The function to execute with the physics plugin native code
  118513. */
  118514. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  118515. /**
  118516. * Register a function that will be executed before the physics world is stepping forward
  118517. * @param func The function to execute before the physics world is stepped forward
  118518. */
  118519. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  118520. /**
  118521. * Unregister a function that will be executed before the physics world is stepping forward
  118522. * @param func The function to execute before the physics world is stepped forward
  118523. */
  118524. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  118525. /**
  118526. * Register a function that will be executed after the physics step
  118527. * @param func The function to execute after physics step
  118528. */
  118529. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  118530. /**
  118531. * Unregisters a function that will be executed after the physics step
  118532. * @param func The function to execute after physics step
  118533. */
  118534. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  118535. /**
  118536. * register a function that will be executed when this impostor collides against a different body
  118537. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  118538. * @param func Callback that is executed on collision
  118539. */
  118540. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  118541. /**
  118542. * Unregisters the physics imposter on contact
  118543. * @param collideAgainst The physics object to collide against
  118544. * @param func Callback to execute on collision
  118545. */
  118546. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  118547. private _tmpQuat;
  118548. private _tmpQuat2;
  118549. /**
  118550. * Get the parent rotation
  118551. * @returns The parent rotation
  118552. */
  118553. getParentsRotation(): Quaternion;
  118554. /**
  118555. * this function is executed by the physics engine.
  118556. */
  118557. beforeStep: () => void;
  118558. /**
  118559. * this function is executed by the physics engine
  118560. */
  118561. afterStep: () => void;
  118562. /**
  118563. * Legacy collision detection event support
  118564. */
  118565. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  118566. /**
  118567. * event and body object due to cannon's event-based architecture.
  118568. */
  118569. onCollide: (e: {
  118570. body: any;
  118571. point: Nullable<Vector3>;
  118572. }) => void;
  118573. /**
  118574. * Apply a force
  118575. * @param force The force to apply
  118576. * @param contactPoint The contact point for the force
  118577. * @returns The physics imposter
  118578. */
  118579. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  118580. /**
  118581. * Apply an impulse
  118582. * @param force The impulse force
  118583. * @param contactPoint The contact point for the impulse force
  118584. * @returns The physics imposter
  118585. */
  118586. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  118587. /**
  118588. * A help function to create a joint
  118589. * @param otherImpostor A physics imposter used to create a joint
  118590. * @param jointType The type of joint
  118591. * @param jointData The data for the joint
  118592. * @returns The physics imposter
  118593. */
  118594. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  118595. /**
  118596. * Add a joint to this impostor with a different impostor
  118597. * @param otherImpostor A physics imposter used to add a joint
  118598. * @param joint The joint to add
  118599. * @returns The physics imposter
  118600. */
  118601. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  118602. /**
  118603. * Add an anchor to a cloth impostor
  118604. * @param otherImpostor rigid impostor to anchor to
  118605. * @param width ratio across width from 0 to 1
  118606. * @param height ratio up height from 0 to 1
  118607. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  118608. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  118609. * @returns impostor the soft imposter
  118610. */
  118611. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  118612. /**
  118613. * Add a hook to a rope impostor
  118614. * @param otherImpostor rigid impostor to anchor to
  118615. * @param length ratio across rope from 0 to 1
  118616. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  118617. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118618. * @returns impostor the rope imposter
  118619. */
  118620. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  118621. /**
  118622. * Will keep this body still, in a sleep mode.
  118623. * @returns the physics imposter
  118624. */
  118625. sleep(): PhysicsImpostor;
  118626. /**
  118627. * Wake the body up.
  118628. * @returns The physics imposter
  118629. */
  118630. wakeUp(): PhysicsImpostor;
  118631. /**
  118632. * Clones the physics imposter
  118633. * @param newObject The physics imposter clones to this physics-enabled object
  118634. * @returns A nullable physics imposter
  118635. */
  118636. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118637. /**
  118638. * Disposes the physics imposter
  118639. */
  118640. dispose(): void;
  118641. /**
  118642. * Sets the delta position
  118643. * @param position The delta position amount
  118644. */
  118645. setDeltaPosition(position: Vector3): void;
  118646. /**
  118647. * Sets the delta rotation
  118648. * @param rotation The delta rotation amount
  118649. */
  118650. setDeltaRotation(rotation: Quaternion): void;
  118651. /**
  118652. * Gets the box size of the physics imposter and stores the result in the input parameter
  118653. * @param result Stores the box size
  118654. * @returns The physics imposter
  118655. */
  118656. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  118657. /**
  118658. * Gets the radius of the physics imposter
  118659. * @returns Radius of the physics imposter
  118660. */
  118661. getRadius(): number;
  118662. /**
  118663. * Sync a bone with this impostor
  118664. * @param bone The bone to sync to the impostor.
  118665. * @param boneMesh The mesh that the bone is influencing.
  118666. * @param jointPivot The pivot of the joint / bone in local space.
  118667. * @param distToJoint Optional distance from the impostor to the joint.
  118668. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  118669. */
  118670. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  118671. /**
  118672. * Sync impostor to a bone
  118673. * @param bone The bone that the impostor will be synced to.
  118674. * @param boneMesh The mesh that the bone is influencing.
  118675. * @param jointPivot The pivot of the joint / bone in local space.
  118676. * @param distToJoint Optional distance from the impostor to the joint.
  118677. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  118678. * @param boneAxis Optional vector3 axis the bone is aligned with
  118679. */
  118680. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  118681. /**
  118682. * No-Imposter type
  118683. */
  118684. static NoImpostor: number;
  118685. /**
  118686. * Sphere-Imposter type
  118687. */
  118688. static SphereImpostor: number;
  118689. /**
  118690. * Box-Imposter type
  118691. */
  118692. static BoxImpostor: number;
  118693. /**
  118694. * Plane-Imposter type
  118695. */
  118696. static PlaneImpostor: number;
  118697. /**
  118698. * Mesh-imposter type
  118699. */
  118700. static MeshImpostor: number;
  118701. /**
  118702. * Capsule-Impostor type (Ammo.js plugin only)
  118703. */
  118704. static CapsuleImpostor: number;
  118705. /**
  118706. * Cylinder-Imposter type
  118707. */
  118708. static CylinderImpostor: number;
  118709. /**
  118710. * Particle-Imposter type
  118711. */
  118712. static ParticleImpostor: number;
  118713. /**
  118714. * Heightmap-Imposter type
  118715. */
  118716. static HeightmapImpostor: number;
  118717. /**
  118718. * ConvexHull-Impostor type (Ammo.js plugin only)
  118719. */
  118720. static ConvexHullImpostor: number;
  118721. /**
  118722. * Custom-Imposter type (Ammo.js plugin only)
  118723. */
  118724. static CustomImpostor: number;
  118725. /**
  118726. * Rope-Imposter type
  118727. */
  118728. static RopeImpostor: number;
  118729. /**
  118730. * Cloth-Imposter type
  118731. */
  118732. static ClothImpostor: number;
  118733. /**
  118734. * Softbody-Imposter type
  118735. */
  118736. static SoftbodyImpostor: number;
  118737. }
  118738. }
  118739. declare module BABYLON {
  118740. /**
  118741. * @hidden
  118742. **/
  118743. export class _CreationDataStorage {
  118744. closePath?: boolean;
  118745. closeArray?: boolean;
  118746. idx: number[];
  118747. dashSize: number;
  118748. gapSize: number;
  118749. path3D: Path3D;
  118750. pathArray: Vector3[][];
  118751. arc: number;
  118752. radius: number;
  118753. cap: number;
  118754. tessellation: number;
  118755. }
  118756. /**
  118757. * @hidden
  118758. **/
  118759. class _InstanceDataStorage {
  118760. visibleInstances: any;
  118761. batchCache: _InstancesBatch;
  118762. instancesBufferSize: number;
  118763. instancesBuffer: Nullable<Buffer>;
  118764. instancesData: Float32Array;
  118765. overridenInstanceCount: number;
  118766. isFrozen: boolean;
  118767. previousBatch: Nullable<_InstancesBatch>;
  118768. hardwareInstancedRendering: boolean;
  118769. sideOrientation: number;
  118770. manualUpdate: boolean;
  118771. previousRenderId: number;
  118772. }
  118773. /**
  118774. * @hidden
  118775. **/
  118776. export class _InstancesBatch {
  118777. mustReturn: boolean;
  118778. visibleInstances: Nullable<InstancedMesh[]>[];
  118779. renderSelf: boolean[];
  118780. hardwareInstancedRendering: boolean[];
  118781. }
  118782. /**
  118783. * @hidden
  118784. **/
  118785. class _ThinInstanceDataStorage {
  118786. instancesCount: number;
  118787. matrixBuffer: Nullable<Buffer>;
  118788. matrixBufferSize: number;
  118789. matrixData: Nullable<Float32Array>;
  118790. boundingVectors: Array<Vector3>;
  118791. worldMatrices: Nullable<Matrix[]>;
  118792. }
  118793. /**
  118794. * Class used to represent renderable models
  118795. */
  118796. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  118797. /**
  118798. * Mesh side orientation : usually the external or front surface
  118799. */
  118800. static readonly FRONTSIDE: number;
  118801. /**
  118802. * Mesh side orientation : usually the internal or back surface
  118803. */
  118804. static readonly BACKSIDE: number;
  118805. /**
  118806. * Mesh side orientation : both internal and external or front and back surfaces
  118807. */
  118808. static readonly DOUBLESIDE: number;
  118809. /**
  118810. * Mesh side orientation : by default, `FRONTSIDE`
  118811. */
  118812. static readonly DEFAULTSIDE: number;
  118813. /**
  118814. * Mesh cap setting : no cap
  118815. */
  118816. static readonly NO_CAP: number;
  118817. /**
  118818. * Mesh cap setting : one cap at the beginning of the mesh
  118819. */
  118820. static readonly CAP_START: number;
  118821. /**
  118822. * Mesh cap setting : one cap at the end of the mesh
  118823. */
  118824. static readonly CAP_END: number;
  118825. /**
  118826. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  118827. */
  118828. static readonly CAP_ALL: number;
  118829. /**
  118830. * Mesh pattern setting : no flip or rotate
  118831. */
  118832. static readonly NO_FLIP: number;
  118833. /**
  118834. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  118835. */
  118836. static readonly FLIP_TILE: number;
  118837. /**
  118838. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  118839. */
  118840. static readonly ROTATE_TILE: number;
  118841. /**
  118842. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  118843. */
  118844. static readonly FLIP_ROW: number;
  118845. /**
  118846. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  118847. */
  118848. static readonly ROTATE_ROW: number;
  118849. /**
  118850. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  118851. */
  118852. static readonly FLIP_N_ROTATE_TILE: number;
  118853. /**
  118854. * Mesh pattern setting : rotate pattern and rotate
  118855. */
  118856. static readonly FLIP_N_ROTATE_ROW: number;
  118857. /**
  118858. * Mesh tile positioning : part tiles same on left/right or top/bottom
  118859. */
  118860. static readonly CENTER: number;
  118861. /**
  118862. * Mesh tile positioning : part tiles on left
  118863. */
  118864. static readonly LEFT: number;
  118865. /**
  118866. * Mesh tile positioning : part tiles on right
  118867. */
  118868. static readonly RIGHT: number;
  118869. /**
  118870. * Mesh tile positioning : part tiles on top
  118871. */
  118872. static readonly TOP: number;
  118873. /**
  118874. * Mesh tile positioning : part tiles on bottom
  118875. */
  118876. static readonly BOTTOM: number;
  118877. /**
  118878. * Gets the default side orientation.
  118879. * @param orientation the orientation to value to attempt to get
  118880. * @returns the default orientation
  118881. * @hidden
  118882. */
  118883. static _GetDefaultSideOrientation(orientation?: number): number;
  118884. private _internalMeshDataInfo;
  118885. get computeBonesUsingShaders(): boolean;
  118886. set computeBonesUsingShaders(value: boolean);
  118887. /**
  118888. * An event triggered before rendering the mesh
  118889. */
  118890. get onBeforeRenderObservable(): Observable<Mesh>;
  118891. /**
  118892. * An event triggered before binding the mesh
  118893. */
  118894. get onBeforeBindObservable(): Observable<Mesh>;
  118895. /**
  118896. * An event triggered after rendering the mesh
  118897. */
  118898. get onAfterRenderObservable(): Observable<Mesh>;
  118899. /**
  118900. * An event triggered before drawing the mesh
  118901. */
  118902. get onBeforeDrawObservable(): Observable<Mesh>;
  118903. private _onBeforeDrawObserver;
  118904. /**
  118905. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  118906. */
  118907. set onBeforeDraw(callback: () => void);
  118908. get hasInstances(): boolean;
  118909. get hasThinInstances(): boolean;
  118910. /**
  118911. * Gets the delay loading state of the mesh (when delay loading is turned on)
  118912. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  118913. */
  118914. delayLoadState: number;
  118915. /**
  118916. * Gets the list of instances created from this mesh
  118917. * it is not supposed to be modified manually.
  118918. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  118919. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118920. */
  118921. instances: InstancedMesh[];
  118922. /**
  118923. * Gets the file containing delay loading data for this mesh
  118924. */
  118925. delayLoadingFile: string;
  118926. /** @hidden */
  118927. _binaryInfo: any;
  118928. /**
  118929. * User defined function used to change how LOD level selection is done
  118930. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  118931. */
  118932. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  118933. /**
  118934. * Gets or sets the morph target manager
  118935. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  118936. */
  118937. get morphTargetManager(): Nullable<MorphTargetManager>;
  118938. set morphTargetManager(value: Nullable<MorphTargetManager>);
  118939. /** @hidden */
  118940. _creationDataStorage: Nullable<_CreationDataStorage>;
  118941. /** @hidden */
  118942. _geometry: Nullable<Geometry>;
  118943. /** @hidden */
  118944. _delayInfo: Array<string>;
  118945. /** @hidden */
  118946. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  118947. /** @hidden */
  118948. _instanceDataStorage: _InstanceDataStorage;
  118949. /** @hidden */
  118950. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  118951. private _effectiveMaterial;
  118952. /** @hidden */
  118953. _shouldGenerateFlatShading: boolean;
  118954. /** @hidden */
  118955. _originalBuilderSideOrientation: number;
  118956. /**
  118957. * Use this property to change the original side orientation defined at construction time
  118958. */
  118959. overrideMaterialSideOrientation: Nullable<number>;
  118960. /**
  118961. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  118962. * Note this will reduce performance when set to true.
  118963. */
  118964. ignoreCameraMaxZ: boolean;
  118965. /**
  118966. * Gets the source mesh (the one used to clone this one from)
  118967. */
  118968. get source(): Nullable<Mesh>;
  118969. /**
  118970. * Gets the list of clones of this mesh
  118971. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  118972. * Note that useClonedMeshMap=true is the default setting
  118973. */
  118974. get cloneMeshMap(): Nullable<{
  118975. [id: string]: Mesh | undefined;
  118976. }>;
  118977. /**
  118978. * Gets or sets a boolean indicating that this mesh does not use index buffer
  118979. */
  118980. get isUnIndexed(): boolean;
  118981. set isUnIndexed(value: boolean);
  118982. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  118983. get worldMatrixInstancedBuffer(): Float32Array;
  118984. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  118985. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  118986. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  118987. /**
  118988. * @constructor
  118989. * @param name The value used by scene.getMeshByName() to do a lookup.
  118990. * @param scene The scene to add this mesh to.
  118991. * @param parent The parent of this mesh, if it has one
  118992. * @param source An optional Mesh from which geometry is shared, cloned.
  118993. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  118994. * When false, achieved by calling a clone(), also passing False.
  118995. * This will make creation of children, recursive.
  118996. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  118997. */
  118998. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  118999. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  119000. doNotInstantiate: boolean;
  119001. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  119002. /**
  119003. * Gets the class name
  119004. * @returns the string "Mesh".
  119005. */
  119006. getClassName(): string;
  119007. /** @hidden */
  119008. get _isMesh(): boolean;
  119009. /**
  119010. * Returns a description of this mesh
  119011. * @param fullDetails define if full details about this mesh must be used
  119012. * @returns a descriptive string representing this mesh
  119013. */
  119014. toString(fullDetails?: boolean): string;
  119015. /** @hidden */
  119016. _unBindEffect(): void;
  119017. /**
  119018. * Gets a boolean indicating if this mesh has LOD
  119019. */
  119020. get hasLODLevels(): boolean;
  119021. /**
  119022. * Gets the list of MeshLODLevel associated with the current mesh
  119023. * @returns an array of MeshLODLevel
  119024. */
  119025. getLODLevels(): MeshLODLevel[];
  119026. private _sortLODLevels;
  119027. /**
  119028. * Add a mesh as LOD level triggered at the given distance.
  119029. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  119030. * @param distance The distance from the center of the object to show this level
  119031. * @param mesh The mesh to be added as LOD level (can be null)
  119032. * @return This mesh (for chaining)
  119033. */
  119034. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  119035. /**
  119036. * Returns the LOD level mesh at the passed distance or null if not found.
  119037. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  119038. * @param distance The distance from the center of the object to show this level
  119039. * @returns a Mesh or `null`
  119040. */
  119041. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  119042. /**
  119043. * Remove a mesh from the LOD array
  119044. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  119045. * @param mesh defines the mesh to be removed
  119046. * @return This mesh (for chaining)
  119047. */
  119048. removeLODLevel(mesh: Mesh): Mesh;
  119049. /**
  119050. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  119051. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  119052. * @param camera defines the camera to use to compute distance
  119053. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  119054. * @return This mesh (for chaining)
  119055. */
  119056. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  119057. /**
  119058. * Gets the mesh internal Geometry object
  119059. */
  119060. get geometry(): Nullable<Geometry>;
  119061. /**
  119062. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  119063. * @returns the total number of vertices
  119064. */
  119065. getTotalVertices(): number;
  119066. /**
  119067. * Returns the content of an associated vertex buffer
  119068. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  119069. * - VertexBuffer.PositionKind
  119070. * - VertexBuffer.UVKind
  119071. * - VertexBuffer.UV2Kind
  119072. * - VertexBuffer.UV3Kind
  119073. * - VertexBuffer.UV4Kind
  119074. * - VertexBuffer.UV5Kind
  119075. * - VertexBuffer.UV6Kind
  119076. * - VertexBuffer.ColorKind
  119077. * - VertexBuffer.MatricesIndicesKind
  119078. * - VertexBuffer.MatricesIndicesExtraKind
  119079. * - VertexBuffer.MatricesWeightsKind
  119080. * - VertexBuffer.MatricesWeightsExtraKind
  119081. * @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
  119082. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  119083. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  119084. */
  119085. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  119086. /**
  119087. * Returns the mesh VertexBuffer object from the requested `kind`
  119088. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  119089. * - VertexBuffer.PositionKind
  119090. * - VertexBuffer.NormalKind
  119091. * - VertexBuffer.UVKind
  119092. * - VertexBuffer.UV2Kind
  119093. * - VertexBuffer.UV3Kind
  119094. * - VertexBuffer.UV4Kind
  119095. * - VertexBuffer.UV5Kind
  119096. * - VertexBuffer.UV6Kind
  119097. * - VertexBuffer.ColorKind
  119098. * - VertexBuffer.MatricesIndicesKind
  119099. * - VertexBuffer.MatricesIndicesExtraKind
  119100. * - VertexBuffer.MatricesWeightsKind
  119101. * - VertexBuffer.MatricesWeightsExtraKind
  119102. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  119103. */
  119104. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  119105. /**
  119106. * Tests if a specific vertex buffer is associated with this mesh
  119107. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  119108. * - VertexBuffer.PositionKind
  119109. * - VertexBuffer.NormalKind
  119110. * - VertexBuffer.UVKind
  119111. * - VertexBuffer.UV2Kind
  119112. * - VertexBuffer.UV3Kind
  119113. * - VertexBuffer.UV4Kind
  119114. * - VertexBuffer.UV5Kind
  119115. * - VertexBuffer.UV6Kind
  119116. * - VertexBuffer.ColorKind
  119117. * - VertexBuffer.MatricesIndicesKind
  119118. * - VertexBuffer.MatricesIndicesExtraKind
  119119. * - VertexBuffer.MatricesWeightsKind
  119120. * - VertexBuffer.MatricesWeightsExtraKind
  119121. * @returns a boolean
  119122. */
  119123. isVerticesDataPresent(kind: string): boolean;
  119124. /**
  119125. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  119126. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  119127. * - VertexBuffer.PositionKind
  119128. * - VertexBuffer.UVKind
  119129. * - VertexBuffer.UV2Kind
  119130. * - VertexBuffer.UV3Kind
  119131. * - VertexBuffer.UV4Kind
  119132. * - VertexBuffer.UV5Kind
  119133. * - VertexBuffer.UV6Kind
  119134. * - VertexBuffer.ColorKind
  119135. * - VertexBuffer.MatricesIndicesKind
  119136. * - VertexBuffer.MatricesIndicesExtraKind
  119137. * - VertexBuffer.MatricesWeightsKind
  119138. * - VertexBuffer.MatricesWeightsExtraKind
  119139. * @returns a boolean
  119140. */
  119141. isVertexBufferUpdatable(kind: string): boolean;
  119142. /**
  119143. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  119144. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  119145. * - VertexBuffer.PositionKind
  119146. * - VertexBuffer.NormalKind
  119147. * - VertexBuffer.UVKind
  119148. * - VertexBuffer.UV2Kind
  119149. * - VertexBuffer.UV3Kind
  119150. * - VertexBuffer.UV4Kind
  119151. * - VertexBuffer.UV5Kind
  119152. * - VertexBuffer.UV6Kind
  119153. * - VertexBuffer.ColorKind
  119154. * - VertexBuffer.MatricesIndicesKind
  119155. * - VertexBuffer.MatricesIndicesExtraKind
  119156. * - VertexBuffer.MatricesWeightsKind
  119157. * - VertexBuffer.MatricesWeightsExtraKind
  119158. * @returns an array of strings
  119159. */
  119160. getVerticesDataKinds(): string[];
  119161. /**
  119162. * Returns a positive integer : the total number of indices in this mesh geometry.
  119163. * @returns the numner of indices or zero if the mesh has no geometry.
  119164. */
  119165. getTotalIndices(): number;
  119166. /**
  119167. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  119168. * @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.
  119169. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  119170. * @returns the indices array or an empty array if the mesh has no geometry
  119171. */
  119172. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  119173. get isBlocked(): boolean;
  119174. /**
  119175. * Determine if the current mesh is ready to be rendered
  119176. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  119177. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  119178. * @returns true if all associated assets are ready (material, textures, shaders)
  119179. */
  119180. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  119181. /**
  119182. * 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.
  119183. */
  119184. get areNormalsFrozen(): boolean;
  119185. /**
  119186. * 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.
  119187. * @returns the current mesh
  119188. */
  119189. freezeNormals(): Mesh;
  119190. /**
  119191. * 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
  119192. * @returns the current mesh
  119193. */
  119194. unfreezeNormals(): Mesh;
  119195. /**
  119196. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  119197. */
  119198. set overridenInstanceCount(count: number);
  119199. /** @hidden */
  119200. _preActivate(): Mesh;
  119201. /** @hidden */
  119202. _preActivateForIntermediateRendering(renderId: number): Mesh;
  119203. /** @hidden */
  119204. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  119205. protected _afterComputeWorldMatrix(): void;
  119206. /** @hidden */
  119207. _postActivate(): void;
  119208. /**
  119209. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  119210. * This means the mesh underlying bounding box and sphere are recomputed.
  119211. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  119212. * @returns the current mesh
  119213. */
  119214. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  119215. /** @hidden */
  119216. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  119217. /**
  119218. * This function will subdivide the mesh into multiple submeshes
  119219. * @param count defines the expected number of submeshes
  119220. */
  119221. subdivide(count: number): void;
  119222. /**
  119223. * Copy a FloatArray into a specific associated vertex buffer
  119224. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  119225. * - VertexBuffer.PositionKind
  119226. * - VertexBuffer.UVKind
  119227. * - VertexBuffer.UV2Kind
  119228. * - VertexBuffer.UV3Kind
  119229. * - VertexBuffer.UV4Kind
  119230. * - VertexBuffer.UV5Kind
  119231. * - VertexBuffer.UV6Kind
  119232. * - VertexBuffer.ColorKind
  119233. * - VertexBuffer.MatricesIndicesKind
  119234. * - VertexBuffer.MatricesIndicesExtraKind
  119235. * - VertexBuffer.MatricesWeightsKind
  119236. * - VertexBuffer.MatricesWeightsExtraKind
  119237. * @param data defines the data source
  119238. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  119239. * @param stride defines the data stride size (can be null)
  119240. * @returns the current mesh
  119241. */
  119242. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  119243. /**
  119244. * Delete a vertex buffer associated with this mesh
  119245. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  119246. * - VertexBuffer.PositionKind
  119247. * - VertexBuffer.UVKind
  119248. * - VertexBuffer.UV2Kind
  119249. * - VertexBuffer.UV3Kind
  119250. * - VertexBuffer.UV4Kind
  119251. * - VertexBuffer.UV5Kind
  119252. * - VertexBuffer.UV6Kind
  119253. * - VertexBuffer.ColorKind
  119254. * - VertexBuffer.MatricesIndicesKind
  119255. * - VertexBuffer.MatricesIndicesExtraKind
  119256. * - VertexBuffer.MatricesWeightsKind
  119257. * - VertexBuffer.MatricesWeightsExtraKind
  119258. */
  119259. removeVerticesData(kind: string): void;
  119260. /**
  119261. * Flags an associated vertex buffer as updatable
  119262. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  119263. * - VertexBuffer.PositionKind
  119264. * - VertexBuffer.UVKind
  119265. * - VertexBuffer.UV2Kind
  119266. * - VertexBuffer.UV3Kind
  119267. * - VertexBuffer.UV4Kind
  119268. * - VertexBuffer.UV5Kind
  119269. * - VertexBuffer.UV6Kind
  119270. * - VertexBuffer.ColorKind
  119271. * - VertexBuffer.MatricesIndicesKind
  119272. * - VertexBuffer.MatricesIndicesExtraKind
  119273. * - VertexBuffer.MatricesWeightsKind
  119274. * - VertexBuffer.MatricesWeightsExtraKind
  119275. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  119276. */
  119277. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  119278. /**
  119279. * Sets the mesh global Vertex Buffer
  119280. * @param buffer defines the buffer to use
  119281. * @returns the current mesh
  119282. */
  119283. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  119284. /**
  119285. * Update a specific associated vertex buffer
  119286. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  119287. * - VertexBuffer.PositionKind
  119288. * - VertexBuffer.UVKind
  119289. * - VertexBuffer.UV2Kind
  119290. * - VertexBuffer.UV3Kind
  119291. * - VertexBuffer.UV4Kind
  119292. * - VertexBuffer.UV5Kind
  119293. * - VertexBuffer.UV6Kind
  119294. * - VertexBuffer.ColorKind
  119295. * - VertexBuffer.MatricesIndicesKind
  119296. * - VertexBuffer.MatricesIndicesExtraKind
  119297. * - VertexBuffer.MatricesWeightsKind
  119298. * - VertexBuffer.MatricesWeightsExtraKind
  119299. * @param data defines the data source
  119300. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  119301. * @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)
  119302. * @returns the current mesh
  119303. */
  119304. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  119305. /**
  119306. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  119307. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  119308. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  119309. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  119310. * @returns the current mesh
  119311. */
  119312. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  119313. /**
  119314. * Creates a un-shared specific occurence of the geometry for the mesh.
  119315. * @returns the current mesh
  119316. */
  119317. makeGeometryUnique(): Mesh;
  119318. /**
  119319. * Set the index buffer of this mesh
  119320. * @param indices defines the source data
  119321. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  119322. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  119323. * @returns the current mesh
  119324. */
  119325. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  119326. /**
  119327. * Update the current index buffer
  119328. * @param indices defines the source data
  119329. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  119330. * @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)
  119331. * @returns the current mesh
  119332. */
  119333. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  119334. /**
  119335. * Invert the geometry to move from a right handed system to a left handed one.
  119336. * @returns the current mesh
  119337. */
  119338. toLeftHanded(): Mesh;
  119339. /** @hidden */
  119340. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  119341. /** @hidden */
  119342. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  119343. /**
  119344. * Registers for this mesh a javascript function called just before the rendering process
  119345. * @param func defines the function to call before rendering this mesh
  119346. * @returns the current mesh
  119347. */
  119348. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  119349. /**
  119350. * Disposes a previously registered javascript function called before the rendering
  119351. * @param func defines the function to remove
  119352. * @returns the current mesh
  119353. */
  119354. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  119355. /**
  119356. * Registers for this mesh a javascript function called just after the rendering is complete
  119357. * @param func defines the function to call after rendering this mesh
  119358. * @returns the current mesh
  119359. */
  119360. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  119361. /**
  119362. * Disposes a previously registered javascript function called after the rendering.
  119363. * @param func defines the function to remove
  119364. * @returns the current mesh
  119365. */
  119366. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  119367. /** @hidden */
  119368. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  119369. /** @hidden */
  119370. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  119371. /** @hidden */
  119372. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  119373. /** @hidden */
  119374. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  119375. /** @hidden */
  119376. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  119377. /** @hidden */
  119378. _rebuild(): void;
  119379. /** @hidden */
  119380. _freeze(): void;
  119381. /** @hidden */
  119382. _unFreeze(): void;
  119383. /**
  119384. * 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
  119385. * @param subMesh defines the subMesh to render
  119386. * @param enableAlphaMode defines if alpha mode can be changed
  119387. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  119388. * @returns the current mesh
  119389. */
  119390. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  119391. private _onBeforeDraw;
  119392. /**
  119393. * Renormalize the mesh and patch it up if there are no weights
  119394. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  119395. * However in the case of zero weights then we set just a single influence to 1.
  119396. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  119397. */
  119398. cleanMatrixWeights(): void;
  119399. private normalizeSkinFourWeights;
  119400. private normalizeSkinWeightsAndExtra;
  119401. /**
  119402. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  119403. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  119404. * the user know there was an issue with importing the mesh
  119405. * @returns a validation object with skinned, valid and report string
  119406. */
  119407. validateSkinning(): {
  119408. skinned: boolean;
  119409. valid: boolean;
  119410. report: string;
  119411. };
  119412. /** @hidden */
  119413. _checkDelayState(): Mesh;
  119414. private _queueLoad;
  119415. /**
  119416. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  119417. * A mesh is in the frustum if its bounding box intersects the frustum
  119418. * @param frustumPlanes defines the frustum to test
  119419. * @returns true if the mesh is in the frustum planes
  119420. */
  119421. isInFrustum(frustumPlanes: Plane[]): boolean;
  119422. /**
  119423. * Sets the mesh material by the material or multiMaterial `id` property
  119424. * @param id is a string identifying the material or the multiMaterial
  119425. * @returns the current mesh
  119426. */
  119427. setMaterialByID(id: string): Mesh;
  119428. /**
  119429. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  119430. * @returns an array of IAnimatable
  119431. */
  119432. getAnimatables(): IAnimatable[];
  119433. /**
  119434. * Modifies the mesh geometry according to the passed transformation matrix.
  119435. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  119436. * The mesh normals are modified using the same transformation.
  119437. * Note that, under the hood, this method sets a new VertexBuffer each call.
  119438. * @param transform defines the transform matrix to use
  119439. * @see https://doc.babylonjs.com/resources/baking_transformations
  119440. * @returns the current mesh
  119441. */
  119442. bakeTransformIntoVertices(transform: Matrix): Mesh;
  119443. /**
  119444. * Modifies the mesh geometry according to its own current World Matrix.
  119445. * The mesh World Matrix is then reset.
  119446. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  119447. * Note that, under the hood, this method sets a new VertexBuffer each call.
  119448. * @see https://doc.babylonjs.com/resources/baking_transformations
  119449. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  119450. * @returns the current mesh
  119451. */
  119452. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  119453. /** @hidden */
  119454. get _positions(): Nullable<Vector3[]>;
  119455. /** @hidden */
  119456. _resetPointsArrayCache(): Mesh;
  119457. /** @hidden */
  119458. _generatePointsArray(): boolean;
  119459. /**
  119460. * Returns a new Mesh object generated from the current mesh properties.
  119461. * This method must not get confused with createInstance()
  119462. * @param name is a string, the name given to the new mesh
  119463. * @param newParent can be any Node object (default `null`)
  119464. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  119465. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  119466. * @returns a new mesh
  119467. */
  119468. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  119469. /**
  119470. * Releases resources associated with this mesh.
  119471. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119472. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119473. */
  119474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119475. /** @hidden */
  119476. _disposeInstanceSpecificData(): void;
  119477. /** @hidden */
  119478. _disposeThinInstanceSpecificData(): void;
  119479. /**
  119480. * Modifies the mesh geometry according to a displacement map.
  119481. * 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.
  119482. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  119483. * @param url is a string, the URL from the image file is to be downloaded.
  119484. * @param minHeight is the lower limit of the displacement.
  119485. * @param maxHeight is the upper limit of the displacement.
  119486. * @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.
  119487. * @param uvOffset is an optional vector2 used to offset UV.
  119488. * @param uvScale is an optional vector2 used to scale UV.
  119489. * @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.
  119490. * @returns the Mesh.
  119491. */
  119492. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  119493. /**
  119494. * Modifies the mesh geometry according to a displacementMap buffer.
  119495. * 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.
  119496. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  119497. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  119498. * @param heightMapWidth is the width of the buffer image.
  119499. * @param heightMapHeight is the height of the buffer image.
  119500. * @param minHeight is the lower limit of the displacement.
  119501. * @param maxHeight is the upper limit of the displacement.
  119502. * @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.
  119503. * @param uvOffset is an optional vector2 used to offset UV.
  119504. * @param uvScale is an optional vector2 used to scale UV.
  119505. * @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.
  119506. * @returns the Mesh.
  119507. */
  119508. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  119509. /**
  119510. * Modify the mesh to get a flat shading rendering.
  119511. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  119512. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  119513. * @returns current mesh
  119514. */
  119515. convertToFlatShadedMesh(): Mesh;
  119516. /**
  119517. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  119518. * In other words, more vertices, no more indices and a single bigger VBO.
  119519. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  119520. * @returns current mesh
  119521. */
  119522. convertToUnIndexedMesh(): Mesh;
  119523. /**
  119524. * Inverses facet orientations.
  119525. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  119526. * @param flipNormals will also inverts the normals
  119527. * @returns current mesh
  119528. */
  119529. flipFaces(flipNormals?: boolean): Mesh;
  119530. /**
  119531. * Increase the number of facets and hence vertices in a mesh
  119532. * Vertex normals are interpolated from existing vertex normals
  119533. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  119534. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  119535. */
  119536. increaseVertices(numberPerEdge: number): void;
  119537. /**
  119538. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  119539. * This will undo any application of covertToFlatShadedMesh
  119540. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  119541. */
  119542. forceSharedVertices(): void;
  119543. /** @hidden */
  119544. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  119545. /** @hidden */
  119546. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  119547. /**
  119548. * Creates a new InstancedMesh object from the mesh model.
  119549. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119550. * @param name defines the name of the new instance
  119551. * @returns a new InstancedMesh
  119552. */
  119553. createInstance(name: string): InstancedMesh;
  119554. /**
  119555. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  119556. * After this call, all the mesh instances have the same submeshes than the current mesh.
  119557. * @returns the current mesh
  119558. */
  119559. synchronizeInstances(): Mesh;
  119560. /**
  119561. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  119562. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  119563. * This should be used together with the simplification to avoid disappearing triangles.
  119564. * @param successCallback an optional success callback to be called after the optimization finished.
  119565. * @returns the current mesh
  119566. */
  119567. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  119568. /**
  119569. * Serialize current mesh
  119570. * @param serializationObject defines the object which will receive the serialization data
  119571. */
  119572. serialize(serializationObject: any): void;
  119573. /** @hidden */
  119574. _syncGeometryWithMorphTargetManager(): void;
  119575. /** @hidden */
  119576. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  119577. /**
  119578. * Returns a new Mesh object parsed from the source provided.
  119579. * @param parsedMesh is the source
  119580. * @param scene defines the hosting scene
  119581. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  119582. * @returns a new Mesh
  119583. */
  119584. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  119585. /**
  119586. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  119587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119588. * @param name defines the name of the mesh to create
  119589. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  119590. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  119591. * @param closePath creates a seam between the first and the last points of each path of the path array
  119592. * @param offset is taken in account only if the `pathArray` is containing a single path
  119593. * @param scene defines the hosting scene
  119594. * @param updatable defines if the mesh must be flagged as updatable
  119595. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119596. * @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)
  119597. * @returns a new Mesh
  119598. */
  119599. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  119600. /**
  119601. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  119602. * @param name defines the name of the mesh to create
  119603. * @param radius sets the radius size (float) of the polygon (default 0.5)
  119604. * @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
  119605. * @param scene defines the hosting scene
  119606. * @param updatable defines if the mesh must be flagged as updatable
  119607. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119608. * @returns a new Mesh
  119609. */
  119610. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  119611. /**
  119612. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  119613. * @param name defines the name of the mesh to create
  119614. * @param size sets the size (float) of each box side (default 1)
  119615. * @param scene defines the hosting scene
  119616. * @param updatable defines if the mesh must be flagged as updatable
  119617. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119618. * @returns a new Mesh
  119619. */
  119620. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  119621. /**
  119622. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  119623. * @param name defines the name of the mesh to create
  119624. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  119625. * @param diameter sets the diameter size (float) of the sphere (default 1)
  119626. * @param scene defines the hosting scene
  119627. * @param updatable defines if the mesh must be flagged as updatable
  119628. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119629. * @returns a new Mesh
  119630. */
  119631. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  119632. /**
  119633. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  119634. * @param name defines the name of the mesh to create
  119635. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  119636. * @param diameter sets the diameter size (float) of the sphere (default 1)
  119637. * @param scene defines the hosting scene
  119638. * @returns a new Mesh
  119639. */
  119640. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  119641. /**
  119642. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  119643. * @param name defines the name of the mesh to create
  119644. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  119645. * @param diameterTop set the top cap diameter (floats, default 1)
  119646. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  119647. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  119648. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  119649. * @param scene defines the hosting scene
  119650. * @param updatable defines if the mesh must be flagged as updatable
  119651. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119652. * @returns a new Mesh
  119653. */
  119654. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  119655. /**
  119656. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  119657. * @param name defines the name of the mesh to create
  119658. * @param diameter sets the diameter size (float) of the torus (default 1)
  119659. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  119660. * @param tessellation sets the number of torus sides (positive integer, default 16)
  119661. * @param scene defines the hosting scene
  119662. * @param updatable defines if the mesh must be flagged as updatable
  119663. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119664. * @returns a new Mesh
  119665. */
  119666. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  119667. /**
  119668. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  119669. * @param name defines the name of the mesh to create
  119670. * @param radius sets the global radius size (float) of the torus knot (default 2)
  119671. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  119672. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  119673. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  119674. * @param p the number of windings on X axis (positive integers, default 2)
  119675. * @param q the number of windings on Y axis (positive integers, default 3)
  119676. * @param scene defines the hosting scene
  119677. * @param updatable defines if the mesh must be flagged as updatable
  119678. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119679. * @returns a new Mesh
  119680. */
  119681. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  119682. /**
  119683. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  119684. * @param name defines the name of the mesh to create
  119685. * @param points is an array successive Vector3
  119686. * @param scene defines the hosting scene
  119687. * @param updatable defines if the mesh must be flagged as updatable
  119688. * @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).
  119689. * @returns a new Mesh
  119690. */
  119691. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  119692. /**
  119693. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  119694. * @param name defines the name of the mesh to create
  119695. * @param points is an array successive Vector3
  119696. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  119697. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119698. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  119699. * @param scene defines the hosting scene
  119700. * @param updatable defines if the mesh must be flagged as updatable
  119701. * @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)
  119702. * @returns a new Mesh
  119703. */
  119704. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  119705. /**
  119706. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  119707. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  119708. * 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.
  119709. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119710. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119711. * Remember you can only change the shape positions, not their number when updating a polygon.
  119712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  119713. * @param name defines the name of the mesh to create
  119714. * @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
  119715. * @param scene defines the hosting scene
  119716. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  119717. * @param updatable defines if the mesh must be flagged as updatable
  119718. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119719. * @param earcutInjection can be used to inject your own earcut reference
  119720. * @returns a new Mesh
  119721. */
  119722. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  119723. /**
  119724. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  119725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  119726. * @param name defines the name of the mesh to create
  119727. * @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
  119728. * @param depth defines the height of extrusion
  119729. * @param scene defines the hosting scene
  119730. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  119731. * @param updatable defines if the mesh must be flagged as updatable
  119732. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119733. * @param earcutInjection can be used to inject your own earcut reference
  119734. * @returns a new Mesh
  119735. */
  119736. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  119737. /**
  119738. * Creates an extruded shape mesh.
  119739. * 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
  119740. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119742. * @param name defines the name of the mesh to create
  119743. * @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
  119744. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  119745. * @param scale is the value to scale the shape
  119746. * @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
  119747. * @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
  119748. * @param scene defines the hosting scene
  119749. * @param updatable defines if the mesh must be flagged as updatable
  119750. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119751. * @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)
  119752. * @returns a new Mesh
  119753. */
  119754. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  119755. /**
  119756. * Creates an custom extruded shape mesh.
  119757. * The custom extrusion is a parametric shape.
  119758. * It has no predefined shape. Its final shape will depend on the input parameters.
  119759. * Please consider using the same method from the MeshBuilder class instead
  119760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119761. * @param name defines the name of the mesh to create
  119762. * @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
  119763. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  119764. * @param scaleFunction is a custom Javascript function called on each path point
  119765. * @param rotationFunction is a custom Javascript function called on each path point
  119766. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119767. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  119768. * @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
  119769. * @param scene defines the hosting scene
  119770. * @param updatable defines if the mesh must be flagged as updatable
  119771. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119772. * @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)
  119773. * @returns a new Mesh
  119774. */
  119775. 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;
  119776. /**
  119777. * Creates lathe mesh.
  119778. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  119779. * Please consider using the same method from the MeshBuilder class instead
  119780. * @param name defines the name of the mesh to create
  119781. * @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
  119782. * @param radius is the radius value of the lathe
  119783. * @param tessellation is the side number of the lathe.
  119784. * @param scene defines the hosting scene
  119785. * @param updatable defines if the mesh must be flagged as updatable
  119786. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119787. * @returns a new Mesh
  119788. */
  119789. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  119790. /**
  119791. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  119792. * @param name defines the name of the mesh to create
  119793. * @param size sets the size (float) of both sides of the plane at once (default 1)
  119794. * @param scene defines the hosting scene
  119795. * @param updatable defines if the mesh must be flagged as updatable
  119796. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119797. * @returns a new Mesh
  119798. */
  119799. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  119800. /**
  119801. * Creates a ground mesh.
  119802. * Please consider using the same method from the MeshBuilder class instead
  119803. * @param name defines the name of the mesh to create
  119804. * @param width set the width of the ground
  119805. * @param height set the height of the ground
  119806. * @param subdivisions sets the number of subdivisions per side
  119807. * @param scene defines the hosting scene
  119808. * @param updatable defines if the mesh must be flagged as updatable
  119809. * @returns a new Mesh
  119810. */
  119811. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  119812. /**
  119813. * Creates a tiled ground mesh.
  119814. * Please consider using the same method from the MeshBuilder class instead
  119815. * @param name defines the name of the mesh to create
  119816. * @param xmin set the ground minimum X coordinate
  119817. * @param zmin set the ground minimum Y coordinate
  119818. * @param xmax set the ground maximum X coordinate
  119819. * @param zmax set the ground maximum Z coordinate
  119820. * @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
  119821. * @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
  119822. * @param scene defines the hosting scene
  119823. * @param updatable defines if the mesh must be flagged as updatable
  119824. * @returns a new Mesh
  119825. */
  119826. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  119827. w: number;
  119828. h: number;
  119829. }, precision: {
  119830. w: number;
  119831. h: number;
  119832. }, scene: Scene, updatable?: boolean): Mesh;
  119833. /**
  119834. * Creates a ground mesh from a height map.
  119835. * Please consider using the same method from the MeshBuilder class instead
  119836. * @see https://doc.babylonjs.com/babylon101/height_map
  119837. * @param name defines the name of the mesh to create
  119838. * @param url sets the URL of the height map image resource
  119839. * @param width set the ground width size
  119840. * @param height set the ground height size
  119841. * @param subdivisions sets the number of subdivision per side
  119842. * @param minHeight is the minimum altitude on the ground
  119843. * @param maxHeight is the maximum altitude on the ground
  119844. * @param scene defines the hosting scene
  119845. * @param updatable defines if the mesh must be flagged as updatable
  119846. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  119847. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  119848. * @returns a new Mesh
  119849. */
  119850. 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;
  119851. /**
  119852. * Creates a tube mesh.
  119853. * The tube is a parametric shape.
  119854. * It has no predefined shape. Its final shape will depend on the input parameters.
  119855. * Please consider using the same method from the MeshBuilder class instead
  119856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119857. * @param name defines the name of the mesh to create
  119858. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  119859. * @param radius sets the tube radius size
  119860. * @param tessellation is the number of sides on the tubular surface
  119861. * @param radiusFunction is a custom function. If it is not null, it overrides 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
  119862. * @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
  119863. * @param scene defines the hosting scene
  119864. * @param updatable defines if the mesh must be flagged as updatable
  119865. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  119866. * @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)
  119867. * @returns a new Mesh
  119868. */
  119869. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  119870. (i: number, distance: number): number;
  119871. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  119872. /**
  119873. * Creates a polyhedron mesh.
  119874. * Please consider using the same method from the MeshBuilder class instead.
  119875. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embedded types. Please refer to the type sheet in the tutorial to choose the wanted type
  119876. * * The parameter `size` (positive float, default 1) sets the polygon size
  119877. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119878. * * 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`
  119879. * * 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
  119880. * * 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)`)
  119881. * * 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
  119882. * * 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
  119883. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119886. * @param name defines the name of the mesh to create
  119887. * @param options defines the options used to create the mesh
  119888. * @param scene defines the hosting scene
  119889. * @returns a new Mesh
  119890. */
  119891. static CreatePolyhedron(name: string, options: {
  119892. type?: number;
  119893. size?: number;
  119894. sizeX?: number;
  119895. sizeY?: number;
  119896. sizeZ?: number;
  119897. custom?: any;
  119898. faceUV?: Vector4[];
  119899. faceColors?: Color4[];
  119900. updatable?: boolean;
  119901. sideOrientation?: number;
  119902. }, scene: Scene): Mesh;
  119903. /**
  119904. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119905. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119906. * * 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`)
  119907. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119908. * * 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
  119909. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119912. * @param name defines the name of the mesh
  119913. * @param options defines the options used to create the mesh
  119914. * @param scene defines the hosting scene
  119915. * @returns a new Mesh
  119916. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119917. */
  119918. static CreateIcoSphere(name: string, options: {
  119919. radius?: number;
  119920. flat?: boolean;
  119921. subdivisions?: number;
  119922. sideOrientation?: number;
  119923. updatable?: boolean;
  119924. }, scene: Scene): Mesh;
  119925. /**
  119926. * Creates a decal mesh.
  119927. * Please consider using the same method from the MeshBuilder class instead.
  119928. * A decal is a mesh usually applied as a model onto the surface of another mesh
  119929. * @param name defines the name of the mesh
  119930. * @param sourceMesh defines the mesh receiving the decal
  119931. * @param position sets the position of the decal in world coordinates
  119932. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  119933. * @param size sets the decal scaling
  119934. * @param angle sets the angle to rotate the decal
  119935. * @returns a new Mesh
  119936. */
  119937. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  119938. /** Creates a Capsule Mesh
  119939. * @param name defines the name of the mesh.
  119940. * @param options the constructors options used to shape the mesh.
  119941. * @param scene defines the scene the mesh is scoped to.
  119942. * @returns the capsule mesh
  119943. * @see https://doc.babylonjs.com/how_to/capsule_shape
  119944. */
  119945. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  119946. /**
  119947. * Prepare internal position array for software CPU skinning
  119948. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  119949. */
  119950. setPositionsForCPUSkinning(): Float32Array;
  119951. /**
  119952. * Prepare internal normal array for software CPU skinning
  119953. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  119954. */
  119955. setNormalsForCPUSkinning(): Float32Array;
  119956. /**
  119957. * Updates the vertex buffer by applying transformation from the bones
  119958. * @param skeleton defines the skeleton to apply to current mesh
  119959. * @returns the current mesh
  119960. */
  119961. applySkeleton(skeleton: Skeleton): Mesh;
  119962. /**
  119963. * 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
  119964. * @param meshes defines the list of meshes to scan
  119965. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  119966. */
  119967. static MinMax(meshes: AbstractMesh[]): {
  119968. min: Vector3;
  119969. max: Vector3;
  119970. };
  119971. /**
  119972. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  119973. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  119974. * @returns a vector3
  119975. */
  119976. static Center(meshesOrMinMaxVector: {
  119977. min: Vector3;
  119978. max: Vector3;
  119979. } | AbstractMesh[]): Vector3;
  119980. /**
  119981. * Merge the array of meshes into a single mesh for performance reasons.
  119982. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  119983. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  119984. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  119985. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  119986. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  119987. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  119988. * @returns a new mesh
  119989. */
  119990. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  119991. /** @hidden */
  119992. addInstance(instance: InstancedMesh): void;
  119993. /** @hidden */
  119994. removeInstance(instance: InstancedMesh): void;
  119995. }
  119996. }
  119997. declare module BABYLON {
  119998. /**
  119999. * The options Interface for creating a Capsule Mesh
  120000. */
  120001. export interface ICreateCapsuleOptions {
  120002. /** The Orientation of the capsule. Default : Vector3.Up() */
  120003. orientation?: Vector3;
  120004. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  120005. subdivisions: number;
  120006. /** Number of cylindrical segments on the capsule. */
  120007. tessellation: number;
  120008. /** Height or Length of the capsule. */
  120009. height: number;
  120010. /** Radius of the capsule. */
  120011. radius: number;
  120012. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  120013. capSubdivisions: number;
  120014. /** Overwrite for the top radius. */
  120015. radiusTop?: number;
  120016. /** Overwrite for the bottom radius. */
  120017. radiusBottom?: number;
  120018. /** Overwrite for the top capSubdivisions. */
  120019. topCapSubdivisions?: number;
  120020. /** Overwrite for the bottom capSubdivisions. */
  120021. bottomCapSubdivisions?: number;
  120022. /** Internal geometry is supposed to change once created. */
  120023. updatable?: boolean;
  120024. }
  120025. /**
  120026. * Class containing static functions to help procedurally build meshes
  120027. */
  120028. export class CapsuleBuilder {
  120029. /**
  120030. * Creates a capsule or a pill mesh
  120031. * @param name defines the name of the mesh
  120032. * @param options The constructors options.
  120033. * @param scene The scene the mesh is scoped to.
  120034. * @returns Capsule Mesh
  120035. */
  120036. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  120037. }
  120038. }
  120039. declare module BABYLON {
  120040. /**
  120041. * Define an interface for all classes that will get and set the data on vertices
  120042. */
  120043. export interface IGetSetVerticesData {
  120044. /**
  120045. * Gets a boolean indicating if specific vertex data is present
  120046. * @param kind defines the vertex data kind to use
  120047. * @returns true is data kind is present
  120048. */
  120049. isVerticesDataPresent(kind: string): boolean;
  120050. /**
  120051. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  120052. * @param kind defines the data kind (Position, normal, etc...)
  120053. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  120054. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  120055. * @returns a float array containing vertex data
  120056. */
  120057. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  120058. /**
  120059. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  120060. * @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.
  120061. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  120062. * @returns the indices array or an empty array if the mesh has no geometry
  120063. */
  120064. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  120065. /**
  120066. * Set specific vertex data
  120067. * @param kind defines the data kind (Position, normal, etc...)
  120068. * @param data defines the vertex data to use
  120069. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  120070. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  120071. */
  120072. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  120073. /**
  120074. * Update a specific associated vertex buffer
  120075. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  120076. * - VertexBuffer.PositionKind
  120077. * - VertexBuffer.UVKind
  120078. * - VertexBuffer.UV2Kind
  120079. * - VertexBuffer.UV3Kind
  120080. * - VertexBuffer.UV4Kind
  120081. * - VertexBuffer.UV5Kind
  120082. * - VertexBuffer.UV6Kind
  120083. * - VertexBuffer.ColorKind
  120084. * - VertexBuffer.MatricesIndicesKind
  120085. * - VertexBuffer.MatricesIndicesExtraKind
  120086. * - VertexBuffer.MatricesWeightsKind
  120087. * - VertexBuffer.MatricesWeightsExtraKind
  120088. * @param data defines the data source
  120089. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  120090. * @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)
  120091. */
  120092. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  120093. /**
  120094. * Creates a new index buffer
  120095. * @param indices defines the indices to store in the index buffer
  120096. * @param totalVertices defines the total number of vertices (could be null)
  120097. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  120098. */
  120099. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  120100. }
  120101. /**
  120102. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  120103. */
  120104. export class VertexData {
  120105. /**
  120106. * Mesh side orientation : usually the external or front surface
  120107. */
  120108. static readonly FRONTSIDE: number;
  120109. /**
  120110. * Mesh side orientation : usually the internal or back surface
  120111. */
  120112. static readonly BACKSIDE: number;
  120113. /**
  120114. * Mesh side orientation : both internal and external or front and back surfaces
  120115. */
  120116. static readonly DOUBLESIDE: number;
  120117. /**
  120118. * Mesh side orientation : by default, `FRONTSIDE`
  120119. */
  120120. static readonly DEFAULTSIDE: number;
  120121. /**
  120122. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  120123. */
  120124. positions: Nullable<FloatArray>;
  120125. /**
  120126. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  120127. */
  120128. normals: Nullable<FloatArray>;
  120129. /**
  120130. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  120131. */
  120132. tangents: Nullable<FloatArray>;
  120133. /**
  120134. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  120135. */
  120136. uvs: Nullable<FloatArray>;
  120137. /**
  120138. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  120139. */
  120140. uvs2: Nullable<FloatArray>;
  120141. /**
  120142. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  120143. */
  120144. uvs3: Nullable<FloatArray>;
  120145. /**
  120146. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  120147. */
  120148. uvs4: Nullable<FloatArray>;
  120149. /**
  120150. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  120151. */
  120152. uvs5: Nullable<FloatArray>;
  120153. /**
  120154. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  120155. */
  120156. uvs6: Nullable<FloatArray>;
  120157. /**
  120158. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  120159. */
  120160. colors: Nullable<FloatArray>;
  120161. /**
  120162. * 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).
  120163. */
  120164. matricesIndices: Nullable<FloatArray>;
  120165. /**
  120166. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  120167. */
  120168. matricesWeights: Nullable<FloatArray>;
  120169. /**
  120170. * An array extending the number of possible indices
  120171. */
  120172. matricesIndicesExtra: Nullable<FloatArray>;
  120173. /**
  120174. * An array extending the number of possible weights when the number of indices is extended
  120175. */
  120176. matricesWeightsExtra: Nullable<FloatArray>;
  120177. /**
  120178. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  120179. */
  120180. indices: Nullable<IndicesArray>;
  120181. /**
  120182. * Uses the passed data array to set the set the values for the specified kind of data
  120183. * @param data a linear array of floating numbers
  120184. * @param kind the type of data that is being set, eg positions, colors etc
  120185. */
  120186. set(data: FloatArray, kind: string): void;
  120187. /**
  120188. * Associates the vertexData to the passed Mesh.
  120189. * Sets it as updatable or not (default `false`)
  120190. * @param mesh the mesh the vertexData is applied to
  120191. * @param updatable when used and having the value true allows new data to update the vertexData
  120192. * @returns the VertexData
  120193. */
  120194. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  120195. /**
  120196. * Associates the vertexData to the passed Geometry.
  120197. * Sets it as updatable or not (default `false`)
  120198. * @param geometry the geometry the vertexData is applied to
  120199. * @param updatable when used and having the value true allows new data to update the vertexData
  120200. * @returns VertexData
  120201. */
  120202. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  120203. /**
  120204. * Updates the associated mesh
  120205. * @param mesh the mesh to be updated
  120206. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  120207. * @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
  120208. * @returns VertexData
  120209. */
  120210. updateMesh(mesh: Mesh): VertexData;
  120211. /**
  120212. * Updates the associated geometry
  120213. * @param geometry the geometry to be updated
  120214. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  120215. * @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
  120216. * @returns VertexData.
  120217. */
  120218. updateGeometry(geometry: Geometry): VertexData;
  120219. private _applyTo;
  120220. private _update;
  120221. /**
  120222. * Transforms each position and each normal of the vertexData according to the passed Matrix
  120223. * @param matrix the transforming matrix
  120224. * @returns the VertexData
  120225. */
  120226. transform(matrix: Matrix): VertexData;
  120227. /**
  120228. * Merges the passed VertexData into the current one
  120229. * @param other the VertexData to be merged into the current one
  120230. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  120231. * @returns the modified VertexData
  120232. */
  120233. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  120234. private _mergeElement;
  120235. private _validate;
  120236. /**
  120237. * Serializes the VertexData
  120238. * @returns a serialized object
  120239. */
  120240. serialize(): any;
  120241. /**
  120242. * Extracts the vertexData from a mesh
  120243. * @param mesh the mesh from which to extract the VertexData
  120244. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  120245. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  120246. * @returns the object VertexData associated to the passed mesh
  120247. */
  120248. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  120249. /**
  120250. * Extracts the vertexData from the geometry
  120251. * @param geometry the geometry from which to extract the VertexData
  120252. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  120253. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  120254. * @returns the object VertexData associated to the passed mesh
  120255. */
  120256. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  120257. private static _ExtractFrom;
  120258. /**
  120259. * Creates the VertexData for a Ribbon
  120260. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  120261. * * pathArray array of paths, each of which an array of successive Vector3
  120262. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  120263. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  120264. * * 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
  120265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120266. * * 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)
  120267. * * 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)
  120268. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  120269. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  120270. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  120271. * @returns the VertexData of the ribbon
  120272. */
  120273. static CreateRibbon(options: {
  120274. pathArray: Vector3[][];
  120275. closeArray?: boolean;
  120276. closePath?: boolean;
  120277. offset?: number;
  120278. sideOrientation?: number;
  120279. frontUVs?: Vector4;
  120280. backUVs?: Vector4;
  120281. invertUV?: boolean;
  120282. uvs?: Vector2[];
  120283. colors?: Color4[];
  120284. }): VertexData;
  120285. /**
  120286. * Creates the VertexData for a box
  120287. * @param options an object used to set the following optional parameters for the box, required but can be empty
  120288. * * size sets the width, height and depth of the box to the value of size, optional default 1
  120289. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  120290. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  120291. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  120292. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  120293. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  120294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120295. * * 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)
  120296. * * 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)
  120297. * @returns the VertexData of the box
  120298. */
  120299. static CreateBox(options: {
  120300. size?: number;
  120301. width?: number;
  120302. height?: number;
  120303. depth?: number;
  120304. faceUV?: Vector4[];
  120305. faceColors?: Color4[];
  120306. sideOrientation?: number;
  120307. frontUVs?: Vector4;
  120308. backUVs?: Vector4;
  120309. }): VertexData;
  120310. /**
  120311. * Creates the VertexData for a tiled box
  120312. * @param options an object used to set the following optional parameters for the box, required but can be empty
  120313. * * faceTiles sets the pattern, tile size and number of tiles for a face
  120314. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  120315. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  120316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120317. * @returns the VertexData of the box
  120318. */
  120319. static CreateTiledBox(options: {
  120320. pattern?: number;
  120321. width?: number;
  120322. height?: number;
  120323. depth?: number;
  120324. tileSize?: number;
  120325. tileWidth?: number;
  120326. tileHeight?: number;
  120327. alignHorizontal?: number;
  120328. alignVertical?: number;
  120329. faceUV?: Vector4[];
  120330. faceColors?: Color4[];
  120331. sideOrientation?: number;
  120332. }): VertexData;
  120333. /**
  120334. * Creates the VertexData for a tiled plane
  120335. * @param options an object used to set the following optional parameters for the box, required but can be empty
  120336. * * pattern a limited pattern arrangement depending on the number
  120337. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  120338. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  120339. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  120340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120341. * * 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)
  120342. * * 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)
  120343. * @returns the VertexData of the tiled plane
  120344. */
  120345. static CreateTiledPlane(options: {
  120346. pattern?: number;
  120347. tileSize?: number;
  120348. tileWidth?: number;
  120349. tileHeight?: number;
  120350. size?: number;
  120351. width?: number;
  120352. height?: number;
  120353. alignHorizontal?: number;
  120354. alignVertical?: number;
  120355. sideOrientation?: number;
  120356. frontUVs?: Vector4;
  120357. backUVs?: Vector4;
  120358. }): VertexData;
  120359. /**
  120360. * Creates the VertexData for an ellipsoid, defaults to a sphere
  120361. * @param options an object used to set the following optional parameters for the box, required but can be empty
  120362. * * segments sets the number of horizontal strips optional, default 32
  120363. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  120364. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  120365. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  120366. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  120367. * * 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
  120368. * * 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
  120369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120370. * * 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)
  120371. * * 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)
  120372. * @returns the VertexData of the ellipsoid
  120373. */
  120374. static CreateSphere(options: {
  120375. segments?: number;
  120376. diameter?: number;
  120377. diameterX?: number;
  120378. diameterY?: number;
  120379. diameterZ?: number;
  120380. arc?: number;
  120381. slice?: number;
  120382. sideOrientation?: number;
  120383. frontUVs?: Vector4;
  120384. backUVs?: Vector4;
  120385. }): VertexData;
  120386. /**
  120387. * Creates the VertexData for a cylinder, cone or prism
  120388. * @param options an object used to set the following optional parameters for the box, required but can be empty
  120389. * * height sets the height (y direction) of the cylinder, optional, default 2
  120390. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  120391. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  120392. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  120393. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  120394. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  120395. * * 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
  120396. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  120397. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  120398. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  120399. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  120400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120401. * * 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)
  120402. * * 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)
  120403. * @returns the VertexData of the cylinder, cone or prism
  120404. */
  120405. static CreateCylinder(options: {
  120406. height?: number;
  120407. diameterTop?: number;
  120408. diameterBottom?: number;
  120409. diameter?: number;
  120410. tessellation?: number;
  120411. subdivisions?: number;
  120412. arc?: number;
  120413. faceColors?: Color4[];
  120414. faceUV?: Vector4[];
  120415. hasRings?: boolean;
  120416. enclose?: boolean;
  120417. sideOrientation?: number;
  120418. frontUVs?: Vector4;
  120419. backUVs?: Vector4;
  120420. }): VertexData;
  120421. /**
  120422. * Creates the VertexData for a torus
  120423. * @param options an object used to set the following optional parameters for the box, required but can be empty
  120424. * * diameter the diameter of the torus, optional default 1
  120425. * * thickness the diameter of the tube forming the torus, optional default 0.5
  120426. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  120427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120428. * * 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)
  120429. * * 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)
  120430. * @returns the VertexData of the torus
  120431. */
  120432. static CreateTorus(options: {
  120433. diameter?: number;
  120434. thickness?: number;
  120435. tessellation?: number;
  120436. sideOrientation?: number;
  120437. frontUVs?: Vector4;
  120438. backUVs?: Vector4;
  120439. }): VertexData;
  120440. /**
  120441. * Creates the VertexData of the LineSystem
  120442. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  120443. * - lines an array of lines, each line being an array of successive Vector3
  120444. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  120445. * @returns the VertexData of the LineSystem
  120446. */
  120447. static CreateLineSystem(options: {
  120448. lines: Vector3[][];
  120449. colors?: Nullable<Color4[][]>;
  120450. }): VertexData;
  120451. /**
  120452. * Create the VertexData for a DashedLines
  120453. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  120454. * - points an array successive Vector3
  120455. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  120456. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  120457. * - dashNb the intended total number of dashes, optional, default 200
  120458. * @returns the VertexData for the DashedLines
  120459. */
  120460. static CreateDashedLines(options: {
  120461. points: Vector3[];
  120462. dashSize?: number;
  120463. gapSize?: number;
  120464. dashNb?: number;
  120465. }): VertexData;
  120466. /**
  120467. * Creates the VertexData for a Ground
  120468. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  120469. * - width the width (x direction) of the ground, optional, default 1
  120470. * - height the height (z direction) of the ground, optional, default 1
  120471. * - subdivisions the number of subdivisions per side, optional, default 1
  120472. * @returns the VertexData of the Ground
  120473. */
  120474. static CreateGround(options: {
  120475. width?: number;
  120476. height?: number;
  120477. subdivisions?: number;
  120478. subdivisionsX?: number;
  120479. subdivisionsY?: number;
  120480. }): VertexData;
  120481. /**
  120482. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  120483. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  120484. * * xmin the ground minimum X coordinate, optional, default -1
  120485. * * zmin the ground minimum Z coordinate, optional, default -1
  120486. * * xmax the ground maximum X coordinate, optional, default 1
  120487. * * zmax the ground maximum Z coordinate, optional, default 1
  120488. * * 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}
  120489. * * 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}
  120490. * @returns the VertexData of the TiledGround
  120491. */
  120492. static CreateTiledGround(options: {
  120493. xmin: number;
  120494. zmin: number;
  120495. xmax: number;
  120496. zmax: number;
  120497. subdivisions?: {
  120498. w: number;
  120499. h: number;
  120500. };
  120501. precision?: {
  120502. w: number;
  120503. h: number;
  120504. };
  120505. }): VertexData;
  120506. /**
  120507. * Creates the VertexData of the Ground designed from a heightmap
  120508. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  120509. * * width the width (x direction) of the ground
  120510. * * height the height (z direction) of the ground
  120511. * * subdivisions the number of subdivisions per side
  120512. * * minHeight the minimum altitude on the ground, optional, default 0
  120513. * * maxHeight the maximum altitude on the ground, optional default 1
  120514. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  120515. * * buffer the array holding the image color data
  120516. * * bufferWidth the width of image
  120517. * * bufferHeight the height of image
  120518. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  120519. * @returns the VertexData of the Ground designed from a heightmap
  120520. */
  120521. static CreateGroundFromHeightMap(options: {
  120522. width: number;
  120523. height: number;
  120524. subdivisions: number;
  120525. minHeight: number;
  120526. maxHeight: number;
  120527. colorFilter: Color3;
  120528. buffer: Uint8Array;
  120529. bufferWidth: number;
  120530. bufferHeight: number;
  120531. alphaFilter: number;
  120532. }): VertexData;
  120533. /**
  120534. * Creates the VertexData for a Plane
  120535. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  120536. * * size sets the width and height of the plane to the value of size, optional default 1
  120537. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  120538. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  120539. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120540. * * 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)
  120541. * * 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)
  120542. * @returns the VertexData of the box
  120543. */
  120544. static CreatePlane(options: {
  120545. size?: number;
  120546. width?: number;
  120547. height?: number;
  120548. sideOrientation?: number;
  120549. frontUVs?: Vector4;
  120550. backUVs?: Vector4;
  120551. }): VertexData;
  120552. /**
  120553. * Creates the VertexData of the Disc or regular Polygon
  120554. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  120555. * * radius the radius of the disc, optional default 0.5
  120556. * * tessellation the number of polygon sides, optional, default 64
  120557. * * 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
  120558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120559. * * 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)
  120560. * * 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)
  120561. * @returns the VertexData of the box
  120562. */
  120563. static CreateDisc(options: {
  120564. radius?: number;
  120565. tessellation?: number;
  120566. arc?: number;
  120567. sideOrientation?: number;
  120568. frontUVs?: Vector4;
  120569. backUVs?: Vector4;
  120570. }): VertexData;
  120571. /**
  120572. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  120573. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  120574. * @param polygon a mesh built from polygonTriangulation.build()
  120575. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120576. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  120577. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  120578. * @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)
  120579. * @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)
  120580. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  120581. * @returns the VertexData of the Polygon
  120582. */
  120583. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  120584. /**
  120585. * Creates the VertexData of the IcoSphere
  120586. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  120587. * * radius the radius of the IcoSphere, optional default 1
  120588. * * radiusX allows stretching in the x direction, optional, default radius
  120589. * * radiusY allows stretching in the y direction, optional, default radius
  120590. * * radiusZ allows stretching in the z direction, optional, default radius
  120591. * * flat when true creates a flat shaded mesh, optional, default true
  120592. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  120593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120594. * * 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)
  120595. * * 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)
  120596. * @returns the VertexData of the IcoSphere
  120597. */
  120598. static CreateIcoSphere(options: {
  120599. radius?: number;
  120600. radiusX?: number;
  120601. radiusY?: number;
  120602. radiusZ?: number;
  120603. flat?: boolean;
  120604. subdivisions?: number;
  120605. sideOrientation?: number;
  120606. frontUVs?: Vector4;
  120607. backUVs?: Vector4;
  120608. }): VertexData;
  120609. /**
  120610. * Creates the VertexData for a Polyhedron
  120611. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  120612. * * type provided types are:
  120613. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  120614. * * 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)
  120615. * * size the size of the IcoSphere, optional default 1
  120616. * * sizeX allows stretching in the x direction, optional, default size
  120617. * * sizeY allows stretching in the y direction, optional, default size
  120618. * * sizeZ allows stretching in the z direction, optional, default size
  120619. * * 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
  120620. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  120621. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  120622. * * flat when true creates a flat shaded mesh, optional, default true
  120623. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  120624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120625. * * 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)
  120626. * * 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)
  120627. * @returns the VertexData of the Polyhedron
  120628. */
  120629. static CreatePolyhedron(options: {
  120630. type?: number;
  120631. size?: number;
  120632. sizeX?: number;
  120633. sizeY?: number;
  120634. sizeZ?: number;
  120635. custom?: any;
  120636. faceUV?: Vector4[];
  120637. faceColors?: Color4[];
  120638. flat?: boolean;
  120639. sideOrientation?: number;
  120640. frontUVs?: Vector4;
  120641. backUVs?: Vector4;
  120642. }): VertexData;
  120643. /**
  120644. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  120645. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  120646. * @returns the VertexData of the Capsule
  120647. */
  120648. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  120649. /**
  120650. * Creates the VertexData for a TorusKnot
  120651. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  120652. * * radius the radius of the torus knot, optional, default 2
  120653. * * tube the thickness of the tube, optional, default 0.5
  120654. * * radialSegments the number of sides on each tube segments, optional, default 32
  120655. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  120656. * * p the number of windings around the z axis, optional, default 2
  120657. * * q the number of windings around the x axis, optional, default 3
  120658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120659. * * 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)
  120660. * * 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)
  120661. * @returns the VertexData of the Torus Knot
  120662. */
  120663. static CreateTorusKnot(options: {
  120664. radius?: number;
  120665. tube?: number;
  120666. radialSegments?: number;
  120667. tubularSegments?: number;
  120668. p?: number;
  120669. q?: number;
  120670. sideOrientation?: number;
  120671. frontUVs?: Vector4;
  120672. backUVs?: Vector4;
  120673. }): VertexData;
  120674. /**
  120675. * Compute normals for given positions and indices
  120676. * @param positions an array of vertex positions, [...., x, y, z, ......]
  120677. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  120678. * @param normals an array of vertex normals, [...., x, y, z, ......]
  120679. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  120680. * * facetNormals : optional array of facet normals (vector3)
  120681. * * facetPositions : optional array of facet positions (vector3)
  120682. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  120683. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  120684. * * bInfo : optional bounding info, required for facetPartitioning computation
  120685. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  120686. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  120687. * * useRightHandedSystem: optional boolean to for right handed system computation
  120688. * * depthSort : optional boolean to enable the facet depth sort computation
  120689. * * distanceTo : optional Vector3 to compute the facet depth from this location
  120690. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  120691. */
  120692. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  120693. facetNormals?: any;
  120694. facetPositions?: any;
  120695. facetPartitioning?: any;
  120696. ratio?: number;
  120697. bInfo?: any;
  120698. bbSize?: Vector3;
  120699. subDiv?: any;
  120700. useRightHandedSystem?: boolean;
  120701. depthSort?: boolean;
  120702. distanceTo?: Vector3;
  120703. depthSortedFacets?: any;
  120704. }): void;
  120705. /** @hidden */
  120706. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  120707. /**
  120708. * Applies VertexData created from the imported parameters to the geometry
  120709. * @param parsedVertexData the parsed data from an imported file
  120710. * @param geometry the geometry to apply the VertexData to
  120711. */
  120712. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  120713. }
  120714. }
  120715. declare module BABYLON {
  120716. /**
  120717. * Class containing static functions to help procedurally build meshes
  120718. */
  120719. export class DiscBuilder {
  120720. /**
  120721. * Creates a plane polygonal mesh. By default, this is a disc
  120722. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  120723. * * 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
  120724. * * 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
  120725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120728. * @param name defines the name of the mesh
  120729. * @param options defines the options used to create the mesh
  120730. * @param scene defines the hosting scene
  120731. * @returns the plane polygonal mesh
  120732. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  120733. */
  120734. static CreateDisc(name: string, options: {
  120735. radius?: number;
  120736. tessellation?: number;
  120737. arc?: number;
  120738. updatable?: boolean;
  120739. sideOrientation?: number;
  120740. frontUVs?: Vector4;
  120741. backUVs?: Vector4;
  120742. }, scene?: Nullable<Scene>): Mesh;
  120743. }
  120744. }
  120745. declare module BABYLON {
  120746. /**
  120747. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  120748. *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.
  120749. * The SPS is also a particle system. It provides some methods to manage the particles.
  120750. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  120751. *
  120752. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  120753. */
  120754. export class SolidParticleSystem implements IDisposable {
  120755. /**
  120756. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  120757. * Example : var p = SPS.particles[i];
  120758. */
  120759. particles: SolidParticle[];
  120760. /**
  120761. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  120762. */
  120763. nbParticles: number;
  120764. /**
  120765. * If the particles must ever face the camera (default false). Useful for planar particles.
  120766. */
  120767. billboard: boolean;
  120768. /**
  120769. * Recompute normals when adding a shape
  120770. */
  120771. recomputeNormals: boolean;
  120772. /**
  120773. * This a counter ofr your own usage. It's not set by any SPS functions.
  120774. */
  120775. counter: number;
  120776. /**
  120777. * The SPS name. This name is also given to the underlying mesh.
  120778. */
  120779. name: string;
  120780. /**
  120781. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  120782. */
  120783. mesh: Mesh;
  120784. /**
  120785. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  120786. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  120787. */
  120788. vars: any;
  120789. /**
  120790. * This array is populated when the SPS is set as 'pickable'.
  120791. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  120792. * Each element of this array is an object `{idx: int, faceId: int}`.
  120793. * `idx` is the picked particle index in the `SPS.particles` array
  120794. * `faceId` is the picked face index counted within this particle.
  120795. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  120796. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  120797. * Use the method SPS.pickedParticle(pickingInfo) instead.
  120798. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  120799. */
  120800. pickedParticles: {
  120801. idx: number;
  120802. faceId: number;
  120803. }[];
  120804. /**
  120805. * This array is populated when the SPS is set as 'pickable'
  120806. * Each key of this array is a submesh index.
  120807. * Each element of this array is a second array defined like this :
  120808. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  120809. * Each element of this second array is an object `{idx: int, faceId: int}`.
  120810. * `idx` is the picked particle index in the `SPS.particles` array
  120811. * `faceId` is the picked face index counted within this particle.
  120812. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  120813. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  120814. */
  120815. pickedBySubMesh: {
  120816. idx: number;
  120817. faceId: number;
  120818. }[][];
  120819. /**
  120820. * This array is populated when `enableDepthSort` is set to true.
  120821. * Each element of this array is an instance of the class DepthSortedParticle.
  120822. */
  120823. depthSortedParticles: DepthSortedParticle[];
  120824. /**
  120825. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  120826. * @hidden
  120827. */
  120828. _bSphereOnly: boolean;
  120829. /**
  120830. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  120831. * @hidden
  120832. */
  120833. _bSphereRadiusFactor: number;
  120834. private _scene;
  120835. private _positions;
  120836. private _indices;
  120837. private _normals;
  120838. private _colors;
  120839. private _uvs;
  120840. private _indices32;
  120841. private _positions32;
  120842. private _normals32;
  120843. private _fixedNormal32;
  120844. private _colors32;
  120845. private _uvs32;
  120846. private _index;
  120847. private _updatable;
  120848. private _pickable;
  120849. private _isVisibilityBoxLocked;
  120850. private _alwaysVisible;
  120851. private _depthSort;
  120852. private _expandable;
  120853. private _shapeCounter;
  120854. private _copy;
  120855. private _color;
  120856. private _computeParticleColor;
  120857. private _computeParticleTexture;
  120858. private _computeParticleRotation;
  120859. private _computeParticleVertex;
  120860. private _computeBoundingBox;
  120861. private _depthSortParticles;
  120862. private _camera;
  120863. private _mustUnrotateFixedNormals;
  120864. private _particlesIntersect;
  120865. private _needs32Bits;
  120866. private _isNotBuilt;
  120867. private _lastParticleId;
  120868. private _idxOfId;
  120869. private _multimaterialEnabled;
  120870. private _useModelMaterial;
  120871. private _indicesByMaterial;
  120872. private _materialIndexes;
  120873. private _depthSortFunction;
  120874. private _materialSortFunction;
  120875. private _materials;
  120876. private _multimaterial;
  120877. private _materialIndexesById;
  120878. private _defaultMaterial;
  120879. private _autoUpdateSubMeshes;
  120880. private _tmpVertex;
  120881. /**
  120882. * Creates a SPS (Solid Particle System) object.
  120883. * @param name (String) is the SPS name, this will be the underlying mesh name.
  120884. * @param scene (Scene) is the scene in which the SPS is added.
  120885. * @param options defines the options of the sps e.g.
  120886. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  120887. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  120888. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  120889. * * useModelMaterial (optional boolean, default false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  120890. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  120891. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  120892. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  120893. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  120894. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  120895. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  120896. */
  120897. constructor(name: string, scene: Scene, options?: {
  120898. updatable?: boolean;
  120899. isPickable?: boolean;
  120900. enableDepthSort?: boolean;
  120901. particleIntersection?: boolean;
  120902. boundingSphereOnly?: boolean;
  120903. bSphereRadiusFactor?: number;
  120904. expandable?: boolean;
  120905. useModelMaterial?: boolean;
  120906. enableMultiMaterial?: boolean;
  120907. });
  120908. /**
  120909. * Builds the SPS underlying mesh. Returns a standard Mesh.
  120910. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  120911. * @returns the created mesh
  120912. */
  120913. buildMesh(): Mesh;
  120914. /**
  120915. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  120916. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  120917. * Thus the particles generated from `digest()` have their property `position` set yet.
  120918. * @param mesh ( Mesh ) is the mesh to be digested
  120919. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overridden by the parameter `number` if any
  120920. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  120921. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  120922. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  120923. * @returns the current SPS
  120924. */
  120925. digest(mesh: Mesh, options?: {
  120926. facetNb?: number;
  120927. number?: number;
  120928. delta?: number;
  120929. storage?: [];
  120930. }): SolidParticleSystem;
  120931. /**
  120932. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  120933. * @hidden
  120934. */
  120935. private _unrotateFixedNormals;
  120936. /**
  120937. * Resets the temporary working copy particle
  120938. * @hidden
  120939. */
  120940. private _resetCopy;
  120941. /**
  120942. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  120943. * @param p the current index in the positions array to be updated
  120944. * @param ind the current index in the indices array
  120945. * @param shape a Vector3 array, the shape geometry
  120946. * @param positions the positions array to be updated
  120947. * @param meshInd the shape indices array
  120948. * @param indices the indices array to be updated
  120949. * @param meshUV the shape uv array
  120950. * @param uvs the uv array to be updated
  120951. * @param meshCol the shape color array
  120952. * @param colors the color array to be updated
  120953. * @param meshNor the shape normals array
  120954. * @param normals the normals array to be updated
  120955. * @param idx the particle index
  120956. * @param idxInShape the particle index in its shape
  120957. * @param options the addShape() method passed options
  120958. * @model the particle model
  120959. * @hidden
  120960. */
  120961. private _meshBuilder;
  120962. /**
  120963. * Returns a shape Vector3 array from positions float array
  120964. * @param positions float array
  120965. * @returns a vector3 array
  120966. * @hidden
  120967. */
  120968. private _posToShape;
  120969. /**
  120970. * Returns a shapeUV array from a float uvs (array deep copy)
  120971. * @param uvs as a float array
  120972. * @returns a shapeUV array
  120973. * @hidden
  120974. */
  120975. private _uvsToShapeUV;
  120976. /**
  120977. * Adds a new particle object in the particles array
  120978. * @param idx particle index in particles array
  120979. * @param id particle id
  120980. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  120981. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  120982. * @param model particle ModelShape object
  120983. * @param shapeId model shape identifier
  120984. * @param idxInShape index of the particle in the current model
  120985. * @param bInfo model bounding info object
  120986. * @param storage target storage array, if any
  120987. * @hidden
  120988. */
  120989. private _addParticle;
  120990. /**
  120991. * Adds some particles to the SPS from the model shape. Returns the shape id.
  120992. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  120993. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  120994. * @param nb (positive integer) the number of particles to be created from this model
  120995. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  120996. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  120997. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  120998. * @returns the number of shapes in the system
  120999. */
  121000. addShape(mesh: Mesh, nb: number, options?: {
  121001. positionFunction?: any;
  121002. vertexFunction?: any;
  121003. storage?: [];
  121004. }): number;
  121005. /**
  121006. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  121007. * @hidden
  121008. */
  121009. private _rebuildParticle;
  121010. /**
  121011. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  121012. * @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.
  121013. * @returns the SPS.
  121014. */
  121015. rebuildMesh(reset?: boolean): SolidParticleSystem;
  121016. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  121017. * Returns an array with the removed particles.
  121018. * 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.
  121019. * The SPS can't be empty so at least one particle needs to remain in place.
  121020. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  121021. * @param start index of the first particle to remove
  121022. * @param end index of the last particle to remove (included)
  121023. * @returns an array populated with the removed particles
  121024. */
  121025. removeParticles(start: number, end: number): SolidParticle[];
  121026. /**
  121027. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  121028. * @param solidParticleArray an array populated with Solid Particles objects
  121029. * @returns the SPS
  121030. */
  121031. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  121032. /**
  121033. * Creates a new particle and modifies the SPS mesh geometry :
  121034. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  121035. * - calls _addParticle() to populate the particle array
  121036. * factorized code from addShape() and insertParticlesFromArray()
  121037. * @param idx particle index in the particles array
  121038. * @param i particle index in its shape
  121039. * @param modelShape particle ModelShape object
  121040. * @param shape shape vertex array
  121041. * @param meshInd shape indices array
  121042. * @param meshUV shape uv array
  121043. * @param meshCol shape color array
  121044. * @param meshNor shape normals array
  121045. * @param bbInfo shape bounding info
  121046. * @param storage target particle storage
  121047. * @options addShape() passed options
  121048. * @hidden
  121049. */
  121050. private _insertNewParticle;
  121051. /**
  121052. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  121053. * This method calls `updateParticle()` for each particle of the SPS.
  121054. * For an animated SPS, it is usually called within the render loop.
  121055. * 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.
  121056. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  121057. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  121058. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  121059. * @returns the SPS.
  121060. */
  121061. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  121062. /**
  121063. * Disposes the SPS.
  121064. */
  121065. dispose(): void;
  121066. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  121067. * idx is the particle index in the SPS
  121068. * faceId is the picked face index counted within this particle.
  121069. * Returns null if the pickInfo can't identify a picked particle.
  121070. * @param pickingInfo (PickingInfo object)
  121071. * @returns {idx: number, faceId: number} or null
  121072. */
  121073. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  121074. idx: number;
  121075. faceId: number;
  121076. }>;
  121077. /**
  121078. * Returns a SolidParticle object from its identifier : particle.id
  121079. * @param id (integer) the particle Id
  121080. * @returns the searched particle or null if not found in the SPS.
  121081. */
  121082. getParticleById(id: number): Nullable<SolidParticle>;
  121083. /**
  121084. * Returns a new array populated with the particles having the passed shapeId.
  121085. * @param shapeId (integer) the shape identifier
  121086. * @returns a new solid particle array
  121087. */
  121088. getParticlesByShapeId(shapeId: number): SolidParticle[];
  121089. /**
  121090. * Populates the passed array "ref" with the particles having the passed shapeId.
  121091. * @param shapeId the shape identifier
  121092. * @returns the SPS
  121093. * @param ref
  121094. */
  121095. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  121096. /**
  121097. * Computes the required SubMeshes according the materials assigned to the particles.
  121098. * @returns the solid particle system.
  121099. * Does nothing if called before the SPS mesh is built.
  121100. */
  121101. computeSubMeshes(): SolidParticleSystem;
  121102. /**
  121103. * Sorts the solid particles by material when MultiMaterial is enabled.
  121104. * Updates the indices32 array.
  121105. * Updates the indicesByMaterial array.
  121106. * Updates the mesh indices array.
  121107. * @returns the SPS
  121108. * @hidden
  121109. */
  121110. private _sortParticlesByMaterial;
  121111. /**
  121112. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  121113. * @hidden
  121114. */
  121115. private _setMaterialIndexesById;
  121116. /**
  121117. * Returns an array with unique values of Materials from the passed array
  121118. * @param array the material array to be checked and filtered
  121119. * @hidden
  121120. */
  121121. private _filterUniqueMaterialId;
  121122. /**
  121123. * Sets a new Standard Material as _defaultMaterial if not already set.
  121124. * @hidden
  121125. */
  121126. private _setDefaultMaterial;
  121127. /**
  121128. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  121129. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  121130. * @returns the SPS.
  121131. */
  121132. refreshVisibleSize(): SolidParticleSystem;
  121133. /**
  121134. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  121135. * @param size the size (float) of the visibility box
  121136. * note : this doesn't lock the SPS mesh bounding box.
  121137. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  121138. */
  121139. setVisibilityBox(size: number): void;
  121140. /**
  121141. * Gets whether the SPS as always visible or not
  121142. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  121143. */
  121144. get isAlwaysVisible(): boolean;
  121145. /**
  121146. * Sets the SPS as always visible or not
  121147. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  121148. */
  121149. set isAlwaysVisible(val: boolean);
  121150. /**
  121151. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  121152. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  121153. */
  121154. set isVisibilityBoxLocked(val: boolean);
  121155. /**
  121156. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  121157. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  121158. */
  121159. get isVisibilityBoxLocked(): boolean;
  121160. /**
  121161. * Tells to `setParticles()` to compute the particle rotations or not.
  121162. * Default value : true. The SPS is faster when it's set to false.
  121163. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  121164. */
  121165. set computeParticleRotation(val: boolean);
  121166. /**
  121167. * Tells to `setParticles()` to compute the particle colors or not.
  121168. * Default value : true. The SPS is faster when it's set to false.
  121169. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  121170. */
  121171. set computeParticleColor(val: boolean);
  121172. set computeParticleTexture(val: boolean);
  121173. /**
  121174. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  121175. * Default value : false. The SPS is faster when it's set to false.
  121176. * Note : the particle custom vertex positions aren't stored values.
  121177. */
  121178. set computeParticleVertex(val: boolean);
  121179. /**
  121180. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  121181. */
  121182. set computeBoundingBox(val: boolean);
  121183. /**
  121184. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  121185. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  121186. * Default : `true`
  121187. */
  121188. set depthSortParticles(val: boolean);
  121189. /**
  121190. * Gets if `setParticles()` computes the particle rotations or not.
  121191. * Default value : true. The SPS is faster when it's set to false.
  121192. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  121193. */
  121194. get computeParticleRotation(): boolean;
  121195. /**
  121196. * Gets if `setParticles()` computes the particle colors or not.
  121197. * Default value : true. The SPS is faster when it's set to false.
  121198. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  121199. */
  121200. get computeParticleColor(): boolean;
  121201. /**
  121202. * Gets if `setParticles()` computes the particle textures or not.
  121203. * Default value : true. The SPS is faster when it's set to false.
  121204. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  121205. */
  121206. get computeParticleTexture(): boolean;
  121207. /**
  121208. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  121209. * Default value : false. The SPS is faster when it's set to false.
  121210. * Note : the particle custom vertex positions aren't stored values.
  121211. */
  121212. get computeParticleVertex(): boolean;
  121213. /**
  121214. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  121215. */
  121216. get computeBoundingBox(): boolean;
  121217. /**
  121218. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  121219. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  121220. * Default : `true`
  121221. */
  121222. get depthSortParticles(): boolean;
  121223. /**
  121224. * Gets if the SPS is created as expandable at construction time.
  121225. * Default : `false`
  121226. */
  121227. get expandable(): boolean;
  121228. /**
  121229. * Gets if the SPS supports the Multi Materials
  121230. */
  121231. get multimaterialEnabled(): boolean;
  121232. /**
  121233. * Gets if the SPS uses the model materials for its own multimaterial.
  121234. */
  121235. get useModelMaterial(): boolean;
  121236. /**
  121237. * The SPS used material array.
  121238. */
  121239. get materials(): Material[];
  121240. /**
  121241. * Sets the SPS MultiMaterial from the passed materials.
  121242. * Note : the passed array is internally copied and not used then by reference.
  121243. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  121244. */
  121245. setMultiMaterial(materials: Material[]): void;
  121246. /**
  121247. * The SPS computed multimaterial object
  121248. */
  121249. get multimaterial(): MultiMaterial;
  121250. set multimaterial(mm: MultiMaterial);
  121251. /**
  121252. * If the subMeshes must be updated on the next call to setParticles()
  121253. */
  121254. get autoUpdateSubMeshes(): boolean;
  121255. set autoUpdateSubMeshes(val: boolean);
  121256. /**
  121257. * This function does nothing. It may be overwritten to set all the particle first values.
  121258. * The SPS doesn't call this function, you may have to call it by your own.
  121259. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  121260. */
  121261. initParticles(): void;
  121262. /**
  121263. * This function does nothing. It may be overwritten to recycle a particle.
  121264. * The SPS doesn't call this function, you may have to call it by your own.
  121265. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  121266. * @param particle The particle to recycle
  121267. * @returns the recycled particle
  121268. */
  121269. recycleParticle(particle: SolidParticle): SolidParticle;
  121270. /**
  121271. * Updates a particle : this function should be overwritten by the user.
  121272. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  121273. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  121274. * @example : just set a particle position or velocity and recycle conditions
  121275. * @param particle The particle to update
  121276. * @returns the updated particle
  121277. */
  121278. updateParticle(particle: SolidParticle): SolidParticle;
  121279. /**
  121280. * Updates a vertex of a particle : it can be overwritten by the user.
  121281. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  121282. * @param particle the current particle
  121283. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  121284. * @param pt the index of the current vertex in the particle shape
  121285. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  121286. * @example : just set a vertex particle position or color
  121287. * @returns the sps
  121288. */
  121289. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  121290. /**
  121291. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  121292. * This does nothing and may be overwritten by the user.
  121293. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  121294. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  121295. * @param update the boolean update value actually passed to setParticles()
  121296. */
  121297. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  121298. /**
  121299. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  121300. * This will be passed three parameters.
  121301. * This does nothing and may be overwritten by the user.
  121302. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  121303. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  121304. * @param update the boolean update value actually passed to setParticles()
  121305. */
  121306. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  121307. }
  121308. }
  121309. declare module BABYLON {
  121310. /**
  121311. * Represents one particle of a solid particle system.
  121312. */
  121313. export class SolidParticle {
  121314. /**
  121315. * particle global index
  121316. */
  121317. idx: number;
  121318. /**
  121319. * particle identifier
  121320. */
  121321. id: number;
  121322. /**
  121323. * The color of the particle
  121324. */
  121325. color: Nullable<Color4>;
  121326. /**
  121327. * The world space position of the particle.
  121328. */
  121329. position: Vector3;
  121330. /**
  121331. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  121332. */
  121333. rotation: Vector3;
  121334. /**
  121335. * The world space rotation quaternion of the particle.
  121336. */
  121337. rotationQuaternion: Nullable<Quaternion>;
  121338. /**
  121339. * The scaling of the particle.
  121340. */
  121341. scaling: Vector3;
  121342. /**
  121343. * The uvs of the particle.
  121344. */
  121345. uvs: Vector4;
  121346. /**
  121347. * The current speed of the particle.
  121348. */
  121349. velocity: Vector3;
  121350. /**
  121351. * The pivot point in the particle local space.
  121352. */
  121353. pivot: Vector3;
  121354. /**
  121355. * Must the particle be translated from its pivot point in its local space ?
  121356. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  121357. * Default : false
  121358. */
  121359. translateFromPivot: boolean;
  121360. /**
  121361. * Is the particle active or not ?
  121362. */
  121363. alive: boolean;
  121364. /**
  121365. * Is the particle visible or not ?
  121366. */
  121367. isVisible: boolean;
  121368. /**
  121369. * Index of this particle in the global "positions" array (Internal use)
  121370. * @hidden
  121371. */
  121372. _pos: number;
  121373. /**
  121374. * @hidden Index of this particle in the global "indices" array (Internal use)
  121375. */
  121376. _ind: number;
  121377. /**
  121378. * @hidden ModelShape of this particle (Internal use)
  121379. */
  121380. _model: ModelShape;
  121381. /**
  121382. * ModelShape id of this particle
  121383. */
  121384. shapeId: number;
  121385. /**
  121386. * Index of the particle in its shape id
  121387. */
  121388. idxInShape: number;
  121389. /**
  121390. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  121391. */
  121392. _modelBoundingInfo: BoundingInfo;
  121393. /**
  121394. * @hidden Particle BoundingInfo object (Internal use)
  121395. */
  121396. _boundingInfo: BoundingInfo;
  121397. /**
  121398. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  121399. */
  121400. _sps: SolidParticleSystem;
  121401. /**
  121402. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  121403. */
  121404. _stillInvisible: boolean;
  121405. /**
  121406. * @hidden Last computed particle rotation matrix
  121407. */
  121408. _rotationMatrix: number[];
  121409. /**
  121410. * Parent particle Id, if any.
  121411. * Default null.
  121412. */
  121413. parentId: Nullable<number>;
  121414. /**
  121415. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  121416. */
  121417. materialIndex: Nullable<number>;
  121418. /**
  121419. * Custom object or properties.
  121420. */
  121421. props: Nullable<any>;
  121422. /**
  121423. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  121424. * The possible values are :
  121425. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  121426. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  121427. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  121428. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  121429. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  121430. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  121431. * */
  121432. cullingStrategy: number;
  121433. /**
  121434. * @hidden Internal global position in the SPS.
  121435. */
  121436. _globalPosition: Vector3;
  121437. /**
  121438. * Creates a Solid Particle object.
  121439. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  121440. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  121441. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  121442. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  121443. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  121444. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  121445. * @param shapeId (integer) is the model shape identifier in the SPS.
  121446. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  121447. * @param sps defines the sps it is associated to
  121448. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  121449. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  121450. */
  121451. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  121452. /**
  121453. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  121454. * @param target the particle target
  121455. * @returns the current particle
  121456. */
  121457. copyToRef(target: SolidParticle): SolidParticle;
  121458. /**
  121459. * Legacy support, changed scale to scaling
  121460. */
  121461. get scale(): Vector3;
  121462. /**
  121463. * Legacy support, changed scale to scaling
  121464. */
  121465. set scale(scale: Vector3);
  121466. /**
  121467. * Legacy support, changed quaternion to rotationQuaternion
  121468. */
  121469. get quaternion(): Nullable<Quaternion>;
  121470. /**
  121471. * Legacy support, changed quaternion to rotationQuaternion
  121472. */
  121473. set quaternion(q: Nullable<Quaternion>);
  121474. /**
  121475. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  121476. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  121477. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  121478. * @returns true if it intersects
  121479. */
  121480. intersectsMesh(target: Mesh | SolidParticle): boolean;
  121481. /**
  121482. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  121483. * A particle is in the frustum if its bounding box intersects the frustum
  121484. * @param frustumPlanes defines the frustum to test
  121485. * @returns true if the particle is in the frustum planes
  121486. */
  121487. isInFrustum(frustumPlanes: Plane[]): boolean;
  121488. /**
  121489. * get the rotation matrix of the particle
  121490. * @hidden
  121491. */
  121492. getRotationMatrix(m: Matrix): void;
  121493. }
  121494. /**
  121495. * Represents the shape of the model used by one particle of a solid particle system.
  121496. * SPS internal tool, don't use it manually.
  121497. */
  121498. export class ModelShape {
  121499. /**
  121500. * The shape id
  121501. * @hidden
  121502. */
  121503. shapeID: number;
  121504. /**
  121505. * flat array of model positions (internal use)
  121506. * @hidden
  121507. */
  121508. _shape: Vector3[];
  121509. /**
  121510. * flat array of model UVs (internal use)
  121511. * @hidden
  121512. */
  121513. _shapeUV: number[];
  121514. /**
  121515. * color array of the model
  121516. * @hidden
  121517. */
  121518. _shapeColors: number[];
  121519. /**
  121520. * indices array of the model
  121521. * @hidden
  121522. */
  121523. _indices: number[];
  121524. /**
  121525. * normals array of the model
  121526. * @hidden
  121527. */
  121528. _normals: number[];
  121529. /**
  121530. * length of the shape in the model indices array (internal use)
  121531. * @hidden
  121532. */
  121533. _indicesLength: number;
  121534. /**
  121535. * Custom position function (internal use)
  121536. * @hidden
  121537. */
  121538. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  121539. /**
  121540. * Custom vertex function (internal use)
  121541. * @hidden
  121542. */
  121543. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  121544. /**
  121545. * Model material (internal use)
  121546. * @hidden
  121547. */
  121548. _material: Nullable<Material>;
  121549. /**
  121550. * 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.
  121551. * SPS internal tool, don't use it manually.
  121552. * @hidden
  121553. */
  121554. 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>);
  121555. }
  121556. /**
  121557. * Represents a Depth Sorted Particle in the solid particle system.
  121558. * @hidden
  121559. */
  121560. export class DepthSortedParticle {
  121561. /**
  121562. * Particle index
  121563. */
  121564. idx: number;
  121565. /**
  121566. * Index of the particle in the "indices" array
  121567. */
  121568. ind: number;
  121569. /**
  121570. * Length of the particle shape in the "indices" array
  121571. */
  121572. indicesLength: number;
  121573. /**
  121574. * Squared distance from the particle to the camera
  121575. */
  121576. sqDistance: number;
  121577. /**
  121578. * Material index when used with MultiMaterials
  121579. */
  121580. materialIndex: number;
  121581. /**
  121582. * Creates a new sorted particle
  121583. * @param materialIndex
  121584. */
  121585. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  121586. }
  121587. /**
  121588. * Represents a solid particle vertex
  121589. */
  121590. export class SolidParticleVertex {
  121591. /**
  121592. * Vertex position
  121593. */
  121594. position: Vector3;
  121595. /**
  121596. * Vertex color
  121597. */
  121598. color: Color4;
  121599. /**
  121600. * Vertex UV
  121601. */
  121602. uv: Vector2;
  121603. /**
  121604. * Creates a new solid particle vertex
  121605. */
  121606. constructor();
  121607. /** Vertex x coordinate */
  121608. get x(): number;
  121609. set x(val: number);
  121610. /** Vertex y coordinate */
  121611. get y(): number;
  121612. set y(val: number);
  121613. /** Vertex z coordinate */
  121614. get z(): number;
  121615. set z(val: number);
  121616. }
  121617. }
  121618. declare module BABYLON {
  121619. /**
  121620. * @hidden
  121621. */
  121622. export class _MeshCollisionData {
  121623. _checkCollisions: boolean;
  121624. _collisionMask: number;
  121625. _collisionGroup: number;
  121626. _surroundingMeshes: Nullable<AbstractMesh[]>;
  121627. _collider: Nullable<Collider>;
  121628. _oldPositionForCollisions: Vector3;
  121629. _diffPositionForCollisions: Vector3;
  121630. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  121631. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  121632. _collisionResponse: boolean;
  121633. }
  121634. }
  121635. declare module BABYLON {
  121636. /** @hidden */
  121637. class _FacetDataStorage {
  121638. facetPositions: Vector3[];
  121639. facetNormals: Vector3[];
  121640. facetPartitioning: number[][];
  121641. facetNb: number;
  121642. partitioningSubdivisions: number;
  121643. partitioningBBoxRatio: number;
  121644. facetDataEnabled: boolean;
  121645. facetParameters: any;
  121646. bbSize: Vector3;
  121647. subDiv: {
  121648. max: number;
  121649. X: number;
  121650. Y: number;
  121651. Z: number;
  121652. };
  121653. facetDepthSort: boolean;
  121654. facetDepthSortEnabled: boolean;
  121655. depthSortedIndices: IndicesArray;
  121656. depthSortedFacets: {
  121657. ind: number;
  121658. sqDistance: number;
  121659. }[];
  121660. facetDepthSortFunction: (f1: {
  121661. ind: number;
  121662. sqDistance: number;
  121663. }, f2: {
  121664. ind: number;
  121665. sqDistance: number;
  121666. }) => number;
  121667. facetDepthSortFrom: Vector3;
  121668. facetDepthSortOrigin: Vector3;
  121669. invertedMatrix: Matrix;
  121670. }
  121671. /**
  121672. * @hidden
  121673. **/
  121674. class _InternalAbstractMeshDataInfo {
  121675. _hasVertexAlpha: boolean;
  121676. _useVertexColors: boolean;
  121677. _numBoneInfluencers: number;
  121678. _applyFog: boolean;
  121679. _receiveShadows: boolean;
  121680. _facetData: _FacetDataStorage;
  121681. _visibility: number;
  121682. _skeleton: Nullable<Skeleton>;
  121683. _layerMask: number;
  121684. _computeBonesUsingShaders: boolean;
  121685. _isActive: boolean;
  121686. _onlyForInstances: boolean;
  121687. _isActiveIntermediate: boolean;
  121688. _onlyForInstancesIntermediate: boolean;
  121689. _actAsRegularMesh: boolean;
  121690. _currentLOD: Nullable<AbstractMesh>;
  121691. _currentLODIsUpToDate: boolean;
  121692. }
  121693. /**
  121694. * Class used to store all common mesh properties
  121695. */
  121696. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  121697. /** No occlusion */
  121698. static OCCLUSION_TYPE_NONE: number;
  121699. /** Occlusion set to optimistic */
  121700. static OCCLUSION_TYPE_OPTIMISTIC: number;
  121701. /** Occlusion set to strict */
  121702. static OCCLUSION_TYPE_STRICT: number;
  121703. /** Use an accurate occlusion algorithm */
  121704. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  121705. /** Use a conservative occlusion algorithm */
  121706. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  121707. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  121708. * Test order :
  121709. * Is the bounding sphere outside the frustum ?
  121710. * If not, are the bounding box vertices outside the frustum ?
  121711. * It not, then the cullable object is in the frustum.
  121712. */
  121713. static readonly CULLINGSTRATEGY_STANDARD: number;
  121714. /** Culling strategy : Bounding Sphere Only.
  121715. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  121716. * It's also less accurate than the standard because some not visible objects can still be selected.
  121717. * Test : is the bounding sphere outside the frustum ?
  121718. * If not, then the cullable object is in the frustum.
  121719. */
  121720. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  121721. /** Culling strategy : Optimistic Inclusion.
  121722. * This in an inclusion test first, then the standard exclusion test.
  121723. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  121724. * 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.
  121725. * Anyway, it's as accurate as the standard strategy.
  121726. * Test :
  121727. * Is the cullable object bounding sphere center in the frustum ?
  121728. * If not, apply the default culling strategy.
  121729. */
  121730. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  121731. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  121732. * This in an inclusion test first, then the bounding sphere only exclusion test.
  121733. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  121734. * 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.
  121735. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  121736. * Test :
  121737. * Is the cullable object bounding sphere center in the frustum ?
  121738. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  121739. */
  121740. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  121741. /**
  121742. * No billboard
  121743. */
  121744. static get BILLBOARDMODE_NONE(): number;
  121745. /** Billboard on X axis */
  121746. static get BILLBOARDMODE_X(): number;
  121747. /** Billboard on Y axis */
  121748. static get BILLBOARDMODE_Y(): number;
  121749. /** Billboard on Z axis */
  121750. static get BILLBOARDMODE_Z(): number;
  121751. /** Billboard on all axes */
  121752. static get BILLBOARDMODE_ALL(): number;
  121753. /** Billboard on using position instead of orientation */
  121754. static get BILLBOARDMODE_USE_POSITION(): number;
  121755. /** @hidden */
  121756. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  121757. /**
  121758. * The culling strategy to use to check whether the mesh must be rendered or not.
  121759. * This value can be changed at any time and will be used on the next render mesh selection.
  121760. * The possible values are :
  121761. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  121762. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  121763. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  121764. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  121765. * Please read each static variable documentation to get details about the culling process.
  121766. * */
  121767. cullingStrategy: number;
  121768. /**
  121769. * Gets the number of facets in the mesh
  121770. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  121771. */
  121772. get facetNb(): number;
  121773. /**
  121774. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  121775. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  121776. */
  121777. get partitioningSubdivisions(): number;
  121778. set partitioningSubdivisions(nb: number);
  121779. /**
  121780. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  121781. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  121782. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  121783. */
  121784. get partitioningBBoxRatio(): number;
  121785. set partitioningBBoxRatio(ratio: number);
  121786. /**
  121787. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  121788. * Works only for updatable meshes.
  121789. * Doesn't work with multi-materials
  121790. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  121791. */
  121792. get mustDepthSortFacets(): boolean;
  121793. set mustDepthSortFacets(sort: boolean);
  121794. /**
  121795. * The location (Vector3) where the facet depth sort must be computed from.
  121796. * By default, the active camera position.
  121797. * Used only when facet depth sort is enabled
  121798. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  121799. */
  121800. get facetDepthSortFrom(): Vector3;
  121801. set facetDepthSortFrom(location: Vector3);
  121802. /**
  121803. * gets a boolean indicating if facetData is enabled
  121804. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  121805. */
  121806. get isFacetDataEnabled(): boolean;
  121807. /** @hidden */
  121808. _updateNonUniformScalingState(value: boolean): boolean;
  121809. /**
  121810. * An event triggered when this mesh collides with another one
  121811. */
  121812. onCollideObservable: Observable<AbstractMesh>;
  121813. /** Set a function to call when this mesh collides with another one */
  121814. set onCollide(callback: () => void);
  121815. /**
  121816. * An event triggered when the collision's position changes
  121817. */
  121818. onCollisionPositionChangeObservable: Observable<Vector3>;
  121819. /** Set a function to call when the collision's position changes */
  121820. set onCollisionPositionChange(callback: () => void);
  121821. /**
  121822. * An event triggered when material is changed
  121823. */
  121824. onMaterialChangedObservable: Observable<AbstractMesh>;
  121825. /**
  121826. * Gets or sets the orientation for POV movement & rotation
  121827. */
  121828. definedFacingForward: boolean;
  121829. /** @hidden */
  121830. _occlusionQuery: Nullable<WebGLQuery>;
  121831. /** @hidden */
  121832. _renderingGroup: Nullable<RenderingGroup>;
  121833. /**
  121834. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  121835. */
  121836. get visibility(): number;
  121837. /**
  121838. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  121839. */
  121840. set visibility(value: number);
  121841. /** Gets or sets the alpha index used to sort transparent meshes
  121842. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  121843. */
  121844. alphaIndex: number;
  121845. /**
  121846. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  121847. */
  121848. isVisible: boolean;
  121849. /**
  121850. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  121851. */
  121852. isPickable: boolean;
  121853. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  121854. showSubMeshesBoundingBox: boolean;
  121855. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  121856. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121857. */
  121858. isBlocker: boolean;
  121859. /**
  121860. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  121861. */
  121862. enablePointerMoveEvents: boolean;
  121863. private _renderingGroupId;
  121864. /**
  121865. * Specifies the rendering group id for this mesh (0 by default)
  121866. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  121867. */
  121868. get renderingGroupId(): number;
  121869. set renderingGroupId(value: number);
  121870. private _material;
  121871. /** Gets or sets current material */
  121872. get material(): Nullable<Material>;
  121873. set material(value: Nullable<Material>);
  121874. /**
  121875. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  121876. * @see https://doc.babylonjs.com/babylon101/shadows
  121877. */
  121878. get receiveShadows(): boolean;
  121879. set receiveShadows(value: boolean);
  121880. /** Defines color to use when rendering outline */
  121881. outlineColor: Color3;
  121882. /** Define width to use when rendering outline */
  121883. outlineWidth: number;
  121884. /** Defines color to use when rendering overlay */
  121885. overlayColor: Color3;
  121886. /** Defines alpha to use when rendering overlay */
  121887. overlayAlpha: number;
  121888. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  121889. get hasVertexAlpha(): boolean;
  121890. set hasVertexAlpha(value: boolean);
  121891. /** 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) */
  121892. get useVertexColors(): boolean;
  121893. set useVertexColors(value: boolean);
  121894. /**
  121895. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  121896. */
  121897. get computeBonesUsingShaders(): boolean;
  121898. set computeBonesUsingShaders(value: boolean);
  121899. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  121900. get numBoneInfluencers(): number;
  121901. set numBoneInfluencers(value: number);
  121902. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  121903. get applyFog(): boolean;
  121904. set applyFog(value: boolean);
  121905. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  121906. useOctreeForRenderingSelection: boolean;
  121907. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  121908. useOctreeForPicking: boolean;
  121909. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  121910. useOctreeForCollisions: boolean;
  121911. /**
  121912. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  121913. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  121914. */
  121915. get layerMask(): number;
  121916. set layerMask(value: number);
  121917. /**
  121918. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  121919. */
  121920. alwaysSelectAsActiveMesh: boolean;
  121921. /**
  121922. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  121923. */
  121924. doNotSyncBoundingInfo: boolean;
  121925. /**
  121926. * Gets or sets the current action manager
  121927. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121928. */
  121929. actionManager: Nullable<AbstractActionManager>;
  121930. private _meshCollisionData;
  121931. /**
  121932. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  121933. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121934. */
  121935. ellipsoid: Vector3;
  121936. /**
  121937. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  121938. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121939. */
  121940. ellipsoidOffset: Vector3;
  121941. /**
  121942. * Gets or sets a collision mask used to mask collisions (default is -1).
  121943. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  121944. */
  121945. get collisionMask(): number;
  121946. set collisionMask(mask: number);
  121947. /**
  121948. * Gets or sets a collision response flag (default is true).
  121949. * when collisionResponse is false, events are still triggered but colliding entity has no response
  121950. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  121951. * to respond to the collision.
  121952. */
  121953. get collisionResponse(): boolean;
  121954. set collisionResponse(response: boolean);
  121955. /**
  121956. * Gets or sets the current collision group mask (-1 by default).
  121957. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  121958. */
  121959. get collisionGroup(): number;
  121960. set collisionGroup(mask: number);
  121961. /**
  121962. * Gets or sets current surrounding meshes (null by default).
  121963. *
  121964. * By default collision detection is tested against every mesh in the scene.
  121965. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  121966. * meshes will be tested for the collision.
  121967. *
  121968. * Note: if set to an empty array no collision will happen when this mesh is moved.
  121969. */
  121970. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  121971. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  121972. /**
  121973. * Defines edge width used when edgesRenderer is enabled
  121974. * @see https://www.babylonjs-playground.com/#10OJSG#13
  121975. */
  121976. edgesWidth: number;
  121977. /**
  121978. * Defines edge color used when edgesRenderer is enabled
  121979. * @see https://www.babylonjs-playground.com/#10OJSG#13
  121980. */
  121981. edgesColor: Color4;
  121982. /** @hidden */
  121983. _edgesRenderer: Nullable<IEdgesRenderer>;
  121984. /** @hidden */
  121985. _masterMesh: Nullable<AbstractMesh>;
  121986. /** @hidden */
  121987. _boundingInfo: Nullable<BoundingInfo>;
  121988. /** @hidden */
  121989. _renderId: number;
  121990. /**
  121991. * Gets or sets the list of subMeshes
  121992. * @see https://doc.babylonjs.com/how_to/multi_materials
  121993. */
  121994. subMeshes: SubMesh[];
  121995. /** @hidden */
  121996. _intersectionsInProgress: AbstractMesh[];
  121997. /** @hidden */
  121998. _unIndexed: boolean;
  121999. /** @hidden */
  122000. _lightSources: Light[];
  122001. /** Gets the list of lights affecting that mesh */
  122002. get lightSources(): Light[];
  122003. /** @hidden */
  122004. get _positions(): Nullable<Vector3[]>;
  122005. /** @hidden */
  122006. _waitingData: {
  122007. lods: Nullable<any>;
  122008. actions: Nullable<any>;
  122009. freezeWorldMatrix: Nullable<boolean>;
  122010. };
  122011. /** @hidden */
  122012. _bonesTransformMatrices: Nullable<Float32Array>;
  122013. /** @hidden */
  122014. _transformMatrixTexture: Nullable<RawTexture>;
  122015. /**
  122016. * Gets or sets a skeleton to apply skinning transformations
  122017. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  122018. */
  122019. set skeleton(value: Nullable<Skeleton>);
  122020. get skeleton(): Nullable<Skeleton>;
  122021. /**
  122022. * An event triggered when the mesh is rebuilt.
  122023. */
  122024. onRebuildObservable: Observable<AbstractMesh>;
  122025. /**
  122026. * The current mesh uniform buffer.
  122027. * @hidden Internal use only.
  122028. */
  122029. _uniformBuffer: UniformBuffer;
  122030. /**
  122031. * Creates a new AbstractMesh
  122032. * @param name defines the name of the mesh
  122033. * @param scene defines the hosting scene
  122034. */
  122035. constructor(name: string, scene?: Nullable<Scene>);
  122036. protected _buildUniformLayout(): void;
  122037. /**
  122038. * Transfer the mesh values to its UBO.
  122039. * @param world The world matrix associated with the mesh
  122040. */
  122041. transferToEffect(world: Matrix): void;
  122042. /**
  122043. * Gets the mesh uniform buffer.
  122044. * @return the uniform buffer of the mesh.
  122045. */
  122046. getMeshUniformBuffer(): UniformBuffer;
  122047. /**
  122048. * Returns the string "AbstractMesh"
  122049. * @returns "AbstractMesh"
  122050. */
  122051. getClassName(): string;
  122052. /**
  122053. * Gets a string representation of the current mesh
  122054. * @param fullDetails defines a boolean indicating if full details must be included
  122055. * @returns a string representation of the current mesh
  122056. */
  122057. toString(fullDetails?: boolean): string;
  122058. /**
  122059. * @hidden
  122060. */
  122061. protected _getEffectiveParent(): Nullable<Node>;
  122062. /** @hidden */
  122063. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  122064. /** @hidden */
  122065. _rebuild(): void;
  122066. /** @hidden */
  122067. _resyncLightSources(): void;
  122068. /** @hidden */
  122069. _resyncLightSource(light: Light): void;
  122070. /** @hidden */
  122071. _unBindEffect(): void;
  122072. /** @hidden */
  122073. _removeLightSource(light: Light, dispose: boolean): void;
  122074. private _markSubMeshesAsDirty;
  122075. /** @hidden */
  122076. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  122077. /** @hidden */
  122078. _markSubMeshesAsAttributesDirty(): void;
  122079. /** @hidden */
  122080. _markSubMeshesAsMiscDirty(): void;
  122081. /**
  122082. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  122083. */
  122084. get scaling(): Vector3;
  122085. set scaling(newScaling: Vector3);
  122086. /**
  122087. * Returns true if the mesh is blocked. Implemented by child classes
  122088. */
  122089. get isBlocked(): boolean;
  122090. /**
  122091. * Returns the mesh itself by default. Implemented by child classes
  122092. * @param camera defines the camera to use to pick the right LOD level
  122093. * @returns the currentAbstractMesh
  122094. */
  122095. getLOD(camera: Camera): Nullable<AbstractMesh>;
  122096. /**
  122097. * Returns 0 by default. Implemented by child classes
  122098. * @returns an integer
  122099. */
  122100. getTotalVertices(): number;
  122101. /**
  122102. * Returns a positive integer : the total number of indices in this mesh geometry.
  122103. * @returns the number of indices or zero if the mesh has no geometry.
  122104. */
  122105. getTotalIndices(): number;
  122106. /**
  122107. * Returns null by default. Implemented by child classes
  122108. * @returns null
  122109. */
  122110. getIndices(): Nullable<IndicesArray>;
  122111. /**
  122112. * Returns the array of the requested vertex data kind. Implemented by child classes
  122113. * @param kind defines the vertex data kind to use
  122114. * @returns null
  122115. */
  122116. getVerticesData(kind: string): Nullable<FloatArray>;
  122117. /**
  122118. * Sets the vertex data of the mesh geometry for the requested `kind`.
  122119. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  122120. * Note that a new underlying VertexBuffer object is created each call.
  122121. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  122122. * @param kind defines vertex data kind:
  122123. * * VertexBuffer.PositionKind
  122124. * * VertexBuffer.UVKind
  122125. * * VertexBuffer.UV2Kind
  122126. * * VertexBuffer.UV3Kind
  122127. * * VertexBuffer.UV4Kind
  122128. * * VertexBuffer.UV5Kind
  122129. * * VertexBuffer.UV6Kind
  122130. * * VertexBuffer.ColorKind
  122131. * * VertexBuffer.MatricesIndicesKind
  122132. * * VertexBuffer.MatricesIndicesExtraKind
  122133. * * VertexBuffer.MatricesWeightsKind
  122134. * * VertexBuffer.MatricesWeightsExtraKind
  122135. * @param data defines the data source
  122136. * @param updatable defines if the data must be flagged as updatable (or static)
  122137. * @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
  122138. * @returns the current mesh
  122139. */
  122140. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  122141. /**
  122142. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  122143. * If the mesh has no geometry, it is simply returned as it is.
  122144. * @param kind defines vertex data kind:
  122145. * * VertexBuffer.PositionKind
  122146. * * VertexBuffer.UVKind
  122147. * * VertexBuffer.UV2Kind
  122148. * * VertexBuffer.UV3Kind
  122149. * * VertexBuffer.UV4Kind
  122150. * * VertexBuffer.UV5Kind
  122151. * * VertexBuffer.UV6Kind
  122152. * * VertexBuffer.ColorKind
  122153. * * VertexBuffer.MatricesIndicesKind
  122154. * * VertexBuffer.MatricesIndicesExtraKind
  122155. * * VertexBuffer.MatricesWeightsKind
  122156. * * VertexBuffer.MatricesWeightsExtraKind
  122157. * @param data defines the data source
  122158. * @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
  122159. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  122160. * @returns the current mesh
  122161. */
  122162. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  122163. /**
  122164. * Sets the mesh indices,
  122165. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  122166. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  122167. * @param totalVertices Defines the total number of vertices
  122168. * @returns the current mesh
  122169. */
  122170. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  122171. /**
  122172. * Gets a boolean indicating if specific vertex data is present
  122173. * @param kind defines the vertex data kind to use
  122174. * @returns true is data kind is present
  122175. */
  122176. isVerticesDataPresent(kind: string): boolean;
  122177. /**
  122178. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  122179. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  122180. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  122181. * @returns a BoundingInfo
  122182. */
  122183. getBoundingInfo(): BoundingInfo;
  122184. /**
  122185. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  122186. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  122187. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  122188. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  122189. * @returns the current mesh
  122190. */
  122191. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  122192. /**
  122193. * Overwrite the current bounding info
  122194. * @param boundingInfo defines the new bounding info
  122195. * @returns the current mesh
  122196. */
  122197. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  122198. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  122199. get useBones(): boolean;
  122200. /** @hidden */
  122201. _preActivate(): void;
  122202. /** @hidden */
  122203. _preActivateForIntermediateRendering(renderId: number): void;
  122204. /** @hidden */
  122205. _activate(renderId: number, intermediateRendering: boolean): boolean;
  122206. /** @hidden */
  122207. _postActivate(): void;
  122208. /** @hidden */
  122209. _freeze(): void;
  122210. /** @hidden */
  122211. _unFreeze(): void;
  122212. /**
  122213. * Gets the current world matrix
  122214. * @returns a Matrix
  122215. */
  122216. getWorldMatrix(): Matrix;
  122217. /** @hidden */
  122218. _getWorldMatrixDeterminant(): number;
  122219. /**
  122220. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  122221. */
  122222. get isAnInstance(): boolean;
  122223. /**
  122224. * Gets a boolean indicating if this mesh has instances
  122225. */
  122226. get hasInstances(): boolean;
  122227. /**
  122228. * Gets a boolean indicating if this mesh has thin instances
  122229. */
  122230. get hasThinInstances(): boolean;
  122231. /**
  122232. * Perform relative position change from the point of view of behind the front of the mesh.
  122233. * This is performed taking into account the meshes current rotation, so you do not have to care.
  122234. * Supports definition of mesh facing forward or backward
  122235. * @param amountRight defines the distance on the right axis
  122236. * @param amountUp defines the distance on the up axis
  122237. * @param amountForward defines the distance on the forward axis
  122238. * @returns the current mesh
  122239. */
  122240. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  122241. /**
  122242. * Calculate relative position change from the point of view of behind the front of the mesh.
  122243. * This is performed taking into account the meshes current rotation, so you do not have to care.
  122244. * Supports definition of mesh facing forward or backward
  122245. * @param amountRight defines the distance on the right axis
  122246. * @param amountUp defines the distance on the up axis
  122247. * @param amountForward defines the distance on the forward axis
  122248. * @returns the new displacement vector
  122249. */
  122250. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  122251. /**
  122252. * Perform relative rotation change from the point of view of behind the front of the mesh.
  122253. * Supports definition of mesh facing forward or backward
  122254. * @param flipBack defines the flip
  122255. * @param twirlClockwise defines the twirl
  122256. * @param tiltRight defines the tilt
  122257. * @returns the current mesh
  122258. */
  122259. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  122260. /**
  122261. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  122262. * Supports definition of mesh facing forward or backward.
  122263. * @param flipBack defines the flip
  122264. * @param twirlClockwise defines the twirl
  122265. * @param tiltRight defines the tilt
  122266. * @returns the new rotation vector
  122267. */
  122268. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  122269. /**
  122270. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  122271. * This means the mesh underlying bounding box and sphere are recomputed.
  122272. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  122273. * @returns the current mesh
  122274. */
  122275. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  122276. /** @hidden */
  122277. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  122278. /** @hidden */
  122279. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  122280. /** @hidden */
  122281. _updateBoundingInfo(): AbstractMesh;
  122282. /** @hidden */
  122283. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  122284. /** @hidden */
  122285. protected _afterComputeWorldMatrix(): void;
  122286. /** @hidden */
  122287. get _effectiveMesh(): AbstractMesh;
  122288. /**
  122289. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  122290. * A mesh is in the frustum if its bounding box intersects the frustum
  122291. * @param frustumPlanes defines the frustum to test
  122292. * @returns true if the mesh is in the frustum planes
  122293. */
  122294. isInFrustum(frustumPlanes: Plane[]): boolean;
  122295. /**
  122296. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  122297. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  122298. * @param frustumPlanes defines the frustum to test
  122299. * @returns true if the mesh is completely in the frustum planes
  122300. */
  122301. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  122302. /**
  122303. * True if the mesh intersects another mesh or a SolidParticle object
  122304. * @param mesh defines a target mesh or SolidParticle to test
  122305. * @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)
  122306. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  122307. * @returns true if there is an intersection
  122308. */
  122309. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  122310. /**
  122311. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  122312. * @param point defines the point to test
  122313. * @returns true if there is an intersection
  122314. */
  122315. intersectsPoint(point: Vector3): boolean;
  122316. /**
  122317. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  122318. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  122319. */
  122320. get checkCollisions(): boolean;
  122321. set checkCollisions(collisionEnabled: boolean);
  122322. /**
  122323. * Gets Collider object used to compute collisions (not physics)
  122324. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  122325. */
  122326. get collider(): Nullable<Collider>;
  122327. /**
  122328. * Move the mesh using collision engine
  122329. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  122330. * @param displacement defines the requested displacement vector
  122331. * @returns the current mesh
  122332. */
  122333. moveWithCollisions(displacement: Vector3): AbstractMesh;
  122334. private _onCollisionPositionChange;
  122335. /** @hidden */
  122336. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  122337. /** @hidden */
  122338. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  122339. /** @hidden */
  122340. _checkCollision(collider: Collider): AbstractMesh;
  122341. /** @hidden */
  122342. _generatePointsArray(): boolean;
  122343. /**
  122344. * Checks if the passed Ray intersects with the mesh
  122345. * @param ray defines the ray to use
  122346. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  122347. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  122348. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  122349. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  122350. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  122351. * @returns the picking info
  122352. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  122353. */
  122354. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  122355. /**
  122356. * Clones the current mesh
  122357. * @param name defines the mesh name
  122358. * @param newParent defines the new mesh parent
  122359. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  122360. * @returns the new mesh
  122361. */
  122362. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  122363. /**
  122364. * Disposes all the submeshes of the current meshnp
  122365. * @returns the current mesh
  122366. */
  122367. releaseSubMeshes(): AbstractMesh;
  122368. /**
  122369. * Releases resources associated with this abstract mesh.
  122370. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122371. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122372. */
  122373. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122374. /**
  122375. * Adds the passed mesh as a child to the current mesh
  122376. * @param mesh defines the child mesh
  122377. * @returns the current mesh
  122378. */
  122379. addChild(mesh: AbstractMesh): AbstractMesh;
  122380. /**
  122381. * Removes the passed mesh from the current mesh children list
  122382. * @param mesh defines the child mesh
  122383. * @returns the current mesh
  122384. */
  122385. removeChild(mesh: AbstractMesh): AbstractMesh;
  122386. /** @hidden */
  122387. private _initFacetData;
  122388. /**
  122389. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  122390. * This method can be called within the render loop.
  122391. * 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
  122392. * @returns the current mesh
  122393. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122394. */
  122395. updateFacetData(): AbstractMesh;
  122396. /**
  122397. * Returns the facetLocalNormals array.
  122398. * The normals are expressed in the mesh local spac
  122399. * @returns an array of Vector3
  122400. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122401. */
  122402. getFacetLocalNormals(): Vector3[];
  122403. /**
  122404. * Returns the facetLocalPositions array.
  122405. * The facet positions are expressed in the mesh local space
  122406. * @returns an array of Vector3
  122407. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122408. */
  122409. getFacetLocalPositions(): Vector3[];
  122410. /**
  122411. * Returns the facetLocalPartitioning array
  122412. * @returns an array of array of numbers
  122413. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122414. */
  122415. getFacetLocalPartitioning(): number[][];
  122416. /**
  122417. * Returns the i-th facet position in the world system.
  122418. * This method allocates a new Vector3 per call
  122419. * @param i defines the facet index
  122420. * @returns a new Vector3
  122421. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122422. */
  122423. getFacetPosition(i: number): Vector3;
  122424. /**
  122425. * Sets the reference Vector3 with the i-th facet position in the world system
  122426. * @param i defines the facet index
  122427. * @param ref defines the target vector
  122428. * @returns the current mesh
  122429. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122430. */
  122431. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  122432. /**
  122433. * Returns the i-th facet normal in the world system.
  122434. * This method allocates a new Vector3 per call
  122435. * @param i defines the facet index
  122436. * @returns a new Vector3
  122437. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122438. */
  122439. getFacetNormal(i: number): Vector3;
  122440. /**
  122441. * Sets the reference Vector3 with the i-th facet normal in the world system
  122442. * @param i defines the facet index
  122443. * @param ref defines the target vector
  122444. * @returns the current mesh
  122445. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122446. */
  122447. getFacetNormalToRef(i: number, ref: Vector3): this;
  122448. /**
  122449. * 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)
  122450. * @param x defines x coordinate
  122451. * @param y defines y coordinate
  122452. * @param z defines z coordinate
  122453. * @returns the array of facet indexes
  122454. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122455. */
  122456. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  122457. /**
  122458. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  122459. * @param projected sets as the (x,y,z) world projection on the facet
  122460. * @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
  122461. * @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
  122462. * @param x defines x coordinate
  122463. * @param y defines y coordinate
  122464. * @param z defines z coordinate
  122465. * @returns the face index if found (or null instead)
  122466. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122467. */
  122468. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  122469. /**
  122470. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  122471. * @param projected sets as the (x,y,z) local projection on the facet
  122472. * @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
  122473. * @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
  122474. * @param x defines x coordinate
  122475. * @param y defines y coordinate
  122476. * @param z defines z coordinate
  122477. * @returns the face index if found (or null instead)
  122478. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122479. */
  122480. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  122481. /**
  122482. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  122483. * @returns the parameters
  122484. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122485. */
  122486. getFacetDataParameters(): any;
  122487. /**
  122488. * Disables the feature FacetData and frees the related memory
  122489. * @returns the current mesh
  122490. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  122491. */
  122492. disableFacetData(): AbstractMesh;
  122493. /**
  122494. * Updates the AbstractMesh indices array
  122495. * @param indices defines the data source
  122496. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  122497. * @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)
  122498. * @returns the current mesh
  122499. */
  122500. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  122501. /**
  122502. * Creates new normals data for the mesh
  122503. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  122504. * @returns the current mesh
  122505. */
  122506. createNormals(updatable: boolean): AbstractMesh;
  122507. /**
  122508. * Align the mesh with a normal
  122509. * @param normal defines the normal to use
  122510. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  122511. * @returns the current mesh
  122512. */
  122513. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  122514. /** @hidden */
  122515. _checkOcclusionQuery(): boolean;
  122516. /**
  122517. * Disables the mesh edge rendering mode
  122518. * @returns the currentAbstractMesh
  122519. */
  122520. disableEdgesRendering(): AbstractMesh;
  122521. /**
  122522. * Enables the edge rendering mode on the mesh.
  122523. * This mode makes the mesh edges visible
  122524. * @param epsilon defines the maximal distance between two angles to detect a face
  122525. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  122526. * @param options options to the edge renderer
  122527. * @returns the currentAbstractMesh
  122528. * @see https://www.babylonjs-playground.com/#19O9TU#0
  122529. */
  122530. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  122531. /**
  122532. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  122533. * @returns an array of particle systems in the scene that use the mesh as an emitter
  122534. */
  122535. getConnectedParticleSystems(): IParticleSystem[];
  122536. }
  122537. }
  122538. declare module BABYLON {
  122539. /**
  122540. * Interface used to define ActionEvent
  122541. */
  122542. export interface IActionEvent {
  122543. /** The mesh or sprite that triggered the action */
  122544. source: any;
  122545. /** The X mouse cursor position at the time of the event */
  122546. pointerX: number;
  122547. /** The Y mouse cursor position at the time of the event */
  122548. pointerY: number;
  122549. /** The mesh that is currently pointed at (can be null) */
  122550. meshUnderPointer: Nullable<AbstractMesh>;
  122551. /** the original (browser) event that triggered the ActionEvent */
  122552. sourceEvent?: any;
  122553. /** additional data for the event */
  122554. additionalData?: any;
  122555. }
  122556. /**
  122557. * ActionEvent is the event being sent when an action is triggered.
  122558. */
  122559. export class ActionEvent implements IActionEvent {
  122560. /** The mesh or sprite that triggered the action */
  122561. source: any;
  122562. /** The X mouse cursor position at the time of the event */
  122563. pointerX: number;
  122564. /** The Y mouse cursor position at the time of the event */
  122565. pointerY: number;
  122566. /** The mesh that is currently pointed at (can be null) */
  122567. meshUnderPointer: Nullable<AbstractMesh>;
  122568. /** the original (browser) event that triggered the ActionEvent */
  122569. sourceEvent?: any;
  122570. /** additional data for the event */
  122571. additionalData?: any;
  122572. /**
  122573. * Creates a new ActionEvent
  122574. * @param source The mesh or sprite that triggered the action
  122575. * @param pointerX The X mouse cursor position at the time of the event
  122576. * @param pointerY The Y mouse cursor position at the time of the event
  122577. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  122578. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  122579. * @param additionalData additional data for the event
  122580. */
  122581. constructor(
  122582. /** The mesh or sprite that triggered the action */
  122583. source: any,
  122584. /** The X mouse cursor position at the time of the event */
  122585. pointerX: number,
  122586. /** The Y mouse cursor position at the time of the event */
  122587. pointerY: number,
  122588. /** The mesh that is currently pointed at (can be null) */
  122589. meshUnderPointer: Nullable<AbstractMesh>,
  122590. /** the original (browser) event that triggered the ActionEvent */
  122591. sourceEvent?: any,
  122592. /** additional data for the event */
  122593. additionalData?: any);
  122594. /**
  122595. * Helper function to auto-create an ActionEvent from a source mesh.
  122596. * @param source The source mesh that triggered the event
  122597. * @param evt The original (browser) event
  122598. * @param additionalData additional data for the event
  122599. * @returns the new ActionEvent
  122600. */
  122601. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  122602. /**
  122603. * Helper function to auto-create an ActionEvent from a source sprite
  122604. * @param source The source sprite that triggered the event
  122605. * @param scene Scene associated with the sprite
  122606. * @param evt The original (browser) event
  122607. * @param additionalData additional data for the event
  122608. * @returns the new ActionEvent
  122609. */
  122610. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  122611. /**
  122612. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  122613. * @param scene the scene where the event occurred
  122614. * @param evt The original (browser) event
  122615. * @returns the new ActionEvent
  122616. */
  122617. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  122618. /**
  122619. * Helper function to auto-create an ActionEvent from a primitive
  122620. * @param prim defines the target primitive
  122621. * @param pointerPos defines the pointer position
  122622. * @param evt The original (browser) event
  122623. * @param additionalData additional data for the event
  122624. * @returns the new ActionEvent
  122625. */
  122626. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  122627. }
  122628. }
  122629. declare module BABYLON {
  122630. /**
  122631. * Abstract class used to decouple action Manager from scene and meshes.
  122632. * Do not instantiate.
  122633. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122634. */
  122635. export abstract class AbstractActionManager implements IDisposable {
  122636. /** Gets the list of active triggers */
  122637. static Triggers: {
  122638. [key: string]: number;
  122639. };
  122640. /** Gets the cursor to use when hovering items */
  122641. hoverCursor: string;
  122642. /** Gets the list of actions */
  122643. actions: IAction[];
  122644. /**
  122645. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  122646. */
  122647. isRecursive: boolean;
  122648. /**
  122649. * Releases all associated resources
  122650. */
  122651. abstract dispose(): void;
  122652. /**
  122653. * Does this action manager has pointer triggers
  122654. */
  122655. abstract get hasPointerTriggers(): boolean;
  122656. /**
  122657. * Does this action manager has pick triggers
  122658. */
  122659. abstract get hasPickTriggers(): boolean;
  122660. /**
  122661. * Process a specific trigger
  122662. * @param trigger defines the trigger to process
  122663. * @param evt defines the event details to be processed
  122664. */
  122665. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  122666. /**
  122667. * Does this action manager handles actions of any of the given triggers
  122668. * @param triggers defines the triggers to be tested
  122669. * @return a boolean indicating whether one (or more) of the triggers is handled
  122670. */
  122671. abstract hasSpecificTriggers(triggers: number[]): boolean;
  122672. /**
  122673. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  122674. * speed.
  122675. * @param triggerA defines the trigger to be tested
  122676. * @param triggerB defines the trigger to be tested
  122677. * @return a boolean indicating whether one (or more) of the triggers is handled
  122678. */
  122679. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  122680. /**
  122681. * Does this action manager handles actions of a given trigger
  122682. * @param trigger defines the trigger to be tested
  122683. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  122684. * @return whether the trigger is handled
  122685. */
  122686. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  122687. /**
  122688. * Serialize this manager to a JSON object
  122689. * @param name defines the property name to store this manager
  122690. * @returns a JSON representation of this manager
  122691. */
  122692. abstract serialize(name: string): any;
  122693. /**
  122694. * Registers an action to this action manager
  122695. * @param action defines the action to be registered
  122696. * @return the action amended (prepared) after registration
  122697. */
  122698. abstract registerAction(action: IAction): Nullable<IAction>;
  122699. /**
  122700. * Unregisters an action to this action manager
  122701. * @param action defines the action to be unregistered
  122702. * @return a boolean indicating whether the action has been unregistered
  122703. */
  122704. abstract unregisterAction(action: IAction): Boolean;
  122705. /**
  122706. * Does exist one action manager with at least one trigger
  122707. **/
  122708. static get HasTriggers(): boolean;
  122709. /**
  122710. * Does exist one action manager with at least one pick trigger
  122711. **/
  122712. static get HasPickTriggers(): boolean;
  122713. /**
  122714. * Does exist one action manager that handles actions of a given trigger
  122715. * @param trigger defines the trigger to be tested
  122716. * @return a boolean indicating whether the trigger is handled by at least one action manager
  122717. **/
  122718. static HasSpecificTrigger(trigger: number): boolean;
  122719. }
  122720. }
  122721. declare module BABYLON {
  122722. /**
  122723. * Defines how a node can be built from a string name.
  122724. */
  122725. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  122726. /**
  122727. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  122728. */
  122729. export class Node implements IBehaviorAware<Node> {
  122730. /** @hidden */
  122731. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  122732. private static _NodeConstructors;
  122733. /**
  122734. * Add a new node constructor
  122735. * @param type defines the type name of the node to construct
  122736. * @param constructorFunc defines the constructor function
  122737. */
  122738. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  122739. /**
  122740. * Returns a node constructor based on type name
  122741. * @param type defines the type name
  122742. * @param name defines the new node name
  122743. * @param scene defines the hosting scene
  122744. * @param options defines optional options to transmit to constructors
  122745. * @returns the new constructor or null
  122746. */
  122747. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  122748. /**
  122749. * Gets or sets the name of the node
  122750. */
  122751. name: string;
  122752. /**
  122753. * Gets or sets the id of the node
  122754. */
  122755. id: string;
  122756. /**
  122757. * Gets or sets the unique id of the node
  122758. */
  122759. uniqueId: number;
  122760. /**
  122761. * Gets or sets a string used to store user defined state for the node
  122762. */
  122763. state: string;
  122764. /**
  122765. * Gets or sets an object used to store user defined information for the node
  122766. */
  122767. metadata: any;
  122768. /**
  122769. * For internal use only. Please do not use.
  122770. */
  122771. reservedDataStore: any;
  122772. /**
  122773. * List of inspectable custom properties (used by the Inspector)
  122774. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  122775. */
  122776. inspectableCustomProperties: IInspectable[];
  122777. private _doNotSerialize;
  122778. /**
  122779. * Gets or sets a boolean used to define if the node must be serialized
  122780. */
  122781. get doNotSerialize(): boolean;
  122782. set doNotSerialize(value: boolean);
  122783. /** @hidden */
  122784. _isDisposed: boolean;
  122785. /**
  122786. * Gets a list of Animations associated with the node
  122787. */
  122788. animations: Animation[];
  122789. protected _ranges: {
  122790. [name: string]: Nullable<AnimationRange>;
  122791. };
  122792. /**
  122793. * Callback raised when the node is ready to be used
  122794. */
  122795. onReady: Nullable<(node: Node) => void>;
  122796. private _isEnabled;
  122797. private _isParentEnabled;
  122798. private _isReady;
  122799. /** @hidden */
  122800. _currentRenderId: number;
  122801. private _parentUpdateId;
  122802. /** @hidden */
  122803. _childUpdateId: number;
  122804. /** @hidden */
  122805. _waitingParentId: Nullable<string>;
  122806. /** @hidden */
  122807. _scene: Scene;
  122808. /** @hidden */
  122809. _cache: any;
  122810. private _parentNode;
  122811. private _children;
  122812. /** @hidden */
  122813. _worldMatrix: Matrix;
  122814. /** @hidden */
  122815. _worldMatrixDeterminant: number;
  122816. /** @hidden */
  122817. _worldMatrixDeterminantIsDirty: boolean;
  122818. /** @hidden */
  122819. private _sceneRootNodesIndex;
  122820. /**
  122821. * Gets a boolean indicating if the node has been disposed
  122822. * @returns true if the node was disposed
  122823. */
  122824. isDisposed(): boolean;
  122825. /**
  122826. * Gets or sets the parent of the node (without keeping the current position in the scene)
  122827. * @see https://doc.babylonjs.com/how_to/parenting
  122828. */
  122829. set parent(parent: Nullable<Node>);
  122830. get parent(): Nullable<Node>;
  122831. /** @hidden */
  122832. _addToSceneRootNodes(): void;
  122833. /** @hidden */
  122834. _removeFromSceneRootNodes(): void;
  122835. private _animationPropertiesOverride;
  122836. /**
  122837. * Gets or sets the animation properties override
  122838. */
  122839. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  122840. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  122841. /**
  122842. * Gets a string identifying the name of the class
  122843. * @returns "Node" string
  122844. */
  122845. getClassName(): string;
  122846. /** @hidden */
  122847. readonly _isNode: boolean;
  122848. /**
  122849. * An event triggered when the mesh is disposed
  122850. */
  122851. onDisposeObservable: Observable<Node>;
  122852. private _onDisposeObserver;
  122853. /**
  122854. * Sets a callback that will be raised when the node will be disposed
  122855. */
  122856. set onDispose(callback: () => void);
  122857. /**
  122858. * Creates a new Node
  122859. * @param name the name and id to be given to this node
  122860. * @param scene the scene this node will be added to
  122861. */
  122862. constructor(name: string, scene?: Nullable<Scene>);
  122863. /**
  122864. * Gets the scene of the node
  122865. * @returns a scene
  122866. */
  122867. getScene(): Scene;
  122868. /**
  122869. * Gets the engine of the node
  122870. * @returns a Engine
  122871. */
  122872. getEngine(): Engine;
  122873. private _behaviors;
  122874. /**
  122875. * Attach a behavior to the node
  122876. * @see https://doc.babylonjs.com/features/behaviour
  122877. * @param behavior defines the behavior to attach
  122878. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  122879. * @returns the current Node
  122880. */
  122881. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  122882. /**
  122883. * Remove an attached behavior
  122884. * @see https://doc.babylonjs.com/features/behaviour
  122885. * @param behavior defines the behavior to attach
  122886. * @returns the current Node
  122887. */
  122888. removeBehavior(behavior: Behavior<Node>): Node;
  122889. /**
  122890. * Gets the list of attached behaviors
  122891. * @see https://doc.babylonjs.com/features/behaviour
  122892. */
  122893. get behaviors(): Behavior<Node>[];
  122894. /**
  122895. * Gets an attached behavior by name
  122896. * @param name defines the name of the behavior to look for
  122897. * @see https://doc.babylonjs.com/features/behaviour
  122898. * @returns null if behavior was not found else the requested behavior
  122899. */
  122900. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  122901. /**
  122902. * Returns the latest update of the World matrix
  122903. * @returns a Matrix
  122904. */
  122905. getWorldMatrix(): Matrix;
  122906. /** @hidden */
  122907. _getWorldMatrixDeterminant(): number;
  122908. /**
  122909. * Returns directly the latest state of the mesh World matrix.
  122910. * A Matrix is returned.
  122911. */
  122912. get worldMatrixFromCache(): Matrix;
  122913. /** @hidden */
  122914. _initCache(): void;
  122915. /** @hidden */
  122916. updateCache(force?: boolean): void;
  122917. /** @hidden */
  122918. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  122919. /** @hidden */
  122920. _updateCache(ignoreParentClass?: boolean): void;
  122921. /** @hidden */
  122922. _isSynchronized(): boolean;
  122923. /** @hidden */
  122924. _markSyncedWithParent(): void;
  122925. /** @hidden */
  122926. isSynchronizedWithParent(): boolean;
  122927. /** @hidden */
  122928. isSynchronized(): boolean;
  122929. /**
  122930. * Is this node ready to be used/rendered
  122931. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  122932. * @return true if the node is ready
  122933. */
  122934. isReady(completeCheck?: boolean): boolean;
  122935. /**
  122936. * Is this node enabled?
  122937. * 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
  122938. * @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
  122939. * @return whether this node (and its parent) is enabled
  122940. */
  122941. isEnabled(checkAncestors?: boolean): boolean;
  122942. /** @hidden */
  122943. protected _syncParentEnabledState(): void;
  122944. /**
  122945. * Set the enabled state of this node
  122946. * @param value defines the new enabled state
  122947. */
  122948. setEnabled(value: boolean): void;
  122949. /**
  122950. * Is this node a descendant of the given node?
  122951. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  122952. * @param ancestor defines the parent node to inspect
  122953. * @returns a boolean indicating if this node is a descendant of the given node
  122954. */
  122955. isDescendantOf(ancestor: Node): boolean;
  122956. /** @hidden */
  122957. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  122958. /**
  122959. * Will return all nodes that have this node as ascendant
  122960. * @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
  122961. * @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
  122962. * @return all children nodes of all types
  122963. */
  122964. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  122965. /**
  122966. * Get all child-meshes of this node
  122967. * @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)
  122968. * @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
  122969. * @returns an array of AbstractMesh
  122970. */
  122971. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  122972. /**
  122973. * Get all direct children of this node
  122974. * @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
  122975. * @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)
  122976. * @returns an array of Node
  122977. */
  122978. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  122979. /** @hidden */
  122980. _setReady(state: boolean): void;
  122981. /**
  122982. * Get an animation by name
  122983. * @param name defines the name of the animation to look for
  122984. * @returns null if not found else the requested animation
  122985. */
  122986. getAnimationByName(name: string): Nullable<Animation>;
  122987. /**
  122988. * Creates an animation range for this node
  122989. * @param name defines the name of the range
  122990. * @param from defines the starting key
  122991. * @param to defines the end key
  122992. */
  122993. createAnimationRange(name: string, from: number, to: number): void;
  122994. /**
  122995. * Delete a specific animation range
  122996. * @param name defines the name of the range to delete
  122997. * @param deleteFrames defines if animation frames from the range must be deleted as well
  122998. */
  122999. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  123000. /**
  123001. * Get an animation range by name
  123002. * @param name defines the name of the animation range to look for
  123003. * @returns null if not found else the requested animation range
  123004. */
  123005. getAnimationRange(name: string): Nullable<AnimationRange>;
  123006. /**
  123007. * Gets the list of all animation ranges defined on this node
  123008. * @returns an array
  123009. */
  123010. getAnimationRanges(): Nullable<AnimationRange>[];
  123011. /**
  123012. * Will start the animation sequence
  123013. * @param name defines the range frames for animation sequence
  123014. * @param loop defines if the animation should loop (false by default)
  123015. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  123016. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  123017. * @returns the object created for this animation. If range does not exist, it will return null
  123018. */
  123019. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  123020. /**
  123021. * Serialize animation ranges into a JSON compatible object
  123022. * @returns serialization object
  123023. */
  123024. serializeAnimationRanges(): any;
  123025. /**
  123026. * Computes the world matrix of the node
  123027. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  123028. * @returns the world matrix
  123029. */
  123030. computeWorldMatrix(force?: boolean): Matrix;
  123031. /**
  123032. * Releases resources associated with this node.
  123033. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123034. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123035. */
  123036. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123037. /**
  123038. * Parse animation range data from a serialization object and store them into a given node
  123039. * @param node defines where to store the animation ranges
  123040. * @param parsedNode defines the serialization object to read data from
  123041. * @param scene defines the hosting scene
  123042. */
  123043. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  123044. /**
  123045. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  123046. * @param includeDescendants Include bounding info from descendants as well (true by default)
  123047. * @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
  123048. * @returns the new bounding vectors
  123049. */
  123050. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  123051. min: Vector3;
  123052. max: Vector3;
  123053. };
  123054. }
  123055. }
  123056. declare module BABYLON {
  123057. /**
  123058. * @hidden
  123059. */
  123060. export class _IAnimationState {
  123061. key: number;
  123062. repeatCount: number;
  123063. workValue?: any;
  123064. loopMode?: number;
  123065. offsetValue?: any;
  123066. highLimitValue?: any;
  123067. }
  123068. /**
  123069. * Class used to store any kind of animation
  123070. */
  123071. export class Animation {
  123072. /**Name of the animation */
  123073. name: string;
  123074. /**Property to animate */
  123075. targetProperty: string;
  123076. /**The frames per second of the animation */
  123077. framePerSecond: number;
  123078. /**The data type of the animation */
  123079. dataType: number;
  123080. /**The loop mode of the animation */
  123081. loopMode?: number | undefined;
  123082. /**Specifies if blending should be enabled */
  123083. enableBlending?: boolean | undefined;
  123084. /**
  123085. * Use matrix interpolation instead of using direct key value when animating matrices
  123086. */
  123087. static AllowMatricesInterpolation: boolean;
  123088. /**
  123089. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  123090. */
  123091. static AllowMatrixDecomposeForInterpolation: boolean;
  123092. /** Define the Url to load snippets */
  123093. static SnippetUrl: string;
  123094. /** Snippet ID if the animation was created from the snippet server */
  123095. snippetId: string;
  123096. /**
  123097. * Stores the key frames of the animation
  123098. */
  123099. private _keys;
  123100. /**
  123101. * Stores the easing function of the animation
  123102. */
  123103. private _easingFunction;
  123104. /**
  123105. * @hidden Internal use only
  123106. */
  123107. _runtimeAnimations: RuntimeAnimation[];
  123108. /**
  123109. * The set of event that will be linked to this animation
  123110. */
  123111. private _events;
  123112. /**
  123113. * Stores an array of target property paths
  123114. */
  123115. targetPropertyPath: string[];
  123116. /**
  123117. * Stores the blending speed of the animation
  123118. */
  123119. blendingSpeed: number;
  123120. /**
  123121. * Stores the animation ranges for the animation
  123122. */
  123123. private _ranges;
  123124. /**
  123125. * @hidden Internal use
  123126. */
  123127. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  123128. /**
  123129. * Sets up an animation
  123130. * @param property The property to animate
  123131. * @param animationType The animation type to apply
  123132. * @param framePerSecond The frames per second of the animation
  123133. * @param easingFunction The easing function used in the animation
  123134. * @returns The created animation
  123135. */
  123136. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  123137. /**
  123138. * Create and start an animation on a node
  123139. * @param name defines the name of the global animation that will be run on all nodes
  123140. * @param node defines the root node where the animation will take place
  123141. * @param targetProperty defines property to animate
  123142. * @param framePerSecond defines the number of frame per second yo use
  123143. * @param totalFrame defines the number of frames in total
  123144. * @param from defines the initial value
  123145. * @param to defines the final value
  123146. * @param loopMode defines which loop mode you want to use (off by default)
  123147. * @param easingFunction defines the easing function to use (linear by default)
  123148. * @param onAnimationEnd defines the callback to call when animation end
  123149. * @returns the animatable created for this animation
  123150. */
  123151. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  123152. /**
  123153. * Create and start an animation on a node and its descendants
  123154. * @param name defines the name of the global animation that will be run on all nodes
  123155. * @param node defines the root node where the animation will take place
  123156. * @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
  123157. * @param targetProperty defines property to animate
  123158. * @param framePerSecond defines the number of frame per second to use
  123159. * @param totalFrame defines the number of frames in total
  123160. * @param from defines the initial value
  123161. * @param to defines the final value
  123162. * @param loopMode defines which loop mode you want to use (off by default)
  123163. * @param easingFunction defines the easing function to use (linear by default)
  123164. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  123165. * @returns the list of animatables created for all nodes
  123166. * @example https://www.babylonjs-playground.com/#MH0VLI
  123167. */
  123168. 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[]>;
  123169. /**
  123170. * Creates a new animation, merges it with the existing animations and starts it
  123171. * @param name Name of the animation
  123172. * @param node Node which contains the scene that begins the animations
  123173. * @param targetProperty Specifies which property to animate
  123174. * @param framePerSecond The frames per second of the animation
  123175. * @param totalFrame The total number of frames
  123176. * @param from The frame at the beginning of the animation
  123177. * @param to The frame at the end of the animation
  123178. * @param loopMode Specifies the loop mode of the animation
  123179. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  123180. * @param onAnimationEnd Callback to run once the animation is complete
  123181. * @returns Nullable animation
  123182. */
  123183. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  123184. /**
  123185. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123186. * @param sourceAnimation defines the Animation containing keyframes to convert
  123187. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123188. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  123189. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  123190. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  123191. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  123192. */
  123193. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  123194. /**
  123195. * Transition property of an host to the target Value
  123196. * @param property The property to transition
  123197. * @param targetValue The target Value of the property
  123198. * @param host The object where the property to animate belongs
  123199. * @param scene Scene used to run the animation
  123200. * @param frameRate Framerate (in frame/s) to use
  123201. * @param transition The transition type we want to use
  123202. * @param duration The duration of the animation, in milliseconds
  123203. * @param onAnimationEnd Callback trigger at the end of the animation
  123204. * @returns Nullable animation
  123205. */
  123206. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  123207. /**
  123208. * Return the array of runtime animations currently using this animation
  123209. */
  123210. get runtimeAnimations(): RuntimeAnimation[];
  123211. /**
  123212. * Specifies if any of the runtime animations are currently running
  123213. */
  123214. get hasRunningRuntimeAnimations(): boolean;
  123215. /**
  123216. * Initializes the animation
  123217. * @param name Name of the animation
  123218. * @param targetProperty Property to animate
  123219. * @param framePerSecond The frames per second of the animation
  123220. * @param dataType The data type of the animation
  123221. * @param loopMode The loop mode of the animation
  123222. * @param enableBlending Specifies if blending should be enabled
  123223. */
  123224. constructor(
  123225. /**Name of the animation */
  123226. name: string,
  123227. /**Property to animate */
  123228. targetProperty: string,
  123229. /**The frames per second of the animation */
  123230. framePerSecond: number,
  123231. /**The data type of the animation */
  123232. dataType: number,
  123233. /**The loop mode of the animation */
  123234. loopMode?: number | undefined,
  123235. /**Specifies if blending should be enabled */
  123236. enableBlending?: boolean | undefined);
  123237. /**
  123238. * Converts the animation to a string
  123239. * @param fullDetails support for multiple levels of logging within scene loading
  123240. * @returns String form of the animation
  123241. */
  123242. toString(fullDetails?: boolean): string;
  123243. /**
  123244. * Add an event to this animation
  123245. * @param event Event to add
  123246. */
  123247. addEvent(event: AnimationEvent): void;
  123248. /**
  123249. * Remove all events found at the given frame
  123250. * @param frame The frame to remove events from
  123251. */
  123252. removeEvents(frame: number): void;
  123253. /**
  123254. * Retrieves all the events from the animation
  123255. * @returns Events from the animation
  123256. */
  123257. getEvents(): AnimationEvent[];
  123258. /**
  123259. * Creates an animation range
  123260. * @param name Name of the animation range
  123261. * @param from Starting frame of the animation range
  123262. * @param to Ending frame of the animation
  123263. */
  123264. createRange(name: string, from: number, to: number): void;
  123265. /**
  123266. * Deletes an animation range by name
  123267. * @param name Name of the animation range to delete
  123268. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  123269. */
  123270. deleteRange(name: string, deleteFrames?: boolean): void;
  123271. /**
  123272. * Gets the animation range by name, or null if not defined
  123273. * @param name Name of the animation range
  123274. * @returns Nullable animation range
  123275. */
  123276. getRange(name: string): Nullable<AnimationRange>;
  123277. /**
  123278. * Gets the key frames from the animation
  123279. * @returns The key frames of the animation
  123280. */
  123281. getKeys(): Array<IAnimationKey>;
  123282. /**
  123283. * Gets the highest frame rate of the animation
  123284. * @returns Highest frame rate of the animation
  123285. */
  123286. getHighestFrame(): number;
  123287. /**
  123288. * Gets the easing function of the animation
  123289. * @returns Easing function of the animation
  123290. */
  123291. getEasingFunction(): IEasingFunction;
  123292. /**
  123293. * Sets the easing function of the animation
  123294. * @param easingFunction A custom mathematical formula for animation
  123295. */
  123296. setEasingFunction(easingFunction: EasingFunction): void;
  123297. /**
  123298. * Interpolates a scalar linearly
  123299. * @param startValue Start value of the animation curve
  123300. * @param endValue End value of the animation curve
  123301. * @param gradient Scalar amount to interpolate
  123302. * @returns Interpolated scalar value
  123303. */
  123304. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  123305. /**
  123306. * Interpolates a scalar cubically
  123307. * @param startValue Start value of the animation curve
  123308. * @param outTangent End tangent of the animation
  123309. * @param endValue End value of the animation curve
  123310. * @param inTangent Start tangent of the animation curve
  123311. * @param gradient Scalar amount to interpolate
  123312. * @returns Interpolated scalar value
  123313. */
  123314. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  123315. /**
  123316. * Interpolates a quaternion using a spherical linear interpolation
  123317. * @param startValue Start value of the animation curve
  123318. * @param endValue End value of the animation curve
  123319. * @param gradient Scalar amount to interpolate
  123320. * @returns Interpolated quaternion value
  123321. */
  123322. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  123323. /**
  123324. * Interpolates a quaternion cubically
  123325. * @param startValue Start value of the animation curve
  123326. * @param outTangent End tangent of the animation curve
  123327. * @param endValue End value of the animation curve
  123328. * @param inTangent Start tangent of the animation curve
  123329. * @param gradient Scalar amount to interpolate
  123330. * @returns Interpolated quaternion value
  123331. */
  123332. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  123333. /**
  123334. * Interpolates a Vector3 linearly
  123335. * @param startValue Start value of the animation curve
  123336. * @param endValue End value of the animation curve
  123337. * @param gradient Scalar amount to interpolate
  123338. * @returns Interpolated scalar value
  123339. */
  123340. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  123341. /**
  123342. * Interpolates a Vector3 cubically
  123343. * @param startValue Start value of the animation curve
  123344. * @param outTangent End tangent of the animation
  123345. * @param endValue End value of the animation curve
  123346. * @param inTangent Start tangent of the animation curve
  123347. * @param gradient Scalar amount to interpolate
  123348. * @returns InterpolatedVector3 value
  123349. */
  123350. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  123351. /**
  123352. * Interpolates a Vector2 linearly
  123353. * @param startValue Start value of the animation curve
  123354. * @param endValue End value of the animation curve
  123355. * @param gradient Scalar amount to interpolate
  123356. * @returns Interpolated Vector2 value
  123357. */
  123358. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  123359. /**
  123360. * Interpolates a Vector2 cubically
  123361. * @param startValue Start value of the animation curve
  123362. * @param outTangent End tangent of the animation
  123363. * @param endValue End value of the animation curve
  123364. * @param inTangent Start tangent of the animation curve
  123365. * @param gradient Scalar amount to interpolate
  123366. * @returns Interpolated Vector2 value
  123367. */
  123368. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  123369. /**
  123370. * Interpolates a size linearly
  123371. * @param startValue Start value of the animation curve
  123372. * @param endValue End value of the animation curve
  123373. * @param gradient Scalar amount to interpolate
  123374. * @returns Interpolated Size value
  123375. */
  123376. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  123377. /**
  123378. * Interpolates a Color3 linearly
  123379. * @param startValue Start value of the animation curve
  123380. * @param endValue End value of the animation curve
  123381. * @param gradient Scalar amount to interpolate
  123382. * @returns Interpolated Color3 value
  123383. */
  123384. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  123385. /**
  123386. * Interpolates a Color4 linearly
  123387. * @param startValue Start value of the animation curve
  123388. * @param endValue End value of the animation curve
  123389. * @param gradient Scalar amount to interpolate
  123390. * @returns Interpolated Color3 value
  123391. */
  123392. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  123393. /**
  123394. * @hidden Internal use only
  123395. */
  123396. _getKeyValue(value: any): any;
  123397. /**
  123398. * @hidden Internal use only
  123399. */
  123400. _interpolate(currentFrame: number, state: _IAnimationState): any;
  123401. /**
  123402. * Defines the function to use to interpolate matrices
  123403. * @param startValue defines the start matrix
  123404. * @param endValue defines the end matrix
  123405. * @param gradient defines the gradient between both matrices
  123406. * @param result defines an optional target matrix where to store the interpolation
  123407. * @returns the interpolated matrix
  123408. */
  123409. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  123410. /**
  123411. * Makes a copy of the animation
  123412. * @returns Cloned animation
  123413. */
  123414. clone(): Animation;
  123415. /**
  123416. * Sets the key frames of the animation
  123417. * @param values The animation key frames to set
  123418. */
  123419. setKeys(values: Array<IAnimationKey>): void;
  123420. /**
  123421. * Serializes the animation to an object
  123422. * @returns Serialized object
  123423. */
  123424. serialize(): any;
  123425. /**
  123426. * Float animation type
  123427. */
  123428. static readonly ANIMATIONTYPE_FLOAT: number;
  123429. /**
  123430. * Vector3 animation type
  123431. */
  123432. static readonly ANIMATIONTYPE_VECTOR3: number;
  123433. /**
  123434. * Quaternion animation type
  123435. */
  123436. static readonly ANIMATIONTYPE_QUATERNION: number;
  123437. /**
  123438. * Matrix animation type
  123439. */
  123440. static readonly ANIMATIONTYPE_MATRIX: number;
  123441. /**
  123442. * Color3 animation type
  123443. */
  123444. static readonly ANIMATIONTYPE_COLOR3: number;
  123445. /**
  123446. * Color3 animation type
  123447. */
  123448. static readonly ANIMATIONTYPE_COLOR4: number;
  123449. /**
  123450. * Vector2 animation type
  123451. */
  123452. static readonly ANIMATIONTYPE_VECTOR2: number;
  123453. /**
  123454. * Size animation type
  123455. */
  123456. static readonly ANIMATIONTYPE_SIZE: number;
  123457. /**
  123458. * Relative Loop Mode
  123459. */
  123460. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  123461. /**
  123462. * Cycle Loop Mode
  123463. */
  123464. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  123465. /**
  123466. * Constant Loop Mode
  123467. */
  123468. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  123469. /** @hidden */
  123470. static _UniversalLerp(left: any, right: any, amount: number): any;
  123471. /**
  123472. * Parses an animation object and creates an animation
  123473. * @param parsedAnimation Parsed animation object
  123474. * @returns Animation object
  123475. */
  123476. static Parse(parsedAnimation: any): Animation;
  123477. /**
  123478. * Appends the serialized animations from the source animations
  123479. * @param source Source containing the animations
  123480. * @param destination Target to store the animations
  123481. */
  123482. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  123483. /**
  123484. * Creates a new animation or an array of animations from a snippet saved in a remote file
  123485. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  123486. * @param url defines the url to load from
  123487. * @returns a promise that will resolve to the new animation or an array of animations
  123488. */
  123489. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  123490. /**
  123491. * Creates an animation or an array of animations from a snippet saved by the Inspector
  123492. * @param snippetId defines the snippet to load
  123493. * @returns a promise that will resolve to the new animation or a new array of animations
  123494. */
  123495. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  123496. }
  123497. }
  123498. declare module BABYLON {
  123499. /**
  123500. * Interface containing an array of animations
  123501. */
  123502. export interface IAnimatable {
  123503. /**
  123504. * Array of animations
  123505. */
  123506. animations: Nullable<Array<Animation>>;
  123507. }
  123508. }
  123509. declare module BABYLON {
  123510. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  123511. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123512. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123513. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123514. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123515. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123516. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123517. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123518. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123519. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123520. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123521. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123522. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123523. /**
  123524. * Decorator used to define property that can be serialized as reference to a camera
  123525. * @param sourceName defines the name of the property to decorate
  123526. */
  123527. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  123528. /**
  123529. * Class used to help serialization objects
  123530. */
  123531. export class SerializationHelper {
  123532. /** @hidden */
  123533. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  123534. /** @hidden */
  123535. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  123536. /** @hidden */
  123537. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  123538. /** @hidden */
  123539. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  123540. /**
  123541. * Appends the serialized animations from the source animations
  123542. * @param source Source containing the animations
  123543. * @param destination Target to store the animations
  123544. */
  123545. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  123546. /**
  123547. * Static function used to serialized a specific entity
  123548. * @param entity defines the entity to serialize
  123549. * @param serializationObject defines the optional target object where serialization data will be stored
  123550. * @returns a JSON compatible object representing the serialization of the entity
  123551. */
  123552. static Serialize<T>(entity: T, serializationObject?: any): any;
  123553. /**
  123554. * Creates a new entity from a serialization data object
  123555. * @param creationFunction defines a function used to instanciated the new entity
  123556. * @param source defines the source serialization data
  123557. * @param scene defines the hosting scene
  123558. * @param rootUrl defines the root url for resources
  123559. * @returns a new entity
  123560. */
  123561. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  123562. /**
  123563. * Clones an object
  123564. * @param creationFunction defines the function used to instanciate the new object
  123565. * @param source defines the source object
  123566. * @returns the cloned object
  123567. */
  123568. static Clone<T>(creationFunction: () => T, source: T): T;
  123569. /**
  123570. * Instanciates a new object based on a source one (some data will be shared between both object)
  123571. * @param creationFunction defines the function used to instanciate the new object
  123572. * @param source defines the source object
  123573. * @returns the new object
  123574. */
  123575. static Instanciate<T>(creationFunction: () => T, source: T): T;
  123576. }
  123577. }
  123578. declare module BABYLON {
  123579. /**
  123580. * This is the base class of all the camera used in the application.
  123581. * @see https://doc.babylonjs.com/features/cameras
  123582. */
  123583. export class Camera extends Node {
  123584. /** @hidden */
  123585. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  123586. /**
  123587. * This is the default projection mode used by the cameras.
  123588. * It helps recreating a feeling of perspective and better appreciate depth.
  123589. * This is the best way to simulate real life cameras.
  123590. */
  123591. static readonly PERSPECTIVE_CAMERA: number;
  123592. /**
  123593. * This helps creating camera with an orthographic mode.
  123594. * 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.
  123595. */
  123596. static readonly ORTHOGRAPHIC_CAMERA: number;
  123597. /**
  123598. * This is the default FOV mode for perspective cameras.
  123599. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  123600. */
  123601. static readonly FOVMODE_VERTICAL_FIXED: number;
  123602. /**
  123603. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  123604. */
  123605. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  123606. /**
  123607. * This specifies there is no need for a camera rig.
  123608. * Basically only one eye is rendered corresponding to the camera.
  123609. */
  123610. static readonly RIG_MODE_NONE: number;
  123611. /**
  123612. * Simulates a camera Rig with one blue eye and one red eye.
  123613. * This can be use with 3d blue and red glasses.
  123614. */
  123615. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  123616. /**
  123617. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  123618. */
  123619. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  123620. /**
  123621. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  123622. */
  123623. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  123624. /**
  123625. * Defines that both eyes of the camera will be rendered over under each other.
  123626. */
  123627. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  123628. /**
  123629. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  123630. */
  123631. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  123632. /**
  123633. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  123634. */
  123635. static readonly RIG_MODE_VR: number;
  123636. /**
  123637. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  123638. */
  123639. static readonly RIG_MODE_WEBVR: number;
  123640. /**
  123641. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  123642. */
  123643. static readonly RIG_MODE_CUSTOM: number;
  123644. /**
  123645. * Defines if by default attaching controls should prevent the default javascript event to continue.
  123646. */
  123647. static ForceAttachControlToAlwaysPreventDefault: boolean;
  123648. /**
  123649. * Define the input manager associated with the camera.
  123650. */
  123651. inputs: CameraInputsManager<Camera>;
  123652. /** @hidden */
  123653. _position: Vector3;
  123654. /**
  123655. * Define the current local position of the camera in the scene
  123656. */
  123657. get position(): Vector3;
  123658. set position(newPosition: Vector3);
  123659. protected _upVector: Vector3;
  123660. /**
  123661. * The vector the camera should consider as up.
  123662. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  123663. */
  123664. set upVector(vec: Vector3);
  123665. get upVector(): Vector3;
  123666. /**
  123667. * Define the current limit on the left side for an orthographic camera
  123668. * In scene unit
  123669. */
  123670. orthoLeft: Nullable<number>;
  123671. /**
  123672. * Define the current limit on the right side for an orthographic camera
  123673. * In scene unit
  123674. */
  123675. orthoRight: Nullable<number>;
  123676. /**
  123677. * Define the current limit on the bottom side for an orthographic camera
  123678. * In scene unit
  123679. */
  123680. orthoBottom: Nullable<number>;
  123681. /**
  123682. * Define the current limit on the top side for an orthographic camera
  123683. * In scene unit
  123684. */
  123685. orthoTop: Nullable<number>;
  123686. /**
  123687. * Field Of View is set in Radians. (default is 0.8)
  123688. */
  123689. fov: number;
  123690. /**
  123691. * Define the minimum distance the camera can see from.
  123692. * This is important to note that the depth buffer are not infinite and the closer it starts
  123693. * the more your scene might encounter depth fighting issue.
  123694. */
  123695. minZ: number;
  123696. /**
  123697. * Define the maximum distance the camera can see to.
  123698. * This is important to note that the depth buffer are not infinite and the further it end
  123699. * the more your scene might encounter depth fighting issue.
  123700. */
  123701. maxZ: number;
  123702. /**
  123703. * Define the default inertia of the camera.
  123704. * This helps giving a smooth feeling to the camera movement.
  123705. */
  123706. inertia: number;
  123707. /**
  123708. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  123709. */
  123710. mode: number;
  123711. /**
  123712. * Define whether the camera is intermediate.
  123713. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  123714. */
  123715. isIntermediate: boolean;
  123716. /**
  123717. * Define the viewport of the camera.
  123718. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  123719. */
  123720. viewport: Viewport;
  123721. /**
  123722. * Restricts the camera to viewing objects with the same layerMask.
  123723. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  123724. */
  123725. layerMask: number;
  123726. /**
  123727. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  123728. */
  123729. fovMode: number;
  123730. /**
  123731. * Rig mode of the camera.
  123732. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  123733. * This is normally controlled byt the camera themselves as internal use.
  123734. */
  123735. cameraRigMode: number;
  123736. /**
  123737. * Defines the distance between both "eyes" in case of a RIG
  123738. */
  123739. interaxialDistance: number;
  123740. /**
  123741. * Defines if stereoscopic rendering is done side by side or over under.
  123742. */
  123743. isStereoscopicSideBySide: boolean;
  123744. /**
  123745. * 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
  123746. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  123747. * else in the scene. (Eg. security camera)
  123748. *
  123749. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corresponding to an HMD)
  123750. */
  123751. customRenderTargets: RenderTargetTexture[];
  123752. /**
  123753. * When set, the camera will render to this render target instead of the default canvas
  123754. *
  123755. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  123756. */
  123757. outputRenderTarget: Nullable<RenderTargetTexture>;
  123758. /**
  123759. * Observable triggered when the camera view matrix has changed.
  123760. */
  123761. onViewMatrixChangedObservable: Observable<Camera>;
  123762. /**
  123763. * Observable triggered when the camera Projection matrix has changed.
  123764. */
  123765. onProjectionMatrixChangedObservable: Observable<Camera>;
  123766. /**
  123767. * Observable triggered when the inputs have been processed.
  123768. */
  123769. onAfterCheckInputsObservable: Observable<Camera>;
  123770. /**
  123771. * Observable triggered when reset has been called and applied to the camera.
  123772. */
  123773. onRestoreStateObservable: Observable<Camera>;
  123774. /**
  123775. * Is this camera a part of a rig system?
  123776. */
  123777. isRigCamera: boolean;
  123778. /**
  123779. * If isRigCamera set to true this will be set with the parent camera.
  123780. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  123781. */
  123782. rigParent?: Camera;
  123783. /** @hidden */
  123784. _cameraRigParams: any;
  123785. /** @hidden */
  123786. _rigCameras: Camera[];
  123787. /** @hidden */
  123788. _rigPostProcess: Nullable<PostProcess>;
  123789. protected _webvrViewMatrix: Matrix;
  123790. /** @hidden */
  123791. _skipRendering: boolean;
  123792. /** @hidden */
  123793. _projectionMatrix: Matrix;
  123794. /** @hidden */
  123795. _postProcesses: Nullable<PostProcess>[];
  123796. /** @hidden */
  123797. _activeMeshes: SmartArray<AbstractMesh>;
  123798. protected _globalPosition: Vector3;
  123799. /** @hidden */
  123800. _computedViewMatrix: Matrix;
  123801. private _doNotComputeProjectionMatrix;
  123802. private _transformMatrix;
  123803. private _frustumPlanes;
  123804. private _refreshFrustumPlanes;
  123805. private _storedFov;
  123806. private _stateStored;
  123807. /**
  123808. * Instantiates a new camera object.
  123809. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  123810. * @see https://doc.babylonjs.com/features/cameras
  123811. * @param name Defines the name of the camera in the scene
  123812. * @param position Defines the position of the camera
  123813. * @param scene Defines the scene the camera belongs too
  123814. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  123815. */
  123816. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123817. /**
  123818. * Store current camera state (fov, position, etc..)
  123819. * @returns the camera
  123820. */
  123821. storeState(): Camera;
  123822. /**
  123823. * Restores the camera state values if it has been stored. You must call storeState() first
  123824. */
  123825. protected _restoreStateValues(): boolean;
  123826. /**
  123827. * Restored camera state. You must call storeState() first.
  123828. * @returns true if restored and false otherwise
  123829. */
  123830. restoreState(): boolean;
  123831. /**
  123832. * Gets the class name of the camera.
  123833. * @returns the class name
  123834. */
  123835. getClassName(): string;
  123836. /** @hidden */
  123837. readonly _isCamera: boolean;
  123838. /**
  123839. * Gets a string representation of the camera useful for debug purpose.
  123840. * @param fullDetails Defines that a more verboe level of logging is required
  123841. * @returns the string representation
  123842. */
  123843. toString(fullDetails?: boolean): string;
  123844. /**
  123845. * Gets the current world space position of the camera.
  123846. */
  123847. get globalPosition(): Vector3;
  123848. /**
  123849. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  123850. * @returns the active meshe list
  123851. */
  123852. getActiveMeshes(): SmartArray<AbstractMesh>;
  123853. /**
  123854. * Check whether a mesh is part of the current active mesh list of the camera
  123855. * @param mesh Defines the mesh to check
  123856. * @returns true if active, false otherwise
  123857. */
  123858. isActiveMesh(mesh: Mesh): boolean;
  123859. /**
  123860. * Is this camera ready to be used/rendered
  123861. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  123862. * @return true if the camera is ready
  123863. */
  123864. isReady(completeCheck?: boolean): boolean;
  123865. /** @hidden */
  123866. _initCache(): void;
  123867. /** @hidden */
  123868. _updateCache(ignoreParentClass?: boolean): void;
  123869. /** @hidden */
  123870. _isSynchronized(): boolean;
  123871. /** @hidden */
  123872. _isSynchronizedViewMatrix(): boolean;
  123873. /** @hidden */
  123874. _isSynchronizedProjectionMatrix(): boolean;
  123875. /**
  123876. * Attach the input controls to a specific dom element to get the input from.
  123877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123878. */
  123879. attachControl(noPreventDefault?: boolean): void;
  123880. /**
  123881. * Attach the input controls to a specific dom element to get the input from.
  123882. * @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
  123883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123884. * BACK COMPAT SIGNATURE ONLY.
  123885. */
  123886. attachControl(ignored: any, noPreventDefault?: boolean): void;
  123887. /**
  123888. * Detach the current controls from the specified dom element.
  123889. */
  123890. detachControl(): void;
  123891. /**
  123892. * Detach the current controls from the specified dom element.
  123893. * @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
  123894. */
  123895. detachControl(ignored: any): void;
  123896. /**
  123897. * Update the camera state according to the different inputs gathered during the frame.
  123898. */
  123899. update(): void;
  123900. /** @hidden */
  123901. _checkInputs(): void;
  123902. /** @hidden */
  123903. get rigCameras(): Camera[];
  123904. /**
  123905. * Gets the post process used by the rig cameras
  123906. */
  123907. get rigPostProcess(): Nullable<PostProcess>;
  123908. /**
  123909. * Internal, gets the first post process.
  123910. * @returns the first post process to be run on this camera.
  123911. */
  123912. _getFirstPostProcess(): Nullable<PostProcess>;
  123913. private _cascadePostProcessesToRigCams;
  123914. /**
  123915. * Attach a post process to the camera.
  123916. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  123917. * @param postProcess The post process to attach to the camera
  123918. * @param insertAt The position of the post process in case several of them are in use in the scene
  123919. * @returns the position the post process has been inserted at
  123920. */
  123921. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  123922. /**
  123923. * Detach a post process to the camera.
  123924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  123925. * @param postProcess The post process to detach from the camera
  123926. */
  123927. detachPostProcess(postProcess: PostProcess): void;
  123928. /**
  123929. * Gets the current world matrix of the camera
  123930. */
  123931. getWorldMatrix(): Matrix;
  123932. /** @hidden */
  123933. _getViewMatrix(): Matrix;
  123934. /**
  123935. * Gets the current view matrix of the camera.
  123936. * @param force forces the camera to recompute the matrix without looking at the cached state
  123937. * @returns the view matrix
  123938. */
  123939. getViewMatrix(force?: boolean): Matrix;
  123940. /**
  123941. * Freeze the projection matrix.
  123942. * It will prevent the cache check of the camera projection compute and can speed up perf
  123943. * if no parameter of the camera are meant to change
  123944. * @param projection Defines manually a projection if necessary
  123945. */
  123946. freezeProjectionMatrix(projection?: Matrix): void;
  123947. /**
  123948. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  123949. */
  123950. unfreezeProjectionMatrix(): void;
  123951. /**
  123952. * Gets the current projection matrix of the camera.
  123953. * @param force forces the camera to recompute the matrix without looking at the cached state
  123954. * @returns the projection matrix
  123955. */
  123956. getProjectionMatrix(force?: boolean): Matrix;
  123957. /**
  123958. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  123959. * @returns a Matrix
  123960. */
  123961. getTransformationMatrix(): Matrix;
  123962. private _updateFrustumPlanes;
  123963. /**
  123964. * Checks if a cullable object (mesh...) is in the camera frustum
  123965. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  123966. * @param target The object to check
  123967. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  123968. * @returns true if the object is in frustum otherwise false
  123969. */
  123970. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  123971. /**
  123972. * Checks if a cullable object (mesh...) is in the camera frustum
  123973. * Unlike isInFrustum this checks the full bounding box
  123974. * @param target The object to check
  123975. * @returns true if the object is in frustum otherwise false
  123976. */
  123977. isCompletelyInFrustum(target: ICullable): boolean;
  123978. /**
  123979. * Gets a ray in the forward direction from the camera.
  123980. * @param length Defines the length of the ray to create
  123981. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  123982. * @param origin Defines the start point of the ray which defaults to the camera position
  123983. * @returns the forward ray
  123984. */
  123985. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  123986. /**
  123987. * Gets a ray in the forward direction from the camera.
  123988. * @param refRay the ray to (re)use when setting the values
  123989. * @param length Defines the length of the ray to create
  123990. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  123991. * @param origin Defines the start point of the ray which defaults to the camera position
  123992. * @returns the forward ray
  123993. */
  123994. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  123995. /**
  123996. * Releases resources associated with this node.
  123997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123999. */
  124000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124001. /** @hidden */
  124002. _isLeftCamera: boolean;
  124003. /**
  124004. * Gets the left camera of a rig setup in case of Rigged Camera
  124005. */
  124006. get isLeftCamera(): boolean;
  124007. /** @hidden */
  124008. _isRightCamera: boolean;
  124009. /**
  124010. * Gets the right camera of a rig setup in case of Rigged Camera
  124011. */
  124012. get isRightCamera(): boolean;
  124013. /**
  124014. * Gets the left camera of a rig setup in case of Rigged Camera
  124015. */
  124016. get leftCamera(): Nullable<FreeCamera>;
  124017. /**
  124018. * Gets the right camera of a rig setup in case of Rigged Camera
  124019. */
  124020. get rightCamera(): Nullable<FreeCamera>;
  124021. /**
  124022. * Gets the left camera target of a rig setup in case of Rigged Camera
  124023. * @returns the target position
  124024. */
  124025. getLeftTarget(): Nullable<Vector3>;
  124026. /**
  124027. * Gets the right camera target of a rig setup in case of Rigged Camera
  124028. * @returns the target position
  124029. */
  124030. getRightTarget(): Nullable<Vector3>;
  124031. /**
  124032. * @hidden
  124033. */
  124034. setCameraRigMode(mode: number, rigParams: any): void;
  124035. /** @hidden */
  124036. static _setStereoscopicRigMode(camera: Camera): void;
  124037. /** @hidden */
  124038. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  124039. /** @hidden */
  124040. static _setVRRigMode(camera: Camera, rigParams: any): void;
  124041. /** @hidden */
  124042. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  124043. /** @hidden */
  124044. _getVRProjectionMatrix(): Matrix;
  124045. protected _updateCameraRotationMatrix(): void;
  124046. protected _updateWebVRCameraRotationMatrix(): void;
  124047. /**
  124048. * This function MUST be overwritten by the different WebVR cameras available.
  124049. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  124050. * @hidden
  124051. */
  124052. _getWebVRProjectionMatrix(): Matrix;
  124053. /**
  124054. * This function MUST be overwritten by the different WebVR cameras available.
  124055. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  124056. * @hidden
  124057. */
  124058. _getWebVRViewMatrix(): Matrix;
  124059. /** @hidden */
  124060. setCameraRigParameter(name: string, value: any): void;
  124061. /**
  124062. * needs to be overridden by children so sub has required properties to be copied
  124063. * @hidden
  124064. */
  124065. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  124066. /**
  124067. * May need to be overridden by children
  124068. * @hidden
  124069. */
  124070. _updateRigCameras(): void;
  124071. /** @hidden */
  124072. _setupInputs(): void;
  124073. /**
  124074. * Serialiaze the camera setup to a json representation
  124075. * @returns the JSON representation
  124076. */
  124077. serialize(): any;
  124078. /**
  124079. * Clones the current camera.
  124080. * @param name The cloned camera name
  124081. * @returns the cloned camera
  124082. */
  124083. clone(name: string): Camera;
  124084. /**
  124085. * Gets the direction of the camera relative to a given local axis.
  124086. * @param localAxis Defines the reference axis to provide a relative direction.
  124087. * @return the direction
  124088. */
  124089. getDirection(localAxis: Vector3): Vector3;
  124090. /**
  124091. * Returns the current camera absolute rotation
  124092. */
  124093. get absoluteRotation(): Quaternion;
  124094. /**
  124095. * Gets the direction of the camera relative to a given local axis into a passed vector.
  124096. * @param localAxis Defines the reference axis to provide a relative direction.
  124097. * @param result Defines the vector to store the result in
  124098. */
  124099. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  124100. /**
  124101. * Gets a camera constructor for a given camera type
  124102. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  124103. * @param name The name of the camera the result will be able to instantiate
  124104. * @param scene The scene the result will construct the camera in
  124105. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  124106. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  124107. * @returns a factory method to construct the camera
  124108. */
  124109. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  124110. /**
  124111. * Compute the world matrix of the camera.
  124112. * @returns the camera world matrix
  124113. */
  124114. computeWorldMatrix(): Matrix;
  124115. /**
  124116. * Parse a JSON and creates the camera from the parsed information
  124117. * @param parsedCamera The JSON to parse
  124118. * @param scene The scene to instantiate the camera in
  124119. * @returns the newly constructed camera
  124120. */
  124121. static Parse(parsedCamera: any, scene: Scene): Camera;
  124122. }
  124123. }
  124124. declare module BABYLON {
  124125. /**
  124126. * PostProcessManager is used to manage one or more post processes or post process pipelines
  124127. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124128. */
  124129. export class PostProcessManager {
  124130. private _scene;
  124131. private _indexBuffer;
  124132. private _vertexBuffers;
  124133. /**
  124134. * Creates a new instance PostProcess
  124135. * @param scene The scene that the post process is associated with.
  124136. */
  124137. constructor(scene: Scene);
  124138. private _prepareBuffers;
  124139. private _buildIndexBuffer;
  124140. /**
  124141. * Rebuilds the vertex buffers of the manager.
  124142. * @hidden
  124143. */
  124144. _rebuild(): void;
  124145. /**
  124146. * Prepares a frame to be run through a post process.
  124147. * @param sourceTexture The input texture to the post processes. (default: null)
  124148. * @param postProcesses An array of post processes to be run. (default: null)
  124149. * @returns True if the post processes were able to be run.
  124150. * @hidden
  124151. */
  124152. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  124153. /**
  124154. * Manually render a set of post processes to a texture.
  124155. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  124156. * @param postProcesses An array of post processes to be run.
  124157. * @param targetTexture The target texture to render to.
  124158. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  124159. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  124160. * @param lodLevel defines which lod of the texture to render to
  124161. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  124162. */
  124163. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  124164. /**
  124165. * Finalize the result of the output of the postprocesses.
  124166. * @param doNotPresent If true the result will not be displayed to the screen.
  124167. * @param targetTexture The target texture to render to.
  124168. * @param faceIndex The index of the face to bind the target texture to.
  124169. * @param postProcesses The array of post processes to render.
  124170. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  124171. * @hidden
  124172. */
  124173. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  124174. /**
  124175. * Disposes of the post process manager.
  124176. */
  124177. dispose(): void;
  124178. }
  124179. }
  124180. declare module BABYLON {
  124181. /**
  124182. * This Helps creating a texture that will be created from a camera in your scene.
  124183. * It is basically a dynamic texture that could be used to create special effects for instance.
  124184. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  124185. */
  124186. export class RenderTargetTexture extends Texture {
  124187. /**
  124188. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  124189. */
  124190. static readonly REFRESHRATE_RENDER_ONCE: number;
  124191. /**
  124192. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  124193. */
  124194. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  124195. /**
  124196. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  124197. * the central point of your effect and can save a lot of performances.
  124198. */
  124199. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  124200. /**
  124201. * Use this predicate to dynamically define the list of mesh you want to render.
  124202. * If set, the renderList property will be overwritten.
  124203. */
  124204. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  124205. private _renderList;
  124206. /**
  124207. * Use this list to define the list of mesh you want to render.
  124208. */
  124209. get renderList(): Nullable<Array<AbstractMesh>>;
  124210. set renderList(value: Nullable<Array<AbstractMesh>>);
  124211. /**
  124212. * Use this function to overload the renderList array at rendering time.
  124213. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  124214. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  124215. * the cube (if the RTT is a cube, else layerOrFace=0).
  124216. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  124217. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  124218. * hold dummy elements!
  124219. */
  124220. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  124221. private _hookArray;
  124222. /**
  124223. * Define if particles should be rendered in your texture.
  124224. */
  124225. renderParticles: boolean;
  124226. /**
  124227. * Define if sprites should be rendered in your texture.
  124228. */
  124229. renderSprites: boolean;
  124230. /**
  124231. * Define the camera used to render the texture.
  124232. */
  124233. activeCamera: Nullable<Camera>;
  124234. /**
  124235. * Override the mesh isReady function with your own one.
  124236. */
  124237. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  124238. /**
  124239. * Override the render function of the texture with your own one.
  124240. */
  124241. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  124242. /**
  124243. * Define if camera post processes should be use while rendering the texture.
  124244. */
  124245. useCameraPostProcesses: boolean;
  124246. /**
  124247. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  124248. */
  124249. ignoreCameraViewport: boolean;
  124250. private _postProcessManager;
  124251. /**
  124252. * Post-processes for this render target
  124253. */
  124254. get postProcesses(): PostProcess[];
  124255. private _postProcesses;
  124256. private _resizeObserver;
  124257. private get _prePassEnabled();
  124258. /**
  124259. * An event triggered when the texture is unbind.
  124260. */
  124261. onBeforeBindObservable: Observable<RenderTargetTexture>;
  124262. /**
  124263. * An event triggered when the texture is unbind.
  124264. */
  124265. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  124266. private _onAfterUnbindObserver;
  124267. /**
  124268. * Set a after unbind callback in the texture.
  124269. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  124270. */
  124271. set onAfterUnbind(callback: () => void);
  124272. /**
  124273. * An event triggered before rendering the texture
  124274. */
  124275. onBeforeRenderObservable: Observable<number>;
  124276. private _onBeforeRenderObserver;
  124277. /**
  124278. * Set a before render callback in the texture.
  124279. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  124280. */
  124281. set onBeforeRender(callback: (faceIndex: number) => void);
  124282. /**
  124283. * An event triggered after rendering the texture
  124284. */
  124285. onAfterRenderObservable: Observable<number>;
  124286. private _onAfterRenderObserver;
  124287. /**
  124288. * Set a after render callback in the texture.
  124289. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  124290. */
  124291. set onAfterRender(callback: (faceIndex: number) => void);
  124292. /**
  124293. * An event triggered after the texture clear
  124294. */
  124295. onClearObservable: Observable<Engine>;
  124296. private _onClearObserver;
  124297. /**
  124298. * Set a clear callback in the texture.
  124299. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  124300. */
  124301. set onClear(callback: (Engine: Engine) => void);
  124302. /**
  124303. * An event triggered when the texture is resized.
  124304. */
  124305. onResizeObservable: Observable<RenderTargetTexture>;
  124306. /**
  124307. * Define the clear color of the Render Target if it should be different from the scene.
  124308. */
  124309. clearColor: Color4;
  124310. protected _size: number | {
  124311. width: number;
  124312. height: number;
  124313. layers?: number;
  124314. };
  124315. protected _initialSizeParameter: number | {
  124316. width: number;
  124317. height: number;
  124318. } | {
  124319. ratio: number;
  124320. };
  124321. protected _sizeRatio: Nullable<number>;
  124322. /** @hidden */
  124323. _generateMipMaps: boolean;
  124324. protected _renderingManager: RenderingManager;
  124325. /** @hidden */
  124326. _waitingRenderList?: string[];
  124327. protected _doNotChangeAspectRatio: boolean;
  124328. protected _currentRefreshId: number;
  124329. protected _refreshRate: number;
  124330. protected _textureMatrix: Matrix;
  124331. protected _samples: number;
  124332. protected _renderTargetOptions: RenderTargetCreationOptions;
  124333. /**
  124334. * Gets render target creation options that were used.
  124335. */
  124336. get renderTargetOptions(): RenderTargetCreationOptions;
  124337. protected _onRatioRescale(): void;
  124338. /**
  124339. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  124340. * It must define where the camera used to render the texture is set
  124341. */
  124342. boundingBoxPosition: Vector3;
  124343. private _boundingBoxSize;
  124344. /**
  124345. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  124346. * When defined, the cubemap will switch to local mode
  124347. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  124348. * @example https://www.babylonjs-playground.com/#RNASML
  124349. */
  124350. set boundingBoxSize(value: Vector3);
  124351. get boundingBoxSize(): Vector3;
  124352. /**
  124353. * In case the RTT has been created with a depth texture, get the associated
  124354. * depth texture.
  124355. * Otherwise, return null.
  124356. */
  124357. get depthStencilTexture(): Nullable<InternalTexture>;
  124358. /**
  124359. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  124360. * or used a shadow, depth texture...
  124361. * @param name The friendly name of the texture
  124362. * @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)
  124363. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  124364. * @param generateMipMaps True if mip maps need to be generated after render.
  124365. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  124366. * @param type The type of the buffer in the RTT (int, half float, float...)
  124367. * @param isCube True if a cube texture needs to be created
  124368. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  124369. * @param generateDepthBuffer True to generate a depth buffer
  124370. * @param generateStencilBuffer True to generate a stencil buffer
  124371. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  124372. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  124373. * @param delayAllocation if the texture allocation should be delayed (default: false)
  124374. * @param samples sample count to use when creating the RTT
  124375. */
  124376. constructor(name: string, size: number | {
  124377. width: number;
  124378. height: number;
  124379. layers?: number;
  124380. } | {
  124381. ratio: number;
  124382. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean, samples?: number);
  124383. /**
  124384. * Creates a depth stencil texture.
  124385. * This is only available in WebGL 2 or with the depth texture extension available.
  124386. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  124387. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  124388. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  124389. * @param samples sample count of the depth/stencil texture
  124390. */
  124391. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  124392. private _processSizeParameter;
  124393. /**
  124394. * Define the number of samples to use in case of MSAA.
  124395. * It defaults to one meaning no MSAA has been enabled.
  124396. */
  124397. get samples(): number;
  124398. set samples(value: number);
  124399. /**
  124400. * Resets the refresh counter of the texture and start bak from scratch.
  124401. * Could be useful to regenerate the texture if it is setup to render only once.
  124402. */
  124403. resetRefreshCounter(): void;
  124404. /**
  124405. * Define the refresh rate of the texture or the rendering frequency.
  124406. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  124407. */
  124408. get refreshRate(): number;
  124409. set refreshRate(value: number);
  124410. /**
  124411. * Adds a post process to the render target rendering passes.
  124412. * @param postProcess define the post process to add
  124413. */
  124414. addPostProcess(postProcess: PostProcess): void;
  124415. /**
  124416. * Clear all the post processes attached to the render target
  124417. * @param dispose define if the cleared post processes should also be disposed (false by default)
  124418. */
  124419. clearPostProcesses(dispose?: boolean): void;
  124420. /**
  124421. * Remove one of the post process from the list of attached post processes to the texture
  124422. * @param postProcess define the post process to remove from the list
  124423. */
  124424. removePostProcess(postProcess: PostProcess): void;
  124425. /** @hidden */
  124426. _shouldRender(): boolean;
  124427. /**
  124428. * Gets the actual render size of the texture.
  124429. * @returns the width of the render size
  124430. */
  124431. getRenderSize(): number;
  124432. /**
  124433. * Gets the actual render width of the texture.
  124434. * @returns the width of the render size
  124435. */
  124436. getRenderWidth(): number;
  124437. /**
  124438. * Gets the actual render height of the texture.
  124439. * @returns the height of the render size
  124440. */
  124441. getRenderHeight(): number;
  124442. /**
  124443. * Gets the actual number of layers of the texture.
  124444. * @returns the number of layers
  124445. */
  124446. getRenderLayers(): number;
  124447. /**
  124448. * Get if the texture can be rescaled or not.
  124449. */
  124450. get canRescale(): boolean;
  124451. /**
  124452. * Resize the texture using a ratio.
  124453. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  124454. */
  124455. scale(ratio: number): void;
  124456. /**
  124457. * Get the texture reflection matrix used to rotate/transform the reflection.
  124458. * @returns the reflection matrix
  124459. */
  124460. getReflectionTextureMatrix(): Matrix;
  124461. /**
  124462. * Resize the texture to a new desired size.
  124463. * Be careful as it will recreate all the data in the new texture.
  124464. * @param size Define the new size. It can be:
  124465. * - a number for squared texture,
  124466. * - an object containing { width: number, height: number }
  124467. * - or an object containing a ratio { ratio: number }
  124468. */
  124469. resize(size: number | {
  124470. width: number;
  124471. height: number;
  124472. } | {
  124473. ratio: number;
  124474. }): void;
  124475. private _defaultRenderListPrepared;
  124476. /**
  124477. * Renders all the objects from the render list into the texture.
  124478. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  124479. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  124480. */
  124481. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  124482. private _bestReflectionRenderTargetDimension;
  124483. private _prepareRenderingManager;
  124484. /**
  124485. * @hidden
  124486. * @param faceIndex face index to bind to if this is a cubetexture
  124487. * @param layer defines the index of the texture to bind in the array
  124488. */
  124489. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  124490. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  124491. /**
  124492. * @hidden
  124493. */
  124494. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  124495. private renderToTarget;
  124496. /**
  124497. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  124498. * This allowed control for front to back rendering or reversely depending of the special needs.
  124499. *
  124500. * @param renderingGroupId The rendering group id corresponding to its index
  124501. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  124502. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  124503. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  124504. */
  124505. 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;
  124506. /**
  124507. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  124508. *
  124509. * @param renderingGroupId The rendering group id corresponding to its index
  124510. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124511. */
  124512. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124513. /**
  124514. * Clones the texture.
  124515. * @returns the cloned texture
  124516. */
  124517. clone(): RenderTargetTexture;
  124518. /**
  124519. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  124520. * @returns The JSON representation of the texture
  124521. */
  124522. serialize(): any;
  124523. /**
  124524. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  124525. */
  124526. disposeFramebufferObjects(): void;
  124527. /**
  124528. * Dispose the texture and release its associated resources.
  124529. */
  124530. dispose(): void;
  124531. /** @hidden */
  124532. _rebuild(): void;
  124533. /**
  124534. * Clear the info related to rendering groups preventing retention point in material dispose.
  124535. */
  124536. freeRenderingGroups(): void;
  124537. /**
  124538. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  124539. * @returns the view count
  124540. */
  124541. getViewCount(): number;
  124542. }
  124543. }
  124544. declare module BABYLON {
  124545. /**
  124546. * Options to be used when creating an effect.
  124547. */
  124548. export interface IEffectCreationOptions {
  124549. /**
  124550. * Attributes that will be used in the shader.
  124551. */
  124552. attributes: string[];
  124553. /**
  124554. * Uniform variable names that will be set in the shader.
  124555. */
  124556. uniformsNames: string[];
  124557. /**
  124558. * Uniform buffer variable names that will be set in the shader.
  124559. */
  124560. uniformBuffersNames: string[];
  124561. /**
  124562. * Sampler texture variable names that will be set in the shader.
  124563. */
  124564. samplers: string[];
  124565. /**
  124566. * Define statements that will be set in the shader.
  124567. */
  124568. defines: any;
  124569. /**
  124570. * Possible fallbacks for this effect to improve performance when needed.
  124571. */
  124572. fallbacks: Nullable<IEffectFallbacks>;
  124573. /**
  124574. * Callback that will be called when the shader is compiled.
  124575. */
  124576. onCompiled: Nullable<(effect: Effect) => void>;
  124577. /**
  124578. * Callback that will be called if an error occurs during shader compilation.
  124579. */
  124580. onError: Nullable<(effect: Effect, errors: string) => void>;
  124581. /**
  124582. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  124583. */
  124584. indexParameters?: any;
  124585. /**
  124586. * Max number of lights that can be used in the shader.
  124587. */
  124588. maxSimultaneousLights?: number;
  124589. /**
  124590. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  124591. */
  124592. transformFeedbackVaryings?: Nullable<string[]>;
  124593. /**
  124594. * 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
  124595. */
  124596. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  124597. /**
  124598. * Is this effect rendering to several color attachments ?
  124599. */
  124600. multiTarget?: boolean;
  124601. }
  124602. /**
  124603. * Effect containing vertex and fragment shader that can be executed on an object.
  124604. */
  124605. export class Effect implements IDisposable {
  124606. /**
  124607. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  124608. */
  124609. static ShadersRepository: string;
  124610. /**
  124611. * Enable logging of the shader code when a compilation error occurs
  124612. */
  124613. static LogShaderCodeOnCompilationError: boolean;
  124614. /**
  124615. * Name of the effect.
  124616. */
  124617. name: any;
  124618. /**
  124619. * String container all the define statements that should be set on the shader.
  124620. */
  124621. defines: string;
  124622. /**
  124623. * Callback that will be called when the shader is compiled.
  124624. */
  124625. onCompiled: Nullable<(effect: Effect) => void>;
  124626. /**
  124627. * Callback that will be called if an error occurs during shader compilation.
  124628. */
  124629. onError: Nullable<(effect: Effect, errors: string) => void>;
  124630. /**
  124631. * Callback that will be called when effect is bound.
  124632. */
  124633. onBind: Nullable<(effect: Effect) => void>;
  124634. /**
  124635. * Unique ID of the effect.
  124636. */
  124637. uniqueId: number;
  124638. /**
  124639. * Observable that will be called when the shader is compiled.
  124640. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  124641. */
  124642. onCompileObservable: Observable<Effect>;
  124643. /**
  124644. * Observable that will be called if an error occurs during shader compilation.
  124645. */
  124646. onErrorObservable: Observable<Effect>;
  124647. /** @hidden */
  124648. _onBindObservable: Nullable<Observable<Effect>>;
  124649. /**
  124650. * @hidden
  124651. * Specifies if the effect was previously ready
  124652. */
  124653. _wasPreviouslyReady: boolean;
  124654. /**
  124655. * Observable that will be called when effect is bound.
  124656. */
  124657. get onBindObservable(): Observable<Effect>;
  124658. /** @hidden */
  124659. _bonesComputationForcedToCPU: boolean;
  124660. /** @hidden */
  124661. _uniformBuffersNames: {
  124662. [key: string]: number;
  124663. };
  124664. /** @hidden */
  124665. _samplerList: string[];
  124666. /** @hidden */
  124667. _multiTarget: boolean;
  124668. private static _uniqueIdSeed;
  124669. private _engine;
  124670. private _uniformBuffersNamesList;
  124671. private _uniformsNames;
  124672. private _samplers;
  124673. private _isReady;
  124674. private _compilationError;
  124675. private _allFallbacksProcessed;
  124676. private _attributesNames;
  124677. private _attributes;
  124678. private _attributeLocationByName;
  124679. private _uniforms;
  124680. /**
  124681. * Key for the effect.
  124682. * @hidden
  124683. */
  124684. _key: string;
  124685. private _indexParameters;
  124686. private _fallbacks;
  124687. private _vertexSourceCodeOverride;
  124688. private _fragmentSourceCodeOverride;
  124689. private _transformFeedbackVaryings;
  124690. /**
  124691. * Compiled shader to webGL program.
  124692. * @hidden
  124693. */
  124694. _pipelineContext: Nullable<IPipelineContext>;
  124695. /** @hidden */
  124696. _vertexSourceCode: string;
  124697. /** @hidden */
  124698. _fragmentSourceCode: string;
  124699. /** @hidden */
  124700. private _rawVertexSourceCode;
  124701. /** @hidden */
  124702. private _rawFragmentSourceCode;
  124703. private static _baseCache;
  124704. private _processingContext;
  124705. /**
  124706. * Instantiates an effect.
  124707. * An effect can be used to create/manage/execute vertex and fragment shaders.
  124708. * @param baseName Name of the effect.
  124709. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  124710. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  124711. * @param samplers List of sampler variables that will be passed to the shader.
  124712. * @param engine Engine to be used to render the effect
  124713. * @param defines Define statements to be added to the shader.
  124714. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  124715. * @param onCompiled Callback that will be called when the shader is compiled.
  124716. * @param onError Callback that will be called if an error occurs during shader compilation.
  124717. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  124718. * @param key Effect Key identifying uniquely compiled shader variants
  124719. */
  124720. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any, key?: string);
  124721. private _useFinalCode;
  124722. /**
  124723. * Unique key for this effect
  124724. */
  124725. get key(): string;
  124726. /**
  124727. * If the effect has been compiled and prepared.
  124728. * @returns if the effect is compiled and prepared.
  124729. */
  124730. isReady(): boolean;
  124731. private _isReadyInternal;
  124732. /**
  124733. * The engine the effect was initialized with.
  124734. * @returns the engine.
  124735. */
  124736. getEngine(): Engine;
  124737. /**
  124738. * The pipeline context for this effect
  124739. * @returns the associated pipeline context
  124740. */
  124741. getPipelineContext(): Nullable<IPipelineContext>;
  124742. /**
  124743. * The set of names of attribute variables for the shader.
  124744. * @returns An array of attribute names.
  124745. */
  124746. getAttributesNames(): string[];
  124747. /**
  124748. * Returns the attribute at the given index.
  124749. * @param index The index of the attribute.
  124750. * @returns The location of the attribute.
  124751. */
  124752. getAttributeLocation(index: number): number;
  124753. /**
  124754. * Returns the attribute based on the name of the variable.
  124755. * @param name of the attribute to look up.
  124756. * @returns the attribute location.
  124757. */
  124758. getAttributeLocationByName(name: string): number;
  124759. /**
  124760. * The number of attributes.
  124761. * @returns the number of attributes.
  124762. */
  124763. getAttributesCount(): number;
  124764. /**
  124765. * Gets the index of a uniform variable.
  124766. * @param uniformName of the uniform to look up.
  124767. * @returns the index.
  124768. */
  124769. getUniformIndex(uniformName: string): number;
  124770. /**
  124771. * Returns the attribute based on the name of the variable.
  124772. * @param uniformName of the uniform to look up.
  124773. * @returns the location of the uniform.
  124774. */
  124775. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  124776. /**
  124777. * Returns an array of sampler variable names
  124778. * @returns The array of sampler variable names.
  124779. */
  124780. getSamplers(): string[];
  124781. /**
  124782. * Returns an array of uniform variable names
  124783. * @returns The array of uniform variable names.
  124784. */
  124785. getUniformNames(): string[];
  124786. /**
  124787. * Returns an array of uniform buffer variable names
  124788. * @returns The array of uniform buffer variable names.
  124789. */
  124790. getUniformBuffersNames(): string[];
  124791. /**
  124792. * Returns the index parameters used to create the effect
  124793. * @returns The index parameters object
  124794. */
  124795. getIndexParameters(): any;
  124796. /**
  124797. * The error from the last compilation.
  124798. * @returns the error string.
  124799. */
  124800. getCompilationError(): string;
  124801. /**
  124802. * Gets a boolean indicating that all fallbacks were used during compilation
  124803. * @returns true if all fallbacks were used
  124804. */
  124805. allFallbacksProcessed(): boolean;
  124806. /**
  124807. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  124808. * @param func The callback to be used.
  124809. */
  124810. executeWhenCompiled(func: (effect: Effect) => void): void;
  124811. private _checkIsReady;
  124812. private _loadShader;
  124813. /**
  124814. * Gets the vertex shader source code of this effect
  124815. */
  124816. get vertexSourceCode(): string;
  124817. /**
  124818. * Gets the fragment shader source code of this effect
  124819. */
  124820. get fragmentSourceCode(): string;
  124821. /**
  124822. * Gets the vertex shader source code before it has been processed by the preprocessor
  124823. */
  124824. get rawVertexSourceCode(): string;
  124825. /**
  124826. * Gets the fragment shader source code before it has been processed by the preprocessor
  124827. */
  124828. get rawFragmentSourceCode(): string;
  124829. /**
  124830. * Recompiles the webGL program
  124831. * @param vertexSourceCode The source code for the vertex shader.
  124832. * @param fragmentSourceCode The source code for the fragment shader.
  124833. * @param onCompiled Callback called when completed.
  124834. * @param onError Callback called on error.
  124835. * @hidden
  124836. */
  124837. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  124838. /**
  124839. * Prepares the effect
  124840. * @hidden
  124841. */
  124842. _prepareEffect(): void;
  124843. private _getShaderCodeAndErrorLine;
  124844. private _processCompilationErrors;
  124845. /**
  124846. * Checks if the effect is supported. (Must be called after compilation)
  124847. */
  124848. get isSupported(): boolean;
  124849. /**
  124850. * Binds a texture to the engine to be used as output of the shader.
  124851. * @param channel Name of the output variable.
  124852. * @param texture Texture to bind.
  124853. * @hidden
  124854. */
  124855. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  124856. /**
  124857. * Sets a texture on the engine to be used in the shader.
  124858. * @param channel Name of the sampler variable.
  124859. * @param texture Texture to set.
  124860. */
  124861. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  124862. /**
  124863. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  124864. * @param channel Name of the sampler variable.
  124865. * @param texture Texture to set.
  124866. */
  124867. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  124868. /**
  124869. * Sets an array of textures on the engine to be used in the shader.
  124870. * @param channel Name of the variable.
  124871. * @param textures Textures to set.
  124872. */
  124873. setTextureArray(channel: string, textures: ThinTexture[]): void;
  124874. /**
  124875. * 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)
  124876. * @param channel Name of the sampler variable.
  124877. * @param postProcess Post process to get the input texture from.
  124878. */
  124879. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  124880. /**
  124881. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  124882. * 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)
  124883. * @param channel Name of the sampler variable.
  124884. * @param postProcess Post process to get the output texture from.
  124885. */
  124886. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  124887. /**
  124888. * Binds a buffer to a uniform.
  124889. * @param buffer Buffer to bind.
  124890. * @param name Name of the uniform variable to bind to.
  124891. */
  124892. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  124893. /**
  124894. * Binds block to a uniform.
  124895. * @param blockName Name of the block to bind.
  124896. * @param index Index to bind.
  124897. */
  124898. bindUniformBlock(blockName: string, index: number): void;
  124899. /**
  124900. * Sets an integer value on a uniform variable.
  124901. * @param uniformName Name of the variable.
  124902. * @param value Value to be set.
  124903. * @returns this effect.
  124904. */
  124905. setInt(uniformName: string, value: number): Effect;
  124906. /**
  124907. * Sets an int2 value on a uniform variable.
  124908. * @param uniformName Name of the variable.
  124909. * @param x First int in int2.
  124910. * @param y Second int in int2.
  124911. * @returns this effect.
  124912. */
  124913. setInt2(uniformName: string, x: number, y: number): Effect;
  124914. /**
  124915. * Sets an int3 value on a uniform variable.
  124916. * @param uniformName Name of the variable.
  124917. * @param x First int in int3.
  124918. * @param y Second int in int3.
  124919. * @param z Third int in int3.
  124920. * @returns this effect.
  124921. */
  124922. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  124923. /**
  124924. * Sets an int4 value on a uniform variable.
  124925. * @param uniformName Name of the variable.
  124926. * @param x First int in int4.
  124927. * @param y Second int in int4.
  124928. * @param z Third int in int4.
  124929. * @param w Fourth int in int4.
  124930. * @returns this effect.
  124931. */
  124932. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  124933. /**
  124934. * Sets an int array on a uniform variable.
  124935. * @param uniformName Name of the variable.
  124936. * @param array array to be set.
  124937. * @returns this effect.
  124938. */
  124939. setIntArray(uniformName: string, array: Int32Array): Effect;
  124940. /**
  124941. * 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)
  124942. * @param uniformName Name of the variable.
  124943. * @param array array to be set.
  124944. * @returns this effect.
  124945. */
  124946. setIntArray2(uniformName: string, array: Int32Array): Effect;
  124947. /**
  124948. * 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)
  124949. * @param uniformName Name of the variable.
  124950. * @param array array to be set.
  124951. * @returns this effect.
  124952. */
  124953. setIntArray3(uniformName: string, array: Int32Array): Effect;
  124954. /**
  124955. * 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)
  124956. * @param uniformName Name of the variable.
  124957. * @param array array to be set.
  124958. * @returns this effect.
  124959. */
  124960. setIntArray4(uniformName: string, array: Int32Array): Effect;
  124961. /**
  124962. * Sets an float array on a uniform variable.
  124963. * @param uniformName Name of the variable.
  124964. * @param array array to be set.
  124965. * @returns this effect.
  124966. */
  124967. setFloatArray(uniformName: string, array: FloatArray): Effect;
  124968. /**
  124969. * 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)
  124970. * @param uniformName Name of the variable.
  124971. * @param array array to be set.
  124972. * @returns this effect.
  124973. */
  124974. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  124975. /**
  124976. * 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)
  124977. * @param uniformName Name of the variable.
  124978. * @param array array to be set.
  124979. * @returns this effect.
  124980. */
  124981. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  124982. /**
  124983. * 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)
  124984. * @param uniformName Name of the variable.
  124985. * @param array array to be set.
  124986. * @returns this effect.
  124987. */
  124988. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  124989. /**
  124990. * Sets an array on a uniform variable.
  124991. * @param uniformName Name of the variable.
  124992. * @param array array to be set.
  124993. * @returns this effect.
  124994. */
  124995. setArray(uniformName: string, array: number[]): Effect;
  124996. /**
  124997. * 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)
  124998. * @param uniformName Name of the variable.
  124999. * @param array array to be set.
  125000. * @returns this effect.
  125001. */
  125002. setArray2(uniformName: string, array: number[]): Effect;
  125003. /**
  125004. * 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)
  125005. * @param uniformName Name of the variable.
  125006. * @param array array to be set.
  125007. * @returns this effect.
  125008. */
  125009. setArray3(uniformName: string, array: number[]): Effect;
  125010. /**
  125011. * 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)
  125012. * @param uniformName Name of the variable.
  125013. * @param array array to be set.
  125014. * @returns this effect.
  125015. */
  125016. setArray4(uniformName: string, array: number[]): Effect;
  125017. /**
  125018. * Sets matrices on a uniform variable.
  125019. * @param uniformName Name of the variable.
  125020. * @param matrices matrices to be set.
  125021. * @returns this effect.
  125022. */
  125023. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  125024. /**
  125025. * Sets matrix on a uniform variable.
  125026. * @param uniformName Name of the variable.
  125027. * @param matrix matrix to be set.
  125028. * @returns this effect.
  125029. */
  125030. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  125031. /**
  125032. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  125033. * @param uniformName Name of the variable.
  125034. * @param matrix matrix to be set.
  125035. * @returns this effect.
  125036. */
  125037. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  125038. /**
  125039. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  125040. * @param uniformName Name of the variable.
  125041. * @param matrix matrix to be set.
  125042. * @returns this effect.
  125043. */
  125044. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  125045. /**
  125046. * Sets a float on a uniform variable.
  125047. * @param uniformName Name of the variable.
  125048. * @param value value to be set.
  125049. * @returns this effect.
  125050. */
  125051. setFloat(uniformName: string, value: number): Effect;
  125052. /**
  125053. * Sets a boolean on a uniform variable.
  125054. * @param uniformName Name of the variable.
  125055. * @param bool value to be set.
  125056. * @returns this effect.
  125057. */
  125058. setBool(uniformName: string, bool: boolean): Effect;
  125059. /**
  125060. * Sets a Vector2 on a uniform variable.
  125061. * @param uniformName Name of the variable.
  125062. * @param vector2 vector2 to be set.
  125063. * @returns this effect.
  125064. */
  125065. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  125066. /**
  125067. * Sets a float2 on a uniform variable.
  125068. * @param uniformName Name of the variable.
  125069. * @param x First float in float2.
  125070. * @param y Second float in float2.
  125071. * @returns this effect.
  125072. */
  125073. setFloat2(uniformName: string, x: number, y: number): Effect;
  125074. /**
  125075. * Sets a Vector3 on a uniform variable.
  125076. * @param uniformName Name of the variable.
  125077. * @param vector3 Value to be set.
  125078. * @returns this effect.
  125079. */
  125080. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  125081. /**
  125082. * Sets a float3 on a uniform variable.
  125083. * @param uniformName Name of the variable.
  125084. * @param x First float in float3.
  125085. * @param y Second float in float3.
  125086. * @param z Third float in float3.
  125087. * @returns this effect.
  125088. */
  125089. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  125090. /**
  125091. * Sets a Vector4 on a uniform variable.
  125092. * @param uniformName Name of the variable.
  125093. * @param vector4 Value to be set.
  125094. * @returns this effect.
  125095. */
  125096. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  125097. /**
  125098. * Sets a float4 on a uniform variable.
  125099. * @param uniformName Name of the variable.
  125100. * @param x First float in float4.
  125101. * @param y Second float in float4.
  125102. * @param z Third float in float4.
  125103. * @param w Fourth float in float4.
  125104. * @returns this effect.
  125105. */
  125106. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  125107. /**
  125108. * Sets a Color3 on a uniform variable.
  125109. * @param uniformName Name of the variable.
  125110. * @param color3 Value to be set.
  125111. * @returns this effect.
  125112. */
  125113. setColor3(uniformName: string, color3: IColor3Like): Effect;
  125114. /**
  125115. * Sets a Color4 on a uniform variable.
  125116. * @param uniformName Name of the variable.
  125117. * @param color3 Value to be set.
  125118. * @param alpha Alpha value to be set.
  125119. * @returns this effect.
  125120. */
  125121. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  125122. /**
  125123. * Sets a Color4 on a uniform variable
  125124. * @param uniformName defines the name of the variable
  125125. * @param color4 defines the value to be set
  125126. * @returns this effect.
  125127. */
  125128. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  125129. /**
  125130. * Release all associated resources.
  125131. **/
  125132. dispose(): void;
  125133. /**
  125134. * This function will add a new shader to the shader store
  125135. * @param name the name of the shader
  125136. * @param pixelShader optional pixel shader content
  125137. * @param vertexShader optional vertex shader content
  125138. */
  125139. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  125140. /**
  125141. * Store of each shader (The can be looked up using effect.key)
  125142. */
  125143. static ShadersStore: {
  125144. [key: string]: string;
  125145. };
  125146. /**
  125147. * Store of each included file for a shader (The can be looked up using effect.key)
  125148. */
  125149. static IncludesShadersStore: {
  125150. [key: string]: string;
  125151. };
  125152. /**
  125153. * Resets the cache of effects.
  125154. */
  125155. static ResetCache(): void;
  125156. }
  125157. }
  125158. declare module BABYLON {
  125159. /**
  125160. * Interface used to describe the capabilities of the engine relatively to the current browser
  125161. */
  125162. export interface EngineCapabilities {
  125163. /** Maximum textures units per fragment shader */
  125164. maxTexturesImageUnits: number;
  125165. /** Maximum texture units per vertex shader */
  125166. maxVertexTextureImageUnits: number;
  125167. /** Maximum textures units in the entire pipeline */
  125168. maxCombinedTexturesImageUnits: number;
  125169. /** Maximum texture size */
  125170. maxTextureSize: number;
  125171. /** Maximum texture samples */
  125172. maxSamples?: number;
  125173. /** Maximum cube texture size */
  125174. maxCubemapTextureSize: number;
  125175. /** Maximum render texture size */
  125176. maxRenderTextureSize: number;
  125177. /** Maximum number of vertex attributes */
  125178. maxVertexAttribs: number;
  125179. /** Maximum number of varyings */
  125180. maxVaryingVectors: number;
  125181. /** Maximum number of uniforms per vertex shader */
  125182. maxVertexUniformVectors: number;
  125183. /** Maximum number of uniforms per fragment shader */
  125184. maxFragmentUniformVectors: number;
  125185. /** Defines if standard derivatives (dx/dy) are supported */
  125186. standardDerivatives: boolean;
  125187. /** Defines if s3tc texture compression is supported */
  125188. s3tc?: WEBGL_compressed_texture_s3tc;
  125189. /** Defines if pvrtc texture compression is supported */
  125190. pvrtc: any;
  125191. /** Defines if etc1 texture compression is supported */
  125192. etc1: any;
  125193. /** Defines if etc2 texture compression is supported */
  125194. etc2: any;
  125195. /** Defines if astc texture compression is supported */
  125196. astc: any;
  125197. /** Defines if bptc texture compression is supported */
  125198. bptc: any;
  125199. /** Defines if float textures are supported */
  125200. textureFloat: boolean;
  125201. /** Defines if vertex array objects are supported */
  125202. vertexArrayObject: boolean;
  125203. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  125204. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  125205. /** Gets the maximum level of anisotropy supported */
  125206. maxAnisotropy: number;
  125207. /** Defines if instancing is supported */
  125208. instancedArrays: boolean;
  125209. /** Defines if 32 bits indices are supported */
  125210. uintIndices: boolean;
  125211. /** Defines if high precision shaders are supported */
  125212. highPrecisionShaderSupported: boolean;
  125213. /** Defines if depth reading in the fragment shader is supported */
  125214. fragmentDepthSupported: boolean;
  125215. /** Defines if float texture linear filtering is supported*/
  125216. textureFloatLinearFiltering: boolean;
  125217. /** Defines if rendering to float textures is supported */
  125218. textureFloatRender: boolean;
  125219. /** Defines if half float textures are supported*/
  125220. textureHalfFloat: boolean;
  125221. /** Defines if half float texture linear filtering is supported*/
  125222. textureHalfFloatLinearFiltering: boolean;
  125223. /** Defines if rendering to half float textures is supported */
  125224. textureHalfFloatRender: boolean;
  125225. /** Defines if textureLOD shader command is supported */
  125226. textureLOD: boolean;
  125227. /** Defines if draw buffers extension is supported */
  125228. drawBuffersExtension: boolean;
  125229. /** Defines if depth textures are supported */
  125230. depthTextureExtension: boolean;
  125231. /** Defines if float color buffer are supported */
  125232. colorBufferFloat: boolean;
  125233. /** Gets disjoint timer query extension (null if not supported) */
  125234. timerQuery?: EXT_disjoint_timer_query;
  125235. /** Defines if timestamp can be used with timer query */
  125236. canUseTimestampForTimerQuery: boolean;
  125237. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  125238. multiview?: any;
  125239. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  125240. oculusMultiview?: any;
  125241. /** Function used to let the system compiles shaders in background */
  125242. parallelShaderCompile?: {
  125243. COMPLETION_STATUS_KHR: number;
  125244. };
  125245. /** Max number of texture samples for MSAA */
  125246. maxMSAASamples: number;
  125247. /** Defines if the blend min max extension is supported */
  125248. blendMinMax: boolean;
  125249. /** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
  125250. canUseGLInstanceID: boolean;
  125251. /** Defines if gl_vertexID is available */
  125252. canUseGLVertexID: boolean;
  125253. }
  125254. }
  125255. declare module BABYLON {
  125256. /**
  125257. * @hidden
  125258. **/
  125259. export class DepthCullingState {
  125260. protected _isDepthTestDirty: boolean;
  125261. protected _isDepthMaskDirty: boolean;
  125262. protected _isDepthFuncDirty: boolean;
  125263. protected _isCullFaceDirty: boolean;
  125264. protected _isCullDirty: boolean;
  125265. protected _isZOffsetDirty: boolean;
  125266. protected _isFrontFaceDirty: boolean;
  125267. protected _depthTest: boolean;
  125268. protected _depthMask: boolean;
  125269. protected _depthFunc: Nullable<number>;
  125270. protected _cull: Nullable<boolean>;
  125271. protected _cullFace: Nullable<number>;
  125272. protected _zOffset: number;
  125273. protected _frontFace: Nullable<number>;
  125274. /**
  125275. * Initializes the state.
  125276. */
  125277. constructor(reset?: boolean);
  125278. get isDirty(): boolean;
  125279. get zOffset(): number;
  125280. set zOffset(value: number);
  125281. get cullFace(): Nullable<number>;
  125282. set cullFace(value: Nullable<number>);
  125283. get cull(): Nullable<boolean>;
  125284. set cull(value: Nullable<boolean>);
  125285. get depthFunc(): Nullable<number>;
  125286. set depthFunc(value: Nullable<number>);
  125287. get depthMask(): boolean;
  125288. set depthMask(value: boolean);
  125289. get depthTest(): boolean;
  125290. set depthTest(value: boolean);
  125291. get frontFace(): Nullable<number>;
  125292. set frontFace(value: Nullable<number>);
  125293. reset(): void;
  125294. apply(gl: WebGLRenderingContext): void;
  125295. }
  125296. }
  125297. declare module BABYLON {
  125298. /**
  125299. * @hidden
  125300. **/
  125301. export class StencilState {
  125302. /** 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 */
  125303. static readonly ALWAYS: number;
  125304. /** Passed to stencilOperation to specify that stencil value must be kept */
  125305. static readonly KEEP: number;
  125306. /** Passed to stencilOperation to specify that stencil value must be replaced */
  125307. static readonly REPLACE: number;
  125308. protected _isStencilTestDirty: boolean;
  125309. protected _isStencilMaskDirty: boolean;
  125310. protected _isStencilFuncDirty: boolean;
  125311. protected _isStencilOpDirty: boolean;
  125312. protected _stencilTest: boolean;
  125313. protected _stencilMask: number;
  125314. protected _stencilFunc: number;
  125315. protected _stencilFuncRef: number;
  125316. protected _stencilFuncMask: number;
  125317. protected _stencilOpStencilFail: number;
  125318. protected _stencilOpDepthFail: number;
  125319. protected _stencilOpStencilDepthPass: number;
  125320. get isDirty(): boolean;
  125321. get stencilFunc(): number;
  125322. set stencilFunc(value: number);
  125323. get stencilFuncRef(): number;
  125324. set stencilFuncRef(value: number);
  125325. get stencilFuncMask(): number;
  125326. set stencilFuncMask(value: number);
  125327. get stencilOpStencilFail(): number;
  125328. set stencilOpStencilFail(value: number);
  125329. get stencilOpDepthFail(): number;
  125330. set stencilOpDepthFail(value: number);
  125331. get stencilOpStencilDepthPass(): number;
  125332. set stencilOpStencilDepthPass(value: number);
  125333. get stencilMask(): number;
  125334. set stencilMask(value: number);
  125335. get stencilTest(): boolean;
  125336. set stencilTest(value: boolean);
  125337. constructor(reset?: boolean);
  125338. reset(): void;
  125339. apply(gl: WebGLRenderingContext): void;
  125340. }
  125341. }
  125342. declare module BABYLON {
  125343. /**
  125344. * @hidden
  125345. **/
  125346. export class AlphaState {
  125347. _blendFunctionParameters: Nullable<number>[];
  125348. _blendEquationParameters: Nullable<number>[];
  125349. _blendConstants: Nullable<number>[];
  125350. _isBlendConstantsDirty: boolean;
  125351. private _alphaBlend;
  125352. private _isAlphaBlendDirty;
  125353. private _isBlendFunctionParametersDirty;
  125354. private _isBlendEquationParametersDirty;
  125355. /**
  125356. * Initializes the state.
  125357. */
  125358. constructor();
  125359. get isDirty(): boolean;
  125360. get alphaBlend(): boolean;
  125361. set alphaBlend(value: boolean);
  125362. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  125363. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  125364. setAlphaEquationParameters(rgb: number, alpha: number): void;
  125365. reset(): void;
  125366. apply(gl: WebGLRenderingContext): void;
  125367. }
  125368. }
  125369. declare module BABYLON {
  125370. /** @hidden */
  125371. export class WebGLShaderProcessor implements IShaderProcessor {
  125372. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  125373. }
  125374. }
  125375. declare module BABYLON {
  125376. /** @hidden */
  125377. export class WebGL2ShaderProcessor implements IShaderProcessor {
  125378. attributeProcessor(attribute: string): string;
  125379. varyingProcessor(varying: string, isFragment: boolean): string;
  125380. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  125381. }
  125382. }
  125383. declare module BABYLON {
  125384. /**
  125385. * Interface for attribute information associated with buffer instantiation
  125386. */
  125387. export interface InstancingAttributeInfo {
  125388. /**
  125389. * Name of the GLSL attribute
  125390. * if attribute index is not specified, this is used to retrieve the index from the effect
  125391. */
  125392. attributeName: string;
  125393. /**
  125394. * Index/offset of the attribute in the vertex shader
  125395. * if not specified, this will be computes from the name.
  125396. */
  125397. index?: number;
  125398. /**
  125399. * size of the attribute, 1, 2, 3 or 4
  125400. */
  125401. attributeSize: number;
  125402. /**
  125403. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  125404. */
  125405. offset: number;
  125406. /**
  125407. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  125408. * default to 1
  125409. */
  125410. divisor?: number;
  125411. /**
  125412. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  125413. * default is FLOAT
  125414. */
  125415. attributeType?: number;
  125416. /**
  125417. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  125418. */
  125419. normalized?: boolean;
  125420. }
  125421. }
  125422. declare module BABYLON {
  125423. /** @hidden */
  125424. export interface EngineFeatures {
  125425. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  125426. forceBitmapOverHTMLImageElement: boolean;
  125427. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  125428. supportRenderAndCopyToLodForFloatTextures: boolean;
  125429. /** Indicates that the engine support handling depth/stencil textures */
  125430. supportDepthStencilTexture: boolean;
  125431. /** Indicates that the engine support shadow samplers */
  125432. supportShadowSamplers: boolean;
  125433. /** Indicates to check the matrix bytes per bytes to know if it has changed or not. If false, only the updateFlag of the matrix is checked */
  125434. uniformBufferHardCheckMatrix: boolean;
  125435. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  125436. allowTexturePrefiltering: boolean;
  125437. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  125438. trackUbosInFrame: boolean;
  125439. /** Indicates that the Cascaded Shadow Map technic is supported */
  125440. supportCSM: boolean;
  125441. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  125442. basisNeedsPOT: boolean;
  125443. /** Indicates that the engine supports 3D textures */
  125444. support3DTextures: boolean;
  125445. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  125446. needTypeSuffixInShaderConstants: boolean;
  125447. /** Indicates that MSAA is supported */
  125448. supportMSAA: boolean;
  125449. /** Indicates that SSAO2 is supported */
  125450. supportSSAO2: boolean;
  125451. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  125452. supportExtendedTextureFormats: boolean;
  125453. /** Indicates that the switch/case construct is supported in shaders */
  125454. supportSwitchCaseInShader: boolean;
  125455. /** Indicates that synchronous texture reading is supported */
  125456. supportSyncTextureRead: boolean;
  125457. /** @hidden */
  125458. _collectUbosUpdatedInFrame: boolean;
  125459. }
  125460. }
  125461. declare module BABYLON {
  125462. /** @hidden */
  125463. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  125464. private _webGLTexture;
  125465. private _context;
  125466. get underlyingResource(): Nullable<WebGLTexture>;
  125467. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  125468. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  125469. set(hardwareTexture: WebGLTexture): void;
  125470. reset(): void;
  125471. release(): void;
  125472. }
  125473. }
  125474. declare module BABYLON {
  125475. interface ThinEngine {
  125476. /**
  125477. * Update a video texture
  125478. * @param texture defines the texture to update
  125479. * @param video defines the video element to use
  125480. * @param invertY defines if data must be stored with Y axis inverted
  125481. */
  125482. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  125483. }
  125484. }
  125485. declare module BABYLON {
  125486. interface ThinEngine {
  125487. /**
  125488. * Creates a dynamic texture
  125489. * @param width defines the width of the texture
  125490. * @param height defines the height of the texture
  125491. * @param generateMipMaps defines if the engine should generate the mip levels
  125492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  125493. * @returns the dynamic texture inside an InternalTexture
  125494. */
  125495. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  125496. /**
  125497. * Update the content of a dynamic texture
  125498. * @param texture defines the texture to update
  125499. * @param source defines the source containing the data
  125500. * @param invertY defines if data must be stored with Y axis inverted
  125501. * @param premulAlpha defines if alpha is stored as premultiplied
  125502. * @param format defines the format of the data
  125503. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  125504. */
  125505. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  125506. }
  125507. }
  125508. declare module BABYLON {
  125509. /**
  125510. * Settings for finer control over video usage
  125511. */
  125512. export interface VideoTextureSettings {
  125513. /**
  125514. * Applies `autoplay` to video, if specified
  125515. */
  125516. autoPlay?: boolean;
  125517. /**
  125518. * Applies `muted` to video, if specified
  125519. */
  125520. muted?: boolean;
  125521. /**
  125522. * Applies `loop` to video, if specified
  125523. */
  125524. loop?: boolean;
  125525. /**
  125526. * Automatically updates internal texture from video at every frame in the render loop
  125527. */
  125528. autoUpdateTexture: boolean;
  125529. /**
  125530. * Image src displayed during the video loading or until the user interacts with the video.
  125531. */
  125532. poster?: string;
  125533. }
  125534. /**
  125535. * If you want to display a video in your scene, this is the special texture for that.
  125536. * This special texture works similar to other textures, with the exception of a few parameters.
  125537. * @see https://doc.babylonjs.com/how_to/video_texture
  125538. */
  125539. export class VideoTexture extends Texture {
  125540. /**
  125541. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  125542. */
  125543. readonly autoUpdateTexture: boolean;
  125544. /**
  125545. * The video instance used by the texture internally
  125546. */
  125547. readonly video: HTMLVideoElement;
  125548. private _onUserActionRequestedObservable;
  125549. /**
  125550. * Event triggered when a dom action is required by the user to play the video.
  125551. * This happens due to recent changes in browser policies preventing video to auto start.
  125552. */
  125553. get onUserActionRequestedObservable(): Observable<Texture>;
  125554. private _generateMipMaps;
  125555. private _stillImageCaptured;
  125556. private _displayingPosterTexture;
  125557. private _settings;
  125558. private _createInternalTextureOnEvent;
  125559. private _frameId;
  125560. private _currentSrc;
  125561. /**
  125562. * Creates a video texture.
  125563. * If you want to display a video in your scene, this is the special texture for that.
  125564. * This special texture works similar to other textures, with the exception of a few parameters.
  125565. * @see https://doc.babylonjs.com/how_to/video_texture
  125566. * @param name optional name, will detect from video source, if not defined
  125567. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  125568. * @param scene is obviously the current scene.
  125569. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  125570. * @param invertY is false by default but can be used to invert video on Y axis
  125571. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  125572. * @param settings allows finer control over video usage
  125573. */
  125574. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  125575. private _getName;
  125576. private _getVideo;
  125577. private _createInternalTexture;
  125578. private reset;
  125579. /**
  125580. * @hidden Internal method to initiate `update`.
  125581. */
  125582. _rebuild(): void;
  125583. /**
  125584. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  125585. */
  125586. update(): void;
  125587. /**
  125588. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  125589. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  125590. */
  125591. updateTexture(isVisible: boolean): void;
  125592. protected _updateInternalTexture: () => void;
  125593. /**
  125594. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  125595. * @param url New url.
  125596. */
  125597. updateURL(url: string): void;
  125598. /**
  125599. * Clones the texture.
  125600. * @returns the cloned texture
  125601. */
  125602. clone(): VideoTexture;
  125603. /**
  125604. * Dispose the texture and release its associated resources.
  125605. */
  125606. dispose(): void;
  125607. /**
  125608. * Creates a video texture straight from a stream.
  125609. * @param scene Define the scene the texture should be created in
  125610. * @param stream Define the stream the texture should be created from
  125611. * @returns The created video texture as a promise
  125612. */
  125613. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  125614. /**
  125615. * Creates a video texture straight from your WebCam video feed.
  125616. * @param scene Define the scene the texture should be created in
  125617. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  125618. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  125619. * @returns The created video texture as a promise
  125620. */
  125621. static CreateFromWebCamAsync(scene: Scene, constraints: {
  125622. minWidth: number;
  125623. maxWidth: number;
  125624. minHeight: number;
  125625. maxHeight: number;
  125626. deviceId: string;
  125627. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  125628. /**
  125629. * Creates a video texture straight from your WebCam video feed.
  125630. * @param scene Define the scene the texture should be created in
  125631. * @param onReady Define a callback to triggered once the texture will be ready
  125632. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  125633. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  125634. */
  125635. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  125636. minWidth: number;
  125637. maxWidth: number;
  125638. minHeight: number;
  125639. maxHeight: number;
  125640. deviceId: string;
  125641. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  125642. }
  125643. }
  125644. declare module BABYLON {
  125645. /**
  125646. * Defines the interface used by objects working like Scene
  125647. * @hidden
  125648. */
  125649. export interface ISceneLike {
  125650. _addPendingData(data: any): void;
  125651. _removePendingData(data: any): void;
  125652. offlineProvider: IOfflineProvider;
  125653. }
  125654. /**
  125655. * Information about the current host
  125656. */
  125657. export interface HostInformation {
  125658. /**
  125659. * Defines if the current host is a mobile
  125660. */
  125661. isMobile: boolean;
  125662. }
  125663. /** Interface defining initialization parameters for Engine class */
  125664. export interface EngineOptions extends WebGLContextAttributes {
  125665. /**
  125666. * Defines if the engine should no exceed a specified device ratio
  125667. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  125668. */
  125669. limitDeviceRatio?: number;
  125670. /**
  125671. * Defines if webvr should be enabled automatically
  125672. * @see https://doc.babylonjs.com/how_to/webvr_camera
  125673. */
  125674. autoEnableWebVR?: boolean;
  125675. /**
  125676. * Defines if webgl2 should be turned off even if supported
  125677. * @see https://doc.babylonjs.com/features/webgl2
  125678. */
  125679. disableWebGL2Support?: boolean;
  125680. /**
  125681. * Defines if webaudio should be initialized as well
  125682. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125683. */
  125684. audioEngine?: boolean;
  125685. /**
  125686. * Defines if animations should run using a deterministic lock step
  125687. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  125688. */
  125689. deterministicLockstep?: boolean;
  125690. /** Defines the maximum steps to use with deterministic lock step mode */
  125691. lockstepMaxSteps?: number;
  125692. /** Defines the seconds between each deterministic lock step */
  125693. timeStep?: number;
  125694. /**
  125695. * Defines that engine should ignore context lost events
  125696. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  125697. */
  125698. doNotHandleContextLost?: boolean;
  125699. /**
  125700. * Defines that engine should ignore modifying touch action attribute and style
  125701. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  125702. */
  125703. doNotHandleTouchAction?: boolean;
  125704. /**
  125705. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  125706. */
  125707. useHighPrecisionFloats?: boolean;
  125708. /**
  125709. * Make the canvas XR Compatible for XR sessions
  125710. */
  125711. xrCompatible?: boolean;
  125712. /**
  125713. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  125714. */
  125715. useHighPrecisionMatrix?: boolean;
  125716. /**
  125717. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  125718. */
  125719. failIfMajorPerformanceCaveat?: boolean;
  125720. /**
  125721. * Defines whether to adapt to the device's viewport characteristics (default: false)
  125722. */
  125723. adaptToDeviceRatio?: boolean;
  125724. }
  125725. /**
  125726. * The base engine class (root of all engines)
  125727. */
  125728. export class ThinEngine {
  125729. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  125730. static ExceptionList: ({
  125731. key: string;
  125732. capture: string;
  125733. captureConstraint: number;
  125734. targets: string[];
  125735. } | {
  125736. key: string;
  125737. capture: null;
  125738. captureConstraint: null;
  125739. targets: string[];
  125740. })[];
  125741. /** @hidden */
  125742. static _TextureLoaders: IInternalTextureLoader[];
  125743. /**
  125744. * Returns the current npm package of the sdk
  125745. */
  125746. static get NpmPackage(): string;
  125747. /**
  125748. * Returns the current version of the framework
  125749. */
  125750. static get Version(): string;
  125751. /**
  125752. * Returns a string describing the current engine
  125753. */
  125754. get description(): string;
  125755. /**
  125756. * Returns the name of the engine
  125757. */
  125758. get name(): string;
  125759. /**
  125760. * Returns the version of the engine
  125761. */
  125762. get version(): number;
  125763. /**
  125764. * Gets or sets the epsilon value used by collision engine
  125765. */
  125766. static CollisionsEpsilon: number;
  125767. /**
  125768. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  125769. */
  125770. static get ShadersRepository(): string;
  125771. static set ShadersRepository(value: string);
  125772. /** @hidden */
  125773. _shaderProcessor: Nullable<IShaderProcessor>;
  125774. /**
  125775. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  125776. */
  125777. forcePOTTextures: boolean;
  125778. /**
  125779. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  125780. */
  125781. isFullscreen: boolean;
  125782. /**
  125783. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  125784. */
  125785. cullBackFaces: boolean;
  125786. /**
  125787. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  125788. */
  125789. renderEvenInBackground: boolean;
  125790. /**
  125791. * Gets or sets a boolean indicating that cache can be kept between frames
  125792. */
  125793. preventCacheWipeBetweenFrames: boolean;
  125794. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  125795. validateShaderPrograms: boolean;
  125796. /**
  125797. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  125798. * This can provide greater z depth for distant objects.
  125799. */
  125800. useReverseDepthBuffer: boolean;
  125801. /**
  125802. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  125803. */
  125804. disableUniformBuffers: boolean;
  125805. private _frameId;
  125806. /**
  125807. * Gets the current frame id
  125808. */
  125809. get frameId(): number;
  125810. /** @hidden */
  125811. _uniformBuffers: UniformBuffer[];
  125812. /**
  125813. * Gets a boolean indicating that the engine supports uniform buffers
  125814. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  125815. */
  125816. get supportsUniformBuffers(): boolean;
  125817. /** @hidden */
  125818. _gl: WebGLRenderingContext;
  125819. /** @hidden */
  125820. _webGLVersion: number;
  125821. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  125822. protected _windowIsBackground: boolean;
  125823. protected _creationOptions: EngineOptions;
  125824. protected _highPrecisionShadersAllowed: boolean;
  125825. /** @hidden */
  125826. get _shouldUseHighPrecisionShader(): boolean;
  125827. /**
  125828. * Gets a boolean indicating that only power of 2 textures are supported
  125829. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  125830. */
  125831. get needPOTTextures(): boolean;
  125832. /** @hidden */
  125833. _badOS: boolean;
  125834. /** @hidden */
  125835. _badDesktopOS: boolean;
  125836. protected _hardwareScalingLevel: number;
  125837. /** @hidden */
  125838. _caps: EngineCapabilities;
  125839. /** @hidden */
  125840. _features: EngineFeatures;
  125841. protected _isStencilEnable: boolean;
  125842. private _glVersion;
  125843. private _glRenderer;
  125844. private _glVendor;
  125845. /** @hidden */
  125846. _videoTextureSupported: boolean;
  125847. protected _renderingQueueLaunched: boolean;
  125848. protected _activeRenderLoops: (() => void)[];
  125849. /**
  125850. * Observable signaled when a context lost event is raised
  125851. */
  125852. onContextLostObservable: Observable<ThinEngine>;
  125853. /**
  125854. * Observable signaled when a context restored event is raised
  125855. */
  125856. onContextRestoredObservable: Observable<ThinEngine>;
  125857. private _onContextLost;
  125858. private _onContextRestored;
  125859. protected _contextWasLost: boolean;
  125860. /** @hidden */
  125861. _doNotHandleContextLost: boolean;
  125862. /**
  125863. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  125864. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  125865. */
  125866. get doNotHandleContextLost(): boolean;
  125867. set doNotHandleContextLost(value: boolean);
  125868. /**
  125869. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  125870. */
  125871. disableVertexArrayObjects: boolean;
  125872. /** @hidden */
  125873. protected _colorWrite: boolean;
  125874. /** @hidden */
  125875. protected _colorWriteChanged: boolean;
  125876. /** @hidden */
  125877. protected _depthCullingState: DepthCullingState;
  125878. /** @hidden */
  125879. protected _stencilState: StencilState;
  125880. /** @hidden */
  125881. _alphaState: AlphaState;
  125882. /** @hidden */
  125883. _alphaMode: number;
  125884. /** @hidden */
  125885. _alphaEquation: number;
  125886. /** @hidden */
  125887. _internalTexturesCache: InternalTexture[];
  125888. /** @hidden */
  125889. protected _activeChannel: number;
  125890. private _currentTextureChannel;
  125891. /** @hidden */
  125892. protected _boundTexturesCache: {
  125893. [key: string]: Nullable<InternalTexture>;
  125894. };
  125895. /** @hidden */
  125896. protected _currentEffect: Nullable<Effect>;
  125897. /** @hidden */
  125898. protected _currentProgram: Nullable<WebGLProgram>;
  125899. protected _compiledEffects: {
  125900. [key: string]: Effect;
  125901. };
  125902. private _vertexAttribArraysEnabled;
  125903. /** @hidden */
  125904. protected _cachedViewport: Nullable<IViewportLike>;
  125905. private _cachedVertexArrayObject;
  125906. /** @hidden */
  125907. protected _cachedVertexBuffers: any;
  125908. /** @hidden */
  125909. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  125910. /** @hidden */
  125911. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  125912. /** @hidden */
  125913. _currentRenderTarget: Nullable<InternalTexture>;
  125914. private _uintIndicesCurrentlySet;
  125915. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  125916. /** @hidden */
  125917. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  125918. /** @hidden */
  125919. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  125920. private _currentBufferPointers;
  125921. private _currentInstanceLocations;
  125922. private _currentInstanceBuffers;
  125923. private _textureUnits;
  125924. /** @hidden */
  125925. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  125926. /** @hidden */
  125927. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  125928. /** @hidden */
  125929. _boundRenderFunction: any;
  125930. private _vaoRecordInProgress;
  125931. private _mustWipeVertexAttributes;
  125932. private _emptyTexture;
  125933. private _emptyCubeTexture;
  125934. private _emptyTexture3D;
  125935. private _emptyTexture2DArray;
  125936. /** @hidden */
  125937. _frameHandler: number;
  125938. private _nextFreeTextureSlots;
  125939. private _maxSimultaneousTextures;
  125940. private _activeRequests;
  125941. /** @hidden */
  125942. _transformTextureUrl: Nullable<(url: string) => string>;
  125943. /**
  125944. * Gets information about the current host
  125945. */
  125946. hostInformation: HostInformation;
  125947. protected get _supportsHardwareTextureRescaling(): boolean;
  125948. private _framebufferDimensionsObject;
  125949. /**
  125950. * sets the object from which width and height will be taken from when getting render width and height
  125951. * Will fallback to the gl object
  125952. * @param dimensions the framebuffer width and height that will be used.
  125953. */
  125954. set framebufferDimensionsObject(dimensions: Nullable<{
  125955. framebufferWidth: number;
  125956. framebufferHeight: number;
  125957. }>);
  125958. /**
  125959. * Gets the current viewport
  125960. */
  125961. get currentViewport(): Nullable<IViewportLike>;
  125962. /**
  125963. * Gets the default empty texture
  125964. */
  125965. get emptyTexture(): InternalTexture;
  125966. /**
  125967. * Gets the default empty 3D texture
  125968. */
  125969. get emptyTexture3D(): InternalTexture;
  125970. /**
  125971. * Gets the default empty 2D array texture
  125972. */
  125973. get emptyTexture2DArray(): InternalTexture;
  125974. /**
  125975. * Gets the default empty cube texture
  125976. */
  125977. get emptyCubeTexture(): InternalTexture;
  125978. /**
  125979. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  125980. */
  125981. premultipliedAlpha: boolean;
  125982. /**
  125983. * Observable event triggered before each texture is initialized
  125984. */
  125985. onBeforeTextureInitObservable: Observable<Texture>;
  125986. /** @hidden */
  125987. protected _isWebGPU: boolean;
  125988. /**
  125989. * Gets a boolean indicating if the engine runs in WebGPU or not.
  125990. */
  125991. get isWebGPU(): boolean;
  125992. /** @hidden */
  125993. protected _shaderPlatformName: string;
  125994. /**
  125995. * Gets the shader platfrom name used by the effects.
  125996. */
  125997. get shaderPlatformName(): string;
  125998. /**
  125999. * Creates a new engine
  126000. * @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
  126001. * @param antialias defines enable antialiasing (default: false)
  126002. * @param options defines further options to be sent to the getContext() function
  126003. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  126004. */
  126005. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  126006. /**
  126007. * @hidden
  126008. */
  126009. _debugPushGroup(groupName: string, targetObject?: number): void;
  126010. /**
  126011. * @hidden
  126012. */
  126013. _debugPopGroup(targetObject?: number): void;
  126014. /**
  126015. * @hidden
  126016. */
  126017. _debugInsertMarker(text: string, targetObject?: number): void;
  126018. /**
  126019. * Shared initialization across engines types.
  126020. * @param canvas The canvas associated with this instance of the engine.
  126021. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  126022. * @param audioEngine Defines if an audio engine should be created by default
  126023. */
  126024. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  126025. /**
  126026. * Gets a shader processor implementation fitting with the current engine type.
  126027. * @returns The shader processor implementation.
  126028. */
  126029. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  126030. /** @hidden */
  126031. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  126032. private _rebuildInternalTextures;
  126033. private _rebuildEffects;
  126034. /**
  126035. * Gets a boolean indicating if all created effects are ready
  126036. * @returns true if all effects are ready
  126037. */
  126038. areAllEffectsReady(): boolean;
  126039. protected _rebuildBuffers(): void;
  126040. protected _initGLContext(): void;
  126041. protected _initFeatures(): void;
  126042. /**
  126043. * Gets version of the current webGL context
  126044. * Keep it for back compat - use version instead
  126045. */
  126046. get webGLVersion(): number;
  126047. /**
  126048. * Gets a string identifying the name of the class
  126049. * @returns "Engine" string
  126050. */
  126051. getClassName(): string;
  126052. /**
  126053. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  126054. */
  126055. get isStencilEnable(): boolean;
  126056. /** @hidden */
  126057. _prepareWorkingCanvas(): void;
  126058. /**
  126059. * Reset the texture cache to empty state
  126060. */
  126061. resetTextureCache(): void;
  126062. /**
  126063. * Gets an object containing information about the current webGL context
  126064. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  126065. */
  126066. getGlInfo(): {
  126067. vendor: string;
  126068. renderer: string;
  126069. version: string;
  126070. };
  126071. /**
  126072. * Defines the hardware scaling level.
  126073. * By default the hardware scaling level is computed from the window device ratio.
  126074. * 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.
  126075. * @param level defines the level to use
  126076. */
  126077. setHardwareScalingLevel(level: number): void;
  126078. /**
  126079. * Gets the current hardware scaling level.
  126080. * By default the hardware scaling level is computed from the window device ratio.
  126081. * 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.
  126082. * @returns a number indicating the current hardware scaling level
  126083. */
  126084. getHardwareScalingLevel(): number;
  126085. /**
  126086. * Gets the list of loaded textures
  126087. * @returns an array containing all loaded textures
  126088. */
  126089. getLoadedTexturesCache(): InternalTexture[];
  126090. /**
  126091. * Gets the object containing all engine capabilities
  126092. * @returns the EngineCapabilities object
  126093. */
  126094. getCaps(): EngineCapabilities;
  126095. /**
  126096. * stop executing a render loop function and remove it from the execution array
  126097. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  126098. */
  126099. stopRenderLoop(renderFunction?: () => void): void;
  126100. /** @hidden */
  126101. _renderLoop(): void;
  126102. /**
  126103. * Gets the HTML canvas attached with the current webGL context
  126104. * @returns a HTML canvas
  126105. */
  126106. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  126107. /**
  126108. * Gets host window
  126109. * @returns the host window object
  126110. */
  126111. getHostWindow(): Nullable<Window>;
  126112. /**
  126113. * Gets the current render width
  126114. * @param useScreen defines if screen size must be used (or the current render target if any)
  126115. * @returns a number defining the current render width
  126116. */
  126117. getRenderWidth(useScreen?: boolean): number;
  126118. /**
  126119. * Gets the current render height
  126120. * @param useScreen defines if screen size must be used (or the current render target if any)
  126121. * @returns a number defining the current render height
  126122. */
  126123. getRenderHeight(useScreen?: boolean): number;
  126124. /**
  126125. * Can be used to override the current requestAnimationFrame requester.
  126126. * @hidden
  126127. */
  126128. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  126129. /**
  126130. * Register and execute a render loop. The engine can have more than one render function
  126131. * @param renderFunction defines the function to continuously execute
  126132. */
  126133. runRenderLoop(renderFunction: () => void): void;
  126134. /**
  126135. * Clear the current render buffer or the current render target (if any is set up)
  126136. * @param color defines the color to use
  126137. * @param backBuffer defines if the back buffer must be cleared
  126138. * @param depth defines if the depth buffer must be cleared
  126139. * @param stencil defines if the stencil buffer must be cleared
  126140. */
  126141. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  126142. protected _viewportCached: {
  126143. x: number;
  126144. y: number;
  126145. z: number;
  126146. w: number;
  126147. };
  126148. /** @hidden */
  126149. _viewport(x: number, y: number, width: number, height: number): void;
  126150. /**
  126151. * Set the WebGL's viewport
  126152. * @param viewport defines the viewport element to be used
  126153. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  126154. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  126155. */
  126156. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  126157. /**
  126158. * Begin a new frame
  126159. */
  126160. beginFrame(): void;
  126161. /**
  126162. * Enf the current frame
  126163. */
  126164. endFrame(): void;
  126165. /**
  126166. * Resize the view according to the canvas' size
  126167. * @param forceSetSize true to force setting the sizes of the underlying canvas
  126168. */
  126169. resize(forceSetSize?: boolean): void;
  126170. /**
  126171. * Force a specific size of the canvas
  126172. * @param width defines the new canvas' width
  126173. * @param height defines the new canvas' height
  126174. * @param forceSetSize true to force setting the sizes of the underlying canvas
  126175. * @returns true if the size was changed
  126176. */
  126177. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  126178. /**
  126179. * Binds the frame buffer to the specified texture.
  126180. * @param texture The texture to render to or null for the default canvas
  126181. * @param faceIndex The face of the texture to render to in case of cube texture
  126182. * @param requiredWidth The width of the target to render to
  126183. * @param requiredHeight The height of the target to render to
  126184. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  126185. * @param lodLevel defines the lod level to bind to the frame buffer
  126186. * @param layer defines the 2d array index to bind to frame buffer to
  126187. */
  126188. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  126189. /** @hidden */
  126190. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  126191. /**
  126192. * Unbind the current render target texture from the webGL context
  126193. * @param texture defines the render target texture to unbind
  126194. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  126195. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  126196. */
  126197. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  126198. /**
  126199. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  126200. */
  126201. flushFramebuffer(): void;
  126202. /**
  126203. * Unbind the current render target and bind the default framebuffer
  126204. */
  126205. restoreDefaultFramebuffer(): void;
  126206. /** @hidden */
  126207. protected _resetVertexBufferBinding(): void;
  126208. /**
  126209. * Creates a vertex buffer
  126210. * @param data the data for the vertex buffer
  126211. * @returns the new WebGL static buffer
  126212. */
  126213. createVertexBuffer(data: DataArray): DataBuffer;
  126214. private _createVertexBuffer;
  126215. /**
  126216. * Creates a dynamic vertex buffer
  126217. * @param data the data for the dynamic vertex buffer
  126218. * @returns the new WebGL dynamic buffer
  126219. */
  126220. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  126221. protected _resetIndexBufferBinding(): void;
  126222. /**
  126223. * Creates a new index buffer
  126224. * @param indices defines the content of the index buffer
  126225. * @param updatable defines if the index buffer must be updatable
  126226. * @returns a new webGL buffer
  126227. */
  126228. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  126229. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  126230. /**
  126231. * Bind a webGL buffer to the webGL context
  126232. * @param buffer defines the buffer to bind
  126233. */
  126234. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  126235. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  126236. private bindBuffer;
  126237. /**
  126238. * update the bound buffer with the given data
  126239. * @param data defines the data to update
  126240. */
  126241. updateArrayBuffer(data: Float32Array): void;
  126242. private _vertexAttribPointer;
  126243. /** @hidden */
  126244. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  126245. private _bindVertexBuffersAttributes;
  126246. /**
  126247. * Records a vertex array object
  126248. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  126249. * @param vertexBuffers defines the list of vertex buffers to store
  126250. * @param indexBuffer defines the index buffer to store
  126251. * @param effect defines the effect to store
  126252. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  126253. * @returns the new vertex array object
  126254. */
  126255. recordVertexArrayObject(vertexBuffers: {
  126256. [key: string]: VertexBuffer;
  126257. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  126258. [kind: string]: Nullable<VertexBuffer>;
  126259. }): WebGLVertexArrayObject;
  126260. /**
  126261. * Bind a specific vertex array object
  126262. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  126263. * @param vertexArrayObject defines the vertex array object to bind
  126264. * @param indexBuffer defines the index buffer to bind
  126265. */
  126266. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  126267. /**
  126268. * Bind webGl buffers directly to the webGL context
  126269. * @param vertexBuffer defines the vertex buffer to bind
  126270. * @param indexBuffer defines the index buffer to bind
  126271. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  126272. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  126273. * @param effect defines the effect associated with the vertex buffer
  126274. */
  126275. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  126276. private _unbindVertexArrayObject;
  126277. /**
  126278. * Bind a list of vertex buffers to the webGL context
  126279. * @param vertexBuffers defines the list of vertex buffers to bind
  126280. * @param indexBuffer defines the index buffer to bind
  126281. * @param effect defines the effect associated with the vertex buffers
  126282. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  126283. */
  126284. bindBuffers(vertexBuffers: {
  126285. [key: string]: Nullable<VertexBuffer>;
  126286. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  126287. [kind: string]: Nullable<VertexBuffer>;
  126288. }): void;
  126289. /**
  126290. * Unbind all instance attributes
  126291. */
  126292. unbindInstanceAttributes(): void;
  126293. /**
  126294. * Release and free the memory of a vertex array object
  126295. * @param vao defines the vertex array object to delete
  126296. */
  126297. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  126298. /** @hidden */
  126299. _releaseBuffer(buffer: DataBuffer): boolean;
  126300. protected _deleteBuffer(buffer: DataBuffer): void;
  126301. /**
  126302. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  126303. * @param instancesBuffer defines the webGL buffer to update and bind
  126304. * @param data defines the data to store in the buffer
  126305. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  126306. */
  126307. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  126308. /**
  126309. * Bind the content of a webGL buffer used with instantiation
  126310. * @param instancesBuffer defines the webGL buffer to bind
  126311. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  126312. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  126313. */
  126314. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  126315. /**
  126316. * Disable the instance attribute corresponding to the name in parameter
  126317. * @param name defines the name of the attribute to disable
  126318. */
  126319. disableInstanceAttributeByName(name: string): void;
  126320. /**
  126321. * Disable the instance attribute corresponding to the location in parameter
  126322. * @param attributeLocation defines the attribute location of the attribute to disable
  126323. */
  126324. disableInstanceAttribute(attributeLocation: number): void;
  126325. /**
  126326. * Disable the attribute corresponding to the location in parameter
  126327. * @param attributeLocation defines the attribute location of the attribute to disable
  126328. */
  126329. disableAttributeByIndex(attributeLocation: number): void;
  126330. /**
  126331. * Send a draw order
  126332. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  126333. * @param indexStart defines the starting index
  126334. * @param indexCount defines the number of index to draw
  126335. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  126336. */
  126337. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  126338. /**
  126339. * Draw a list of points
  126340. * @param verticesStart defines the index of first vertex to draw
  126341. * @param verticesCount defines the count of vertices to draw
  126342. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  126343. */
  126344. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  126345. /**
  126346. * Draw a list of unindexed primitives
  126347. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  126348. * @param verticesStart defines the index of first vertex to draw
  126349. * @param verticesCount defines the count of vertices to draw
  126350. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  126351. */
  126352. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  126353. /**
  126354. * Draw a list of indexed primitives
  126355. * @param fillMode defines the primitive to use
  126356. * @param indexStart defines the starting index
  126357. * @param indexCount defines the number of index to draw
  126358. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  126359. */
  126360. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  126361. /**
  126362. * Draw a list of unindexed primitives
  126363. * @param fillMode defines the primitive to use
  126364. * @param verticesStart defines the index of first vertex to draw
  126365. * @param verticesCount defines the count of vertices to draw
  126366. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  126367. */
  126368. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  126369. private _drawMode;
  126370. /** @hidden */
  126371. protected _reportDrawCall(): void;
  126372. /** @hidden */
  126373. _releaseEffect(effect: Effect): void;
  126374. /** @hidden */
  126375. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  126376. /**
  126377. * Create a new effect (used to store vertex/fragment shaders)
  126378. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  126379. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  126380. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  126381. * @param samplers defines an array of string used to represent textures
  126382. * @param defines defines the string containing the defines to use to compile the shaders
  126383. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  126384. * @param onCompiled defines a function to call when the effect creation is successful
  126385. * @param onError defines a function to call when the effect creation has failed
  126386. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  126387. * @returns the new Effect
  126388. */
  126389. 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;
  126390. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  126391. private _compileShader;
  126392. private _compileRawShader;
  126393. /** @hidden */
  126394. _getShaderSource(shader: WebGLShader): Nullable<string>;
  126395. /**
  126396. * Directly creates a webGL program
  126397. * @param pipelineContext defines the pipeline context to attach to
  126398. * @param vertexCode defines the vertex shader code to use
  126399. * @param fragmentCode defines the fragment shader code to use
  126400. * @param context defines the webGL context to use (if not set, the current one will be used)
  126401. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  126402. * @returns the new webGL program
  126403. */
  126404. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  126405. /**
  126406. * Creates a webGL program
  126407. * @param pipelineContext defines the pipeline context to attach to
  126408. * @param vertexCode defines the vertex shader code to use
  126409. * @param fragmentCode defines the fragment shader code to use
  126410. * @param defines defines the string containing the defines to use to compile the shaders
  126411. * @param context defines the webGL context to use (if not set, the current one will be used)
  126412. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  126413. * @returns the new webGL program
  126414. */
  126415. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  126416. /**
  126417. * Creates a new pipeline context
  126418. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  126419. * @returns the new pipeline
  126420. */
  126421. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  126422. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  126423. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  126424. /** @hidden */
  126425. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  126426. /** @hidden */
  126427. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  126428. /** @hidden */
  126429. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  126430. /**
  126431. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  126432. * @param pipelineContext defines the pipeline context to use
  126433. * @param uniformsNames defines the list of uniform names
  126434. * @returns an array of webGL uniform locations
  126435. */
  126436. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  126437. /**
  126438. * Gets the list of active attributes for a given webGL program
  126439. * @param pipelineContext defines the pipeline context to use
  126440. * @param attributesNames defines the list of attribute names to get
  126441. * @returns an array of indices indicating the offset of each attribute
  126442. */
  126443. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  126444. /**
  126445. * Activates an effect, making it the current one (ie. the one used for rendering)
  126446. * @param effect defines the effect to activate
  126447. */
  126448. enableEffect(effect: Nullable<Effect>): void;
  126449. /**
  126450. * Set the value of an uniform to a number (int)
  126451. * @param uniform defines the webGL uniform location where to store the value
  126452. * @param value defines the int number to store
  126453. * @returns true if the value was set
  126454. */
  126455. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  126456. /**
  126457. * Set the value of an uniform to a int2
  126458. * @param uniform defines the webGL uniform location where to store the value
  126459. * @param x defines the 1st component of the value
  126460. * @param y defines the 2nd component of the value
  126461. * @returns true if the value was set
  126462. */
  126463. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  126464. /**
  126465. * Set the value of an uniform to a int3
  126466. * @param uniform defines the webGL uniform location where to store the value
  126467. * @param x defines the 1st component of the value
  126468. * @param y defines the 2nd component of the value
  126469. * @param z defines the 3rd component of the value
  126470. * @returns true if the value was set
  126471. */
  126472. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  126473. /**
  126474. * Set the value of an uniform to a int4
  126475. * @param uniform defines the webGL uniform location where to store the value
  126476. * @param x defines the 1st component of the value
  126477. * @param y defines the 2nd component of the value
  126478. * @param z defines the 3rd component of the value
  126479. * @param w defines the 4th component of the value
  126480. * @returns true if the value was set
  126481. */
  126482. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  126483. /**
  126484. * Set the value of an uniform to an array of int32
  126485. * @param uniform defines the webGL uniform location where to store the value
  126486. * @param array defines the array of int32 to store
  126487. * @returns true if the value was set
  126488. */
  126489. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  126490. /**
  126491. * Set the value of an uniform to an array of int32 (stored as vec2)
  126492. * @param uniform defines the webGL uniform location where to store the value
  126493. * @param array defines the array of int32 to store
  126494. * @returns true if the value was set
  126495. */
  126496. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  126497. /**
  126498. * Set the value of an uniform to an array of int32 (stored as vec3)
  126499. * @param uniform defines the webGL uniform location where to store the value
  126500. * @param array defines the array of int32 to store
  126501. * @returns true if the value was set
  126502. */
  126503. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  126504. /**
  126505. * Set the value of an uniform to an array of int32 (stored as vec4)
  126506. * @param uniform defines the webGL uniform location where to store the value
  126507. * @param array defines the array of int32 to store
  126508. * @returns true if the value was set
  126509. */
  126510. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  126511. /**
  126512. * Set the value of an uniform to an array of number
  126513. * @param uniform defines the webGL uniform location where to store the value
  126514. * @param array defines the array of number to store
  126515. * @returns true if the value was set
  126516. */
  126517. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  126518. /**
  126519. * Set the value of an uniform to an array of number (stored as vec2)
  126520. * @param uniform defines the webGL uniform location where to store the value
  126521. * @param array defines the array of number to store
  126522. * @returns true if the value was set
  126523. */
  126524. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  126525. /**
  126526. * Set the value of an uniform to an array of number (stored as vec3)
  126527. * @param uniform defines the webGL uniform location where to store the value
  126528. * @param array defines the array of number to store
  126529. * @returns true if the value was set
  126530. */
  126531. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  126532. /**
  126533. * Set the value of an uniform to an array of number (stored as vec4)
  126534. * @param uniform defines the webGL uniform location where to store the value
  126535. * @param array defines the array of number to store
  126536. * @returns true if the value was set
  126537. */
  126538. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  126539. /**
  126540. * Set the value of an uniform to an array of float32 (stored as matrices)
  126541. * @param uniform defines the webGL uniform location where to store the value
  126542. * @param matrices defines the array of float32 to store
  126543. * @returns true if the value was set
  126544. */
  126545. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  126546. /**
  126547. * Set the value of an uniform to a matrix (3x3)
  126548. * @param uniform defines the webGL uniform location where to store the value
  126549. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  126550. * @returns true if the value was set
  126551. */
  126552. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  126553. /**
  126554. * Set the value of an uniform to a matrix (2x2)
  126555. * @param uniform defines the webGL uniform location where to store the value
  126556. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  126557. * @returns true if the value was set
  126558. */
  126559. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  126560. /**
  126561. * Set the value of an uniform to a number (float)
  126562. * @param uniform defines the webGL uniform location where to store the value
  126563. * @param value defines the float number to store
  126564. * @returns true if the value was transferred
  126565. */
  126566. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  126567. /**
  126568. * Set the value of an uniform to a vec2
  126569. * @param uniform defines the webGL uniform location where to store the value
  126570. * @param x defines the 1st component of the value
  126571. * @param y defines the 2nd component of the value
  126572. * @returns true if the value was set
  126573. */
  126574. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  126575. /**
  126576. * Set the value of an uniform to a vec3
  126577. * @param uniform defines the webGL uniform location where to store the value
  126578. * @param x defines the 1st component of the value
  126579. * @param y defines the 2nd component of the value
  126580. * @param z defines the 3rd component of the value
  126581. * @returns true if the value was set
  126582. */
  126583. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  126584. /**
  126585. * Set the value of an uniform to a vec4
  126586. * @param uniform defines the webGL uniform location where to store the value
  126587. * @param x defines the 1st component of the value
  126588. * @param y defines the 2nd component of the value
  126589. * @param z defines the 3rd component of the value
  126590. * @param w defines the 4th component of the value
  126591. * @returns true if the value was set
  126592. */
  126593. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  126594. /**
  126595. * Apply all cached states (depth, culling, stencil and alpha)
  126596. */
  126597. applyStates(): void;
  126598. /**
  126599. * Enable or disable color writing
  126600. * @param enable defines the state to set
  126601. */
  126602. setColorWrite(enable: boolean): void;
  126603. /**
  126604. * Gets a boolean indicating if color writing is enabled
  126605. * @returns the current color writing state
  126606. */
  126607. getColorWrite(): boolean;
  126608. /**
  126609. * Gets the depth culling state manager
  126610. */
  126611. get depthCullingState(): DepthCullingState;
  126612. /**
  126613. * Gets the alpha state manager
  126614. */
  126615. get alphaState(): AlphaState;
  126616. /**
  126617. * Gets the stencil state manager
  126618. */
  126619. get stencilState(): StencilState;
  126620. /**
  126621. * Clears the list of texture accessible through engine.
  126622. * This can help preventing texture load conflict due to name collision.
  126623. */
  126624. clearInternalTexturesCache(): void;
  126625. /**
  126626. * Force the entire cache to be cleared
  126627. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  126628. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  126629. */
  126630. wipeCaches(bruteForce?: boolean): void;
  126631. /** @hidden */
  126632. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  126633. min: number;
  126634. mag: number;
  126635. };
  126636. /** @hidden */
  126637. protected _createTexture(): WebGLTexture;
  126638. /** @hidden */
  126639. _createHardwareTexture(): HardwareTextureWrapper;
  126640. protected _createTextureBase(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode: number | undefined, onLoad: (() => void) | null | undefined, onError: ((message: string, exception: any) => void) | null | undefined, prepareTexture: (texture: InternalTexture, extension: string, scene: Nullable<ISceneLike>, img: HTMLImageElement | ImageBitmap | {
  126641. width: number;
  126642. height: number;
  126643. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  126644. width: number;
  126645. height: number;
  126646. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  126647. width: number;
  126648. height: number;
  126649. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  126650. /**
  126651. * Usually called from Texture.ts.
  126652. * Passed information to create a WebGLTexture
  126653. * @param url defines a value which contains one of the following:
  126654. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  126655. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  126656. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  126657. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  126658. * @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)
  126659. * @param scene needed for loading to the correct scene
  126660. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  126661. * @param onLoad optional callback to be called upon successful completion
  126662. * @param onError optional callback to be called upon failure
  126663. * @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
  126664. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  126665. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  126666. * @param forcedExtension defines the extension to use to pick the right loader
  126667. * @param mimeType defines an optional mime type
  126668. * @param loaderOptions options to be passed to the loader
  126669. * @returns a InternalTexture for assignment back into BABYLON.Texture
  126670. */
  126671. 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;
  126672. /**
  126673. * Loads an image as an HTMLImageElement.
  126674. * @param input url string, ArrayBuffer, or Blob to load
  126675. * @param onLoad callback called when the image successfully loads
  126676. * @param onError callback called when the image fails to load
  126677. * @param offlineProvider offline provider for caching
  126678. * @param mimeType optional mime type
  126679. * @returns the HTMLImageElement of the loaded image
  126680. * @hidden
  126681. */
  126682. 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>;
  126683. /**
  126684. * @hidden
  126685. */
  126686. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  126687. private _unpackFlipYCached;
  126688. /**
  126689. * In case you are sharing the context with other applications, it might
  126690. * be interested to not cache the unpack flip y state to ensure a consistent
  126691. * value would be set.
  126692. */
  126693. enableUnpackFlipYCached: boolean;
  126694. /** @hidden */
  126695. _unpackFlipY(value: boolean): void;
  126696. /** @hidden */
  126697. _getUnpackAlignement(): number;
  126698. private _getTextureTarget;
  126699. /**
  126700. * Update the sampling mode of a given texture
  126701. * @param samplingMode defines the required sampling mode
  126702. * @param texture defines the texture to update
  126703. * @param generateMipMaps defines whether to generate mipmaps for the texture
  126704. */
  126705. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  126706. /**
  126707. * Update the dimensions of a texture
  126708. * @param texture texture to update
  126709. * @param width new width of the texture
  126710. * @param height new height of the texture
  126711. * @param depth new depth of the texture
  126712. */
  126713. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  126714. /**
  126715. * Update the sampling mode of a given texture
  126716. * @param texture defines the texture to update
  126717. * @param wrapU defines the texture wrap mode of the u coordinates
  126718. * @param wrapV defines the texture wrap mode of the v coordinates
  126719. * @param wrapR defines the texture wrap mode of the r coordinates
  126720. */
  126721. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  126722. /** @hidden */
  126723. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  126724. width: number;
  126725. height: number;
  126726. layers?: number;
  126727. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  126728. /** @hidden */
  126729. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  126730. /** @hidden */
  126731. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  126732. /**
  126733. * Update a portion of an internal texture
  126734. * @param texture defines the texture to update
  126735. * @param imageData defines the data to store into the texture
  126736. * @param xOffset defines the x coordinates of the update rectangle
  126737. * @param yOffset defines the y coordinates of the update rectangle
  126738. * @param width defines the width of the update rectangle
  126739. * @param height defines the height of the update rectangle
  126740. * @param faceIndex defines the face index if texture is a cube (0 by default)
  126741. * @param lod defines the lod level to update (0 by default)
  126742. */
  126743. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  126744. /** @hidden */
  126745. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  126746. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  126747. private _prepareWebGLTexture;
  126748. /** @hidden */
  126749. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  126750. private _getDepthStencilBuffer;
  126751. /** @hidden */
  126752. _releaseFramebufferObjects(texture: InternalTexture): void;
  126753. /** @hidden */
  126754. _releaseTexture(texture: InternalTexture): void;
  126755. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  126756. protected _setProgram(program: WebGLProgram): void;
  126757. protected _boundUniforms: {
  126758. [key: number]: WebGLUniformLocation;
  126759. };
  126760. /**
  126761. * Binds an effect to the webGL context
  126762. * @param effect defines the effect to bind
  126763. */
  126764. bindSamplers(effect: Effect): void;
  126765. private _activateCurrentTexture;
  126766. /** @hidden */
  126767. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  126768. /** @hidden */
  126769. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  126770. /**
  126771. * Unbind all textures from the webGL context
  126772. */
  126773. unbindAllTextures(): void;
  126774. /**
  126775. * Sets a texture to the according uniform.
  126776. * @param channel The texture channel
  126777. * @param uniform The uniform to set
  126778. * @param texture The texture to apply
  126779. * @param name The name of the uniform in the effect
  126780. */
  126781. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  126782. private _bindSamplerUniformToChannel;
  126783. private _getTextureWrapMode;
  126784. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  126785. /**
  126786. * Sets an array of texture to the webGL context
  126787. * @param channel defines the channel where the texture array must be set
  126788. * @param uniform defines the associated uniform location
  126789. * @param textures defines the array of textures to bind
  126790. * @param name name of the channel
  126791. */
  126792. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  126793. /** @hidden */
  126794. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  126795. private _setTextureParameterFloat;
  126796. private _setTextureParameterInteger;
  126797. /**
  126798. * Unbind all vertex attributes from the webGL context
  126799. */
  126800. unbindAllAttributes(): void;
  126801. /**
  126802. * 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
  126803. */
  126804. releaseEffects(): void;
  126805. /**
  126806. * Dispose and release all associated resources
  126807. */
  126808. dispose(): void;
  126809. /**
  126810. * Attach a new callback raised when context lost event is fired
  126811. * @param callback defines the callback to call
  126812. */
  126813. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  126814. /**
  126815. * Attach a new callback raised when context restored event is fired
  126816. * @param callback defines the callback to call
  126817. */
  126818. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  126819. /**
  126820. * Get the current error code of the webGL context
  126821. * @returns the error code
  126822. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  126823. */
  126824. getError(): number;
  126825. private _canRenderToFloatFramebuffer;
  126826. private _canRenderToHalfFloatFramebuffer;
  126827. private _canRenderToFramebuffer;
  126828. /** @hidden */
  126829. _getWebGLTextureType(type: number): number;
  126830. /** @hidden */
  126831. _getInternalFormat(format: number): number;
  126832. /** @hidden */
  126833. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  126834. /** @hidden */
  126835. _getRGBAMultiSampleBufferFormat(type: number): number;
  126836. /** @hidden */
  126837. _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;
  126838. /**
  126839. * Loads a file from a url
  126840. * @param url url to load
  126841. * @param onSuccess callback called when the file successfully loads
  126842. * @param onProgress callback called while file is loading (if the server supports this mode)
  126843. * @param offlineProvider defines the offline provider for caching
  126844. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126845. * @param onError callback called when the file fails to load
  126846. * @returns a file request object
  126847. * @hidden
  126848. */
  126849. 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;
  126850. /**
  126851. * Reads pixels from the current frame buffer. Please note that this function can be slow
  126852. * @param x defines the x coordinate of the rectangle where pixels must be read
  126853. * @param y defines the y coordinate of the rectangle where pixels must be read
  126854. * @param width defines the width of the rectangle where pixels must be read
  126855. * @param height defines the height of the rectangle where pixels must be read
  126856. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  126857. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  126858. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  126859. */
  126860. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  126861. private static _IsSupported;
  126862. private static _HasMajorPerformanceCaveat;
  126863. /**
  126864. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  126865. */
  126866. static get IsSupported(): boolean;
  126867. /**
  126868. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  126869. * @returns true if the engine can be created
  126870. * @ignorenaming
  126871. */
  126872. static isSupported(): boolean;
  126873. /**
  126874. * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  126875. */
  126876. static get HasMajorPerformanceCaveat(): boolean;
  126877. /**
  126878. * Find the next highest power of two.
  126879. * @param x Number to start search from.
  126880. * @return Next highest power of two.
  126881. */
  126882. static CeilingPOT(x: number): number;
  126883. /**
  126884. * Find the next lowest power of two.
  126885. * @param x Number to start search from.
  126886. * @return Next lowest power of two.
  126887. */
  126888. static FloorPOT(x: number): number;
  126889. /**
  126890. * Find the nearest power of two.
  126891. * @param x Number to start search from.
  126892. * @return Next nearest power of two.
  126893. */
  126894. static NearestPOT(x: number): number;
  126895. /**
  126896. * Get the closest exponent of two
  126897. * @param value defines the value to approximate
  126898. * @param max defines the maximum value to return
  126899. * @param mode defines how to define the closest value
  126900. * @returns closest exponent of two of the given value
  126901. */
  126902. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  126903. /**
  126904. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  126905. * @param func - the function to be called
  126906. * @param requester - the object that will request the next frame. Falls back to window.
  126907. * @returns frame number
  126908. */
  126909. static QueueNewFrame(func: () => void, requester?: any): number;
  126910. /**
  126911. * Gets host document
  126912. * @returns the host document object
  126913. */
  126914. getHostDocument(): Nullable<Document>;
  126915. }
  126916. }
  126917. declare module BABYLON {
  126918. /**
  126919. * Defines the source of the internal texture
  126920. */
  126921. export enum InternalTextureSource {
  126922. /**
  126923. * The source of the texture data is unknown
  126924. */
  126925. Unknown = 0,
  126926. /**
  126927. * Texture data comes from an URL
  126928. */
  126929. Url = 1,
  126930. /**
  126931. * Texture data is only used for temporary storage
  126932. */
  126933. Temp = 2,
  126934. /**
  126935. * Texture data comes from raw data (ArrayBuffer)
  126936. */
  126937. Raw = 3,
  126938. /**
  126939. * Texture content is dynamic (video or dynamic texture)
  126940. */
  126941. Dynamic = 4,
  126942. /**
  126943. * Texture content is generated by rendering to it
  126944. */
  126945. RenderTarget = 5,
  126946. /**
  126947. * Texture content is part of a multi render target process
  126948. */
  126949. MultiRenderTarget = 6,
  126950. /**
  126951. * Texture data comes from a cube data file
  126952. */
  126953. Cube = 7,
  126954. /**
  126955. * Texture data comes from a raw cube data
  126956. */
  126957. CubeRaw = 8,
  126958. /**
  126959. * Texture data come from a prefiltered cube data file
  126960. */
  126961. CubePrefiltered = 9,
  126962. /**
  126963. * Texture content is raw 3D data
  126964. */
  126965. Raw3D = 10,
  126966. /**
  126967. * Texture content is raw 2D array data
  126968. */
  126969. Raw2DArray = 11,
  126970. /**
  126971. * Texture content is a depth texture
  126972. */
  126973. Depth = 12,
  126974. /**
  126975. * Texture data comes from a raw cube data encoded with RGBD
  126976. */
  126977. CubeRawRGBD = 13
  126978. }
  126979. /**
  126980. * Class used to store data associated with WebGL texture data for the engine
  126981. * This class should not be used directly
  126982. */
  126983. export class InternalTexture {
  126984. /** @hidden */
  126985. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  126986. /**
  126987. * Defines if the texture is ready
  126988. */
  126989. isReady: boolean;
  126990. /**
  126991. * Defines if the texture is a cube texture
  126992. */
  126993. isCube: boolean;
  126994. /**
  126995. * Defines if the texture contains 3D data
  126996. */
  126997. is3D: boolean;
  126998. /**
  126999. * Defines if the texture contains 2D array data
  127000. */
  127001. is2DArray: boolean;
  127002. /**
  127003. * Defines if the texture contains multiview data
  127004. */
  127005. isMultiview: boolean;
  127006. /**
  127007. * Gets the URL used to load this texture
  127008. */
  127009. url: string;
  127010. /** @hidden */
  127011. _originalUrl: string;
  127012. /**
  127013. * Gets the sampling mode of the texture
  127014. */
  127015. samplingMode: number;
  127016. /**
  127017. * Gets a boolean indicating if the texture needs mipmaps generation
  127018. */
  127019. generateMipMaps: boolean;
  127020. /**
  127021. * Gets the number of samples used by the texture (WebGL2+ only)
  127022. */
  127023. samples: number;
  127024. /**
  127025. * Gets the type of the texture (int, float...)
  127026. */
  127027. type: number;
  127028. /**
  127029. * Gets the format of the texture (RGB, RGBA...)
  127030. */
  127031. format: number;
  127032. /**
  127033. * Observable called when the texture is loaded
  127034. */
  127035. onLoadedObservable: Observable<InternalTexture>;
  127036. /**
  127037. * Gets the width of the texture
  127038. */
  127039. width: number;
  127040. /**
  127041. * Gets the height of the texture
  127042. */
  127043. height: number;
  127044. /**
  127045. * Gets the depth of the texture
  127046. */
  127047. depth: number;
  127048. /**
  127049. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  127050. */
  127051. baseWidth: number;
  127052. /**
  127053. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  127054. */
  127055. baseHeight: number;
  127056. /**
  127057. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  127058. */
  127059. baseDepth: number;
  127060. /**
  127061. * Gets a boolean indicating if the texture is inverted on Y axis
  127062. */
  127063. invertY: boolean;
  127064. /** @hidden */
  127065. _invertVScale: boolean;
  127066. /** @hidden */
  127067. _associatedChannel: number;
  127068. /** @hidden */
  127069. _source: InternalTextureSource;
  127070. /** @hidden */
  127071. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  127072. /** @hidden */
  127073. _bufferView: Nullable<ArrayBufferView>;
  127074. /** @hidden */
  127075. _bufferViewArray: Nullable<ArrayBufferView[]>;
  127076. /** @hidden */
  127077. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  127078. /** @hidden */
  127079. _size: number;
  127080. /** @hidden */
  127081. _extension: string;
  127082. /** @hidden */
  127083. _files: Nullable<string[]>;
  127084. /** @hidden */
  127085. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  127086. /** @hidden */
  127087. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  127088. /** @hidden */
  127089. _framebuffer: Nullable<WebGLFramebuffer>;
  127090. /** @hidden */
  127091. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  127092. /** @hidden */
  127093. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  127094. /** @hidden */
  127095. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  127096. /** @hidden */
  127097. _attachments: Nullable<number[]>;
  127098. /** @hidden */
  127099. _textureArray: Nullable<InternalTexture[]>;
  127100. /** @hidden */
  127101. _cachedCoordinatesMode: Nullable<number>;
  127102. /** @hidden */
  127103. _cachedWrapU: Nullable<number>;
  127104. /** @hidden */
  127105. _cachedWrapV: Nullable<number>;
  127106. /** @hidden */
  127107. _cachedWrapR: Nullable<number>;
  127108. /** @hidden */
  127109. _cachedAnisotropicFilteringLevel: Nullable<number>;
  127110. /** @hidden */
  127111. _isDisabled: boolean;
  127112. /** @hidden */
  127113. _compression: Nullable<string>;
  127114. /** @hidden */
  127115. _generateStencilBuffer: boolean;
  127116. /** @hidden */
  127117. _generateDepthBuffer: boolean;
  127118. /** @hidden */
  127119. _comparisonFunction: number;
  127120. /** @hidden */
  127121. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  127122. /** @hidden */
  127123. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  127124. /** @hidden */
  127125. _sphericalPolynomialComputed: boolean;
  127126. /** @hidden */
  127127. _lodGenerationScale: number;
  127128. /** @hidden */
  127129. _lodGenerationOffset: number;
  127130. /** @hidden */
  127131. _depthStencilTexture: Nullable<InternalTexture>;
  127132. /** @hidden */
  127133. _colorTextureArray: Nullable<WebGLTexture>;
  127134. /** @hidden */
  127135. _depthStencilTextureArray: Nullable<WebGLTexture>;
  127136. /** @hidden */
  127137. _lodTextureHigh: Nullable<BaseTexture>;
  127138. /** @hidden */
  127139. _lodTextureMid: Nullable<BaseTexture>;
  127140. /** @hidden */
  127141. _lodTextureLow: Nullable<BaseTexture>;
  127142. /** @hidden */
  127143. _isRGBD: boolean;
  127144. /** @hidden */
  127145. _linearSpecularLOD: boolean;
  127146. /** @hidden */
  127147. _irradianceTexture: Nullable<BaseTexture>;
  127148. /** @hidden */
  127149. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  127150. /** @hidden */
  127151. _references: number;
  127152. /** @hidden */
  127153. _gammaSpace: Nullable<boolean>;
  127154. private _engine;
  127155. private _uniqueId;
  127156. private static _Counter;
  127157. /** Gets the unique id of the internal texture */
  127158. get uniqueId(): number;
  127159. /**
  127160. * Gets the Engine the texture belongs to.
  127161. * @returns The babylon engine
  127162. */
  127163. getEngine(): ThinEngine;
  127164. /**
  127165. * Gets the data source type of the texture
  127166. */
  127167. get source(): InternalTextureSource;
  127168. /**
  127169. * Creates a new InternalTexture
  127170. * @param engine defines the engine to use
  127171. * @param source defines the type of data that will be used
  127172. * @param delayAllocation if the texture allocation should be delayed (default: false)
  127173. */
  127174. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  127175. /**
  127176. * Increments the number of references (ie. the number of Texture that point to it)
  127177. */
  127178. incrementReferences(): void;
  127179. /**
  127180. * Change the size of the texture (not the size of the content)
  127181. * @param width defines the new width
  127182. * @param height defines the new height
  127183. * @param depth defines the new depth (1 by default)
  127184. */
  127185. updateSize(width: int, height: int, depth?: int): void;
  127186. /** @hidden */
  127187. _rebuild(): void;
  127188. /** @hidden */
  127189. _swapAndDie(target: InternalTexture): void;
  127190. /**
  127191. * Dispose the current allocated resources
  127192. */
  127193. dispose(): void;
  127194. }
  127195. }
  127196. declare module BABYLON {
  127197. /**
  127198. * Interface used to present a loading screen while loading a scene
  127199. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127200. */
  127201. export interface ILoadingScreen {
  127202. /**
  127203. * Function called to display the loading screen
  127204. */
  127205. displayLoadingUI: () => void;
  127206. /**
  127207. * Function called to hide the loading screen
  127208. */
  127209. hideLoadingUI: () => void;
  127210. /**
  127211. * Gets or sets the color to use for the background
  127212. */
  127213. loadingUIBackgroundColor: string;
  127214. /**
  127215. * Gets or sets the text to display while loading
  127216. */
  127217. loadingUIText: string;
  127218. }
  127219. /**
  127220. * Class used for the default loading screen
  127221. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127222. */
  127223. export class DefaultLoadingScreen implements ILoadingScreen {
  127224. private _renderingCanvas;
  127225. private _loadingText;
  127226. private _loadingDivBackgroundColor;
  127227. private _loadingDiv;
  127228. private _loadingTextDiv;
  127229. /** Gets or sets the logo url to use for the default loading screen */
  127230. static DefaultLogoUrl: string;
  127231. /** Gets or sets the spinner url to use for the default loading screen */
  127232. static DefaultSpinnerUrl: string;
  127233. /**
  127234. * Creates a new default loading screen
  127235. * @param _renderingCanvas defines the canvas used to render the scene
  127236. * @param _loadingText defines the default text to display
  127237. * @param _loadingDivBackgroundColor defines the default background color
  127238. */
  127239. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  127240. /**
  127241. * Function called to display the loading screen
  127242. */
  127243. displayLoadingUI(): void;
  127244. /**
  127245. * Function called to hide the loading screen
  127246. */
  127247. hideLoadingUI(): void;
  127248. /**
  127249. * Gets or sets the text to display while loading
  127250. */
  127251. set loadingUIText(text: string);
  127252. get loadingUIText(): string;
  127253. /**
  127254. * Gets or sets the color to use for the background
  127255. */
  127256. get loadingUIBackgroundColor(): string;
  127257. set loadingUIBackgroundColor(color: string);
  127258. private _resizeLoadingUI;
  127259. }
  127260. }
  127261. declare module BABYLON {
  127262. /**
  127263. * Interface for any object that can request an animation frame
  127264. */
  127265. export interface ICustomAnimationFrameRequester {
  127266. /**
  127267. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  127268. */
  127269. renderFunction?: Function;
  127270. /**
  127271. * Called to request the next frame to render to
  127272. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  127273. */
  127274. requestAnimationFrame: Function;
  127275. /**
  127276. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  127277. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  127278. */
  127279. requestID?: number;
  127280. }
  127281. }
  127282. declare module BABYLON {
  127283. /**
  127284. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  127285. */
  127286. export class PerformanceMonitor {
  127287. private _enabled;
  127288. private _rollingFrameTime;
  127289. private _lastFrameTimeMs;
  127290. /**
  127291. * constructor
  127292. * @param frameSampleSize The number of samples required to saturate the sliding window
  127293. */
  127294. constructor(frameSampleSize?: number);
  127295. /**
  127296. * Samples current frame
  127297. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  127298. */
  127299. sampleFrame(timeMs?: number): void;
  127300. /**
  127301. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  127302. */
  127303. get averageFrameTime(): number;
  127304. /**
  127305. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  127306. */
  127307. get averageFrameTimeVariance(): number;
  127308. /**
  127309. * Returns the frame time of the most recent frame
  127310. */
  127311. get instantaneousFrameTime(): number;
  127312. /**
  127313. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  127314. */
  127315. get averageFPS(): number;
  127316. /**
  127317. * Returns the average framerate in frames per second using the most recent frame time
  127318. */
  127319. get instantaneousFPS(): number;
  127320. /**
  127321. * Returns true if enough samples have been taken to completely fill the sliding window
  127322. */
  127323. get isSaturated(): boolean;
  127324. /**
  127325. * Enables contributions to the sliding window sample set
  127326. */
  127327. enable(): void;
  127328. /**
  127329. * Disables contributions to the sliding window sample set
  127330. * Samples will not be interpolated over the disabled period
  127331. */
  127332. disable(): void;
  127333. /**
  127334. * Returns true if sampling is enabled
  127335. */
  127336. get isEnabled(): boolean;
  127337. /**
  127338. * Resets performance monitor
  127339. */
  127340. reset(): void;
  127341. }
  127342. /**
  127343. * RollingAverage
  127344. *
  127345. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  127346. */
  127347. export class RollingAverage {
  127348. /**
  127349. * Current average
  127350. */
  127351. average: number;
  127352. /**
  127353. * Current variance
  127354. */
  127355. variance: number;
  127356. protected _samples: Array<number>;
  127357. protected _sampleCount: number;
  127358. protected _pos: number;
  127359. protected _m2: number;
  127360. /**
  127361. * constructor
  127362. * @param length The number of samples required to saturate the sliding window
  127363. */
  127364. constructor(length: number);
  127365. /**
  127366. * Adds a sample to the sample set
  127367. * @param v The sample value
  127368. */
  127369. add(v: number): void;
  127370. /**
  127371. * Returns previously added values or null if outside of history or outside the sliding window domain
  127372. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  127373. * @return Value previously recorded with add() or null if outside of range
  127374. */
  127375. history(i: number): number;
  127376. /**
  127377. * Returns true if enough samples have been taken to completely fill the sliding window
  127378. * @return true if sample-set saturated
  127379. */
  127380. isSaturated(): boolean;
  127381. /**
  127382. * Resets the rolling average (equivalent to 0 samples taken so far)
  127383. */
  127384. reset(): void;
  127385. /**
  127386. * Wraps a value around the sample range boundaries
  127387. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  127388. * @return Wrapped position in sample range
  127389. */
  127390. protected _wrapPosition(i: number): number;
  127391. }
  127392. }
  127393. declare module BABYLON {
  127394. /**
  127395. * This class is used to track a performance counter which is number based.
  127396. * The user has access to many properties which give statistics of different nature.
  127397. *
  127398. * The implementer can track two kinds of Performance Counter: time and count.
  127399. * 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.
  127400. * 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.
  127401. */
  127402. export class PerfCounter {
  127403. /**
  127404. * Gets or sets a global boolean to turn on and off all the counters
  127405. */
  127406. static Enabled: boolean;
  127407. /**
  127408. * Returns the smallest value ever
  127409. */
  127410. get min(): number;
  127411. /**
  127412. * Returns the biggest value ever
  127413. */
  127414. get max(): number;
  127415. /**
  127416. * Returns the average value since the performance counter is running
  127417. */
  127418. get average(): number;
  127419. /**
  127420. * Returns the average value of the last second the counter was monitored
  127421. */
  127422. get lastSecAverage(): number;
  127423. /**
  127424. * Returns the current value
  127425. */
  127426. get current(): number;
  127427. /**
  127428. * Gets the accumulated total
  127429. */
  127430. get total(): number;
  127431. /**
  127432. * Gets the total value count
  127433. */
  127434. get count(): number;
  127435. /**
  127436. * Creates a new counter
  127437. */
  127438. constructor();
  127439. /**
  127440. * Call this method to start monitoring a new frame.
  127441. * 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.
  127442. */
  127443. fetchNewFrame(): void;
  127444. /**
  127445. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  127446. * @param newCount the count value to add to the monitored count
  127447. * @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.
  127448. */
  127449. addCount(newCount: number, fetchResult: boolean): void;
  127450. /**
  127451. * Start monitoring this performance counter
  127452. */
  127453. beginMonitoring(): void;
  127454. /**
  127455. * Compute the time lapsed since the previous beginMonitoring() call.
  127456. * @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
  127457. */
  127458. endMonitoring(newFrame?: boolean): void;
  127459. private _fetchResult;
  127460. private _startMonitoringTime;
  127461. private _min;
  127462. private _max;
  127463. private _average;
  127464. private _current;
  127465. private _totalValueCount;
  127466. private _totalAccumulated;
  127467. private _lastSecAverage;
  127468. private _lastSecAccumulated;
  127469. private _lastSecTime;
  127470. private _lastSecValueCount;
  127471. }
  127472. }
  127473. declare module BABYLON {
  127474. interface ThinEngine {
  127475. /** @hidden */
  127476. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  127477. /** @hidden */
  127478. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  127479. }
  127480. }
  127481. declare module BABYLON {
  127482. /**
  127483. * Class used to work with sound analyzer using fast fourier transform (FFT)
  127484. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127485. */
  127486. export class Analyser {
  127487. /**
  127488. * Gets or sets the smoothing
  127489. * @ignorenaming
  127490. */
  127491. SMOOTHING: number;
  127492. /**
  127493. * Gets or sets the FFT table size
  127494. * @ignorenaming
  127495. */
  127496. FFT_SIZE: number;
  127497. /**
  127498. * Gets or sets the bar graph amplitude
  127499. * @ignorenaming
  127500. */
  127501. BARGRAPHAMPLITUDE: number;
  127502. /**
  127503. * Gets or sets the position of the debug canvas
  127504. * @ignorenaming
  127505. */
  127506. DEBUGCANVASPOS: {
  127507. x: number;
  127508. y: number;
  127509. };
  127510. /**
  127511. * Gets or sets the debug canvas size
  127512. * @ignorenaming
  127513. */
  127514. DEBUGCANVASSIZE: {
  127515. width: number;
  127516. height: number;
  127517. };
  127518. private _byteFreqs;
  127519. private _byteTime;
  127520. private _floatFreqs;
  127521. private _webAudioAnalyser;
  127522. private _debugCanvas;
  127523. private _debugCanvasContext;
  127524. private _scene;
  127525. private _registerFunc;
  127526. private _audioEngine;
  127527. /**
  127528. * Creates a new analyser
  127529. * @param scene defines hosting scene
  127530. */
  127531. constructor(scene: Scene);
  127532. /**
  127533. * Get the number of data values you will have to play with for the visualization
  127534. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  127535. * @returns a number
  127536. */
  127537. getFrequencyBinCount(): number;
  127538. /**
  127539. * Gets the current frequency data as a byte array
  127540. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  127541. * @returns a Uint8Array
  127542. */
  127543. getByteFrequencyData(): Uint8Array;
  127544. /**
  127545. * Gets the current waveform as a byte array
  127546. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  127547. * @returns a Uint8Array
  127548. */
  127549. getByteTimeDomainData(): Uint8Array;
  127550. /**
  127551. * Gets the current frequency data as a float array
  127552. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  127553. * @returns a Float32Array
  127554. */
  127555. getFloatFrequencyData(): Float32Array;
  127556. /**
  127557. * Renders the debug canvas
  127558. */
  127559. drawDebugCanvas(): void;
  127560. /**
  127561. * Stops rendering the debug canvas and removes it
  127562. */
  127563. stopDebugCanvas(): void;
  127564. /**
  127565. * Connects two audio nodes
  127566. * @param inputAudioNode defines first node to connect
  127567. * @param outputAudioNode defines second node to connect
  127568. */
  127569. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  127570. /**
  127571. * Releases all associated resources
  127572. */
  127573. dispose(): void;
  127574. }
  127575. }
  127576. declare module BABYLON {
  127577. /**
  127578. * This represents an audio engine and it is responsible
  127579. * to play, synchronize and analyse sounds throughout the application.
  127580. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127581. */
  127582. export interface IAudioEngine extends IDisposable {
  127583. /**
  127584. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  127585. */
  127586. readonly canUseWebAudio: boolean;
  127587. /**
  127588. * Gets the current AudioContext if available.
  127589. */
  127590. readonly audioContext: Nullable<AudioContext>;
  127591. /**
  127592. * The master gain node defines the global audio volume of your audio engine.
  127593. */
  127594. readonly masterGain: GainNode;
  127595. /**
  127596. * Gets whether or not mp3 are supported by your browser.
  127597. */
  127598. readonly isMP3supported: boolean;
  127599. /**
  127600. * Gets whether or not ogg are supported by your browser.
  127601. */
  127602. readonly isOGGsupported: boolean;
  127603. /**
  127604. * Defines if Babylon should emit a warning if WebAudio is not supported.
  127605. * @ignoreNaming
  127606. */
  127607. WarnedWebAudioUnsupported: boolean;
  127608. /**
  127609. * Defines if the audio engine relies on a custom unlocked button.
  127610. * In this case, the embedded button will not be displayed.
  127611. */
  127612. useCustomUnlockedButton: boolean;
  127613. /**
  127614. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  127615. */
  127616. readonly unlocked: boolean;
  127617. /**
  127618. * Event raised when audio has been unlocked on the browser.
  127619. */
  127620. onAudioUnlockedObservable: Observable<IAudioEngine>;
  127621. /**
  127622. * Event raised when audio has been locked on the browser.
  127623. */
  127624. onAudioLockedObservable: Observable<IAudioEngine>;
  127625. /**
  127626. * Flags the audio engine in Locked state.
  127627. * This happens due to new browser policies preventing audio to autoplay.
  127628. */
  127629. lock(): void;
  127630. /**
  127631. * Unlocks the audio engine once a user action has been done on the dom.
  127632. * This is helpful to resume play once browser policies have been satisfied.
  127633. */
  127634. unlock(): void;
  127635. /**
  127636. * Gets the global volume sets on the master gain.
  127637. * @returns the global volume if set or -1 otherwise
  127638. */
  127639. getGlobalVolume(): number;
  127640. /**
  127641. * Sets the global volume of your experience (sets on the master gain).
  127642. * @param newVolume Defines the new global volume of the application
  127643. */
  127644. setGlobalVolume(newVolume: number): void;
  127645. /**
  127646. * Connect the audio engine to an audio analyser allowing some amazing
  127647. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  127648. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127649. * @param analyser The analyser to connect to the engine
  127650. */
  127651. connectToAnalyser(analyser: Analyser): void;
  127652. }
  127653. }
  127654. declare module BABYLON {
  127655. /**
  127656. * Defines the interface used by display changed events
  127657. */
  127658. export interface IDisplayChangedEventArgs {
  127659. /** Gets the vrDisplay object (if any) */
  127660. vrDisplay: Nullable<any>;
  127661. /** Gets a boolean indicating if webVR is supported */
  127662. vrSupported: boolean;
  127663. }
  127664. /**
  127665. * Defines the interface used by objects containing a viewport (like a camera)
  127666. */
  127667. interface IViewportOwnerLike {
  127668. /**
  127669. * Gets or sets the viewport
  127670. */
  127671. viewport: IViewportLike;
  127672. }
  127673. /**
  127674. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  127675. */
  127676. export class Engine extends ThinEngine {
  127677. /** Defines that alpha blending is disabled */
  127678. static readonly ALPHA_DISABLE: number;
  127679. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  127680. static readonly ALPHA_ADD: number;
  127681. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  127682. static readonly ALPHA_COMBINE: number;
  127683. /** Defines that alpha blending to DEST - SRC * DEST */
  127684. static readonly ALPHA_SUBTRACT: number;
  127685. /** Defines that alpha blending to SRC * DEST */
  127686. static readonly ALPHA_MULTIPLY: number;
  127687. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  127688. static readonly ALPHA_MAXIMIZED: number;
  127689. /** Defines that alpha blending to SRC + DEST */
  127690. static readonly ALPHA_ONEONE: number;
  127691. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  127692. static readonly ALPHA_PREMULTIPLIED: number;
  127693. /**
  127694. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  127695. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  127696. */
  127697. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  127698. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  127699. static readonly ALPHA_INTERPOLATE: number;
  127700. /**
  127701. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  127702. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  127703. */
  127704. static readonly ALPHA_SCREENMODE: number;
  127705. /** Defines that the resource is not delayed*/
  127706. static readonly DELAYLOADSTATE_NONE: number;
  127707. /** Defines that the resource was successfully delay loaded */
  127708. static readonly DELAYLOADSTATE_LOADED: number;
  127709. /** Defines that the resource is currently delay loading */
  127710. static readonly DELAYLOADSTATE_LOADING: number;
  127711. /** Defines that the resource is delayed and has not started loading */
  127712. static readonly DELAYLOADSTATE_NOTLOADED: number;
  127713. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  127714. static readonly NEVER: number;
  127715. /** 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 */
  127716. static readonly ALWAYS: number;
  127717. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  127718. static readonly LESS: number;
  127719. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  127720. static readonly EQUAL: number;
  127721. /** 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 */
  127722. static readonly LEQUAL: number;
  127723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  127724. static readonly GREATER: number;
  127725. /** 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 */
  127726. static readonly GEQUAL: number;
  127727. /** 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 */
  127728. static readonly NOTEQUAL: number;
  127729. /** Passed to stencilOperation to specify that stencil value must be kept */
  127730. static readonly KEEP: number;
  127731. /** Passed to stencilOperation to specify that stencil value must be replaced */
  127732. static readonly REPLACE: number;
  127733. /** Passed to stencilOperation to specify that stencil value must be incremented */
  127734. static readonly INCR: number;
  127735. /** Passed to stencilOperation to specify that stencil value must be decremented */
  127736. static readonly DECR: number;
  127737. /** Passed to stencilOperation to specify that stencil value must be inverted */
  127738. static readonly INVERT: number;
  127739. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  127740. static readonly INCR_WRAP: number;
  127741. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  127742. static readonly DECR_WRAP: number;
  127743. /** Texture is not repeating outside of 0..1 UVs */
  127744. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  127745. /** Texture is repeating outside of 0..1 UVs */
  127746. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  127747. /** Texture is repeating and mirrored */
  127748. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  127749. /** ALPHA */
  127750. static readonly TEXTUREFORMAT_ALPHA: number;
  127751. /** LUMINANCE */
  127752. static readonly TEXTUREFORMAT_LUMINANCE: number;
  127753. /** LUMINANCE_ALPHA */
  127754. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  127755. /** RGB */
  127756. static readonly TEXTUREFORMAT_RGB: number;
  127757. /** RGBA */
  127758. static readonly TEXTUREFORMAT_RGBA: number;
  127759. /** RED */
  127760. static readonly TEXTUREFORMAT_RED: number;
  127761. /** RED (2nd reference) */
  127762. static readonly TEXTUREFORMAT_R: number;
  127763. /** RG */
  127764. static readonly TEXTUREFORMAT_RG: number;
  127765. /** RED_INTEGER */
  127766. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  127767. /** RED_INTEGER (2nd reference) */
  127768. static readonly TEXTUREFORMAT_R_INTEGER: number;
  127769. /** RG_INTEGER */
  127770. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  127771. /** RGB_INTEGER */
  127772. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  127773. /** RGBA_INTEGER */
  127774. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  127775. /** UNSIGNED_BYTE */
  127776. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  127777. /** UNSIGNED_BYTE (2nd reference) */
  127778. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  127779. /** FLOAT */
  127780. static readonly TEXTURETYPE_FLOAT: number;
  127781. /** HALF_FLOAT */
  127782. static readonly TEXTURETYPE_HALF_FLOAT: number;
  127783. /** BYTE */
  127784. static readonly TEXTURETYPE_BYTE: number;
  127785. /** SHORT */
  127786. static readonly TEXTURETYPE_SHORT: number;
  127787. /** UNSIGNED_SHORT */
  127788. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  127789. /** INT */
  127790. static readonly TEXTURETYPE_INT: number;
  127791. /** UNSIGNED_INT */
  127792. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  127793. /** UNSIGNED_SHORT_4_4_4_4 */
  127794. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  127795. /** UNSIGNED_SHORT_5_5_5_1 */
  127796. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  127797. /** UNSIGNED_SHORT_5_6_5 */
  127798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  127799. /** UNSIGNED_INT_2_10_10_10_REV */
  127800. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  127801. /** UNSIGNED_INT_24_8 */
  127802. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  127803. /** UNSIGNED_INT_10F_11F_11F_REV */
  127804. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  127805. /** UNSIGNED_INT_5_9_9_9_REV */
  127806. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  127807. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  127808. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  127809. /** nearest is mag = nearest and min = nearest and mip = none */
  127810. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  127811. /** Bilinear is mag = linear and min = linear and mip = nearest */
  127812. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  127813. /** Trilinear is mag = linear and min = linear and mip = linear */
  127814. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  127815. /** nearest is mag = nearest and min = nearest and mip = linear */
  127816. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  127817. /** Bilinear is mag = linear and min = linear and mip = nearest */
  127818. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  127819. /** Trilinear is mag = linear and min = linear and mip = linear */
  127820. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  127821. /** mag = nearest and min = nearest and mip = nearest */
  127822. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  127823. /** mag = nearest and min = linear and mip = nearest */
  127824. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  127825. /** mag = nearest and min = linear and mip = linear */
  127826. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  127827. /** mag = nearest and min = linear and mip = none */
  127828. static readonly TEXTURE_NEAREST_LINEAR: number;
  127829. /** mag = nearest and min = nearest and mip = none */
  127830. static readonly TEXTURE_NEAREST_NEAREST: number;
  127831. /** mag = linear and min = nearest and mip = nearest */
  127832. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  127833. /** mag = linear and min = nearest and mip = linear */
  127834. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  127835. /** mag = linear and min = linear and mip = none */
  127836. static readonly TEXTURE_LINEAR_LINEAR: number;
  127837. /** mag = linear and min = nearest and mip = none */
  127838. static readonly TEXTURE_LINEAR_NEAREST: number;
  127839. /** Explicit coordinates mode */
  127840. static readonly TEXTURE_EXPLICIT_MODE: number;
  127841. /** Spherical coordinates mode */
  127842. static readonly TEXTURE_SPHERICAL_MODE: number;
  127843. /** Planar coordinates mode */
  127844. static readonly TEXTURE_PLANAR_MODE: number;
  127845. /** Cubic coordinates mode */
  127846. static readonly TEXTURE_CUBIC_MODE: number;
  127847. /** Projection coordinates mode */
  127848. static readonly TEXTURE_PROJECTION_MODE: number;
  127849. /** Skybox coordinates mode */
  127850. static readonly TEXTURE_SKYBOX_MODE: number;
  127851. /** Inverse Cubic coordinates mode */
  127852. static readonly TEXTURE_INVCUBIC_MODE: number;
  127853. /** Equirectangular coordinates mode */
  127854. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  127855. /** Equirectangular Fixed coordinates mode */
  127856. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  127857. /** Equirectangular Fixed Mirrored coordinates mode */
  127858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  127859. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  127860. static readonly SCALEMODE_FLOOR: number;
  127861. /** Defines that texture rescaling will look for the nearest power of 2 size */
  127862. static readonly SCALEMODE_NEAREST: number;
  127863. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  127864. static readonly SCALEMODE_CEILING: number;
  127865. /**
  127866. * Returns the current npm package of the sdk
  127867. */
  127868. static get NpmPackage(): string;
  127869. /**
  127870. * Returns the current version of the framework
  127871. */
  127872. static get Version(): string;
  127873. /** Gets the list of created engines */
  127874. static get Instances(): Engine[];
  127875. /**
  127876. * Gets the latest created engine
  127877. */
  127878. static get LastCreatedEngine(): Nullable<Engine>;
  127879. /**
  127880. * Gets the latest created scene
  127881. */
  127882. static get LastCreatedScene(): Nullable<Scene>;
  127883. /**
  127884. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  127885. * @param flag defines which part of the materials must be marked as dirty
  127886. * @param predicate defines a predicate used to filter which materials should be affected
  127887. */
  127888. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  127889. /**
  127890. * Method called to create the default loading screen.
  127891. * This can be overridden in your own app.
  127892. * @param canvas The rendering canvas element
  127893. * @returns The loading screen
  127894. */
  127895. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  127896. /**
  127897. * Method called to create the default rescale post process on each engine.
  127898. */
  127899. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  127900. /**
  127901. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  127902. **/
  127903. enableOfflineSupport: boolean;
  127904. /**
  127905. * 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)
  127906. **/
  127907. disableManifestCheck: boolean;
  127908. /**
  127909. * Gets the list of created scenes
  127910. */
  127911. scenes: Scene[];
  127912. /**
  127913. * Event raised when a new scene is created
  127914. */
  127915. onNewSceneAddedObservable: Observable<Scene>;
  127916. /**
  127917. * Gets the list of created postprocesses
  127918. */
  127919. postProcesses: PostProcess[];
  127920. /**
  127921. * Gets a boolean indicating if the pointer is currently locked
  127922. */
  127923. isPointerLock: boolean;
  127924. /**
  127925. * Observable event triggered each time the rendering canvas is resized
  127926. */
  127927. onResizeObservable: Observable<Engine>;
  127928. /**
  127929. * Observable event triggered each time the canvas loses focus
  127930. */
  127931. onCanvasBlurObservable: Observable<Engine>;
  127932. /**
  127933. * Observable event triggered each time the canvas gains focus
  127934. */
  127935. onCanvasFocusObservable: Observable<Engine>;
  127936. /**
  127937. * Observable event triggered each time the canvas receives pointerout event
  127938. */
  127939. onCanvasPointerOutObservable: Observable<PointerEvent>;
  127940. /**
  127941. * Observable raised when the engine begins a new frame
  127942. */
  127943. onBeginFrameObservable: Observable<Engine>;
  127944. /**
  127945. * If set, will be used to request the next animation frame for the render loop
  127946. */
  127947. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  127948. /**
  127949. * Observable raised when the engine ends the current frame
  127950. */
  127951. onEndFrameObservable: Observable<Engine>;
  127952. /**
  127953. * Observable raised when the engine is about to compile a shader
  127954. */
  127955. onBeforeShaderCompilationObservable: Observable<Engine>;
  127956. /**
  127957. * Observable raised when the engine has just compiled a shader
  127958. */
  127959. onAfterShaderCompilationObservable: Observable<Engine>;
  127960. /**
  127961. * Gets the audio engine
  127962. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127963. * @ignorenaming
  127964. */
  127965. static audioEngine: IAudioEngine;
  127966. /**
  127967. * Default AudioEngine factory responsible of creating the Audio Engine.
  127968. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  127969. */
  127970. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  127971. /**
  127972. * Default offline support factory responsible of creating a tool used to store data locally.
  127973. * By default, this will create a Database object if the workload has been embedded.
  127974. */
  127975. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  127976. private _loadingScreen;
  127977. private _pointerLockRequested;
  127978. private _rescalePostProcess;
  127979. protected _deterministicLockstep: boolean;
  127980. protected _lockstepMaxSteps: number;
  127981. protected _timeStep: number;
  127982. protected get _supportsHardwareTextureRescaling(): boolean;
  127983. private _fps;
  127984. private _deltaTime;
  127985. /** @hidden */
  127986. _drawCalls: PerfCounter;
  127987. /** 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 */
  127988. canvasTabIndex: number;
  127989. /**
  127990. * Turn this value on if you want to pause FPS computation when in background
  127991. */
  127992. disablePerformanceMonitorInBackground: boolean;
  127993. private _performanceMonitor;
  127994. /**
  127995. * Gets the performance monitor attached to this engine
  127996. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127997. */
  127998. get performanceMonitor(): PerformanceMonitor;
  127999. private _onFocus;
  128000. private _onBlur;
  128001. private _onCanvasPointerOut;
  128002. private _onCanvasBlur;
  128003. private _onCanvasFocus;
  128004. private _onFullscreenChange;
  128005. private _onPointerLockChange;
  128006. /**
  128007. * Gets the HTML element used to attach event listeners
  128008. * @returns a HTML element
  128009. */
  128010. getInputElement(): Nullable<HTMLElement>;
  128011. /**
  128012. * Creates a new engine
  128013. * @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 already used the WebGL context
  128014. * @param antialias defines enable antialiasing (default: false)
  128015. * @param options defines further options to be sent to the getContext() function
  128016. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  128017. */
  128018. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  128019. /**
  128020. * Shared initialization across engines types.
  128021. * @param canvas The canvas associated with this instance of the engine.
  128022. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  128023. * @param audioEngine Defines if an audio engine should be created by default
  128024. */
  128025. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  128026. /**
  128027. * Gets current aspect ratio
  128028. * @param viewportOwner defines the camera to use to get the aspect ratio
  128029. * @param useScreen defines if screen size must be used (or the current render target if any)
  128030. * @returns a number defining the aspect ratio
  128031. */
  128032. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  128033. /**
  128034. * Gets current screen aspect ratio
  128035. * @returns a number defining the aspect ratio
  128036. */
  128037. getScreenAspectRatio(): number;
  128038. /**
  128039. * Gets the client rect of the HTML canvas attached with the current webGL context
  128040. * @returns a client rectangle
  128041. */
  128042. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  128043. /**
  128044. * Gets the client rect of the HTML element used for events
  128045. * @returns a client rectangle
  128046. */
  128047. getInputElementClientRect(): Nullable<ClientRect>;
  128048. /**
  128049. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128050. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128051. * @returns true if engine is in deterministic lock step mode
  128052. */
  128053. isDeterministicLockStep(): boolean;
  128054. /**
  128055. * Gets the max steps when engine is running in deterministic lock step
  128056. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128057. * @returns the max steps
  128058. */
  128059. getLockstepMaxSteps(): number;
  128060. /**
  128061. * Returns the time in ms between steps when using deterministic lock step.
  128062. * @returns time step in (ms)
  128063. */
  128064. getTimeStep(): number;
  128065. /**
  128066. * Force the mipmap generation for the given render target texture
  128067. * @param texture defines the render target texture to use
  128068. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  128069. */
  128070. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  128071. /** States */
  128072. /**
  128073. * Set various states to the webGL context
  128074. * @param culling defines backface culling state
  128075. * @param zOffset defines the value to apply to zOffset (0 by default)
  128076. * @param force defines if states must be applied even if cache is up to date
  128077. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128078. */
  128079. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128080. /**
  128081. * Set the z offset to apply to current rendering
  128082. * @param value defines the offset to apply
  128083. */
  128084. setZOffset(value: number): void;
  128085. /**
  128086. * Gets the current value of the zOffset
  128087. * @returns the current zOffset state
  128088. */
  128089. getZOffset(): number;
  128090. /**
  128091. * Gets a boolean indicating if depth testing is enabled
  128092. * @returns the current state
  128093. */
  128094. getDepthBuffer(): boolean;
  128095. /**
  128096. * Enable or disable depth buffering
  128097. * @param enable defines the state to set
  128098. */
  128099. setDepthBuffer(enable: boolean): void;
  128100. /**
  128101. * Gets a boolean indicating if depth writing is enabled
  128102. * @returns the current depth writing state
  128103. */
  128104. getDepthWrite(): boolean;
  128105. /**
  128106. * Enable or disable depth writing
  128107. * @param enable defines the state to set
  128108. */
  128109. setDepthWrite(enable: boolean): void;
  128110. /**
  128111. * Gets a boolean indicating if stencil buffer is enabled
  128112. * @returns the current stencil buffer state
  128113. */
  128114. getStencilBuffer(): boolean;
  128115. /**
  128116. * Enable or disable the stencil buffer
  128117. * @param enable defines if the stencil buffer must be enabled or disabled
  128118. */
  128119. setStencilBuffer(enable: boolean): void;
  128120. /**
  128121. * Gets the current stencil mask
  128122. * @returns a number defining the new stencil mask to use
  128123. */
  128124. getStencilMask(): number;
  128125. /**
  128126. * Sets the current stencil mask
  128127. * @param mask defines the new stencil mask to use
  128128. */
  128129. setStencilMask(mask: number): void;
  128130. /**
  128131. * Gets the current stencil function
  128132. * @returns a number defining the stencil function to use
  128133. */
  128134. getStencilFunction(): number;
  128135. /**
  128136. * Gets the current stencil reference value
  128137. * @returns a number defining the stencil reference value to use
  128138. */
  128139. getStencilFunctionReference(): number;
  128140. /**
  128141. * Gets the current stencil mask
  128142. * @returns a number defining the stencil mask to use
  128143. */
  128144. getStencilFunctionMask(): number;
  128145. /**
  128146. * Sets the current stencil function
  128147. * @param stencilFunc defines the new stencil function to use
  128148. */
  128149. setStencilFunction(stencilFunc: number): void;
  128150. /**
  128151. * Sets the current stencil reference
  128152. * @param reference defines the new stencil reference to use
  128153. */
  128154. setStencilFunctionReference(reference: number): void;
  128155. /**
  128156. * Sets the current stencil mask
  128157. * @param mask defines the new stencil mask to use
  128158. */
  128159. setStencilFunctionMask(mask: number): void;
  128160. /**
  128161. * Gets the current stencil operation when stencil fails
  128162. * @returns a number defining stencil operation to use when stencil fails
  128163. */
  128164. getStencilOperationFail(): number;
  128165. /**
  128166. * Gets the current stencil operation when depth fails
  128167. * @returns a number defining stencil operation to use when depth fails
  128168. */
  128169. getStencilOperationDepthFail(): number;
  128170. /**
  128171. * Gets the current stencil operation when stencil passes
  128172. * @returns a number defining stencil operation to use when stencil passes
  128173. */
  128174. getStencilOperationPass(): number;
  128175. /**
  128176. * Sets the stencil operation to use when stencil fails
  128177. * @param operation defines the stencil operation to use when stencil fails
  128178. */
  128179. setStencilOperationFail(operation: number): void;
  128180. /**
  128181. * Sets the stencil operation to use when depth fails
  128182. * @param operation defines the stencil operation to use when depth fails
  128183. */
  128184. setStencilOperationDepthFail(operation: number): void;
  128185. /**
  128186. * Sets the stencil operation to use when stencil passes
  128187. * @param operation defines the stencil operation to use when stencil passes
  128188. */
  128189. setStencilOperationPass(operation: number): void;
  128190. /**
  128191. * Sets a boolean indicating if the dithering state is enabled or disabled
  128192. * @param value defines the dithering state
  128193. */
  128194. setDitheringState(value: boolean): void;
  128195. /**
  128196. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  128197. * @param value defines the rasterizer state
  128198. */
  128199. setRasterizerState(value: boolean): void;
  128200. /**
  128201. * Gets the current depth function
  128202. * @returns a number defining the depth function
  128203. */
  128204. getDepthFunction(): Nullable<number>;
  128205. /**
  128206. * Sets the current depth function
  128207. * @param depthFunc defines the function to use
  128208. */
  128209. setDepthFunction(depthFunc: number): void;
  128210. /**
  128211. * Sets the current depth function to GREATER
  128212. */
  128213. setDepthFunctionToGreater(): void;
  128214. /**
  128215. * Sets the current depth function to GEQUAL
  128216. */
  128217. setDepthFunctionToGreaterOrEqual(): void;
  128218. /**
  128219. * Sets the current depth function to LESS
  128220. */
  128221. setDepthFunctionToLess(): void;
  128222. /**
  128223. * Sets the current depth function to LEQUAL
  128224. */
  128225. setDepthFunctionToLessOrEqual(): void;
  128226. private _cachedStencilBuffer;
  128227. private _cachedStencilFunction;
  128228. private _cachedStencilMask;
  128229. private _cachedStencilOperationPass;
  128230. private _cachedStencilOperationFail;
  128231. private _cachedStencilOperationDepthFail;
  128232. private _cachedStencilReference;
  128233. /**
  128234. * Caches the the state of the stencil buffer
  128235. */
  128236. cacheStencilState(): void;
  128237. /**
  128238. * Restores the state of the stencil buffer
  128239. */
  128240. restoreStencilState(): void;
  128241. /**
  128242. * Directly set the WebGL Viewport
  128243. * @param x defines the x coordinate of the viewport (in screen space)
  128244. * @param y defines the y coordinate of the viewport (in screen space)
  128245. * @param width defines the width of the viewport (in screen space)
  128246. * @param height defines the height of the viewport (in screen space)
  128247. * @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
  128248. */
  128249. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  128250. /**
  128251. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  128252. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  128253. * @param y defines the y-coordinate of the corner of the clear rectangle
  128254. * @param width defines the width of the clear rectangle
  128255. * @param height defines the height of the clear rectangle
  128256. * @param clearColor defines the clear color
  128257. */
  128258. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  128259. /**
  128260. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  128261. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  128262. * @param y defines the y-coordinate of the corner of the clear rectangle
  128263. * @param width defines the width of the clear rectangle
  128264. * @param height defines the height of the clear rectangle
  128265. */
  128266. enableScissor(x: number, y: number, width: number, height: number): void;
  128267. /**
  128268. * Disable previously set scissor test rectangle
  128269. */
  128270. disableScissor(): void;
  128271. protected _reportDrawCall(): void;
  128272. /**
  128273. * Initializes a webVR display and starts listening to display change events
  128274. * The onVRDisplayChangedObservable will be notified upon these changes
  128275. * @returns The onVRDisplayChangedObservable
  128276. */
  128277. initWebVR(): Observable<IDisplayChangedEventArgs>;
  128278. /** @hidden */
  128279. _prepareVRComponent(): void;
  128280. /** @hidden */
  128281. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  128282. /** @hidden */
  128283. _submitVRFrame(): void;
  128284. /**
  128285. * Call this function to leave webVR mode
  128286. * Will do nothing if webVR is not supported or if there is no webVR device
  128287. * @see https://doc.babylonjs.com/how_to/webvr_camera
  128288. */
  128289. disableVR(): void;
  128290. /**
  128291. * Gets a boolean indicating that the system is in VR mode and is presenting
  128292. * @returns true if VR mode is engaged
  128293. */
  128294. isVRPresenting(): boolean;
  128295. /** @hidden */
  128296. _requestVRFrame(): void;
  128297. /** @hidden */
  128298. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  128299. /**
  128300. * Gets the source code of the vertex shader associated with a specific webGL program
  128301. * @param program defines the program to use
  128302. * @returns a string containing the source code of the vertex shader associated with the program
  128303. */
  128304. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  128305. /**
  128306. * Gets the source code of the fragment shader associated with a specific webGL program
  128307. * @param program defines the program to use
  128308. * @returns a string containing the source code of the fragment shader associated with the program
  128309. */
  128310. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  128311. /**
  128312. * Sets a depth stencil texture from a render target to the according uniform.
  128313. * @param channel The texture channel
  128314. * @param uniform The uniform to set
  128315. * @param texture The render target texture containing the depth stencil texture to apply
  128316. * @param name The texture name
  128317. */
  128318. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  128319. /**
  128320. * Sets a texture to the webGL context from a postprocess
  128321. * @param channel defines the channel to use
  128322. * @param postProcess defines the source postprocess
  128323. * @param name name of the channel
  128324. */
  128325. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  128326. /**
  128327. * Binds the output of the passed in post process to the texture channel specified
  128328. * @param channel The channel the texture should be bound to
  128329. * @param postProcess The post process which's output should be bound
  128330. * @param name name of the channel
  128331. */
  128332. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  128333. protected _rebuildBuffers(): void;
  128334. /** @hidden */
  128335. _renderFrame(): void;
  128336. _renderLoop(): void;
  128337. /** @hidden */
  128338. _renderViews(): boolean;
  128339. /**
  128340. * Toggle full screen mode
  128341. * @param requestPointerLock defines if a pointer lock should be requested from the user
  128342. */
  128343. switchFullscreen(requestPointerLock: boolean): void;
  128344. /**
  128345. * Enters full screen mode
  128346. * @param requestPointerLock defines if a pointer lock should be requested from the user
  128347. */
  128348. enterFullscreen(requestPointerLock: boolean): void;
  128349. /**
  128350. * Exits full screen mode
  128351. */
  128352. exitFullscreen(): void;
  128353. /**
  128354. * Enters Pointerlock mode
  128355. */
  128356. enterPointerlock(): void;
  128357. /**
  128358. * Exits Pointerlock mode
  128359. */
  128360. exitPointerlock(): void;
  128361. /**
  128362. * Begin a new frame
  128363. */
  128364. beginFrame(): void;
  128365. /**
  128366. * End the current frame
  128367. */
  128368. endFrame(): void;
  128369. /**
  128370. * Resize the view according to the canvas' size
  128371. * @param forceSetSize true to force setting the sizes of the underlying canvas
  128372. */
  128373. resize(forceSetSize?: boolean): void;
  128374. /**
  128375. * Force a specific size of the canvas
  128376. * @param width defines the new canvas' width
  128377. * @param height defines the new canvas' height
  128378. * @param forceSetSize true to force setting the sizes of the underlying canvas
  128379. * @returns true if the size was changed
  128380. */
  128381. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  128382. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  128383. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  128384. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  128385. _releaseTexture(texture: InternalTexture): void;
  128386. /**
  128387. * @hidden
  128388. * Rescales a texture
  128389. * @param source input texture
  128390. * @param destination destination texture
  128391. * @param scene scene to use to render the resize
  128392. * @param internalFormat format to use when resizing
  128393. * @param onComplete callback to be called when resize has completed
  128394. */
  128395. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  128396. /**
  128397. * Gets the current framerate
  128398. * @returns a number representing the framerate
  128399. */
  128400. getFps(): number;
  128401. /**
  128402. * Gets the time spent between current and previous frame
  128403. * @returns a number representing the delta time in ms
  128404. */
  128405. getDeltaTime(): number;
  128406. private _measureFps;
  128407. /** @hidden */
  128408. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  128409. /**
  128410. * Updates the sample count of a render target texture
  128411. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  128412. * @param texture defines the texture to update
  128413. * @param samples defines the sample count to set
  128414. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  128415. */
  128416. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  128417. /**
  128418. * Updates a depth texture Comparison Mode and Function.
  128419. * If the comparison Function is equal to 0, the mode will be set to none.
  128420. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  128421. * @param texture The texture to set the comparison function for
  128422. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  128423. */
  128424. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  128425. /**
  128426. * Creates a webGL buffer to use with instantiation
  128427. * @param capacity defines the size of the buffer
  128428. * @returns the webGL buffer
  128429. */
  128430. createInstancesBuffer(capacity: number): DataBuffer;
  128431. /**
  128432. * Delete a webGL buffer used with instantiation
  128433. * @param buffer defines the webGL buffer to delete
  128434. */
  128435. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  128436. private _clientWaitAsync;
  128437. /** @hidden */
  128438. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  128439. dispose(): void;
  128440. private _disableTouchAction;
  128441. /**
  128442. * Display the loading screen
  128443. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128444. */
  128445. displayLoadingUI(): void;
  128446. /**
  128447. * Hide the loading screen
  128448. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128449. */
  128450. hideLoadingUI(): void;
  128451. /**
  128452. * Gets the current loading screen object
  128453. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128454. */
  128455. get loadingScreen(): ILoadingScreen;
  128456. /**
  128457. * Sets the current loading screen object
  128458. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128459. */
  128460. set loadingScreen(loadingScreen: ILoadingScreen);
  128461. /**
  128462. * Sets the current loading screen text
  128463. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128464. */
  128465. set loadingUIText(text: string);
  128466. /**
  128467. * Sets the current loading screen background color
  128468. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128469. */
  128470. set loadingUIBackgroundColor(color: string);
  128471. /** Pointerlock and fullscreen */
  128472. /**
  128473. * Ask the browser to promote the current element to pointerlock mode
  128474. * @param element defines the DOM element to promote
  128475. */
  128476. static _RequestPointerlock(element: HTMLElement): void;
  128477. /**
  128478. * Asks the browser to exit pointerlock mode
  128479. */
  128480. static _ExitPointerlock(): void;
  128481. /**
  128482. * Ask the browser to promote the current element to fullscreen rendering mode
  128483. * @param element defines the DOM element to promote
  128484. */
  128485. static _RequestFullscreen(element: HTMLElement): void;
  128486. /**
  128487. * Asks the browser to exit fullscreen mode
  128488. */
  128489. static _ExitFullscreen(): void;
  128490. }
  128491. }
  128492. declare module BABYLON {
  128493. /**
  128494. * The engine store class is responsible to hold all the instances of Engine and Scene created
  128495. * during the life time of the application.
  128496. */
  128497. export class EngineStore {
  128498. /** Gets the list of created engines */
  128499. static Instances: Engine[];
  128500. /** @hidden */
  128501. static _LastCreatedScene: Nullable<Scene>;
  128502. /**
  128503. * Gets the latest created engine
  128504. */
  128505. static get LastCreatedEngine(): Nullable<Engine>;
  128506. /**
  128507. * Gets the latest created scene
  128508. */
  128509. static get LastCreatedScene(): Nullable<Scene>;
  128510. /**
  128511. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  128512. * @ignorenaming
  128513. */
  128514. static UseFallbackTexture: boolean;
  128515. /**
  128516. * Texture content used if a texture cannot loaded
  128517. * @ignorenaming
  128518. */
  128519. static FallbackTexture: string;
  128520. }
  128521. }
  128522. declare module BABYLON {
  128523. /**
  128524. * Helper class that provides a small promise polyfill
  128525. */
  128526. export class PromisePolyfill {
  128527. /**
  128528. * Static function used to check if the polyfill is required
  128529. * If this is the case then the function will inject the polyfill to window.Promise
  128530. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  128531. */
  128532. static Apply(force?: boolean): void;
  128533. }
  128534. }
  128535. declare module BABYLON {
  128536. /**
  128537. * Interface for screenshot methods with describe argument called `size` as object with options
  128538. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  128539. */
  128540. export interface IScreenshotSize {
  128541. /**
  128542. * number in pixels for canvas height
  128543. */
  128544. height?: number;
  128545. /**
  128546. * multiplier allowing render at a higher or lower resolution
  128547. * If value is defined then height and width will be ignored and taken from camera
  128548. */
  128549. precision?: number;
  128550. /**
  128551. * number in pixels for canvas width
  128552. */
  128553. width?: number;
  128554. }
  128555. }
  128556. declare module BABYLON {
  128557. interface IColor4Like {
  128558. r: float;
  128559. g: float;
  128560. b: float;
  128561. a: float;
  128562. }
  128563. /**
  128564. * Class containing a set of static utilities functions
  128565. */
  128566. export class Tools {
  128567. /**
  128568. * Gets or sets the base URL to use to load assets
  128569. */
  128570. static get BaseUrl(): string;
  128571. static set BaseUrl(value: string);
  128572. /**
  128573. * Enable/Disable Custom HTTP Request Headers globally.
  128574. * default = false
  128575. * @see CustomRequestHeaders
  128576. */
  128577. static UseCustomRequestHeaders: boolean;
  128578. /**
  128579. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  128580. * i.e. when loading files, where the server/service expects an Authorization header
  128581. */
  128582. static CustomRequestHeaders: {
  128583. [key: string]: string;
  128584. };
  128585. /**
  128586. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  128587. */
  128588. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  128589. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  128590. /**
  128591. * Default behaviour for cors in the application.
  128592. * It can be a string if the expected behavior is identical in the entire app.
  128593. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  128594. */
  128595. static get CorsBehavior(): string | ((url: string | string[]) => string);
  128596. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  128597. /**
  128598. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  128599. * @ignorenaming
  128600. */
  128601. static get UseFallbackTexture(): boolean;
  128602. static set UseFallbackTexture(value: boolean);
  128603. /**
  128604. * Use this object to register external classes like custom textures or material
  128605. * to allow the loaders to instantiate them
  128606. */
  128607. static get RegisteredExternalClasses(): {
  128608. [key: string]: Object;
  128609. };
  128610. static set RegisteredExternalClasses(classes: {
  128611. [key: string]: Object;
  128612. });
  128613. /**
  128614. * Texture content used if a texture cannot loaded
  128615. * @ignorenaming
  128616. */
  128617. static get fallbackTexture(): string;
  128618. static set fallbackTexture(value: string);
  128619. /**
  128620. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  128621. * @param u defines the coordinate on X axis
  128622. * @param v defines the coordinate on Y axis
  128623. * @param width defines the width of the source data
  128624. * @param height defines the height of the source data
  128625. * @param pixels defines the source byte array
  128626. * @param color defines the output color
  128627. */
  128628. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  128629. /**
  128630. * Interpolates between a and b via alpha
  128631. * @param a The lower value (returned when alpha = 0)
  128632. * @param b The upper value (returned when alpha = 1)
  128633. * @param alpha The interpolation-factor
  128634. * @return The mixed value
  128635. */
  128636. static Mix(a: number, b: number, alpha: number): number;
  128637. /**
  128638. * Tries to instantiate a new object from a given class name
  128639. * @param className defines the class name to instantiate
  128640. * @returns the new object or null if the system was not able to do the instantiation
  128641. */
  128642. static Instantiate(className: string): any;
  128643. /**
  128644. * Provides a slice function that will work even on IE
  128645. * @param data defines the array to slice
  128646. * @param start defines the start of the data (optional)
  128647. * @param end defines the end of the data (optional)
  128648. * @returns the new sliced array
  128649. */
  128650. static Slice<T>(data: T, start?: number, end?: number): T;
  128651. /**
  128652. * Provides a slice function that will work even on IE
  128653. * The difference between this and Slice is that this will force-convert to array
  128654. * @param data defines the array to slice
  128655. * @param start defines the start of the data (optional)
  128656. * @param end defines the end of the data (optional)
  128657. * @returns the new sliced array
  128658. */
  128659. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  128660. /**
  128661. * Polyfill for setImmediate
  128662. * @param action defines the action to execute after the current execution block
  128663. */
  128664. static SetImmediate(action: () => void): void;
  128665. /**
  128666. * Function indicating if a number is an exponent of 2
  128667. * @param value defines the value to test
  128668. * @returns true if the value is an exponent of 2
  128669. */
  128670. static IsExponentOfTwo(value: number): boolean;
  128671. private static _tmpFloatArray;
  128672. /**
  128673. * Returns the nearest 32-bit single precision float representation of a Number
  128674. * @param value A Number. If the parameter is of a different type, it will get converted
  128675. * to a number or to NaN if it cannot be converted
  128676. * @returns number
  128677. */
  128678. static FloatRound(value: number): number;
  128679. /**
  128680. * Extracts the filename from a path
  128681. * @param path defines the path to use
  128682. * @returns the filename
  128683. */
  128684. static GetFilename(path: string): string;
  128685. /**
  128686. * Extracts the "folder" part of a path (everything before the filename).
  128687. * @param uri The URI to extract the info from
  128688. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  128689. * @returns The "folder" part of the path
  128690. */
  128691. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  128692. /**
  128693. * Extracts text content from a DOM element hierarchy
  128694. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  128695. */
  128696. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  128697. /**
  128698. * Convert an angle in radians to degrees
  128699. * @param angle defines the angle to convert
  128700. * @returns the angle in degrees
  128701. */
  128702. static ToDegrees(angle: number): number;
  128703. /**
  128704. * Convert an angle in degrees to radians
  128705. * @param angle defines the angle to convert
  128706. * @returns the angle in radians
  128707. */
  128708. static ToRadians(angle: number): number;
  128709. /**
  128710. * Returns an array if obj is not an array
  128711. * @param obj defines the object to evaluate as an array
  128712. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  128713. * @returns either obj directly if obj is an array or a new array containing obj
  128714. */
  128715. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  128716. /**
  128717. * Gets the pointer prefix to use
  128718. * @param engine defines the engine we are finding the prefix for
  128719. * @returns "pointer" if touch is enabled. Else returns "mouse"
  128720. */
  128721. static GetPointerPrefix(engine: Engine): string;
  128722. /**
  128723. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  128724. * @param url define the url we are trying
  128725. * @param element define the dom element where to configure the cors policy
  128726. */
  128727. static SetCorsBehavior(url: string | string[], element: {
  128728. crossOrigin: string | null;
  128729. }): void;
  128730. /**
  128731. * Removes unwanted characters from an url
  128732. * @param url defines the url to clean
  128733. * @returns the cleaned url
  128734. */
  128735. static CleanUrl(url: string): string;
  128736. /**
  128737. * Gets or sets a function used to pre-process url before using them to load assets
  128738. */
  128739. static get PreprocessUrl(): (url: string) => string;
  128740. static set PreprocessUrl(processor: (url: string) => string);
  128741. /**
  128742. * Loads an image as an HTMLImageElement.
  128743. * @param input url string, ArrayBuffer, or Blob to load
  128744. * @param onLoad callback called when the image successfully loads
  128745. * @param onError callback called when the image fails to load
  128746. * @param offlineProvider offline provider for caching
  128747. * @param mimeType optional mime type
  128748. * @returns the HTMLImageElement of the loaded image
  128749. */
  128750. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  128751. /**
  128752. * Loads a file from a url
  128753. * @param url url string, ArrayBuffer, or Blob to load
  128754. * @param onSuccess callback called when the file successfully loads
  128755. * @param onProgress callback called while file is loading (if the server supports this mode)
  128756. * @param offlineProvider defines the offline provider for caching
  128757. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128758. * @param onError callback called when the file fails to load
  128759. * @returns a file request object
  128760. */
  128761. 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;
  128762. /**
  128763. * Loads a file from a url
  128764. * @param url the file url to load
  128765. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128766. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  128767. */
  128768. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  128769. /**
  128770. * Load a script (identified by an url). When the url returns, the
  128771. * content of this file is added into a new script element, attached to the DOM (body element)
  128772. * @param scriptUrl defines the url of the script to laod
  128773. * @param onSuccess defines the callback called when the script is loaded
  128774. * @param onError defines the callback to call if an error occurs
  128775. * @param scriptId defines the id of the script element
  128776. */
  128777. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  128778. /**
  128779. * Load an asynchronous script (identified by an url). When the url returns, the
  128780. * content of this file is added into a new script element, attached to the DOM (body element)
  128781. * @param scriptUrl defines the url of the script to laod
  128782. * @param scriptId defines the id of the script element
  128783. * @returns a promise request object
  128784. */
  128785. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  128786. /**
  128787. * Loads a file from a blob
  128788. * @param fileToLoad defines the blob to use
  128789. * @param callback defines the callback to call when data is loaded
  128790. * @param progressCallback defines the callback to call during loading process
  128791. * @returns a file request object
  128792. */
  128793. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  128794. /**
  128795. * Reads a file from a File object
  128796. * @param file defines the file to load
  128797. * @param onSuccess defines the callback to call when data is loaded
  128798. * @param onProgress defines the callback to call during loading process
  128799. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128800. * @param onError defines the callback to call when an error occurs
  128801. * @returns a file request object
  128802. */
  128803. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  128804. /**
  128805. * Creates a data url from a given string content
  128806. * @param content defines the content to convert
  128807. * @returns the new data url link
  128808. */
  128809. static FileAsURL(content: string): string;
  128810. /**
  128811. * Format the given number to a specific decimal format
  128812. * @param value defines the number to format
  128813. * @param decimals defines the number of decimals to use
  128814. * @returns the formatted string
  128815. */
  128816. static Format(value: number, decimals?: number): string;
  128817. /**
  128818. * Tries to copy an object by duplicating every property
  128819. * @param source defines the source object
  128820. * @param destination defines the target object
  128821. * @param doNotCopyList defines a list of properties to avoid
  128822. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  128823. */
  128824. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  128825. /**
  128826. * Gets a boolean indicating if the given object has no own property
  128827. * @param obj defines the object to test
  128828. * @returns true if object has no own property
  128829. */
  128830. static IsEmpty(obj: any): boolean;
  128831. /**
  128832. * Function used to register events at window level
  128833. * @param windowElement defines the Window object to use
  128834. * @param events defines the events to register
  128835. */
  128836. static RegisterTopRootEvents(windowElement: Window, events: {
  128837. name: string;
  128838. handler: Nullable<(e: FocusEvent) => any>;
  128839. }[]): void;
  128840. /**
  128841. * Function used to unregister events from window level
  128842. * @param windowElement defines the Window object to use
  128843. * @param events defines the events to unregister
  128844. */
  128845. static UnregisterTopRootEvents(windowElement: Window, events: {
  128846. name: string;
  128847. handler: Nullable<(e: FocusEvent) => any>;
  128848. }[]): void;
  128849. /**
  128850. * @ignore
  128851. */
  128852. static _ScreenshotCanvas: HTMLCanvasElement;
  128853. /**
  128854. * Dumps the current bound framebuffer
  128855. * @param width defines the rendering width
  128856. * @param height defines the rendering height
  128857. * @param engine defines the hosting engine
  128858. * @param successCallback defines the callback triggered once the data are available
  128859. * @param mimeType defines the mime type of the result
  128860. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  128861. * @return a void promise
  128862. */
  128863. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  128864. /**
  128865. * Dumps an array buffer
  128866. * @param width defines the rendering width
  128867. * @param height defines the rendering height
  128868. * @param data the data array
  128869. * @param successCallback defines the callback triggered once the data are available
  128870. * @param mimeType defines the mime type of the result
  128871. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  128872. * @param invertY true to invert the picture in the Y dimension
  128873. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  128874. */
  128875. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  128876. /**
  128877. * Dumps an array buffer
  128878. * @param width defines the rendering width
  128879. * @param height defines the rendering height
  128880. * @param data the data array
  128881. * @param successCallback defines the callback triggered once the data are available
  128882. * @param mimeType defines the mime type of the result
  128883. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  128884. * @param invertY true to invert the picture in the Y dimension
  128885. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  128886. * @return a promise that resolve to the final data
  128887. */
  128888. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  128889. /**
  128890. * Converts the canvas data to blob.
  128891. * This acts as a polyfill for browsers not supporting the to blob function.
  128892. * @param canvas Defines the canvas to extract the data from
  128893. * @param successCallback Defines the callback triggered once the data are available
  128894. * @param mimeType Defines the mime type of the result
  128895. */
  128896. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  128897. /**
  128898. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  128899. * @param successCallback defines the callback triggered once the data are available
  128900. * @param mimeType defines the mime type of the result
  128901. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  128902. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  128903. */
  128904. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  128905. /**
  128906. * Downloads a blob in the browser
  128907. * @param blob defines the blob to download
  128908. * @param fileName defines the name of the downloaded file
  128909. */
  128910. static Download(blob: Blob, fileName: string): void;
  128911. /**
  128912. * Will return the right value of the noPreventDefault variable
  128913. * Needed to keep backwards compatibility to the old API.
  128914. *
  128915. * @param args arguments passed to the attachControl function
  128916. * @returns the correct value for noPreventDefault
  128917. */
  128918. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  128919. /**
  128920. * Captures a screenshot of the current rendering
  128921. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128922. * @param engine defines the rendering engine
  128923. * @param camera defines the source camera
  128924. * @param size This parameter can be set to a single number or to an object with the
  128925. * following (optional) properties: precision, width, height. If a single number is passed,
  128926. * it will be used for both width and height. If an object is passed, the screenshot size
  128927. * will be derived from the parameters. The precision property is a multiplier allowing
  128928. * rendering at a higher or lower resolution
  128929. * @param successCallback defines the callback receives a single parameter which contains the
  128930. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128931. * src parameter of an <img> to display it
  128932. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128933. * Check your browser for supported MIME types
  128934. */
  128935. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  128936. /**
  128937. * Captures a screenshot of the current rendering
  128938. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128939. * @param engine defines the rendering engine
  128940. * @param camera defines the source camera
  128941. * @param size This parameter can be set to a single number or to an object with the
  128942. * following (optional) properties: precision, width, height. If a single number is passed,
  128943. * it will be used for both width and height. If an object is passed, the screenshot size
  128944. * will be derived from the parameters. The precision property is a multiplier allowing
  128945. * rendering at a higher or lower resolution
  128946. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128947. * Check your browser for supported MIME types
  128948. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128949. * to the src parameter of an <img> to display it
  128950. */
  128951. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  128952. /**
  128953. * Generates an image screenshot from the specified camera.
  128954. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128955. * @param engine The engine to use for rendering
  128956. * @param camera The camera to use for rendering
  128957. * @param size This parameter can be set to a single number or to an object with the
  128958. * following (optional) properties: precision, width, height. If a single number is passed,
  128959. * it will be used for both width and height. If an object is passed, the screenshot size
  128960. * will be derived from the parameters. The precision property is a multiplier allowing
  128961. * rendering at a higher or lower resolution
  128962. * @param successCallback The callback receives a single parameter which contains the
  128963. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128964. * src parameter of an <img> to display it
  128965. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128966. * Check your browser for supported MIME types
  128967. * @param samples Texture samples (default: 1)
  128968. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128969. * @param fileName A name for for the downloaded file.
  128970. */
  128971. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128972. /**
  128973. * Generates an image screenshot from the specified camera.
  128974. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  128975. * @param engine The engine to use for rendering
  128976. * @param camera The camera to use for rendering
  128977. * @param size This parameter can be set to a single number or to an object with the
  128978. * following (optional) properties: precision, width, height. If a single number is passed,
  128979. * it will be used for both width and height. If an object is passed, the screenshot size
  128980. * will be derived from the parameters. The precision property is a multiplier allowing
  128981. * rendering at a higher or lower resolution
  128982. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128983. * Check your browser for supported MIME types
  128984. * @param samples Texture samples (default: 1)
  128985. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128986. * @param fileName A name for for the downloaded file.
  128987. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128988. * to the src parameter of an <img> to display it
  128989. */
  128990. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128991. /**
  128992. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  128993. * Be aware Math.random() could cause collisions, but:
  128994. * "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"
  128995. * @returns a pseudo random id
  128996. */
  128997. static RandomId(): string;
  128998. /**
  128999. * Test if the given uri is a base64 string
  129000. * @param uri The uri to test
  129001. * @return True if the uri is a base64 string or false otherwise
  129002. */
  129003. static IsBase64(uri: string): boolean;
  129004. /**
  129005. * Decode the given base64 uri.
  129006. * @param uri The uri to decode
  129007. * @return The decoded base64 data.
  129008. */
  129009. static DecodeBase64(uri: string): ArrayBuffer;
  129010. /**
  129011. * Gets the absolute url.
  129012. * @param url the input url
  129013. * @return the absolute url
  129014. */
  129015. static GetAbsoluteUrl(url: string): string;
  129016. /**
  129017. * No log
  129018. */
  129019. static readonly NoneLogLevel: number;
  129020. /**
  129021. * Only message logs
  129022. */
  129023. static readonly MessageLogLevel: number;
  129024. /**
  129025. * Only warning logs
  129026. */
  129027. static readonly WarningLogLevel: number;
  129028. /**
  129029. * Only error logs
  129030. */
  129031. static readonly ErrorLogLevel: number;
  129032. /**
  129033. * All logs
  129034. */
  129035. static readonly AllLogLevel: number;
  129036. /**
  129037. * Gets a value indicating the number of loading errors
  129038. * @ignorenaming
  129039. */
  129040. static get errorsCount(): number;
  129041. /**
  129042. * Callback called when a new log is added
  129043. */
  129044. static OnNewCacheEntry: (entry: string) => void;
  129045. /**
  129046. * Log a message to the console
  129047. * @param message defines the message to log
  129048. */
  129049. static Log(message: string): void;
  129050. /**
  129051. * Write a warning message to the console
  129052. * @param message defines the message to log
  129053. */
  129054. static Warn(message: string): void;
  129055. /**
  129056. * Write an error message to the console
  129057. * @param message defines the message to log
  129058. */
  129059. static Error(message: string): void;
  129060. /**
  129061. * Gets current log cache (list of logs)
  129062. */
  129063. static get LogCache(): string;
  129064. /**
  129065. * Clears the log cache
  129066. */
  129067. static ClearLogCache(): void;
  129068. /**
  129069. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  129070. */
  129071. static set LogLevels(level: number);
  129072. /**
  129073. * Checks if the window object exists
  129074. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  129075. */
  129076. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  129077. /**
  129078. * No performance log
  129079. */
  129080. static readonly PerformanceNoneLogLevel: number;
  129081. /**
  129082. * Use user marks to log performance
  129083. */
  129084. static readonly PerformanceUserMarkLogLevel: number;
  129085. /**
  129086. * Log performance to the console
  129087. */
  129088. static readonly PerformanceConsoleLogLevel: number;
  129089. private static _performance;
  129090. /**
  129091. * Sets the current performance log level
  129092. */
  129093. static set PerformanceLogLevel(level: number);
  129094. private static _StartPerformanceCounterDisabled;
  129095. private static _EndPerformanceCounterDisabled;
  129096. private static _StartUserMark;
  129097. private static _EndUserMark;
  129098. private static _StartPerformanceConsole;
  129099. private static _EndPerformanceConsole;
  129100. /**
  129101. * Starts a performance counter
  129102. */
  129103. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  129104. /**
  129105. * Ends a specific performance counter
  129106. */
  129107. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  129108. /**
  129109. * Gets either window.performance.now() if supported or Date.now() else
  129110. */
  129111. static get Now(): number;
  129112. /**
  129113. * This method will return the name of the class used to create the instance of the given object.
  129114. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  129115. * @param object the object to get the class name from
  129116. * @param isType defines if the object is actually a type
  129117. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  129118. */
  129119. static GetClassName(object: any, isType?: boolean): string;
  129120. /**
  129121. * Gets the first element of an array satisfying a given predicate
  129122. * @param array defines the array to browse
  129123. * @param predicate defines the predicate to use
  129124. * @returns null if not found or the element
  129125. */
  129126. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  129127. /**
  129128. * This method will return the name of the full name of the class, including its owning module (if any).
  129129. * 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).
  129130. * @param object the object to get the class name from
  129131. * @param isType defines if the object is actually a type
  129132. * @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.
  129133. * @ignorenaming
  129134. */
  129135. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  129136. /**
  129137. * Returns a promise that resolves after the given amount of time.
  129138. * @param delay Number of milliseconds to delay
  129139. * @returns Promise that resolves after the given amount of time
  129140. */
  129141. static DelayAsync(delay: number): Promise<void>;
  129142. /**
  129143. * Utility function to detect if the current user agent is Safari
  129144. * @returns whether or not the current user agent is safari
  129145. */
  129146. static IsSafari(): boolean;
  129147. }
  129148. /**
  129149. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  129150. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  129151. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  129152. * @param name The name of the class, case should be preserved
  129153. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  129154. */
  129155. export function className(name: string, module?: string): (target: Object) => void;
  129156. /**
  129157. * An implementation of a loop for asynchronous functions.
  129158. */
  129159. export class AsyncLoop {
  129160. /**
  129161. * Defines the number of iterations for the loop
  129162. */
  129163. iterations: number;
  129164. /**
  129165. * Defines the current index of the loop.
  129166. */
  129167. index: number;
  129168. private _done;
  129169. private _fn;
  129170. private _successCallback;
  129171. /**
  129172. * Constructor.
  129173. * @param iterations the number of iterations.
  129174. * @param func the function to run each iteration
  129175. * @param successCallback the callback that will be called upon successful execution
  129176. * @param offset starting offset.
  129177. */
  129178. constructor(
  129179. /**
  129180. * Defines the number of iterations for the loop
  129181. */
  129182. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  129183. /**
  129184. * Execute the next iteration. Must be called after the last iteration was finished.
  129185. */
  129186. executeNext(): void;
  129187. /**
  129188. * Break the loop and run the success callback.
  129189. */
  129190. breakLoop(): void;
  129191. /**
  129192. * Create and run an async loop.
  129193. * @param iterations the number of iterations.
  129194. * @param fn the function to run each iteration
  129195. * @param successCallback the callback that will be called upon successful execution
  129196. * @param offset starting offset.
  129197. * @returns the created async loop object
  129198. */
  129199. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  129200. /**
  129201. * A for-loop that will run a given number of iterations synchronous and the rest async.
  129202. * @param iterations total number of iterations
  129203. * @param syncedIterations number of synchronous iterations in each async iteration.
  129204. * @param fn the function to call each iteration.
  129205. * @param callback a success call back that will be called when iterating stops.
  129206. * @param breakFunction a break condition (optional)
  129207. * @param timeout timeout settings for the setTimeout function. default - 0.
  129208. * @returns the created async loop object
  129209. */
  129210. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  129211. }
  129212. }
  129213. declare module BABYLON {
  129214. /**
  129215. * This class implement a typical dictionary using a string as key and the generic type T as value.
  129216. * The underlying implementation relies on an associative array to ensure the best performances.
  129217. * The value can be anything including 'null' but except 'undefined'
  129218. */
  129219. export class StringDictionary<T> {
  129220. /**
  129221. * This will clear this dictionary and copy the content from the 'source' one.
  129222. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  129223. * @param source the dictionary to take the content from and copy to this dictionary
  129224. */
  129225. copyFrom(source: StringDictionary<T>): void;
  129226. /**
  129227. * Get a value based from its key
  129228. * @param key the given key to get the matching value from
  129229. * @return the value if found, otherwise undefined is returned
  129230. */
  129231. get(key: string): T | undefined;
  129232. /**
  129233. * Get a value from its key or add it if it doesn't exist.
  129234. * This method will ensure you that a given key/data will be present in the dictionary.
  129235. * @param key the given key to get the matching value from
  129236. * @param factory the factory that will create the value if the key is not present in the dictionary.
  129237. * The factory will only be invoked if there's no data for the given key.
  129238. * @return the value corresponding to the key.
  129239. */
  129240. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  129241. /**
  129242. * Get a value from its key if present in the dictionary otherwise add it
  129243. * @param key the key to get the value from
  129244. * @param val if there's no such key/value pair in the dictionary add it with this value
  129245. * @return the value corresponding to the key
  129246. */
  129247. getOrAdd(key: string, val: T): T;
  129248. /**
  129249. * Check if there's a given key in the dictionary
  129250. * @param key the key to check for
  129251. * @return true if the key is present, false otherwise
  129252. */
  129253. contains(key: string): boolean;
  129254. /**
  129255. * Add a new key and its corresponding value
  129256. * @param key the key to add
  129257. * @param value the value corresponding to the key
  129258. * @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
  129259. */
  129260. add(key: string, value: T): boolean;
  129261. /**
  129262. * Update a specific value associated to a key
  129263. * @param key defines the key to use
  129264. * @param value defines the value to store
  129265. * @returns true if the value was updated (or false if the key was not found)
  129266. */
  129267. set(key: string, value: T): boolean;
  129268. /**
  129269. * Get the element of the given key and remove it from the dictionary
  129270. * @param key defines the key to search
  129271. * @returns the value associated with the key or null if not found
  129272. */
  129273. getAndRemove(key: string): Nullable<T>;
  129274. /**
  129275. * Remove a key/value from the dictionary.
  129276. * @param key the key to remove
  129277. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  129278. */
  129279. remove(key: string): boolean;
  129280. /**
  129281. * Clear the whole content of the dictionary
  129282. */
  129283. clear(): void;
  129284. /**
  129285. * Gets the current count
  129286. */
  129287. get count(): number;
  129288. /**
  129289. * Execute a callback on each key/val of the dictionary.
  129290. * Note that you can remove any element in this dictionary in the callback implementation
  129291. * @param callback the callback to execute on a given key/value pair
  129292. */
  129293. forEach(callback: (key: string, val: T) => void): void;
  129294. /**
  129295. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  129296. * If the callback returns null or undefined the method will iterate to the next key/value pair
  129297. * Note that you can remove any element in this dictionary in the callback implementation
  129298. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  129299. * @returns the first item
  129300. */
  129301. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  129302. private _count;
  129303. private _data;
  129304. }
  129305. }
  129306. declare module BABYLON {
  129307. /** @hidden */
  129308. export interface ICollisionCoordinator {
  129309. createCollider(): Collider;
  129310. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  129311. init(scene: Scene): void;
  129312. }
  129313. /** @hidden */
  129314. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  129315. private _scene;
  129316. private _scaledPosition;
  129317. private _scaledVelocity;
  129318. private _finalPosition;
  129319. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  129320. createCollider(): Collider;
  129321. init(scene: Scene): void;
  129322. private _collideWithWorld;
  129323. }
  129324. }
  129325. declare module BABYLON {
  129326. /**
  129327. * Class used to manage all inputs for the scene.
  129328. */
  129329. export class InputManager {
  129330. /** The distance in pixel that you have to move to prevent some events */
  129331. static DragMovementThreshold: number;
  129332. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  129333. static LongPressDelay: number;
  129334. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  129335. static DoubleClickDelay: number;
  129336. /** If you need to check double click without raising a single click at first click, enable this flag */
  129337. static ExclusiveDoubleClickMode: boolean;
  129338. /** 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. */
  129339. private _alreadyAttached;
  129340. private _alreadyAttachedTo;
  129341. private _wheelEventName;
  129342. private _onPointerMove;
  129343. private _onPointerDown;
  129344. private _onPointerUp;
  129345. private _initClickEvent;
  129346. private _initActionManager;
  129347. private _delayedSimpleClick;
  129348. private _delayedSimpleClickTimeout;
  129349. private _previousDelayedSimpleClickTimeout;
  129350. private _meshPickProceed;
  129351. private _previousButtonPressed;
  129352. private _currentPickResult;
  129353. private _previousPickResult;
  129354. private _totalPointersPressed;
  129355. private _doubleClickOccured;
  129356. private _pointerOverMesh;
  129357. private _pickedDownMesh;
  129358. private _pickedUpMesh;
  129359. private _pointerX;
  129360. private _pointerY;
  129361. private _unTranslatedPointerX;
  129362. private _unTranslatedPointerY;
  129363. private _startingPointerPosition;
  129364. private _previousStartingPointerPosition;
  129365. private _startingPointerTime;
  129366. private _previousStartingPointerTime;
  129367. private _pointerCaptures;
  129368. private _meshUnderPointerId;
  129369. private _onKeyDown;
  129370. private _onKeyUp;
  129371. private _keyboardIsAttached;
  129372. private _onCanvasFocusObserver;
  129373. private _onCanvasBlurObserver;
  129374. private _scene;
  129375. /**
  129376. * Creates a new InputManager
  129377. * @param scene defines the hosting scene
  129378. */
  129379. constructor(scene: Scene);
  129380. /**
  129381. * Gets the mesh that is currently under the pointer
  129382. */
  129383. get meshUnderPointer(): Nullable<AbstractMesh>;
  129384. /**
  129385. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  129386. * @param pointerId the pointer id to use
  129387. * @returns The mesh under this pointer id or null if not found
  129388. */
  129389. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  129390. /**
  129391. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  129392. */
  129393. get unTranslatedPointer(): Vector2;
  129394. /**
  129395. * Gets or sets the current on-screen X position of the pointer
  129396. */
  129397. get pointerX(): number;
  129398. set pointerX(value: number);
  129399. /**
  129400. * Gets or sets the current on-screen Y position of the pointer
  129401. */
  129402. get pointerY(): number;
  129403. set pointerY(value: number);
  129404. private _updatePointerPosition;
  129405. private _processPointerMove;
  129406. private _setRayOnPointerInfo;
  129407. private _checkPrePointerObservable;
  129408. /**
  129409. * Use this method to simulate a pointer move on a mesh
  129410. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129411. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129412. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129413. */
  129414. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  129415. /**
  129416. * Use this method to simulate a pointer down on a mesh
  129417. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129418. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129419. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129420. */
  129421. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  129422. private _processPointerDown;
  129423. /** @hidden */
  129424. _isPointerSwiping(): boolean;
  129425. /**
  129426. * Use this method to simulate a pointer up on a mesh
  129427. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129428. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129429. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129430. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  129431. */
  129432. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  129433. private _processPointerUp;
  129434. /**
  129435. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  129436. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  129437. * @returns true if the pointer was captured
  129438. */
  129439. isPointerCaptured(pointerId?: number): boolean;
  129440. /**
  129441. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  129442. * @param attachUp defines if you want to attach events to pointerup
  129443. * @param attachDown defines if you want to attach events to pointerdown
  129444. * @param attachMove defines if you want to attach events to pointermove
  129445. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  129446. */
  129447. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  129448. /**
  129449. * Detaches all event handlers
  129450. */
  129451. detachControl(): void;
  129452. /**
  129453. * Force the value of meshUnderPointer
  129454. * @param mesh defines the mesh to use
  129455. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  129456. */
  129457. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  129458. /**
  129459. * Gets the mesh under the pointer
  129460. * @returns a Mesh or null if no mesh is under the pointer
  129461. */
  129462. getPointerOverMesh(): Nullable<AbstractMesh>;
  129463. }
  129464. }
  129465. declare module BABYLON {
  129466. /**
  129467. * This class defines the direct association between an animation and a target
  129468. */
  129469. export class TargetedAnimation {
  129470. /**
  129471. * Animation to perform
  129472. */
  129473. animation: Animation;
  129474. /**
  129475. * Target to animate
  129476. */
  129477. target: any;
  129478. /**
  129479. * Returns the string "TargetedAnimation"
  129480. * @returns "TargetedAnimation"
  129481. */
  129482. getClassName(): string;
  129483. /**
  129484. * Serialize the object
  129485. * @returns the JSON object representing the current entity
  129486. */
  129487. serialize(): any;
  129488. }
  129489. /**
  129490. * Use this class to create coordinated animations on multiple targets
  129491. */
  129492. export class AnimationGroup implements IDisposable {
  129493. /** The name of the animation group */
  129494. name: string;
  129495. private _scene;
  129496. private _targetedAnimations;
  129497. private _animatables;
  129498. private _from;
  129499. private _to;
  129500. private _isStarted;
  129501. private _isPaused;
  129502. private _speedRatio;
  129503. private _loopAnimation;
  129504. private _isAdditive;
  129505. /**
  129506. * Gets or sets the unique id of the node
  129507. */
  129508. uniqueId: number;
  129509. /**
  129510. * This observable will notify when one animation have ended
  129511. */
  129512. onAnimationEndObservable: Observable<TargetedAnimation>;
  129513. /**
  129514. * Observer raised when one animation loops
  129515. */
  129516. onAnimationLoopObservable: Observable<TargetedAnimation>;
  129517. /**
  129518. * Observer raised when all animations have looped
  129519. */
  129520. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  129521. /**
  129522. * This observable will notify when all animations have ended.
  129523. */
  129524. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  129525. /**
  129526. * This observable will notify when all animations have paused.
  129527. */
  129528. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  129529. /**
  129530. * This observable will notify when all animations are playing.
  129531. */
  129532. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  129533. /**
  129534. * Gets the first frame
  129535. */
  129536. get from(): number;
  129537. /**
  129538. * Gets the last frame
  129539. */
  129540. get to(): number;
  129541. /**
  129542. * Define if the animations are started
  129543. */
  129544. get isStarted(): boolean;
  129545. /**
  129546. * Gets a value indicating that the current group is playing
  129547. */
  129548. get isPlaying(): boolean;
  129549. /**
  129550. * Gets or sets the speed ratio to use for all animations
  129551. */
  129552. get speedRatio(): number;
  129553. /**
  129554. * Gets or sets the speed ratio to use for all animations
  129555. */
  129556. set speedRatio(value: number);
  129557. /**
  129558. * Gets or sets if all animations should loop or not
  129559. */
  129560. get loopAnimation(): boolean;
  129561. set loopAnimation(value: boolean);
  129562. /**
  129563. * Gets or sets if all animations should be evaluated additively
  129564. */
  129565. get isAdditive(): boolean;
  129566. set isAdditive(value: boolean);
  129567. /**
  129568. * Gets the targeted animations for this animation group
  129569. */
  129570. get targetedAnimations(): Array<TargetedAnimation>;
  129571. /**
  129572. * returning the list of animatables controlled by this animation group.
  129573. */
  129574. get animatables(): Array<Animatable>;
  129575. /**
  129576. * Gets the list of target animations
  129577. */
  129578. get children(): TargetedAnimation[];
  129579. /**
  129580. * Instantiates a new Animation Group.
  129581. * This helps managing several animations at once.
  129582. * @see https://doc.babylonjs.com/how_to/group
  129583. * @param name Defines the name of the group
  129584. * @param scene Defines the scene the group belongs to
  129585. */
  129586. constructor(
  129587. /** The name of the animation group */
  129588. name: string, scene?: Nullable<Scene>);
  129589. /**
  129590. * Add an animation (with its target) in the group
  129591. * @param animation defines the animation we want to add
  129592. * @param target defines the target of the animation
  129593. * @returns the TargetedAnimation object
  129594. */
  129595. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  129596. /**
  129597. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  129598. * It can add constant keys at begin or end
  129599. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  129600. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  129601. * @returns the animation group
  129602. */
  129603. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  129604. private _animationLoopCount;
  129605. private _animationLoopFlags;
  129606. private _processLoop;
  129607. /**
  129608. * Start all animations on given targets
  129609. * @param loop defines if animations must loop
  129610. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  129611. * @param from defines the from key (optional)
  129612. * @param to defines the to key (optional)
  129613. * @param isAdditive defines the additive state for the resulting animatables (optional)
  129614. * @returns the current animation group
  129615. */
  129616. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  129617. /**
  129618. * Pause all animations
  129619. * @returns the animation group
  129620. */
  129621. pause(): AnimationGroup;
  129622. /**
  129623. * Play all animations to initial state
  129624. * This function will start() the animations if they were not started or will restart() them if they were paused
  129625. * @param loop defines if animations must loop
  129626. * @returns the animation group
  129627. */
  129628. play(loop?: boolean): AnimationGroup;
  129629. /**
  129630. * Reset all animations to initial state
  129631. * @returns the animation group
  129632. */
  129633. reset(): AnimationGroup;
  129634. /**
  129635. * Restart animations from key 0
  129636. * @returns the animation group
  129637. */
  129638. restart(): AnimationGroup;
  129639. /**
  129640. * Stop all animations
  129641. * @returns the animation group
  129642. */
  129643. stop(): AnimationGroup;
  129644. /**
  129645. * Set animation weight for all animatables
  129646. * @param weight defines the weight to use
  129647. * @return the animationGroup
  129648. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  129649. */
  129650. setWeightForAllAnimatables(weight: number): AnimationGroup;
  129651. /**
  129652. * Synchronize and normalize all animatables with a source animatable
  129653. * @param root defines the root animatable to synchronize with
  129654. * @return the animationGroup
  129655. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  129656. */
  129657. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  129658. /**
  129659. * Goes to a specific frame in this animation group
  129660. * @param frame the frame number to go to
  129661. * @return the animationGroup
  129662. */
  129663. goToFrame(frame: number): AnimationGroup;
  129664. /**
  129665. * Dispose all associated resources
  129666. */
  129667. dispose(): void;
  129668. private _checkAnimationGroupEnded;
  129669. /**
  129670. * Clone the current animation group and returns a copy
  129671. * @param newName defines the name of the new group
  129672. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  129673. * @returns the new animation group
  129674. */
  129675. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  129676. /**
  129677. * Serializes the animationGroup to an object
  129678. * @returns Serialized object
  129679. */
  129680. serialize(): any;
  129681. /**
  129682. * Returns a new AnimationGroup object parsed from the source provided.
  129683. * @param parsedAnimationGroup defines the source
  129684. * @param scene defines the scene that will receive the animationGroup
  129685. * @returns a new AnimationGroup
  129686. */
  129687. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  129688. /**
  129689. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  129690. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  129691. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  129692. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  129693. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  129694. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  129695. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  129696. */
  129697. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  129698. /**
  129699. * Returns the string "AnimationGroup"
  129700. * @returns "AnimationGroup"
  129701. */
  129702. getClassName(): string;
  129703. /**
  129704. * Creates a detailed string about the object
  129705. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  129706. * @returns a string representing the object
  129707. */
  129708. toString(fullDetails?: boolean): string;
  129709. }
  129710. }
  129711. declare module BABYLON {
  129712. /**
  129713. * @hidden
  129714. **/
  129715. export class _TimeToken {
  129716. _startTimeQuery: Nullable<WebGLQuery>;
  129717. _endTimeQuery: Nullable<WebGLQuery>;
  129718. _timeElapsedQuery: Nullable<WebGLQuery>;
  129719. _timeElapsedQueryEnded: boolean;
  129720. }
  129721. }
  129722. declare module BABYLON {
  129723. /** @hidden */
  129724. export enum ExtensionName {
  129725. DepthClamping = "depth-clamping",
  129726. Depth24UnormStencil8 = "depth24unorm-stencil8",
  129727. Depth32FloatStencil8 = "depth32float-stencil8",
  129728. PipelineStatisticsQuery = "pipeline-statistics-query",
  129729. TextureCompressionBC = "texture-compression-bc",
  129730. TimestampQuery = "timestamp-query"
  129731. }
  129732. /** @hidden */
  129733. export enum AddressMode {
  129734. ClampToEdge = "clamp-to-edge",
  129735. Repeat = "repeat",
  129736. MirrorRepeat = "mirror-repeat"
  129737. }
  129738. /** @hidden */
  129739. export enum BindingType {
  129740. UniformBuffer = "uniform-buffer",
  129741. StorageBuffer = "storage-buffer",
  129742. ReadonlyStorageBuffer = "readonly-storage-buffer",
  129743. Sampler = "sampler",
  129744. ComparisonSampler = "comparison-sampler",
  129745. SampledTexture = "sampled-texture",
  129746. ReadonlyStorageTexture = "readonly-storage-texture",
  129747. WriteonlyStorageTexture = "writeonly-storage-texture"
  129748. }
  129749. /** @hidden */
  129750. export enum BlendFactor {
  129751. Zero = "zero",
  129752. One = "one",
  129753. SrcColor = "src-color",
  129754. OneMinusSrcColor = "one-minus-src-color",
  129755. SrcAlpha = "src-alpha",
  129756. OneMinusSrcAlpha = "one-minus-src-alpha",
  129757. DstColor = "dst-color",
  129758. OneMinusDstColor = "one-minus-dst-color",
  129759. DstAlpha = "dst-alpha",
  129760. OneMinusDstAlpha = "one-minus-dst-alpha",
  129761. SrcAlphaSaturated = "src-alpha-saturated",
  129762. BlendColor = "blend-color",
  129763. OneMinusBlendColor = "one-minus-blend-color"
  129764. }
  129765. /** @hidden */
  129766. export enum BlendOperation {
  129767. Add = "add",
  129768. Subtract = "subtract",
  129769. ReverseSubtract = "reverse-subtract",
  129770. Min = "min",
  129771. Max = "max"
  129772. }
  129773. /** @hidden */
  129774. export enum CompareFunction {
  129775. Never = "never",
  129776. Less = "less",
  129777. Equal = "equal",
  129778. LessEqual = "less-equal",
  129779. Greater = "greater",
  129780. NotEqual = "not-equal",
  129781. GreaterEqual = "greater-equal",
  129782. Always = "always"
  129783. }
  129784. /** @hidden */
  129785. export enum CullMode {
  129786. None = "none",
  129787. Front = "front",
  129788. Back = "back"
  129789. }
  129790. /** @hidden */
  129791. export enum FilterMode {
  129792. Nearest = "nearest",
  129793. Linear = "linear"
  129794. }
  129795. /** @hidden */
  129796. export enum FrontFace {
  129797. CCW = "ccw",
  129798. CW = "cw"
  129799. }
  129800. /** @hidden */
  129801. export enum IndexFormat {
  129802. Uint16 = "uint16",
  129803. Uint32 = "uint32"
  129804. }
  129805. /** @hidden */
  129806. export enum InputStepMode {
  129807. Vertex = "vertex",
  129808. Instance = "instance"
  129809. }
  129810. /** @hidden */
  129811. export enum LoadOp {
  129812. Load = "load"
  129813. }
  129814. /** @hidden */
  129815. export enum PrimitiveTopology {
  129816. PointList = "point-list",
  129817. LineList = "line-list",
  129818. LineStrip = "line-strip",
  129819. TriangleList = "triangle-list",
  129820. TriangleStrip = "triangle-strip"
  129821. }
  129822. /** @hidden */
  129823. export enum StencilOperation {
  129824. Keep = "keep",
  129825. Zero = "zero",
  129826. Replace = "replace",
  129827. Invert = "invert",
  129828. IncrementClamp = "increment-clamp",
  129829. DecrementClamp = "decrement-clamp",
  129830. IncrementWrap = "increment-wrap",
  129831. DecrementWrap = "decrement-wrap"
  129832. }
  129833. /** @hidden */
  129834. export enum StoreOp {
  129835. Store = "store",
  129836. Clear = "clear"
  129837. }
  129838. /** @hidden */
  129839. export enum TextureDimension {
  129840. E1d = "1d",
  129841. E2d = "2d",
  129842. E3d = "3d"
  129843. }
  129844. /** @hidden */
  129845. export enum TextureFormat {
  129846. R8Unorm = "r8unorm",
  129847. R8Snorm = "r8snorm",
  129848. R8Uint = "r8uint",
  129849. R8Sint = "r8sint",
  129850. R16Uint = "r16uint",
  129851. R16Sint = "r16sint",
  129852. R16Float = "r16float",
  129853. RG8Unorm = "rg8unorm",
  129854. RG8Snorm = "rg8snorm",
  129855. RG8Uint = "rg8uint",
  129856. RG8Sint = "rg8sint",
  129857. R32Uint = "r32uint",
  129858. R32Sint = "r32sint",
  129859. R32Float = "r32float",
  129860. RG16Uint = "rg16uint",
  129861. RG16Sint = "rg16sint",
  129862. RG16Float = "rg16float",
  129863. RGBA8Unorm = "rgba8unorm",
  129864. RGBA8UnormSRGB = "rgba8unorm-srgb",
  129865. RGBA8Snorm = "rgba8snorm",
  129866. RGBA8Uint = "rgba8uint",
  129867. RGBA8Sint = "rgba8sint",
  129868. BGRA8Unorm = "bgra8unorm",
  129869. BGRA8UnormSRGB = "bgra8unorm-srgb",
  129870. RGB9E5UFloat = "rgb9e5ufloat",
  129871. RGB10A2Unorm = "rgb10a2unorm",
  129872. RG11B10UFloat = "rg11b10ufloat",
  129873. RG32Uint = "rg32uint",
  129874. RG32Sint = "rg32sint",
  129875. RG32Float = "rg32float",
  129876. RGBA16Uint = "rgba16uint",
  129877. RGBA16Sint = "rgba16sint",
  129878. RGBA16Float = "rgba16float",
  129879. RGBA32Uint = "rgba32uint",
  129880. RGBA32Sint = "rgba32sint",
  129881. RGBA32Float = "rgba32float",
  129882. Stencil8 = "stencil8",
  129883. Depth16Unorm = "depth16unorm",
  129884. Depth24Plus = "depth24plus",
  129885. Depth24PlusStencil8 = "depth24plus-stencil8",
  129886. Depth32Float = "depth32float",
  129887. BC1RGBAUNorm = "bc1-rgba-unorm",
  129888. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  129889. BC2RGBAUnorm = "bc2-rgba-unorm",
  129890. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  129891. BC3RGBAUnorm = "bc3-rgba-unorm",
  129892. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  129893. BC4RUnorm = "bc4-r-unorm",
  129894. BC4RSnorm = "bc4-r-snorm",
  129895. BC5RGUnorm = "bc5-rg-unorm",
  129896. BC5RGSnorm = "bc5-rg-snorm",
  129897. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  129898. BC6HRGBFloat = "bc6h-rgb-float",
  129899. BC7RGBAUnorm = "bc7-rgba-unorm",
  129900. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  129901. Depth24UnormStencil8 = "depth24unorm-stencil8",
  129902. Depth32FloatStencil8 = "depth32float-stencil8"
  129903. }
  129904. /** @hidden */
  129905. export enum TextureComponentType {
  129906. Float = "float",
  129907. Sint = "sint",
  129908. Uint = "uint",
  129909. DepthComparison = "depth-comparison"
  129910. }
  129911. /** @hidden */
  129912. export enum TextureViewDimension {
  129913. E1d = "1d",
  129914. E2d = "2d",
  129915. E2dArray = "2d-array",
  129916. Cube = "cube",
  129917. CubeArray = "cube-array",
  129918. E3d = "3d"
  129919. }
  129920. /** @hidden */
  129921. export enum VertexFormat {
  129922. Uchar2 = "uchar2",
  129923. Uchar4 = "uchar4",
  129924. Char2 = "char2",
  129925. Char4 = "char4",
  129926. Uchar2Norm = "uchar2norm",
  129927. Uchar4Norm = "uchar4norm",
  129928. Char2Norm = "char2norm",
  129929. Char4Norm = "char4norm",
  129930. Ushort2 = "ushort2",
  129931. Ushort4 = "ushort4",
  129932. Short2 = "short2",
  129933. Short4 = "short4",
  129934. Ushort2Norm = "ushort2norm",
  129935. Ushort4Norm = "ushort4norm",
  129936. Short2Norm = "short2norm",
  129937. Short4Norm = "short4norm",
  129938. Half2 = "half2",
  129939. Half4 = "half4",
  129940. Float = "float",
  129941. Float2 = "float2",
  129942. Float3 = "float3",
  129943. Float4 = "float4",
  129944. Uint = "uint",
  129945. Uint2 = "uint2",
  129946. Uint3 = "uint3",
  129947. Uint4 = "uint4",
  129948. Int = "int",
  129949. Int2 = "int2",
  129950. Int3 = "int3",
  129951. Int4 = "int4"
  129952. }
  129953. /** @hidden */
  129954. export enum TextureAspect {
  129955. All = "all",
  129956. StencilOnly = "stencil-only",
  129957. DepthOnly = "depth-only"
  129958. }
  129959. /** @hidden */
  129960. export enum CompilationMessageType {
  129961. Error = "error",
  129962. Warning = "warning",
  129963. Info = "info"
  129964. }
  129965. /** @hidden */
  129966. export enum QueryType {
  129967. Occlusion = "occlusion"
  129968. }
  129969. /** @hidden */
  129970. export enum BufferUsage {
  129971. MapRead = 1,
  129972. MapWrite = 2,
  129973. CopySrc = 4,
  129974. CopyDst = 8,
  129975. Index = 16,
  129976. Vertex = 32,
  129977. Uniform = 64,
  129978. Storage = 128,
  129979. Indirect = 256,
  129980. QueryResolve = 512
  129981. }
  129982. /** @hidden */
  129983. export enum ColorWrite {
  129984. Red = 1,
  129985. Green = 2,
  129986. Blue = 4,
  129987. Alpha = 8,
  129988. All = 15
  129989. }
  129990. /** @hidden */
  129991. export enum ShaderStage {
  129992. Vertex = 1,
  129993. Fragment = 2,
  129994. Compute = 4
  129995. }
  129996. /** @hidden */
  129997. export enum TextureUsage {
  129998. CopySrc = 1,
  129999. CopyDst = 2,
  130000. Sampled = 4,
  130001. Storage = 8,
  130002. OutputAttachment = 16
  130003. }
  130004. /** @hidden */
  130005. export enum MapMode {
  130006. Read = 1,
  130007. Write = 2
  130008. }
  130009. }
  130010. declare module BABYLON {
  130011. /** @hidden */
  130012. export interface WebGPUBindingInfo {
  130013. setIndex: number;
  130014. bindingIndex: number;
  130015. }
  130016. /** @hidden */
  130017. export interface WebGPUTextureSamplerBindingDescription {
  130018. sampler: WebGPUBindingInfo;
  130019. isTextureArray: boolean;
  130020. textures: Array<WebGPUBindingInfo>;
  130021. }
  130022. /** @hidden
  130023. * If the binding is a UBO, isSampler=isTexture=false
  130024. */
  130025. export interface WebGPUBindingDescription {
  130026. name: string;
  130027. usedInVertex: boolean;
  130028. usedInFragment: boolean;
  130029. isSampler: boolean;
  130030. isComparisonSampler?: boolean;
  130031. isTexture: boolean;
  130032. componentType?: GPUTextureComponentType;
  130033. textureDimension?: GPUTextureViewDimension;
  130034. }
  130035. /**
  130036. * @hidden
  130037. */
  130038. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  130039. uboNextBindingIndex: number;
  130040. freeSetIndex: number;
  130041. freeBindingIndex: number;
  130042. availableVaryings: {
  130043. [key: string]: number;
  130044. };
  130045. availableAttributes: {
  130046. [key: string]: number;
  130047. };
  130048. availableUBOs: {
  130049. [key: string]: {
  130050. setIndex: number;
  130051. bindingIndex: number;
  130052. };
  130053. };
  130054. availableSamplers: {
  130055. [key: string]: WebGPUTextureSamplerBindingDescription;
  130056. };
  130057. leftOverUniforms: {
  130058. name: string;
  130059. type: string;
  130060. length: number;
  130061. }[];
  130062. orderedAttributes: string[];
  130063. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  130064. uniformBufferNames: string[];
  130065. attributeNamesFromEffect: string[];
  130066. attributeLocationsFromEffect: number[];
  130067. private _attributeNextLocation;
  130068. private _varyingNextLocation;
  130069. constructor();
  130070. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  130071. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  130072. getNextFreeUBOBinding(): {
  130073. setIndex: number;
  130074. bindingIndex: number;
  130075. };
  130076. private _getNextFreeBinding;
  130077. }
  130078. }
  130079. declare module BABYLON {
  130080. /** @hidden */
  130081. export interface IWebGPUPipelineContextSamplerCache {
  130082. samplerBinding: number;
  130083. firstTextureName: string;
  130084. }
  130085. /** @hidden */
  130086. export interface IWebGPUPipelineContextTextureCache {
  130087. textureBinding: number;
  130088. texture: InternalTexture;
  130089. }
  130090. /** @hidden */
  130091. export interface IWebGPUPipelineContextVertexInputsCache {
  130092. indexBuffer: Nullable<GPUBuffer>;
  130093. indexOffset: number;
  130094. vertexStartSlot: number;
  130095. vertexBuffers: GPUBuffer[];
  130096. vertexOffsets: number[];
  130097. }
  130098. /** @hidden */
  130099. export interface IWebGPURenderPipelineStageDescriptor {
  130100. vertexStage: GPUProgrammableStageDescriptor;
  130101. fragmentStage?: GPUProgrammableStageDescriptor;
  130102. }
  130103. /** @hidden */
  130104. export class WebGPUBindGroupCacheNode {
  130105. values: {
  130106. [id: number]: WebGPUBindGroupCacheNode;
  130107. };
  130108. bindGroups: GPUBindGroup[];
  130109. constructor();
  130110. }
  130111. /** @hidden */
  130112. export class WebGPUPipelineContext implements IPipelineContext {
  130113. engine: WebGPUEngine;
  130114. shaderProcessingContext: WebGPUShaderProcessingContext;
  130115. leftOverUniformsByName: {
  130116. [name: string]: string;
  130117. };
  130118. sources: {
  130119. vertex: string;
  130120. fragment: string;
  130121. rawVertex: string;
  130122. rawFragment: string;
  130123. };
  130124. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  130125. samplers: {
  130126. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  130127. };
  130128. textures: {
  130129. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  130130. };
  130131. bindGroupLayouts: GPUBindGroupLayout[];
  130132. bindGroupsCache: WebGPUBindGroupCacheNode;
  130133. /**
  130134. * Stores the uniform buffer
  130135. */
  130136. uniformBuffer: Nullable<UniformBuffer>;
  130137. onCompiled?: () => void;
  130138. get isAsync(): boolean;
  130139. get isReady(): boolean;
  130140. /** @hidden */
  130141. _name: string;
  130142. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  130143. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  130144. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  130145. [key: string]: number;
  130146. }, uniformsNames: string[], uniforms: {
  130147. [key: string]: Nullable<WebGLUniformLocation>;
  130148. }, samplerList: string[], samplers: {
  130149. [key: string]: number;
  130150. }, attributesNames: string[], attributes: number[]): void;
  130151. /** @hidden */
  130152. /**
  130153. * Build the uniform buffer used in the material.
  130154. */
  130155. buildUniformLayout(): void;
  130156. /**
  130157. * Release all associated resources.
  130158. **/
  130159. dispose(): void;
  130160. /**
  130161. * Sets an integer value on a uniform variable.
  130162. * @param uniformName Name of the variable.
  130163. * @param value Value to be set.
  130164. */
  130165. setInt(uniformName: string, value: number): void;
  130166. /**
  130167. * Sets an int2 value on a uniform variable.
  130168. * @param uniformName Name of the variable.
  130169. * @param x First int in int2.
  130170. * @param y Second int in int2.
  130171. */
  130172. setInt2(uniformName: string, x: number, y: number): void;
  130173. /**
  130174. * Sets an int3 value on a uniform variable.
  130175. * @param uniformName Name of the variable.
  130176. * @param x First int in int3.
  130177. * @param y Second int in int3.
  130178. * @param z Third int in int3.
  130179. */
  130180. setInt3(uniformName: string, x: number, y: number, z: number): void;
  130181. /**
  130182. * Sets an int4 value on a uniform variable.
  130183. * @param uniformName Name of the variable.
  130184. * @param x First int in int4.
  130185. * @param y Second int in int4.
  130186. * @param z Third int in int4.
  130187. * @param w Fourth int in int4.
  130188. */
  130189. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  130190. /**
  130191. * Sets an int array on a uniform variable.
  130192. * @param uniformName Name of the variable.
  130193. * @param array array to be set.
  130194. */
  130195. setIntArray(uniformName: string, array: Int32Array): void;
  130196. /**
  130197. * 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)
  130198. * @param uniformName Name of the variable.
  130199. * @param array array to be set.
  130200. */
  130201. setIntArray2(uniformName: string, array: Int32Array): void;
  130202. /**
  130203. * 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)
  130204. * @param uniformName Name of the variable.
  130205. * @param array array to be set.
  130206. */
  130207. setIntArray3(uniformName: string, array: Int32Array): void;
  130208. /**
  130209. * 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)
  130210. * @param uniformName Name of the variable.
  130211. * @param array array to be set.
  130212. */
  130213. setIntArray4(uniformName: string, array: Int32Array): void;
  130214. /**
  130215. * Sets an array on a uniform variable.
  130216. * @param uniformName Name of the variable.
  130217. * @param array array to be set.
  130218. */
  130219. setArray(uniformName: string, array: number[]): void;
  130220. /**
  130221. * 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)
  130222. * @param uniformName Name of the variable.
  130223. * @param array array to be set.
  130224. */
  130225. setArray2(uniformName: string, array: number[]): void;
  130226. /**
  130227. * 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)
  130228. * @param uniformName Name of the variable.
  130229. * @param array array to be set.
  130230. * @returns this effect.
  130231. */
  130232. setArray3(uniformName: string, array: number[]): void;
  130233. /**
  130234. * 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)
  130235. * @param uniformName Name of the variable.
  130236. * @param array array to be set.
  130237. */
  130238. setArray4(uniformName: string, array: number[]): void;
  130239. /**
  130240. * Sets matrices on a uniform variable.
  130241. * @param uniformName Name of the variable.
  130242. * @param matrices matrices to be set.
  130243. */
  130244. setMatrices(uniformName: string, matrices: Float32Array): void;
  130245. /**
  130246. * Sets matrix on a uniform variable.
  130247. * @param uniformName Name of the variable.
  130248. * @param matrix matrix to be set.
  130249. */
  130250. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  130251. /**
  130252. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  130253. * @param uniformName Name of the variable.
  130254. * @param matrix matrix to be set.
  130255. */
  130256. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  130257. /**
  130258. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  130259. * @param uniformName Name of the variable.
  130260. * @param matrix matrix to be set.
  130261. */
  130262. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  130263. /**
  130264. * Sets a float on a uniform variable.
  130265. * @param uniformName Name of the variable.
  130266. * @param value value to be set.
  130267. * @returns this effect.
  130268. */
  130269. setFloat(uniformName: string, value: number): void;
  130270. /**
  130271. * Sets a Vector2 on a uniform variable.
  130272. * @param uniformName Name of the variable.
  130273. * @param vector2 vector2 to be set.
  130274. */
  130275. setVector2(uniformName: string, vector2: IVector2Like): void;
  130276. /**
  130277. * Sets a float2 on a uniform variable.
  130278. * @param uniformName Name of the variable.
  130279. * @param x First float in float2.
  130280. * @param y Second float in float2.
  130281. */
  130282. setFloat2(uniformName: string, x: number, y: number): void;
  130283. /**
  130284. * Sets a Vector3 on a uniform variable.
  130285. * @param uniformName Name of the variable.
  130286. * @param vector3 Value to be set.
  130287. */
  130288. setVector3(uniformName: string, vector3: IVector3Like): void;
  130289. /**
  130290. * Sets a float3 on a uniform variable.
  130291. * @param uniformName Name of the variable.
  130292. * @param x First float in float3.
  130293. * @param y Second float in float3.
  130294. * @param z Third float in float3.
  130295. */
  130296. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  130297. /**
  130298. * Sets a Vector4 on a uniform variable.
  130299. * @param uniformName Name of the variable.
  130300. * @param vector4 Value to be set.
  130301. */
  130302. setVector4(uniformName: string, vector4: IVector4Like): void;
  130303. /**
  130304. * Sets a float4 on a uniform variable.
  130305. * @param uniformName Name of the variable.
  130306. * @param x First float in float4.
  130307. * @param y Second float in float4.
  130308. * @param z Third float in float4.
  130309. * @param w Fourth float in float4.
  130310. * @returns this effect.
  130311. */
  130312. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  130313. /**
  130314. * Sets a Color3 on a uniform variable.
  130315. * @param uniformName Name of the variable.
  130316. * @param color3 Value to be set.
  130317. */
  130318. setColor3(uniformName: string, color3: IColor3Like): void;
  130319. /**
  130320. * Sets a Color4 on a uniform variable.
  130321. * @param uniformName Name of the variable.
  130322. * @param color3 Value to be set.
  130323. * @param alpha Alpha value to be set.
  130324. */
  130325. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  130326. /**
  130327. * Sets a Color4 on a uniform variable
  130328. * @param uniformName defines the name of the variable
  130329. * @param color4 defines the value to be set
  130330. */
  130331. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  130332. _getVertexShaderCode(): string | null;
  130333. _getFragmentShaderCode(): string | null;
  130334. }
  130335. }
  130336. declare module BABYLON {
  130337. /** @hidden */
  130338. export class WebGPUDataBuffer extends DataBuffer {
  130339. private _buffer;
  130340. constructor(resource: GPUBuffer);
  130341. get underlyingResource(): any;
  130342. }
  130343. }
  130344. declare module BABYLON {
  130345. /**
  130346. * Class used to inline functions in shader code
  130347. */
  130348. export class ShaderCodeInliner {
  130349. private static readonly _RegexpFindFunctionNameAndType;
  130350. private _sourceCode;
  130351. private _functionDescr;
  130352. private _numMaxIterations;
  130353. /** Gets or sets the token used to mark the functions to inline */
  130354. inlineToken: string;
  130355. /** Gets or sets the debug mode */
  130356. debug: boolean;
  130357. /** Gets the code after the inlining process */
  130358. get code(): string;
  130359. /**
  130360. * Initializes the inliner
  130361. * @param sourceCode shader code source to inline
  130362. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  130363. */
  130364. constructor(sourceCode: string, numMaxIterations?: number);
  130365. /**
  130366. * Start the processing of the shader code
  130367. */
  130368. processCode(): void;
  130369. private _collectFunctions;
  130370. private _processInlining;
  130371. private _extractBetweenMarkers;
  130372. private _skipWhitespaces;
  130373. private _isIdentifierChar;
  130374. private _removeComments;
  130375. private _replaceFunctionCallsByCode;
  130376. private _findBackward;
  130377. private _escapeRegExp;
  130378. private _replaceNames;
  130379. }
  130380. }
  130381. declare module BABYLON {
  130382. /** @hidden */
  130383. export class WebGPUShaderProcessor implements IShaderProcessor {
  130384. protected _missingVaryings: Array<string>;
  130385. protected _textureArrayProcessing: Array<string>;
  130386. protected _preProcessors: {
  130387. [key: string]: string;
  130388. };
  130389. private _getArraySize;
  130390. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  130391. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  130392. [key: string]: string;
  130393. }, processingContext: Nullable<ShaderProcessingContext>): string;
  130394. attributeProcessor(attribute: string, preProcessors: {
  130395. [key: string]: string;
  130396. }, processingContext: Nullable<ShaderProcessingContext>): string;
  130397. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  130398. [key: string]: string;
  130399. }, processingContext: Nullable<ShaderProcessingContext>): string;
  130400. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  130401. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  130402. private _applyTextureArrayProcessing;
  130403. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  130404. vertexCode: string;
  130405. fragmentCode: string;
  130406. };
  130407. }
  130408. }
  130409. declare module BABYLON {
  130410. /** @hidden */
  130411. export class WebGPUBufferManager {
  130412. private _device;
  130413. private _deferredReleaseBuffers;
  130414. private static _IsGPUBuffer;
  130415. constructor(device: GPUDevice);
  130416. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  130417. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  130418. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  130419. private _FromHalfFloat;
  130420. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  130421. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  130422. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  130423. destroyDeferredBuffers(): void;
  130424. }
  130425. }
  130426. declare module BABYLON {
  130427. /** @hidden */
  130428. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  130429. private _webgpuTexture;
  130430. private _webgpuMSAATexture;
  130431. get underlyingResource(): Nullable<GPUTexture>;
  130432. get msaaTexture(): Nullable<GPUTexture>;
  130433. set msaaTexture(texture: Nullable<GPUTexture>);
  130434. view: Nullable<GPUTextureView>;
  130435. format: GPUTextureFormat;
  130436. textureUsages: number;
  130437. constructor(existingTexture?: Nullable<GPUTexture>);
  130438. set(hardwareTexture: GPUTexture): void;
  130439. setMSAATexture(hardwareTexture: GPUTexture): void;
  130440. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  130441. createView(descriptor?: GPUTextureViewDescriptor): void;
  130442. reset(): void;
  130443. release(): void;
  130444. }
  130445. }
  130446. declare module BABYLON {
  130447. /** @hidden */
  130448. export class WebGPUTextureHelper {
  130449. private _device;
  130450. private _glslang;
  130451. private _bufferManager;
  130452. private _mipmapSampler;
  130453. private _invertYPreMultiplyAlphaSampler;
  130454. private _pipelines;
  130455. private _compiledShaders;
  130456. private _deferredReleaseTextures;
  130457. private _commandEncoderForCreation;
  130458. static ComputeNumMipmapLevels(width: number, height: number): number;
  130459. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  130460. private _getPipeline;
  130461. private static _GetTextureTypeFromFormat;
  130462. private static _GetBlockInformationFromFormat;
  130463. private static _IsHardwareTexture;
  130464. private static _IsInternalTexture;
  130465. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  130466. static IsImageBitmap(imageBitmap: ImageBitmap | {
  130467. width: number;
  130468. height: number;
  130469. }): imageBitmap is ImageBitmap;
  130470. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  130471. width: number;
  130472. height: number;
  130473. }): imageBitmap is ImageBitmap[];
  130474. setCommandEncoder(encoder: GPUCommandEncoder): void;
  130475. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  130476. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  130477. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  130478. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  130479. createTexture(imageBitmap: ImageBitmap | {
  130480. width: number;
  130481. height: number;
  130482. layers: number;
  130483. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  130484. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  130485. width: number;
  130486. height: number;
  130487. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  130488. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  130489. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  130490. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  130491. createMSAATexture(texture: InternalTexture, samples: number): void;
  130492. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  130493. updateTexture(imageBitmap: ImageBitmap | Uint8Array, gpuTexture: GPUTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  130494. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  130495. releaseTexture(texture: InternalTexture | GPUTexture): void;
  130496. destroyDeferredTextures(): void;
  130497. }
  130498. }
  130499. declare module BABYLON {
  130500. /** @hidden */
  130501. export class WebGPURenderPassWrapper {
  130502. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  130503. renderPass: Nullable<GPURenderPassEncoder>;
  130504. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  130505. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  130506. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  130507. depthTextureFormat: GPUTextureFormat | undefined;
  130508. constructor();
  130509. reset(fullReset?: boolean): void;
  130510. }
  130511. }
  130512. declare module BABYLON {
  130513. /** @hidden */
  130514. export class WebGPUCacheSampler {
  130515. private _samplers;
  130516. private _device;
  130517. disabled: boolean;
  130518. constructor(device: GPUDevice);
  130519. private static _GetSamplerHashCode;
  130520. private static _GetSamplerFilterDescriptor;
  130521. private static _GetWrappingMode;
  130522. private static _GetSamplerWrappingDescriptor;
  130523. private static _GetSamplerDescriptor;
  130524. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  130525. }
  130526. }
  130527. declare module BABYLON {
  130528. /** @hidden */
  130529. export class WebGPUShaderManager {
  130530. private _shaders;
  130531. private _device;
  130532. constructor(device: GPUDevice);
  130533. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  130534. }
  130535. }
  130536. declare module BABYLON {
  130537. /** @hidden */
  130538. export abstract class WebGPUCacheRenderPipeline {
  130539. static NumCacheHitWithoutHash: number;
  130540. static NumCacheHitWithHash: number;
  130541. static NumCacheMiss: number;
  130542. static NumPipelineCreationLastFrame: number;
  130543. disabled: boolean;
  130544. private static _NumPipelineCreationCurrentFrame;
  130545. protected _states: number[];
  130546. protected _stateDirtyLowestIndex: number;
  130547. lastStateDirtyLowestIndex: number;
  130548. private _device;
  130549. private _isDirty;
  130550. private _emptyVertexBuffer;
  130551. private _parameter;
  130552. private _shaderId;
  130553. private _alphaToCoverageEnabled;
  130554. private _frontFace;
  130555. private _cullEnabled;
  130556. private _cullFace;
  130557. private _clampDepth;
  130558. private _rasterizationState;
  130559. private _depthBias;
  130560. private _depthBiasClamp;
  130561. private _depthBiasSlopeScale;
  130562. private _colorFormat;
  130563. private _webgpuColorFormat;
  130564. private _mrtAttachments1;
  130565. private _mrtAttachments2;
  130566. private _mrtFormats;
  130567. private _alphaBlendEnabled;
  130568. private _alphaBlendFuncParams;
  130569. private _alphaBlendEqParams;
  130570. private _writeMask;
  130571. private _colorStates;
  130572. private _depthStencilFormat;
  130573. private _webgpuDepthStencilFormat;
  130574. private _depthTestEnabled;
  130575. private _depthWriteEnabled;
  130576. private _depthCompare;
  130577. private _stencilEnabled;
  130578. private _stencilFrontCompare;
  130579. private _stencilFrontDepthFailOp;
  130580. private _stencilFrontPassOp;
  130581. private _stencilFrontFailOp;
  130582. private _stencilReadMask;
  130583. private _stencilWriteMask;
  130584. private _depthStencilState;
  130585. private _vertexBuffers;
  130586. private _overrideVertexBuffers;
  130587. private _indexBuffer;
  130588. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  130589. reset(): void;
  130590. protected abstract _getRenderPipeline(param: {
  130591. token: any;
  130592. pipeline: Nullable<GPURenderPipeline>;
  130593. }): void;
  130594. protected abstract _setRenderPipeline(param: {
  130595. token: any;
  130596. pipeline: Nullable<GPURenderPipeline>;
  130597. }): void;
  130598. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  130599. endFrame(): void;
  130600. setAlphaToCoverage(enabled: boolean): void;
  130601. setFrontFace(frontFace: number): void;
  130602. setCullEnabled(enabled: boolean): void;
  130603. setCullFace(cullFace: number): void;
  130604. setClampDepth(clampDepth: boolean): void;
  130605. resetDepthCullingState(): void;
  130606. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  130607. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  130608. setColorFormat(format: GPUTextureFormat): void;
  130609. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  130610. setAlphaBlendEnabled(enabled: boolean): void;
  130611. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  130612. setWriteMask(mask: number): void;
  130613. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  130614. setDepthTestEnabled(enabled: boolean): void;
  130615. setDepthWriteEnabled(enabled: boolean): void;
  130616. setDepthCompare(func: Nullable<number>): void;
  130617. setStencilEnabled(enabled: boolean): void;
  130618. setStencilCompare(func: Nullable<number>): void;
  130619. setStencilDepthFailOp(op: Nullable<number>): void;
  130620. setStencilPassOp(op: Nullable<number>): void;
  130621. setStencilFailOp(op: Nullable<number>): void;
  130622. setStencilReadMask(mask: number): void;
  130623. setStencilWriteMask(mask: number): void;
  130624. resetStencilState(): void;
  130625. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  130626. setBuffers(vertexBuffers: Nullable<{
  130627. [key: string]: Nullable<VertexBuffer>;
  130628. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  130629. [key: string]: Nullable<VertexBuffer>;
  130630. }>): void;
  130631. private static _GetTopology;
  130632. private static _GetAphaBlendOperation;
  130633. private static _GetAphaBlendFactor;
  130634. private static _GetCompareFunction;
  130635. private static _GetStencilOpFunction;
  130636. private static _GetVertexInputDescriptorFormat;
  130637. private _getAphaBlendState;
  130638. private _getColorBlendState;
  130639. private _setShaderStage;
  130640. private _setRasterizationState;
  130641. private _setColorStates;
  130642. private _setDepthStencilState;
  130643. private _setVertexState;
  130644. private _createPipelineLayout;
  130645. private _getVertexInputDescriptor;
  130646. private _createRenderPipeline;
  130647. }
  130648. }
  130649. declare module BABYLON {
  130650. /** @hidden */
  130651. class NodeState {
  130652. values: {
  130653. [name: number]: NodeState;
  130654. };
  130655. pipeline: GPURenderPipeline;
  130656. constructor();
  130657. count(): [number, number];
  130658. }
  130659. /** @hidden */
  130660. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  130661. private static _Cache;
  130662. private _nodeStack;
  130663. static GetNodeCounts(): {
  130664. nodeCount: number;
  130665. pipelineCount: number;
  130666. };
  130667. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  130668. protected _getRenderPipeline(param: {
  130669. token: any;
  130670. pipeline: Nullable<GPURenderPipeline>;
  130671. }): void;
  130672. protected _setRenderPipeline(param: {
  130673. token: NodeState;
  130674. pipeline: Nullable<GPURenderPipeline>;
  130675. }): void;
  130676. }
  130677. }
  130678. declare module BABYLON {
  130679. /**
  130680. * @hidden
  130681. **/
  130682. export class WebGPUStencilState extends StencilState {
  130683. private _cache;
  130684. constructor(cache: WebGPUCacheRenderPipeline);
  130685. get stencilFunc(): number;
  130686. set stencilFunc(value: number);
  130687. get stencilFuncRef(): number;
  130688. set stencilFuncRef(value: number);
  130689. get stencilFuncMask(): number;
  130690. set stencilFuncMask(value: number);
  130691. get stencilOpStencilFail(): number;
  130692. set stencilOpStencilFail(value: number);
  130693. get stencilOpDepthFail(): number;
  130694. set stencilOpDepthFail(value: number);
  130695. get stencilOpStencilDepthPass(): number;
  130696. set stencilOpStencilDepthPass(value: number);
  130697. get stencilMask(): number;
  130698. set stencilMask(value: number);
  130699. get stencilTest(): boolean;
  130700. set stencilTest(value: boolean);
  130701. reset(): void;
  130702. apply(gl: WebGLRenderingContext): void;
  130703. }
  130704. }
  130705. declare module BABYLON {
  130706. /**
  130707. * @hidden
  130708. **/
  130709. export class WebGPUDepthCullingState extends DepthCullingState {
  130710. private _cache;
  130711. /**
  130712. * Initializes the state.
  130713. */
  130714. constructor(cache: WebGPUCacheRenderPipeline);
  130715. get zOffset(): number;
  130716. set zOffset(value: number);
  130717. get cullFace(): Nullable<number>;
  130718. set cullFace(value: Nullable<number>);
  130719. get cull(): Nullable<boolean>;
  130720. set cull(value: Nullable<boolean>);
  130721. get depthFunc(): Nullable<number>;
  130722. set depthFunc(value: Nullable<number>);
  130723. get depthMask(): boolean;
  130724. set depthMask(value: boolean);
  130725. get depthTest(): boolean;
  130726. set depthTest(value: boolean);
  130727. get frontFace(): Nullable<number>;
  130728. set frontFace(value: Nullable<number>);
  130729. reset(): void;
  130730. apply(gl: WebGLRenderingContext): void;
  130731. }
  130732. }
  130733. declare module BABYLON {
  130734. /** @hidden */
  130735. export var clearQuadVertexShader: {
  130736. name: string;
  130737. shader: string;
  130738. };
  130739. }
  130740. declare module BABYLON {
  130741. /** @hidden */
  130742. export var clearQuadPixelShader: {
  130743. name: string;
  130744. shader: string;
  130745. };
  130746. }
  130747. declare module BABYLON {
  130748. /**
  130749. * Options to load the associated Glslang library
  130750. */
  130751. export interface GlslangOptions {
  130752. /**
  130753. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  130754. */
  130755. glslang?: any;
  130756. /**
  130757. * Defines the URL of the glslang JS File.
  130758. */
  130759. jsPath?: string;
  130760. /**
  130761. * Defines the URL of the glslang WASM File.
  130762. */
  130763. wasmPath?: string;
  130764. }
  130765. /**
  130766. * Options to create the WebGPU engine
  130767. */
  130768. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  130769. /**
  130770. * If delta time between frames should be constant
  130771. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130772. */
  130773. deterministicLockstep?: boolean;
  130774. /**
  130775. * Maximum about of steps between frames (Default: 4)
  130776. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130777. */
  130778. lockstepMaxSteps?: number;
  130779. /**
  130780. * Defines the seconds between each deterministic lock step
  130781. */
  130782. timeStep?: number;
  130783. /**
  130784. * Defines that engine should ignore modifying touch action attribute and style
  130785. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  130786. */
  130787. doNotHandleTouchAction?: boolean;
  130788. /**
  130789. * Defines if webaudio should be initialized as well
  130790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  130791. */
  130792. audioEngine?: boolean;
  130793. /**
  130794. * Defines the category of adapter to use.
  130795. * Is it the discrete or integrated device.
  130796. */
  130797. powerPreference?: GPUPowerPreference;
  130798. /**
  130799. * Defines the device descriptor used to create a device.
  130800. */
  130801. deviceDescriptor?: GPUDeviceDescriptor;
  130802. /**
  130803. * Defines the requested Swap Chain Format.
  130804. */
  130805. swapChainFormat?: GPUTextureFormat;
  130806. /**
  130807. * Defines whether MSAA is enabled on the canvas.
  130808. */
  130809. antialiasing?: boolean;
  130810. /**
  130811. * Defines whether the stencil buffer should be enabled.
  130812. */
  130813. stencil?: boolean;
  130814. /**
  130815. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  130816. */
  130817. enableGPUDebugMarkers?: boolean;
  130818. /**
  130819. * Options to load the associated Glslang library
  130820. */
  130821. glslangOptions?: GlslangOptions;
  130822. }
  130823. /**
  130824. * The web GPU engine class provides support for WebGPU version of babylon.js.
  130825. */
  130826. export class WebGPUEngine extends Engine {
  130827. private static readonly _glslangDefaultOptions;
  130828. private readonly _uploadEncoderDescriptor;
  130829. private readonly _renderEncoderDescriptor;
  130830. private readonly _renderTargetEncoderDescriptor;
  130831. private readonly _clearDepthValue;
  130832. private readonly _clearReverseDepthValue;
  130833. private readonly _clearStencilValue;
  130834. private readonly _defaultSampleCount;
  130835. private _canvas;
  130836. private _options;
  130837. private _glslang;
  130838. private _adapter;
  130839. private _adapterSupportedExtensions;
  130840. private _device;
  130841. private _deviceEnabledExtensions;
  130842. private _context;
  130843. private _swapChain;
  130844. private _swapChainTexture;
  130845. private _mainPassSampleCount;
  130846. private _textureHelper;
  130847. private _bufferManager;
  130848. private _shaderManager;
  130849. private _cacheSampler;
  130850. private _cacheRenderPipeline;
  130851. private _emptyVertexBuffer;
  130852. private _lastCachedWrapU;
  130853. private _lastCachedWrapV;
  130854. private _lastCachedWrapR;
  130855. private _mrtAttachments;
  130856. private _counters;
  130857. private _mainTexture;
  130858. private _depthTexture;
  130859. private _mainTextureExtends;
  130860. private _depthTextureFormat;
  130861. private _colorFormat;
  130862. private _uploadEncoder;
  130863. private _renderEncoder;
  130864. private _renderTargetEncoder;
  130865. private _commandBuffers;
  130866. private _currentRenderPass;
  130867. private _mainRenderPassWrapper;
  130868. private _rttRenderPassWrapper;
  130869. private _pendingDebugCommands;
  130870. private _currentVertexBuffers;
  130871. private _currentOverrideVertexBuffers;
  130872. private _currentIndexBuffer;
  130873. private __colorWrite;
  130874. private _uniformsBuffers;
  130875. private _forceEnableEffect;
  130876. /** @hidden */
  130877. dbgShowShaderCode: boolean;
  130878. /** @hidden */
  130879. dbgSanityChecks: boolean;
  130880. /** @hidden */
  130881. dbgGenerateLogs: boolean;
  130882. /** @hidden */
  130883. dbgVerboseLogsForFirstFrames: boolean;
  130884. /** @hidden */
  130885. dbgVerboseLogsNumFrames: number;
  130886. /** @hidden */
  130887. dbgShowWarningsNotImplemented: boolean;
  130888. /**
  130889. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  130890. */
  130891. get disableCacheSamplers(): boolean;
  130892. set disableCacheSamplers(disable: boolean);
  130893. /**
  130894. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  130895. */
  130896. get disableCacheRenderPipelines(): boolean;
  130897. set disableCacheRenderPipelines(disable: boolean);
  130898. /**
  130899. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  130900. * @returns true if the engine can be created
  130901. */
  130902. static get IsSupported(): boolean;
  130903. /**
  130904. * Gets a boolean indicating that the engine supports uniform buffers
  130905. */
  130906. get supportsUniformBuffers(): boolean;
  130907. /** Gets the supported extensions by the WebGPU adapter */
  130908. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  130909. /** Gets the currently enabled extensions on the WebGPU device */
  130910. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  130911. /**
  130912. * Returns the name of the engine
  130913. */
  130914. get name(): string;
  130915. /**
  130916. * Returns a string describing the current engine
  130917. */
  130918. get description(): string;
  130919. /**
  130920. * Returns the version of the engine
  130921. */
  130922. get version(): number;
  130923. /**
  130924. * Create a new instance of the gpu engine asynchronously
  130925. * @param canvas Defines the canvas to use to display the result
  130926. * @param options Defines the options passed to the engine to create the GPU context dependencies
  130927. * @returns a promise that resolves with the created engine
  130928. */
  130929. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  130930. /**
  130931. * Create a new instance of the gpu engine.
  130932. * @param canvas Defines the canvas to use to display the result
  130933. * @param options Defines the options passed to the engine to create the GPU context dependencies
  130934. */
  130935. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  130936. /**
  130937. * Initializes the WebGPU context and dependencies.
  130938. * @param glslangOptions Defines the GLSLang compiler options if necessary
  130939. * @returns a promise notifying the readiness of the engine.
  130940. */
  130941. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  130942. private _initGlslang;
  130943. private _initializeLimits;
  130944. private _initializeContextAndSwapChain;
  130945. private _initializeMainAttachments;
  130946. /**
  130947. * Force a specific size of the canvas
  130948. * @param width defines the new canvas' width
  130949. * @param height defines the new canvas' height
  130950. * @param forceSetSize true to force setting the sizes of the underlying canvas
  130951. * @returns true if the size was changed
  130952. */
  130953. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  130954. /**
  130955. * Gets a shader processor implementation fitting with the current engine type.
  130956. * @returns The shader processor implementation.
  130957. */
  130958. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  130959. /** @hidden */
  130960. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  130961. /**
  130962. * Force the entire cache to be cleared
  130963. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  130964. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130965. */
  130966. wipeCaches(bruteForce?: boolean): void;
  130967. /**
  130968. * Enable or disable color writing
  130969. * @param enable defines the state to set
  130970. */
  130971. setColorWrite(enable: boolean): void;
  130972. /**
  130973. * Gets a boolean indicating if color writing is enabled
  130974. * @returns the current color writing state
  130975. */
  130976. getColorWrite(): boolean;
  130977. private _viewportsCurrent;
  130978. private _resetCurrentViewport;
  130979. private _applyViewport;
  130980. /** @hidden */
  130981. _viewport(x: number, y: number, width: number, height: number): void;
  130982. private _scissorsCurrent;
  130983. protected _scissorCached: {
  130984. x: number;
  130985. y: number;
  130986. z: number;
  130987. w: number;
  130988. };
  130989. private _resetCurrentScissor;
  130990. private _applyScissor;
  130991. private _scissorIsActive;
  130992. enableScissor(x: number, y: number, width: number, height: number): void;
  130993. disableScissor(): void;
  130994. /**
  130995. * Clear the current render buffer or the current render target (if any is set up)
  130996. * @param color defines the color to use
  130997. * @param backBuffer defines if the back buffer must be cleared
  130998. * @param depth defines if the depth buffer must be cleared
  130999. * @param stencil defines if the stencil buffer must be cleared
  131000. */
  131001. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131002. /**
  131003. * Clears a list of attachments
  131004. * @param attachments list of the attachments
  131005. * @param colorMain clear color for the main attachment (the first one)
  131006. * @param colorOthers clear color for the other attachments
  131007. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  131008. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  131009. */
  131010. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  131011. /**
  131012. * Creates a vertex buffer
  131013. * @param data the data for the vertex buffer
  131014. * @returns the new buffer
  131015. */
  131016. createVertexBuffer(data: DataArray): DataBuffer;
  131017. /**
  131018. * Creates a vertex buffer
  131019. * @param data the data for the dynamic vertex buffer
  131020. * @returns the new buffer
  131021. */
  131022. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  131023. /**
  131024. * Updates a vertex buffer.
  131025. * @param vertexBuffer the vertex buffer to update
  131026. * @param data the data used to update the vertex buffer
  131027. * @param byteOffset the byte offset of the data
  131028. * @param byteLength the byte length of the data
  131029. */
  131030. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  131031. /**
  131032. * Creates a new index buffer
  131033. * @param indices defines the content of the index buffer
  131034. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  131035. * @returns a new buffer
  131036. */
  131037. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  131038. /**
  131039. * Update an index buffer
  131040. * @param indexBuffer defines the target index buffer
  131041. * @param indices defines the data to update
  131042. * @param offset defines the offset in the target index buffer where update should start
  131043. */
  131044. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  131045. /** @hidden */
  131046. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  131047. /** @hidden */
  131048. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  131049. /**
  131050. * Bind a list of vertex buffers with the engine
  131051. * @param vertexBuffers defines the list of vertex buffers to bind
  131052. * @param indexBuffer defines the index buffer to bind
  131053. * @param effect defines the effect associated with the vertex buffers
  131054. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  131055. */
  131056. bindBuffers(vertexBuffers: {
  131057. [key: string]: Nullable<VertexBuffer>;
  131058. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  131059. [kind: string]: Nullable<VertexBuffer>;
  131060. }): void;
  131061. /** @hidden */
  131062. _releaseBuffer(buffer: DataBuffer): boolean;
  131063. createUniformBuffer(elements: FloatArray): DataBuffer;
  131064. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  131065. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  131066. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  131067. /**
  131068. * Create a new effect (used to store vertex/fragment shaders)
  131069. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  131070. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  131071. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  131072. * @param samplers defines an array of string used to represent textures
  131073. * @param defines defines the string containing the defines to use to compile the shaders
  131074. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  131075. * @param onCompiled defines a function to call when the effect creation is successful
  131076. * @param onError defines a function to call when the effect creation has failed
  131077. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  131078. * @returns the new Effect
  131079. */
  131080. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  131081. private _compileRawShaderToSpirV;
  131082. private _compileShaderToSpirV;
  131083. private _createPipelineStageDescriptor;
  131084. private _compileRawPipelineStageDescriptor;
  131085. private _compilePipelineStageDescriptor;
  131086. /** @hidden */
  131087. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  131088. /** @hidden */
  131089. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  131090. /**
  131091. * Creates a new pipeline context
  131092. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  131093. * @returns the new pipeline
  131094. */
  131095. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  131096. /** @hidden */
  131097. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  131098. /**
  131099. * Gets the list of active attributes for a given WebGPU program
  131100. * @param pipelineContext defines the pipeline context to use
  131101. * @param attributesNames defines the list of attribute names to get
  131102. * @returns an array of indices indicating the offset of each attribute
  131103. */
  131104. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131105. /**
  131106. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  131107. * @param effect defines the effect to activate
  131108. */
  131109. enableEffect(effect: Nullable<Effect>): void;
  131110. /** @hidden */
  131111. _releaseEffect(effect: Effect): void;
  131112. /**
  131113. * 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
  131114. */
  131115. releaseEffects(): void;
  131116. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131117. /**
  131118. * Gets a boolean indicating that only power of 2 textures are supported
  131119. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  131120. */
  131121. get needPOTTextures(): boolean;
  131122. /** @hidden */
  131123. _createHardwareTexture(): HardwareTextureWrapper;
  131124. /** @hidden */
  131125. _releaseTexture(texture: InternalTexture): void;
  131126. /** @hidden */
  131127. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  131128. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  131129. /**
  131130. * Usually called from Texture.ts.
  131131. * Passed information to create a hardware texture
  131132. * @param url defines a value which contains one of the following:
  131133. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131134. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131135. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131136. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131137. * @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)
  131138. * @param scene needed for loading to the correct scene
  131139. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131140. * @param onLoad optional callback to be called upon successful completion
  131141. * @param onError optional callback to be called upon failure
  131142. * @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
  131143. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131144. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131145. * @param forcedExtension defines the extension to use to pick the right loader
  131146. * @param mimeType defines an optional mime type
  131147. * @param loaderOptions options to be passed to the loader
  131148. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131149. */
  131150. 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;
  131151. /** @hidden */
  131152. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  131153. /**
  131154. * Creates a cube texture
  131155. * @param rootUrl defines the url where the files to load is located
  131156. * @param scene defines the current scene
  131157. * @param files defines the list of files to load (1 per face)
  131158. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  131159. * @param onLoad defines an optional callback raised when the texture is loaded
  131160. * @param onError defines an optional callback raised if there is an issue to load the texture
  131161. * @param format defines the format of the data
  131162. * @param forcedExtension defines the extension to use to pick the right loader
  131163. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  131164. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131165. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131166. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  131167. * @param loaderOptions options to be passed to the loader
  131168. * @returns the cube texture as an InternalTexture
  131169. */
  131170. 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;
  131171. /**
  131172. * Creates a raw texture
  131173. * @param data defines the data to store in the texture
  131174. * @param width defines the width of the texture
  131175. * @param height defines the height of the texture
  131176. * @param format defines the format of the data
  131177. * @param generateMipMaps defines if the engine should generate the mip levels
  131178. * @param invertY defines if data must be stored with Y axis inverted
  131179. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  131180. * @param compression defines the compression used (null by default)
  131181. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131182. * @returns the raw texture inside an InternalTexture
  131183. */
  131184. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  131185. /**
  131186. * Creates a new raw cube texture
  131187. * @param data defines the array of data to use to create each face
  131188. * @param size defines the size of the textures
  131189. * @param format defines the format of the data
  131190. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131191. * @param generateMipMaps defines if the engine should generate the mip levels
  131192. * @param invertY defines if data must be stored with Y axis inverted
  131193. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131194. * @param compression defines the compression used (null by default)
  131195. * @returns the cube texture as an InternalTexture
  131196. */
  131197. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  131198. /**
  131199. * Creates a new raw cube texture from a specified url
  131200. * @param url defines the url where the data is located
  131201. * @param scene defines the current scene
  131202. * @param size defines the size of the textures
  131203. * @param format defines the format of the data
  131204. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131205. * @param noMipmap defines if the engine should avoid generating the mip levels
  131206. * @param callback defines a callback used to extract texture data from loaded data
  131207. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  131208. * @param onLoad defines a callback called when texture is loaded
  131209. * @param onError defines a callback called if there is an error
  131210. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131211. * @param invertY defines if data must be stored with Y axis inverted
  131212. * @returns the cube texture as an InternalTexture
  131213. */
  131214. 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;
  131215. /**
  131216. * Creates a new raw 2D array texture
  131217. * @param data defines the data used to create the texture
  131218. * @param width defines the width of the texture
  131219. * @param height defines the height of the texture
  131220. * @param depth defines the number of layers of the texture
  131221. * @param format defines the format of the texture
  131222. * @param generateMipMaps defines if the engine must generate mip levels
  131223. * @param invertY defines if data must be stored with Y axis inverted
  131224. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131225. * @param compression defines the compressed used (can be null)
  131226. * @param textureType defines the compressed used (can be null)
  131227. * @returns a new raw 2D array texture (stored in an InternalTexture)
  131228. */
  131229. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  131230. /**
  131231. * Creates a new raw 3D texture
  131232. * @param data defines the data used to create the texture
  131233. * @param width defines the width of the texture
  131234. * @param height defines the height of the texture
  131235. * @param depth defines the depth of the texture
  131236. * @param format defines the format of the texture
  131237. * @param generateMipMaps defines if the engine must generate mip levels
  131238. * @param invertY defines if data must be stored with Y axis inverted
  131239. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131240. * @param compression defines the compressed used (can be null)
  131241. * @param textureType defines the compressed used (can be null)
  131242. * @returns a new raw 3D texture (stored in an InternalTexture)
  131243. */
  131244. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  131245. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  131246. /**
  131247. * Update the sampling mode of a given texture
  131248. * @param samplingMode defines the required sampling mode
  131249. * @param texture defines the texture to update
  131250. * @param generateMipMaps defines whether to generate mipmaps for the texture
  131251. */
  131252. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  131253. /**
  131254. * Update the sampling mode of a given texture
  131255. * @param texture defines the texture to update
  131256. * @param wrapU defines the texture wrap mode of the u coordinates
  131257. * @param wrapV defines the texture wrap mode of the v coordinates
  131258. * @param wrapR defines the texture wrap mode of the r coordinates
  131259. */
  131260. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  131261. /**
  131262. * Update the dimensions of a texture
  131263. * @param texture texture to update
  131264. * @param width new width of the texture
  131265. * @param height new height of the texture
  131266. * @param depth new depth of the texture
  131267. */
  131268. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  131269. private _setInternalTexture;
  131270. /**
  131271. * Sets a texture to the according uniform.
  131272. * @param channel The texture channel
  131273. * @param unused unused parameter
  131274. * @param texture The texture to apply
  131275. * @param name The name of the uniform in the effect
  131276. */
  131277. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  131278. /**
  131279. * Sets an array of texture to the WebGPU context
  131280. * @param channel defines the channel where the texture array must be set
  131281. * @param unused unused parameter
  131282. * @param textures defines the array of textures to bind
  131283. * @param name name of the channel
  131284. */
  131285. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  131286. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  131287. /** @hidden */
  131288. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  131289. /** @hidden */
  131290. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  131291. private _generateMipmaps;
  131292. /**
  131293. * Update the content of a texture
  131294. * @param texture defines the texture to update
  131295. * @param canvas defines the source containing the data
  131296. * @param invertY defines if data must be stored with Y axis inverted
  131297. * @param premulAlpha defines if alpha is stored as premultiplied
  131298. * @param format defines the format of the data
  131299. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  131300. */
  131301. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  131302. /**
  131303. * Update a portion of an internal texture
  131304. * @param texture defines the texture to update
  131305. * @param imageData defines the data to store into the texture
  131306. * @param xOffset defines the x coordinates of the update rectangle
  131307. * @param yOffset defines the y coordinates of the update rectangle
  131308. * @param width defines the width of the update rectangle
  131309. * @param height defines the height of the update rectangle
  131310. * @param faceIndex defines the face index if texture is a cube (0 by default)
  131311. * @param lod defines the lod level to update (0 by default)
  131312. */
  131313. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  131314. /**
  131315. * Update a video texture
  131316. * @param texture defines the texture to update
  131317. * @param video defines the video element to use
  131318. * @param invertY defines if data must be stored with Y axis inverted
  131319. */
  131320. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  131321. /** @hidden */
  131322. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131323. /** @hidden */
  131324. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  131325. /** @hidden */
  131326. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131327. /** @hidden */
  131328. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  131329. /**
  131330. * Update a raw texture
  131331. * @param texture defines the texture to update
  131332. * @param bufferView defines the data to store in the texture
  131333. * @param format defines the format of the data
  131334. * @param invertY defines if data must be stored with Y axis inverted
  131335. * @param compression defines the compression used (null by default)
  131336. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131337. */
  131338. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  131339. /**
  131340. * Update a raw cube texture
  131341. * @param texture defines the texture to update
  131342. * @param bufferView defines the data to store
  131343. * @param format defines the data format
  131344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131345. * @param invertY defines if data must be stored with Y axis inverted
  131346. * @param compression defines the compression used (null by default)
  131347. * @param level defines which level of the texture to update
  131348. */
  131349. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  131350. /**
  131351. * Update a raw 2D array texture
  131352. * @param texture defines the texture to update
  131353. * @param bufferView defines the data to store
  131354. * @param format defines the data format
  131355. * @param invertY defines if data must be stored with Y axis inverted
  131356. * @param compression defines the used compression (can be null)
  131357. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131358. */
  131359. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  131360. /**
  131361. * Update a raw 3D texture
  131362. * @param texture defines the texture to update
  131363. * @param bufferView defines the data to store
  131364. * @param format defines the data format
  131365. * @param invertY defines if data must be stored with Y axis inverted
  131366. * @param compression defines the used compression (can be null)
  131367. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131368. */
  131369. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  131370. /**
  131371. * Reads pixels from the current frame buffer. Please note that this function can be slow
  131372. * @param x defines the x coordinate of the rectangle where pixels must be read
  131373. * @param y defines the y coordinate of the rectangle where pixels must be read
  131374. * @param width defines the width of the rectangle where pixels must be read
  131375. * @param height defines the height of the rectangle where pixels must be read
  131376. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  131377. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  131378. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  131379. */
  131380. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  131381. /** @hidden */
  131382. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  131383. /** @hidden */
  131384. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  131385. /**
  131386. * Creates a new render target texture
  131387. * @param size defines the size of the texture
  131388. * @param options defines the options used to create the texture
  131389. * @returns a new render target texture stored in an InternalTexture
  131390. */
  131391. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  131392. /**
  131393. * Create a multi render target texture
  131394. * @param size defines the size of the texture
  131395. * @param options defines the creation options
  131396. * @returns the cube texture as an InternalTexture
  131397. */
  131398. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  131399. /**
  131400. * Creates a new render target cube texture
  131401. * @param size defines the size of the texture
  131402. * @param options defines the options used to create the texture
  131403. * @returns a new render target cube texture stored in an InternalTexture
  131404. */
  131405. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  131406. /** @hidden */
  131407. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  131408. width: number;
  131409. height: number;
  131410. layers?: number;
  131411. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  131412. /** @hidden */
  131413. _createDepthStencilTexture(size: number | {
  131414. width: number;
  131415. height: number;
  131416. layers?: number;
  131417. }, options: DepthTextureCreationOptions): InternalTexture;
  131418. /** @hidden */
  131419. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  131420. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  131421. /**
  131422. * Update the sample count for a given multiple render target texture
  131423. * @param textures defines the textures to update
  131424. * @param samples defines the sample count to set
  131425. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  131426. */
  131427. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  131428. /**
  131429. * Begin a new frame
  131430. */
  131431. beginFrame(): void;
  131432. /**
  131433. * End the current frame
  131434. */
  131435. endFrame(): void;
  131436. /**
  131437. * Force a WebGPU flush (ie. a flush of all waiting commands)
  131438. */
  131439. flushFramebuffer(): void;
  131440. private _startRenderTargetRenderPass;
  131441. private _endRenderTargetRenderPass;
  131442. private _getCurrentRenderPass;
  131443. private _startMainRenderPass;
  131444. private _endMainRenderPass;
  131445. /**
  131446. * Restores the WebGPU state to only draw on the main color attachment
  131447. */
  131448. restoreSingleAttachment(): void;
  131449. /**
  131450. * Creates a layout object to draw/clear on specific textures in a MRT
  131451. * @param textureStatus textureStatus[i] indicates if the i-th is active
  131452. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  131453. */
  131454. buildTextureLayout(textureStatus: boolean[]): number[];
  131455. /**
  131456. * Select a subsets of attachments to draw to.
  131457. * @param attachments index of attachments
  131458. */
  131459. bindAttachments(attachments: number[]): void;
  131460. /**
  131461. * Binds the frame buffer to the specified texture.
  131462. * @param texture The texture to render to or null for the default canvas
  131463. * @param faceIndex The face of the texture to render to in case of cube texture
  131464. * @param requiredWidth The width of the target to render to
  131465. * @param requiredHeight The height of the target to render to
  131466. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  131467. * @param lodLevel defines the lod level to bind to the frame buffer
  131468. * @param layer defines the 2d array index to bind to frame buffer to
  131469. */
  131470. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  131471. /**
  131472. * Unbind the current render target texture from the WebGPU context
  131473. * @param texture defines the render target texture to unbind
  131474. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  131475. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  131476. */
  131477. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131478. /**
  131479. * Unbind a list of render target textures from the WebGPU context
  131480. * @param textures defines the render target textures to unbind
  131481. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  131482. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  131483. */
  131484. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131485. /**
  131486. * Unbind the current render target and bind the default framebuffer
  131487. */
  131488. restoreDefaultFramebuffer(): void;
  131489. private _setColorFormat;
  131490. private _setDepthTextureFormat;
  131491. setDitheringState(value: boolean): void;
  131492. setRasterizerState(value: boolean): void;
  131493. /**
  131494. * Set various states to the context
  131495. * @param culling defines backface culling state
  131496. * @param zOffset defines the value to apply to zOffset (0 by default)
  131497. * @param force defines if states must be applied even if cache is up to date
  131498. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  131499. */
  131500. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131501. /**
  131502. * Sets the current alpha mode
  131503. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  131504. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131505. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131506. */
  131507. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131508. /**
  131509. * Sets the current alpha equation
  131510. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  131511. */
  131512. setAlphaEquation(equation: number): void;
  131513. private _getBindGroupsToRender;
  131514. private _bindVertexInputs;
  131515. private _setRenderBindGroups;
  131516. private _setRenderPipeline;
  131517. /**
  131518. * Draw a list of indexed primitives
  131519. * @param fillMode defines the primitive to use
  131520. * @param indexStart defines the starting index
  131521. * @param indexCount defines the number of index to draw
  131522. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  131523. */
  131524. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131525. /**
  131526. * Draw a list of unindexed primitives
  131527. * @param fillMode defines the primitive to use
  131528. * @param verticesStart defines the index of first vertex to draw
  131529. * @param verticesCount defines the count of vertices to draw
  131530. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  131531. */
  131532. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131533. private _bundleEncoder;
  131534. /**
  131535. * Start recording all the gpu calls into a bundle.
  131536. */
  131537. startRecordBundle(): void;
  131538. /**
  131539. * Stops recording the bundle.
  131540. * @returns the recorded bundle
  131541. */
  131542. stopRecordBundle(): GPURenderBundle;
  131543. /**
  131544. * Execute the previously recorded bundle.
  131545. * @param bundles defines the bundle to replay
  131546. */
  131547. executeBundles(bundles: GPURenderBundle[]): void;
  131548. /**
  131549. * Dispose and release all associated resources
  131550. */
  131551. dispose(): void;
  131552. /**
  131553. * Gets the current render width
  131554. * @param useScreen defines if screen size must be used (or the current render target if any)
  131555. * @returns a number defining the current render width
  131556. */
  131557. getRenderWidth(useScreen?: boolean): number;
  131558. /**
  131559. * Gets the current render height
  131560. * @param useScreen defines if screen size must be used (or the current render target if any)
  131561. * @returns a number defining the current render height
  131562. */
  131563. getRenderHeight(useScreen?: boolean): number;
  131564. /**
  131565. * Gets the HTML canvas attached with the current WebGPU context
  131566. * @returns a HTML canvas
  131567. */
  131568. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  131569. /** @hidden */
  131570. _debugPushGroup(groupName: string, targetObject?: number): void;
  131571. /** @hidden */
  131572. _debugPopGroup(targetObject?: number): void;
  131573. /** @hidden */
  131574. _debugInsertMarker(text: string, targetObject?: number): void;
  131575. private _debugFlushPendingCommands;
  131576. /**
  131577. * Get the current error code of the WebGPU context
  131578. * @returns the error code
  131579. */
  131580. getError(): number;
  131581. /** @hidden */
  131582. bindSamplers(effect: Effect): void;
  131583. /** @hidden */
  131584. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  131585. /** @hidden */
  131586. _releaseFramebufferObjects(texture: InternalTexture): void;
  131587. /** @hidden */
  131588. applyStates(): void;
  131589. /**
  131590. * Gets a boolean indicating if all created effects are ready
  131591. * @returns always true - No parallel shader compilation
  131592. */
  131593. areAllEffectsReady(): boolean;
  131594. /** @hidden */
  131595. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131596. /** @hidden */
  131597. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131598. /** @hidden */
  131599. _getUnpackAlignement(): number;
  131600. /** @hidden */
  131601. _unpackFlipY(value: boolean): void;
  131602. /** @hidden */
  131603. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  131604. min: number;
  131605. mag: number;
  131606. };
  131607. /** @hidden */
  131608. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131609. /** @hidden */
  131610. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  131611. /** @hidden */
  131612. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  131613. /** @hidden */
  131614. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  131615. /** @hidden */
  131616. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  131617. /** @hidden */
  131618. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  131619. /** @hidden */
  131620. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  131621. /** @hidden */
  131622. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  131623. /** @hidden */
  131624. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  131625. /** @hidden */
  131626. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  131627. /** @hidden */
  131628. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  131629. /** @hidden */
  131630. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  131631. /** @hidden */
  131632. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  131633. /** @hidden */
  131634. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  131635. /** @hidden */
  131636. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  131637. /** @hidden */
  131638. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  131639. /** @hidden */
  131640. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  131641. }
  131642. }
  131643. declare module BABYLON {
  131644. /**
  131645. * Define an interface for all classes that will hold resources
  131646. */
  131647. export interface IDisposable {
  131648. /**
  131649. * Releases all held resources
  131650. */
  131651. dispose(): void;
  131652. }
  131653. /** Interface defining initialization parameters for Scene class */
  131654. export interface SceneOptions {
  131655. /**
  131656. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  131657. * It will improve performance when the number of geometries becomes important.
  131658. */
  131659. useGeometryUniqueIdsMap?: boolean;
  131660. /**
  131661. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  131662. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  131663. */
  131664. useMaterialMeshMap?: boolean;
  131665. /**
  131666. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  131667. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  131668. */
  131669. useClonedMeshMap?: boolean;
  131670. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  131671. virtual?: boolean;
  131672. }
  131673. /**
  131674. * Represents a scene to be rendered by the engine.
  131675. * @see https://doc.babylonjs.com/features/scene
  131676. */
  131677. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  131678. /** The fog is deactivated */
  131679. static readonly FOGMODE_NONE: number;
  131680. /** The fog density is following an exponential function */
  131681. static readonly FOGMODE_EXP: number;
  131682. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  131683. static readonly FOGMODE_EXP2: number;
  131684. /** The fog density is following a linear function. */
  131685. static readonly FOGMODE_LINEAR: number;
  131686. /**
  131687. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  131688. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131689. */
  131690. static MinDeltaTime: number;
  131691. /**
  131692. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  131693. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131694. */
  131695. static MaxDeltaTime: number;
  131696. /**
  131697. * Factory used to create the default material.
  131698. * @param name The name of the material to create
  131699. * @param scene The scene to create the material for
  131700. * @returns The default material
  131701. */
  131702. static DefaultMaterialFactory(scene: Scene): Material;
  131703. /**
  131704. * Factory used to create the a collision coordinator.
  131705. * @returns The collision coordinator
  131706. */
  131707. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  131708. /** @hidden */
  131709. _inputManager: InputManager;
  131710. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  131711. cameraToUseForPointers: Nullable<Camera>;
  131712. /** @hidden */
  131713. readonly _isScene: boolean;
  131714. /** @hidden */
  131715. _blockEntityCollection: boolean;
  131716. /**
  131717. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  131718. */
  131719. autoClear: boolean;
  131720. /**
  131721. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  131722. */
  131723. autoClearDepthAndStencil: boolean;
  131724. /**
  131725. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  131726. */
  131727. clearColor: Color4;
  131728. /**
  131729. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  131730. */
  131731. ambientColor: Color3;
  131732. /**
  131733. * This is use to store the default BRDF lookup for PBR materials in your scene.
  131734. * It should only be one of the following (if not the default embedded one):
  131735. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  131736. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  131737. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  131738. * The material properties need to be setup according to the type of texture in use.
  131739. */
  131740. environmentBRDFTexture: BaseTexture;
  131741. /**
  131742. * Texture used in all pbr material as the reflection texture.
  131743. * As in the majority of the scene they are the same (exception for multi room and so on),
  131744. * this is easier to reference from here than from all the materials.
  131745. */
  131746. get environmentTexture(): Nullable<BaseTexture>;
  131747. /**
  131748. * Texture used in all pbr material as the reflection texture.
  131749. * As in the majority of the scene they are the same (exception for multi room and so on),
  131750. * this is easier to set here than in all the materials.
  131751. */
  131752. set environmentTexture(value: Nullable<BaseTexture>);
  131753. /** @hidden */
  131754. protected _environmentIntensity: number;
  131755. /**
  131756. * Intensity of the environment in all pbr material.
  131757. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  131758. * As in the majority of the scene they are the same (exception for multi room and so on),
  131759. * this is easier to reference from here than from all the materials.
  131760. */
  131761. get environmentIntensity(): number;
  131762. /**
  131763. * Intensity of the environment in all pbr material.
  131764. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  131765. * As in the majority of the scene they are the same (exception for multi room and so on),
  131766. * this is easier to set here than in all the materials.
  131767. */
  131768. set environmentIntensity(value: number);
  131769. /** @hidden */
  131770. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131771. /**
  131772. * Default image processing configuration used either in the rendering
  131773. * Forward main pass or through the imageProcessingPostProcess if present.
  131774. * As in the majority of the scene they are the same (exception for multi camera),
  131775. * this is easier to reference from here than from all the materials and post process.
  131776. *
  131777. * No setter as we it is a shared configuration, you can set the values instead.
  131778. */
  131779. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  131780. private _forceWireframe;
  131781. /**
  131782. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  131783. */
  131784. set forceWireframe(value: boolean);
  131785. get forceWireframe(): boolean;
  131786. private _skipFrustumClipping;
  131787. /**
  131788. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  131789. */
  131790. set skipFrustumClipping(value: boolean);
  131791. get skipFrustumClipping(): boolean;
  131792. private _forcePointsCloud;
  131793. /**
  131794. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  131795. */
  131796. set forcePointsCloud(value: boolean);
  131797. get forcePointsCloud(): boolean;
  131798. /**
  131799. * Gets or sets the active clipplane 1
  131800. */
  131801. clipPlane: Nullable<Plane>;
  131802. /**
  131803. * Gets or sets the active clipplane 2
  131804. */
  131805. clipPlane2: Nullable<Plane>;
  131806. /**
  131807. * Gets or sets the active clipplane 3
  131808. */
  131809. clipPlane3: Nullable<Plane>;
  131810. /**
  131811. * Gets or sets the active clipplane 4
  131812. */
  131813. clipPlane4: Nullable<Plane>;
  131814. /**
  131815. * Gets or sets the active clipplane 5
  131816. */
  131817. clipPlane5: Nullable<Plane>;
  131818. /**
  131819. * Gets or sets the active clipplane 6
  131820. */
  131821. clipPlane6: Nullable<Plane>;
  131822. /**
  131823. * Gets or sets a boolean indicating if animations are enabled
  131824. */
  131825. animationsEnabled: boolean;
  131826. private _animationPropertiesOverride;
  131827. /**
  131828. * Gets or sets the animation properties override
  131829. */
  131830. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  131831. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  131832. /**
  131833. * Gets or sets a boolean indicating if a constant deltatime has to be used
  131834. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  131835. */
  131836. useConstantAnimationDeltaTime: boolean;
  131837. /**
  131838. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  131839. * Please note that it requires to run a ray cast through the scene on every frame
  131840. */
  131841. constantlyUpdateMeshUnderPointer: boolean;
  131842. /**
  131843. * Defines the HTML cursor to use when hovering over interactive elements
  131844. */
  131845. hoverCursor: string;
  131846. /**
  131847. * Defines the HTML default cursor to use (empty by default)
  131848. */
  131849. defaultCursor: string;
  131850. /**
  131851. * Defines whether cursors are handled by the scene.
  131852. */
  131853. doNotHandleCursors: boolean;
  131854. /**
  131855. * This is used to call preventDefault() on pointer down
  131856. * in order to block unwanted artifacts like system double clicks
  131857. */
  131858. preventDefaultOnPointerDown: boolean;
  131859. /**
  131860. * This is used to call preventDefault() on pointer up
  131861. * in order to block unwanted artifacts like system double clicks
  131862. */
  131863. preventDefaultOnPointerUp: boolean;
  131864. /**
  131865. * Gets or sets user defined metadata
  131866. */
  131867. metadata: any;
  131868. /**
  131869. * For internal use only. Please do not use.
  131870. */
  131871. reservedDataStore: any;
  131872. /**
  131873. * Gets the name of the plugin used to load this scene (null by default)
  131874. */
  131875. loadingPluginName: string;
  131876. /**
  131877. * Use this array to add regular expressions used to disable offline support for specific urls
  131878. */
  131879. disableOfflineSupportExceptionRules: RegExp[];
  131880. /**
  131881. * An event triggered when the scene is disposed.
  131882. */
  131883. onDisposeObservable: Observable<Scene>;
  131884. private _onDisposeObserver;
  131885. /** Sets a function to be executed when this scene is disposed. */
  131886. set onDispose(callback: () => void);
  131887. /**
  131888. * An event triggered before rendering the scene (right after animations and physics)
  131889. */
  131890. onBeforeRenderObservable: Observable<Scene>;
  131891. private _onBeforeRenderObserver;
  131892. /** Sets a function to be executed before rendering this scene */
  131893. set beforeRender(callback: Nullable<() => void>);
  131894. /**
  131895. * An event triggered after rendering the scene
  131896. */
  131897. onAfterRenderObservable: Observable<Scene>;
  131898. /**
  131899. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  131900. */
  131901. onAfterRenderCameraObservable: Observable<Camera>;
  131902. private _onAfterRenderObserver;
  131903. /** Sets a function to be executed after rendering this scene */
  131904. set afterRender(callback: Nullable<() => void>);
  131905. /**
  131906. * An event triggered before animating the scene
  131907. */
  131908. onBeforeAnimationsObservable: Observable<Scene>;
  131909. /**
  131910. * An event triggered after animations processing
  131911. */
  131912. onAfterAnimationsObservable: Observable<Scene>;
  131913. /**
  131914. * An event triggered before draw calls are ready to be sent
  131915. */
  131916. onBeforeDrawPhaseObservable: Observable<Scene>;
  131917. /**
  131918. * An event triggered after draw calls have been sent
  131919. */
  131920. onAfterDrawPhaseObservable: Observable<Scene>;
  131921. /**
  131922. * An event triggered when the scene is ready
  131923. */
  131924. onReadyObservable: Observable<Scene>;
  131925. /**
  131926. * An event triggered before rendering a camera
  131927. */
  131928. onBeforeCameraRenderObservable: Observable<Camera>;
  131929. private _onBeforeCameraRenderObserver;
  131930. /** Sets a function to be executed before rendering a camera*/
  131931. set beforeCameraRender(callback: () => void);
  131932. /**
  131933. * An event triggered after rendering a camera
  131934. */
  131935. onAfterCameraRenderObservable: Observable<Camera>;
  131936. private _onAfterCameraRenderObserver;
  131937. /** Sets a function to be executed after rendering a camera*/
  131938. set afterCameraRender(callback: () => void);
  131939. /**
  131940. * An event triggered when active meshes evaluation is about to start
  131941. */
  131942. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  131943. /**
  131944. * An event triggered when active meshes evaluation is done
  131945. */
  131946. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  131947. /**
  131948. * An event triggered when particles rendering is about to start
  131949. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  131950. */
  131951. onBeforeParticlesRenderingObservable: Observable<Scene>;
  131952. /**
  131953. * An event triggered when particles rendering is done
  131954. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  131955. */
  131956. onAfterParticlesRenderingObservable: Observable<Scene>;
  131957. /**
  131958. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  131959. */
  131960. onDataLoadedObservable: Observable<Scene>;
  131961. /**
  131962. * An event triggered when a camera is created
  131963. */
  131964. onNewCameraAddedObservable: Observable<Camera>;
  131965. /**
  131966. * An event triggered when a camera is removed
  131967. */
  131968. onCameraRemovedObservable: Observable<Camera>;
  131969. /**
  131970. * An event triggered when a light is created
  131971. */
  131972. onNewLightAddedObservable: Observable<Light>;
  131973. /**
  131974. * An event triggered when a light is removed
  131975. */
  131976. onLightRemovedObservable: Observable<Light>;
  131977. /**
  131978. * An event triggered when a geometry is created
  131979. */
  131980. onNewGeometryAddedObservable: Observable<Geometry>;
  131981. /**
  131982. * An event triggered when a geometry is removed
  131983. */
  131984. onGeometryRemovedObservable: Observable<Geometry>;
  131985. /**
  131986. * An event triggered when a transform node is created
  131987. */
  131988. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  131989. /**
  131990. * An event triggered when a transform node is removed
  131991. */
  131992. onTransformNodeRemovedObservable: Observable<TransformNode>;
  131993. /**
  131994. * An event triggered when a mesh is created
  131995. */
  131996. onNewMeshAddedObservable: Observable<AbstractMesh>;
  131997. /**
  131998. * An event triggered when a mesh is removed
  131999. */
  132000. onMeshRemovedObservable: Observable<AbstractMesh>;
  132001. /**
  132002. * An event triggered when a skeleton is created
  132003. */
  132004. onNewSkeletonAddedObservable: Observable<Skeleton>;
  132005. /**
  132006. * An event triggered when a skeleton is removed
  132007. */
  132008. onSkeletonRemovedObservable: Observable<Skeleton>;
  132009. /**
  132010. * An event triggered when a material is created
  132011. */
  132012. onNewMaterialAddedObservable: Observable<Material>;
  132013. /**
  132014. * An event triggered when a multi material is created
  132015. */
  132016. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  132017. /**
  132018. * An event triggered when a material is removed
  132019. */
  132020. onMaterialRemovedObservable: Observable<Material>;
  132021. /**
  132022. * An event triggered when a multi material is removed
  132023. */
  132024. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  132025. /**
  132026. * An event triggered when a texture is created
  132027. */
  132028. onNewTextureAddedObservable: Observable<BaseTexture>;
  132029. /**
  132030. * An event triggered when a texture is removed
  132031. */
  132032. onTextureRemovedObservable: Observable<BaseTexture>;
  132033. /**
  132034. * An event triggered when render targets are about to be rendered
  132035. * Can happen multiple times per frame.
  132036. */
  132037. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  132038. /**
  132039. * An event triggered when render targets were rendered.
  132040. * Can happen multiple times per frame.
  132041. */
  132042. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  132043. /**
  132044. * An event triggered before calculating deterministic simulation step
  132045. */
  132046. onBeforeStepObservable: Observable<Scene>;
  132047. /**
  132048. * An event triggered after calculating deterministic simulation step
  132049. */
  132050. onAfterStepObservable: Observable<Scene>;
  132051. /**
  132052. * An event triggered when the activeCamera property is updated
  132053. */
  132054. onActiveCameraChanged: Observable<Scene>;
  132055. /**
  132056. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  132057. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  132058. * 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)
  132059. */
  132060. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  132061. /**
  132062. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  132063. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  132064. * 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)
  132065. */
  132066. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  132067. /**
  132068. * This Observable will when a mesh has been imported into the scene.
  132069. */
  132070. onMeshImportedObservable: Observable<AbstractMesh>;
  132071. /**
  132072. * This Observable will when an animation file has been imported into the scene.
  132073. */
  132074. onAnimationFileImportedObservable: Observable<Scene>;
  132075. /**
  132076. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  132077. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  132078. */
  132079. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  132080. /** @hidden */
  132081. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  132082. /**
  132083. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  132084. */
  132085. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  132086. /**
  132087. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  132088. */
  132089. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  132090. /**
  132091. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  132092. */
  132093. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  132094. /** Callback called when a pointer move is detected */
  132095. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  132096. /** Callback called when a pointer down is detected */
  132097. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  132098. /** Callback called when a pointer up is detected */
  132099. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  132100. /** Callback called when a pointer pick is detected */
  132101. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  132102. /**
  132103. * 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).
  132104. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  132105. */
  132106. onPrePointerObservable: Observable<PointerInfoPre>;
  132107. /**
  132108. * Observable event triggered each time an input event is received from the rendering canvas
  132109. */
  132110. onPointerObservable: Observable<PointerInfo>;
  132111. /**
  132112. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  132113. */
  132114. get unTranslatedPointer(): Vector2;
  132115. /**
  132116. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  132117. */
  132118. static get DragMovementThreshold(): number;
  132119. static set DragMovementThreshold(value: number);
  132120. /**
  132121. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  132122. */
  132123. static get LongPressDelay(): number;
  132124. static set LongPressDelay(value: number);
  132125. /**
  132126. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  132127. */
  132128. static get DoubleClickDelay(): number;
  132129. static set DoubleClickDelay(value: number);
  132130. /** If you need to check double click without raising a single click at first click, enable this flag */
  132131. static get ExclusiveDoubleClickMode(): boolean;
  132132. static set ExclusiveDoubleClickMode(value: boolean);
  132133. /** @hidden */
  132134. _mirroredCameraPosition: Nullable<Vector3>;
  132135. /**
  132136. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  132137. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  132138. */
  132139. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  132140. /**
  132141. * Observable event triggered each time an keyboard event is received from the hosting window
  132142. */
  132143. onKeyboardObservable: Observable<KeyboardInfo>;
  132144. private _useRightHandedSystem;
  132145. /**
  132146. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  132147. */
  132148. set useRightHandedSystem(value: boolean);
  132149. get useRightHandedSystem(): boolean;
  132150. private _timeAccumulator;
  132151. private _currentStepId;
  132152. private _currentInternalStep;
  132153. /**
  132154. * Sets the step Id used by deterministic lock step
  132155. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132156. * @param newStepId defines the step Id
  132157. */
  132158. setStepId(newStepId: number): void;
  132159. /**
  132160. * Gets the step Id used by deterministic lock step
  132161. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132162. * @returns the step Id
  132163. */
  132164. getStepId(): number;
  132165. /**
  132166. * Gets the internal step used by deterministic lock step
  132167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132168. * @returns the internal step
  132169. */
  132170. getInternalStep(): number;
  132171. private _fogEnabled;
  132172. /**
  132173. * Gets or sets a boolean indicating if fog is enabled on this scene
  132174. * @see https://doc.babylonjs.com/babylon101/environment#fog
  132175. * (Default is true)
  132176. */
  132177. set fogEnabled(value: boolean);
  132178. get fogEnabled(): boolean;
  132179. private _fogMode;
  132180. /**
  132181. * Gets or sets the fog mode to use
  132182. * @see https://doc.babylonjs.com/babylon101/environment#fog
  132183. * | mode | value |
  132184. * | --- | --- |
  132185. * | FOGMODE_NONE | 0 |
  132186. * | FOGMODE_EXP | 1 |
  132187. * | FOGMODE_EXP2 | 2 |
  132188. * | FOGMODE_LINEAR | 3 |
  132189. */
  132190. set fogMode(value: number);
  132191. get fogMode(): number;
  132192. /**
  132193. * Gets or sets the fog color to use
  132194. * @see https://doc.babylonjs.com/babylon101/environment#fog
  132195. * (Default is Color3(0.2, 0.2, 0.3))
  132196. */
  132197. fogColor: Color3;
  132198. /**
  132199. * Gets or sets the fog density to use
  132200. * @see https://doc.babylonjs.com/babylon101/environment#fog
  132201. * (Default is 0.1)
  132202. */
  132203. fogDensity: number;
  132204. /**
  132205. * Gets or sets the fog start distance to use
  132206. * @see https://doc.babylonjs.com/babylon101/environment#fog
  132207. * (Default is 0)
  132208. */
  132209. fogStart: number;
  132210. /**
  132211. * Gets or sets the fog end distance to use
  132212. * @see https://doc.babylonjs.com/babylon101/environment#fog
  132213. * (Default is 1000)
  132214. */
  132215. fogEnd: number;
  132216. /**
  132217. * Flag indicating that the frame buffer binding is handled by another component
  132218. */
  132219. get prePass(): boolean;
  132220. private _shadowsEnabled;
  132221. /**
  132222. * Gets or sets a boolean indicating if shadows are enabled on this scene
  132223. */
  132224. set shadowsEnabled(value: boolean);
  132225. get shadowsEnabled(): boolean;
  132226. private _lightsEnabled;
  132227. /**
  132228. * Gets or sets a boolean indicating if lights are enabled on this scene
  132229. */
  132230. set lightsEnabled(value: boolean);
  132231. get lightsEnabled(): boolean;
  132232. /** All of the active cameras added to this scene. */
  132233. activeCameras: Nullable<Camera[]>;
  132234. /** @hidden */
  132235. _activeCamera: Nullable<Camera>;
  132236. /** Gets or sets the current active camera */
  132237. get activeCamera(): Nullable<Camera>;
  132238. set activeCamera(value: Nullable<Camera>);
  132239. private _defaultMaterial;
  132240. /** The default material used on meshes when no material is affected */
  132241. get defaultMaterial(): Material;
  132242. /** The default material used on meshes when no material is affected */
  132243. set defaultMaterial(value: Material);
  132244. private _texturesEnabled;
  132245. /**
  132246. * Gets or sets a boolean indicating if textures are enabled on this scene
  132247. */
  132248. set texturesEnabled(value: boolean);
  132249. get texturesEnabled(): boolean;
  132250. /**
  132251. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  132252. */
  132253. physicsEnabled: boolean;
  132254. /**
  132255. * Gets or sets a boolean indicating if particles are enabled on this scene
  132256. */
  132257. particlesEnabled: boolean;
  132258. /**
  132259. * Gets or sets a boolean indicating if sprites are enabled on this scene
  132260. */
  132261. spritesEnabled: boolean;
  132262. private _skeletonsEnabled;
  132263. /**
  132264. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  132265. */
  132266. set skeletonsEnabled(value: boolean);
  132267. get skeletonsEnabled(): boolean;
  132268. /**
  132269. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  132270. */
  132271. lensFlaresEnabled: boolean;
  132272. /**
  132273. * Gets or sets a boolean indicating if collisions are enabled on this scene
  132274. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  132275. */
  132276. collisionsEnabled: boolean;
  132277. private _collisionCoordinator;
  132278. /** @hidden */
  132279. get collisionCoordinator(): ICollisionCoordinator;
  132280. /**
  132281. * Defines the gravity applied to this scene (used only for collisions)
  132282. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  132283. */
  132284. gravity: Vector3;
  132285. /**
  132286. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  132287. */
  132288. postProcessesEnabled: boolean;
  132289. /**
  132290. * Gets the current postprocess manager
  132291. */
  132292. postProcessManager: PostProcessManager;
  132293. /**
  132294. * Gets or sets a boolean indicating if render targets are enabled on this scene
  132295. */
  132296. renderTargetsEnabled: boolean;
  132297. /**
  132298. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  132299. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  132300. */
  132301. dumpNextRenderTargets: boolean;
  132302. /**
  132303. * The list of user defined render targets added to the scene
  132304. */
  132305. customRenderTargets: RenderTargetTexture[];
  132306. /**
  132307. * Defines if texture loading must be delayed
  132308. * If true, textures will only be loaded when they need to be rendered
  132309. */
  132310. useDelayedTextureLoading: boolean;
  132311. /**
  132312. * Gets the list of meshes imported to the scene through SceneLoader
  132313. */
  132314. importedMeshesFiles: String[];
  132315. /**
  132316. * Gets or sets a boolean indicating if probes are enabled on this scene
  132317. */
  132318. probesEnabled: boolean;
  132319. /**
  132320. * Gets or sets the current offline provider to use to store scene data
  132321. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  132322. */
  132323. offlineProvider: IOfflineProvider;
  132324. /**
  132325. * Gets or sets the action manager associated with the scene
  132326. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  132327. */
  132328. actionManager: AbstractActionManager;
  132329. private _meshesForIntersections;
  132330. /**
  132331. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  132332. */
  132333. proceduralTexturesEnabled: boolean;
  132334. private _engine;
  132335. private _totalVertices;
  132336. /** @hidden */
  132337. _activeIndices: PerfCounter;
  132338. /** @hidden */
  132339. _activeParticles: PerfCounter;
  132340. /** @hidden */
  132341. _activeBones: PerfCounter;
  132342. private _animationRatio;
  132343. /** @hidden */
  132344. _animationTimeLast: number;
  132345. /** @hidden */
  132346. _animationTime: number;
  132347. /**
  132348. * Gets or sets a general scale for animation speed
  132349. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  132350. */
  132351. animationTimeScale: number;
  132352. /** @hidden */
  132353. _cachedMaterial: Nullable<Material>;
  132354. /** @hidden */
  132355. _cachedEffect: Nullable<Effect>;
  132356. /** @hidden */
  132357. _cachedVisibility: Nullable<number>;
  132358. private _renderId;
  132359. private _frameId;
  132360. private _executeWhenReadyTimeoutId;
  132361. private _intermediateRendering;
  132362. private _viewUpdateFlag;
  132363. private _projectionUpdateFlag;
  132364. /** @hidden */
  132365. _toBeDisposed: Nullable<IDisposable>[];
  132366. private _activeRequests;
  132367. /** @hidden */
  132368. _pendingData: any[];
  132369. private _isDisposed;
  132370. /**
  132371. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  132372. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  132373. */
  132374. dispatchAllSubMeshesOfActiveMeshes: boolean;
  132375. private _activeMeshes;
  132376. private _processedMaterials;
  132377. private _renderTargets;
  132378. /** @hidden */
  132379. _activeParticleSystems: SmartArray<IParticleSystem>;
  132380. private _activeSkeletons;
  132381. private _softwareSkinnedMeshes;
  132382. private _renderingManager;
  132383. /** @hidden */
  132384. _activeAnimatables: Animatable[];
  132385. private _transformMatrix;
  132386. private _sceneUbo;
  132387. /** @hidden */
  132388. _viewMatrix: Matrix;
  132389. /** @hidden */
  132390. _projectionMatrix: Matrix;
  132391. /** @hidden */
  132392. _forcedViewPosition: Nullable<Vector3>;
  132393. /** @hidden */
  132394. _frustumPlanes: Plane[];
  132395. /**
  132396. * Gets the list of frustum planes (built from the active camera)
  132397. */
  132398. get frustumPlanes(): Plane[];
  132399. /**
  132400. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  132401. * This is useful if there are more lights that the maximum simulteanous authorized
  132402. */
  132403. requireLightSorting: boolean;
  132404. /** @hidden */
  132405. readonly useMaterialMeshMap: boolean;
  132406. /** @hidden */
  132407. readonly useClonedMeshMap: boolean;
  132408. private _externalData;
  132409. private _uid;
  132410. /**
  132411. * @hidden
  132412. * Backing store of defined scene components.
  132413. */
  132414. _components: ISceneComponent[];
  132415. /**
  132416. * @hidden
  132417. * Backing store of defined scene components.
  132418. */
  132419. _serializableComponents: ISceneSerializableComponent[];
  132420. /**
  132421. * List of components to register on the next registration step.
  132422. */
  132423. private _transientComponents;
  132424. /**
  132425. * Registers the transient components if needed.
  132426. */
  132427. private _registerTransientComponents;
  132428. /**
  132429. * @hidden
  132430. * Add a component to the scene.
  132431. * Note that the ccomponent could be registered on th next frame if this is called after
  132432. * the register component stage.
  132433. * @param component Defines the component to add to the scene
  132434. */
  132435. _addComponent(component: ISceneComponent): void;
  132436. /**
  132437. * @hidden
  132438. * Gets a component from the scene.
  132439. * @param name defines the name of the component to retrieve
  132440. * @returns the component or null if not present
  132441. */
  132442. _getComponent(name: string): Nullable<ISceneComponent>;
  132443. /**
  132444. * @hidden
  132445. * Defines the actions happening before camera updates.
  132446. */
  132447. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  132448. /**
  132449. * @hidden
  132450. * Defines the actions happening before clear the canvas.
  132451. */
  132452. _beforeClearStage: Stage<SimpleStageAction>;
  132453. /**
  132454. * @hidden
  132455. * Defines the actions happening before clear the canvas.
  132456. */
  132457. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  132458. /**
  132459. * @hidden
  132460. * Defines the actions when collecting render targets for the frame.
  132461. */
  132462. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  132463. /**
  132464. * @hidden
  132465. * Defines the actions happening for one camera in the frame.
  132466. */
  132467. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  132468. /**
  132469. * @hidden
  132470. * Defines the actions happening during the per mesh ready checks.
  132471. */
  132472. _isReadyForMeshStage: Stage<MeshStageAction>;
  132473. /**
  132474. * @hidden
  132475. * Defines the actions happening before evaluate active mesh checks.
  132476. */
  132477. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  132478. /**
  132479. * @hidden
  132480. * Defines the actions happening during the evaluate sub mesh checks.
  132481. */
  132482. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  132483. /**
  132484. * @hidden
  132485. * Defines the actions happening during the active mesh stage.
  132486. */
  132487. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  132488. /**
  132489. * @hidden
  132490. * Defines the actions happening during the per camera render target step.
  132491. */
  132492. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  132493. /**
  132494. * @hidden
  132495. * Defines the actions happening just before the active camera is drawing.
  132496. */
  132497. _beforeCameraDrawStage: Stage<CameraStageAction>;
  132498. /**
  132499. * @hidden
  132500. * Defines the actions happening just before a render target is drawing.
  132501. */
  132502. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  132503. /**
  132504. * @hidden
  132505. * Defines the actions happening just before a rendering group is drawing.
  132506. */
  132507. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  132508. /**
  132509. * @hidden
  132510. * Defines the actions happening just before a mesh is drawing.
  132511. */
  132512. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  132513. /**
  132514. * @hidden
  132515. * Defines the actions happening just after a mesh has been drawn.
  132516. */
  132517. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  132518. /**
  132519. * @hidden
  132520. * Defines the actions happening just after a rendering group has been drawn.
  132521. */
  132522. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  132523. /**
  132524. * @hidden
  132525. * Defines the actions happening just after the active camera has been drawn.
  132526. */
  132527. _afterCameraDrawStage: Stage<CameraStageAction>;
  132528. /**
  132529. * @hidden
  132530. * Defines the actions happening just after a render target has been drawn.
  132531. */
  132532. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  132533. /**
  132534. * @hidden
  132535. * Defines the actions happening just after rendering all cameras and computing intersections.
  132536. */
  132537. _afterRenderStage: Stage<SimpleStageAction>;
  132538. /**
  132539. * @hidden
  132540. * Defines the actions happening when a pointer move event happens.
  132541. */
  132542. _pointerMoveStage: Stage<PointerMoveStageAction>;
  132543. /**
  132544. * @hidden
  132545. * Defines the actions happening when a pointer down event happens.
  132546. */
  132547. _pointerDownStage: Stage<PointerUpDownStageAction>;
  132548. /**
  132549. * @hidden
  132550. * Defines the actions happening when a pointer up event happens.
  132551. */
  132552. _pointerUpStage: Stage<PointerUpDownStageAction>;
  132553. /**
  132554. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  132555. */
  132556. private geometriesByUniqueId;
  132557. private _renderBundles;
  132558. /**
  132559. * Creates a new Scene
  132560. * @param engine defines the engine to use to render this scene
  132561. * @param options defines the scene options
  132562. */
  132563. constructor(engine: Engine, options?: SceneOptions);
  132564. /**
  132565. * Gets a string identifying the name of the class
  132566. * @returns "Scene" string
  132567. */
  132568. getClassName(): string;
  132569. private _defaultMeshCandidates;
  132570. /**
  132571. * @hidden
  132572. */
  132573. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  132574. private _defaultSubMeshCandidates;
  132575. /**
  132576. * @hidden
  132577. */
  132578. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  132579. /**
  132580. * Sets the default candidate providers for the scene.
  132581. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  132582. * and getCollidingSubMeshCandidates to their default function
  132583. */
  132584. setDefaultCandidateProviders(): void;
  132585. /**
  132586. * Gets the mesh that is currently under the pointer
  132587. */
  132588. get meshUnderPointer(): Nullable<AbstractMesh>;
  132589. /**
  132590. * Gets or sets the current on-screen X position of the pointer
  132591. */
  132592. get pointerX(): number;
  132593. set pointerX(value: number);
  132594. /**
  132595. * Gets or sets the current on-screen Y position of the pointer
  132596. */
  132597. get pointerY(): number;
  132598. set pointerY(value: number);
  132599. /**
  132600. * Gets the cached material (ie. the latest rendered one)
  132601. * @returns the cached material
  132602. */
  132603. getCachedMaterial(): Nullable<Material>;
  132604. /**
  132605. * Gets the cached effect (ie. the latest rendered one)
  132606. * @returns the cached effect
  132607. */
  132608. getCachedEffect(): Nullable<Effect>;
  132609. /**
  132610. * Gets the cached visibility state (ie. the latest rendered one)
  132611. * @returns the cached visibility state
  132612. */
  132613. getCachedVisibility(): Nullable<number>;
  132614. /**
  132615. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  132616. * @param material defines the current material
  132617. * @param effect defines the current effect
  132618. * @param visibility defines the current visibility state
  132619. * @returns true if one parameter is not cached
  132620. */
  132621. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  132622. /**
  132623. * Gets the engine associated with the scene
  132624. * @returns an Engine
  132625. */
  132626. getEngine(): Engine;
  132627. /**
  132628. * Gets the total number of vertices rendered per frame
  132629. * @returns the total number of vertices rendered per frame
  132630. */
  132631. getTotalVertices(): number;
  132632. /**
  132633. * Gets the performance counter for total vertices
  132634. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  132635. */
  132636. get totalVerticesPerfCounter(): PerfCounter;
  132637. /**
  132638. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  132639. * @returns the total number of active indices rendered per frame
  132640. */
  132641. getActiveIndices(): number;
  132642. /**
  132643. * Gets the performance counter for active indices
  132644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  132645. */
  132646. get totalActiveIndicesPerfCounter(): PerfCounter;
  132647. /**
  132648. * Gets the total number of active particles rendered per frame
  132649. * @returns the total number of active particles rendered per frame
  132650. */
  132651. getActiveParticles(): number;
  132652. /**
  132653. * Gets the performance counter for active particles
  132654. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  132655. */
  132656. get activeParticlesPerfCounter(): PerfCounter;
  132657. /**
  132658. * Gets the total number of active bones rendered per frame
  132659. * @returns the total number of active bones rendered per frame
  132660. */
  132661. getActiveBones(): number;
  132662. /**
  132663. * Gets the performance counter for active bones
  132664. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  132665. */
  132666. get activeBonesPerfCounter(): PerfCounter;
  132667. /**
  132668. * Gets the array of active meshes
  132669. * @returns an array of AbstractMesh
  132670. */
  132671. getActiveMeshes(): SmartArray<AbstractMesh>;
  132672. /**
  132673. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  132674. * @returns a number
  132675. */
  132676. getAnimationRatio(): number;
  132677. /**
  132678. * Gets an unique Id for the current render phase
  132679. * @returns a number
  132680. */
  132681. getRenderId(): number;
  132682. /**
  132683. * Gets an unique Id for the current frame
  132684. * @returns a number
  132685. */
  132686. getFrameId(): number;
  132687. /** Call this function if you want to manually increment the render Id*/
  132688. incrementRenderId(): void;
  132689. private _createUbo;
  132690. /**
  132691. * Use this method to simulate a pointer move on a mesh
  132692. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  132693. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  132694. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  132695. * @returns the current scene
  132696. */
  132697. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  132698. /**
  132699. * Use this method to simulate a pointer down on a mesh
  132700. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  132701. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  132702. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  132703. * @returns the current scene
  132704. */
  132705. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  132706. /**
  132707. * Use this method to simulate a pointer up on a mesh
  132708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  132709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  132710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  132711. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  132712. * @returns the current scene
  132713. */
  132714. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  132715. /**
  132716. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  132717. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  132718. * @returns true if the pointer was captured
  132719. */
  132720. isPointerCaptured(pointerId?: number): boolean;
  132721. /**
  132722. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  132723. * @param attachUp defines if you want to attach events to pointerup
  132724. * @param attachDown defines if you want to attach events to pointerdown
  132725. * @param attachMove defines if you want to attach events to pointermove
  132726. */
  132727. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  132728. /** Detaches all event handlers*/
  132729. detachControl(): void;
  132730. /**
  132731. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  132732. * Delay loaded resources are not taking in account
  132733. * @return true if all required resources are ready
  132734. */
  132735. isReady(): boolean;
  132736. /** Resets all cached information relative to material (including effect and visibility) */
  132737. resetCachedMaterial(): void;
  132738. /**
  132739. * Registers a function to be called before every frame render
  132740. * @param func defines the function to register
  132741. */
  132742. registerBeforeRender(func: () => void): void;
  132743. /**
  132744. * Unregisters a function called before every frame render
  132745. * @param func defines the function to unregister
  132746. */
  132747. unregisterBeforeRender(func: () => void): void;
  132748. /**
  132749. * Registers a function to be called after every frame render
  132750. * @param func defines the function to register
  132751. */
  132752. registerAfterRender(func: () => void): void;
  132753. /**
  132754. * Unregisters a function called after every frame render
  132755. * @param func defines the function to unregister
  132756. */
  132757. unregisterAfterRender(func: () => void): void;
  132758. private _executeOnceBeforeRender;
  132759. /**
  132760. * The provided function will run before render once and will be disposed afterwards.
  132761. * A timeout delay can be provided so that the function will be executed in N ms.
  132762. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  132763. * @param func The function to be executed.
  132764. * @param timeout optional delay in ms
  132765. */
  132766. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  132767. /** @hidden */
  132768. _addPendingData(data: any): void;
  132769. /** @hidden */
  132770. _removePendingData(data: any): void;
  132771. /**
  132772. * Returns the number of items waiting to be loaded
  132773. * @returns the number of items waiting to be loaded
  132774. */
  132775. getWaitingItemsCount(): number;
  132776. /**
  132777. * Returns a boolean indicating if the scene is still loading data
  132778. */
  132779. get isLoading(): boolean;
  132780. /**
  132781. * Registers a function to be executed when the scene is ready
  132782. * @param {Function} func - the function to be executed
  132783. */
  132784. executeWhenReady(func: () => void): void;
  132785. /**
  132786. * Returns a promise that resolves when the scene is ready
  132787. * @returns A promise that resolves when the scene is ready
  132788. */
  132789. whenReadyAsync(): Promise<void>;
  132790. /** @hidden */
  132791. _checkIsReady(): void;
  132792. /**
  132793. * Gets all animatable attached to the scene
  132794. */
  132795. get animatables(): Animatable[];
  132796. /**
  132797. * Resets the last animation time frame.
  132798. * Useful to override when animations start running when loading a scene for the first time.
  132799. */
  132800. resetLastAnimationTimeFrame(): void;
  132801. /**
  132802. * Gets the current view matrix
  132803. * @returns a Matrix
  132804. */
  132805. getViewMatrix(): Matrix;
  132806. /**
  132807. * Gets the current projection matrix
  132808. * @returns a Matrix
  132809. */
  132810. getProjectionMatrix(): Matrix;
  132811. /**
  132812. * Gets the current transform matrix
  132813. * @returns a Matrix made of View * Projection
  132814. */
  132815. getTransformMatrix(): Matrix;
  132816. /**
  132817. * Sets the current transform matrix
  132818. * @param viewL defines the View matrix to use
  132819. * @param projectionL defines the Projection matrix to use
  132820. * @param viewR defines the right View matrix to use (if provided)
  132821. * @param projectionR defines the right Projection matrix to use (if provided)
  132822. */
  132823. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  132824. /**
  132825. * Gets the uniform buffer used to store scene data
  132826. * @returns a UniformBuffer
  132827. */
  132828. getSceneUniformBuffer(): UniformBuffer;
  132829. /**
  132830. * Gets an unique (relatively to the current scene) Id
  132831. * @returns an unique number for the scene
  132832. */
  132833. getUniqueId(): number;
  132834. /**
  132835. * Add a mesh to the list of scene's meshes
  132836. * @param newMesh defines the mesh to add
  132837. * @param recursive if all child meshes should also be added to the scene
  132838. */
  132839. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  132840. /**
  132841. * Remove a mesh for the list of scene's meshes
  132842. * @param toRemove defines the mesh to remove
  132843. * @param recursive if all child meshes should also be removed from the scene
  132844. * @returns the index where the mesh was in the mesh list
  132845. */
  132846. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  132847. /**
  132848. * Add a transform node to the list of scene's transform nodes
  132849. * @param newTransformNode defines the transform node to add
  132850. */
  132851. addTransformNode(newTransformNode: TransformNode): void;
  132852. /**
  132853. * Remove a transform node for the list of scene's transform nodes
  132854. * @param toRemove defines the transform node to remove
  132855. * @returns the index where the transform node was in the transform node list
  132856. */
  132857. removeTransformNode(toRemove: TransformNode): number;
  132858. /**
  132859. * Remove a skeleton for the list of scene's skeletons
  132860. * @param toRemove defines the skeleton to remove
  132861. * @returns the index where the skeleton was in the skeleton list
  132862. */
  132863. removeSkeleton(toRemove: Skeleton): number;
  132864. /**
  132865. * Remove a morph target for the list of scene's morph targets
  132866. * @param toRemove defines the morph target to remove
  132867. * @returns the index where the morph target was in the morph target list
  132868. */
  132869. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  132870. /**
  132871. * Remove a light for the list of scene's lights
  132872. * @param toRemove defines the light to remove
  132873. * @returns the index where the light was in the light list
  132874. */
  132875. removeLight(toRemove: Light): number;
  132876. /**
  132877. * Remove a camera for the list of scene's cameras
  132878. * @param toRemove defines the camera to remove
  132879. * @returns the index where the camera was in the camera list
  132880. */
  132881. removeCamera(toRemove: Camera): number;
  132882. /**
  132883. * Remove a particle system for the list of scene's particle systems
  132884. * @param toRemove defines the particle system to remove
  132885. * @returns the index where the particle system was in the particle system list
  132886. */
  132887. removeParticleSystem(toRemove: IParticleSystem): number;
  132888. /**
  132889. * Remove a animation for the list of scene's animations
  132890. * @param toRemove defines the animation to remove
  132891. * @returns the index where the animation was in the animation list
  132892. */
  132893. removeAnimation(toRemove: Animation): number;
  132894. /**
  132895. * Will stop the animation of the given target
  132896. * @param target - the target
  132897. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  132898. * @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)
  132899. */
  132900. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  132901. /**
  132902. * Removes the given animation group from this scene.
  132903. * @param toRemove The animation group to remove
  132904. * @returns The index of the removed animation group
  132905. */
  132906. removeAnimationGroup(toRemove: AnimationGroup): number;
  132907. /**
  132908. * Removes the given multi-material from this scene.
  132909. * @param toRemove The multi-material to remove
  132910. * @returns The index of the removed multi-material
  132911. */
  132912. removeMultiMaterial(toRemove: MultiMaterial): number;
  132913. /**
  132914. * Removes the given material from this scene.
  132915. * @param toRemove The material to remove
  132916. * @returns The index of the removed material
  132917. */
  132918. removeMaterial(toRemove: Material): number;
  132919. /**
  132920. * Removes the given action manager from this scene.
  132921. * @param toRemove The action manager to remove
  132922. * @returns The index of the removed action manager
  132923. */
  132924. removeActionManager(toRemove: AbstractActionManager): number;
  132925. /**
  132926. * Removes the given texture from this scene.
  132927. * @param toRemove The texture to remove
  132928. * @returns The index of the removed texture
  132929. */
  132930. removeTexture(toRemove: BaseTexture): number;
  132931. /**
  132932. * Adds the given light to this scene
  132933. * @param newLight The light to add
  132934. */
  132935. addLight(newLight: Light): void;
  132936. /**
  132937. * Sorts the list list based on light priorities
  132938. */
  132939. sortLightsByPriority(): void;
  132940. /**
  132941. * Adds the given camera to this scene
  132942. * @param newCamera The camera to add
  132943. */
  132944. addCamera(newCamera: Camera): void;
  132945. /**
  132946. * Adds the given skeleton to this scene
  132947. * @param newSkeleton The skeleton to add
  132948. */
  132949. addSkeleton(newSkeleton: Skeleton): void;
  132950. /**
  132951. * Adds the given particle system to this scene
  132952. * @param newParticleSystem The particle system to add
  132953. */
  132954. addParticleSystem(newParticleSystem: IParticleSystem): void;
  132955. /**
  132956. * Adds the given animation to this scene
  132957. * @param newAnimation The animation to add
  132958. */
  132959. addAnimation(newAnimation: Animation): void;
  132960. /**
  132961. * Adds the given animation group to this scene.
  132962. * @param newAnimationGroup The animation group to add
  132963. */
  132964. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  132965. /**
  132966. * Adds the given multi-material to this scene
  132967. * @param newMultiMaterial The multi-material to add
  132968. */
  132969. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  132970. /**
  132971. * Adds the given material to this scene
  132972. * @param newMaterial The material to add
  132973. */
  132974. addMaterial(newMaterial: Material): void;
  132975. /**
  132976. * Adds the given morph target to this scene
  132977. * @param newMorphTargetManager The morph target to add
  132978. */
  132979. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  132980. /**
  132981. * Adds the given geometry to this scene
  132982. * @param newGeometry The geometry to add
  132983. */
  132984. addGeometry(newGeometry: Geometry): void;
  132985. /**
  132986. * Adds the given action manager to this scene
  132987. * @param newActionManager The action manager to add
  132988. */
  132989. addActionManager(newActionManager: AbstractActionManager): void;
  132990. /**
  132991. * Adds the given texture to this scene.
  132992. * @param newTexture The texture to add
  132993. */
  132994. addTexture(newTexture: BaseTexture): void;
  132995. /**
  132996. * Switch active camera
  132997. * @param newCamera defines the new active camera
  132998. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  132999. */
  133000. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  133001. /**
  133002. * sets the active camera of the scene using its ID
  133003. * @param id defines the camera's ID
  133004. * @return the new active camera or null if none found.
  133005. */
  133006. setActiveCameraByID(id: string): Nullable<Camera>;
  133007. /**
  133008. * sets the active camera of the scene using its name
  133009. * @param name defines the camera's name
  133010. * @returns the new active camera or null if none found.
  133011. */
  133012. setActiveCameraByName(name: string): Nullable<Camera>;
  133013. /**
  133014. * get an animation group using its name
  133015. * @param name defines the material's name
  133016. * @return the animation group or null if none found.
  133017. */
  133018. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  133019. /**
  133020. * Get a material using its unique id
  133021. * @param uniqueId defines the material's unique id
  133022. * @return the material or null if none found.
  133023. */
  133024. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  133025. /**
  133026. * get a material using its id
  133027. * @param id defines the material's ID
  133028. * @return the material or null if none found.
  133029. */
  133030. getMaterialByID(id: string): Nullable<Material>;
  133031. /**
  133032. * Gets a the last added material using a given id
  133033. * @param id defines the material's ID
  133034. * @return the last material with the given id or null if none found.
  133035. */
  133036. getLastMaterialByID(id: string): Nullable<Material>;
  133037. /**
  133038. * Gets a material using its name
  133039. * @param name defines the material's name
  133040. * @return the material or null if none found.
  133041. */
  133042. getMaterialByName(name: string): Nullable<Material>;
  133043. /**
  133044. * Get a texture using its unique id
  133045. * @param uniqueId defines the texture's unique id
  133046. * @return the texture or null if none found.
  133047. */
  133048. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  133049. /**
  133050. * Gets a camera using its id
  133051. * @param id defines the id to look for
  133052. * @returns the camera or null if not found
  133053. */
  133054. getCameraByID(id: string): Nullable<Camera>;
  133055. /**
  133056. * Gets a camera using its unique id
  133057. * @param uniqueId defines the unique id to look for
  133058. * @returns the camera or null if not found
  133059. */
  133060. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  133061. /**
  133062. * Gets a camera using its name
  133063. * @param name defines the camera's name
  133064. * @return the camera or null if none found.
  133065. */
  133066. getCameraByName(name: string): Nullable<Camera>;
  133067. /**
  133068. * Gets a bone using its id
  133069. * @param id defines the bone's id
  133070. * @return the bone or null if not found
  133071. */
  133072. getBoneByID(id: string): Nullable<Bone>;
  133073. /**
  133074. * Gets a bone using its id
  133075. * @param name defines the bone's name
  133076. * @return the bone or null if not found
  133077. */
  133078. getBoneByName(name: string): Nullable<Bone>;
  133079. /**
  133080. * Gets a light node using its name
  133081. * @param name defines the the light's name
  133082. * @return the light or null if none found.
  133083. */
  133084. getLightByName(name: string): Nullable<Light>;
  133085. /**
  133086. * Gets a light node using its id
  133087. * @param id defines the light's id
  133088. * @return the light or null if none found.
  133089. */
  133090. getLightByID(id: string): Nullable<Light>;
  133091. /**
  133092. * Gets a light node using its scene-generated unique ID
  133093. * @param uniqueId defines the light's unique id
  133094. * @return the light or null if none found.
  133095. */
  133096. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  133097. /**
  133098. * Gets a particle system by id
  133099. * @param id defines the particle system id
  133100. * @return the corresponding system or null if none found
  133101. */
  133102. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  133103. /**
  133104. * Gets a geometry using its ID
  133105. * @param id defines the geometry's id
  133106. * @return the geometry or null if none found.
  133107. */
  133108. getGeometryByID(id: string): Nullable<Geometry>;
  133109. private _getGeometryByUniqueID;
  133110. /**
  133111. * Add a new geometry to this scene
  133112. * @param geometry defines the geometry to be added to the scene.
  133113. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  133114. * @return a boolean defining if the geometry was added or not
  133115. */
  133116. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  133117. /**
  133118. * Removes an existing geometry
  133119. * @param geometry defines the geometry to be removed from the scene
  133120. * @return a boolean defining if the geometry was removed or not
  133121. */
  133122. removeGeometry(geometry: Geometry): boolean;
  133123. /**
  133124. * Gets the list of geometries attached to the scene
  133125. * @returns an array of Geometry
  133126. */
  133127. getGeometries(): Geometry[];
  133128. /**
  133129. * Gets the first added mesh found of a given ID
  133130. * @param id defines the id to search for
  133131. * @return the mesh found or null if not found at all
  133132. */
  133133. getMeshByID(id: string): Nullable<AbstractMesh>;
  133134. /**
  133135. * Gets a list of meshes using their id
  133136. * @param id defines the id to search for
  133137. * @returns a list of meshes
  133138. */
  133139. getMeshesByID(id: string): Array<AbstractMesh>;
  133140. /**
  133141. * Gets the first added transform node found of a given ID
  133142. * @param id defines the id to search for
  133143. * @return the found transform node or null if not found at all.
  133144. */
  133145. getTransformNodeByID(id: string): Nullable<TransformNode>;
  133146. /**
  133147. * Gets a transform node with its auto-generated unique id
  133148. * @param uniqueId efines the unique id to search for
  133149. * @return the found transform node or null if not found at all.
  133150. */
  133151. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  133152. /**
  133153. * Gets a list of transform nodes using their id
  133154. * @param id defines the id to search for
  133155. * @returns a list of transform nodes
  133156. */
  133157. getTransformNodesByID(id: string): Array<TransformNode>;
  133158. /**
  133159. * Gets a mesh with its auto-generated unique id
  133160. * @param uniqueId defines the unique id to search for
  133161. * @return the found mesh or null if not found at all.
  133162. */
  133163. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  133164. /**
  133165. * Gets a the last added mesh using a given id
  133166. * @param id defines the id to search for
  133167. * @return the found mesh or null if not found at all.
  133168. */
  133169. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  133170. /**
  133171. * Gets a the last added node (Mesh, Camera, Light) using a given id
  133172. * @param id defines the id to search for
  133173. * @return the found node or null if not found at all
  133174. */
  133175. getLastEntryByID(id: string): Nullable<Node>;
  133176. /**
  133177. * Gets a node (Mesh, Camera, Light) using a given id
  133178. * @param id defines the id to search for
  133179. * @return the found node or null if not found at all
  133180. */
  133181. getNodeByID(id: string): Nullable<Node>;
  133182. /**
  133183. * Gets a node (Mesh, Camera, Light) using a given name
  133184. * @param name defines the name to search for
  133185. * @return the found node or null if not found at all.
  133186. */
  133187. getNodeByName(name: string): Nullable<Node>;
  133188. /**
  133189. * Gets a mesh using a given name
  133190. * @param name defines the name to search for
  133191. * @return the found mesh or null if not found at all.
  133192. */
  133193. getMeshByName(name: string): Nullable<AbstractMesh>;
  133194. /**
  133195. * Gets a transform node using a given name
  133196. * @param name defines the name to search for
  133197. * @return the found transform node or null if not found at all.
  133198. */
  133199. getTransformNodeByName(name: string): Nullable<TransformNode>;
  133200. /**
  133201. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  133202. * @param id defines the id to search for
  133203. * @return the found skeleton or null if not found at all.
  133204. */
  133205. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  133206. /**
  133207. * Gets a skeleton using a given auto generated unique id
  133208. * @param uniqueId defines the unique id to search for
  133209. * @return the found skeleton or null if not found at all.
  133210. */
  133211. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  133212. /**
  133213. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  133214. * @param id defines the id to search for
  133215. * @return the found skeleton or null if not found at all.
  133216. */
  133217. getSkeletonById(id: string): Nullable<Skeleton>;
  133218. /**
  133219. * Gets a skeleton using a given name
  133220. * @param name defines the name to search for
  133221. * @return the found skeleton or null if not found at all.
  133222. */
  133223. getSkeletonByName(name: string): Nullable<Skeleton>;
  133224. /**
  133225. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  133226. * @param id defines the id to search for
  133227. * @return the found morph target manager or null if not found at all.
  133228. */
  133229. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  133230. /**
  133231. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  133232. * @param id defines the id to search for
  133233. * @return the found morph target or null if not found at all.
  133234. */
  133235. getMorphTargetById(id: string): Nullable<MorphTarget>;
  133236. /**
  133237. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  133238. * @param name defines the name to search for
  133239. * @return the found morph target or null if not found at all.
  133240. */
  133241. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  133242. /**
  133243. * Gets a post process using a given name (if many are found, this function will pick the first one)
  133244. * @param name defines the name to search for
  133245. * @return the found post process or null if not found at all.
  133246. */
  133247. getPostProcessByName(name: string): Nullable<PostProcess>;
  133248. /**
  133249. * Gets a boolean indicating if the given mesh is active
  133250. * @param mesh defines the mesh to look for
  133251. * @returns true if the mesh is in the active list
  133252. */
  133253. isActiveMesh(mesh: AbstractMesh): boolean;
  133254. /**
  133255. * Return a unique id as a string which can serve as an identifier for the scene
  133256. */
  133257. get uid(): string;
  133258. /**
  133259. * Add an externaly attached data from its key.
  133260. * This method call will fail and return false, if such key already exists.
  133261. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  133262. * @param key the unique key that identifies the data
  133263. * @param data the data object to associate to the key for this Engine instance
  133264. * @return true if no such key were already present and the data was added successfully, false otherwise
  133265. */
  133266. addExternalData<T>(key: string, data: T): boolean;
  133267. /**
  133268. * Get an externaly attached data from its key
  133269. * @param key the unique key that identifies the data
  133270. * @return the associated data, if present (can be null), or undefined if not present
  133271. */
  133272. getExternalData<T>(key: string): Nullable<T>;
  133273. /**
  133274. * Get an externaly attached data from its key, create it using a factory if it's not already present
  133275. * @param key the unique key that identifies the data
  133276. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  133277. * @return the associated data, can be null if the factory returned null.
  133278. */
  133279. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  133280. /**
  133281. * Remove an externaly attached data from the Engine instance
  133282. * @param key the unique key that identifies the data
  133283. * @return true if the data was successfully removed, false if it doesn't exist
  133284. */
  133285. removeExternalData(key: string): boolean;
  133286. private _evaluateSubMesh;
  133287. /**
  133288. * Clear the processed materials smart array preventing retention point in material dispose.
  133289. */
  133290. freeProcessedMaterials(): void;
  133291. private _preventFreeActiveMeshesAndRenderingGroups;
  133292. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  133293. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  133294. * when disposing several meshes in a row or a hierarchy of meshes.
  133295. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  133296. */
  133297. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  133298. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  133299. /**
  133300. * Clear the active meshes smart array preventing retention point in mesh dispose.
  133301. */
  133302. freeActiveMeshes(): void;
  133303. /**
  133304. * Clear the info related to rendering groups preventing retention points during dispose.
  133305. */
  133306. freeRenderingGroups(): void;
  133307. /** @hidden */
  133308. _isInIntermediateRendering(): boolean;
  133309. /**
  133310. * Lambda returning the list of potentially active meshes.
  133311. */
  133312. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  133313. /**
  133314. * Lambda returning the list of potentially active sub meshes.
  133315. */
  133316. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  133317. /**
  133318. * Lambda returning the list of potentially intersecting sub meshes.
  133319. */
  133320. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  133321. /**
  133322. * Lambda returning the list of potentially colliding sub meshes.
  133323. */
  133324. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  133325. /** @hidden */
  133326. _activeMeshesFrozen: boolean;
  133327. private _skipEvaluateActiveMeshesCompletely;
  133328. /**
  133329. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  133330. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  133331. * @param onSuccess optional success callback
  133332. * @param onError optional error callback
  133333. * @returns the current scene
  133334. */
  133335. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  133336. /**
  133337. * Use this function to restart evaluating active meshes on every frame
  133338. * @returns the current scene
  133339. */
  133340. unfreezeActiveMeshes(): Scene;
  133341. private _evaluateActiveMeshes;
  133342. private _activeMesh;
  133343. /**
  133344. * Update the transform matrix to update from the current active camera
  133345. * @param force defines a boolean used to force the update even if cache is up to date
  133346. */
  133347. updateTransformMatrix(force?: boolean): void;
  133348. private _bindFrameBuffer;
  133349. /** @hidden */
  133350. _allowPostProcessClearColor: boolean;
  133351. /** @hidden */
  133352. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  133353. private _processSubCameras;
  133354. private _checkIntersections;
  133355. /** @hidden */
  133356. _advancePhysicsEngineStep(step: number): void;
  133357. /**
  133358. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  133359. */
  133360. getDeterministicFrameTime: () => number;
  133361. /** @hidden */
  133362. _animate(): void;
  133363. /** Execute all animations (for a frame) */
  133364. animate(): void;
  133365. /**
  133366. * Render the scene
  133367. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  133368. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  133369. */
  133370. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  133371. /**
  133372. * Freeze all materials
  133373. * A frozen material will not be updatable but should be faster to render
  133374. */
  133375. freezeMaterials(): void;
  133376. /**
  133377. * Unfreeze all materials
  133378. * A frozen material will not be updatable but should be faster to render
  133379. */
  133380. unfreezeMaterials(): void;
  133381. /**
  133382. * Releases all held ressources
  133383. */
  133384. dispose(): void;
  133385. /**
  133386. * Gets if the scene is already disposed
  133387. */
  133388. get isDisposed(): boolean;
  133389. /**
  133390. * Call this function to reduce memory footprint of the scene.
  133391. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  133392. */
  133393. clearCachedVertexData(): void;
  133394. /**
  133395. * This function will remove the local cached buffer data from texture.
  133396. * It will save memory but will prevent the texture from being rebuilt
  133397. */
  133398. cleanCachedTextureBuffer(): void;
  133399. /**
  133400. * Get the world extend vectors with an optional filter
  133401. *
  133402. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  133403. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  133404. */
  133405. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  133406. min: Vector3;
  133407. max: Vector3;
  133408. };
  133409. /**
  133410. * Creates a ray that can be used to pick in the scene
  133411. * @param x defines the x coordinate of the origin (on-screen)
  133412. * @param y defines the y coordinate of the origin (on-screen)
  133413. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  133414. * @param camera defines the camera to use for the picking
  133415. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  133416. * @returns a Ray
  133417. */
  133418. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  133419. /**
  133420. * Creates a ray that can be used to pick in the scene
  133421. * @param x defines the x coordinate of the origin (on-screen)
  133422. * @param y defines the y coordinate of the origin (on-screen)
  133423. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  133424. * @param result defines the ray where to store the picking ray
  133425. * @param camera defines the camera to use for the picking
  133426. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  133427. * @returns the current scene
  133428. */
  133429. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  133430. /**
  133431. * Creates a ray that can be used to pick in the scene
  133432. * @param x defines the x coordinate of the origin (on-screen)
  133433. * @param y defines the y coordinate of the origin (on-screen)
  133434. * @param camera defines the camera to use for the picking
  133435. * @returns a Ray
  133436. */
  133437. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  133438. /**
  133439. * Creates a ray that can be used to pick in the scene
  133440. * @param x defines the x coordinate of the origin (on-screen)
  133441. * @param y defines the y coordinate of the origin (on-screen)
  133442. * @param result defines the ray where to store the picking ray
  133443. * @param camera defines the camera to use for the picking
  133444. * @returns the current scene
  133445. */
  133446. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  133447. /** Launch a ray to try to pick a mesh in the scene
  133448. * @param x position on screen
  133449. * @param y position on screen
  133450. * @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
  133451. * @param fastCheck defines if the first intersection will be used (and not the closest)
  133452. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  133453. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133454. * @returns a PickingInfo
  133455. */
  133456. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  133457. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  133458. * @param x position on screen
  133459. * @param y position on screen
  133460. * @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
  133461. * @param fastCheck defines if the first intersection will be used (and not the closest)
  133462. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  133463. * @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)
  133464. */
  133465. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  133466. /** Use the given ray to pick a mesh in the scene
  133467. * @param ray The ray to use to pick meshes
  133468. * @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
  133469. * @param fastCheck defines if the first intersection will be used (and not the closest)
  133470. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133471. * @returns a PickingInfo
  133472. */
  133473. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  133474. /**
  133475. * Launch a ray to try to pick a mesh in the scene
  133476. * @param x X position on screen
  133477. * @param y Y position on screen
  133478. * @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
  133479. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  133480. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133481. * @returns an array of PickingInfo
  133482. */
  133483. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  133484. /**
  133485. * Launch a ray to try to pick a mesh in the scene
  133486. * @param ray Ray to use
  133487. * @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
  133488. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  133489. * @returns an array of PickingInfo
  133490. */
  133491. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  133492. /**
  133493. * Force the value of meshUnderPointer
  133494. * @param mesh defines the mesh to use
  133495. * @param pointerId optional pointer id when using more than one pointer
  133496. */
  133497. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  133498. /**
  133499. * Gets the mesh under the pointer
  133500. * @returns a Mesh or null if no mesh is under the pointer
  133501. */
  133502. getPointerOverMesh(): Nullable<AbstractMesh>;
  133503. /** @hidden */
  133504. _rebuildGeometries(): void;
  133505. /** @hidden */
  133506. _rebuildTextures(): void;
  133507. private _getByTags;
  133508. /**
  133509. * Get a list of meshes by tags
  133510. * @param tagsQuery defines the tags query to use
  133511. * @param forEach defines a predicate used to filter results
  133512. * @returns an array of Mesh
  133513. */
  133514. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  133515. /**
  133516. * Get a list of cameras by tags
  133517. * @param tagsQuery defines the tags query to use
  133518. * @param forEach defines a predicate used to filter results
  133519. * @returns an array of Camera
  133520. */
  133521. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  133522. /**
  133523. * Get a list of lights by tags
  133524. * @param tagsQuery defines the tags query to use
  133525. * @param forEach defines a predicate used to filter results
  133526. * @returns an array of Light
  133527. */
  133528. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  133529. /**
  133530. * Get a list of materials by tags
  133531. * @param tagsQuery defines the tags query to use
  133532. * @param forEach defines a predicate used to filter results
  133533. * @returns an array of Material
  133534. */
  133535. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  133536. /**
  133537. * Get a list of transform nodes by tags
  133538. * @param tagsQuery defines the tags query to use
  133539. * @param forEach defines a predicate used to filter results
  133540. * @returns an array of TransformNode
  133541. */
  133542. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  133543. /**
  133544. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  133545. * This allowed control for front to back rendering or reversly depending of the special needs.
  133546. *
  133547. * @param renderingGroupId The rendering group id corresponding to its index
  133548. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  133549. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  133550. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  133551. */
  133552. 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;
  133553. /**
  133554. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  133555. *
  133556. * @param renderingGroupId The rendering group id corresponding to its index
  133557. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  133558. * @param depth Automatically clears depth between groups if true and autoClear is true.
  133559. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  133560. */
  133561. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  133562. /**
  133563. * Gets the current auto clear configuration for one rendering group of the rendering
  133564. * manager.
  133565. * @param index the rendering group index to get the information for
  133566. * @returns The auto clear setup for the requested rendering group
  133567. */
  133568. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  133569. private _blockMaterialDirtyMechanism;
  133570. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  133571. get blockMaterialDirtyMechanism(): boolean;
  133572. set blockMaterialDirtyMechanism(value: boolean);
  133573. /**
  133574. * Will flag all materials as dirty to trigger new shader compilation
  133575. * @param flag defines the flag used to specify which material part must be marked as dirty
  133576. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  133577. */
  133578. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  133579. /** @hidden */
  133580. _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;
  133581. /** @hidden */
  133582. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  133583. /** @hidden */
  133584. _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;
  133585. /** @hidden */
  133586. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  133587. /** @hidden */
  133588. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  133589. /** @hidden */
  133590. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  133591. }
  133592. }
  133593. declare module BABYLON {
  133594. /**
  133595. * Set of assets to keep when moving a scene into an asset container.
  133596. */
  133597. export class KeepAssets extends AbstractScene {
  133598. }
  133599. /**
  133600. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  133601. */
  133602. export class InstantiatedEntries {
  133603. /**
  133604. * List of new root nodes (eg. nodes with no parent)
  133605. */
  133606. rootNodes: TransformNode[];
  133607. /**
  133608. * List of new skeletons
  133609. */
  133610. skeletons: Skeleton[];
  133611. /**
  133612. * List of new animation groups
  133613. */
  133614. animationGroups: AnimationGroup[];
  133615. }
  133616. /**
  133617. * Container with a set of assets that can be added or removed from a scene.
  133618. */
  133619. export class AssetContainer extends AbstractScene {
  133620. private _wasAddedToScene;
  133621. /**
  133622. * The scene the AssetContainer belongs to.
  133623. */
  133624. scene: Scene;
  133625. /**
  133626. * Instantiates an AssetContainer.
  133627. * @param scene The scene the AssetContainer belongs to.
  133628. */
  133629. constructor(scene: Scene);
  133630. /**
  133631. * Instantiate or clone all meshes and add the new ones to the scene.
  133632. * Skeletons and animation groups will all be cloned
  133633. * @param nameFunction defines an optional function used to get new names for clones
  133634. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  133635. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  133636. */
  133637. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  133638. /**
  133639. * Adds all the assets from the container to the scene.
  133640. */
  133641. addAllToScene(): void;
  133642. /**
  133643. * Removes all the assets in the container from the scene
  133644. */
  133645. removeAllFromScene(): void;
  133646. /**
  133647. * Disposes all the assets in the container
  133648. */
  133649. dispose(): void;
  133650. private _moveAssets;
  133651. /**
  133652. * Removes all the assets contained in the scene and adds them to the container.
  133653. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  133654. */
  133655. moveAllFromScene(keepAssets?: KeepAssets): void;
  133656. /**
  133657. * 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.
  133658. * @returns the root mesh
  133659. */
  133660. createRootMesh(): Mesh;
  133661. /**
  133662. * Merge animations (direct and animation groups) from this asset container into a scene
  133663. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133664. * @param animatables set of animatables to retarget to a node from the scene
  133665. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  133666. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  133667. */
  133668. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  133669. }
  133670. }
  133671. declare module BABYLON {
  133672. /**
  133673. * Defines how the parser contract is defined.
  133674. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  133675. */
  133676. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  133677. /**
  133678. * Defines how the individual parser contract is defined.
  133679. * These parser can parse an individual asset
  133680. */
  133681. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  133682. /**
  133683. * Base class of the scene acting as a container for the different elements composing a scene.
  133684. * This class is dynamically extended by the different components of the scene increasing
  133685. * flexibility and reducing coupling
  133686. */
  133687. export abstract class AbstractScene {
  133688. /**
  133689. * Stores the list of available parsers in the application.
  133690. */
  133691. private static _BabylonFileParsers;
  133692. /**
  133693. * Stores the list of available individual parsers in the application.
  133694. */
  133695. private static _IndividualBabylonFileParsers;
  133696. /**
  133697. * Adds a parser in the list of available ones
  133698. * @param name Defines the name of the parser
  133699. * @param parser Defines the parser to add
  133700. */
  133701. static AddParser(name: string, parser: BabylonFileParser): void;
  133702. /**
  133703. * Gets a general parser from the list of avaialble ones
  133704. * @param name Defines the name of the parser
  133705. * @returns the requested parser or null
  133706. */
  133707. static GetParser(name: string): Nullable<BabylonFileParser>;
  133708. /**
  133709. * Adds n individual parser in the list of available ones
  133710. * @param name Defines the name of the parser
  133711. * @param parser Defines the parser to add
  133712. */
  133713. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  133714. /**
  133715. * Gets an individual parser from the list of avaialble ones
  133716. * @param name Defines the name of the parser
  133717. * @returns the requested parser or null
  133718. */
  133719. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  133720. /**
  133721. * Parser json data and populate both a scene and its associated container object
  133722. * @param jsonData Defines the data to parse
  133723. * @param scene Defines the scene to parse the data for
  133724. * @param container Defines the container attached to the parsing sequence
  133725. * @param rootUrl Defines the root url of the data
  133726. */
  133727. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  133728. /**
  133729. * Gets the list of root nodes (ie. nodes with no parent)
  133730. */
  133731. rootNodes: Node[];
  133732. /** All of the cameras added to this scene
  133733. * @see https://doc.babylonjs.com/babylon101/cameras
  133734. */
  133735. cameras: Camera[];
  133736. /**
  133737. * All of the lights added to this scene
  133738. * @see https://doc.babylonjs.com/babylon101/lights
  133739. */
  133740. lights: Light[];
  133741. /**
  133742. * All of the (abstract) meshes added to this scene
  133743. */
  133744. meshes: AbstractMesh[];
  133745. /**
  133746. * The list of skeletons added to the scene
  133747. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  133748. */
  133749. skeletons: Skeleton[];
  133750. /**
  133751. * All of the particle systems added to this scene
  133752. * @see https://doc.babylonjs.com/babylon101/particles
  133753. */
  133754. particleSystems: IParticleSystem[];
  133755. /**
  133756. * Gets a list of Animations associated with the scene
  133757. */
  133758. animations: Animation[];
  133759. /**
  133760. * All of the animation groups added to this scene
  133761. * @see https://doc.babylonjs.com/how_to/group
  133762. */
  133763. animationGroups: AnimationGroup[];
  133764. /**
  133765. * All of the multi-materials added to this scene
  133766. * @see https://doc.babylonjs.com/how_to/multi_materials
  133767. */
  133768. multiMaterials: MultiMaterial[];
  133769. /**
  133770. * All of the materials added to this scene
  133771. * In the context of a Scene, it is not supposed to be modified manually.
  133772. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  133773. * Note also that the order of the Material within the array is not significant and might change.
  133774. * @see https://doc.babylonjs.com/babylon101/materials
  133775. */
  133776. materials: Material[];
  133777. /**
  133778. * The list of morph target managers added to the scene
  133779. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  133780. */
  133781. morphTargetManagers: MorphTargetManager[];
  133782. /**
  133783. * The list of geometries used in the scene.
  133784. */
  133785. geometries: Geometry[];
  133786. /**
  133787. * All of the tranform nodes added to this scene
  133788. * In the context of a Scene, it is not supposed to be modified manually.
  133789. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  133790. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  133791. * @see https://doc.babylonjs.com/how_to/transformnode
  133792. */
  133793. transformNodes: TransformNode[];
  133794. /**
  133795. * ActionManagers available on the scene.
  133796. */
  133797. actionManagers: AbstractActionManager[];
  133798. /**
  133799. * Textures to keep.
  133800. */
  133801. textures: BaseTexture[];
  133802. /** @hidden */
  133803. protected _environmentTexture: Nullable<BaseTexture>;
  133804. /**
  133805. * Texture used in all pbr material as the reflection texture.
  133806. * As in the majority of the scene they are the same (exception for multi room and so on),
  133807. * this is easier to reference from here than from all the materials.
  133808. */
  133809. get environmentTexture(): Nullable<BaseTexture>;
  133810. set environmentTexture(value: Nullable<BaseTexture>);
  133811. /**
  133812. * The list of postprocesses added to the scene
  133813. */
  133814. postProcesses: PostProcess[];
  133815. /**
  133816. * @returns all meshes, lights, cameras, transformNodes and bones
  133817. */
  133818. getNodes(): Array<Node>;
  133819. }
  133820. }
  133821. declare module BABYLON {
  133822. /**
  133823. * Interface used to define options for Sound class
  133824. */
  133825. export interface ISoundOptions {
  133826. /**
  133827. * Does the sound autoplay once loaded.
  133828. */
  133829. autoplay?: boolean;
  133830. /**
  133831. * Does the sound loop after it finishes playing once.
  133832. */
  133833. loop?: boolean;
  133834. /**
  133835. * Sound's volume
  133836. */
  133837. volume?: number;
  133838. /**
  133839. * Is it a spatial sound?
  133840. */
  133841. spatialSound?: boolean;
  133842. /**
  133843. * Maximum distance to hear that sound
  133844. */
  133845. maxDistance?: number;
  133846. /**
  133847. * Uses user defined attenuation function
  133848. */
  133849. useCustomAttenuation?: boolean;
  133850. /**
  133851. * Define the roll off factor of spatial sounds.
  133852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133853. */
  133854. rolloffFactor?: number;
  133855. /**
  133856. * Define the reference distance the sound should be heard perfectly.
  133857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133858. */
  133859. refDistance?: number;
  133860. /**
  133861. * Define the distance attenuation model the sound will follow.
  133862. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133863. */
  133864. distanceModel?: string;
  133865. /**
  133866. * Defines the playback speed (1 by default)
  133867. */
  133868. playbackRate?: number;
  133869. /**
  133870. * Defines if the sound is from a streaming source
  133871. */
  133872. streaming?: boolean;
  133873. /**
  133874. * Defines an optional length (in seconds) inside the sound file
  133875. */
  133876. length?: number;
  133877. /**
  133878. * Defines an optional offset (in seconds) inside the sound file
  133879. */
  133880. offset?: number;
  133881. /**
  133882. * If true, URLs will not be required to state the audio file codec to use.
  133883. */
  133884. skipCodecCheck?: boolean;
  133885. }
  133886. }
  133887. declare module BABYLON {
  133888. /**
  133889. * Defines a sound that can be played in the application.
  133890. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  133891. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  133892. */
  133893. export class Sound {
  133894. /**
  133895. * The name of the sound in the scene.
  133896. */
  133897. name: string;
  133898. /**
  133899. * Does the sound autoplay once loaded.
  133900. */
  133901. autoplay: boolean;
  133902. private _loop;
  133903. /**
  133904. * Does the sound loop after it finishes playing once.
  133905. */
  133906. get loop(): boolean;
  133907. set loop(value: boolean);
  133908. /**
  133909. * Does the sound use a custom attenuation curve to simulate the falloff
  133910. * happening when the source gets further away from the camera.
  133911. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  133912. */
  133913. useCustomAttenuation: boolean;
  133914. /**
  133915. * The sound track id this sound belongs to.
  133916. */
  133917. soundTrackId: number;
  133918. /**
  133919. * Is this sound currently played.
  133920. */
  133921. isPlaying: boolean;
  133922. /**
  133923. * Is this sound currently paused.
  133924. */
  133925. isPaused: boolean;
  133926. /**
  133927. * Does this sound enables spatial sound.
  133928. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133929. */
  133930. spatialSound: boolean;
  133931. /**
  133932. * Define the reference distance the sound should be heard perfectly.
  133933. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133934. */
  133935. refDistance: number;
  133936. /**
  133937. * Define the roll off factor of spatial sounds.
  133938. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133939. */
  133940. rolloffFactor: number;
  133941. /**
  133942. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  133943. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133944. */
  133945. maxDistance: number;
  133946. /**
  133947. * Define the distance attenuation model the sound will follow.
  133948. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  133949. */
  133950. distanceModel: string;
  133951. /**
  133952. * @hidden
  133953. * Back Compat
  133954. **/
  133955. onended: () => any;
  133956. /**
  133957. * Gets or sets an object used to store user defined information for the sound.
  133958. */
  133959. metadata: any;
  133960. /**
  133961. * Observable event when the current playing sound finishes.
  133962. */
  133963. onEndedObservable: Observable<Sound>;
  133964. /**
  133965. * Gets the current time for the sound.
  133966. */
  133967. get currentTime(): number;
  133968. private _panningModel;
  133969. private _playbackRate;
  133970. private _streaming;
  133971. private _startTime;
  133972. private _startOffset;
  133973. private _position;
  133974. /** @hidden */
  133975. _positionInEmitterSpace: boolean;
  133976. private _localDirection;
  133977. private _volume;
  133978. private _isReadyToPlay;
  133979. private _isDirectional;
  133980. private _readyToPlayCallback;
  133981. private _audioBuffer;
  133982. private _soundSource;
  133983. private _streamingSource;
  133984. private _soundPanner;
  133985. private _soundGain;
  133986. private _inputAudioNode;
  133987. private _outputAudioNode;
  133988. private _coneInnerAngle;
  133989. private _coneOuterAngle;
  133990. private _coneOuterGain;
  133991. private _scene;
  133992. private _connectedTransformNode;
  133993. private _customAttenuationFunction;
  133994. private _registerFunc;
  133995. private _isOutputConnected;
  133996. private _htmlAudioElement;
  133997. private _urlType;
  133998. private _length?;
  133999. private _offset?;
  134000. /** @hidden */
  134001. static _SceneComponentInitialization: (scene: Scene) => void;
  134002. /**
  134003. * Create a sound and attach it to a scene
  134004. * @param name Name of your sound
  134005. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  134006. * @param scene defines the scene the sound belongs to
  134007. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  134008. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  134009. */
  134010. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  134011. /**
  134012. * Release the sound and its associated resources
  134013. */
  134014. dispose(): void;
  134015. /**
  134016. * Gets if the sounds is ready to be played or not.
  134017. * @returns true if ready, otherwise false
  134018. */
  134019. isReady(): boolean;
  134020. /**
  134021. * Get the current class name.
  134022. * @returns current class name
  134023. */
  134024. getClassName(): string;
  134025. private _soundLoaded;
  134026. /**
  134027. * Sets the data of the sound from an audiobuffer
  134028. * @param audioBuffer The audioBuffer containing the data
  134029. */
  134030. setAudioBuffer(audioBuffer: AudioBuffer): void;
  134031. /**
  134032. * Updates the current sounds options such as maxdistance, loop...
  134033. * @param options A JSON object containing values named as the object properties
  134034. */
  134035. updateOptions(options: ISoundOptions): void;
  134036. private _createSpatialParameters;
  134037. private _updateSpatialParameters;
  134038. /**
  134039. * Switch the panning model to HRTF:
  134040. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  134041. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  134042. */
  134043. switchPanningModelToHRTF(): void;
  134044. /**
  134045. * Switch the panning model to Equal Power:
  134046. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  134047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  134048. */
  134049. switchPanningModelToEqualPower(): void;
  134050. private _switchPanningModel;
  134051. /**
  134052. * Connect this sound to a sound track audio node like gain...
  134053. * @param soundTrackAudioNode the sound track audio node to connect to
  134054. */
  134055. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  134056. /**
  134057. * Transform this sound into a directional source
  134058. * @param coneInnerAngle Size of the inner cone in degree
  134059. * @param coneOuterAngle Size of the outer cone in degree
  134060. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  134061. */
  134062. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  134063. /**
  134064. * Gets or sets the inner angle for the directional cone.
  134065. */
  134066. get directionalConeInnerAngle(): number;
  134067. /**
  134068. * Gets or sets the inner angle for the directional cone.
  134069. */
  134070. set directionalConeInnerAngle(value: number);
  134071. /**
  134072. * Gets or sets the outer angle for the directional cone.
  134073. */
  134074. get directionalConeOuterAngle(): number;
  134075. /**
  134076. * Gets or sets the outer angle for the directional cone.
  134077. */
  134078. set directionalConeOuterAngle(value: number);
  134079. /**
  134080. * Sets the position of the emitter if spatial sound is enabled
  134081. * @param newPosition Defines the new position
  134082. */
  134083. setPosition(newPosition: Vector3): void;
  134084. /**
  134085. * Sets the local direction of the emitter if spatial sound is enabled
  134086. * @param newLocalDirection Defines the new local direction
  134087. */
  134088. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  134089. private _updateDirection;
  134090. /** @hidden */
  134091. updateDistanceFromListener(): void;
  134092. /**
  134093. * Sets a new custom attenuation function for the sound.
  134094. * @param callback Defines the function used for the attenuation
  134095. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  134096. */
  134097. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  134098. /**
  134099. * Play the sound
  134100. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  134101. * @param offset (optional) Start the sound at a specific time in seconds
  134102. * @param length (optional) Sound duration (in seconds)
  134103. */
  134104. play(time?: number, offset?: number, length?: number): void;
  134105. private _onended;
  134106. /**
  134107. * Stop the sound
  134108. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  134109. */
  134110. stop(time?: number): void;
  134111. /**
  134112. * Put the sound in pause
  134113. */
  134114. pause(): void;
  134115. /**
  134116. * Sets a dedicated volume for this sounds
  134117. * @param newVolume Define the new volume of the sound
  134118. * @param time Define time for gradual change to new volume
  134119. */
  134120. setVolume(newVolume: number, time?: number): void;
  134121. /**
  134122. * Set the sound play back rate
  134123. * @param newPlaybackRate Define the playback rate the sound should be played at
  134124. */
  134125. setPlaybackRate(newPlaybackRate: number): void;
  134126. /**
  134127. * Gets the volume of the sound.
  134128. * @returns the volume of the sound
  134129. */
  134130. getVolume(): number;
  134131. /**
  134132. * Attach the sound to a dedicated mesh
  134133. * @param transformNode The transform node to connect the sound with
  134134. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  134135. */
  134136. attachToMesh(transformNode: TransformNode): void;
  134137. /**
  134138. * Detach the sound from the previously attached mesh
  134139. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  134140. */
  134141. detachFromMesh(): void;
  134142. private _onRegisterAfterWorldMatrixUpdate;
  134143. /**
  134144. * Clone the current sound in the scene.
  134145. * @returns the new sound clone
  134146. */
  134147. clone(): Nullable<Sound>;
  134148. /**
  134149. * Gets the current underlying audio buffer containing the data
  134150. * @returns the audio buffer
  134151. */
  134152. getAudioBuffer(): Nullable<AudioBuffer>;
  134153. /**
  134154. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  134155. * @returns the source node
  134156. */
  134157. getSoundSource(): Nullable<AudioBufferSourceNode>;
  134158. /**
  134159. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  134160. * @returns the gain node
  134161. */
  134162. getSoundGain(): Nullable<GainNode>;
  134163. /**
  134164. * Serializes the Sound in a JSON representation
  134165. * @returns the JSON representation of the sound
  134166. */
  134167. serialize(): any;
  134168. /**
  134169. * Parse a JSON representation of a sound to instantiate in a given scene
  134170. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  134171. * @param scene Define the scene the new parsed sound should be created in
  134172. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  134173. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  134174. * @returns the newly parsed sound
  134175. */
  134176. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  134177. }
  134178. }
  134179. declare module BABYLON {
  134180. /**
  134181. * This defines an action helpful to play a defined sound on a triggered action.
  134182. */
  134183. export class PlaySoundAction extends Action {
  134184. private _sound;
  134185. /**
  134186. * Instantiate the action
  134187. * @param triggerOptions defines the trigger options
  134188. * @param sound defines the sound to play
  134189. * @param condition defines the trigger related conditions
  134190. */
  134191. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  134192. /** @hidden */
  134193. _prepare(): void;
  134194. /**
  134195. * Execute the action and play the sound.
  134196. */
  134197. execute(): void;
  134198. /**
  134199. * Serializes the actions and its related information.
  134200. * @param parent defines the object to serialize in
  134201. * @returns the serialized object
  134202. */
  134203. serialize(parent: any): any;
  134204. }
  134205. /**
  134206. * This defines an action helpful to stop a defined sound on a triggered action.
  134207. */
  134208. export class StopSoundAction extends Action {
  134209. private _sound;
  134210. /**
  134211. * Instantiate the action
  134212. * @param triggerOptions defines the trigger options
  134213. * @param sound defines the sound to stop
  134214. * @param condition defines the trigger related conditions
  134215. */
  134216. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  134217. /** @hidden */
  134218. _prepare(): void;
  134219. /**
  134220. * Execute the action and stop the sound.
  134221. */
  134222. execute(): void;
  134223. /**
  134224. * Serializes the actions and its related information.
  134225. * @param parent defines the object to serialize in
  134226. * @returns the serialized object
  134227. */
  134228. serialize(parent: any): any;
  134229. }
  134230. }
  134231. declare module BABYLON {
  134232. /**
  134233. * This defines an action responsible to change the value of a property
  134234. * by interpolating between its current value and the newly set one once triggered.
  134235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  134236. */
  134237. export class InterpolateValueAction extends Action {
  134238. /**
  134239. * Defines the path of the property where the value should be interpolated
  134240. */
  134241. propertyPath: string;
  134242. /**
  134243. * Defines the target value at the end of the interpolation.
  134244. */
  134245. value: any;
  134246. /**
  134247. * Defines the time it will take for the property to interpolate to the value.
  134248. */
  134249. duration: number;
  134250. /**
  134251. * Defines if the other scene animations should be stopped when the action has been triggered
  134252. */
  134253. stopOtherAnimations?: boolean;
  134254. /**
  134255. * Defines a callback raised once the interpolation animation has been done.
  134256. */
  134257. onInterpolationDone?: () => void;
  134258. /**
  134259. * Observable triggered once the interpolation animation has been done.
  134260. */
  134261. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  134262. private _target;
  134263. private _effectiveTarget;
  134264. private _property;
  134265. /**
  134266. * Instantiate the action
  134267. * @param triggerOptions defines the trigger options
  134268. * @param target defines the object containing the value to interpolate
  134269. * @param propertyPath defines the path to the property in the target object
  134270. * @param value defines the target value at the end of the interpolation
  134271. * @param duration defines the time it will take for the property to interpolate to the value.
  134272. * @param condition defines the trigger related conditions
  134273. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  134274. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  134275. */
  134276. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  134277. /** @hidden */
  134278. _prepare(): void;
  134279. /**
  134280. * Execute the action starts the value interpolation.
  134281. */
  134282. execute(): void;
  134283. /**
  134284. * Serializes the actions and its related information.
  134285. * @param parent defines the object to serialize in
  134286. * @returns the serialized object
  134287. */
  134288. serialize(parent: any): any;
  134289. }
  134290. }
  134291. declare module BABYLON {
  134292. /**
  134293. * A cursor which tracks a point on a path
  134294. */
  134295. export class PathCursor {
  134296. private path;
  134297. /**
  134298. * Stores path cursor callbacks for when an onchange event is triggered
  134299. */
  134300. private _onchange;
  134301. /**
  134302. * The value of the path cursor
  134303. */
  134304. value: number;
  134305. /**
  134306. * The animation array of the path cursor
  134307. */
  134308. animations: Animation[];
  134309. /**
  134310. * Initializes the path cursor
  134311. * @param path The path to track
  134312. */
  134313. constructor(path: Path2);
  134314. /**
  134315. * Gets the cursor point on the path
  134316. * @returns A point on the path cursor at the cursor location
  134317. */
  134318. getPoint(): Vector3;
  134319. /**
  134320. * Moves the cursor ahead by the step amount
  134321. * @param step The amount to move the cursor forward
  134322. * @returns This path cursor
  134323. */
  134324. moveAhead(step?: number): PathCursor;
  134325. /**
  134326. * Moves the cursor behind by the step amount
  134327. * @param step The amount to move the cursor back
  134328. * @returns This path cursor
  134329. */
  134330. moveBack(step?: number): PathCursor;
  134331. /**
  134332. * Moves the cursor by the step amount
  134333. * If the step amount is greater than one, an exception is thrown
  134334. * @param step The amount to move the cursor
  134335. * @returns This path cursor
  134336. */
  134337. move(step: number): PathCursor;
  134338. /**
  134339. * Ensures that the value is limited between zero and one
  134340. * @returns This path cursor
  134341. */
  134342. private ensureLimits;
  134343. /**
  134344. * Runs onchange callbacks on change (used by the animation engine)
  134345. * @returns This path cursor
  134346. */
  134347. private raiseOnChange;
  134348. /**
  134349. * Executes a function on change
  134350. * @param f A path cursor onchange callback
  134351. * @returns This path cursor
  134352. */
  134353. onchange(f: (cursor: PathCursor) => void): PathCursor;
  134354. }
  134355. }
  134356. declare module BABYLON {
  134357. /**
  134358. * This represents the default audio engine used in babylon.
  134359. * It is responsible to play, synchronize and analyse sounds throughout the application.
  134360. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  134361. */
  134362. export class AudioEngine implements IAudioEngine {
  134363. private _audioContext;
  134364. private _audioContextInitialized;
  134365. private _muteButton;
  134366. private _hostElement;
  134367. /**
  134368. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  134369. */
  134370. canUseWebAudio: boolean;
  134371. /**
  134372. * The master gain node defines the global audio volume of your audio engine.
  134373. */
  134374. masterGain: GainNode;
  134375. /**
  134376. * Defines if Babylon should emit a warning if WebAudio is not supported.
  134377. * @ignoreNaming
  134378. */
  134379. WarnedWebAudioUnsupported: boolean;
  134380. /**
  134381. * Gets whether or not mp3 are supported by your browser.
  134382. */
  134383. isMP3supported: boolean;
  134384. /**
  134385. * Gets whether or not ogg are supported by your browser.
  134386. */
  134387. isOGGsupported: boolean;
  134388. /**
  134389. * Gets whether audio has been unlocked on the device.
  134390. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  134391. * a user interaction has happened.
  134392. */
  134393. unlocked: boolean;
  134394. /**
  134395. * Defines if the audio engine relies on a custom unlocked button.
  134396. * In this case, the embedded button will not be displayed.
  134397. */
  134398. useCustomUnlockedButton: boolean;
  134399. /**
  134400. * Event raised when audio has been unlocked on the browser.
  134401. */
  134402. onAudioUnlockedObservable: Observable<IAudioEngine>;
  134403. /**
  134404. * Event raised when audio has been locked on the browser.
  134405. */
  134406. onAudioLockedObservable: Observable<IAudioEngine>;
  134407. /**
  134408. * Gets the current AudioContext if available.
  134409. */
  134410. get audioContext(): Nullable<AudioContext>;
  134411. private _connectedAnalyser;
  134412. /**
  134413. * Instantiates a new audio engine.
  134414. *
  134415. * There should be only one per page as some browsers restrict the number
  134416. * of audio contexts you can create.
  134417. * @param hostElement defines the host element where to display the mute icon if necessary
  134418. */
  134419. constructor(hostElement?: Nullable<HTMLElement>);
  134420. /**
  134421. * Flags the audio engine in Locked state.
  134422. * This happens due to new browser policies preventing audio to autoplay.
  134423. */
  134424. lock(): void;
  134425. /**
  134426. * Unlocks the audio engine once a user action has been done on the dom.
  134427. * This is helpful to resume play once browser policies have been satisfied.
  134428. */
  134429. unlock(): void;
  134430. private _resumeAudioContext;
  134431. private _initializeAudioContext;
  134432. private _tryToRun;
  134433. private _triggerRunningState;
  134434. private _triggerSuspendedState;
  134435. private _displayMuteButton;
  134436. private _moveButtonToTopLeft;
  134437. private _onResize;
  134438. private _hideMuteButton;
  134439. /**
  134440. * Destroy and release the resources associated with the audio context.
  134441. */
  134442. dispose(): void;
  134443. /**
  134444. * Gets the global volume sets on the master gain.
  134445. * @returns the global volume if set or -1 otherwise
  134446. */
  134447. getGlobalVolume(): number;
  134448. /**
  134449. * Sets the global volume of your experience (sets on the master gain).
  134450. * @param newVolume Defines the new global volume of the application
  134451. */
  134452. setGlobalVolume(newVolume: number): void;
  134453. /**
  134454. * Connect the audio engine to an audio analyser allowing some amazing
  134455. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  134456. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  134457. * @param analyser The analyser to connect to the engine
  134458. */
  134459. connectToAnalyser(analyser: Analyser): void;
  134460. }
  134461. }
  134462. declare module BABYLON {
  134463. /**
  134464. * Options allowed during the creation of a sound track.
  134465. */
  134466. export interface ISoundTrackOptions {
  134467. /**
  134468. * The volume the sound track should take during creation
  134469. */
  134470. volume?: number;
  134471. /**
  134472. * Define if the sound track is the main sound track of the scene
  134473. */
  134474. mainTrack?: boolean;
  134475. }
  134476. /**
  134477. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  134478. * It will be also used in a future release to apply effects on a specific track.
  134479. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  134480. */
  134481. export class SoundTrack {
  134482. /**
  134483. * The unique identifier of the sound track in the scene.
  134484. */
  134485. id: number;
  134486. /**
  134487. * The list of sounds included in the sound track.
  134488. */
  134489. soundCollection: Array<Sound>;
  134490. private _outputAudioNode;
  134491. private _scene;
  134492. private _connectedAnalyser;
  134493. private _options;
  134494. private _isInitialized;
  134495. /**
  134496. * Creates a new sound track.
  134497. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  134498. * @param scene Define the scene the sound track belongs to
  134499. * @param options
  134500. */
  134501. constructor(scene: Scene, options?: ISoundTrackOptions);
  134502. private _initializeSoundTrackAudioGraph;
  134503. /**
  134504. * Release the sound track and its associated resources
  134505. */
  134506. dispose(): void;
  134507. /**
  134508. * Adds a sound to this sound track
  134509. * @param sound define the sound to add
  134510. * @ignoreNaming
  134511. */
  134512. addSound(sound: Sound): void;
  134513. /**
  134514. * Removes a sound to this sound track
  134515. * @param sound define the sound to remove
  134516. * @ignoreNaming
  134517. */
  134518. removeSound(sound: Sound): void;
  134519. /**
  134520. * Set a global volume for the full sound track.
  134521. * @param newVolume Define the new volume of the sound track
  134522. */
  134523. setVolume(newVolume: number): void;
  134524. /**
  134525. * Switch the panning model to HRTF:
  134526. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  134527. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  134528. */
  134529. switchPanningModelToHRTF(): void;
  134530. /**
  134531. * Switch the panning model to Equal Power:
  134532. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  134533. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  134534. */
  134535. switchPanningModelToEqualPower(): void;
  134536. /**
  134537. * Connect the sound track to an audio analyser allowing some amazing
  134538. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  134539. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  134540. * @param analyser The analyser to connect to the engine
  134541. */
  134542. connectToAnalyser(analyser: Analyser): void;
  134543. }
  134544. }
  134545. declare module BABYLON {
  134546. interface AbstractScene {
  134547. /**
  134548. * The list of sounds used in the scene.
  134549. */
  134550. sounds: Nullable<Array<Sound>>;
  134551. }
  134552. interface Scene {
  134553. /**
  134554. * @hidden
  134555. * Backing field
  134556. */
  134557. _mainSoundTrack: SoundTrack;
  134558. /**
  134559. * The main sound track played by the scene.
  134560. * It contains your primary collection of sounds.
  134561. */
  134562. mainSoundTrack: SoundTrack;
  134563. /**
  134564. * The list of sound tracks added to the scene
  134565. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  134566. */
  134567. soundTracks: Nullable<Array<SoundTrack>>;
  134568. /**
  134569. * Gets a sound using a given name
  134570. * @param name defines the name to search for
  134571. * @return the found sound or null if not found at all.
  134572. */
  134573. getSoundByName(name: string): Nullable<Sound>;
  134574. /**
  134575. * Gets or sets if audio support is enabled
  134576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  134577. */
  134578. audioEnabled: boolean;
  134579. /**
  134580. * Gets or sets if audio will be output to headphones
  134581. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  134582. */
  134583. headphone: boolean;
  134584. /**
  134585. * Gets or sets custom audio listener position provider
  134586. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  134587. */
  134588. audioListenerPositionProvider: Nullable<() => Vector3>;
  134589. /**
  134590. * Gets or sets a refresh rate when using 3D audio positioning
  134591. */
  134592. audioPositioningRefreshRate: number;
  134593. }
  134594. /**
  134595. * Defines the sound scene component responsible to manage any sounds
  134596. * in a given scene.
  134597. */
  134598. export class AudioSceneComponent implements ISceneSerializableComponent {
  134599. private static _CameraDirectionLH;
  134600. private static _CameraDirectionRH;
  134601. /**
  134602. * The component name helpful to identify the component in the list of scene components.
  134603. */
  134604. readonly name: string;
  134605. /**
  134606. * The scene the component belongs to.
  134607. */
  134608. scene: Scene;
  134609. private _audioEnabled;
  134610. /**
  134611. * Gets whether audio is enabled or not.
  134612. * Please use related enable/disable method to switch state.
  134613. */
  134614. get audioEnabled(): boolean;
  134615. private _headphone;
  134616. /**
  134617. * Gets whether audio is outputting to headphone or not.
  134618. * Please use the according Switch methods to change output.
  134619. */
  134620. get headphone(): boolean;
  134621. /**
  134622. * Gets or sets a refresh rate when using 3D audio positioning
  134623. */
  134624. audioPositioningRefreshRate: number;
  134625. private _audioListenerPositionProvider;
  134626. /**
  134627. * Gets the current audio listener position provider
  134628. */
  134629. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  134630. /**
  134631. * Sets a custom listener position for all sounds in the scene
  134632. * By default, this is the position of the first active camera
  134633. */
  134634. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  134635. /**
  134636. * Creates a new instance of the component for the given scene
  134637. * @param scene Defines the scene to register the component in
  134638. */
  134639. constructor(scene: Scene);
  134640. /**
  134641. * Registers the component in a given scene
  134642. */
  134643. register(): void;
  134644. /**
  134645. * Rebuilds the elements related to this component in case of
  134646. * context lost for instance.
  134647. */
  134648. rebuild(): void;
  134649. /**
  134650. * Serializes the component data to the specified json object
  134651. * @param serializationObject The object to serialize to
  134652. */
  134653. serialize(serializationObject: any): void;
  134654. /**
  134655. * Adds all the elements from the container to the scene
  134656. * @param container the container holding the elements
  134657. */
  134658. addFromContainer(container: AbstractScene): void;
  134659. /**
  134660. * Removes all the elements in the container from the scene
  134661. * @param container contains the elements to remove
  134662. * @param dispose if the removed element should be disposed (default: false)
  134663. */
  134664. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134665. /**
  134666. * Disposes the component and the associated resources.
  134667. */
  134668. dispose(): void;
  134669. /**
  134670. * Disables audio in the associated scene.
  134671. */
  134672. disableAudio(): void;
  134673. /**
  134674. * Enables audio in the associated scene.
  134675. */
  134676. enableAudio(): void;
  134677. /**
  134678. * Switch audio to headphone output.
  134679. */
  134680. switchAudioModeForHeadphones(): void;
  134681. /**
  134682. * Switch audio to normal speakers.
  134683. */
  134684. switchAudioModeForNormalSpeakers(): void;
  134685. private _cachedCameraDirection;
  134686. private _cachedCameraPosition;
  134687. private _lastCheck;
  134688. private _afterRender;
  134689. }
  134690. }
  134691. declare module BABYLON {
  134692. /**
  134693. * Wraps one or more Sound objects and selects one with random weight for playback.
  134694. */
  134695. export class WeightedSound {
  134696. /** When true a Sound will be selected and played when the current playing Sound completes. */
  134697. loop: boolean;
  134698. private _coneInnerAngle;
  134699. private _coneOuterAngle;
  134700. private _volume;
  134701. /** A Sound is currently playing. */
  134702. isPlaying: boolean;
  134703. /** A Sound is currently paused. */
  134704. isPaused: boolean;
  134705. private _sounds;
  134706. private _weights;
  134707. private _currentIndex?;
  134708. /**
  134709. * Creates a new WeightedSound from the list of sounds given.
  134710. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  134711. * @param sounds Array of Sounds that will be selected from.
  134712. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  134713. */
  134714. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  134715. /**
  134716. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  134717. */
  134718. get directionalConeInnerAngle(): number;
  134719. /**
  134720. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  134721. */
  134722. set directionalConeInnerAngle(value: number);
  134723. /**
  134724. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  134725. * Listener angles between innerAngle and outerAngle will falloff linearly.
  134726. */
  134727. get directionalConeOuterAngle(): number;
  134728. /**
  134729. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  134730. * Listener angles between innerAngle and outerAngle will falloff linearly.
  134731. */
  134732. set directionalConeOuterAngle(value: number);
  134733. /**
  134734. * Playback volume.
  134735. */
  134736. get volume(): number;
  134737. /**
  134738. * Playback volume.
  134739. */
  134740. set volume(value: number);
  134741. private _onended;
  134742. /**
  134743. * Suspend playback
  134744. */
  134745. pause(): void;
  134746. /**
  134747. * Stop playback
  134748. */
  134749. stop(): void;
  134750. /**
  134751. * Start playback.
  134752. * @param startOffset Position the clip head at a specific time in seconds.
  134753. */
  134754. play(startOffset?: number): void;
  134755. }
  134756. }
  134757. declare module BABYLON {
  134758. /**
  134759. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  134760. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  134761. */
  134762. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  134763. /**
  134764. * Gets the name of the behavior.
  134765. */
  134766. get name(): string;
  134767. /**
  134768. * The easing function used by animations
  134769. */
  134770. static EasingFunction: BackEase;
  134771. /**
  134772. * The easing mode used by animations
  134773. */
  134774. static EasingMode: number;
  134775. /**
  134776. * The duration of the animation, in milliseconds
  134777. */
  134778. transitionDuration: number;
  134779. /**
  134780. * Length of the distance animated by the transition when lower radius is reached
  134781. */
  134782. lowerRadiusTransitionRange: number;
  134783. /**
  134784. * Length of the distance animated by the transition when upper radius is reached
  134785. */
  134786. upperRadiusTransitionRange: number;
  134787. private _autoTransitionRange;
  134788. /**
  134789. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  134790. */
  134791. get autoTransitionRange(): boolean;
  134792. /**
  134793. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  134794. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  134795. */
  134796. set autoTransitionRange(value: boolean);
  134797. private _attachedCamera;
  134798. private _onAfterCheckInputsObserver;
  134799. private _onMeshTargetChangedObserver;
  134800. /**
  134801. * Initializes the behavior.
  134802. */
  134803. init(): void;
  134804. /**
  134805. * Attaches the behavior to its arc rotate camera.
  134806. * @param camera Defines the camera to attach the behavior to
  134807. */
  134808. attach(camera: ArcRotateCamera): void;
  134809. /**
  134810. * Detaches the behavior from its current arc rotate camera.
  134811. */
  134812. detach(): void;
  134813. private _radiusIsAnimating;
  134814. private _radiusBounceTransition;
  134815. private _animatables;
  134816. private _cachedWheelPrecision;
  134817. /**
  134818. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  134819. * @param radiusLimit The limit to check against.
  134820. * @return Bool to indicate if at limit.
  134821. */
  134822. private _isRadiusAtLimit;
  134823. /**
  134824. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  134825. * @param radiusDelta The delta by which to animate to. Can be negative.
  134826. */
  134827. private _applyBoundRadiusAnimation;
  134828. /**
  134829. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  134830. */
  134831. protected _clearAnimationLocks(): void;
  134832. /**
  134833. * Stops and removes all animations that have been applied to the camera
  134834. */
  134835. stopAllAnimations(): void;
  134836. }
  134837. }
  134838. declare module BABYLON {
  134839. /**
  134840. * 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.
  134841. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  134842. */
  134843. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  134844. /**
  134845. * Gets the name of the behavior.
  134846. */
  134847. get name(): string;
  134848. private _mode;
  134849. private _radiusScale;
  134850. private _positionScale;
  134851. private _defaultElevation;
  134852. private _elevationReturnTime;
  134853. private _elevationReturnWaitTime;
  134854. private _zoomStopsAnimation;
  134855. private _framingTime;
  134856. /**
  134857. * The easing function used by animations
  134858. */
  134859. static EasingFunction: ExponentialEase;
  134860. /**
  134861. * The easing mode used by animations
  134862. */
  134863. static EasingMode: number;
  134864. /**
  134865. * Sets the current mode used by the behavior
  134866. */
  134867. set mode(mode: number);
  134868. /**
  134869. * Gets current mode used by the behavior.
  134870. */
  134871. get mode(): number;
  134872. /**
  134873. * Sets the scale applied to the radius (1 by default)
  134874. */
  134875. set radiusScale(radius: number);
  134876. /**
  134877. * Gets the scale applied to the radius
  134878. */
  134879. get radiusScale(): number;
  134880. /**
  134881. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  134882. */
  134883. set positionScale(scale: number);
  134884. /**
  134885. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  134886. */
  134887. get positionScale(): number;
  134888. /**
  134889. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  134890. * behaviour is triggered, in radians.
  134891. */
  134892. set defaultElevation(elevation: number);
  134893. /**
  134894. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  134895. * behaviour is triggered, in radians.
  134896. */
  134897. get defaultElevation(): number;
  134898. /**
  134899. * Sets the time (in milliseconds) taken to return to the default beta position.
  134900. * Negative value indicates camera should not return to default.
  134901. */
  134902. set elevationReturnTime(speed: number);
  134903. /**
  134904. * Gets the time (in milliseconds) taken to return to the default beta position.
  134905. * Negative value indicates camera should not return to default.
  134906. */
  134907. get elevationReturnTime(): number;
  134908. /**
  134909. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  134910. */
  134911. set elevationReturnWaitTime(time: number);
  134912. /**
  134913. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  134914. */
  134915. get elevationReturnWaitTime(): number;
  134916. /**
  134917. * Sets the flag that indicates if user zooming should stop animation.
  134918. */
  134919. set zoomStopsAnimation(flag: boolean);
  134920. /**
  134921. * Gets the flag that indicates if user zooming should stop animation.
  134922. */
  134923. get zoomStopsAnimation(): boolean;
  134924. /**
  134925. * Sets the transition time when framing the mesh, in milliseconds
  134926. */
  134927. set framingTime(time: number);
  134928. /**
  134929. * Gets the transition time when framing the mesh, in milliseconds
  134930. */
  134931. get framingTime(): number;
  134932. /**
  134933. * Define if the behavior should automatically change the configured
  134934. * camera limits and sensibilities.
  134935. */
  134936. autoCorrectCameraLimitsAndSensibility: boolean;
  134937. private _onPrePointerObservableObserver;
  134938. private _onAfterCheckInputsObserver;
  134939. private _onMeshTargetChangedObserver;
  134940. private _attachedCamera;
  134941. private _isPointerDown;
  134942. private _lastInteractionTime;
  134943. /**
  134944. * Initializes the behavior.
  134945. */
  134946. init(): void;
  134947. /**
  134948. * Attaches the behavior to its arc rotate camera.
  134949. * @param camera Defines the camera to attach the behavior to
  134950. */
  134951. attach(camera: ArcRotateCamera): void;
  134952. /**
  134953. * Detaches the behavior from its current arc rotate camera.
  134954. */
  134955. detach(): void;
  134956. private _animatables;
  134957. private _betaIsAnimating;
  134958. private _betaTransition;
  134959. private _radiusTransition;
  134960. private _vectorTransition;
  134961. /**
  134962. * Targets the given mesh and updates zoom level accordingly.
  134963. * @param mesh The mesh to target.
  134964. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  134965. * @param onAnimationEnd Callback triggered at the end of the framing animation
  134966. */
  134967. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  134968. /**
  134969. * Targets the given mesh with its children and updates zoom level accordingly.
  134970. * @param mesh The mesh to target.
  134971. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  134972. * @param onAnimationEnd Callback triggered at the end of the framing animation
  134973. */
  134974. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  134975. /**
  134976. * Targets the given meshes with their children and updates zoom level accordingly.
  134977. * @param meshes The mesh to target.
  134978. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  134979. * @param onAnimationEnd Callback triggered at the end of the framing animation
  134980. */
  134981. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  134982. /**
  134983. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  134984. * @param minimumWorld Determines the smaller position of the bounding box extend
  134985. * @param maximumWorld Determines the bigger position of the bounding box extend
  134986. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  134987. * @param onAnimationEnd Callback triggered at the end of the framing animation
  134988. */
  134989. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  134990. /**
  134991. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  134992. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  134993. * frustum width.
  134994. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  134995. * to fully enclose the mesh in the viewing frustum.
  134996. */
  134997. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  134998. /**
  134999. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  135000. * is automatically returned to its default position (expected to be above ground plane).
  135001. */
  135002. private _maintainCameraAboveGround;
  135003. /**
  135004. * Returns the frustum slope based on the canvas ratio and camera FOV
  135005. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  135006. */
  135007. private _getFrustumSlope;
  135008. /**
  135009. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  135010. */
  135011. private _clearAnimationLocks;
  135012. /**
  135013. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  135014. */
  135015. private _applyUserInteraction;
  135016. /**
  135017. * Stops and removes all animations that have been applied to the camera
  135018. */
  135019. stopAllAnimations(): void;
  135020. /**
  135021. * Gets a value indicating if the user is moving the camera
  135022. */
  135023. get isUserIsMoving(): boolean;
  135024. /**
  135025. * The camera can move all the way towards the mesh.
  135026. */
  135027. static IgnoreBoundsSizeMode: number;
  135028. /**
  135029. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  135030. */
  135031. static FitFrustumSidesMode: number;
  135032. }
  135033. }
  135034. declare module BABYLON {
  135035. /**
  135036. * Base class for Camera Pointer Inputs.
  135037. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  135038. * for example usage.
  135039. */
  135040. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  135041. /**
  135042. * Defines the camera the input is attached to.
  135043. */
  135044. abstract camera: Camera;
  135045. /**
  135046. * Whether keyboard modifier keys are pressed at time of last mouse event.
  135047. */
  135048. protected _altKey: boolean;
  135049. protected _ctrlKey: boolean;
  135050. protected _metaKey: boolean;
  135051. protected _shiftKey: boolean;
  135052. /**
  135053. * Which mouse buttons were pressed at time of last mouse event.
  135054. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  135055. */
  135056. protected _buttonsPressed: number;
  135057. /**
  135058. * Defines the buttons associated with the input to handle camera move.
  135059. */
  135060. buttons: number[];
  135061. /**
  135062. * Attach the input controls to a specific dom element to get the input from.
  135063. * @param element Defines the element the controls should be listened from
  135064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135065. */
  135066. attachControl(noPreventDefault?: boolean): void;
  135067. /**
  135068. * Detach the current controls from the specified dom element.
  135069. */
  135070. detachControl(): void;
  135071. /**
  135072. * Gets the class name of the current input.
  135073. * @returns the class name
  135074. */
  135075. getClassName(): string;
  135076. /**
  135077. * Get the friendly name associated with the input class.
  135078. * @returns the input friendly name
  135079. */
  135080. getSimpleName(): string;
  135081. /**
  135082. * Called on pointer POINTERDOUBLETAP event.
  135083. * Override this method to provide functionality on POINTERDOUBLETAP event.
  135084. */
  135085. protected onDoubleTap(type: string): void;
  135086. /**
  135087. * Called on pointer POINTERMOVE event if only a single touch is active.
  135088. * Override this method to provide functionality.
  135089. */
  135090. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  135091. /**
  135092. * Called on pointer POINTERMOVE event if multiple touches are active.
  135093. * Override this method to provide functionality.
  135094. */
  135095. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  135096. /**
  135097. * Called on JS contextmenu event.
  135098. * Override this method to provide functionality.
  135099. */
  135100. protected onContextMenu(evt: PointerEvent): void;
  135101. /**
  135102. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  135103. * press.
  135104. * Override this method to provide functionality.
  135105. */
  135106. protected onButtonDown(evt: PointerEvent): void;
  135107. /**
  135108. * Called each time a new POINTERUP event occurs. Ie, for each button
  135109. * release.
  135110. * Override this method to provide functionality.
  135111. */
  135112. protected onButtonUp(evt: PointerEvent): void;
  135113. /**
  135114. * Called when window becomes inactive.
  135115. * Override this method to provide functionality.
  135116. */
  135117. protected onLostFocus(): void;
  135118. private _pointerInput;
  135119. private _observer;
  135120. private _onLostFocus;
  135121. private pointA;
  135122. private pointB;
  135123. }
  135124. }
  135125. declare module BABYLON {
  135126. /**
  135127. * Manage the pointers inputs to control an arc rotate camera.
  135128. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135129. */
  135130. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  135131. /**
  135132. * Defines the camera the input is attached to.
  135133. */
  135134. camera: ArcRotateCamera;
  135135. /**
  135136. * Gets the class name of the current input.
  135137. * @returns the class name
  135138. */
  135139. getClassName(): string;
  135140. /**
  135141. * Defines the buttons associated with the input to handle camera move.
  135142. */
  135143. buttons: number[];
  135144. /**
  135145. * Defines the pointer angular sensibility along the X axis or how fast is
  135146. * the camera rotating.
  135147. */
  135148. angularSensibilityX: number;
  135149. /**
  135150. * Defines the pointer angular sensibility along the Y axis or how fast is
  135151. * the camera rotating.
  135152. */
  135153. angularSensibilityY: number;
  135154. /**
  135155. * Defines the pointer pinch precision or how fast is the camera zooming.
  135156. */
  135157. pinchPrecision: number;
  135158. /**
  135159. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  135160. * from 0.
  135161. * It defines the percentage of current camera.radius to use as delta when
  135162. * pinch zoom is used.
  135163. */
  135164. pinchDeltaPercentage: number;
  135165. /**
  135166. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  135167. * that any object in the plane at the camera's target point will scale
  135168. * perfectly with finger motion.
  135169. * Overrides pinchDeltaPercentage and pinchPrecision.
  135170. */
  135171. useNaturalPinchZoom: boolean;
  135172. /**
  135173. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  135174. */
  135175. pinchZoom: boolean;
  135176. /**
  135177. * Defines the pointer panning sensibility or how fast is the camera moving.
  135178. */
  135179. panningSensibility: number;
  135180. /**
  135181. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  135182. */
  135183. multiTouchPanning: boolean;
  135184. /**
  135185. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  135186. * zoom (pinch) through multitouch.
  135187. */
  135188. multiTouchPanAndZoom: boolean;
  135189. /**
  135190. * Revers pinch action direction.
  135191. */
  135192. pinchInwards: boolean;
  135193. private _isPanClick;
  135194. private _twoFingerActivityCount;
  135195. private _isPinching;
  135196. /**
  135197. * Move camera from multi touch panning positions.
  135198. */
  135199. private _computeMultiTouchPanning;
  135200. /**
  135201. * Move camera from pinch zoom distances.
  135202. */
  135203. private _computePinchZoom;
  135204. /**
  135205. * Called on pointer POINTERMOVE event if only a single touch is active.
  135206. */
  135207. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  135208. /**
  135209. * Called on pointer POINTERDOUBLETAP event.
  135210. */
  135211. protected onDoubleTap(type: string): void;
  135212. /**
  135213. * Called on pointer POINTERMOVE event if multiple touches are active.
  135214. */
  135215. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  135216. /**
  135217. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  135218. * press.
  135219. */
  135220. protected onButtonDown(evt: PointerEvent): void;
  135221. /**
  135222. * Called each time a new POINTERUP event occurs. Ie, for each button
  135223. * release.
  135224. */
  135225. protected onButtonUp(evt: PointerEvent): void;
  135226. /**
  135227. * Called when window becomes inactive.
  135228. */
  135229. protected onLostFocus(): void;
  135230. }
  135231. }
  135232. declare module BABYLON {
  135233. /**
  135234. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  135235. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135236. */
  135237. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  135238. /**
  135239. * Defines the camera the input is attached to.
  135240. */
  135241. camera: ArcRotateCamera;
  135242. /**
  135243. * Defines the list of key codes associated with the up action (increase alpha)
  135244. */
  135245. keysUp: number[];
  135246. /**
  135247. * Defines the list of key codes associated with the down action (decrease alpha)
  135248. */
  135249. keysDown: number[];
  135250. /**
  135251. * Defines the list of key codes associated with the left action (increase beta)
  135252. */
  135253. keysLeft: number[];
  135254. /**
  135255. * Defines the list of key codes associated with the right action (decrease beta)
  135256. */
  135257. keysRight: number[];
  135258. /**
  135259. * Defines the list of key codes associated with the reset action.
  135260. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  135261. */
  135262. keysReset: number[];
  135263. /**
  135264. * Defines the panning sensibility of the inputs.
  135265. * (How fast is the camera panning)
  135266. */
  135267. panningSensibility: number;
  135268. /**
  135269. * Defines the zooming sensibility of the inputs.
  135270. * (How fast is the camera zooming)
  135271. */
  135272. zoomingSensibility: number;
  135273. /**
  135274. * Defines whether maintaining the alt key down switch the movement mode from
  135275. * orientation to zoom.
  135276. */
  135277. useAltToZoom: boolean;
  135278. /**
  135279. * Rotation speed of the camera
  135280. */
  135281. angularSpeed: number;
  135282. private _keys;
  135283. private _ctrlPressed;
  135284. private _altPressed;
  135285. private _onCanvasBlurObserver;
  135286. private _onKeyboardObserver;
  135287. private _engine;
  135288. private _scene;
  135289. /**
  135290. * Attach the input controls to a specific dom element to get the input from.
  135291. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135292. */
  135293. attachControl(noPreventDefault?: boolean): void;
  135294. /**
  135295. * Detach the current controls from the specified dom element.
  135296. */
  135297. detachControl(): void;
  135298. /**
  135299. * Update the current camera state depending on the inputs that have been used this frame.
  135300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135301. */
  135302. checkInputs(): void;
  135303. /**
  135304. * Gets the class name of the current input.
  135305. * @returns the class name
  135306. */
  135307. getClassName(): string;
  135308. /**
  135309. * Get the friendly name associated with the input class.
  135310. * @returns the input friendly name
  135311. */
  135312. getSimpleName(): string;
  135313. }
  135314. }
  135315. declare module BABYLON {
  135316. /**
  135317. * Manage the mouse wheel inputs to control an arc rotate camera.
  135318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135319. */
  135320. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  135321. /**
  135322. * Defines the camera the input is attached to.
  135323. */
  135324. camera: ArcRotateCamera;
  135325. /**
  135326. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  135327. */
  135328. wheelPrecision: number;
  135329. /**
  135330. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  135331. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  135332. */
  135333. wheelDeltaPercentage: number;
  135334. private _wheel;
  135335. private _observer;
  135336. private computeDeltaFromMouseWheelLegacyEvent;
  135337. /**
  135338. * Attach the input controls to a specific dom element to get the input from.
  135339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135340. */
  135341. attachControl(noPreventDefault?: boolean): void;
  135342. /**
  135343. * Detach the current controls from the specified dom element.
  135344. */
  135345. detachControl(): void;
  135346. /**
  135347. * Gets the class name of the current input.
  135348. * @returns the class name
  135349. */
  135350. getClassName(): string;
  135351. /**
  135352. * Get the friendly name associated with the input class.
  135353. * @returns the input friendly name
  135354. */
  135355. getSimpleName(): string;
  135356. }
  135357. }
  135358. declare module BABYLON {
  135359. /**
  135360. * Default Inputs manager for the ArcRotateCamera.
  135361. * It groups all the default supported inputs for ease of use.
  135362. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135363. */
  135364. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  135365. /**
  135366. * Instantiates a new ArcRotateCameraInputsManager.
  135367. * @param camera Defines the camera the inputs belong to
  135368. */
  135369. constructor(camera: ArcRotateCamera);
  135370. /**
  135371. * Add mouse wheel input support to the input manager.
  135372. * @returns the current input manager
  135373. */
  135374. addMouseWheel(): ArcRotateCameraInputsManager;
  135375. /**
  135376. * Add pointers input support to the input manager.
  135377. * @returns the current input manager
  135378. */
  135379. addPointers(): ArcRotateCameraInputsManager;
  135380. /**
  135381. * Add keyboard input support to the input manager.
  135382. * @returns the current input manager
  135383. */
  135384. addKeyboard(): ArcRotateCameraInputsManager;
  135385. }
  135386. }
  135387. declare module BABYLON {
  135388. /**
  135389. * This represents an orbital type of camera.
  135390. *
  135391. * 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.
  135392. * 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.
  135393. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  135394. */
  135395. export class ArcRotateCamera extends TargetCamera {
  135396. /**
  135397. * Defines the rotation angle of the camera along the longitudinal axis.
  135398. */
  135399. alpha: number;
  135400. /**
  135401. * Defines the rotation angle of the camera along the latitudinal axis.
  135402. */
  135403. beta: number;
  135404. /**
  135405. * Defines the radius of the camera from it s target point.
  135406. */
  135407. radius: number;
  135408. protected _target: Vector3;
  135409. protected _targetHost: Nullable<AbstractMesh>;
  135410. /**
  135411. * Defines the target point of the camera.
  135412. * The camera looks towards it form the radius distance.
  135413. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  135414. */
  135415. get target(): Vector3;
  135416. set target(value: Vector3);
  135417. /**
  135418. * Define the current local position of the camera in the scene
  135419. */
  135420. get position(): Vector3;
  135421. set position(newPosition: Vector3);
  135422. protected _upToYMatrix: Matrix;
  135423. protected _YToUpMatrix: Matrix;
  135424. /**
  135425. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  135426. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  135427. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  135428. */
  135429. set upVector(vec: Vector3);
  135430. get upVector(): Vector3;
  135431. /**
  135432. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  135433. */
  135434. setMatUp(): void;
  135435. /**
  135436. * Current inertia value on the longitudinal axis.
  135437. * The bigger this number the longer it will take for the camera to stop.
  135438. */
  135439. inertialAlphaOffset: number;
  135440. /**
  135441. * Current inertia value on the latitudinal axis.
  135442. * The bigger this number the longer it will take for the camera to stop.
  135443. */
  135444. inertialBetaOffset: number;
  135445. /**
  135446. * Current inertia value on the radius axis.
  135447. * The bigger this number the longer it will take for the camera to stop.
  135448. */
  135449. inertialRadiusOffset: number;
  135450. /**
  135451. * Minimum allowed angle on the longitudinal axis.
  135452. * This can help limiting how the Camera is able to move in the scene.
  135453. */
  135454. lowerAlphaLimit: Nullable<number>;
  135455. /**
  135456. * Maximum allowed angle on the longitudinal axis.
  135457. * This can help limiting how the Camera is able to move in the scene.
  135458. */
  135459. upperAlphaLimit: Nullable<number>;
  135460. /**
  135461. * Minimum allowed angle on the latitudinal axis.
  135462. * This can help limiting how the Camera is able to move in the scene.
  135463. */
  135464. lowerBetaLimit: number;
  135465. /**
  135466. * Maximum allowed angle on the latitudinal axis.
  135467. * This can help limiting how the Camera is able to move in the scene.
  135468. */
  135469. upperBetaLimit: number;
  135470. /**
  135471. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  135472. * This can help limiting how the Camera is able to move in the scene.
  135473. */
  135474. lowerRadiusLimit: Nullable<number>;
  135475. /**
  135476. * Maximum allowed distance of the camera to the target (The camera can not get further).
  135477. * This can help limiting how the Camera is able to move in the scene.
  135478. */
  135479. upperRadiusLimit: Nullable<number>;
  135480. /**
  135481. * Defines the current inertia value used during panning of the camera along the X axis.
  135482. */
  135483. inertialPanningX: number;
  135484. /**
  135485. * Defines the current inertia value used during panning of the camera along the Y axis.
  135486. */
  135487. inertialPanningY: number;
  135488. /**
  135489. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  135490. * Basically if your fingers moves away from more than this distance you will be considered
  135491. * in pinch mode.
  135492. */
  135493. pinchToPanMaxDistance: number;
  135494. /**
  135495. * Defines the maximum distance the camera can pan.
  135496. * This could help keeping the camera always in your scene.
  135497. */
  135498. panningDistanceLimit: Nullable<number>;
  135499. /**
  135500. * Defines the target of the camera before panning.
  135501. */
  135502. panningOriginTarget: Vector3;
  135503. /**
  135504. * Defines the value of the inertia used during panning.
  135505. * 0 would mean stop inertia and one would mean no decelleration at all.
  135506. */
  135507. panningInertia: number;
  135508. /**
  135509. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  135510. */
  135511. get angularSensibilityX(): number;
  135512. set angularSensibilityX(value: number);
  135513. /**
  135514. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  135515. */
  135516. get angularSensibilityY(): number;
  135517. set angularSensibilityY(value: number);
  135518. /**
  135519. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  135520. */
  135521. get pinchPrecision(): number;
  135522. set pinchPrecision(value: number);
  135523. /**
  135524. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  135525. * It will be used instead of pinchDeltaPrecision if different from 0.
  135526. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  135527. */
  135528. get pinchDeltaPercentage(): number;
  135529. set pinchDeltaPercentage(value: number);
  135530. /**
  135531. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  135532. * and pinch delta percentage.
  135533. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  135534. * that any object in the plane at the camera's target point will scale
  135535. * perfectly with finger motion.
  135536. */
  135537. get useNaturalPinchZoom(): boolean;
  135538. set useNaturalPinchZoom(value: boolean);
  135539. /**
  135540. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  135541. */
  135542. get panningSensibility(): number;
  135543. set panningSensibility(value: number);
  135544. /**
  135545. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  135546. */
  135547. get keysUp(): number[];
  135548. set keysUp(value: number[]);
  135549. /**
  135550. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  135551. */
  135552. get keysDown(): number[];
  135553. set keysDown(value: number[]);
  135554. /**
  135555. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  135556. */
  135557. get keysLeft(): number[];
  135558. set keysLeft(value: number[]);
  135559. /**
  135560. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  135561. */
  135562. get keysRight(): number[];
  135563. set keysRight(value: number[]);
  135564. /**
  135565. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  135566. */
  135567. get wheelPrecision(): number;
  135568. set wheelPrecision(value: number);
  135569. /**
  135570. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  135571. * It will be used instead of pinchDeltaPrecision if different from 0.
  135572. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  135573. */
  135574. get wheelDeltaPercentage(): number;
  135575. set wheelDeltaPercentage(value: number);
  135576. /**
  135577. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  135578. */
  135579. zoomOnFactor: number;
  135580. /**
  135581. * Defines a screen offset for the camera position.
  135582. */
  135583. targetScreenOffset: Vector2;
  135584. /**
  135585. * Allows the camera to be completely reversed.
  135586. * If false the camera can not arrive upside down.
  135587. */
  135588. allowUpsideDown: boolean;
  135589. /**
  135590. * Define if double tap/click is used to restore the previously saved state of the camera.
  135591. */
  135592. useInputToRestoreState: boolean;
  135593. /** @hidden */
  135594. _viewMatrix: Matrix;
  135595. /** @hidden */
  135596. _useCtrlForPanning: boolean;
  135597. /** @hidden */
  135598. _panningMouseButton: number;
  135599. /**
  135600. * Defines the input associated to the camera.
  135601. */
  135602. inputs: ArcRotateCameraInputsManager;
  135603. /** @hidden */
  135604. _reset: () => void;
  135605. /**
  135606. * Defines the allowed panning axis.
  135607. */
  135608. panningAxis: Vector3;
  135609. protected _transformedDirection: Vector3;
  135610. private _bouncingBehavior;
  135611. /**
  135612. * Gets the bouncing behavior of the camera if it has been enabled.
  135613. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  135614. */
  135615. get bouncingBehavior(): Nullable<BouncingBehavior>;
  135616. /**
  135617. * Defines if the bouncing behavior of the camera is enabled on the camera.
  135618. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  135619. */
  135620. get useBouncingBehavior(): boolean;
  135621. set useBouncingBehavior(value: boolean);
  135622. private _framingBehavior;
  135623. /**
  135624. * Gets the framing behavior of the camera if it has been enabled.
  135625. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  135626. */
  135627. get framingBehavior(): Nullable<FramingBehavior>;
  135628. /**
  135629. * Defines if the framing behavior of the camera is enabled on the camera.
  135630. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  135631. */
  135632. get useFramingBehavior(): boolean;
  135633. set useFramingBehavior(value: boolean);
  135634. private _autoRotationBehavior;
  135635. /**
  135636. * Gets the auto rotation behavior of the camera if it has been enabled.
  135637. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  135638. */
  135639. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  135640. /**
  135641. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  135642. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  135643. */
  135644. get useAutoRotationBehavior(): boolean;
  135645. set useAutoRotationBehavior(value: boolean);
  135646. /**
  135647. * Observable triggered when the mesh target has been changed on the camera.
  135648. */
  135649. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  135650. /**
  135651. * Event raised when the camera is colliding with a mesh.
  135652. */
  135653. onCollide: (collidedMesh: AbstractMesh) => void;
  135654. /**
  135655. * Defines whether the camera should check collision with the objects oh the scene.
  135656. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  135657. */
  135658. checkCollisions: boolean;
  135659. /**
  135660. * Defines the collision radius of the camera.
  135661. * This simulates a sphere around the camera.
  135662. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  135663. */
  135664. collisionRadius: Vector3;
  135665. protected _collider: Collider;
  135666. protected _previousPosition: Vector3;
  135667. protected _collisionVelocity: Vector3;
  135668. protected _newPosition: Vector3;
  135669. protected _previousAlpha: number;
  135670. protected _previousBeta: number;
  135671. protected _previousRadius: number;
  135672. protected _collisionTriggered: boolean;
  135673. protected _targetBoundingCenter: Nullable<Vector3>;
  135674. private _computationVector;
  135675. /**
  135676. * Instantiates a new ArcRotateCamera in a given scene
  135677. * @param name Defines the name of the camera
  135678. * @param alpha Defines the camera rotation along the longitudinal axis
  135679. * @param beta Defines the camera rotation along the latitudinal axis
  135680. * @param radius Defines the camera distance from its target
  135681. * @param target Defines the camera target
  135682. * @param scene Defines the scene the camera belongs to
  135683. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  135684. */
  135685. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  135686. /** @hidden */
  135687. _initCache(): void;
  135688. /** @hidden */
  135689. _updateCache(ignoreParentClass?: boolean): void;
  135690. protected _getTargetPosition(): Vector3;
  135691. private _storedAlpha;
  135692. private _storedBeta;
  135693. private _storedRadius;
  135694. private _storedTarget;
  135695. private _storedTargetScreenOffset;
  135696. /**
  135697. * Stores the current state of the camera (alpha, beta, radius and target)
  135698. * @returns the camera itself
  135699. */
  135700. storeState(): Camera;
  135701. /**
  135702. * @hidden
  135703. * Restored camera state. You must call storeState() first
  135704. */
  135705. _restoreStateValues(): boolean;
  135706. /** @hidden */
  135707. _isSynchronizedViewMatrix(): boolean;
  135708. /**
  135709. * Attach the input controls to a specific dom element to get the input from.
  135710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135711. */
  135712. attachControl(noPreventDefault?: boolean): void;
  135713. /**
  135714. * Attach the input controls to a specific dom element to get the input from.
  135715. * @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
  135716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135717. */
  135718. attachControl(ignored: any, noPreventDefault?: boolean): void;
  135719. /**
  135720. * Attached controls to the current camera.
  135721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135722. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  135723. */
  135724. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  135725. /**
  135726. * Attached controls to the current camera.
  135727. * @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
  135728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135729. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  135730. */
  135731. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  135732. /**
  135733. * Attached controls to the current camera.
  135734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135735. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  135736. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  135737. */
  135738. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  135739. /**
  135740. * Detach the current controls from the specified dom element.
  135741. */
  135742. detachControl(): void;
  135743. /**
  135744. * Detach the current controls from the specified dom element.
  135745. * @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
  135746. */
  135747. detachControl(ignored: any): void;
  135748. /** @hidden */
  135749. _checkInputs(): void;
  135750. protected _checkLimits(): void;
  135751. /**
  135752. * Rebuilds angles (alpha, beta) and radius from the give position and target
  135753. */
  135754. rebuildAnglesAndRadius(): void;
  135755. /**
  135756. * Use a position to define the current camera related information like alpha, beta and radius
  135757. * @param position Defines the position to set the camera at
  135758. */
  135759. setPosition(position: Vector3): void;
  135760. /**
  135761. * Defines the target the camera should look at.
  135762. * This will automatically adapt alpha beta and radius to fit within the new target.
  135763. * @param target Defines the new target as a Vector or a mesh
  135764. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  135765. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  135766. */
  135767. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  135768. /** @hidden */
  135769. _getViewMatrix(): Matrix;
  135770. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  135771. /**
  135772. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  135773. * @param meshes Defines the mesh to zoom on
  135774. * @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)
  135775. */
  135776. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  135777. /**
  135778. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  135779. * The target will be changed but the radius
  135780. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  135781. * @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)
  135782. */
  135783. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  135784. min: Vector3;
  135785. max: Vector3;
  135786. distance: number;
  135787. }, doNotUpdateMaxZ?: boolean): void;
  135788. /**
  135789. * @override
  135790. * Override Camera.createRigCamera
  135791. */
  135792. createRigCamera(name: string, cameraIndex: number): Camera;
  135793. /**
  135794. * @hidden
  135795. * @override
  135796. * Override Camera._updateRigCameras
  135797. */
  135798. _updateRigCameras(): void;
  135799. /**
  135800. * Destroy the camera and release the current resources hold by it.
  135801. */
  135802. dispose(): void;
  135803. /**
  135804. * Gets the current object class name.
  135805. * @return the class name
  135806. */
  135807. getClassName(): string;
  135808. }
  135809. }
  135810. declare module BABYLON {
  135811. /**
  135812. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  135813. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  135814. */
  135815. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  135816. /**
  135817. * Gets the name of the behavior.
  135818. */
  135819. get name(): string;
  135820. private _zoomStopsAnimation;
  135821. private _idleRotationSpeed;
  135822. private _idleRotationWaitTime;
  135823. private _idleRotationSpinupTime;
  135824. /**
  135825. * Sets the flag that indicates if user zooming should stop animation.
  135826. */
  135827. set zoomStopsAnimation(flag: boolean);
  135828. /**
  135829. * Gets the flag that indicates if user zooming should stop animation.
  135830. */
  135831. get zoomStopsAnimation(): boolean;
  135832. /**
  135833. * Sets the default speed at which the camera rotates around the model.
  135834. */
  135835. set idleRotationSpeed(speed: number);
  135836. /**
  135837. * Gets the default speed at which the camera rotates around the model.
  135838. */
  135839. get idleRotationSpeed(): number;
  135840. /**
  135841. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  135842. */
  135843. set idleRotationWaitTime(time: number);
  135844. /**
  135845. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  135846. */
  135847. get idleRotationWaitTime(): number;
  135848. /**
  135849. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  135850. */
  135851. set idleRotationSpinupTime(time: number);
  135852. /**
  135853. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  135854. */
  135855. get idleRotationSpinupTime(): number;
  135856. /**
  135857. * Gets a value indicating if the camera is currently rotating because of this behavior
  135858. */
  135859. get rotationInProgress(): boolean;
  135860. private _onPrePointerObservableObserver;
  135861. private _onAfterCheckInputsObserver;
  135862. private _attachedCamera;
  135863. private _isPointerDown;
  135864. private _lastFrameTime;
  135865. private _lastInteractionTime;
  135866. private _cameraRotationSpeed;
  135867. /**
  135868. * Initializes the behavior.
  135869. */
  135870. init(): void;
  135871. /**
  135872. * Attaches the behavior to its arc rotate camera.
  135873. * @param camera Defines the camera to attach the behavior to
  135874. */
  135875. attach(camera: ArcRotateCamera): void;
  135876. /**
  135877. * Detaches the behavior from its current arc rotate camera.
  135878. */
  135879. detach(): void;
  135880. /**
  135881. * Returns true if user is scrolling.
  135882. * @return true if user is scrolling.
  135883. */
  135884. private _userIsZooming;
  135885. private _lastFrameRadius;
  135886. private _shouldAnimationStopForInteraction;
  135887. /**
  135888. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  135889. */
  135890. private _applyUserInteraction;
  135891. private _userIsMoving;
  135892. }
  135893. }
  135894. declare module BABYLON {
  135895. /**
  135896. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  135897. */
  135898. export class AttachToBoxBehavior implements Behavior<Mesh> {
  135899. private ui;
  135900. /**
  135901. * The name of the behavior
  135902. */
  135903. name: string;
  135904. /**
  135905. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  135906. */
  135907. distanceAwayFromFace: number;
  135908. /**
  135909. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  135910. */
  135911. distanceAwayFromBottomOfFace: number;
  135912. private _faceVectors;
  135913. private _target;
  135914. private _scene;
  135915. private _onRenderObserver;
  135916. private _tmpMatrix;
  135917. private _tmpVector;
  135918. /**
  135919. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  135920. * @param ui The transform node that should be attached to the mesh
  135921. */
  135922. constructor(ui: TransformNode);
  135923. /**
  135924. * Initializes the behavior
  135925. */
  135926. init(): void;
  135927. private _closestFace;
  135928. private _zeroVector;
  135929. private _lookAtTmpMatrix;
  135930. private _lookAtToRef;
  135931. /**
  135932. * Attaches the AttachToBoxBehavior to the passed in mesh
  135933. * @param target The mesh that the specified node will be attached to
  135934. */
  135935. attach(target: Mesh): void;
  135936. /**
  135937. * Detaches the behavior from the mesh
  135938. */
  135939. detach(): void;
  135940. }
  135941. }
  135942. declare module BABYLON {
  135943. /**
  135944. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  135945. */
  135946. export class FadeInOutBehavior implements Behavior<Mesh> {
  135947. /**
  135948. * Time in milliseconds to delay before fading in (Default: 0)
  135949. */
  135950. delay: number;
  135951. /**
  135952. * Time in milliseconds for the mesh to fade in (Default: 300)
  135953. */
  135954. fadeInTime: number;
  135955. private _millisecondsPerFrame;
  135956. private _hovered;
  135957. private _hoverValue;
  135958. private _ownerNode;
  135959. /**
  135960. * Instantiates the FadeInOutBehavior
  135961. */
  135962. constructor();
  135963. /**
  135964. * The name of the behavior
  135965. */
  135966. get name(): string;
  135967. /**
  135968. * Initializes the behavior
  135969. */
  135970. init(): void;
  135971. /**
  135972. * Attaches the fade behavior on the passed in mesh
  135973. * @param ownerNode The mesh that will be faded in/out once attached
  135974. */
  135975. attach(ownerNode: Mesh): void;
  135976. /**
  135977. * Detaches the behavior from the mesh
  135978. */
  135979. detach(): void;
  135980. /**
  135981. * Triggers the mesh to begin fading in or out
  135982. * @param value if the object should fade in or out (true to fade in)
  135983. */
  135984. fadeIn(value: boolean): void;
  135985. private _update;
  135986. private _setAllVisibility;
  135987. }
  135988. }
  135989. declare module BABYLON {
  135990. /**
  135991. * Class containing a set of static utilities functions for managing Pivots
  135992. * @hidden
  135993. */
  135994. export class PivotTools {
  135995. private static _PivotCached;
  135996. private static _OldPivotPoint;
  135997. private static _PivotTranslation;
  135998. private static _PivotTmpVector;
  135999. private static _PivotPostMultiplyPivotMatrix;
  136000. /** @hidden */
  136001. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  136002. /** @hidden */
  136003. static _RestorePivotPoint(mesh: AbstractMesh): void;
  136004. }
  136005. }
  136006. declare module BABYLON {
  136007. /**
  136008. * Class containing static functions to help procedurally build meshes
  136009. */
  136010. export class PlaneBuilder {
  136011. /**
  136012. * Creates a plane mesh
  136013. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  136014. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  136015. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  136016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136019. * @param name defines the name of the mesh
  136020. * @param options defines the options used to create the mesh
  136021. * @param scene defines the hosting scene
  136022. * @returns the plane mesh
  136023. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136024. */
  136025. static CreatePlane(name: string, options: {
  136026. size?: number;
  136027. width?: number;
  136028. height?: number;
  136029. sideOrientation?: number;
  136030. frontUVs?: Vector4;
  136031. backUVs?: Vector4;
  136032. updatable?: boolean;
  136033. sourcePlane?: Plane;
  136034. }, scene?: Nullable<Scene>): Mesh;
  136035. }
  136036. }
  136037. declare module BABYLON {
  136038. /**
  136039. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  136040. */
  136041. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  136042. private static _AnyMouseID;
  136043. /**
  136044. * Abstract mesh the behavior is set on
  136045. */
  136046. attachedNode: AbstractMesh;
  136047. private _dragPlane;
  136048. private _scene;
  136049. private _pointerObserver;
  136050. private _beforeRenderObserver;
  136051. private static _planeScene;
  136052. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  136053. /**
  136054. * 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)
  136055. */
  136056. maxDragAngle: number;
  136057. /**
  136058. * @hidden
  136059. */
  136060. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  136061. /**
  136062. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  136063. */
  136064. currentDraggingPointerID: number;
  136065. /**
  136066. * The last position where the pointer hit the drag plane in world space
  136067. */
  136068. lastDragPosition: Vector3;
  136069. /**
  136070. * If the behavior is currently in a dragging state
  136071. */
  136072. dragging: boolean;
  136073. /**
  136074. * 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)
  136075. */
  136076. dragDeltaRatio: number;
  136077. /**
  136078. * If the drag plane orientation should be updated during the dragging (Default: true)
  136079. */
  136080. updateDragPlane: boolean;
  136081. private _debugMode;
  136082. private _moving;
  136083. /**
  136084. * Fires each time the attached mesh is dragged with the pointer
  136085. * * delta between last drag position and current drag position in world space
  136086. * * dragDistance along the drag axis
  136087. * * dragPlaneNormal normal of the current drag plane used during the drag
  136088. * * dragPlanePoint in world space where the drag intersects the drag plane
  136089. */
  136090. onDragObservable: Observable<{
  136091. delta: Vector3;
  136092. dragPlanePoint: Vector3;
  136093. dragPlaneNormal: Vector3;
  136094. dragDistance: number;
  136095. pointerId: number;
  136096. }>;
  136097. /**
  136098. * Fires each time a drag begins (eg. mouse down on mesh)
  136099. */
  136100. onDragStartObservable: Observable<{
  136101. dragPlanePoint: Vector3;
  136102. pointerId: number;
  136103. }>;
  136104. /**
  136105. * Fires each time a drag ends (eg. mouse release after drag)
  136106. */
  136107. onDragEndObservable: Observable<{
  136108. dragPlanePoint: Vector3;
  136109. pointerId: number;
  136110. }>;
  136111. /**
  136112. * If the attached mesh should be moved when dragged
  136113. */
  136114. moveAttached: boolean;
  136115. /**
  136116. * If the drag behavior will react to drag events (Default: true)
  136117. */
  136118. enabled: boolean;
  136119. /**
  136120. * If pointer events should start and release the drag (Default: true)
  136121. */
  136122. startAndReleaseDragOnPointerEvents: boolean;
  136123. /**
  136124. * If camera controls should be detached during the drag
  136125. */
  136126. detachCameraControls: boolean;
  136127. /**
  136128. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  136129. */
  136130. useObjectOrientationForDragging: boolean;
  136131. private _options;
  136132. /**
  136133. * Gets the options used by the behavior
  136134. */
  136135. get options(): {
  136136. dragAxis?: Vector3;
  136137. dragPlaneNormal?: Vector3;
  136138. };
  136139. /**
  136140. * Sets the options used by the behavior
  136141. */
  136142. set options(options: {
  136143. dragAxis?: Vector3;
  136144. dragPlaneNormal?: Vector3;
  136145. });
  136146. /**
  136147. * Creates a pointer drag behavior that can be attached to a mesh
  136148. * @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)
  136149. */
  136150. constructor(options?: {
  136151. dragAxis?: Vector3;
  136152. dragPlaneNormal?: Vector3;
  136153. });
  136154. /**
  136155. * Predicate to determine if it is valid to move the object to a new position when it is moved
  136156. */
  136157. validateDrag: (targetPosition: Vector3) => boolean;
  136158. /**
  136159. * The name of the behavior
  136160. */
  136161. get name(): string;
  136162. /**
  136163. * Initializes the behavior
  136164. */
  136165. init(): void;
  136166. private _tmpVector;
  136167. private _alternatePickedPoint;
  136168. private _worldDragAxis;
  136169. private _targetPosition;
  136170. private _attachedToElement;
  136171. /**
  136172. * Attaches the drag behavior the passed in mesh
  136173. * @param ownerNode The mesh that will be dragged around once attached
  136174. * @param predicate Predicate to use for pick filtering
  136175. */
  136176. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  136177. /**
  136178. * Force release the drag action by code.
  136179. */
  136180. releaseDrag(): void;
  136181. private _startDragRay;
  136182. private _lastPointerRay;
  136183. /**
  136184. * Simulates the start of a pointer drag event on the behavior
  136185. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  136186. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  136187. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  136188. */
  136189. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  136190. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  136191. private _dragDelta;
  136192. protected _moveDrag(ray: Ray): void;
  136193. private _pickWithRayOnDragPlane;
  136194. private _pointA;
  136195. private _pointC;
  136196. private _localAxis;
  136197. private _lookAt;
  136198. private _updateDragPlanePosition;
  136199. /**
  136200. * Detaches the behavior from the mesh
  136201. */
  136202. detach(): void;
  136203. }
  136204. }
  136205. declare module BABYLON {
  136206. /**
  136207. * A behavior that when attached to a mesh will allow the mesh to be scaled
  136208. */
  136209. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  136210. private _dragBehaviorA;
  136211. private _dragBehaviorB;
  136212. private _startDistance;
  136213. private _initialScale;
  136214. private _targetScale;
  136215. private _ownerNode;
  136216. private _sceneRenderObserver;
  136217. /**
  136218. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  136219. */
  136220. constructor();
  136221. /**
  136222. * The name of the behavior
  136223. */
  136224. get name(): string;
  136225. /**
  136226. * Initializes the behavior
  136227. */
  136228. init(): void;
  136229. private _getCurrentDistance;
  136230. /**
  136231. * Attaches the scale behavior the passed in mesh
  136232. * @param ownerNode The mesh that will be scaled around once attached
  136233. */
  136234. attach(ownerNode: Mesh): void;
  136235. /**
  136236. * Detaches the behavior from the mesh
  136237. */
  136238. detach(): void;
  136239. }
  136240. }
  136241. declare module BABYLON {
  136242. /**
  136243. * 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
  136244. */
  136245. export class SixDofDragBehavior implements Behavior<Mesh> {
  136246. private static _virtualScene;
  136247. private _ownerNode;
  136248. private _sceneRenderObserver;
  136249. private _scene;
  136250. private _targetPosition;
  136251. private _virtualOriginMesh;
  136252. private _virtualDragMesh;
  136253. private _pointerObserver;
  136254. private _moving;
  136255. private _startingOrientation;
  136256. private _attachedToElement;
  136257. /**
  136258. * 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)
  136259. */
  136260. private zDragFactor;
  136261. /**
  136262. * If the object should rotate to face the drag origin
  136263. */
  136264. rotateDraggedObject: boolean;
  136265. /**
  136266. * If the behavior is currently in a dragging state
  136267. */
  136268. dragging: boolean;
  136269. /**
  136270. * 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)
  136271. */
  136272. dragDeltaRatio: number;
  136273. /**
  136274. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  136275. */
  136276. currentDraggingPointerID: number;
  136277. /**
  136278. * If camera controls should be detached during the drag
  136279. */
  136280. detachCameraControls: boolean;
  136281. /**
  136282. * Fires each time a drag starts
  136283. */
  136284. onDragStartObservable: Observable<{}>;
  136285. /**
  136286. * Fires each time a drag happens
  136287. */
  136288. onDragObservable: Observable<void>;
  136289. /**
  136290. * Fires each time a drag ends (eg. mouse release after drag)
  136291. */
  136292. onDragEndObservable: Observable<{}>;
  136293. /**
  136294. * 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
  136295. */
  136296. constructor();
  136297. /**
  136298. * The name of the behavior
  136299. */
  136300. get name(): string;
  136301. /**
  136302. * Initializes the behavior
  136303. */
  136304. init(): void;
  136305. /**
  136306. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  136307. */
  136308. private get _pointerCamera();
  136309. /**
  136310. * Attaches the scale behavior the passed in mesh
  136311. * @param ownerNode The mesh that will be scaled around once attached
  136312. */
  136313. attach(ownerNode: Mesh): void;
  136314. /**
  136315. * Detaches the behavior from the mesh
  136316. */
  136317. detach(): void;
  136318. }
  136319. }
  136320. declare module BABYLON {
  136321. /**
  136322. * Class used to apply inverse kinematics to bones
  136323. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  136324. */
  136325. export class BoneIKController {
  136326. private static _tmpVecs;
  136327. private static _tmpQuat;
  136328. private static _tmpMats;
  136329. /**
  136330. * Gets or sets the target mesh
  136331. */
  136332. targetMesh: AbstractMesh;
  136333. /** Gets or sets the mesh used as pole */
  136334. poleTargetMesh: AbstractMesh;
  136335. /**
  136336. * Gets or sets the bone used as pole
  136337. */
  136338. poleTargetBone: Nullable<Bone>;
  136339. /**
  136340. * Gets or sets the target position
  136341. */
  136342. targetPosition: Vector3;
  136343. /**
  136344. * Gets or sets the pole target position
  136345. */
  136346. poleTargetPosition: Vector3;
  136347. /**
  136348. * Gets or sets the pole target local offset
  136349. */
  136350. poleTargetLocalOffset: Vector3;
  136351. /**
  136352. * Gets or sets the pole angle
  136353. */
  136354. poleAngle: number;
  136355. /**
  136356. * Gets or sets the mesh associated with the controller
  136357. */
  136358. mesh: AbstractMesh;
  136359. /**
  136360. * 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)
  136361. */
  136362. slerpAmount: number;
  136363. private _bone1Quat;
  136364. private _bone1Mat;
  136365. private _bone2Ang;
  136366. private _bone1;
  136367. private _bone2;
  136368. private _bone1Length;
  136369. private _bone2Length;
  136370. private _maxAngle;
  136371. private _maxReach;
  136372. private _rightHandedSystem;
  136373. private _bendAxis;
  136374. private _slerping;
  136375. private _adjustRoll;
  136376. /**
  136377. * Gets or sets maximum allowed angle
  136378. */
  136379. get maxAngle(): number;
  136380. set maxAngle(value: number);
  136381. /**
  136382. * Creates a new BoneIKController
  136383. * @param mesh defines the mesh to control
  136384. * @param bone defines the bone to control
  136385. * @param options defines options to set up the controller
  136386. */
  136387. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  136388. targetMesh?: AbstractMesh;
  136389. poleTargetMesh?: AbstractMesh;
  136390. poleTargetBone?: Bone;
  136391. poleTargetLocalOffset?: Vector3;
  136392. poleAngle?: number;
  136393. bendAxis?: Vector3;
  136394. maxAngle?: number;
  136395. slerpAmount?: number;
  136396. });
  136397. private _setMaxAngle;
  136398. /**
  136399. * Force the controller to update the bones
  136400. */
  136401. update(): void;
  136402. }
  136403. }
  136404. declare module BABYLON {
  136405. /**
  136406. * Class used to make a bone look toward a point in space
  136407. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  136408. */
  136409. export class BoneLookController {
  136410. private static _tmpVecs;
  136411. private static _tmpQuat;
  136412. private static _tmpMats;
  136413. /**
  136414. * The target Vector3 that the bone will look at
  136415. */
  136416. target: Vector3;
  136417. /**
  136418. * The mesh that the bone is attached to
  136419. */
  136420. mesh: AbstractMesh;
  136421. /**
  136422. * The bone that will be looking to the target
  136423. */
  136424. bone: Bone;
  136425. /**
  136426. * The up axis of the coordinate system that is used when the bone is rotated
  136427. */
  136428. upAxis: Vector3;
  136429. /**
  136430. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  136431. */
  136432. upAxisSpace: Space;
  136433. /**
  136434. * Used to make an adjustment to the yaw of the bone
  136435. */
  136436. adjustYaw: number;
  136437. /**
  136438. * Used to make an adjustment to the pitch of the bone
  136439. */
  136440. adjustPitch: number;
  136441. /**
  136442. * Used to make an adjustment to the roll of the bone
  136443. */
  136444. adjustRoll: number;
  136445. /**
  136446. * 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)
  136447. */
  136448. slerpAmount: number;
  136449. private _minYaw;
  136450. private _maxYaw;
  136451. private _minPitch;
  136452. private _maxPitch;
  136453. private _minYawSin;
  136454. private _minYawCos;
  136455. private _maxYawSin;
  136456. private _maxYawCos;
  136457. private _midYawConstraint;
  136458. private _minPitchTan;
  136459. private _maxPitchTan;
  136460. private _boneQuat;
  136461. private _slerping;
  136462. private _transformYawPitch;
  136463. private _transformYawPitchInv;
  136464. private _firstFrameSkipped;
  136465. private _yawRange;
  136466. private _fowardAxis;
  136467. /**
  136468. * Gets or sets the minimum yaw angle that the bone can look to
  136469. */
  136470. get minYaw(): number;
  136471. set minYaw(value: number);
  136472. /**
  136473. * Gets or sets the maximum yaw angle that the bone can look to
  136474. */
  136475. get maxYaw(): number;
  136476. set maxYaw(value: number);
  136477. /**
  136478. * Gets or sets the minimum pitch angle that the bone can look to
  136479. */
  136480. get minPitch(): number;
  136481. set minPitch(value: number);
  136482. /**
  136483. * Gets or sets the maximum pitch angle that the bone can look to
  136484. */
  136485. get maxPitch(): number;
  136486. set maxPitch(value: number);
  136487. /**
  136488. * Create a BoneLookController
  136489. * @param mesh the mesh that the bone belongs to
  136490. * @param bone the bone that will be looking to the target
  136491. * @param target the target Vector3 to look at
  136492. * @param options optional settings:
  136493. * * maxYaw: the maximum angle the bone will yaw to
  136494. * * minYaw: the minimum angle the bone will yaw to
  136495. * * maxPitch: the maximum angle the bone will pitch to
  136496. * * minPitch: the minimum angle the bone will yaw to
  136497. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  136498. * * upAxis: the up axis of the coordinate system
  136499. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  136500. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  136501. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  136502. * * adjustYaw: used to make an adjustment to the yaw of the bone
  136503. * * adjustPitch: used to make an adjustment to the pitch of the bone
  136504. * * adjustRoll: used to make an adjustment to the roll of the bone
  136505. **/
  136506. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  136507. maxYaw?: number;
  136508. minYaw?: number;
  136509. maxPitch?: number;
  136510. minPitch?: number;
  136511. slerpAmount?: number;
  136512. upAxis?: Vector3;
  136513. upAxisSpace?: Space;
  136514. yawAxis?: Vector3;
  136515. pitchAxis?: Vector3;
  136516. adjustYaw?: number;
  136517. adjustPitch?: number;
  136518. adjustRoll?: number;
  136519. });
  136520. /**
  136521. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  136522. */
  136523. update(): void;
  136524. private _getAngleDiff;
  136525. private _getAngleBetween;
  136526. private _isAngleBetween;
  136527. }
  136528. }
  136529. declare module BABYLON {
  136530. /**
  136531. * Manage the gamepad inputs to control an arc rotate camera.
  136532. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136533. */
  136534. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  136535. /**
  136536. * Defines the camera the input is attached to.
  136537. */
  136538. camera: ArcRotateCamera;
  136539. /**
  136540. * Defines the gamepad the input is gathering event from.
  136541. */
  136542. gamepad: Nullable<Gamepad>;
  136543. /**
  136544. * Defines the gamepad rotation sensiblity.
  136545. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  136546. */
  136547. gamepadRotationSensibility: number;
  136548. /**
  136549. * Defines the gamepad move sensiblity.
  136550. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  136551. */
  136552. gamepadMoveSensibility: number;
  136553. private _yAxisScale;
  136554. /**
  136555. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  136556. */
  136557. get invertYAxis(): boolean;
  136558. set invertYAxis(value: boolean);
  136559. private _onGamepadConnectedObserver;
  136560. private _onGamepadDisconnectedObserver;
  136561. /**
  136562. * Attach the input controls to a specific dom element to get the input from.
  136563. */
  136564. attachControl(): void;
  136565. /**
  136566. * Detach the current controls from the specified dom element.
  136567. */
  136568. detachControl(): void;
  136569. /**
  136570. * Update the current camera state depending on the inputs that have been used this frame.
  136571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136572. */
  136573. checkInputs(): void;
  136574. /**
  136575. * Gets the class name of the current intput.
  136576. * @returns the class name
  136577. */
  136578. getClassName(): string;
  136579. /**
  136580. * Get the friendly name associated with the input class.
  136581. * @returns the input friendly name
  136582. */
  136583. getSimpleName(): string;
  136584. }
  136585. }
  136586. declare module BABYLON {
  136587. interface ArcRotateCameraInputsManager {
  136588. /**
  136589. * Add orientation input support to the input manager.
  136590. * @returns the current input manager
  136591. */
  136592. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  136593. }
  136594. /**
  136595. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  136596. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136597. */
  136598. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  136599. /**
  136600. * Defines the camera the input is attached to.
  136601. */
  136602. camera: ArcRotateCamera;
  136603. /**
  136604. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  136605. */
  136606. alphaCorrection: number;
  136607. /**
  136608. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  136609. */
  136610. gammaCorrection: number;
  136611. private _alpha;
  136612. private _gamma;
  136613. private _dirty;
  136614. private _deviceOrientationHandler;
  136615. /**
  136616. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  136617. */
  136618. constructor();
  136619. /**
  136620. * Attach the input controls to a specific dom element to get the input from.
  136621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136622. */
  136623. attachControl(noPreventDefault?: boolean): void;
  136624. /** @hidden */
  136625. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  136626. /**
  136627. * Update the current camera state depending on the inputs that have been used this frame.
  136628. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136629. */
  136630. checkInputs(): void;
  136631. /**
  136632. * Detach the current controls from the specified dom element.
  136633. */
  136634. detachControl(): void;
  136635. /**
  136636. * Gets the class name of the current input.
  136637. * @returns the class name
  136638. */
  136639. getClassName(): string;
  136640. /**
  136641. * Get the friendly name associated with the input class.
  136642. * @returns the input friendly name
  136643. */
  136644. getSimpleName(): string;
  136645. }
  136646. }
  136647. declare module BABYLON {
  136648. /**
  136649. * Listen to mouse events to control the camera.
  136650. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136651. */
  136652. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  136653. /**
  136654. * Defines the camera the input is attached to.
  136655. */
  136656. camera: FlyCamera;
  136657. /**
  136658. * Defines if touch is enabled. (Default is true.)
  136659. */
  136660. touchEnabled: boolean;
  136661. /**
  136662. * Defines the buttons associated with the input to handle camera rotation.
  136663. */
  136664. buttons: number[];
  136665. /**
  136666. * Assign buttons for Yaw control.
  136667. */
  136668. buttonsYaw: number[];
  136669. /**
  136670. * Assign buttons for Pitch control.
  136671. */
  136672. buttonsPitch: number[];
  136673. /**
  136674. * Assign buttons for Roll control.
  136675. */
  136676. buttonsRoll: number[];
  136677. /**
  136678. * Detect if any button is being pressed while mouse is moved.
  136679. * -1 = Mouse locked.
  136680. * 0 = Left button.
  136681. * 1 = Middle Button.
  136682. * 2 = Right Button.
  136683. */
  136684. activeButton: number;
  136685. /**
  136686. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  136687. * Higher values reduce its sensitivity.
  136688. */
  136689. angularSensibility: number;
  136690. private _observer;
  136691. private _rollObserver;
  136692. private previousPosition;
  136693. private noPreventDefault;
  136694. private element;
  136695. /**
  136696. * Listen to mouse events to control the camera.
  136697. * @param touchEnabled Define if touch is enabled. (Default is true.)
  136698. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136699. */
  136700. constructor(touchEnabled?: boolean);
  136701. /**
  136702. * Attach the mouse control to the HTML DOM element.
  136703. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  136704. */
  136705. attachControl(noPreventDefault?: boolean): void;
  136706. /**
  136707. * Detach the current controls from the specified dom element.
  136708. */
  136709. detachControl(): void;
  136710. /**
  136711. * Gets the class name of the current input.
  136712. * @returns the class name.
  136713. */
  136714. getClassName(): string;
  136715. /**
  136716. * Get the friendly name associated with the input class.
  136717. * @returns the input's friendly name.
  136718. */
  136719. getSimpleName(): string;
  136720. private _pointerInput;
  136721. private _onMouseMove;
  136722. /**
  136723. * Rotate camera by mouse offset.
  136724. */
  136725. private rotateCamera;
  136726. }
  136727. }
  136728. declare module BABYLON {
  136729. /**
  136730. * Default Inputs manager for the FlyCamera.
  136731. * It groups all the default supported inputs for ease of use.
  136732. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136733. */
  136734. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  136735. /**
  136736. * Instantiates a new FlyCameraInputsManager.
  136737. * @param camera Defines the camera the inputs belong to.
  136738. */
  136739. constructor(camera: FlyCamera);
  136740. /**
  136741. * Add keyboard input support to the input manager.
  136742. * @returns the new FlyCameraKeyboardMoveInput().
  136743. */
  136744. addKeyboard(): FlyCameraInputsManager;
  136745. /**
  136746. * Add mouse input support to the input manager.
  136747. * @param touchEnabled Enable touch screen support.
  136748. * @returns the new FlyCameraMouseInput().
  136749. */
  136750. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  136751. }
  136752. }
  136753. declare module BABYLON {
  136754. /**
  136755. * This is a flying camera, designed for 3D movement and rotation in all directions,
  136756. * such as in a 3D Space Shooter or a Flight Simulator.
  136757. */
  136758. export class FlyCamera extends TargetCamera {
  136759. /**
  136760. * Define the collision ellipsoid of the camera.
  136761. * This is helpful for simulating a camera body, like a player's body.
  136762. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  136763. */
  136764. ellipsoid: Vector3;
  136765. /**
  136766. * Define an offset for the position of the ellipsoid around the camera.
  136767. * This can be helpful if the camera is attached away from the player's body center,
  136768. * such as at its head.
  136769. */
  136770. ellipsoidOffset: Vector3;
  136771. /**
  136772. * Enable or disable collisions of the camera with the rest of the scene objects.
  136773. */
  136774. checkCollisions: boolean;
  136775. /**
  136776. * Enable or disable gravity on the camera.
  136777. */
  136778. applyGravity: boolean;
  136779. /**
  136780. * Define the current direction the camera is moving to.
  136781. */
  136782. cameraDirection: Vector3;
  136783. /**
  136784. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  136785. * This overrides and empties cameraRotation.
  136786. */
  136787. rotationQuaternion: Quaternion;
  136788. /**
  136789. * Track Roll to maintain the wanted Rolling when looking around.
  136790. */
  136791. _trackRoll: number;
  136792. /**
  136793. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  136794. */
  136795. rollCorrect: number;
  136796. /**
  136797. * Mimic a banked turn, Rolling the camera when Yawing.
  136798. * It's recommended to use rollCorrect = 10 for faster banking correction.
  136799. */
  136800. bankedTurn: boolean;
  136801. /**
  136802. * Limit in radians for how much Roll banking will add. (Default: 90°)
  136803. */
  136804. bankedTurnLimit: number;
  136805. /**
  136806. * Value of 0 disables the banked Roll.
  136807. * Value of 1 is equal to the Yaw angle in radians.
  136808. */
  136809. bankedTurnMultiplier: number;
  136810. /**
  136811. * The inputs manager loads all the input sources, such as keyboard and mouse.
  136812. */
  136813. inputs: FlyCameraInputsManager;
  136814. /**
  136815. * Gets the input sensibility for mouse input.
  136816. * Higher values reduce sensitivity.
  136817. */
  136818. get angularSensibility(): number;
  136819. /**
  136820. * Sets the input sensibility for a mouse input.
  136821. * Higher values reduce sensitivity.
  136822. */
  136823. set angularSensibility(value: number);
  136824. /**
  136825. * Get the keys for camera movement forward.
  136826. */
  136827. get keysForward(): number[];
  136828. /**
  136829. * Set the keys for camera movement forward.
  136830. */
  136831. set keysForward(value: number[]);
  136832. /**
  136833. * Get the keys for camera movement backward.
  136834. */
  136835. get keysBackward(): number[];
  136836. set keysBackward(value: number[]);
  136837. /**
  136838. * Get the keys for camera movement up.
  136839. */
  136840. get keysUp(): number[];
  136841. /**
  136842. * Set the keys for camera movement up.
  136843. */
  136844. set keysUp(value: number[]);
  136845. /**
  136846. * Get the keys for camera movement down.
  136847. */
  136848. get keysDown(): number[];
  136849. /**
  136850. * Set the keys for camera movement down.
  136851. */
  136852. set keysDown(value: number[]);
  136853. /**
  136854. * Get the keys for camera movement left.
  136855. */
  136856. get keysLeft(): number[];
  136857. /**
  136858. * Set the keys for camera movement left.
  136859. */
  136860. set keysLeft(value: number[]);
  136861. /**
  136862. * Set the keys for camera movement right.
  136863. */
  136864. get keysRight(): number[];
  136865. /**
  136866. * Set the keys for camera movement right.
  136867. */
  136868. set keysRight(value: number[]);
  136869. /**
  136870. * Event raised when the camera collides with a mesh in the scene.
  136871. */
  136872. onCollide: (collidedMesh: AbstractMesh) => void;
  136873. private _collider;
  136874. private _needMoveForGravity;
  136875. private _oldPosition;
  136876. private _diffPosition;
  136877. private _newPosition;
  136878. /** @hidden */
  136879. _localDirection: Vector3;
  136880. /** @hidden */
  136881. _transformedDirection: Vector3;
  136882. /**
  136883. * Instantiates a FlyCamera.
  136884. * This is a flying camera, designed for 3D movement and rotation in all directions,
  136885. * such as in a 3D Space Shooter or a Flight Simulator.
  136886. * @param name Define the name of the camera in the scene.
  136887. * @param position Define the starting position of the camera in the scene.
  136888. * @param scene Define the scene the camera belongs to.
  136889. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  136890. */
  136891. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  136892. /**
  136893. * Attach the input controls to a specific dom element to get the input from.
  136894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136895. */
  136896. attachControl(noPreventDefault?: boolean): void;
  136897. /**
  136898. * Detach a control from the HTML DOM element.
  136899. * The camera will stop reacting to that input.
  136900. */
  136901. detachControl(): void;
  136902. private _collisionMask;
  136903. /**
  136904. * Get the mask that the camera ignores in collision events.
  136905. */
  136906. get collisionMask(): number;
  136907. /**
  136908. * Set the mask that the camera ignores in collision events.
  136909. */
  136910. set collisionMask(mask: number);
  136911. /** @hidden */
  136912. _collideWithWorld(displacement: Vector3): void;
  136913. /** @hidden */
  136914. private _onCollisionPositionChange;
  136915. /** @hidden */
  136916. _checkInputs(): void;
  136917. /** @hidden */
  136918. _decideIfNeedsToMove(): boolean;
  136919. /** @hidden */
  136920. _updatePosition(): void;
  136921. /**
  136922. * Restore the Roll to its target value at the rate specified.
  136923. * @param rate - Higher means slower restoring.
  136924. * @hidden
  136925. */
  136926. restoreRoll(rate: number): void;
  136927. /**
  136928. * Destroy the camera and release the current resources held by it.
  136929. */
  136930. dispose(): void;
  136931. /**
  136932. * Get the current object class name.
  136933. * @returns the class name.
  136934. */
  136935. getClassName(): string;
  136936. }
  136937. }
  136938. declare module BABYLON {
  136939. /**
  136940. * Listen to keyboard events to control the camera.
  136941. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136942. */
  136943. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  136944. /**
  136945. * Defines the camera the input is attached to.
  136946. */
  136947. camera: FlyCamera;
  136948. /**
  136949. * The list of keyboard keys used to control the forward move of the camera.
  136950. */
  136951. keysForward: number[];
  136952. /**
  136953. * The list of keyboard keys used to control the backward move of the camera.
  136954. */
  136955. keysBackward: number[];
  136956. /**
  136957. * The list of keyboard keys used to control the forward move of the camera.
  136958. */
  136959. keysUp: number[];
  136960. /**
  136961. * The list of keyboard keys used to control the backward move of the camera.
  136962. */
  136963. keysDown: number[];
  136964. /**
  136965. * The list of keyboard keys used to control the right strafe move of the camera.
  136966. */
  136967. keysRight: number[];
  136968. /**
  136969. * The list of keyboard keys used to control the left strafe move of the camera.
  136970. */
  136971. keysLeft: number[];
  136972. private _keys;
  136973. private _onCanvasBlurObserver;
  136974. private _onKeyboardObserver;
  136975. private _engine;
  136976. private _scene;
  136977. /**
  136978. * Attach the input controls to a specific dom element to get the input from.
  136979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  136980. */
  136981. attachControl(noPreventDefault?: boolean): void;
  136982. /**
  136983. * Detach the current controls from the specified dom element.
  136984. */
  136985. detachControl(): void;
  136986. /**
  136987. * Gets the class name of the current intput.
  136988. * @returns the class name
  136989. */
  136990. getClassName(): string;
  136991. /** @hidden */
  136992. _onLostFocus(e: FocusEvent): void;
  136993. /**
  136994. * Get the friendly name associated with the input class.
  136995. * @returns the input friendly name
  136996. */
  136997. getSimpleName(): string;
  136998. /**
  136999. * Update the current camera state depending on the inputs that have been used this frame.
  137000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  137001. */
  137002. checkInputs(): void;
  137003. }
  137004. }
  137005. declare module BABYLON {
  137006. /**
  137007. * Manage the mouse wheel inputs to control a follow camera.
  137008. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  137009. */
  137010. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  137011. /**
  137012. * Defines the camera the input is attached to.
  137013. */
  137014. camera: FollowCamera;
  137015. /**
  137016. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  137017. */
  137018. axisControlRadius: boolean;
  137019. /**
  137020. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  137021. */
  137022. axisControlHeight: boolean;
  137023. /**
  137024. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  137025. */
  137026. axisControlRotation: boolean;
  137027. /**
  137028. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  137029. * relation to mouseWheel events.
  137030. */
  137031. wheelPrecision: number;
  137032. /**
  137033. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  137034. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  137035. */
  137036. wheelDeltaPercentage: number;
  137037. private _wheel;
  137038. private _observer;
  137039. /**
  137040. * Attach the input controls to a specific dom element to get the input from.
  137041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  137042. */
  137043. attachControl(noPreventDefault?: boolean): void;
  137044. /**
  137045. * Detach the current controls from the specified dom element.
  137046. */
  137047. detachControl(): void;
  137048. /**
  137049. * Gets the class name of the current input.
  137050. * @returns the class name
  137051. */
  137052. getClassName(): string;
  137053. /**
  137054. * Get the friendly name associated with the input class.
  137055. * @returns the input friendly name
  137056. */
  137057. getSimpleName(): string;
  137058. }
  137059. }
  137060. declare module BABYLON {
  137061. /**
  137062. * Manage the pointers inputs to control an follow camera.
  137063. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  137064. */
  137065. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  137066. /**
  137067. * Defines the camera the input is attached to.
  137068. */
  137069. camera: FollowCamera;
  137070. /**
  137071. * Gets the class name of the current input.
  137072. * @returns the class name
  137073. */
  137074. getClassName(): string;
  137075. /**
  137076. * Defines the pointer angular sensibility along the X axis or how fast is
  137077. * the camera rotating.
  137078. * A negative number will reverse the axis direction.
  137079. */
  137080. angularSensibilityX: number;
  137081. /**
  137082. * Defines the pointer angular sensibility along the Y axis or how fast is
  137083. * the camera rotating.
  137084. * A negative number will reverse the axis direction.
  137085. */
  137086. angularSensibilityY: number;
  137087. /**
  137088. * Defines the pointer pinch precision or how fast is the camera zooming.
  137089. * A negative number will reverse the axis direction.
  137090. */
  137091. pinchPrecision: number;
  137092. /**
  137093. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  137094. * from 0.
  137095. * It defines the percentage of current camera.radius to use as delta when
  137096. * pinch zoom is used.
  137097. */
  137098. pinchDeltaPercentage: number;
  137099. /**
  137100. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  137101. */
  137102. axisXControlRadius: boolean;
  137103. /**
  137104. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  137105. */
  137106. axisXControlHeight: boolean;
  137107. /**
  137108. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  137109. */
  137110. axisXControlRotation: boolean;
  137111. /**
  137112. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  137113. */
  137114. axisYControlRadius: boolean;
  137115. /**
  137116. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  137117. */
  137118. axisYControlHeight: boolean;
  137119. /**
  137120. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  137121. */
  137122. axisYControlRotation: boolean;
  137123. /**
  137124. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  137125. */
  137126. axisPinchControlRadius: boolean;
  137127. /**
  137128. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  137129. */
  137130. axisPinchControlHeight: boolean;
  137131. /**
  137132. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  137133. */
  137134. axisPinchControlRotation: boolean;
  137135. /**
  137136. * Log error messages if basic misconfiguration has occurred.
  137137. */
  137138. warningEnable: boolean;
  137139. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  137140. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  137141. private _warningCounter;
  137142. private _warning;
  137143. }
  137144. }
  137145. declare module BABYLON {
  137146. /**
  137147. * Default Inputs manager for the FollowCamera.
  137148. * It groups all the default supported inputs for ease of use.
  137149. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  137150. */
  137151. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  137152. /**
  137153. * Instantiates a new FollowCameraInputsManager.
  137154. * @param camera Defines the camera the inputs belong to
  137155. */
  137156. constructor(camera: FollowCamera);
  137157. /**
  137158. * Add keyboard input support to the input manager.
  137159. * @returns the current input manager
  137160. */
  137161. addKeyboard(): FollowCameraInputsManager;
  137162. /**
  137163. * Add mouse wheel input support to the input manager.
  137164. * @returns the current input manager
  137165. */
  137166. addMouseWheel(): FollowCameraInputsManager;
  137167. /**
  137168. * Add pointers input support to the input manager.
  137169. * @returns the current input manager
  137170. */
  137171. addPointers(): FollowCameraInputsManager;
  137172. /**
  137173. * Add orientation input support to the input manager.
  137174. * @returns the current input manager
  137175. */
  137176. addVRDeviceOrientation(): FollowCameraInputsManager;
  137177. }
  137178. }
  137179. declare module BABYLON {
  137180. /**
  137181. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  137182. * an arc rotate version arcFollowCamera are available.
  137183. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  137184. */
  137185. export class FollowCamera extends TargetCamera {
  137186. /**
  137187. * Distance the follow camera should follow an object at
  137188. */
  137189. radius: number;
  137190. /**
  137191. * Minimum allowed distance of the camera to the axis of rotation
  137192. * (The camera can not get closer).
  137193. * This can help limiting how the Camera is able to move in the scene.
  137194. */
  137195. lowerRadiusLimit: Nullable<number>;
  137196. /**
  137197. * Maximum allowed distance of the camera to the axis of rotation
  137198. * (The camera can not get further).
  137199. * This can help limiting how the Camera is able to move in the scene.
  137200. */
  137201. upperRadiusLimit: Nullable<number>;
  137202. /**
  137203. * Define a rotation offset between the camera and the object it follows
  137204. */
  137205. rotationOffset: number;
  137206. /**
  137207. * Minimum allowed angle to camera position relative to target object.
  137208. * This can help limiting how the Camera is able to move in the scene.
  137209. */
  137210. lowerRotationOffsetLimit: Nullable<number>;
  137211. /**
  137212. * Maximum allowed angle to camera position relative to target object.
  137213. * This can help limiting how the Camera is able to move in the scene.
  137214. */
  137215. upperRotationOffsetLimit: Nullable<number>;
  137216. /**
  137217. * Define a height offset between the camera and the object it follows.
  137218. * It can help following an object from the top (like a car chasing a plane)
  137219. */
  137220. heightOffset: number;
  137221. /**
  137222. * Minimum allowed height of camera position relative to target object.
  137223. * This can help limiting how the Camera is able to move in the scene.
  137224. */
  137225. lowerHeightOffsetLimit: Nullable<number>;
  137226. /**
  137227. * Maximum allowed height of camera position relative to target object.
  137228. * This can help limiting how the Camera is able to move in the scene.
  137229. */
  137230. upperHeightOffsetLimit: Nullable<number>;
  137231. /**
  137232. * Define how fast the camera can accelerate to follow it s target.
  137233. */
  137234. cameraAcceleration: number;
  137235. /**
  137236. * Define the speed limit of the camera following an object.
  137237. */
  137238. maxCameraSpeed: number;
  137239. /**
  137240. * Define the target of the camera.
  137241. */
  137242. lockedTarget: Nullable<AbstractMesh>;
  137243. /**
  137244. * Defines the input associated with the camera.
  137245. */
  137246. inputs: FollowCameraInputsManager;
  137247. /**
  137248. * Instantiates the follow camera.
  137249. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  137250. * @param name Define the name of the camera in the scene
  137251. * @param position Define the position of the camera
  137252. * @param scene Define the scene the camera belong to
  137253. * @param lockedTarget Define the target of the camera
  137254. */
  137255. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  137256. private _follow;
  137257. /**
  137258. * Attach the input controls to a specific dom element to get the input from.
  137259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  137260. */
  137261. attachControl(noPreventDefault?: boolean): void;
  137262. /**
  137263. * Detach the current controls from the specified dom element.
  137264. */
  137265. detachControl(): void;
  137266. /** @hidden */
  137267. _checkInputs(): void;
  137268. private _checkLimits;
  137269. /**
  137270. * Gets the camera class name.
  137271. * @returns the class name
  137272. */
  137273. getClassName(): string;
  137274. }
  137275. /**
  137276. * Arc Rotate version of the follow camera.
  137277. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  137278. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  137279. */
  137280. export class ArcFollowCamera extends TargetCamera {
  137281. /** The longitudinal angle of the camera */
  137282. alpha: number;
  137283. /** The latitudinal angle of the camera */
  137284. beta: number;
  137285. /** The radius of the camera from its target */
  137286. radius: number;
  137287. private _cartesianCoordinates;
  137288. /** Define the camera target (the mesh it should follow) */
  137289. private _meshTarget;
  137290. /**
  137291. * Instantiates a new ArcFollowCamera
  137292. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  137293. * @param name Define the name of the camera
  137294. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  137295. * @param beta Define the rotation angle of the camera around the elevation axis
  137296. * @param radius Define the radius of the camera from its target point
  137297. * @param target Define the target of the camera
  137298. * @param scene Define the scene the camera belongs to
  137299. */
  137300. constructor(name: string,
  137301. /** The longitudinal angle of the camera */
  137302. alpha: number,
  137303. /** The latitudinal angle of the camera */
  137304. beta: number,
  137305. /** The radius of the camera from its target */
  137306. radius: number,
  137307. /** Define the camera target (the mesh it should follow) */
  137308. target: Nullable<AbstractMesh>, scene: Scene);
  137309. private _follow;
  137310. /** @hidden */
  137311. _checkInputs(): void;
  137312. /**
  137313. * Returns the class name of the object.
  137314. * It is mostly used internally for serialization purposes.
  137315. */
  137316. getClassName(): string;
  137317. }
  137318. }
  137319. declare module BABYLON {
  137320. /**
  137321. * Manage the keyboard inputs to control the movement of a follow camera.
  137322. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  137323. */
  137324. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  137325. /**
  137326. * Defines the camera the input is attached to.
  137327. */
  137328. camera: FollowCamera;
  137329. /**
  137330. * Defines the list of key codes associated with the up action (increase heightOffset)
  137331. */
  137332. keysHeightOffsetIncr: number[];
  137333. /**
  137334. * Defines the list of key codes associated with the down action (decrease heightOffset)
  137335. */
  137336. keysHeightOffsetDecr: number[];
  137337. /**
  137338. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  137339. */
  137340. keysHeightOffsetModifierAlt: boolean;
  137341. /**
  137342. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  137343. */
  137344. keysHeightOffsetModifierCtrl: boolean;
  137345. /**
  137346. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  137347. */
  137348. keysHeightOffsetModifierShift: boolean;
  137349. /**
  137350. * Defines the list of key codes associated with the left action (increase rotationOffset)
  137351. */
  137352. keysRotationOffsetIncr: number[];
  137353. /**
  137354. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  137355. */
  137356. keysRotationOffsetDecr: number[];
  137357. /**
  137358. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  137359. */
  137360. keysRotationOffsetModifierAlt: boolean;
  137361. /**
  137362. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  137363. */
  137364. keysRotationOffsetModifierCtrl: boolean;
  137365. /**
  137366. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  137367. */
  137368. keysRotationOffsetModifierShift: boolean;
  137369. /**
  137370. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  137371. */
  137372. keysRadiusIncr: number[];
  137373. /**
  137374. * Defines the list of key codes associated with the zoom-out action (increase radius)
  137375. */
  137376. keysRadiusDecr: number[];
  137377. /**
  137378. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  137379. */
  137380. keysRadiusModifierAlt: boolean;
  137381. /**
  137382. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  137383. */
  137384. keysRadiusModifierCtrl: boolean;
  137385. /**
  137386. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  137387. */
  137388. keysRadiusModifierShift: boolean;
  137389. /**
  137390. * Defines the rate of change of heightOffset.
  137391. */
  137392. heightSensibility: number;
  137393. /**
  137394. * Defines the rate of change of rotationOffset.
  137395. */
  137396. rotationSensibility: number;
  137397. /**
  137398. * Defines the rate of change of radius.
  137399. */
  137400. radiusSensibility: number;
  137401. private _keys;
  137402. private _ctrlPressed;
  137403. private _altPressed;
  137404. private _shiftPressed;
  137405. private _onCanvasBlurObserver;
  137406. private _onKeyboardObserver;
  137407. private _engine;
  137408. private _scene;
  137409. /**
  137410. * Attach the input controls to a specific dom element to get the input from.
  137411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  137412. */
  137413. attachControl(noPreventDefault?: boolean): void;
  137414. /**
  137415. * Detach the current controls from the specified dom element.
  137416. */
  137417. detachControl(): void;
  137418. /**
  137419. * Update the current camera state depending on the inputs that have been used this frame.
  137420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  137421. */
  137422. checkInputs(): void;
  137423. /**
  137424. * Gets the class name of the current input.
  137425. * @returns the class name
  137426. */
  137427. getClassName(): string;
  137428. /**
  137429. * Get the friendly name associated with the input class.
  137430. * @returns the input friendly name
  137431. */
  137432. getSimpleName(): string;
  137433. /**
  137434. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  137435. * allow modification of the heightOffset value.
  137436. */
  137437. private _modifierHeightOffset;
  137438. /**
  137439. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  137440. * allow modification of the rotationOffset value.
  137441. */
  137442. private _modifierRotationOffset;
  137443. /**
  137444. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  137445. * allow modification of the radius value.
  137446. */
  137447. private _modifierRadius;
  137448. }
  137449. }
  137450. declare module BABYLON {
  137451. interface FreeCameraInputsManager {
  137452. /**
  137453. * @hidden
  137454. */
  137455. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  137456. /**
  137457. * Add orientation input support to the input manager.
  137458. * @returns the current input manager
  137459. */
  137460. addDeviceOrientation(): FreeCameraInputsManager;
  137461. }
  137462. /**
  137463. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  137464. * Screen rotation is taken into account.
  137465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  137466. */
  137467. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  137468. private _camera;
  137469. private _screenOrientationAngle;
  137470. private _constantTranform;
  137471. private _screenQuaternion;
  137472. private _alpha;
  137473. private _beta;
  137474. private _gamma;
  137475. /**
  137476. * Can be used to detect if a device orientation sensor is available on a device
  137477. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  137478. * @returns a promise that will resolve on orientation change
  137479. */
  137480. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  137481. /**
  137482. * @hidden
  137483. */
  137484. _onDeviceOrientationChangedObservable: Observable<void>;
  137485. /**
  137486. * Instantiates a new input
  137487. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  137488. */
  137489. constructor();
  137490. /**
  137491. * Define the camera controlled by the input.
  137492. */
  137493. get camera(): FreeCamera;
  137494. set camera(camera: FreeCamera);
  137495. /**
  137496. * Attach the input controls to a specific dom element to get the input from.
  137497. */
  137498. attachControl(): void;
  137499. private _orientationChanged;
  137500. private _deviceOrientation;
  137501. /**
  137502. * Detach the current controls from the specified dom element.
  137503. */
  137504. detachControl(): void;
  137505. /**
  137506. * Update the current camera state depending on the inputs that have been used this frame.
  137507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  137508. */
  137509. checkInputs(): void;
  137510. /**
  137511. * Gets the class name of the current input.
  137512. * @returns the class name
  137513. */
  137514. getClassName(): string;
  137515. /**
  137516. * Get the friendly name associated with the input class.
  137517. * @returns the input friendly name
  137518. */
  137519. getSimpleName(): string;
  137520. }
  137521. }
  137522. declare module BABYLON {
  137523. /**
  137524. * Manage the gamepad inputs to control a free camera.
  137525. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  137526. */
  137527. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  137528. /**
  137529. * Define the camera the input is attached to.
  137530. */
  137531. camera: FreeCamera;
  137532. /**
  137533. * Define the Gamepad controlling the input
  137534. */
  137535. gamepad: Nullable<Gamepad>;
  137536. /**
  137537. * Defines the gamepad rotation sensiblity.
  137538. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  137539. */
  137540. gamepadAngularSensibility: number;
  137541. /**
  137542. * Defines the gamepad move sensiblity.
  137543. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  137544. */
  137545. gamepadMoveSensibility: number;
  137546. private _yAxisScale;
  137547. /**
  137548. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  137549. */
  137550. get invertYAxis(): boolean;
  137551. set invertYAxis(value: boolean);
  137552. private _onGamepadConnectedObserver;
  137553. private _onGamepadDisconnectedObserver;
  137554. private _cameraTransform;
  137555. private _deltaTransform;
  137556. private _vector3;
  137557. private _vector2;
  137558. /**
  137559. * Attach the input controls to a specific dom element to get the input from.
  137560. */
  137561. attachControl(): void;
  137562. /**
  137563. * Detach the current controls from the specified dom element.
  137564. */
  137565. detachControl(): void;
  137566. /**
  137567. * Update the current camera state depending on the inputs that have been used this frame.
  137568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  137569. */
  137570. checkInputs(): void;
  137571. /**
  137572. * Gets the class name of the current input.
  137573. * @returns the class name
  137574. */
  137575. getClassName(): string;
  137576. /**
  137577. * Get the friendly name associated with the input class.
  137578. * @returns the input friendly name
  137579. */
  137580. getSimpleName(): string;
  137581. }
  137582. }
  137583. declare module BABYLON {
  137584. /**
  137585. * Defines the potential axis of a Joystick
  137586. */
  137587. export enum JoystickAxis {
  137588. /** X axis */
  137589. X = 0,
  137590. /** Y axis */
  137591. Y = 1,
  137592. /** Z axis */
  137593. Z = 2
  137594. }
  137595. /**
  137596. * Represents the different customization options available
  137597. * for VirtualJoystick
  137598. */
  137599. interface VirtualJoystickCustomizations {
  137600. /**
  137601. * Size of the joystick's puck
  137602. */
  137603. puckSize: number;
  137604. /**
  137605. * Size of the joystick's container
  137606. */
  137607. containerSize: number;
  137608. /**
  137609. * Color of the joystick && puck
  137610. */
  137611. color: string;
  137612. /**
  137613. * Image URL for the joystick's puck
  137614. */
  137615. puckImage?: string;
  137616. /**
  137617. * Image URL for the joystick's container
  137618. */
  137619. containerImage?: string;
  137620. /**
  137621. * Defines the unmoving position of the joystick container
  137622. */
  137623. position?: {
  137624. x: number;
  137625. y: number;
  137626. };
  137627. /**
  137628. * Defines whether or not the joystick container is always visible
  137629. */
  137630. alwaysVisible: boolean;
  137631. /**
  137632. * Defines whether or not to limit the movement of the puck to the joystick's container
  137633. */
  137634. limitToContainer: boolean;
  137635. }
  137636. /**
  137637. * Class used to define virtual joystick (used in touch mode)
  137638. */
  137639. export class VirtualJoystick {
  137640. /**
  137641. * Gets or sets a boolean indicating that left and right values must be inverted
  137642. */
  137643. reverseLeftRight: boolean;
  137644. /**
  137645. * Gets or sets a boolean indicating that up and down values must be inverted
  137646. */
  137647. reverseUpDown: boolean;
  137648. /**
  137649. * Gets the offset value for the position (ie. the change of the position value)
  137650. */
  137651. deltaPosition: Vector3;
  137652. /**
  137653. * Gets a boolean indicating if the virtual joystick was pressed
  137654. */
  137655. pressed: boolean;
  137656. /**
  137657. * Canvas the virtual joystick will render onto, default z-index of this is 5
  137658. */
  137659. static Canvas: Nullable<HTMLCanvasElement>;
  137660. /**
  137661. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  137662. */
  137663. limitToContainer: boolean;
  137664. private static _globalJoystickIndex;
  137665. private static _alwaysVisibleSticks;
  137666. private static vjCanvasContext;
  137667. private static vjCanvasWidth;
  137668. private static vjCanvasHeight;
  137669. private static halfWidth;
  137670. private static _GetDefaultOptions;
  137671. private _action;
  137672. private _axisTargetedByLeftAndRight;
  137673. private _axisTargetedByUpAndDown;
  137674. private _joystickSensibility;
  137675. private _inversedSensibility;
  137676. private _joystickPointerID;
  137677. private _joystickColor;
  137678. private _joystickPointerPos;
  137679. private _joystickPreviousPointerPos;
  137680. private _joystickPointerStartPos;
  137681. private _deltaJoystickVector;
  137682. private _leftJoystick;
  137683. private _touches;
  137684. private _joystickPosition;
  137685. private _alwaysVisible;
  137686. private _puckImage;
  137687. private _containerImage;
  137688. private _joystickPuckSize;
  137689. private _joystickContainerSize;
  137690. private _clearPuckSize;
  137691. private _clearContainerSize;
  137692. private _clearPuckSizeOffset;
  137693. private _clearContainerSizeOffset;
  137694. private _onPointerDownHandlerRef;
  137695. private _onPointerMoveHandlerRef;
  137696. private _onPointerUpHandlerRef;
  137697. private _onResize;
  137698. /**
  137699. * Creates a new virtual joystick
  137700. * @param leftJoystick defines that the joystick is for left hand (false by default)
  137701. * @param customizations Defines the options we want to customize the VirtualJoystick
  137702. */
  137703. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  137704. /**
  137705. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  137706. * @param newJoystickSensibility defines the new sensibility
  137707. */
  137708. setJoystickSensibility(newJoystickSensibility: number): void;
  137709. private _onPointerDown;
  137710. private _onPointerMove;
  137711. private _onPointerUp;
  137712. /**
  137713. * Change the color of the virtual joystick
  137714. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  137715. */
  137716. setJoystickColor(newColor: string): void;
  137717. /**
  137718. * Size of the joystick's container
  137719. */
  137720. set containerSize(newSize: number);
  137721. get containerSize(): number;
  137722. /**
  137723. * Size of the joystick's puck
  137724. */
  137725. set puckSize(newSize: number);
  137726. get puckSize(): number;
  137727. /**
  137728. * Clears the set position of the joystick
  137729. */
  137730. clearPosition(): void;
  137731. /**
  137732. * Defines whether or not the joystick container is always visible
  137733. */
  137734. set alwaysVisible(value: boolean);
  137735. get alwaysVisible(): boolean;
  137736. /**
  137737. * Sets the constant position of the Joystick container
  137738. * @param x X axis coordinate
  137739. * @param y Y axis coordinate
  137740. */
  137741. setPosition(x: number, y: number): void;
  137742. /**
  137743. * Defines a callback to call when the joystick is touched
  137744. * @param action defines the callback
  137745. */
  137746. setActionOnTouch(action: () => any): void;
  137747. /**
  137748. * Defines which axis you'd like to control for left & right
  137749. * @param axis defines the axis to use
  137750. */
  137751. setAxisForLeftRight(axis: JoystickAxis): void;
  137752. /**
  137753. * Defines which axis you'd like to control for up & down
  137754. * @param axis defines the axis to use
  137755. */
  137756. setAxisForUpDown(axis: JoystickAxis): void;
  137757. /**
  137758. * Clears the canvas from the previous puck / container draw
  137759. */
  137760. private _clearPreviousDraw;
  137761. /**
  137762. * Loads `urlPath` to be used for the container's image
  137763. * @param urlPath defines the urlPath of an image to use
  137764. */
  137765. setContainerImage(urlPath: string): void;
  137766. /**
  137767. * Loads `urlPath` to be used for the puck's image
  137768. * @param urlPath defines the urlPath of an image to use
  137769. */
  137770. setPuckImage(urlPath: string): void;
  137771. /**
  137772. * Draws the Virtual Joystick's container
  137773. */
  137774. private _drawContainer;
  137775. /**
  137776. * Draws the Virtual Joystick's puck
  137777. */
  137778. private _drawPuck;
  137779. private _drawVirtualJoystick;
  137780. /**
  137781. * Release internal HTML canvas
  137782. */
  137783. releaseCanvas(): void;
  137784. }
  137785. }
  137786. declare module BABYLON {
  137787. interface FreeCameraInputsManager {
  137788. /**
  137789. * Add virtual joystick input support to the input manager.
  137790. * @returns the current input manager
  137791. */
  137792. addVirtualJoystick(): FreeCameraInputsManager;
  137793. }
  137794. /**
  137795. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  137796. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  137797. */
  137798. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  137799. /**
  137800. * Defines the camera the input is attached to.
  137801. */
  137802. camera: FreeCamera;
  137803. private _leftjoystick;
  137804. private _rightjoystick;
  137805. /**
  137806. * Gets the left stick of the virtual joystick.
  137807. * @returns The virtual Joystick
  137808. */
  137809. getLeftJoystick(): VirtualJoystick;
  137810. /**
  137811. * Gets the right stick of the virtual joystick.
  137812. * @returns The virtual Joystick
  137813. */
  137814. getRightJoystick(): VirtualJoystick;
  137815. /**
  137816. * Update the current camera state depending on the inputs that have been used this frame.
  137817. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  137818. */
  137819. checkInputs(): void;
  137820. /**
  137821. * Attach the input controls to a specific dom element to get the input from.
  137822. */
  137823. attachControl(): void;
  137824. /**
  137825. * Detach the current controls from the specified dom element.
  137826. */
  137827. detachControl(): void;
  137828. /**
  137829. * Gets the class name of the current input.
  137830. * @returns the class name
  137831. */
  137832. getClassName(): string;
  137833. /**
  137834. * Get the friendly name associated with the input class.
  137835. * @returns the input friendly name
  137836. */
  137837. getSimpleName(): string;
  137838. }
  137839. }
  137840. declare module BABYLON {
  137841. /**
  137842. * This represents a FPS type of camera controlled by touch.
  137843. * This is like a universal camera minus the Gamepad controls.
  137844. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137845. */
  137846. export class TouchCamera extends FreeCamera {
  137847. /**
  137848. * Defines the touch sensibility for rotation.
  137849. * The higher the faster.
  137850. */
  137851. get touchAngularSensibility(): number;
  137852. set touchAngularSensibility(value: number);
  137853. /**
  137854. * Defines the touch sensibility for move.
  137855. * The higher the faster.
  137856. */
  137857. get touchMoveSensibility(): number;
  137858. set touchMoveSensibility(value: number);
  137859. /**
  137860. * Instantiates a new touch camera.
  137861. * This represents a FPS type of camera controlled by touch.
  137862. * This is like a universal camera minus the Gamepad controls.
  137863. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  137864. * @param name Define the name of the camera in the scene
  137865. * @param position Define the start position of the camera in the scene
  137866. * @param scene Define the scene the camera belongs to
  137867. */
  137868. constructor(name: string, position: Vector3, scene: Scene);
  137869. /**
  137870. * Gets the current object class name.
  137871. * @return the class name
  137872. */
  137873. getClassName(): string;
  137874. /** @hidden */
  137875. _setupInputs(): void;
  137876. }
  137877. }
  137878. declare module BABYLON {
  137879. /**
  137880. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  137881. * being tilted forward or back and left or right.
  137882. */
  137883. export class DeviceOrientationCamera extends FreeCamera {
  137884. private _initialQuaternion;
  137885. private _quaternionCache;
  137886. private _tmpDragQuaternion;
  137887. private _disablePointerInputWhenUsingDeviceOrientation;
  137888. /**
  137889. * Creates a new device orientation camera
  137890. * @param name The name of the camera
  137891. * @param position The start position camera
  137892. * @param scene The scene the camera belongs to
  137893. */
  137894. constructor(name: string, position: Vector3, scene: Scene);
  137895. /**
  137896. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  137897. */
  137898. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  137899. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  137900. private _dragFactor;
  137901. /**
  137902. * Enabled turning on the y axis when the orientation sensor is active
  137903. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  137904. */
  137905. enableHorizontalDragging(dragFactor?: number): void;
  137906. /**
  137907. * Gets the current instance class name ("DeviceOrientationCamera").
  137908. * This helps avoiding instanceof at run time.
  137909. * @returns the class name
  137910. */
  137911. getClassName(): string;
  137912. /**
  137913. * @hidden
  137914. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  137915. */
  137916. _checkInputs(): void;
  137917. /**
  137918. * Reset the camera to its default orientation on the specified axis only.
  137919. * @param axis The axis to reset
  137920. */
  137921. resetToCurrentRotation(axis?: Axis): void;
  137922. }
  137923. }
  137924. declare module BABYLON {
  137925. /**
  137926. * Defines supported buttons for XBox360 compatible gamepads
  137927. */
  137928. export enum Xbox360Button {
  137929. /** A */
  137930. A = 0,
  137931. /** B */
  137932. B = 1,
  137933. /** X */
  137934. X = 2,
  137935. /** Y */
  137936. Y = 3,
  137937. /** Left button */
  137938. LB = 4,
  137939. /** Right button */
  137940. RB = 5,
  137941. /** Back */
  137942. Back = 8,
  137943. /** Start */
  137944. Start = 9,
  137945. /** Left stick */
  137946. LeftStick = 10,
  137947. /** Right stick */
  137948. RightStick = 11
  137949. }
  137950. /** Defines values for XBox360 DPad */
  137951. export enum Xbox360Dpad {
  137952. /** Up */
  137953. Up = 12,
  137954. /** Down */
  137955. Down = 13,
  137956. /** Left */
  137957. Left = 14,
  137958. /** Right */
  137959. Right = 15
  137960. }
  137961. /**
  137962. * Defines a XBox360 gamepad
  137963. */
  137964. export class Xbox360Pad extends Gamepad {
  137965. private _leftTrigger;
  137966. private _rightTrigger;
  137967. private _onlefttriggerchanged;
  137968. private _onrighttriggerchanged;
  137969. private _onbuttondown;
  137970. private _onbuttonup;
  137971. private _ondpaddown;
  137972. private _ondpadup;
  137973. /** Observable raised when a button is pressed */
  137974. onButtonDownObservable: Observable<Xbox360Button>;
  137975. /** Observable raised when a button is released */
  137976. onButtonUpObservable: Observable<Xbox360Button>;
  137977. /** Observable raised when a pad is pressed */
  137978. onPadDownObservable: Observable<Xbox360Dpad>;
  137979. /** Observable raised when a pad is released */
  137980. onPadUpObservable: Observable<Xbox360Dpad>;
  137981. private _buttonA;
  137982. private _buttonB;
  137983. private _buttonX;
  137984. private _buttonY;
  137985. private _buttonBack;
  137986. private _buttonStart;
  137987. private _buttonLB;
  137988. private _buttonRB;
  137989. private _buttonLeftStick;
  137990. private _buttonRightStick;
  137991. private _dPadUp;
  137992. private _dPadDown;
  137993. private _dPadLeft;
  137994. private _dPadRight;
  137995. private _isXboxOnePad;
  137996. /**
  137997. * Creates a new XBox360 gamepad object
  137998. * @param id defines the id of this gamepad
  137999. * @param index defines its index
  138000. * @param gamepad defines the internal HTML gamepad object
  138001. * @param xboxOne defines if it is a XBox One gamepad
  138002. */
  138003. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  138004. /**
  138005. * Defines the callback to call when left trigger is pressed
  138006. * @param callback defines the callback to use
  138007. */
  138008. onlefttriggerchanged(callback: (value: number) => void): void;
  138009. /**
  138010. * Defines the callback to call when right trigger is pressed
  138011. * @param callback defines the callback to use
  138012. */
  138013. onrighttriggerchanged(callback: (value: number) => void): void;
  138014. /**
  138015. * Gets the left trigger value
  138016. */
  138017. get leftTrigger(): number;
  138018. /**
  138019. * Sets the left trigger value
  138020. */
  138021. set leftTrigger(newValue: number);
  138022. /**
  138023. * Gets the right trigger value
  138024. */
  138025. get rightTrigger(): number;
  138026. /**
  138027. * Sets the right trigger value
  138028. */
  138029. set rightTrigger(newValue: number);
  138030. /**
  138031. * Defines the callback to call when a button is pressed
  138032. * @param callback defines the callback to use
  138033. */
  138034. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  138035. /**
  138036. * Defines the callback to call when a button is released
  138037. * @param callback defines the callback to use
  138038. */
  138039. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  138040. /**
  138041. * Defines the callback to call when a pad is pressed
  138042. * @param callback defines the callback to use
  138043. */
  138044. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  138045. /**
  138046. * Defines the callback to call when a pad is released
  138047. * @param callback defines the callback to use
  138048. */
  138049. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  138050. private _setButtonValue;
  138051. private _setDPadValue;
  138052. /**
  138053. * Gets the value of the `A` button
  138054. */
  138055. get buttonA(): number;
  138056. /**
  138057. * Sets the value of the `A` button
  138058. */
  138059. set buttonA(value: number);
  138060. /**
  138061. * Gets the value of the `B` button
  138062. */
  138063. get buttonB(): number;
  138064. /**
  138065. * Sets the value of the `B` button
  138066. */
  138067. set buttonB(value: number);
  138068. /**
  138069. * Gets the value of the `X` button
  138070. */
  138071. get buttonX(): number;
  138072. /**
  138073. * Sets the value of the `X` button
  138074. */
  138075. set buttonX(value: number);
  138076. /**
  138077. * Gets the value of the `Y` button
  138078. */
  138079. get buttonY(): number;
  138080. /**
  138081. * Sets the value of the `Y` button
  138082. */
  138083. set buttonY(value: number);
  138084. /**
  138085. * Gets the value of the `Start` button
  138086. */
  138087. get buttonStart(): number;
  138088. /**
  138089. * Sets the value of the `Start` button
  138090. */
  138091. set buttonStart(value: number);
  138092. /**
  138093. * Gets the value of the `Back` button
  138094. */
  138095. get buttonBack(): number;
  138096. /**
  138097. * Sets the value of the `Back` button
  138098. */
  138099. set buttonBack(value: number);
  138100. /**
  138101. * Gets the value of the `Left` button
  138102. */
  138103. get buttonLB(): number;
  138104. /**
  138105. * Sets the value of the `Left` button
  138106. */
  138107. set buttonLB(value: number);
  138108. /**
  138109. * Gets the value of the `Right` button
  138110. */
  138111. get buttonRB(): number;
  138112. /**
  138113. * Sets the value of the `Right` button
  138114. */
  138115. set buttonRB(value: number);
  138116. /**
  138117. * Gets the value of the Left joystick
  138118. */
  138119. get buttonLeftStick(): number;
  138120. /**
  138121. * Sets the value of the Left joystick
  138122. */
  138123. set buttonLeftStick(value: number);
  138124. /**
  138125. * Gets the value of the Right joystick
  138126. */
  138127. get buttonRightStick(): number;
  138128. /**
  138129. * Sets the value of the Right joystick
  138130. */
  138131. set buttonRightStick(value: number);
  138132. /**
  138133. * Gets the value of D-pad up
  138134. */
  138135. get dPadUp(): number;
  138136. /**
  138137. * Sets the value of D-pad up
  138138. */
  138139. set dPadUp(value: number);
  138140. /**
  138141. * Gets the value of D-pad down
  138142. */
  138143. get dPadDown(): number;
  138144. /**
  138145. * Sets the value of D-pad down
  138146. */
  138147. set dPadDown(value: number);
  138148. /**
  138149. * Gets the value of D-pad left
  138150. */
  138151. get dPadLeft(): number;
  138152. /**
  138153. * Sets the value of D-pad left
  138154. */
  138155. set dPadLeft(value: number);
  138156. /**
  138157. * Gets the value of D-pad right
  138158. */
  138159. get dPadRight(): number;
  138160. /**
  138161. * Sets the value of D-pad right
  138162. */
  138163. set dPadRight(value: number);
  138164. /**
  138165. * Force the gamepad to synchronize with device values
  138166. */
  138167. update(): void;
  138168. /**
  138169. * Disposes the gamepad
  138170. */
  138171. dispose(): void;
  138172. }
  138173. }
  138174. declare module BABYLON {
  138175. /**
  138176. * Defines supported buttons for DualShock compatible gamepads
  138177. */
  138178. export enum DualShockButton {
  138179. /** Cross */
  138180. Cross = 0,
  138181. /** Circle */
  138182. Circle = 1,
  138183. /** Square */
  138184. Square = 2,
  138185. /** Triangle */
  138186. Triangle = 3,
  138187. /** L1 */
  138188. L1 = 4,
  138189. /** R1 */
  138190. R1 = 5,
  138191. /** Share */
  138192. Share = 8,
  138193. /** Options */
  138194. Options = 9,
  138195. /** Left stick */
  138196. LeftStick = 10,
  138197. /** Right stick */
  138198. RightStick = 11
  138199. }
  138200. /** Defines values for DualShock DPad */
  138201. export enum DualShockDpad {
  138202. /** Up */
  138203. Up = 12,
  138204. /** Down */
  138205. Down = 13,
  138206. /** Left */
  138207. Left = 14,
  138208. /** Right */
  138209. Right = 15
  138210. }
  138211. /**
  138212. * Defines a DualShock gamepad
  138213. */
  138214. export class DualShockPad extends Gamepad {
  138215. private _leftTrigger;
  138216. private _rightTrigger;
  138217. private _onlefttriggerchanged;
  138218. private _onrighttriggerchanged;
  138219. private _onbuttondown;
  138220. private _onbuttonup;
  138221. private _ondpaddown;
  138222. private _ondpadup;
  138223. /** Observable raised when a button is pressed */
  138224. onButtonDownObservable: Observable<DualShockButton>;
  138225. /** Observable raised when a button is released */
  138226. onButtonUpObservable: Observable<DualShockButton>;
  138227. /** Observable raised when a pad is pressed */
  138228. onPadDownObservable: Observable<DualShockDpad>;
  138229. /** Observable raised when a pad is released */
  138230. onPadUpObservable: Observable<DualShockDpad>;
  138231. private _buttonCross;
  138232. private _buttonCircle;
  138233. private _buttonSquare;
  138234. private _buttonTriangle;
  138235. private _buttonShare;
  138236. private _buttonOptions;
  138237. private _buttonL1;
  138238. private _buttonR1;
  138239. private _buttonLeftStick;
  138240. private _buttonRightStick;
  138241. private _dPadUp;
  138242. private _dPadDown;
  138243. private _dPadLeft;
  138244. private _dPadRight;
  138245. /**
  138246. * Creates a new DualShock gamepad object
  138247. * @param id defines the id of this gamepad
  138248. * @param index defines its index
  138249. * @param gamepad defines the internal HTML gamepad object
  138250. */
  138251. constructor(id: string, index: number, gamepad: any);
  138252. /**
  138253. * Defines the callback to call when left trigger is pressed
  138254. * @param callback defines the callback to use
  138255. */
  138256. onlefttriggerchanged(callback: (value: number) => void): void;
  138257. /**
  138258. * Defines the callback to call when right trigger is pressed
  138259. * @param callback defines the callback to use
  138260. */
  138261. onrighttriggerchanged(callback: (value: number) => void): void;
  138262. /**
  138263. * Gets the left trigger value
  138264. */
  138265. get leftTrigger(): number;
  138266. /**
  138267. * Sets the left trigger value
  138268. */
  138269. set leftTrigger(newValue: number);
  138270. /**
  138271. * Gets the right trigger value
  138272. */
  138273. get rightTrigger(): number;
  138274. /**
  138275. * Sets the right trigger value
  138276. */
  138277. set rightTrigger(newValue: number);
  138278. /**
  138279. * Defines the callback to call when a button is pressed
  138280. * @param callback defines the callback to use
  138281. */
  138282. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  138283. /**
  138284. * Defines the callback to call when a button is released
  138285. * @param callback defines the callback to use
  138286. */
  138287. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  138288. /**
  138289. * Defines the callback to call when a pad is pressed
  138290. * @param callback defines the callback to use
  138291. */
  138292. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  138293. /**
  138294. * Defines the callback to call when a pad is released
  138295. * @param callback defines the callback to use
  138296. */
  138297. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  138298. private _setButtonValue;
  138299. private _setDPadValue;
  138300. /**
  138301. * Gets the value of the `Cross` button
  138302. */
  138303. get buttonCross(): number;
  138304. /**
  138305. * Sets the value of the `Cross` button
  138306. */
  138307. set buttonCross(value: number);
  138308. /**
  138309. * Gets the value of the `Circle` button
  138310. */
  138311. get buttonCircle(): number;
  138312. /**
  138313. * Sets the value of the `Circle` button
  138314. */
  138315. set buttonCircle(value: number);
  138316. /**
  138317. * Gets the value of the `Square` button
  138318. */
  138319. get buttonSquare(): number;
  138320. /**
  138321. * Sets the value of the `Square` button
  138322. */
  138323. set buttonSquare(value: number);
  138324. /**
  138325. * Gets the value of the `Triangle` button
  138326. */
  138327. get buttonTriangle(): number;
  138328. /**
  138329. * Sets the value of the `Triangle` button
  138330. */
  138331. set buttonTriangle(value: number);
  138332. /**
  138333. * Gets the value of the `Options` button
  138334. */
  138335. get buttonOptions(): number;
  138336. /**
  138337. * Sets the value of the `Options` button
  138338. */
  138339. set buttonOptions(value: number);
  138340. /**
  138341. * Gets the value of the `Share` button
  138342. */
  138343. get buttonShare(): number;
  138344. /**
  138345. * Sets the value of the `Share` button
  138346. */
  138347. set buttonShare(value: number);
  138348. /**
  138349. * Gets the value of the `L1` button
  138350. */
  138351. get buttonL1(): number;
  138352. /**
  138353. * Sets the value of the `L1` button
  138354. */
  138355. set buttonL1(value: number);
  138356. /**
  138357. * Gets the value of the `R1` button
  138358. */
  138359. get buttonR1(): number;
  138360. /**
  138361. * Sets the value of the `R1` button
  138362. */
  138363. set buttonR1(value: number);
  138364. /**
  138365. * Gets the value of the Left joystick
  138366. */
  138367. get buttonLeftStick(): number;
  138368. /**
  138369. * Sets the value of the Left joystick
  138370. */
  138371. set buttonLeftStick(value: number);
  138372. /**
  138373. * Gets the value of the Right joystick
  138374. */
  138375. get buttonRightStick(): number;
  138376. /**
  138377. * Sets the value of the Right joystick
  138378. */
  138379. set buttonRightStick(value: number);
  138380. /**
  138381. * Gets the value of D-pad up
  138382. */
  138383. get dPadUp(): number;
  138384. /**
  138385. * Sets the value of D-pad up
  138386. */
  138387. set dPadUp(value: number);
  138388. /**
  138389. * Gets the value of D-pad down
  138390. */
  138391. get dPadDown(): number;
  138392. /**
  138393. * Sets the value of D-pad down
  138394. */
  138395. set dPadDown(value: number);
  138396. /**
  138397. * Gets the value of D-pad left
  138398. */
  138399. get dPadLeft(): number;
  138400. /**
  138401. * Sets the value of D-pad left
  138402. */
  138403. set dPadLeft(value: number);
  138404. /**
  138405. * Gets the value of D-pad right
  138406. */
  138407. get dPadRight(): number;
  138408. /**
  138409. * Sets the value of D-pad right
  138410. */
  138411. set dPadRight(value: number);
  138412. /**
  138413. * Force the gamepad to synchronize with device values
  138414. */
  138415. update(): void;
  138416. /**
  138417. * Disposes the gamepad
  138418. */
  138419. dispose(): void;
  138420. }
  138421. }
  138422. declare module BABYLON {
  138423. /**
  138424. * Manager for handling gamepads
  138425. */
  138426. export class GamepadManager {
  138427. private _scene?;
  138428. private _babylonGamepads;
  138429. private _oneGamepadConnected;
  138430. /** @hidden */
  138431. _isMonitoring: boolean;
  138432. private _gamepadEventSupported;
  138433. private _gamepadSupport?;
  138434. /**
  138435. * observable to be triggered when the gamepad controller has been connected
  138436. */
  138437. onGamepadConnectedObservable: Observable<Gamepad>;
  138438. /**
  138439. * observable to be triggered when the gamepad controller has been disconnected
  138440. */
  138441. onGamepadDisconnectedObservable: Observable<Gamepad>;
  138442. private _onGamepadConnectedEvent;
  138443. private _onGamepadDisconnectedEvent;
  138444. /**
  138445. * Initializes the gamepad manager
  138446. * @param _scene BabylonJS scene
  138447. */
  138448. constructor(_scene?: Scene | undefined);
  138449. /**
  138450. * The gamepads in the game pad manager
  138451. */
  138452. get gamepads(): Gamepad[];
  138453. /**
  138454. * Get the gamepad controllers based on type
  138455. * @param type The type of gamepad controller
  138456. * @returns Nullable gamepad
  138457. */
  138458. getGamepadByType(type?: number): Nullable<Gamepad>;
  138459. /**
  138460. * Disposes the gamepad manager
  138461. */
  138462. dispose(): void;
  138463. private _addNewGamepad;
  138464. private _startMonitoringGamepads;
  138465. private _stopMonitoringGamepads;
  138466. /** @hidden */
  138467. _checkGamepadsStatus(): void;
  138468. private _updateGamepadObjects;
  138469. }
  138470. }
  138471. declare module BABYLON {
  138472. interface Scene {
  138473. /** @hidden */
  138474. _gamepadManager: Nullable<GamepadManager>;
  138475. /**
  138476. * Gets the gamepad manager associated with the scene
  138477. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  138478. */
  138479. gamepadManager: GamepadManager;
  138480. }
  138481. /**
  138482. * Interface representing a free camera inputs manager
  138483. */
  138484. interface FreeCameraInputsManager {
  138485. /**
  138486. * Adds gamepad input support to the FreeCameraInputsManager.
  138487. * @returns the FreeCameraInputsManager
  138488. */
  138489. addGamepad(): FreeCameraInputsManager;
  138490. }
  138491. /**
  138492. * Interface representing an arc rotate camera inputs manager
  138493. */
  138494. interface ArcRotateCameraInputsManager {
  138495. /**
  138496. * Adds gamepad input support to the ArcRotateCamera InputManager.
  138497. * @returns the camera inputs manager
  138498. */
  138499. addGamepad(): ArcRotateCameraInputsManager;
  138500. }
  138501. /**
  138502. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  138503. */
  138504. export class GamepadSystemSceneComponent implements ISceneComponent {
  138505. /**
  138506. * The component name helpfull to identify the component in the list of scene components.
  138507. */
  138508. readonly name: string;
  138509. /**
  138510. * The scene the component belongs to.
  138511. */
  138512. scene: Scene;
  138513. /**
  138514. * Creates a new instance of the component for the given scene
  138515. * @param scene Defines the scene to register the component in
  138516. */
  138517. constructor(scene: Scene);
  138518. /**
  138519. * Registers the component in a given scene
  138520. */
  138521. register(): void;
  138522. /**
  138523. * Rebuilds the elements related to this component in case of
  138524. * context lost for instance.
  138525. */
  138526. rebuild(): void;
  138527. /**
  138528. * Disposes the component and the associated ressources
  138529. */
  138530. dispose(): void;
  138531. private _beforeCameraUpdate;
  138532. }
  138533. }
  138534. declare module BABYLON {
  138535. /**
  138536. * 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,
  138537. * which still works and will still be found in many Playgrounds.
  138538. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  138539. */
  138540. export class UniversalCamera extends TouchCamera {
  138541. /**
  138542. * Defines the gamepad rotation sensiblity.
  138543. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  138544. */
  138545. get gamepadAngularSensibility(): number;
  138546. set gamepadAngularSensibility(value: number);
  138547. /**
  138548. * Defines the gamepad move sensiblity.
  138549. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  138550. */
  138551. get gamepadMoveSensibility(): number;
  138552. set gamepadMoveSensibility(value: number);
  138553. /**
  138554. * 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,
  138555. * which still works and will still be found in many Playgrounds.
  138556. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  138557. * @param name Define the name of the camera in the scene
  138558. * @param position Define the start position of the camera in the scene
  138559. * @param scene Define the scene the camera belongs to
  138560. */
  138561. constructor(name: string, position: Vector3, scene: Scene);
  138562. /**
  138563. * Gets the current object class name.
  138564. * @return the class name
  138565. */
  138566. getClassName(): string;
  138567. }
  138568. }
  138569. declare module BABYLON {
  138570. /**
  138571. * This represents a FPS type of camera. This is only here for back compat purpose.
  138572. * Please use the UniversalCamera instead as both are identical.
  138573. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  138574. */
  138575. export class GamepadCamera extends UniversalCamera {
  138576. /**
  138577. * Instantiates a new Gamepad Camera
  138578. * This represents a FPS type of camera. This is only here for back compat purpose.
  138579. * Please use the UniversalCamera instead as both are identical.
  138580. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  138581. * @param name Define the name of the camera in the scene
  138582. * @param position Define the start position of the camera in the scene
  138583. * @param scene Define the scene the camera belongs to
  138584. */
  138585. constructor(name: string, position: Vector3, scene: Scene);
  138586. /**
  138587. * Gets the current object class name.
  138588. * @return the class name
  138589. */
  138590. getClassName(): string;
  138591. }
  138592. }
  138593. declare module BABYLON {
  138594. /** @hidden */
  138595. export var anaglyphPixelShader: {
  138596. name: string;
  138597. shader: string;
  138598. };
  138599. }
  138600. declare module BABYLON {
  138601. /**
  138602. * Postprocess used to generate anaglyphic rendering
  138603. */
  138604. export class AnaglyphPostProcess extends PostProcess {
  138605. private _passedProcess;
  138606. /**
  138607. * Gets a string identifying the name of the class
  138608. * @returns "AnaglyphPostProcess" string
  138609. */
  138610. getClassName(): string;
  138611. /**
  138612. * Creates a new AnaglyphPostProcess
  138613. * @param name defines postprocess name
  138614. * @param options defines creation options or target ratio scale
  138615. * @param rigCameras defines cameras using this postprocess
  138616. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  138617. * @param engine defines hosting engine
  138618. * @param reusable defines if the postprocess will be reused multiple times per frame
  138619. */
  138620. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  138621. }
  138622. }
  138623. declare module BABYLON {
  138624. /**
  138625. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  138626. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  138627. */
  138628. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  138629. /**
  138630. * Creates a new AnaglyphArcRotateCamera
  138631. * @param name defines camera name
  138632. * @param alpha defines alpha angle (in radians)
  138633. * @param beta defines beta angle (in radians)
  138634. * @param radius defines radius
  138635. * @param target defines camera target
  138636. * @param interaxialDistance defines distance between each color axis
  138637. * @param scene defines the hosting scene
  138638. */
  138639. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  138640. /**
  138641. * Gets camera class name
  138642. * @returns AnaglyphArcRotateCamera
  138643. */
  138644. getClassName(): string;
  138645. }
  138646. }
  138647. declare module BABYLON {
  138648. /**
  138649. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  138650. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  138651. */
  138652. export class AnaglyphFreeCamera extends FreeCamera {
  138653. /**
  138654. * Creates a new AnaglyphFreeCamera
  138655. * @param name defines camera name
  138656. * @param position defines initial position
  138657. * @param interaxialDistance defines distance between each color axis
  138658. * @param scene defines the hosting scene
  138659. */
  138660. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  138661. /**
  138662. * Gets camera class name
  138663. * @returns AnaglyphFreeCamera
  138664. */
  138665. getClassName(): string;
  138666. }
  138667. }
  138668. declare module BABYLON {
  138669. /**
  138670. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  138671. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  138672. */
  138673. export class AnaglyphGamepadCamera extends GamepadCamera {
  138674. /**
  138675. * Creates a new AnaglyphGamepadCamera
  138676. * @param name defines camera name
  138677. * @param position defines initial position
  138678. * @param interaxialDistance defines distance between each color axis
  138679. * @param scene defines the hosting scene
  138680. */
  138681. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  138682. /**
  138683. * Gets camera class name
  138684. * @returns AnaglyphGamepadCamera
  138685. */
  138686. getClassName(): string;
  138687. }
  138688. }
  138689. declare module BABYLON {
  138690. /**
  138691. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  138692. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  138693. */
  138694. export class AnaglyphUniversalCamera extends UniversalCamera {
  138695. /**
  138696. * Creates a new AnaglyphUniversalCamera
  138697. * @param name defines camera name
  138698. * @param position defines initial position
  138699. * @param interaxialDistance defines distance between each color axis
  138700. * @param scene defines the hosting scene
  138701. */
  138702. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  138703. /**
  138704. * Gets camera class name
  138705. * @returns AnaglyphUniversalCamera
  138706. */
  138707. getClassName(): string;
  138708. }
  138709. }
  138710. declare module BABYLON {
  138711. /** @hidden */
  138712. export var stereoscopicInterlacePixelShader: {
  138713. name: string;
  138714. shader: string;
  138715. };
  138716. }
  138717. declare module BABYLON {
  138718. /**
  138719. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  138720. */
  138721. export class StereoscopicInterlacePostProcessI extends PostProcess {
  138722. private _stepSize;
  138723. private _passedProcess;
  138724. /**
  138725. * Gets a string identifying the name of the class
  138726. * @returns "StereoscopicInterlacePostProcessI" string
  138727. */
  138728. getClassName(): string;
  138729. /**
  138730. * Initializes a StereoscopicInterlacePostProcessI
  138731. * @param name The name of the effect.
  138732. * @param rigCameras The rig cameras to be applied to the post process
  138733. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  138734. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  138735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138736. * @param engine The engine which the post process will be applied. (default: current engine)
  138737. * @param reusable If the post process can be reused on the same frame. (default: false)
  138738. */
  138739. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138740. }
  138741. /**
  138742. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  138743. */
  138744. export class StereoscopicInterlacePostProcess extends PostProcess {
  138745. private _stepSize;
  138746. private _passedProcess;
  138747. /**
  138748. * Gets a string identifying the name of the class
  138749. * @returns "StereoscopicInterlacePostProcess" string
  138750. */
  138751. getClassName(): string;
  138752. /**
  138753. * Initializes a StereoscopicInterlacePostProcess
  138754. * @param name The name of the effect.
  138755. * @param rigCameras The rig cameras to be applied to the post process
  138756. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  138757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138758. * @param engine The engine which the post process will be applied. (default: current engine)
  138759. * @param reusable If the post process can be reused on the same frame. (default: false)
  138760. */
  138761. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138762. }
  138763. }
  138764. declare module BABYLON {
  138765. /**
  138766. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  138767. * @see https://doc.babylonjs.com/features/cameras
  138768. */
  138769. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  138770. /**
  138771. * Creates a new StereoscopicArcRotateCamera
  138772. * @param name defines camera name
  138773. * @param alpha defines alpha angle (in radians)
  138774. * @param beta defines beta angle (in radians)
  138775. * @param radius defines radius
  138776. * @param target defines camera target
  138777. * @param interaxialDistance defines distance between each color axis
  138778. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  138779. * @param scene defines the hosting scene
  138780. */
  138781. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  138782. /**
  138783. * Gets camera class name
  138784. * @returns StereoscopicArcRotateCamera
  138785. */
  138786. getClassName(): string;
  138787. }
  138788. }
  138789. declare module BABYLON {
  138790. /**
  138791. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  138792. * @see https://doc.babylonjs.com/features/cameras
  138793. */
  138794. export class StereoscopicFreeCamera extends FreeCamera {
  138795. /**
  138796. * Creates a new StereoscopicFreeCamera
  138797. * @param name defines camera name
  138798. * @param position defines initial position
  138799. * @param interaxialDistance defines distance between each color axis
  138800. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  138801. * @param scene defines the hosting scene
  138802. */
  138803. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  138804. /**
  138805. * Gets camera class name
  138806. * @returns StereoscopicFreeCamera
  138807. */
  138808. getClassName(): string;
  138809. }
  138810. }
  138811. declare module BABYLON {
  138812. /**
  138813. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  138814. * @see https://doc.babylonjs.com/features/cameras
  138815. */
  138816. export class StereoscopicGamepadCamera extends GamepadCamera {
  138817. /**
  138818. * Creates a new StereoscopicGamepadCamera
  138819. * @param name defines camera name
  138820. * @param position defines initial position
  138821. * @param interaxialDistance defines distance between each color axis
  138822. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  138823. * @param scene defines the hosting scene
  138824. */
  138825. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  138826. /**
  138827. * Gets camera class name
  138828. * @returns StereoscopicGamepadCamera
  138829. */
  138830. getClassName(): string;
  138831. }
  138832. }
  138833. declare module BABYLON {
  138834. /**
  138835. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  138836. * @see https://doc.babylonjs.com/features/cameras
  138837. */
  138838. export class StereoscopicUniversalCamera extends UniversalCamera {
  138839. /**
  138840. * Creates a new StereoscopicUniversalCamera
  138841. * @param name defines camera name
  138842. * @param position defines initial position
  138843. * @param interaxialDistance defines distance between each color axis
  138844. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  138845. * @param scene defines the hosting scene
  138846. */
  138847. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  138848. /**
  138849. * Gets camera class name
  138850. * @returns StereoscopicUniversalCamera
  138851. */
  138852. getClassName(): string;
  138853. }
  138854. }
  138855. declare module BABYLON {
  138856. /**
  138857. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  138858. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  138859. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  138860. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  138861. */
  138862. export class VirtualJoysticksCamera extends FreeCamera {
  138863. /**
  138864. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  138865. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  138866. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  138867. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  138868. * @param name Define the name of the camera in the scene
  138869. * @param position Define the start position of the camera in the scene
  138870. * @param scene Define the scene the camera belongs to
  138871. */
  138872. constructor(name: string, position: Vector3, scene: Scene);
  138873. /**
  138874. * Gets the current object class name.
  138875. * @return the class name
  138876. */
  138877. getClassName(): string;
  138878. }
  138879. }
  138880. declare module BABYLON {
  138881. /**
  138882. * This represents all the required metrics to create a VR camera.
  138883. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  138884. */
  138885. export class VRCameraMetrics {
  138886. /**
  138887. * Define the horizontal resolution off the screen.
  138888. */
  138889. hResolution: number;
  138890. /**
  138891. * Define the vertical resolution off the screen.
  138892. */
  138893. vResolution: number;
  138894. /**
  138895. * Define the horizontal screen size.
  138896. */
  138897. hScreenSize: number;
  138898. /**
  138899. * Define the vertical screen size.
  138900. */
  138901. vScreenSize: number;
  138902. /**
  138903. * Define the vertical screen center position.
  138904. */
  138905. vScreenCenter: number;
  138906. /**
  138907. * Define the distance of the eyes to the screen.
  138908. */
  138909. eyeToScreenDistance: number;
  138910. /**
  138911. * Define the distance between both lenses
  138912. */
  138913. lensSeparationDistance: number;
  138914. /**
  138915. * Define the distance between both viewer's eyes.
  138916. */
  138917. interpupillaryDistance: number;
  138918. /**
  138919. * Define the distortion factor of the VR postprocess.
  138920. * Please, touch with care.
  138921. */
  138922. distortionK: number[];
  138923. /**
  138924. * Define the chromatic aberration correction factors for the VR post process.
  138925. */
  138926. chromaAbCorrection: number[];
  138927. /**
  138928. * Define the scale factor of the post process.
  138929. * The smaller the better but the slower.
  138930. */
  138931. postProcessScaleFactor: number;
  138932. /**
  138933. * Define an offset for the lens center.
  138934. */
  138935. lensCenterOffset: number;
  138936. /**
  138937. * Define if the current vr camera should compensate the distortion of the lens or not.
  138938. */
  138939. compensateDistortion: boolean;
  138940. /**
  138941. * Defines if multiview should be enabled when rendering (Default: false)
  138942. */
  138943. multiviewEnabled: boolean;
  138944. /**
  138945. * Gets the rendering aspect ratio based on the provided resolutions.
  138946. */
  138947. get aspectRatio(): number;
  138948. /**
  138949. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  138950. */
  138951. get aspectRatioFov(): number;
  138952. /**
  138953. * @hidden
  138954. */
  138955. get leftHMatrix(): Matrix;
  138956. /**
  138957. * @hidden
  138958. */
  138959. get rightHMatrix(): Matrix;
  138960. /**
  138961. * @hidden
  138962. */
  138963. get leftPreViewMatrix(): Matrix;
  138964. /**
  138965. * @hidden
  138966. */
  138967. get rightPreViewMatrix(): Matrix;
  138968. /**
  138969. * Get the default VRMetrics based on the most generic setup.
  138970. * @returns the default vr metrics
  138971. */
  138972. static GetDefault(): VRCameraMetrics;
  138973. }
  138974. }
  138975. declare module BABYLON {
  138976. /** @hidden */
  138977. export var vrDistortionCorrectionPixelShader: {
  138978. name: string;
  138979. shader: string;
  138980. };
  138981. }
  138982. declare module BABYLON {
  138983. /**
  138984. * VRDistortionCorrectionPostProcess used for mobile VR
  138985. */
  138986. export class VRDistortionCorrectionPostProcess extends PostProcess {
  138987. private _isRightEye;
  138988. private _distortionFactors;
  138989. private _postProcessScaleFactor;
  138990. private _lensCenterOffset;
  138991. private _scaleIn;
  138992. private _scaleFactor;
  138993. private _lensCenter;
  138994. /**
  138995. * Gets a string identifying the name of the class
  138996. * @returns "VRDistortionCorrectionPostProcess" string
  138997. */
  138998. getClassName(): string;
  138999. /**
  139000. * Initializes the VRDistortionCorrectionPostProcess
  139001. * @param name The name of the effect.
  139002. * @param camera The camera to apply the render pass to.
  139003. * @param isRightEye If this is for the right eye distortion
  139004. * @param vrMetrics All the required metrics for the VR camera
  139005. */
  139006. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  139007. }
  139008. }
  139009. declare module BABYLON {
  139010. /**
  139011. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  139012. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  139013. */
  139014. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  139015. /**
  139016. * Creates a new VRDeviceOrientationArcRotateCamera
  139017. * @param name defines camera name
  139018. * @param alpha defines the camera rotation along the longitudinal axis
  139019. * @param beta defines the camera rotation along the latitudinal axis
  139020. * @param radius defines the camera distance from its target
  139021. * @param target defines the camera target
  139022. * @param scene defines the scene the camera belongs to
  139023. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  139024. * @param vrCameraMetrics defines the vr metrics associated to the camera
  139025. */
  139026. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  139027. /**
  139028. * Gets camera class name
  139029. * @returns VRDeviceOrientationArcRotateCamera
  139030. */
  139031. getClassName(): string;
  139032. }
  139033. }
  139034. declare module BABYLON {
  139035. /**
  139036. * Camera used to simulate VR rendering (based on FreeCamera)
  139037. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  139038. */
  139039. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  139040. /**
  139041. * Creates a new VRDeviceOrientationFreeCamera
  139042. * @param name defines camera name
  139043. * @param position defines the start position of the camera
  139044. * @param scene defines the scene the camera belongs to
  139045. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  139046. * @param vrCameraMetrics defines the vr metrics associated to the camera
  139047. */
  139048. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  139049. /**
  139050. * Gets camera class name
  139051. * @returns VRDeviceOrientationFreeCamera
  139052. */
  139053. getClassName(): string;
  139054. }
  139055. }
  139056. declare module BABYLON {
  139057. /**
  139058. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  139059. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  139060. */
  139061. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  139062. /**
  139063. * Creates a new VRDeviceOrientationGamepadCamera
  139064. * @param name defines camera name
  139065. * @param position defines the start position of the camera
  139066. * @param scene defines the scene the camera belongs to
  139067. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  139068. * @param vrCameraMetrics defines the vr metrics associated to the camera
  139069. */
  139070. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  139071. /**
  139072. * Gets camera class name
  139073. * @returns VRDeviceOrientationGamepadCamera
  139074. */
  139075. getClassName(): string;
  139076. }
  139077. }
  139078. declare module BABYLON {
  139079. /**
  139080. * A class extending Texture allowing drawing on a texture
  139081. * @see https://doc.babylonjs.com/how_to/dynamictexture
  139082. */
  139083. export class DynamicTexture extends Texture {
  139084. private _generateMipMaps;
  139085. private _canvas;
  139086. private _context;
  139087. /**
  139088. * Creates a DynamicTexture
  139089. * @param name defines the name of the texture
  139090. * @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
  139091. * @param scene defines the scene where you want the texture
  139092. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  139093. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139094. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  139095. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  139096. */
  139097. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  139098. /**
  139099. * Get the current class name of the texture useful for serialization or dynamic coding.
  139100. * @returns "DynamicTexture"
  139101. */
  139102. getClassName(): string;
  139103. /**
  139104. * Gets the current state of canRescale
  139105. */
  139106. get canRescale(): boolean;
  139107. private _recreate;
  139108. /**
  139109. * Scales the texture
  139110. * @param ratio the scale factor to apply to both width and height
  139111. */
  139112. scale(ratio: number): void;
  139113. /**
  139114. * Resizes the texture
  139115. * @param width the new width
  139116. * @param height the new height
  139117. */
  139118. scaleTo(width: number, height: number): void;
  139119. /**
  139120. * Gets the context of the canvas used by the texture
  139121. * @returns the canvas context of the dynamic texture
  139122. */
  139123. getContext(): CanvasRenderingContext2D;
  139124. /**
  139125. * Clears the texture
  139126. */
  139127. clear(): void;
  139128. /**
  139129. * Updates the texture
  139130. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  139131. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  139132. */
  139133. update(invertY?: boolean, premulAlpha?: boolean): void;
  139134. /**
  139135. * Draws text onto the texture
  139136. * @param text defines the text to be drawn
  139137. * @param x defines the placement of the text from the left
  139138. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  139139. * @param font defines the font to be used with font-style, font-size, font-name
  139140. * @param color defines the color used for the text
  139141. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  139142. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  139143. * @param update defines whether texture is immediately update (default is true)
  139144. */
  139145. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  139146. /**
  139147. * Clones the texture
  139148. * @returns the clone of the texture.
  139149. */
  139150. clone(): DynamicTexture;
  139151. /**
  139152. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  139153. * @returns a serialized dynamic texture object
  139154. */
  139155. serialize(): any;
  139156. private _IsCanvasElement;
  139157. /** @hidden */
  139158. _rebuild(): void;
  139159. }
  139160. }
  139161. declare module BABYLON {
  139162. /**
  139163. * Class containing static functions to help procedurally build meshes
  139164. */
  139165. export class GroundBuilder {
  139166. /**
  139167. * Creates a ground mesh
  139168. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  139169. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  139170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139171. * @param name defines the name of the mesh
  139172. * @param options defines the options used to create the mesh
  139173. * @param scene defines the hosting scene
  139174. * @returns the ground mesh
  139175. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  139176. */
  139177. static CreateGround(name: string, options: {
  139178. width?: number;
  139179. height?: number;
  139180. subdivisions?: number;
  139181. subdivisionsX?: number;
  139182. subdivisionsY?: number;
  139183. updatable?: boolean;
  139184. }, scene: any): Mesh;
  139185. /**
  139186. * Creates a tiled ground mesh
  139187. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  139188. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  139189. * * 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
  139190. * * 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
  139191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139192. * @param name defines the name of the mesh
  139193. * @param options defines the options used to create the mesh
  139194. * @param scene defines the hosting scene
  139195. * @returns the tiled ground mesh
  139196. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  139197. */
  139198. static CreateTiledGround(name: string, options: {
  139199. xmin: number;
  139200. zmin: number;
  139201. xmax: number;
  139202. zmax: number;
  139203. subdivisions?: {
  139204. w: number;
  139205. h: number;
  139206. };
  139207. precision?: {
  139208. w: number;
  139209. h: number;
  139210. };
  139211. updatable?: boolean;
  139212. }, scene?: Nullable<Scene>): Mesh;
  139213. /**
  139214. * Creates a ground mesh from a height map
  139215. * * The parameter `url` sets the URL of the height map image resource.
  139216. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  139217. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  139218. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  139219. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  139220. * * 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.
  139221. * * 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).
  139222. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  139223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139224. * @param name defines the name of the mesh
  139225. * @param url defines the url to the height map
  139226. * @param options defines the options used to create the mesh
  139227. * @param scene defines the hosting scene
  139228. * @returns the ground mesh
  139229. * @see https://doc.babylonjs.com/babylon101/height_map
  139230. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  139231. */
  139232. static CreateGroundFromHeightMap(name: string, url: string, options: {
  139233. width?: number;
  139234. height?: number;
  139235. subdivisions?: number;
  139236. minHeight?: number;
  139237. maxHeight?: number;
  139238. colorFilter?: Color3;
  139239. alphaFilter?: number;
  139240. updatable?: boolean;
  139241. onReady?: (mesh: GroundMesh) => void;
  139242. }, scene?: Nullable<Scene>): GroundMesh;
  139243. }
  139244. }
  139245. declare module BABYLON {
  139246. /**
  139247. * Class containing static functions to help procedurally build meshes
  139248. */
  139249. export class TorusBuilder {
  139250. /**
  139251. * Creates a torus mesh
  139252. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  139253. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  139254. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  139255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139258. * @param name defines the name of the mesh
  139259. * @param options defines the options used to create the mesh
  139260. * @param scene defines the hosting scene
  139261. * @returns the torus mesh
  139262. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  139263. */
  139264. static CreateTorus(name: string, options: {
  139265. diameter?: number;
  139266. thickness?: number;
  139267. tessellation?: number;
  139268. updatable?: boolean;
  139269. sideOrientation?: number;
  139270. frontUVs?: Vector4;
  139271. backUVs?: Vector4;
  139272. }, scene: any): Mesh;
  139273. }
  139274. }
  139275. declare module BABYLON {
  139276. /**
  139277. * Class containing static functions to help procedurally build meshes
  139278. */
  139279. export class CylinderBuilder {
  139280. /**
  139281. * Creates a cylinder or a cone mesh
  139282. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  139283. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  139284. * * 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.
  139285. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  139286. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  139287. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  139288. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  139289. * * 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).
  139290. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  139291. * * 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).
  139292. * * 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
  139293. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  139294. * * 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
  139295. * * 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.
  139296. * * If `enclose` is false, a ring surface is one element.
  139297. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  139298. * * 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
  139299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139302. * @param name defines the name of the mesh
  139303. * @param options defines the options used to create the mesh
  139304. * @param scene defines the hosting scene
  139305. * @returns the cylinder mesh
  139306. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  139307. */
  139308. static CreateCylinder(name: string, options: {
  139309. height?: number;
  139310. diameterTop?: number;
  139311. diameterBottom?: number;
  139312. diameter?: number;
  139313. tessellation?: number;
  139314. subdivisions?: number;
  139315. arc?: number;
  139316. faceColors?: Color4[];
  139317. faceUV?: Vector4[];
  139318. updatable?: boolean;
  139319. hasRings?: boolean;
  139320. enclose?: boolean;
  139321. cap?: number;
  139322. sideOrientation?: number;
  139323. frontUVs?: Vector4;
  139324. backUVs?: Vector4;
  139325. }, scene: any): Mesh;
  139326. }
  139327. }
  139328. declare module BABYLON {
  139329. /**
  139330. * States of the webXR experience
  139331. */
  139332. export enum WebXRState {
  139333. /**
  139334. * Transitioning to being in XR mode
  139335. */
  139336. ENTERING_XR = 0,
  139337. /**
  139338. * Transitioning to non XR mode
  139339. */
  139340. EXITING_XR = 1,
  139341. /**
  139342. * In XR mode and presenting
  139343. */
  139344. IN_XR = 2,
  139345. /**
  139346. * Not entered XR mode
  139347. */
  139348. NOT_IN_XR = 3
  139349. }
  139350. /**
  139351. * The state of the XR camera's tracking
  139352. */
  139353. export enum WebXRTrackingState {
  139354. /**
  139355. * No transformation received, device is not being tracked
  139356. */
  139357. NOT_TRACKING = 0,
  139358. /**
  139359. * Tracking lost - using emulated position
  139360. */
  139361. TRACKING_LOST = 1,
  139362. /**
  139363. * Transformation tracking works normally
  139364. */
  139365. TRACKING = 2
  139366. }
  139367. /**
  139368. * Abstraction of the XR render target
  139369. */
  139370. export interface WebXRRenderTarget extends IDisposable {
  139371. /**
  139372. * xrpresent context of the canvas which can be used to display/mirror xr content
  139373. */
  139374. canvasContext: WebGLRenderingContext;
  139375. /**
  139376. * xr layer for the canvas
  139377. */
  139378. xrLayer: Nullable<XRWebGLLayer>;
  139379. /**
  139380. * Initializes the xr layer for the session
  139381. * @param xrSession xr session
  139382. * @returns a promise that will resolve once the XR Layer has been created
  139383. */
  139384. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  139385. }
  139386. }
  139387. declare module BABYLON {
  139388. /**
  139389. * Configuration object for WebXR output canvas
  139390. */
  139391. export class WebXRManagedOutputCanvasOptions {
  139392. /**
  139393. * An optional canvas in case you wish to create it yourself and provide it here.
  139394. * If not provided, a new canvas will be created
  139395. */
  139396. canvasElement?: HTMLCanvasElement;
  139397. /**
  139398. * Options for this XR Layer output
  139399. */
  139400. canvasOptions?: XRWebGLLayerInit;
  139401. /**
  139402. * CSS styling for a newly created canvas (if not provided)
  139403. */
  139404. newCanvasCssStyle?: string;
  139405. /**
  139406. * Get the default values of the configuration object
  139407. * @param engine defines the engine to use (can be null)
  139408. * @returns default values of this configuration object
  139409. */
  139410. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  139411. }
  139412. /**
  139413. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  139414. */
  139415. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  139416. private _options;
  139417. private _canvas;
  139418. private _engine;
  139419. private _originalCanvasSize;
  139420. /**
  139421. * Rendering context of the canvas which can be used to display/mirror xr content
  139422. */
  139423. canvasContext: WebGLRenderingContext;
  139424. /**
  139425. * xr layer for the canvas
  139426. */
  139427. xrLayer: Nullable<XRWebGLLayer>;
  139428. /**
  139429. * Observers registered here will be triggered when the xr layer was initialized
  139430. */
  139431. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  139432. /**
  139433. * Initializes the canvas to be added/removed upon entering/exiting xr
  139434. * @param _xrSessionManager The XR Session manager
  139435. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  139436. */
  139437. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  139438. /**
  139439. * Disposes of the object
  139440. */
  139441. dispose(): void;
  139442. /**
  139443. * Initializes the xr layer for the session
  139444. * @param xrSession xr session
  139445. * @returns a promise that will resolve once the XR Layer has been created
  139446. */
  139447. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  139448. private _addCanvas;
  139449. private _removeCanvas;
  139450. private _setCanvasSize;
  139451. private _setManagedOutputCanvas;
  139452. }
  139453. }
  139454. declare module BABYLON {
  139455. /**
  139456. * Manages an XRSession to work with Babylon's engine
  139457. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  139458. */
  139459. export class WebXRSessionManager implements IDisposable {
  139460. /** The scene which the session should be created for */
  139461. scene: Scene;
  139462. private _referenceSpace;
  139463. private _rttProvider;
  139464. private _sessionEnded;
  139465. private _xrNavigator;
  139466. private baseLayer;
  139467. /**
  139468. * The base reference space from which the session started. good if you want to reset your
  139469. * reference space
  139470. */
  139471. baseReferenceSpace: XRReferenceSpace;
  139472. /**
  139473. * Current XR frame
  139474. */
  139475. currentFrame: Nullable<XRFrame>;
  139476. /** WebXR timestamp updated every frame */
  139477. currentTimestamp: number;
  139478. /**
  139479. * Used just in case of a failure to initialize an immersive session.
  139480. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  139481. */
  139482. defaultHeightCompensation: number;
  139483. /**
  139484. * Fires every time a new xrFrame arrives which can be used to update the camera
  139485. */
  139486. onXRFrameObservable: Observable<XRFrame>;
  139487. /**
  139488. * Fires when the reference space changed
  139489. */
  139490. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  139491. /**
  139492. * Fires when the xr session is ended either by the device or manually done
  139493. */
  139494. onXRSessionEnded: Observable<any>;
  139495. /**
  139496. * Fires when the xr session is ended either by the device or manually done
  139497. */
  139498. onXRSessionInit: Observable<XRSession>;
  139499. /**
  139500. * Underlying xr session
  139501. */
  139502. session: XRSession;
  139503. /**
  139504. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  139505. * or get the offset the player is currently at.
  139506. */
  139507. viewerReferenceSpace: XRReferenceSpace;
  139508. /**
  139509. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  139510. * @param scene The scene which the session should be created for
  139511. */
  139512. constructor(
  139513. /** The scene which the session should be created for */
  139514. scene: Scene);
  139515. /**
  139516. * The current reference space used in this session. This reference space can constantly change!
  139517. * It is mainly used to offset the camera's position.
  139518. */
  139519. get referenceSpace(): XRReferenceSpace;
  139520. /**
  139521. * Set a new reference space and triggers the observable
  139522. */
  139523. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  139524. /**
  139525. * Disposes of the session manager
  139526. */
  139527. dispose(): void;
  139528. /**
  139529. * Stops the xrSession and restores the render loop
  139530. * @returns Promise which resolves after it exits XR
  139531. */
  139532. exitXRAsync(): Promise<void>;
  139533. /**
  139534. * Gets the correct render target texture to be rendered this frame for this eye
  139535. * @param eye the eye for which to get the render target
  139536. * @returns the render target for the specified eye
  139537. */
  139538. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  139539. /**
  139540. * Creates a WebXRRenderTarget object for the XR session
  139541. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  139542. * @param options optional options to provide when creating a new render target
  139543. * @returns a WebXR render target to which the session can render
  139544. */
  139545. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  139546. /**
  139547. * Initializes the manager
  139548. * After initialization enterXR can be called to start an XR session
  139549. * @returns Promise which resolves after it is initialized
  139550. */
  139551. initializeAsync(): Promise<void>;
  139552. /**
  139553. * Initializes an xr session
  139554. * @param xrSessionMode mode to initialize
  139555. * @param xrSessionInit defines optional and required values to pass to the session builder
  139556. * @returns a promise which will resolve once the session has been initialized
  139557. */
  139558. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  139559. /**
  139560. * Checks if a session would be supported for the creation options specified
  139561. * @param sessionMode session mode to check if supported eg. immersive-vr
  139562. * @returns A Promise that resolves to true if supported and false if not
  139563. */
  139564. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  139565. /**
  139566. * Resets the reference space to the one started the session
  139567. */
  139568. resetReferenceSpace(): void;
  139569. /**
  139570. * Starts rendering to the xr layer
  139571. */
  139572. runXRRenderLoop(): void;
  139573. /**
  139574. * Sets the reference space on the xr session
  139575. * @param referenceSpaceType space to set
  139576. * @returns a promise that will resolve once the reference space has been set
  139577. */
  139578. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  139579. /**
  139580. * Updates the render state of the session
  139581. * @param state state to set
  139582. * @returns a promise that resolves once the render state has been updated
  139583. */
  139584. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  139585. /**
  139586. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  139587. * @param sessionMode defines the session to test
  139588. * @returns a promise with boolean as final value
  139589. */
  139590. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  139591. /**
  139592. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  139593. */
  139594. get isNative(): boolean;
  139595. private _createRenderTargetTexture;
  139596. }
  139597. }
  139598. declare module BABYLON {
  139599. /**
  139600. * WebXR Camera which holds the views for the xrSession
  139601. * @see https://doc.babylonjs.com/how_to/webxr_camera
  139602. */
  139603. export class WebXRCamera extends FreeCamera {
  139604. private _xrSessionManager;
  139605. private _firstFrame;
  139606. private _referenceQuaternion;
  139607. private _referencedPosition;
  139608. private _xrInvPositionCache;
  139609. private _xrInvQuaternionCache;
  139610. private _trackingState;
  139611. /**
  139612. * Observable raised before camera teleportation
  139613. */
  139614. onBeforeCameraTeleport: Observable<Vector3>;
  139615. /**
  139616. * Observable raised after camera teleportation
  139617. */
  139618. onAfterCameraTeleport: Observable<Vector3>;
  139619. /**
  139620. * Notifies when the camera's tracking state has changed.
  139621. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  139622. */
  139623. onTrackingStateChanged: Observable<WebXRTrackingState>;
  139624. /**
  139625. * Should position compensation execute on first frame.
  139626. * This is used when copying the position from a native (non XR) camera
  139627. */
  139628. compensateOnFirstFrame: boolean;
  139629. /**
  139630. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  139631. * @param name the name of the camera
  139632. * @param scene the scene to add the camera to
  139633. * @param _xrSessionManager a constructed xr session manager
  139634. */
  139635. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  139636. /**
  139637. * Get the current XR tracking state of the camera
  139638. */
  139639. get trackingState(): WebXRTrackingState;
  139640. private _setTrackingState;
  139641. /**
  139642. * Return the user's height, unrelated to the current ground.
  139643. * This will be the y position of this camera, when ground level is 0.
  139644. */
  139645. get realWorldHeight(): number;
  139646. /** @hidden */
  139647. _updateForDualEyeDebugging(): void;
  139648. /**
  139649. * Sets this camera's transformation based on a non-vr camera
  139650. * @param otherCamera the non-vr camera to copy the transformation from
  139651. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  139652. */
  139653. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  139654. /**
  139655. * Gets the current instance class name ("WebXRCamera").
  139656. * @returns the class name
  139657. */
  139658. getClassName(): string;
  139659. private _rotate180;
  139660. private _updateFromXRSession;
  139661. private _updateNumberOfRigCameras;
  139662. private _updateReferenceSpace;
  139663. private _updateReferenceSpaceOffset;
  139664. }
  139665. }
  139666. declare module BABYLON {
  139667. /**
  139668. * Defining the interface required for a (webxr) feature
  139669. */
  139670. export interface IWebXRFeature extends IDisposable {
  139671. /**
  139672. * Is this feature attached
  139673. */
  139674. attached: boolean;
  139675. /**
  139676. * Should auto-attach be disabled?
  139677. */
  139678. disableAutoAttach: boolean;
  139679. /**
  139680. * Attach the feature to the session
  139681. * Will usually be called by the features manager
  139682. *
  139683. * @param force should attachment be forced (even when already attached)
  139684. * @returns true if successful.
  139685. */
  139686. attach(force?: boolean): boolean;
  139687. /**
  139688. * Detach the feature from the session
  139689. * Will usually be called by the features manager
  139690. *
  139691. * @returns true if successful.
  139692. */
  139693. detach(): boolean;
  139694. /**
  139695. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  139696. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  139697. *
  139698. * @returns whether or not the feature is compatible in this environment
  139699. */
  139700. isCompatible(): boolean;
  139701. /**
  139702. * Was this feature disposed;
  139703. */
  139704. isDisposed: boolean;
  139705. /**
  139706. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  139707. */
  139708. xrNativeFeatureName?: string;
  139709. /**
  139710. * A list of (Babylon WebXR) features this feature depends on
  139711. */
  139712. dependsOn?: string[];
  139713. /**
  139714. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  139715. */
  139716. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  139717. }
  139718. /**
  139719. * A list of the currently available features without referencing them
  139720. */
  139721. export class WebXRFeatureName {
  139722. /**
  139723. * The name of the anchor system feature
  139724. */
  139725. static readonly ANCHOR_SYSTEM: string;
  139726. /**
  139727. * The name of the background remover feature
  139728. */
  139729. static readonly BACKGROUND_REMOVER: string;
  139730. /**
  139731. * The name of the hit test feature
  139732. */
  139733. static readonly HIT_TEST: string;
  139734. /**
  139735. * The name of the mesh detection feature
  139736. */
  139737. static readonly MESH_DETECTION: string;
  139738. /**
  139739. * physics impostors for xr controllers feature
  139740. */
  139741. static readonly PHYSICS_CONTROLLERS: string;
  139742. /**
  139743. * The name of the plane detection feature
  139744. */
  139745. static readonly PLANE_DETECTION: string;
  139746. /**
  139747. * The name of the pointer selection feature
  139748. */
  139749. static readonly POINTER_SELECTION: string;
  139750. /**
  139751. * The name of the teleportation feature
  139752. */
  139753. static readonly TELEPORTATION: string;
  139754. /**
  139755. * The name of the feature points feature.
  139756. */
  139757. static readonly FEATURE_POINTS: string;
  139758. /**
  139759. * The name of the hand tracking feature.
  139760. */
  139761. static readonly HAND_TRACKING: string;
  139762. /**
  139763. * The name of the image tracking feature
  139764. */
  139765. static readonly IMAGE_TRACKING: string;
  139766. }
  139767. /**
  139768. * Defining the constructor of a feature. Used to register the modules.
  139769. */
  139770. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  139771. /**
  139772. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  139773. * It is mainly used in AR sessions.
  139774. *
  139775. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  139776. */
  139777. export class WebXRFeaturesManager implements IDisposable {
  139778. private _xrSessionManager;
  139779. private static readonly _AvailableFeatures;
  139780. private _features;
  139781. /**
  139782. * constructs a new features manages.
  139783. *
  139784. * @param _xrSessionManager an instance of WebXRSessionManager
  139785. */
  139786. constructor(_xrSessionManager: WebXRSessionManager);
  139787. /**
  139788. * Used to register a module. After calling this function a developer can use this feature in the scene.
  139789. * Mainly used internally.
  139790. *
  139791. * @param featureName the name of the feature to register
  139792. * @param constructorFunction the function used to construct the module
  139793. * @param version the (babylon) version of the module
  139794. * @param stable is that a stable version of this module
  139795. */
  139796. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  139797. /**
  139798. * Returns a constructor of a specific feature.
  139799. *
  139800. * @param featureName the name of the feature to construct
  139801. * @param version the version of the feature to load
  139802. * @param xrSessionManager the xrSessionManager. Used to construct the module
  139803. * @param options optional options provided to the module.
  139804. * @returns a function that, when called, will return a new instance of this feature
  139805. */
  139806. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  139807. /**
  139808. * Can be used to return the list of features currently registered
  139809. *
  139810. * @returns an Array of available features
  139811. */
  139812. static GetAvailableFeatures(): string[];
  139813. /**
  139814. * Gets the versions available for a specific feature
  139815. * @param featureName the name of the feature
  139816. * @returns an array with the available versions
  139817. */
  139818. static GetAvailableVersions(featureName: string): string[];
  139819. /**
  139820. * Return the latest unstable version of this feature
  139821. * @param featureName the name of the feature to search
  139822. * @returns the version number. if not found will return -1
  139823. */
  139824. static GetLatestVersionOfFeature(featureName: string): number;
  139825. /**
  139826. * Return the latest stable version of this feature
  139827. * @param featureName the name of the feature to search
  139828. * @returns the version number. if not found will return -1
  139829. */
  139830. static GetStableVersionOfFeature(featureName: string): number;
  139831. /**
  139832. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  139833. * Can be used during a session to start a feature
  139834. * @param featureName the name of feature to attach
  139835. */
  139836. attachFeature(featureName: string): void;
  139837. /**
  139838. * Can be used inside a session or when the session ends to detach a specific feature
  139839. * @param featureName the name of the feature to detach
  139840. */
  139841. detachFeature(featureName: string): void;
  139842. /**
  139843. * Used to disable an already-enabled feature
  139844. * The feature will be disposed and will be recreated once enabled.
  139845. * @param featureName the feature to disable
  139846. * @returns true if disable was successful
  139847. */
  139848. disableFeature(featureName: string | {
  139849. Name: string;
  139850. }): boolean;
  139851. /**
  139852. * dispose this features manager
  139853. */
  139854. dispose(): void;
  139855. /**
  139856. * 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.
  139857. * 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.
  139858. *
  139859. * @param featureName the name of the feature to load or the class of the feature
  139860. * @param version optional version to load. if not provided the latest version will be enabled
  139861. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  139862. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  139863. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  139864. * @returns a new constructed feature or throws an error if feature not found.
  139865. */
  139866. enableFeature(featureName: string | {
  139867. Name: string;
  139868. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  139869. /**
  139870. * get the implementation of an enabled feature.
  139871. * @param featureName the name of the feature to load
  139872. * @returns the feature class, if found
  139873. */
  139874. getEnabledFeature(featureName: string): IWebXRFeature;
  139875. /**
  139876. * Get the list of enabled features
  139877. * @returns an array of enabled features
  139878. */
  139879. getEnabledFeatures(): string[];
  139880. /**
  139881. * This function will extend the session creation configuration object with enabled features.
  139882. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  139883. * according to the defined "required" variable, provided during enableFeature call
  139884. * @param xrSessionInit the xr Session init object to extend
  139885. *
  139886. * @returns an extended XRSessionInit object
  139887. */
  139888. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  139889. }
  139890. }
  139891. declare module BABYLON {
  139892. /**
  139893. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  139894. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  139895. */
  139896. export class WebXRExperienceHelper implements IDisposable {
  139897. private scene;
  139898. private _nonVRCamera;
  139899. private _originalSceneAutoClear;
  139900. private _supported;
  139901. /**
  139902. * Camera used to render xr content
  139903. */
  139904. camera: WebXRCamera;
  139905. /** A features manager for this xr session */
  139906. featuresManager: WebXRFeaturesManager;
  139907. /**
  139908. * Observers registered here will be triggered after the camera's initial transformation is set
  139909. * This can be used to set a different ground level or an extra rotation.
  139910. *
  139911. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  139912. * to the position set after this observable is done executing.
  139913. */
  139914. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  139915. /**
  139916. * Fires when the state of the experience helper has changed
  139917. */
  139918. onStateChangedObservable: Observable<WebXRState>;
  139919. /** Session manager used to keep track of xr session */
  139920. sessionManager: WebXRSessionManager;
  139921. /**
  139922. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  139923. */
  139924. state: WebXRState;
  139925. /**
  139926. * Creates a WebXRExperienceHelper
  139927. * @param scene The scene the helper should be created in
  139928. */
  139929. private constructor();
  139930. /**
  139931. * Creates the experience helper
  139932. * @param scene the scene to attach the experience helper to
  139933. * @returns a promise for the experience helper
  139934. */
  139935. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  139936. /**
  139937. * Disposes of the experience helper
  139938. */
  139939. dispose(): void;
  139940. /**
  139941. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  139942. * @param sessionMode options for the XR session
  139943. * @param referenceSpaceType frame of reference of the XR session
  139944. * @param renderTarget the output canvas that will be used to enter XR mode
  139945. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  139946. * @returns promise that resolves after xr mode has entered
  139947. */
  139948. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  139949. /**
  139950. * Exits XR mode and returns the scene to its original state
  139951. * @returns promise that resolves after xr mode has exited
  139952. */
  139953. exitXRAsync(): Promise<void>;
  139954. private _nonXRToXRCamera;
  139955. private _setState;
  139956. }
  139957. }
  139958. declare module BABYLON {
  139959. /**
  139960. * X-Y values for axes in WebXR
  139961. */
  139962. export interface IWebXRMotionControllerAxesValue {
  139963. /**
  139964. * The value of the x axis
  139965. */
  139966. x: number;
  139967. /**
  139968. * The value of the y-axis
  139969. */
  139970. y: number;
  139971. }
  139972. /**
  139973. * changed / previous values for the values of this component
  139974. */
  139975. export interface IWebXRMotionControllerComponentChangesValues<T> {
  139976. /**
  139977. * current (this frame) value
  139978. */
  139979. current: T;
  139980. /**
  139981. * previous (last change) value
  139982. */
  139983. previous: T;
  139984. }
  139985. /**
  139986. * Represents changes in the component between current frame and last values recorded
  139987. */
  139988. export interface IWebXRMotionControllerComponentChanges {
  139989. /**
  139990. * will be populated with previous and current values if axes changed
  139991. */
  139992. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  139993. /**
  139994. * will be populated with previous and current values if pressed changed
  139995. */
  139996. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  139997. /**
  139998. * will be populated with previous and current values if touched changed
  139999. */
  140000. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  140001. /**
  140002. * will be populated with previous and current values if value changed
  140003. */
  140004. value?: IWebXRMotionControllerComponentChangesValues<number>;
  140005. }
  140006. /**
  140007. * This class represents a single component (for example button or thumbstick) of a motion controller
  140008. */
  140009. export class WebXRControllerComponent implements IDisposable {
  140010. /**
  140011. * the id of this component
  140012. */
  140013. id: string;
  140014. /**
  140015. * the type of the component
  140016. */
  140017. type: MotionControllerComponentType;
  140018. private _buttonIndex;
  140019. private _axesIndices;
  140020. private _axes;
  140021. private _changes;
  140022. private _currentValue;
  140023. private _hasChanges;
  140024. private _pressed;
  140025. private _touched;
  140026. /**
  140027. * button component type
  140028. */
  140029. static BUTTON_TYPE: MotionControllerComponentType;
  140030. /**
  140031. * squeeze component type
  140032. */
  140033. static SQUEEZE_TYPE: MotionControllerComponentType;
  140034. /**
  140035. * Thumbstick component type
  140036. */
  140037. static THUMBSTICK_TYPE: MotionControllerComponentType;
  140038. /**
  140039. * Touchpad component type
  140040. */
  140041. static TOUCHPAD_TYPE: MotionControllerComponentType;
  140042. /**
  140043. * trigger component type
  140044. */
  140045. static TRIGGER_TYPE: MotionControllerComponentType;
  140046. /**
  140047. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  140048. * the axes data changes
  140049. */
  140050. onAxisValueChangedObservable: Observable<{
  140051. x: number;
  140052. y: number;
  140053. }>;
  140054. /**
  140055. * Observers registered here will be triggered when the state of a button changes
  140056. * State change is either pressed / touched / value
  140057. */
  140058. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  140059. /**
  140060. * Creates a new component for a motion controller.
  140061. * It is created by the motion controller itself
  140062. *
  140063. * @param id the id of this component
  140064. * @param type the type of the component
  140065. * @param _buttonIndex index in the buttons array of the gamepad
  140066. * @param _axesIndices indices of the values in the axes array of the gamepad
  140067. */
  140068. constructor(
  140069. /**
  140070. * the id of this component
  140071. */
  140072. id: string,
  140073. /**
  140074. * the type of the component
  140075. */
  140076. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  140077. /**
  140078. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  140079. */
  140080. get axes(): IWebXRMotionControllerAxesValue;
  140081. /**
  140082. * Get the changes. Elements will be populated only if they changed with their previous and current value
  140083. */
  140084. get changes(): IWebXRMotionControllerComponentChanges;
  140085. /**
  140086. * Return whether or not the component changed the last frame
  140087. */
  140088. get hasChanges(): boolean;
  140089. /**
  140090. * is the button currently pressed
  140091. */
  140092. get pressed(): boolean;
  140093. /**
  140094. * is the button currently touched
  140095. */
  140096. get touched(): boolean;
  140097. /**
  140098. * Get the current value of this component
  140099. */
  140100. get value(): number;
  140101. /**
  140102. * Dispose this component
  140103. */
  140104. dispose(): void;
  140105. /**
  140106. * Are there axes correlating to this component
  140107. * @return true is axes data is available
  140108. */
  140109. isAxes(): boolean;
  140110. /**
  140111. * Is this component a button (hence - pressable)
  140112. * @returns true if can be pressed
  140113. */
  140114. isButton(): boolean;
  140115. /**
  140116. * update this component using the gamepad object it is in. Called on every frame
  140117. * @param nativeController the native gamepad controller object
  140118. */
  140119. update(nativeController: IMinimalMotionControllerObject): void;
  140120. }
  140121. }
  140122. declare module BABYLON {
  140123. /**
  140124. * Type used for the success callback of ImportMesh
  140125. */
  140126. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  140127. /**
  140128. * Interface used for the result of ImportMeshAsync
  140129. */
  140130. export interface ISceneLoaderAsyncResult {
  140131. /**
  140132. * The array of loaded meshes
  140133. */
  140134. readonly meshes: AbstractMesh[];
  140135. /**
  140136. * The array of loaded particle systems
  140137. */
  140138. readonly particleSystems: IParticleSystem[];
  140139. /**
  140140. * The array of loaded skeletons
  140141. */
  140142. readonly skeletons: Skeleton[];
  140143. /**
  140144. * The array of loaded animation groups
  140145. */
  140146. readonly animationGroups: AnimationGroup[];
  140147. /**
  140148. * The array of loaded transform nodes
  140149. */
  140150. readonly transformNodes: TransformNode[];
  140151. /**
  140152. * The array of loaded geometries
  140153. */
  140154. readonly geometries: Geometry[];
  140155. /**
  140156. * The array of loaded lights
  140157. */
  140158. readonly lights: Light[];
  140159. }
  140160. /**
  140161. * Interface used to represent data loading progression
  140162. */
  140163. export interface ISceneLoaderProgressEvent {
  140164. /**
  140165. * Defines if data length to load can be evaluated
  140166. */
  140167. readonly lengthComputable: boolean;
  140168. /**
  140169. * Defines the loaded data length
  140170. */
  140171. readonly loaded: number;
  140172. /**
  140173. * Defines the data length to load
  140174. */
  140175. readonly total: number;
  140176. }
  140177. /**
  140178. * Interface used by SceneLoader plugins to define supported file extensions
  140179. */
  140180. export interface ISceneLoaderPluginExtensions {
  140181. /**
  140182. * Defines the list of supported extensions
  140183. */
  140184. [extension: string]: {
  140185. isBinary: boolean;
  140186. };
  140187. }
  140188. /**
  140189. * Interface used by SceneLoader plugin factory
  140190. */
  140191. export interface ISceneLoaderPluginFactory {
  140192. /**
  140193. * Defines the name of the factory
  140194. */
  140195. name: string;
  140196. /**
  140197. * Function called to create a new plugin
  140198. * @return the new plugin
  140199. */
  140200. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  140201. /**
  140202. * The callback that returns true if the data can be directly loaded.
  140203. * @param data string containing the file data
  140204. * @returns if the data can be loaded directly
  140205. */
  140206. canDirectLoad?(data: string): boolean;
  140207. }
  140208. /**
  140209. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  140210. */
  140211. export interface ISceneLoaderPluginBase {
  140212. /**
  140213. * The friendly name of this plugin.
  140214. */
  140215. name: string;
  140216. /**
  140217. * The file extensions supported by this plugin.
  140218. */
  140219. extensions: string | ISceneLoaderPluginExtensions;
  140220. /**
  140221. * The callback called when loading from a url.
  140222. * @param scene scene loading this url
  140223. * @param url url to load
  140224. * @param onSuccess callback called when the file successfully loads
  140225. * @param onProgress callback called while file is loading (if the server supports this mode)
  140226. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  140227. * @param onError callback called when the file fails to load
  140228. * @returns a file request object
  140229. */
  140230. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  140231. /**
  140232. * The callback called when loading from a file object.
  140233. * @param scene scene loading this file
  140234. * @param file defines the file to load
  140235. * @param onSuccess defines the callback to call when data is loaded
  140236. * @param onProgress defines the callback to call during loading process
  140237. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  140238. * @param onError defines the callback to call when an error occurs
  140239. * @returns a file request object
  140240. */
  140241. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  140242. /**
  140243. * The callback that returns true if the data can be directly loaded.
  140244. * @param data string containing the file data
  140245. * @returns if the data can be loaded directly
  140246. */
  140247. canDirectLoad?(data: string): boolean;
  140248. /**
  140249. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  140250. * @param scene scene loading this data
  140251. * @param data string containing the data
  140252. * @returns data to pass to the plugin
  140253. */
  140254. directLoad?(scene: Scene, data: string): any;
  140255. /**
  140256. * The callback that allows custom handling of the root url based on the response url.
  140257. * @param rootUrl the original root url
  140258. * @param responseURL the response url if available
  140259. * @returns the new root url
  140260. */
  140261. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  140262. }
  140263. /**
  140264. * Interface used to define a SceneLoader plugin
  140265. */
  140266. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  140267. /**
  140268. * Import meshes into a scene.
  140269. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  140270. * @param scene The scene to import into
  140271. * @param data The data to import
  140272. * @param rootUrl The root url for scene and resources
  140273. * @param meshes The meshes array to import into
  140274. * @param particleSystems The particle systems array to import into
  140275. * @param skeletons The skeletons array to import into
  140276. * @param onError The callback when import fails
  140277. * @returns True if successful or false otherwise
  140278. */
  140279. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  140280. /**
  140281. * Load into a scene.
  140282. * @param scene The scene to load into
  140283. * @param data The data to import
  140284. * @param rootUrl The root url for scene and resources
  140285. * @param onError The callback when import fails
  140286. * @returns True if successful or false otherwise
  140287. */
  140288. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  140289. /**
  140290. * Load into an asset container.
  140291. * @param scene The scene to load into
  140292. * @param data The data to import
  140293. * @param rootUrl The root url for scene and resources
  140294. * @param onError The callback when import fails
  140295. * @returns The loaded asset container
  140296. */
  140297. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  140298. }
  140299. /**
  140300. * Interface used to define an async SceneLoader plugin
  140301. */
  140302. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  140303. /**
  140304. * Import meshes into a scene.
  140305. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  140306. * @param scene The scene to import into
  140307. * @param data The data to import
  140308. * @param rootUrl The root url for scene and resources
  140309. * @param onProgress The callback when the load progresses
  140310. * @param fileName Defines the name of the file to load
  140311. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  140312. */
  140313. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  140314. /**
  140315. * Load into a scene.
  140316. * @param scene The scene to load into
  140317. * @param data The data to import
  140318. * @param rootUrl The root url for scene and resources
  140319. * @param onProgress The callback when the load progresses
  140320. * @param fileName Defines the name of the file to load
  140321. * @returns Nothing
  140322. */
  140323. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  140324. /**
  140325. * Load into an asset container.
  140326. * @param scene The scene to load into
  140327. * @param data The data to import
  140328. * @param rootUrl The root url for scene and resources
  140329. * @param onProgress The callback when the load progresses
  140330. * @param fileName Defines the name of the file to load
  140331. * @returns The loaded asset container
  140332. */
  140333. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  140334. }
  140335. /**
  140336. * Mode that determines how to handle old animation groups before loading new ones.
  140337. */
  140338. export enum SceneLoaderAnimationGroupLoadingMode {
  140339. /**
  140340. * Reset all old animations to initial state then dispose them.
  140341. */
  140342. Clean = 0,
  140343. /**
  140344. * Stop all old animations.
  140345. */
  140346. Stop = 1,
  140347. /**
  140348. * Restart old animations from first frame.
  140349. */
  140350. Sync = 2,
  140351. /**
  140352. * Old animations remains untouched.
  140353. */
  140354. NoSync = 3
  140355. }
  140356. /**
  140357. * Defines a plugin registered by the SceneLoader
  140358. */
  140359. interface IRegisteredPlugin {
  140360. /**
  140361. * Defines the plugin to use
  140362. */
  140363. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  140364. /**
  140365. * Defines if the plugin supports binary data
  140366. */
  140367. isBinary: boolean;
  140368. }
  140369. /**
  140370. * Class used to load scene from various file formats using registered plugins
  140371. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  140372. */
  140373. export class SceneLoader {
  140374. /**
  140375. * No logging while loading
  140376. */
  140377. static readonly NO_LOGGING: number;
  140378. /**
  140379. * Minimal logging while loading
  140380. */
  140381. static readonly MINIMAL_LOGGING: number;
  140382. /**
  140383. * Summary logging while loading
  140384. */
  140385. static readonly SUMMARY_LOGGING: number;
  140386. /**
  140387. * Detailed logging while loading
  140388. */
  140389. static readonly DETAILED_LOGGING: number;
  140390. /**
  140391. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  140392. */
  140393. static get ForceFullSceneLoadingForIncremental(): boolean;
  140394. static set ForceFullSceneLoadingForIncremental(value: boolean);
  140395. /**
  140396. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  140397. */
  140398. static get ShowLoadingScreen(): boolean;
  140399. static set ShowLoadingScreen(value: boolean);
  140400. /**
  140401. * Defines the current logging level (while loading the scene)
  140402. * @ignorenaming
  140403. */
  140404. static get loggingLevel(): number;
  140405. static set loggingLevel(value: number);
  140406. /**
  140407. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  140408. */
  140409. static get CleanBoneMatrixWeights(): boolean;
  140410. static set CleanBoneMatrixWeights(value: boolean);
  140411. /**
  140412. * Event raised when a plugin is used to load a scene
  140413. */
  140414. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  140415. private static _registeredPlugins;
  140416. private static _showingLoadingScreen;
  140417. /**
  140418. * Gets the default plugin (used to load Babylon files)
  140419. * @returns the .babylon plugin
  140420. */
  140421. static GetDefaultPlugin(): IRegisteredPlugin;
  140422. private static _GetPluginForExtension;
  140423. private static _GetPluginForDirectLoad;
  140424. private static _GetPluginForFilename;
  140425. private static _GetDirectLoad;
  140426. private static _LoadData;
  140427. private static _GetFileInfo;
  140428. /**
  140429. * Gets a plugin that can load the given extension
  140430. * @param extension defines the extension to load
  140431. * @returns a plugin or null if none works
  140432. */
  140433. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  140434. /**
  140435. * Gets a boolean indicating that the given extension can be loaded
  140436. * @param extension defines the extension to load
  140437. * @returns true if the extension is supported
  140438. */
  140439. static IsPluginForExtensionAvailable(extension: string): boolean;
  140440. /**
  140441. * Adds a new plugin to the list of registered plugins
  140442. * @param plugin defines the plugin to add
  140443. */
  140444. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  140445. /**
  140446. * Import meshes into a scene
  140447. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  140448. * @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)
  140449. * @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)
  140450. * @param scene the instance of BABYLON.Scene to append to
  140451. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  140452. * @param onProgress a callback with a progress event for each file being loaded
  140453. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  140454. * @param pluginExtension the extension used to determine the plugin
  140455. * @returns The loaded plugin
  140456. */
  140457. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  140458. /**
  140459. * Import meshes into a scene
  140460. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  140461. * @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)
  140462. * @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)
  140463. * @param scene the instance of BABYLON.Scene to append to
  140464. * @param onProgress a callback with a progress event for each file being loaded
  140465. * @param pluginExtension the extension used to determine the plugin
  140466. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  140467. */
  140468. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  140469. /**
  140470. * Load a scene
  140471. * @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)
  140472. * @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)
  140473. * @param engine is the instance of BABYLON.Engine to use to create the scene
  140474. * @param onSuccess a callback with the scene when import succeeds
  140475. * @param onProgress a callback with a progress event for each file being loaded
  140476. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  140477. * @param pluginExtension the extension used to determine the plugin
  140478. * @returns The loaded plugin
  140479. */
  140480. 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>;
  140481. /**
  140482. * Load a scene
  140483. * @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)
  140484. * @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)
  140485. * @param engine is the instance of BABYLON.Engine to use to create the scene
  140486. * @param onProgress a callback with a progress event for each file being loaded
  140487. * @param pluginExtension the extension used to determine the plugin
  140488. * @returns The loaded scene
  140489. */
  140490. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  140491. /**
  140492. * Append a scene
  140493. * @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)
  140494. * @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)
  140495. * @param scene is the instance of BABYLON.Scene to append to
  140496. * @param onSuccess a callback with the scene when import succeeds
  140497. * @param onProgress a callback with a progress event for each file being loaded
  140498. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  140499. * @param pluginExtension the extension used to determine the plugin
  140500. * @returns The loaded plugin
  140501. */
  140502. 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>;
  140503. /**
  140504. * Append a scene
  140505. * @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)
  140506. * @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)
  140507. * @param scene is the instance of BABYLON.Scene to append to
  140508. * @param onProgress a callback with a progress event for each file being loaded
  140509. * @param pluginExtension the extension used to determine the plugin
  140510. * @returns The given scene
  140511. */
  140512. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  140513. /**
  140514. * Load a scene into an asset container
  140515. * @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)
  140516. * @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)
  140517. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  140518. * @param onSuccess a callback with the scene when import succeeds
  140519. * @param onProgress a callback with a progress event for each file being loaded
  140520. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  140521. * @param pluginExtension the extension used to determine the plugin
  140522. * @returns The loaded plugin
  140523. */
  140524. 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>;
  140525. /**
  140526. * Load a scene into an asset container
  140527. * @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)
  140528. * @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)
  140529. * @param scene is the instance of Scene to append to
  140530. * @param onProgress a callback with a progress event for each file being loaded
  140531. * @param pluginExtension the extension used to determine the plugin
  140532. * @returns The loaded asset container
  140533. */
  140534. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  140535. /**
  140536. * Import animations from a file into a scene
  140537. * @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)
  140538. * @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)
  140539. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  140540. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  140541. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  140542. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  140543. * @param onSuccess a callback with the scene when import succeeds
  140544. * @param onProgress a callback with a progress event for each file being loaded
  140545. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  140546. * @param pluginExtension the extension used to determine the plugin
  140547. */
  140548. 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;
  140549. /**
  140550. * Import animations from a file into a scene
  140551. * @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)
  140552. * @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)
  140553. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  140554. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  140555. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  140556. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  140557. * @param onSuccess a callback with the scene when import succeeds
  140558. * @param onProgress a callback with a progress event for each file being loaded
  140559. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  140560. * @param pluginExtension the extension used to determine the plugin
  140561. * @returns the updated scene with imported animations
  140562. */
  140563. 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>;
  140564. }
  140565. }
  140566. declare module BABYLON {
  140567. /**
  140568. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  140569. */
  140570. export type MotionControllerHandedness = "none" | "left" | "right";
  140571. /**
  140572. * The type of components available in motion controllers.
  140573. * This is not the name of the component.
  140574. */
  140575. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  140576. /**
  140577. * The state of a controller component
  140578. */
  140579. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  140580. /**
  140581. * The schema of motion controller layout.
  140582. * No object will be initialized using this interface
  140583. * This is used just to define the profile.
  140584. */
  140585. export interface IMotionControllerLayout {
  140586. /**
  140587. * Path to load the assets. Usually relative to the base path
  140588. */
  140589. assetPath: string;
  140590. /**
  140591. * Available components (unsorted)
  140592. */
  140593. components: {
  140594. /**
  140595. * A map of component Ids
  140596. */
  140597. [componentId: string]: {
  140598. /**
  140599. * The type of input the component outputs
  140600. */
  140601. type: MotionControllerComponentType;
  140602. /**
  140603. * The indices of this component in the gamepad object
  140604. */
  140605. gamepadIndices: {
  140606. /**
  140607. * Index of button
  140608. */
  140609. button?: number;
  140610. /**
  140611. * If available, index of x-axis
  140612. */
  140613. xAxis?: number;
  140614. /**
  140615. * If available, index of y-axis
  140616. */
  140617. yAxis?: number;
  140618. };
  140619. /**
  140620. * The mesh's root node name
  140621. */
  140622. rootNodeName: string;
  140623. /**
  140624. * Animation definitions for this model
  140625. */
  140626. visualResponses: {
  140627. [stateKey: string]: {
  140628. /**
  140629. * What property will be animated
  140630. */
  140631. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  140632. /**
  140633. * What states influence this visual response
  140634. */
  140635. states: MotionControllerComponentStateType[];
  140636. /**
  140637. * Type of animation - movement or visibility
  140638. */
  140639. valueNodeProperty: "transform" | "visibility";
  140640. /**
  140641. * Base node name to move. Its position will be calculated according to the min and max nodes
  140642. */
  140643. valueNodeName?: string;
  140644. /**
  140645. * Minimum movement node
  140646. */
  140647. minNodeName?: string;
  140648. /**
  140649. * Max movement node
  140650. */
  140651. maxNodeName?: string;
  140652. };
  140653. };
  140654. /**
  140655. * If touch enabled, what is the name of node to display user feedback
  140656. */
  140657. touchPointNodeName?: string;
  140658. };
  140659. };
  140660. /**
  140661. * Is it xr standard mapping or not
  140662. */
  140663. gamepadMapping: "" | "xr-standard";
  140664. /**
  140665. * Base root node of this entire model
  140666. */
  140667. rootNodeName: string;
  140668. /**
  140669. * Defines the main button component id
  140670. */
  140671. selectComponentId: string;
  140672. }
  140673. /**
  140674. * A definition for the layout map in the input profile
  140675. */
  140676. export interface IMotionControllerLayoutMap {
  140677. /**
  140678. * Layouts with handedness type as a key
  140679. */
  140680. [handedness: string]: IMotionControllerLayout;
  140681. }
  140682. /**
  140683. * The XR Input profile schema
  140684. * Profiles can be found here:
  140685. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  140686. */
  140687. export interface IMotionControllerProfile {
  140688. /**
  140689. * fallback profiles for this profileId
  140690. */
  140691. fallbackProfileIds: string[];
  140692. /**
  140693. * The layout map, with handedness as key
  140694. */
  140695. layouts: IMotionControllerLayoutMap;
  140696. /**
  140697. * The id of this profile
  140698. * correlates to the profile(s) in the xrInput.profiles array
  140699. */
  140700. profileId: string;
  140701. }
  140702. /**
  140703. * A helper-interface for the 3 meshes needed for controller button animation
  140704. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  140705. */
  140706. export interface IMotionControllerButtonMeshMap {
  140707. /**
  140708. * the mesh that defines the pressed value mesh position.
  140709. * This is used to find the max-position of this button
  140710. */
  140711. pressedMesh: AbstractMesh;
  140712. /**
  140713. * the mesh that defines the unpressed value mesh position.
  140714. * This is used to find the min (or initial) position of this button
  140715. */
  140716. unpressedMesh: AbstractMesh;
  140717. /**
  140718. * The mesh that will be changed when value changes
  140719. */
  140720. valueMesh: AbstractMesh;
  140721. }
  140722. /**
  140723. * A helper-interface for the 3 meshes needed for controller axis animation.
  140724. * This will be expanded when touchpad animations are fully supported
  140725. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  140726. */
  140727. export interface IMotionControllerMeshMap {
  140728. /**
  140729. * the mesh that defines the maximum value mesh position.
  140730. */
  140731. maxMesh?: AbstractMesh;
  140732. /**
  140733. * the mesh that defines the minimum value mesh position.
  140734. */
  140735. minMesh?: AbstractMesh;
  140736. /**
  140737. * The mesh that will be changed when axis value changes
  140738. */
  140739. valueMesh?: AbstractMesh;
  140740. }
  140741. /**
  140742. * The elements needed for change-detection of the gamepad objects in motion controllers
  140743. */
  140744. export interface IMinimalMotionControllerObject {
  140745. /**
  140746. * Available axes of this controller
  140747. */
  140748. axes: number[];
  140749. /**
  140750. * An array of available buttons
  140751. */
  140752. buttons: Array<{
  140753. /**
  140754. * Value of the button/trigger
  140755. */
  140756. value: number;
  140757. /**
  140758. * If the button/trigger is currently touched
  140759. */
  140760. touched: boolean;
  140761. /**
  140762. * If the button/trigger is currently pressed
  140763. */
  140764. pressed: boolean;
  140765. }>;
  140766. /**
  140767. * EXPERIMENTAL haptic support.
  140768. */
  140769. hapticActuators?: Array<{
  140770. pulse: (value: number, duration: number) => Promise<boolean>;
  140771. }>;
  140772. }
  140773. /**
  140774. * An Abstract Motion controller
  140775. * This class receives an xrInput and a profile layout and uses those to initialize the components
  140776. * Each component has an observable to check for changes in value and state
  140777. */
  140778. export abstract class WebXRAbstractMotionController implements IDisposable {
  140779. protected scene: Scene;
  140780. protected layout: IMotionControllerLayout;
  140781. /**
  140782. * The gamepad object correlating to this controller
  140783. */
  140784. gamepadObject: IMinimalMotionControllerObject;
  140785. /**
  140786. * handedness (left/right/none) of this controller
  140787. */
  140788. handedness: MotionControllerHandedness;
  140789. private _initComponent;
  140790. private _modelReady;
  140791. /**
  140792. * A map of components (WebXRControllerComponent) in this motion controller
  140793. * Components have a ComponentType and can also have both button and axis definitions
  140794. */
  140795. readonly components: {
  140796. [id: string]: WebXRControllerComponent;
  140797. };
  140798. /**
  140799. * Disable the model's animation. Can be set at any time.
  140800. */
  140801. disableAnimation: boolean;
  140802. /**
  140803. * Observers registered here will be triggered when the model of this controller is done loading
  140804. */
  140805. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  140806. /**
  140807. * The profile id of this motion controller
  140808. */
  140809. abstract profileId: string;
  140810. /**
  140811. * The root mesh of the model. It is null if the model was not yet initialized
  140812. */
  140813. rootMesh: Nullable<AbstractMesh>;
  140814. /**
  140815. * constructs a new abstract motion controller
  140816. * @param scene the scene to which the model of the controller will be added
  140817. * @param layout The profile layout to load
  140818. * @param gamepadObject The gamepad object correlating to this controller
  140819. * @param handedness handedness (left/right/none) of this controller
  140820. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  140821. */
  140822. constructor(scene: Scene, layout: IMotionControllerLayout,
  140823. /**
  140824. * The gamepad object correlating to this controller
  140825. */
  140826. gamepadObject: IMinimalMotionControllerObject,
  140827. /**
  140828. * handedness (left/right/none) of this controller
  140829. */
  140830. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  140831. /**
  140832. * Dispose this controller, the model mesh and all its components
  140833. */
  140834. dispose(): void;
  140835. /**
  140836. * Returns all components of specific type
  140837. * @param type the type to search for
  140838. * @return an array of components with this type
  140839. */
  140840. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  140841. /**
  140842. * get a component based an its component id as defined in layout.components
  140843. * @param id the id of the component
  140844. * @returns the component correlates to the id or undefined if not found
  140845. */
  140846. getComponent(id: string): WebXRControllerComponent;
  140847. /**
  140848. * Get the list of components available in this motion controller
  140849. * @returns an array of strings correlating to available components
  140850. */
  140851. getComponentIds(): string[];
  140852. /**
  140853. * Get the first component of specific type
  140854. * @param type type of component to find
  140855. * @return a controller component or null if not found
  140856. */
  140857. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  140858. /**
  140859. * Get the main (Select) component of this controller as defined in the layout
  140860. * @returns the main component of this controller
  140861. */
  140862. getMainComponent(): WebXRControllerComponent;
  140863. /**
  140864. * Loads the model correlating to this controller
  140865. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  140866. * @returns A promise fulfilled with the result of the model loading
  140867. */
  140868. loadModel(): Promise<boolean>;
  140869. /**
  140870. * Update this model using the current XRFrame
  140871. * @param xrFrame the current xr frame to use and update the model
  140872. */
  140873. updateFromXRFrame(xrFrame: XRFrame): void;
  140874. /**
  140875. * Backwards compatibility due to a deeply-integrated typo
  140876. */
  140877. get handness(): XREye;
  140878. /**
  140879. * Pulse (vibrate) this controller
  140880. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  140881. * Consecutive calls to this function will cancel the last pulse call
  140882. *
  140883. * @param value the strength of the pulse in 0.0...1.0 range
  140884. * @param duration Duration of the pulse in milliseconds
  140885. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  140886. * @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
  140887. */
  140888. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  140889. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  140890. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  140891. /**
  140892. * Moves the axis on the controller mesh based on its current state
  140893. * @param axis the index of the axis
  140894. * @param axisValue the value of the axis which determines the meshes new position
  140895. * @hidden
  140896. */
  140897. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  140898. /**
  140899. * Update the model itself with the current frame data
  140900. * @param xrFrame the frame to use for updating the model mesh
  140901. */
  140902. protected updateModel(xrFrame: XRFrame): void;
  140903. /**
  140904. * Get the filename and path for this controller's model
  140905. * @returns a map of filename and path
  140906. */
  140907. protected abstract _getFilenameAndPath(): {
  140908. filename: string;
  140909. path: string;
  140910. };
  140911. /**
  140912. * This function is called before the mesh is loaded. It checks for loading constraints.
  140913. * For example, this function can check if the GLB loader is available
  140914. * If this function returns false, the generic controller will be loaded instead
  140915. * @returns Is the client ready to load the mesh
  140916. */
  140917. protected abstract _getModelLoadingConstraints(): boolean;
  140918. /**
  140919. * This function will be called after the model was successfully loaded and can be used
  140920. * for mesh transformations before it is available for the user
  140921. * @param meshes the loaded meshes
  140922. */
  140923. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  140924. /**
  140925. * Set the root mesh for this controller. Important for the WebXR controller class
  140926. * @param meshes the loaded meshes
  140927. */
  140928. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  140929. /**
  140930. * A function executed each frame that updates the mesh (if needed)
  140931. * @param xrFrame the current xrFrame
  140932. */
  140933. protected abstract _updateModel(xrFrame: XRFrame): void;
  140934. private _getGenericFilenameAndPath;
  140935. private _getGenericParentMesh;
  140936. }
  140937. }
  140938. declare module BABYLON {
  140939. /**
  140940. * A generic trigger-only motion controller for WebXR
  140941. */
  140942. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  140943. /**
  140944. * Static version of the profile id of this controller
  140945. */
  140946. static ProfileId: string;
  140947. profileId: string;
  140948. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  140949. protected _getFilenameAndPath(): {
  140950. filename: string;
  140951. path: string;
  140952. };
  140953. protected _getModelLoadingConstraints(): boolean;
  140954. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  140955. protected _setRootMesh(meshes: AbstractMesh[]): void;
  140956. protected _updateModel(): void;
  140957. }
  140958. }
  140959. declare module BABYLON {
  140960. /**
  140961. * Class containing static functions to help procedurally build meshes
  140962. */
  140963. export class SphereBuilder {
  140964. /**
  140965. * Creates a sphere mesh
  140966. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  140967. * * 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`)
  140968. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  140969. * * 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
  140970. * * 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)
  140971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140974. * @param name defines the name of the mesh
  140975. * @param options defines the options used to create the mesh
  140976. * @param scene defines the hosting scene
  140977. * @returns the sphere mesh
  140978. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  140979. */
  140980. static CreateSphere(name: string, options: {
  140981. segments?: number;
  140982. diameter?: number;
  140983. diameterX?: number;
  140984. diameterY?: number;
  140985. diameterZ?: number;
  140986. arc?: number;
  140987. slice?: number;
  140988. sideOrientation?: number;
  140989. frontUVs?: Vector4;
  140990. backUVs?: Vector4;
  140991. updatable?: boolean;
  140992. }, scene?: Nullable<Scene>): Mesh;
  140993. }
  140994. }
  140995. declare module BABYLON {
  140996. /**
  140997. * A profiled motion controller has its profile loaded from an online repository.
  140998. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  140999. */
  141000. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  141001. private _repositoryUrl;
  141002. private _buttonMeshMapping;
  141003. private _touchDots;
  141004. /**
  141005. * The profile ID of this controller. Will be populated when the controller initializes.
  141006. */
  141007. profileId: string;
  141008. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  141009. dispose(): void;
  141010. protected _getFilenameAndPath(): {
  141011. filename: string;
  141012. path: string;
  141013. };
  141014. protected _getModelLoadingConstraints(): boolean;
  141015. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  141016. protected _setRootMesh(meshes: AbstractMesh[]): void;
  141017. protected _updateModel(_xrFrame: XRFrame): void;
  141018. }
  141019. }
  141020. declare module BABYLON {
  141021. /**
  141022. * A construction function type to create a new controller based on an xrInput object
  141023. */
  141024. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  141025. /**
  141026. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  141027. *
  141028. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  141029. * it should be replaced with auto-loaded controllers.
  141030. *
  141031. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  141032. */
  141033. export class WebXRMotionControllerManager {
  141034. private static _AvailableControllers;
  141035. private static _Fallbacks;
  141036. private static _ProfileLoadingPromises;
  141037. private static _ProfilesList;
  141038. /**
  141039. * The base URL of the online controller repository. Can be changed at any time.
  141040. */
  141041. static BaseRepositoryUrl: string;
  141042. /**
  141043. * Which repository gets priority - local or online
  141044. */
  141045. static PrioritizeOnlineRepository: boolean;
  141046. /**
  141047. * Use the online repository, or use only locally-defined controllers
  141048. */
  141049. static UseOnlineRepository: boolean;
  141050. /**
  141051. * Clear the cache used for profile loading and reload when requested again
  141052. */
  141053. static ClearProfilesCache(): void;
  141054. /**
  141055. * Register the default fallbacks.
  141056. * This function is called automatically when this file is imported.
  141057. */
  141058. static DefaultFallbacks(): void;
  141059. /**
  141060. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  141061. * @param profileId the profile to which a fallback needs to be found
  141062. * @return an array with corresponding fallback profiles
  141063. */
  141064. static FindFallbackWithProfileId(profileId: string): string[];
  141065. /**
  141066. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  141067. * The order of search:
  141068. *
  141069. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  141070. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  141071. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  141072. * 4) return the generic trigger controller if none were found
  141073. *
  141074. * @param xrInput the xrInput to which a new controller is initialized
  141075. * @param scene the scene to which the model will be added
  141076. * @param forceProfile force a certain profile for this controller
  141077. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  141078. */
  141079. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  141080. /**
  141081. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  141082. *
  141083. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  141084. *
  141085. * @param type the profile type to register
  141086. * @param constructFunction the function to be called when loading this profile
  141087. */
  141088. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  141089. /**
  141090. * Register a fallback to a specific profile.
  141091. * @param profileId the profileId that will receive the fallbacks
  141092. * @param fallbacks A list of fallback profiles
  141093. */
  141094. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  141095. /**
  141096. * Will update the list of profiles available in the repository
  141097. * @return a promise that resolves to a map of profiles available online
  141098. */
  141099. static UpdateProfilesList(): Promise<{
  141100. [profile: string]: string;
  141101. }>;
  141102. private static _LoadProfileFromRepository;
  141103. private static _LoadProfilesFromAvailableControllers;
  141104. }
  141105. }
  141106. declare module BABYLON {
  141107. /**
  141108. * Configuration options for the WebXR controller creation
  141109. */
  141110. export interface IWebXRControllerOptions {
  141111. /**
  141112. * Should the controller mesh be animated when a user interacts with it
  141113. * The pressed buttons / thumbstick and touchpad animations will be disabled
  141114. */
  141115. disableMotionControllerAnimation?: boolean;
  141116. /**
  141117. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  141118. */
  141119. doNotLoadControllerMesh?: boolean;
  141120. /**
  141121. * Force a specific controller type for this controller.
  141122. * This can be used when creating your own profile or when testing different controllers
  141123. */
  141124. forceControllerProfile?: string;
  141125. /**
  141126. * Defines a rendering group ID for meshes that will be loaded.
  141127. * This is for the default controllers only.
  141128. */
  141129. renderingGroupId?: number;
  141130. }
  141131. /**
  141132. * Represents an XR controller
  141133. */
  141134. export class WebXRInputSource {
  141135. private _scene;
  141136. /** The underlying input source for the controller */
  141137. inputSource: XRInputSource;
  141138. private _options;
  141139. private _tmpVector;
  141140. private _uniqueId;
  141141. private _disposed;
  141142. /**
  141143. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if that's the case only the pointer from the head will be available
  141144. */
  141145. grip?: AbstractMesh;
  141146. /**
  141147. * If available, this is the gamepad object related to this controller.
  141148. * Using this object it is possible to get click events and trackpad changes of the
  141149. * webxr controller that is currently being used.
  141150. */
  141151. motionController?: WebXRAbstractMotionController;
  141152. /**
  141153. * Event that fires when the controller is removed/disposed.
  141154. * The object provided as event data is this controller, after associated assets were disposed.
  141155. * uniqueId is still available.
  141156. */
  141157. onDisposeObservable: Observable<WebXRInputSource>;
  141158. /**
  141159. * Will be triggered when the mesh associated with the motion controller is done loading.
  141160. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  141161. * A shortened version of controller -> motion controller -> on mesh loaded.
  141162. */
  141163. onMeshLoadedObservable: Observable<AbstractMesh>;
  141164. /**
  141165. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  141166. */
  141167. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  141168. /**
  141169. * Pointer which can be used to select objects or attach a visible laser to
  141170. */
  141171. pointer: AbstractMesh;
  141172. /**
  141173. * Creates the input source object
  141174. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  141175. * @param _scene the scene which the controller should be associated to
  141176. * @param inputSource the underlying input source for the controller
  141177. * @param _options options for this controller creation
  141178. */
  141179. constructor(_scene: Scene,
  141180. /** The underlying input source for the controller */
  141181. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  141182. /**
  141183. * Get this controllers unique id
  141184. */
  141185. get uniqueId(): string;
  141186. /**
  141187. * Disposes of the object
  141188. */
  141189. dispose(): void;
  141190. /**
  141191. * Gets a world space ray coming from the pointer or grip
  141192. * @param result the resulting ray
  141193. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  141194. */
  141195. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  141196. /**
  141197. * Updates the controller pose based on the given XRFrame
  141198. * @param xrFrame xr frame to update the pose with
  141199. * @param referenceSpace reference space to use
  141200. */
  141201. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  141202. }
  141203. }
  141204. declare module BABYLON {
  141205. /**
  141206. * The schema for initialization options of the XR Input class
  141207. */
  141208. export interface IWebXRInputOptions {
  141209. /**
  141210. * If set to true no model will be automatically loaded
  141211. */
  141212. doNotLoadControllerMeshes?: boolean;
  141213. /**
  141214. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  141215. * If not found, the xr input profile data will be used.
  141216. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  141217. */
  141218. forceInputProfile?: string;
  141219. /**
  141220. * Do not send a request to the controller repository to load the profile.
  141221. *
  141222. * Instead, use the controllers available in babylon itself.
  141223. */
  141224. disableOnlineControllerRepository?: boolean;
  141225. /**
  141226. * A custom URL for the controllers repository
  141227. */
  141228. customControllersRepositoryURL?: string;
  141229. /**
  141230. * Should the controller model's components not move according to the user input
  141231. */
  141232. disableControllerAnimation?: boolean;
  141233. /**
  141234. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  141235. */
  141236. controllerOptions?: IWebXRControllerOptions;
  141237. }
  141238. /**
  141239. * XR input used to track XR inputs such as controllers/rays
  141240. */
  141241. export class WebXRInput implements IDisposable {
  141242. /**
  141243. * the xr session manager for this session
  141244. */
  141245. xrSessionManager: WebXRSessionManager;
  141246. /**
  141247. * the WebXR camera for this session. Mainly used for teleportation
  141248. */
  141249. xrCamera: WebXRCamera;
  141250. private readonly options;
  141251. /**
  141252. * XR controllers being tracked
  141253. */
  141254. controllers: Array<WebXRInputSource>;
  141255. private _frameObserver;
  141256. private _sessionEndedObserver;
  141257. private _sessionInitObserver;
  141258. /**
  141259. * Event when a controller has been connected/added
  141260. */
  141261. onControllerAddedObservable: Observable<WebXRInputSource>;
  141262. /**
  141263. * Event when a controller has been removed/disconnected
  141264. */
  141265. onControllerRemovedObservable: Observable<WebXRInputSource>;
  141266. /**
  141267. * Initializes the WebXRInput
  141268. * @param xrSessionManager the xr session manager for this session
  141269. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  141270. * @param options = initialization options for this xr input
  141271. */
  141272. constructor(
  141273. /**
  141274. * the xr session manager for this session
  141275. */
  141276. xrSessionManager: WebXRSessionManager,
  141277. /**
  141278. * the WebXR camera for this session. Mainly used for teleportation
  141279. */
  141280. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  141281. private _onInputSourcesChange;
  141282. private _addAndRemoveControllers;
  141283. /**
  141284. * Disposes of the object
  141285. */
  141286. dispose(): void;
  141287. }
  141288. }
  141289. declare module BABYLON {
  141290. /**
  141291. * This is the base class for all WebXR features.
  141292. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  141293. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  141294. */
  141295. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  141296. protected _xrSessionManager: WebXRSessionManager;
  141297. private _attached;
  141298. private _removeOnDetach;
  141299. /**
  141300. * Is this feature disposed?
  141301. */
  141302. isDisposed: boolean;
  141303. /**
  141304. * Should auto-attach be disabled?
  141305. */
  141306. disableAutoAttach: boolean;
  141307. /**
  141308. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  141309. */
  141310. xrNativeFeatureName: string;
  141311. /**
  141312. * Construct a new (abstract) WebXR feature
  141313. * @param _xrSessionManager the xr session manager for this feature
  141314. */
  141315. constructor(_xrSessionManager: WebXRSessionManager);
  141316. /**
  141317. * Is this feature attached
  141318. */
  141319. get attached(): boolean;
  141320. /**
  141321. * attach this feature
  141322. *
  141323. * @param force should attachment be forced (even when already attached)
  141324. * @returns true if successful, false is failed or already attached
  141325. */
  141326. attach(force?: boolean): boolean;
  141327. /**
  141328. * detach this feature.
  141329. *
  141330. * @returns true if successful, false if failed or already detached
  141331. */
  141332. detach(): boolean;
  141333. /**
  141334. * Dispose this feature and all of the resources attached
  141335. */
  141336. dispose(): void;
  141337. /**
  141338. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  141339. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  141340. *
  141341. * @returns whether or not the feature is compatible in this environment
  141342. */
  141343. isCompatible(): boolean;
  141344. /**
  141345. * This is used to register callbacks that will automatically be removed when detach is called.
  141346. * @param observable the observable to which the observer will be attached
  141347. * @param callback the callback to register
  141348. */
  141349. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  141350. /**
  141351. * Code in this function will be executed on each xrFrame received from the browser.
  141352. * This function will not execute after the feature is detached.
  141353. * @param _xrFrame the current frame
  141354. */
  141355. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  141356. }
  141357. }
  141358. declare module BABYLON {
  141359. /**
  141360. * Renders a layer on top of an existing scene
  141361. */
  141362. export class UtilityLayerRenderer implements IDisposable {
  141363. /** the original scene that will be rendered on top of */
  141364. originalScene: Scene;
  141365. private _pointerCaptures;
  141366. private _lastPointerEvents;
  141367. private static _DefaultUtilityLayer;
  141368. private static _DefaultKeepDepthUtilityLayer;
  141369. private _sharedGizmoLight;
  141370. private _renderCamera;
  141371. /**
  141372. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  141373. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  141374. * @returns the camera that is used when rendering the utility layer
  141375. */
  141376. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  141377. /**
  141378. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  141379. * @param cam the camera that should be used when rendering the utility layer
  141380. */
  141381. setRenderCamera(cam: Nullable<Camera>): void;
  141382. /**
  141383. * @hidden
  141384. * Light which used by gizmos to get light shading
  141385. */
  141386. _getSharedGizmoLight(): HemisphericLight;
  141387. /**
  141388. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  141389. */
  141390. pickUtilitySceneFirst: boolean;
  141391. /**
  141392. * 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)
  141393. */
  141394. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  141395. /**
  141396. * 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)
  141397. */
  141398. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  141399. /**
  141400. * The scene that is rendered on top of the original scene
  141401. */
  141402. utilityLayerScene: Scene;
  141403. /**
  141404. * If the utility layer should automatically be rendered on top of existing scene
  141405. */
  141406. shouldRender: boolean;
  141407. /**
  141408. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  141409. */
  141410. onlyCheckPointerDownEvents: boolean;
  141411. /**
  141412. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  141413. */
  141414. processAllEvents: boolean;
  141415. /**
  141416. * Observable raised when the pointer move from the utility layer scene to the main scene
  141417. */
  141418. onPointerOutObservable: Observable<number>;
  141419. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  141420. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  141421. private _afterRenderObserver;
  141422. private _sceneDisposeObserver;
  141423. private _originalPointerObserver;
  141424. /**
  141425. * Instantiates a UtilityLayerRenderer
  141426. * @param originalScene the original scene that will be rendered on top of
  141427. * @param handleEvents boolean indicating if the utility layer should handle events
  141428. */
  141429. constructor(
  141430. /** the original scene that will be rendered on top of */
  141431. originalScene: Scene, handleEvents?: boolean);
  141432. private _notifyObservers;
  141433. /**
  141434. * Renders the utility layers scene on top of the original scene
  141435. */
  141436. render(): void;
  141437. /**
  141438. * Disposes of the renderer
  141439. */
  141440. dispose(): void;
  141441. private _updateCamera;
  141442. }
  141443. }
  141444. declare module BABYLON {
  141445. /**
  141446. * Options interface for the pointer selection module
  141447. */
  141448. export interface IWebXRControllerPointerSelectionOptions {
  141449. /**
  141450. * if provided, this scene will be used to render meshes.
  141451. */
  141452. customUtilityLayerScene?: Scene;
  141453. /**
  141454. * 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)
  141455. * If not disabled, the last picked point will be used to execute a pointer up event
  141456. * If disabled, pointer up event will be triggered right after the pointer down event.
  141457. * Used in screen and gaze target ray mode only
  141458. */
  141459. disablePointerUpOnTouchOut: boolean;
  141460. /**
  141461. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  141462. */
  141463. forceGazeMode: boolean;
  141464. /**
  141465. * 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
  141466. * to start a new countdown to the pointer down event.
  141467. * Defaults to 1.
  141468. */
  141469. gazeModePointerMovedFactor?: number;
  141470. /**
  141471. * Different button type to use instead of the main component
  141472. */
  141473. overrideButtonId?: string;
  141474. /**
  141475. * use this rendering group id for the meshes (optional)
  141476. */
  141477. renderingGroupId?: number;
  141478. /**
  141479. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  141480. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  141481. * 3000 means 3 seconds between pointing at something and selecting it
  141482. */
  141483. timeToSelect?: number;
  141484. /**
  141485. * Should meshes created here be added to a utility layer or the main scene
  141486. */
  141487. useUtilityLayer?: boolean;
  141488. /**
  141489. * Optional WebXR camera to be used for gaze selection
  141490. */
  141491. gazeCamera?: WebXRCamera;
  141492. /**
  141493. * the xr input to use with this pointer selection
  141494. */
  141495. xrInput: WebXRInput;
  141496. /**
  141497. * Should the scene pointerX and pointerY update be disabled
  141498. * This is required for fullscreen AR GUI, but might slow down other experiences.
  141499. * Disable in VR, if not needed.
  141500. * The first rig camera (left eye) will be used to calculate the projection
  141501. */
  141502. disableScenePointerVectorUpdate: boolean;
  141503. /**
  141504. * Enable pointer selection on all controllers instead of switching between them
  141505. */
  141506. enablePointerSelectionOnAllControllers?: boolean;
  141507. /**
  141508. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  141509. * If switch is enabled, it will still allow the user to switch between the different controllers
  141510. */
  141511. preferredHandedness?: XRHandedness;
  141512. /**
  141513. * Disable switching the pointer selection from one controller to the other.
  141514. * 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
  141515. */
  141516. disableSwitchOnClick?: boolean;
  141517. /**
  141518. * The maximum distance of the pointer selection feature. Defaults to 100.
  141519. */
  141520. maxPointerDistance?: number;
  141521. }
  141522. /**
  141523. * A module that will enable pointer selection for motion controllers of XR Input Sources
  141524. */
  141525. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  141526. private readonly _options;
  141527. private static _idCounter;
  141528. private _attachController;
  141529. private _controllers;
  141530. private _scene;
  141531. private _tmpVectorForPickCompare;
  141532. private _attachedController;
  141533. /**
  141534. * The module's name
  141535. */
  141536. static readonly Name: string;
  141537. /**
  141538. * The (Babylon) version of this module.
  141539. * This is an integer representing the implementation version.
  141540. * This number does not correspond to the WebXR specs version
  141541. */
  141542. static readonly Version: number;
  141543. /**
  141544. * Disable lighting on the laser pointer (so it will always be visible)
  141545. */
  141546. disablePointerLighting: boolean;
  141547. /**
  141548. * Disable lighting on the selection mesh (so it will always be visible)
  141549. */
  141550. disableSelectionMeshLighting: boolean;
  141551. /**
  141552. * Should the laser pointer be displayed
  141553. */
  141554. displayLaserPointer: boolean;
  141555. /**
  141556. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  141557. */
  141558. displaySelectionMesh: boolean;
  141559. /**
  141560. * This color will be set to the laser pointer when selection is triggered
  141561. */
  141562. laserPointerPickedColor: Color3;
  141563. /**
  141564. * Default color of the laser pointer
  141565. */
  141566. laserPointerDefaultColor: Color3;
  141567. /**
  141568. * default color of the selection ring
  141569. */
  141570. selectionMeshDefaultColor: Color3;
  141571. /**
  141572. * This color will be applied to the selection ring when selection is triggered
  141573. */
  141574. selectionMeshPickedColor: Color3;
  141575. /**
  141576. * Optional filter to be used for ray selection. This predicate shares behavior with
  141577. * scene.pointerMovePredicate which takes priority if it is also assigned.
  141578. */
  141579. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  141580. /**
  141581. * constructs a new background remover module
  141582. * @param _xrSessionManager the session manager for this module
  141583. * @param _options read-only options to be used in this module
  141584. */
  141585. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  141586. /**
  141587. * attach this feature
  141588. * Will usually be called by the features manager
  141589. *
  141590. * @returns true if successful.
  141591. */
  141592. attach(): boolean;
  141593. /**
  141594. * detach this feature.
  141595. * Will usually be called by the features manager
  141596. *
  141597. * @returns true if successful.
  141598. */
  141599. detach(): boolean;
  141600. /**
  141601. * Will get the mesh under a specific pointer.
  141602. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  141603. * @param controllerId the controllerId to check
  141604. * @returns The mesh under pointer or null if no mesh is under the pointer
  141605. */
  141606. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  141607. /**
  141608. * Get the xr controller that correlates to the pointer id in the pointer event
  141609. *
  141610. * @param id the pointer id to search for
  141611. * @returns the controller that correlates to this id or null if not found
  141612. */
  141613. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  141614. private _identityMatrix;
  141615. private _screenCoordinatesRef;
  141616. private _viewportRef;
  141617. protected _onXRFrame(_xrFrame: XRFrame): void;
  141618. private _attachGazeMode;
  141619. private _attachScreenRayMode;
  141620. private _attachTrackedPointerRayMode;
  141621. private _convertNormalToDirectionOfRay;
  141622. private _detachController;
  141623. private _generateNewMeshPair;
  141624. private _pickingMoved;
  141625. private _updatePointerDistance;
  141626. /** @hidden */
  141627. get lasterPointerDefaultColor(): Color3;
  141628. }
  141629. }
  141630. declare module BABYLON {
  141631. /**
  141632. * Button which can be used to enter a different mode of XR
  141633. */
  141634. export class WebXREnterExitUIButton {
  141635. /** button element */
  141636. element: HTMLElement;
  141637. /** XR initialization options for the button */
  141638. sessionMode: XRSessionMode;
  141639. /** Reference space type */
  141640. referenceSpaceType: XRReferenceSpaceType;
  141641. /**
  141642. * Creates a WebXREnterExitUIButton
  141643. * @param element button element
  141644. * @param sessionMode XR initialization session mode
  141645. * @param referenceSpaceType the type of reference space to be used
  141646. */
  141647. constructor(
  141648. /** button element */
  141649. element: HTMLElement,
  141650. /** XR initialization options for the button */
  141651. sessionMode: XRSessionMode,
  141652. /** Reference space type */
  141653. referenceSpaceType: XRReferenceSpaceType);
  141654. /**
  141655. * Extendable function which can be used to update the button's visuals when the state changes
  141656. * @param activeButton the current active button in the UI
  141657. */
  141658. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  141659. }
  141660. /**
  141661. * Options to create the webXR UI
  141662. */
  141663. export class WebXREnterExitUIOptions {
  141664. /**
  141665. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  141666. */
  141667. customButtons?: Array<WebXREnterExitUIButton>;
  141668. /**
  141669. * A reference space type to use when creating the default button.
  141670. * Default is local-floor
  141671. */
  141672. referenceSpaceType?: XRReferenceSpaceType;
  141673. /**
  141674. * Context to enter xr with
  141675. */
  141676. renderTarget?: Nullable<WebXRRenderTarget>;
  141677. /**
  141678. * A session mode to use when creating the default button.
  141679. * Default is immersive-vr
  141680. */
  141681. sessionMode?: XRSessionMode;
  141682. /**
  141683. * A list of optional features to init the session with
  141684. */
  141685. optionalFeatures?: string[];
  141686. /**
  141687. * A list of optional features to init the session with
  141688. */
  141689. requiredFeatures?: string[];
  141690. /**
  141691. * If defined, this function will be executed if the UI encounters an error when entering XR
  141692. */
  141693. onError?: (error: any) => void;
  141694. }
  141695. /**
  141696. * UI to allow the user to enter/exit XR mode
  141697. */
  141698. export class WebXREnterExitUI implements IDisposable {
  141699. private scene;
  141700. /** version of the options passed to this UI */
  141701. options: WebXREnterExitUIOptions;
  141702. private _activeButton;
  141703. private _buttons;
  141704. /**
  141705. * The HTML Div Element to which buttons are added.
  141706. */
  141707. readonly overlay: HTMLDivElement;
  141708. /**
  141709. * Fired every time the active button is changed.
  141710. *
  141711. * When xr is entered via a button that launches xr that button will be the callback parameter
  141712. *
  141713. * When exiting xr the callback parameter will be null)
  141714. */
  141715. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  141716. /**
  141717. *
  141718. * @param scene babylon scene object to use
  141719. * @param options (read-only) version of the options passed to this UI
  141720. */
  141721. private constructor();
  141722. /**
  141723. * Creates UI to allow the user to enter/exit XR mode
  141724. * @param scene the scene to add the ui to
  141725. * @param helper the xr experience helper to enter/exit xr with
  141726. * @param options options to configure the UI
  141727. * @returns the created ui
  141728. */
  141729. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  141730. /**
  141731. * Disposes of the XR UI component
  141732. */
  141733. dispose(): void;
  141734. private _updateButtons;
  141735. }
  141736. }
  141737. declare module BABYLON {
  141738. /**
  141739. * Class containing static functions to help procedurally build meshes
  141740. */
  141741. export class LinesBuilder {
  141742. /**
  141743. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  141744. * * 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
  141745. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  141746. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  141747. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  141748. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  141749. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  141750. * * 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
  141751. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  141752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  141754. * @param name defines the name of the new line system
  141755. * @param options defines the options used to create the line system
  141756. * @param scene defines the hosting scene
  141757. * @returns a new line system mesh
  141758. */
  141759. static CreateLineSystem(name: string, options: {
  141760. lines: Vector3[][];
  141761. updatable?: boolean;
  141762. instance?: Nullable<LinesMesh>;
  141763. colors?: Nullable<Color4[][]>;
  141764. useVertexAlpha?: boolean;
  141765. }, scene: Nullable<Scene>): LinesMesh;
  141766. /**
  141767. * Creates a line mesh
  141768. * 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
  141769. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141770. * * The parameter `points` is an array successive Vector3
  141771. * * 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
  141772. * * The optional parameter `colors` is an array of successive Color4, one per line point
  141773. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  141774. * * When updating an instance, remember that only point positions can change, not the number of points
  141775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  141777. * @param name defines the name of the new line system
  141778. * @param options defines the options used to create the line system
  141779. * @param scene defines the hosting scene
  141780. * @returns a new line mesh
  141781. */
  141782. static CreateLines(name: string, options: {
  141783. points: Vector3[];
  141784. updatable?: boolean;
  141785. instance?: Nullable<LinesMesh>;
  141786. colors?: Color4[];
  141787. useVertexAlpha?: boolean;
  141788. }, scene?: Nullable<Scene>): LinesMesh;
  141789. /**
  141790. * Creates a dashed line mesh
  141791. * * 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
  141792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141793. * * The parameter `points` is an array successive Vector3
  141794. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  141795. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  141796. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  141797. * * 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
  141798. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  141799. * * When updating an instance, remember that only point positions can change, not the number of points
  141800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141801. * @param name defines the name of the mesh
  141802. * @param options defines the options used to create the mesh
  141803. * @param scene defines the hosting scene
  141804. * @returns the dashed line mesh
  141805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  141806. */
  141807. static CreateDashedLines(name: string, options: {
  141808. points: Vector3[];
  141809. dashSize?: number;
  141810. gapSize?: number;
  141811. dashNb?: number;
  141812. updatable?: boolean;
  141813. instance?: LinesMesh;
  141814. useVertexAlpha?: boolean;
  141815. }, scene?: Nullable<Scene>): LinesMesh;
  141816. }
  141817. }
  141818. declare module BABYLON {
  141819. /**
  141820. * Construction options for a timer
  141821. */
  141822. export interface ITimerOptions<T> {
  141823. /**
  141824. * Time-to-end
  141825. */
  141826. timeout: number;
  141827. /**
  141828. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  141829. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  141830. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  141831. */
  141832. contextObservable: Observable<T>;
  141833. /**
  141834. * Optional parameters when adding an observer to the observable
  141835. */
  141836. observableParameters?: {
  141837. mask?: number;
  141838. insertFirst?: boolean;
  141839. scope?: any;
  141840. };
  141841. /**
  141842. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  141843. */
  141844. breakCondition?: (data?: ITimerData<T>) => boolean;
  141845. /**
  141846. * Will be triggered when the time condition has met
  141847. */
  141848. onEnded?: (data: ITimerData<any>) => void;
  141849. /**
  141850. * Will be triggered when the break condition has met (prematurely ended)
  141851. */
  141852. onAborted?: (data: ITimerData<any>) => void;
  141853. /**
  141854. * Optional function to execute on each tick (or count)
  141855. */
  141856. onTick?: (data: ITimerData<any>) => void;
  141857. }
  141858. /**
  141859. * An interface defining the data sent by the timer
  141860. */
  141861. export interface ITimerData<T> {
  141862. /**
  141863. * When did it start
  141864. */
  141865. startTime: number;
  141866. /**
  141867. * Time now
  141868. */
  141869. currentTime: number;
  141870. /**
  141871. * Time passed since started
  141872. */
  141873. deltaTime: number;
  141874. /**
  141875. * How much is completed, in [0.0...1.0].
  141876. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  141877. */
  141878. completeRate: number;
  141879. /**
  141880. * What the registered observable sent in the last count
  141881. */
  141882. payload: T;
  141883. }
  141884. /**
  141885. * The current state of the timer
  141886. */
  141887. export enum TimerState {
  141888. /**
  141889. * Timer initialized, not yet started
  141890. */
  141891. INIT = 0,
  141892. /**
  141893. * Timer started and counting
  141894. */
  141895. STARTED = 1,
  141896. /**
  141897. * Timer ended (whether aborted or time reached)
  141898. */
  141899. ENDED = 2
  141900. }
  141901. /**
  141902. * A simple version of the timer. Will take options and start the timer immediately after calling it
  141903. *
  141904. * @param options options with which to initialize this timer
  141905. */
  141906. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  141907. /**
  141908. * An advanced implementation of a timer class
  141909. */
  141910. export class AdvancedTimer<T = any> implements IDisposable {
  141911. /**
  141912. * Will notify each time the timer calculates the remaining time
  141913. */
  141914. onEachCountObservable: Observable<ITimerData<T>>;
  141915. /**
  141916. * Will trigger when the timer was aborted due to the break condition
  141917. */
  141918. onTimerAbortedObservable: Observable<ITimerData<T>>;
  141919. /**
  141920. * Will trigger when the timer ended successfully
  141921. */
  141922. onTimerEndedObservable: Observable<ITimerData<T>>;
  141923. /**
  141924. * Will trigger when the timer state has changed
  141925. */
  141926. onStateChangedObservable: Observable<TimerState>;
  141927. private _observer;
  141928. private _contextObservable;
  141929. private _observableParameters;
  141930. private _startTime;
  141931. private _timer;
  141932. private _state;
  141933. private _breakCondition;
  141934. private _timeToEnd;
  141935. private _breakOnNextTick;
  141936. /**
  141937. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  141938. * @param options construction options for this advanced timer
  141939. */
  141940. constructor(options: ITimerOptions<T>);
  141941. /**
  141942. * set a breaking condition for this timer. Default is to never break during count
  141943. * @param predicate the new break condition. Returns true to break, false otherwise
  141944. */
  141945. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  141946. /**
  141947. * Reset ALL associated observables in this advanced timer
  141948. */
  141949. clearObservables(): void;
  141950. /**
  141951. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  141952. *
  141953. * @param timeToEnd how much time to measure until timer ended
  141954. */
  141955. start(timeToEnd?: number): void;
  141956. /**
  141957. * Will force a stop on the next tick.
  141958. */
  141959. stop(): void;
  141960. /**
  141961. * Dispose this timer, clearing all resources
  141962. */
  141963. dispose(): void;
  141964. private _setState;
  141965. private _tick;
  141966. private _stop;
  141967. }
  141968. }
  141969. declare module BABYLON {
  141970. /**
  141971. * The options container for the teleportation module
  141972. */
  141973. export interface IWebXRTeleportationOptions {
  141974. /**
  141975. * if provided, this scene will be used to render meshes.
  141976. */
  141977. customUtilityLayerScene?: Scene;
  141978. /**
  141979. * Values to configure the default target mesh
  141980. */
  141981. defaultTargetMeshOptions?: {
  141982. /**
  141983. * Fill color of the teleportation area
  141984. */
  141985. teleportationFillColor?: string;
  141986. /**
  141987. * Border color for the teleportation area
  141988. */
  141989. teleportationBorderColor?: string;
  141990. /**
  141991. * Disable the mesh's animation sequence
  141992. */
  141993. disableAnimation?: boolean;
  141994. /**
  141995. * Disable lighting on the material or the ring and arrow
  141996. */
  141997. disableLighting?: boolean;
  141998. /**
  141999. * Override the default material of the torus and arrow
  142000. */
  142001. torusArrowMaterial?: Material;
  142002. };
  142003. /**
  142004. * A list of meshes to use as floor meshes.
  142005. * Meshes can be added and removed after initializing the feature using the
  142006. * addFloorMesh and removeFloorMesh functions
  142007. * If empty, rotation will still work
  142008. */
  142009. floorMeshes?: AbstractMesh[];
  142010. /**
  142011. * use this rendering group id for the meshes (optional)
  142012. */
  142013. renderingGroupId?: number;
  142014. /**
  142015. * Should teleportation move only to snap points
  142016. */
  142017. snapPointsOnly?: boolean;
  142018. /**
  142019. * An array of points to which the teleportation will snap to.
  142020. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  142021. */
  142022. snapPositions?: Vector3[];
  142023. /**
  142024. * How close should the teleportation ray be in order to snap to position.
  142025. * Default to 0.8 units (meters)
  142026. */
  142027. snapToPositionRadius?: number;
  142028. /**
  142029. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  142030. * If you want to support rotation, make sure your mesh has a direction indicator.
  142031. *
  142032. * When left untouched, the default mesh will be initialized.
  142033. */
  142034. teleportationTargetMesh?: AbstractMesh;
  142035. /**
  142036. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  142037. */
  142038. timeToTeleport?: number;
  142039. /**
  142040. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  142041. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  142042. */
  142043. useMainComponentOnly?: boolean;
  142044. /**
  142045. * Should meshes created here be added to a utility layer or the main scene
  142046. */
  142047. useUtilityLayer?: boolean;
  142048. /**
  142049. * Babylon XR Input class for controller
  142050. */
  142051. xrInput: WebXRInput;
  142052. /**
  142053. * Meshes that the teleportation ray cannot go through
  142054. */
  142055. pickBlockerMeshes?: AbstractMesh[];
  142056. /**
  142057. * Should teleport work only on a specific hand?
  142058. */
  142059. forceHandedness?: XRHandedness;
  142060. /**
  142061. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  142062. */
  142063. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  142064. }
  142065. /**
  142066. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  142067. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  142068. * the input of the attached controllers.
  142069. */
  142070. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  142071. private _options;
  142072. private _controllers;
  142073. private _currentTeleportationControllerId;
  142074. private _floorMeshes;
  142075. private _quadraticBezierCurve;
  142076. private _selectionFeature;
  142077. private _snapToPositions;
  142078. private _snappedToPoint;
  142079. private _teleportationRingMaterial?;
  142080. private _tmpRay;
  142081. private _tmpVector;
  142082. private _tmpQuaternion;
  142083. /**
  142084. * The module's name
  142085. */
  142086. static readonly Name: string;
  142087. /**
  142088. * The (Babylon) version of this module.
  142089. * This is an integer representing the implementation version.
  142090. * This number does not correspond to the webxr specs version
  142091. */
  142092. static readonly Version: number;
  142093. /**
  142094. * Is movement backwards enabled
  142095. */
  142096. backwardsMovementEnabled: boolean;
  142097. /**
  142098. * Distance to travel when moving backwards
  142099. */
  142100. backwardsTeleportationDistance: number;
  142101. /**
  142102. * The distance from the user to the inspection point in the direction of the controller
  142103. * A higher number will allow the user to move further
  142104. * defaults to 5 (meters, in xr units)
  142105. */
  142106. parabolicCheckRadius: number;
  142107. /**
  142108. * Should the module support parabolic ray on top of direct ray
  142109. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  142110. * Very helpful when moving between floors / different heights
  142111. */
  142112. parabolicRayEnabled: boolean;
  142113. /**
  142114. * The second type of ray - straight line.
  142115. * Should it be enabled or should the parabolic line be the only one.
  142116. */
  142117. straightRayEnabled: boolean;
  142118. /**
  142119. * How much rotation should be applied when rotating right and left
  142120. */
  142121. rotationAngle: number;
  142122. private _rotationEnabled;
  142123. /**
  142124. * Is rotation enabled when moving forward?
  142125. * Disabling this feature will prevent the user from deciding the direction when teleporting
  142126. */
  142127. get rotationEnabled(): boolean;
  142128. /**
  142129. * Sets whether rotation is enabled or not
  142130. * @param enabled is rotation enabled when teleportation is shown
  142131. */
  142132. set rotationEnabled(enabled: boolean);
  142133. /**
  142134. * Exposes the currently set teleportation target mesh.
  142135. */
  142136. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  142137. /**
  142138. * constructs a new anchor system
  142139. * @param _xrSessionManager an instance of WebXRSessionManager
  142140. * @param _options configuration object for this feature
  142141. */
  142142. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  142143. /**
  142144. * Get the snapPointsOnly flag
  142145. */
  142146. get snapPointsOnly(): boolean;
  142147. /**
  142148. * Sets the snapPointsOnly flag
  142149. * @param snapToPoints should teleportation be exclusively to snap points
  142150. */
  142151. set snapPointsOnly(snapToPoints: boolean);
  142152. /**
  142153. * Add a new mesh to the floor meshes array
  142154. * @param mesh the mesh to use as floor mesh
  142155. */
  142156. addFloorMesh(mesh: AbstractMesh): void;
  142157. /**
  142158. * Add a new snap-to point to fix teleportation to this position
  142159. * @param newSnapPoint The new Snap-To point
  142160. */
  142161. addSnapPoint(newSnapPoint: Vector3): void;
  142162. attach(): boolean;
  142163. detach(): boolean;
  142164. dispose(): void;
  142165. /**
  142166. * Remove a mesh from the floor meshes array
  142167. * @param mesh the mesh to remove
  142168. */
  142169. removeFloorMesh(mesh: AbstractMesh): void;
  142170. /**
  142171. * Remove a mesh from the floor meshes array using its name
  142172. * @param name the mesh name to remove
  142173. */
  142174. removeFloorMeshByName(name: string): void;
  142175. /**
  142176. * 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
  142177. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  142178. * @returns was the point found and removed or not
  142179. */
  142180. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  142181. /**
  142182. * This function sets a selection feature that will be disabled when
  142183. * the forward ray is shown and will be reattached when hidden.
  142184. * This is used to remove the selection rays when moving.
  142185. * @param selectionFeature the feature to disable when forward movement is enabled
  142186. */
  142187. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  142188. protected _onXRFrame(_xrFrame: XRFrame): void;
  142189. private _attachController;
  142190. private _createDefaultTargetMesh;
  142191. private _detachController;
  142192. private _findClosestSnapPointWithRadius;
  142193. private _setTargetMeshPosition;
  142194. private _setTargetMeshVisibility;
  142195. private _showParabolicPath;
  142196. private _teleportForward;
  142197. }
  142198. }
  142199. declare module BABYLON {
  142200. /**
  142201. * Options for the default xr helper
  142202. */
  142203. export class WebXRDefaultExperienceOptions {
  142204. /**
  142205. * Enable or disable default UI to enter XR
  142206. */
  142207. disableDefaultUI?: boolean;
  142208. /**
  142209. * Should teleportation not initialize. defaults to false.
  142210. */
  142211. disableTeleportation?: boolean;
  142212. /**
  142213. * Floor meshes that will be used for teleport
  142214. */
  142215. floorMeshes?: Array<AbstractMesh>;
  142216. /**
  142217. * If set to true, the first frame will not be used to reset position
  142218. * The first frame is mainly used when copying transformation from the old camera
  142219. * Mainly used in AR
  142220. */
  142221. ignoreNativeCameraTransformation?: boolean;
  142222. /**
  142223. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  142224. */
  142225. inputOptions?: IWebXRInputOptions;
  142226. /**
  142227. * optional configuration for the output canvas
  142228. */
  142229. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  142230. /**
  142231. * optional UI options. This can be used among other to change session mode and reference space type
  142232. */
  142233. uiOptions?: WebXREnterExitUIOptions;
  142234. /**
  142235. * When loading teleportation and pointer select, use stable versions instead of latest.
  142236. */
  142237. useStablePlugins?: boolean;
  142238. /**
  142239. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  142240. */
  142241. renderingGroupId?: number;
  142242. /**
  142243. * A list of optional features to init the session with
  142244. * If set to true, all features we support will be added
  142245. */
  142246. optionalFeatures?: boolean | string[];
  142247. }
  142248. /**
  142249. * Default experience which provides a similar setup to the previous webVRExperience
  142250. */
  142251. export class WebXRDefaultExperience {
  142252. /**
  142253. * Base experience
  142254. */
  142255. baseExperience: WebXRExperienceHelper;
  142256. /**
  142257. * Enables ui for entering/exiting xr
  142258. */
  142259. enterExitUI: WebXREnterExitUI;
  142260. /**
  142261. * Input experience extension
  142262. */
  142263. input: WebXRInput;
  142264. /**
  142265. * Enables laser pointer and selection
  142266. */
  142267. pointerSelection: WebXRControllerPointerSelection;
  142268. /**
  142269. * Default target xr should render to
  142270. */
  142271. renderTarget: WebXRRenderTarget;
  142272. /**
  142273. * Enables teleportation
  142274. */
  142275. teleportation: WebXRMotionControllerTeleportation;
  142276. private constructor();
  142277. /**
  142278. * Creates the default xr experience
  142279. * @param scene scene
  142280. * @param options options for basic configuration
  142281. * @returns resulting WebXRDefaultExperience
  142282. */
  142283. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  142284. /**
  142285. * Disposes of the experience helper
  142286. */
  142287. dispose(): void;
  142288. }
  142289. }
  142290. declare module BABYLON {
  142291. /**
  142292. * Options to modify the vr teleportation behavior.
  142293. */
  142294. export interface VRTeleportationOptions {
  142295. /**
  142296. * The name of the mesh which should be used as the teleportation floor. (default: null)
  142297. */
  142298. floorMeshName?: string;
  142299. /**
  142300. * A list of meshes to be used as the teleportation floor. (default: empty)
  142301. */
  142302. floorMeshes?: Mesh[];
  142303. /**
  142304. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  142305. */
  142306. teleportationMode?: number;
  142307. /**
  142308. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  142309. */
  142310. teleportationTime?: number;
  142311. /**
  142312. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  142313. */
  142314. teleportationSpeed?: number;
  142315. /**
  142316. * The easing function used in the animation or null for Linear. (default CircleEase)
  142317. */
  142318. easingFunction?: EasingFunction;
  142319. }
  142320. /**
  142321. * Options to modify the vr experience helper's behavior.
  142322. */
  142323. export interface VRExperienceHelperOptions extends WebVROptions {
  142324. /**
  142325. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  142326. */
  142327. createDeviceOrientationCamera?: boolean;
  142328. /**
  142329. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  142330. */
  142331. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  142332. /**
  142333. * Uses the main button on the controller to toggle the laser casted. (default: true)
  142334. */
  142335. laserToggle?: boolean;
  142336. /**
  142337. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  142338. */
  142339. floorMeshes?: Mesh[];
  142340. /**
  142341. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  142342. */
  142343. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  142344. /**
  142345. * Defines if WebXR should be used instead of WebVR (if available)
  142346. */
  142347. useXR?: boolean;
  142348. }
  142349. /**
  142350. * Event containing information after VR has been entered
  142351. */
  142352. export class OnAfterEnteringVRObservableEvent {
  142353. /**
  142354. * If entering vr was successful
  142355. */
  142356. success: boolean;
  142357. }
  142358. /**
  142359. * Helps to quickly add VR support to an existing scene.
  142360. * See https://doc.babylonjs.com/how_to/webvr_helper
  142361. */
  142362. export class VRExperienceHelper {
  142363. /** Options to modify the vr experience helper's behavior. */
  142364. webVROptions: VRExperienceHelperOptions;
  142365. private _scene;
  142366. private _position;
  142367. private _btnVR;
  142368. private _btnVRDisplayed;
  142369. private _webVRsupported;
  142370. private _webVRready;
  142371. private _webVRrequesting;
  142372. private _webVRpresenting;
  142373. private _hasEnteredVR;
  142374. private _fullscreenVRpresenting;
  142375. private _inputElement;
  142376. private _webVRCamera;
  142377. private _vrDeviceOrientationCamera;
  142378. private _deviceOrientationCamera;
  142379. private _existingCamera;
  142380. private _onKeyDown;
  142381. private _onVrDisplayPresentChange;
  142382. private _onVRDisplayChanged;
  142383. private _onVRRequestPresentStart;
  142384. private _onVRRequestPresentComplete;
  142385. /**
  142386. * 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)
  142387. */
  142388. enableGazeEvenWhenNoPointerLock: boolean;
  142389. /**
  142390. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  142391. */
  142392. exitVROnDoubleTap: boolean;
  142393. /**
  142394. * Observable raised right before entering VR.
  142395. */
  142396. onEnteringVRObservable: Observable<VRExperienceHelper>;
  142397. /**
  142398. * Observable raised when entering VR has completed.
  142399. */
  142400. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  142401. /**
  142402. * Observable raised when exiting VR.
  142403. */
  142404. onExitingVRObservable: Observable<VRExperienceHelper>;
  142405. /**
  142406. * Observable raised when controller mesh is loaded.
  142407. */
  142408. onControllerMeshLoadedObservable: Observable<WebVRController>;
  142409. /** Return this.onEnteringVRObservable
  142410. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  142411. */
  142412. get onEnteringVR(): Observable<VRExperienceHelper>;
  142413. /** Return this.onExitingVRObservable
  142414. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  142415. */
  142416. get onExitingVR(): Observable<VRExperienceHelper>;
  142417. /** Return this.onControllerMeshLoadedObservable
  142418. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  142419. */
  142420. get onControllerMeshLoaded(): Observable<WebVRController>;
  142421. private _rayLength;
  142422. private _useCustomVRButton;
  142423. private _teleportationRequested;
  142424. private _teleportActive;
  142425. private _floorMeshName;
  142426. private _floorMeshesCollection;
  142427. private _teleportationMode;
  142428. private _teleportationTime;
  142429. private _teleportationSpeed;
  142430. private _teleportationEasing;
  142431. private _rotationAllowed;
  142432. private _teleportBackwardsVector;
  142433. private _teleportationTarget;
  142434. private _isDefaultTeleportationTarget;
  142435. private _postProcessMove;
  142436. private _teleportationFillColor;
  142437. private _teleportationBorderColor;
  142438. private _rotationAngle;
  142439. private _haloCenter;
  142440. private _cameraGazer;
  142441. private _padSensibilityUp;
  142442. private _padSensibilityDown;
  142443. private _leftController;
  142444. private _rightController;
  142445. private _gazeColor;
  142446. private _laserColor;
  142447. private _pickedLaserColor;
  142448. private _pickedGazeColor;
  142449. /**
  142450. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  142451. */
  142452. onNewMeshSelected: Observable<AbstractMesh>;
  142453. /**
  142454. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  142455. * This observable will provide the mesh and the controller used to select the mesh
  142456. */
  142457. onMeshSelectedWithController: Observable<{
  142458. mesh: AbstractMesh;
  142459. controller: WebVRController;
  142460. }>;
  142461. /**
  142462. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  142463. */
  142464. onNewMeshPicked: Observable<PickingInfo>;
  142465. private _circleEase;
  142466. /**
  142467. * Observable raised before camera teleportation
  142468. */
  142469. onBeforeCameraTeleport: Observable<Vector3>;
  142470. /**
  142471. * Observable raised after camera teleportation
  142472. */
  142473. onAfterCameraTeleport: Observable<Vector3>;
  142474. /**
  142475. * Observable raised when current selected mesh gets unselected
  142476. */
  142477. onSelectedMeshUnselected: Observable<AbstractMesh>;
  142478. private _raySelectionPredicate;
  142479. /**
  142480. * To be optionally changed by user to define custom ray selection
  142481. */
  142482. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  142483. /**
  142484. * To be optionally changed by user to define custom selection logic (after ray selection)
  142485. */
  142486. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  142487. /**
  142488. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  142489. */
  142490. teleportationEnabled: boolean;
  142491. private _defaultHeight;
  142492. private _teleportationInitialized;
  142493. private _interactionsEnabled;
  142494. private _interactionsRequested;
  142495. private _displayGaze;
  142496. private _displayLaserPointer;
  142497. /**
  142498. * The mesh used to display where the user is going to teleport.
  142499. */
  142500. get teleportationTarget(): Mesh;
  142501. /**
  142502. * Sets the mesh to be used to display where the user is going to teleport.
  142503. */
  142504. set teleportationTarget(value: Mesh);
  142505. /**
  142506. * 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
  142507. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  142508. * See https://doc.babylonjs.com/resources/baking_transformations
  142509. */
  142510. get gazeTrackerMesh(): Mesh;
  142511. set gazeTrackerMesh(value: Mesh);
  142512. /**
  142513. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  142514. */
  142515. updateGazeTrackerScale: boolean;
  142516. /**
  142517. * If the gaze trackers color should be updated when selecting meshes
  142518. */
  142519. updateGazeTrackerColor: boolean;
  142520. /**
  142521. * If the controller laser color should be updated when selecting meshes
  142522. */
  142523. updateControllerLaserColor: boolean;
  142524. /**
  142525. * The gaze tracking mesh corresponding to the left controller
  142526. */
  142527. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  142528. /**
  142529. * The gaze tracking mesh corresponding to the right controller
  142530. */
  142531. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  142532. /**
  142533. * If the ray of the gaze should be displayed.
  142534. */
  142535. get displayGaze(): boolean;
  142536. /**
  142537. * Sets if the ray of the gaze should be displayed.
  142538. */
  142539. set displayGaze(value: boolean);
  142540. /**
  142541. * If the ray of the LaserPointer should be displayed.
  142542. */
  142543. get displayLaserPointer(): boolean;
  142544. /**
  142545. * Sets if the ray of the LaserPointer should be displayed.
  142546. */
  142547. set displayLaserPointer(value: boolean);
  142548. /**
  142549. * The deviceOrientationCamera used as the camera when not in VR.
  142550. */
  142551. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  142552. /**
  142553. * Based on the current WebVR support, returns the current VR camera used.
  142554. */
  142555. get currentVRCamera(): Nullable<Camera>;
  142556. /**
  142557. * The webVRCamera which is used when in VR.
  142558. */
  142559. get webVRCamera(): WebVRFreeCamera;
  142560. /**
  142561. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  142562. */
  142563. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  142564. /**
  142565. * The html button that is used to trigger entering into VR.
  142566. */
  142567. get vrButton(): Nullable<HTMLButtonElement>;
  142568. private get _teleportationRequestInitiated();
  142569. /**
  142570. * Defines whether or not Pointer lock should be requested when switching to
  142571. * full screen.
  142572. */
  142573. requestPointerLockOnFullScreen: boolean;
  142574. /**
  142575. * If asking to force XR, this will be populated with the default xr experience
  142576. */
  142577. xr: WebXRDefaultExperience;
  142578. /**
  142579. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  142580. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  142581. */
  142582. xrTestDone: boolean;
  142583. /**
  142584. * Instantiates a VRExperienceHelper.
  142585. * Helps to quickly add VR support to an existing scene.
  142586. * @param scene The scene the VRExperienceHelper belongs to.
  142587. * @param webVROptions Options to modify the vr experience helper's behavior.
  142588. */
  142589. constructor(scene: Scene,
  142590. /** Options to modify the vr experience helper's behavior. */
  142591. webVROptions?: VRExperienceHelperOptions);
  142592. private completeVRInit;
  142593. private _onDefaultMeshLoaded;
  142594. private _onResize;
  142595. private _onFullscreenChange;
  142596. /**
  142597. * Gets a value indicating if we are currently in VR mode.
  142598. */
  142599. get isInVRMode(): boolean;
  142600. private onVrDisplayPresentChange;
  142601. private onVRDisplayChanged;
  142602. private moveButtonToBottomRight;
  142603. private displayVRButton;
  142604. private updateButtonVisibility;
  142605. private _cachedAngularSensibility;
  142606. /**
  142607. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  142608. * Otherwise, will use the fullscreen API.
  142609. */
  142610. enterVR(): void;
  142611. /**
  142612. * Attempt to exit VR, or fullscreen.
  142613. */
  142614. exitVR(): void;
  142615. /**
  142616. * The position of the vr experience helper.
  142617. */
  142618. get position(): Vector3;
  142619. /**
  142620. * Sets the position of the vr experience helper.
  142621. */
  142622. set position(value: Vector3);
  142623. /**
  142624. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  142625. */
  142626. enableInteractions(): void;
  142627. private get _noControllerIsActive();
  142628. private beforeRender;
  142629. private _isTeleportationFloor;
  142630. /**
  142631. * Adds a floor mesh to be used for teleportation.
  142632. * @param floorMesh the mesh to be used for teleportation.
  142633. */
  142634. addFloorMesh(floorMesh: Mesh): void;
  142635. /**
  142636. * Removes a floor mesh from being used for teleportation.
  142637. * @param floorMesh the mesh to be removed.
  142638. */
  142639. removeFloorMesh(floorMesh: Mesh): void;
  142640. /**
  142641. * Enables interactions and teleportation using the VR controllers and gaze.
  142642. * @param vrTeleportationOptions options to modify teleportation behavior.
  142643. */
  142644. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  142645. private _onNewGamepadConnected;
  142646. private _tryEnableInteractionOnController;
  142647. private _onNewGamepadDisconnected;
  142648. private _enableInteractionOnController;
  142649. private _checkTeleportWithRay;
  142650. private _checkRotate;
  142651. private _checkTeleportBackwards;
  142652. private _enableTeleportationOnController;
  142653. private _createTeleportationCircles;
  142654. private _displayTeleportationTarget;
  142655. private _hideTeleportationTarget;
  142656. private _rotateCamera;
  142657. private _moveTeleportationSelectorTo;
  142658. private _workingVector;
  142659. private _workingQuaternion;
  142660. private _workingMatrix;
  142661. /**
  142662. * Time Constant Teleportation Mode
  142663. */
  142664. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  142665. /**
  142666. * Speed Constant Teleportation Mode
  142667. */
  142668. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  142669. /**
  142670. * Teleports the users feet to the desired location
  142671. * @param location The location where the user's feet should be placed
  142672. */
  142673. teleportCamera(location: Vector3): void;
  142674. private _convertNormalToDirectionOfRay;
  142675. private _castRayAndSelectObject;
  142676. private _notifySelectedMeshUnselected;
  142677. /**
  142678. * Permanently set new colors for the laser pointer
  142679. * @param color the new laser color
  142680. * @param pickedColor the new laser color when picked mesh detected
  142681. */
  142682. setLaserColor(color: Color3, pickedColor?: Color3): void;
  142683. /**
  142684. * Set lighting enabled / disabled on the laser pointer of both controllers
  142685. * @param enabled should the lighting be enabled on the laser pointer
  142686. */
  142687. setLaserLightingState(enabled?: boolean): void;
  142688. /**
  142689. * Permanently set new colors for the gaze pointer
  142690. * @param color the new gaze color
  142691. * @param pickedColor the new gaze color when picked mesh detected
  142692. */
  142693. setGazeColor(color: Color3, pickedColor?: Color3): void;
  142694. /**
  142695. * Sets the color of the laser ray from the vr controllers.
  142696. * @param color new color for the ray.
  142697. */
  142698. changeLaserColor(color: Color3): void;
  142699. /**
  142700. * Sets the color of the ray from the vr headsets gaze.
  142701. * @param color new color for the ray.
  142702. */
  142703. changeGazeColor(color: Color3): void;
  142704. /**
  142705. * Exits VR and disposes of the vr experience helper
  142706. */
  142707. dispose(): void;
  142708. /**
  142709. * Gets the name of the VRExperienceHelper class
  142710. * @returns "VRExperienceHelper"
  142711. */
  142712. getClassName(): string;
  142713. }
  142714. }
  142715. declare module BABYLON {
  142716. /**
  142717. * Contains an array of blocks representing the octree
  142718. */
  142719. export interface IOctreeContainer<T> {
  142720. /**
  142721. * Blocks within the octree
  142722. */
  142723. blocks: Array<OctreeBlock<T>>;
  142724. }
  142725. /**
  142726. * Class used to store a cell in an octree
  142727. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142728. */
  142729. export class OctreeBlock<T> {
  142730. /**
  142731. * Gets the content of the current block
  142732. */
  142733. entries: T[];
  142734. /**
  142735. * Gets the list of block children
  142736. */
  142737. blocks: Array<OctreeBlock<T>>;
  142738. private _depth;
  142739. private _maxDepth;
  142740. private _capacity;
  142741. private _minPoint;
  142742. private _maxPoint;
  142743. private _boundingVectors;
  142744. private _creationFunc;
  142745. /**
  142746. * Creates a new block
  142747. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  142748. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  142749. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  142750. * @param depth defines the current depth of this block in the octree
  142751. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  142752. * @param creationFunc defines a callback to call when an element is added to the block
  142753. */
  142754. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  142755. /**
  142756. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  142757. */
  142758. get capacity(): number;
  142759. /**
  142760. * Gets the minimum vector (in world space) of the block's bounding box
  142761. */
  142762. get minPoint(): Vector3;
  142763. /**
  142764. * Gets the maximum vector (in world space) of the block's bounding box
  142765. */
  142766. get maxPoint(): Vector3;
  142767. /**
  142768. * Add a new element to this block
  142769. * @param entry defines the element to add
  142770. */
  142771. addEntry(entry: T): void;
  142772. /**
  142773. * Remove an element from this block
  142774. * @param entry defines the element to remove
  142775. */
  142776. removeEntry(entry: T): void;
  142777. /**
  142778. * Add an array of elements to this block
  142779. * @param entries defines the array of elements to add
  142780. */
  142781. addEntries(entries: T[]): void;
  142782. /**
  142783. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  142784. * @param frustumPlanes defines the frustum planes to test
  142785. * @param selection defines the array to store current content if selection is positive
  142786. * @param allowDuplicate defines if the selection array can contains duplicated entries
  142787. */
  142788. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  142789. /**
  142790. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  142791. * @param sphereCenter defines the bounding sphere center
  142792. * @param sphereRadius defines the bounding sphere radius
  142793. * @param selection defines the array to store current content if selection is positive
  142794. * @param allowDuplicate defines if the selection array can contains duplicated entries
  142795. */
  142796. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  142797. /**
  142798. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  142799. * @param ray defines the ray to test with
  142800. * @param selection defines the array to store current content if selection is positive
  142801. */
  142802. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  142803. /**
  142804. * Subdivide the content into child blocks (this block will then be empty)
  142805. */
  142806. createInnerBlocks(): void;
  142807. /**
  142808. * @hidden
  142809. */
  142810. 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;
  142811. }
  142812. }
  142813. declare module BABYLON {
  142814. /**
  142815. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  142816. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142817. */
  142818. export class Octree<T> {
  142819. /** 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.) */
  142820. maxDepth: number;
  142821. /**
  142822. * Blocks within the octree containing objects
  142823. */
  142824. blocks: Array<OctreeBlock<T>>;
  142825. /**
  142826. * Content stored in the octree
  142827. */
  142828. dynamicContent: T[];
  142829. private _maxBlockCapacity;
  142830. private _selectionContent;
  142831. private _creationFunc;
  142832. /**
  142833. * Creates a octree
  142834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142835. * @param creationFunc function to be used to instantiate the octree
  142836. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  142837. * @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.)
  142838. */
  142839. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  142840. /** 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.) */
  142841. maxDepth?: number);
  142842. /**
  142843. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  142844. * @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);
  142845. * @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);
  142846. * @param entries meshes to be added to the octree blocks
  142847. */
  142848. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  142849. /**
  142850. * Adds a mesh to the octree
  142851. * @param entry Mesh to add to the octree
  142852. */
  142853. addMesh(entry: T): void;
  142854. /**
  142855. * Remove an element from the octree
  142856. * @param entry defines the element to remove
  142857. */
  142858. removeMesh(entry: T): void;
  142859. /**
  142860. * Selects an array of meshes within the frustum
  142861. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  142862. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  142863. * @returns array of meshes within the frustum
  142864. */
  142865. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  142866. /**
  142867. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  142868. * @param sphereCenter defines the bounding sphere center
  142869. * @param sphereRadius defines the bounding sphere radius
  142870. * @param allowDuplicate defines if the selection array can contains duplicated entries
  142871. * @returns an array of objects that intersect the sphere
  142872. */
  142873. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  142874. /**
  142875. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  142876. * @param ray defines the ray to test with
  142877. * @returns array of intersected objects
  142878. */
  142879. intersectsRay(ray: Ray): SmartArray<T>;
  142880. /**
  142881. * Adds a mesh into the octree block if it intersects the block
  142882. */
  142883. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  142884. /**
  142885. * Adds a submesh into the octree block if it intersects the block
  142886. */
  142887. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  142888. }
  142889. }
  142890. declare module BABYLON {
  142891. interface Scene {
  142892. /**
  142893. * @hidden
  142894. * Backing Filed
  142895. */
  142896. _selectionOctree: Octree<AbstractMesh>;
  142897. /**
  142898. * Gets the octree used to boost mesh selection (picking)
  142899. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142900. */
  142901. selectionOctree: Octree<AbstractMesh>;
  142902. /**
  142903. * Creates or updates the octree used to boost selection (picking)
  142904. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142905. * @param maxCapacity defines the maximum capacity per leaf
  142906. * @param maxDepth defines the maximum depth of the octree
  142907. * @returns an octree of AbstractMesh
  142908. */
  142909. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  142910. }
  142911. interface AbstractMesh {
  142912. /**
  142913. * @hidden
  142914. * Backing Field
  142915. */
  142916. _submeshesOctree: Octree<SubMesh>;
  142917. /**
  142918. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  142919. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  142920. * @param maxCapacity defines the maximum size of each block (64 by default)
  142921. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  142922. * @returns the new octree
  142923. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  142924. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  142925. */
  142926. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  142927. }
  142928. /**
  142929. * Defines the octree scene component responsible to manage any octrees
  142930. * in a given scene.
  142931. */
  142932. export class OctreeSceneComponent {
  142933. /**
  142934. * The component name help to identify the component in the list of scene components.
  142935. */
  142936. readonly name: string;
  142937. /**
  142938. * The scene the component belongs to.
  142939. */
  142940. scene: Scene;
  142941. /**
  142942. * Indicates if the meshes have been checked to make sure they are isEnabled()
  142943. */
  142944. readonly checksIsEnabled: boolean;
  142945. /**
  142946. * Creates a new instance of the component for the given scene
  142947. * @param scene Defines the scene to register the component in
  142948. */
  142949. constructor(scene: Scene);
  142950. /**
  142951. * Registers the component in a given scene
  142952. */
  142953. register(): void;
  142954. /**
  142955. * Return the list of active meshes
  142956. * @returns the list of active meshes
  142957. */
  142958. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  142959. /**
  142960. * Return the list of active sub meshes
  142961. * @param mesh The mesh to get the candidates sub meshes from
  142962. * @returns the list of active sub meshes
  142963. */
  142964. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  142965. private _tempRay;
  142966. /**
  142967. * Return the list of sub meshes intersecting with a given local ray
  142968. * @param mesh defines the mesh to find the submesh for
  142969. * @param localRay defines the ray in local space
  142970. * @returns the list of intersecting sub meshes
  142971. */
  142972. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  142973. /**
  142974. * Return the list of sub meshes colliding with a collider
  142975. * @param mesh defines the mesh to find the submesh for
  142976. * @param collider defines the collider to evaluate the collision against
  142977. * @returns the list of colliding sub meshes
  142978. */
  142979. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  142980. /**
  142981. * Rebuilds the elements related to this component in case of
  142982. * context lost for instance.
  142983. */
  142984. rebuild(): void;
  142985. /**
  142986. * Disposes the component and the associated resources.
  142987. */
  142988. dispose(): void;
  142989. }
  142990. }
  142991. declare module BABYLON {
  142992. /**
  142993. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  142994. */
  142995. export interface GizmoAxisCache {
  142996. /** Mesh used to render the Gizmo */
  142997. gizmoMeshes: Mesh[];
  142998. /** Mesh used to detect user interaction with Gizmo */
  142999. colliderMeshes: Mesh[];
  143000. /** Material used to indicate color of gizmo mesh */
  143001. material: StandardMaterial;
  143002. /** Material used to indicate hover state of the Gizmo */
  143003. hoverMaterial: StandardMaterial;
  143004. /** Material used to indicate disabled state of the Gizmo */
  143005. disableMaterial: StandardMaterial;
  143006. /** Used to indicate Active state of the Gizmo */
  143007. active: boolean;
  143008. }
  143009. /**
  143010. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  143011. */
  143012. export class Gizmo implements IDisposable {
  143013. /** The utility layer the gizmo will be added to */
  143014. gizmoLayer: UtilityLayerRenderer;
  143015. /**
  143016. * The root mesh of the gizmo
  143017. */
  143018. _rootMesh: Mesh;
  143019. private _attachedMesh;
  143020. private _attachedNode;
  143021. /**
  143022. * Ratio for the scale of the gizmo (Default: 1)
  143023. */
  143024. protected _scaleRatio: number;
  143025. /**
  143026. * boolean updated by pointermove when a gizmo mesh is hovered
  143027. */
  143028. protected _isHovered: boolean;
  143029. /**
  143030. * Ratio for the scale of the gizmo (Default: 1)
  143031. */
  143032. set scaleRatio(value: number);
  143033. get scaleRatio(): number;
  143034. /**
  143035. * True when the mouse pointer is hovered a gizmo mesh
  143036. */
  143037. get isHovered(): boolean;
  143038. /**
  143039. * If a custom mesh has been set (Default: false)
  143040. */
  143041. protected _customMeshSet: boolean;
  143042. /**
  143043. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  143044. * * When set, interactions will be enabled
  143045. */
  143046. get attachedMesh(): Nullable<AbstractMesh>;
  143047. set attachedMesh(value: Nullable<AbstractMesh>);
  143048. /**
  143049. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  143050. * * When set, interactions will be enabled
  143051. */
  143052. get attachedNode(): Nullable<Node>;
  143053. set attachedNode(value: Nullable<Node>);
  143054. /**
  143055. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  143056. * @param mesh The mesh to replace the default mesh of the gizmo
  143057. */
  143058. setCustomMesh(mesh: Mesh): void;
  143059. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  143060. /**
  143061. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  143062. */
  143063. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  143064. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  143065. /**
  143066. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  143067. */
  143068. updateGizmoPositionToMatchAttachedMesh: boolean;
  143069. /**
  143070. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  143071. */
  143072. updateScale: boolean;
  143073. protected _interactionsEnabled: boolean;
  143074. protected _attachedNodeChanged(value: Nullable<Node>): void;
  143075. private _beforeRenderObserver;
  143076. private _tempQuaternion;
  143077. private _tempVector;
  143078. private _tempVector2;
  143079. private _tempMatrix1;
  143080. private _tempMatrix2;
  143081. private _rightHandtoLeftHandMatrix;
  143082. /**
  143083. * Creates a gizmo
  143084. * @param gizmoLayer The utility layer the gizmo will be added to
  143085. */
  143086. constructor(
  143087. /** The utility layer the gizmo will be added to */
  143088. gizmoLayer?: UtilityLayerRenderer);
  143089. /**
  143090. * Updates the gizmo to match the attached mesh's position/rotation
  143091. */
  143092. protected _update(): void;
  143093. /**
  143094. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  143095. * @param value Node, TransformNode or mesh
  143096. */
  143097. protected _matrixChanged(): void;
  143098. /**
  143099. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  143100. * @param gizmoLayer The utility layer the gizmo will be added to
  143101. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  143102. * @returns {Observer<PointerInfo>} pointerObserver
  143103. */
  143104. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  143105. /**
  143106. * Disposes of the gizmo
  143107. */
  143108. dispose(): void;
  143109. }
  143110. }
  143111. declare module BABYLON {
  143112. /**
  143113. * Single plane drag gizmo
  143114. */
  143115. export class PlaneDragGizmo extends Gizmo {
  143116. /**
  143117. * Drag behavior responsible for the gizmos dragging interactions
  143118. */
  143119. dragBehavior: PointerDragBehavior;
  143120. private _pointerObserver;
  143121. /**
  143122. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  143123. */
  143124. snapDistance: number;
  143125. /**
  143126. * Event that fires each time the gizmo snaps to a new location.
  143127. * * snapDistance is the the change in distance
  143128. */
  143129. onSnapObservable: Observable<{
  143130. snapDistance: number;
  143131. }>;
  143132. private _gizmoMesh;
  143133. private _coloredMaterial;
  143134. private _hoverMaterial;
  143135. private _disableMaterial;
  143136. private _isEnabled;
  143137. private _parent;
  143138. private _dragging;
  143139. /** @hidden */
  143140. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  143141. /**
  143142. * Creates a PlaneDragGizmo
  143143. * @param gizmoLayer The utility layer the gizmo will be added to
  143144. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  143145. * @param color The color of the gizmo
  143146. */
  143147. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  143148. protected _attachedNodeChanged(value: Nullable<Node>): void;
  143149. /**
  143150. * If the gizmo is enabled
  143151. */
  143152. set isEnabled(value: boolean);
  143153. get isEnabled(): boolean;
  143154. /**
  143155. * Disposes of the gizmo
  143156. */
  143157. dispose(): void;
  143158. }
  143159. }
  143160. declare module BABYLON {
  143161. /**
  143162. * Single plane rotation gizmo
  143163. */
  143164. export class PlaneRotationGizmo extends Gizmo {
  143165. /**
  143166. * Drag behavior responsible for the gizmos dragging interactions
  143167. */
  143168. dragBehavior: PointerDragBehavior;
  143169. private _pointerObserver;
  143170. /**
  143171. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  143172. */
  143173. snapDistance: number;
  143174. /**
  143175. * Event that fires each time the gizmo snaps to a new location.
  143176. * * snapDistance is the the change in distance
  143177. */
  143178. onSnapObservable: Observable<{
  143179. snapDistance: number;
  143180. }>;
  143181. private _isEnabled;
  143182. private _parent;
  143183. private _coloredMaterial;
  143184. private _hoverMaterial;
  143185. private _disableMaterial;
  143186. private _gizmoMesh;
  143187. private _rotationCircle;
  143188. private _dragging;
  143189. private static _CircleConstants;
  143190. /**
  143191. * Creates a PlaneRotationGizmo
  143192. * @param gizmoLayer The utility layer the gizmo will be added to
  143193. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  143194. * @param color The color of the gizmo
  143195. * @param tessellation Amount of tessellation to be used when creating rotation circles
  143196. * @param useEulerRotation Use and update Euler angle instead of quaternion
  143197. * @param thickness display gizmo axis thickness
  143198. */
  143199. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  143200. /** Create Geometry for Gizmo */
  143201. private _createGizmoMesh;
  143202. protected _attachedNodeChanged(value: Nullable<Node>): void;
  143203. private setupRotationCircle;
  143204. private updateRotationPath;
  143205. private updateRotationCircle;
  143206. /**
  143207. * If the gizmo is enabled
  143208. */
  143209. set isEnabled(value: boolean);
  143210. get isEnabled(): boolean;
  143211. /**
  143212. * Disposes of the gizmo
  143213. */
  143214. dispose(): void;
  143215. }
  143216. }
  143217. declare module BABYLON {
  143218. /**
  143219. * Gizmo that enables rotating a mesh along 3 axis
  143220. */
  143221. export class RotationGizmo extends Gizmo {
  143222. /**
  143223. * Internal gizmo used for interactions on the x axis
  143224. */
  143225. xGizmo: PlaneRotationGizmo;
  143226. /**
  143227. * Internal gizmo used for interactions on the y axis
  143228. */
  143229. yGizmo: PlaneRotationGizmo;
  143230. /**
  143231. * Internal gizmo used for interactions on the z axis
  143232. */
  143233. zGizmo: PlaneRotationGizmo;
  143234. /** Fires an event when any of it's sub gizmos are dragged */
  143235. onDragStartObservable: Observable<unknown>;
  143236. /** Fires an event when any of it's sub gizmos are released from dragging */
  143237. onDragEndObservable: Observable<unknown>;
  143238. private _meshAttached;
  143239. private _nodeAttached;
  143240. private _observables;
  143241. /** Node Caching for quick lookup */
  143242. private _gizmoAxisCache;
  143243. get attachedMesh(): Nullable<AbstractMesh>;
  143244. set attachedMesh(mesh: Nullable<AbstractMesh>);
  143245. get attachedNode(): Nullable<Node>;
  143246. set attachedNode(node: Nullable<Node>);
  143247. protected _checkBillboardTransform(): void;
  143248. /**
  143249. * True when the mouse pointer is hovering a gizmo mesh
  143250. */
  143251. get isHovered(): boolean;
  143252. /**
  143253. * Creates a RotationGizmo
  143254. * @param gizmoLayer The utility layer the gizmo will be added to
  143255. * @param tessellation Amount of tessellation to be used when creating rotation circles
  143256. * @param useEulerRotation Use and update Euler angle instead of quaternion
  143257. * @param thickness display gizmo axis thickness
  143258. */
  143259. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  143260. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  143261. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  143262. /**
  143263. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  143264. */
  143265. set snapDistance(value: number);
  143266. get snapDistance(): number;
  143267. /**
  143268. * Ratio for the scale of the gizmo (Default: 1)
  143269. */
  143270. set scaleRatio(value: number);
  143271. get scaleRatio(): number;
  143272. /**
  143273. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  143274. * @param mesh Axis gizmo mesh
  143275. * @param cache Gizmo axis definition used for reactive gizmo UI
  143276. */
  143277. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  143278. /**
  143279. * Disposes of the gizmo
  143280. */
  143281. dispose(): void;
  143282. /**
  143283. * CustomMeshes are not supported by this gizmo
  143284. * @param mesh The mesh to replace the default mesh of the gizmo
  143285. */
  143286. setCustomMesh(mesh: Mesh): void;
  143287. }
  143288. }
  143289. declare module BABYLON {
  143290. /**
  143291. * Class containing static functions to help procedurally build meshes
  143292. */
  143293. export class PolyhedronBuilder {
  143294. /**
  143295. * Creates a polyhedron mesh
  143296. * * 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
  143297. * * The parameter `size` (positive float, default 1) sets the polygon size
  143298. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143299. * * 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 overrides the parameter `type`
  143300. * * 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
  143301. * * 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)`)
  143302. * * 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
  143303. * * 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
  143304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143307. * @param name defines the name of the mesh
  143308. * @param options defines the options used to create the mesh
  143309. * @param scene defines the hosting scene
  143310. * @returns the polyhedron mesh
  143311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143312. */
  143313. static CreatePolyhedron(name: string, options: {
  143314. type?: number;
  143315. size?: number;
  143316. sizeX?: number;
  143317. sizeY?: number;
  143318. sizeZ?: number;
  143319. custom?: any;
  143320. faceUV?: Vector4[];
  143321. faceColors?: Color4[];
  143322. flat?: boolean;
  143323. updatable?: boolean;
  143324. sideOrientation?: number;
  143325. frontUVs?: Vector4;
  143326. backUVs?: Vector4;
  143327. }, scene?: Nullable<Scene>): Mesh;
  143328. }
  143329. }
  143330. declare module BABYLON {
  143331. /**
  143332. * Class containing static functions to help procedurally build meshes
  143333. */
  143334. export class BoxBuilder {
  143335. /**
  143336. * Creates a box mesh
  143337. * * The parameter `size` sets the size (float) of each box side (default 1)
  143338. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  143339. * * 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)
  143340. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143344. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143345. * @param name defines the name of the mesh
  143346. * @param options defines the options used to create the mesh
  143347. * @param scene defines the hosting scene
  143348. * @returns the box mesh
  143349. */
  143350. static CreateBox(name: string, options: {
  143351. size?: number;
  143352. width?: number;
  143353. height?: number;
  143354. depth?: number;
  143355. faceUV?: Vector4[];
  143356. faceColors?: Color4[];
  143357. sideOrientation?: number;
  143358. frontUVs?: Vector4;
  143359. backUVs?: Vector4;
  143360. wrap?: boolean;
  143361. topBaseAt?: number;
  143362. bottomBaseAt?: number;
  143363. updatable?: boolean;
  143364. }, scene?: Nullable<Scene>): Mesh;
  143365. }
  143366. }
  143367. declare module BABYLON {
  143368. /**
  143369. * Single axis scale gizmo
  143370. */
  143371. export class AxisScaleGizmo extends Gizmo {
  143372. /**
  143373. * Drag behavior responsible for the gizmos dragging interactions
  143374. */
  143375. dragBehavior: PointerDragBehavior;
  143376. private _pointerObserver;
  143377. /**
  143378. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  143379. */
  143380. snapDistance: number;
  143381. /**
  143382. * Event that fires each time the gizmo snaps to a new location.
  143383. * * snapDistance is the the change in distance
  143384. */
  143385. onSnapObservable: Observable<{
  143386. snapDistance: number;
  143387. }>;
  143388. /**
  143389. * If the scaling operation should be done on all axis (default: false)
  143390. */
  143391. uniformScaling: boolean;
  143392. /**
  143393. * Custom sensitivity value for the drag strength
  143394. */
  143395. sensitivity: number;
  143396. private _isEnabled;
  143397. private _parent;
  143398. private _gizmoMesh;
  143399. private _coloredMaterial;
  143400. private _hoverMaterial;
  143401. private _disableMaterial;
  143402. private _dragging;
  143403. private _tmpVector;
  143404. private _tmpMatrix;
  143405. private _tmpMatrix2;
  143406. /**
  143407. * Creates an AxisScaleGizmo
  143408. * @param gizmoLayer The utility layer the gizmo will be added to
  143409. * @param dragAxis The axis which the gizmo will be able to scale on
  143410. * @param color The color of the gizmo
  143411. * @param thickness display gizmo axis thickness
  143412. */
  143413. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  143414. /** Create Geometry for Gizmo */
  143415. private _createGizmoMesh;
  143416. protected _attachedNodeChanged(value: Nullable<Node>): void;
  143417. /**
  143418. * If the gizmo is enabled
  143419. */
  143420. set isEnabled(value: boolean);
  143421. get isEnabled(): boolean;
  143422. /**
  143423. * Disposes of the gizmo
  143424. */
  143425. dispose(): void;
  143426. /**
  143427. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  143428. * @param mesh The mesh to replace the default mesh of the gizmo
  143429. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  143430. */
  143431. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  143432. }
  143433. }
  143434. declare module BABYLON {
  143435. /**
  143436. * Gizmo that enables scaling a mesh along 3 axis
  143437. */
  143438. export class ScaleGizmo extends Gizmo {
  143439. /**
  143440. * Internal gizmo used for interactions on the x axis
  143441. */
  143442. xGizmo: AxisScaleGizmo;
  143443. /**
  143444. * Internal gizmo used for interactions on the y axis
  143445. */
  143446. yGizmo: AxisScaleGizmo;
  143447. /**
  143448. * Internal gizmo used for interactions on the z axis
  143449. */
  143450. zGizmo: AxisScaleGizmo;
  143451. /**
  143452. * Internal gizmo used to scale all axis equally
  143453. */
  143454. uniformScaleGizmo: AxisScaleGizmo;
  143455. private _meshAttached;
  143456. private _nodeAttached;
  143457. private _snapDistance;
  143458. private _uniformScalingMesh;
  143459. private _octahedron;
  143460. private _sensitivity;
  143461. private _coloredMaterial;
  143462. private _hoverMaterial;
  143463. private _disableMaterial;
  143464. private _observables;
  143465. /** Node Caching for quick lookup */
  143466. private _gizmoAxisCache;
  143467. /** Fires an event when any of it's sub gizmos are dragged */
  143468. onDragStartObservable: Observable<unknown>;
  143469. /** Fires an event when any of it's sub gizmos are released from dragging */
  143470. onDragEndObservable: Observable<unknown>;
  143471. get attachedMesh(): Nullable<AbstractMesh>;
  143472. set attachedMesh(mesh: Nullable<AbstractMesh>);
  143473. get attachedNode(): Nullable<Node>;
  143474. set attachedNode(node: Nullable<Node>);
  143475. /**
  143476. * True when the mouse pointer is hovering a gizmo mesh
  143477. */
  143478. get isHovered(): boolean;
  143479. /**
  143480. * Creates a ScaleGizmo
  143481. * @param gizmoLayer The utility layer the gizmo will be added to
  143482. * @param thickness display gizmo axis thickness
  143483. */
  143484. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  143485. /** Create Geometry for Gizmo */
  143486. private _createUniformScaleMesh;
  143487. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  143488. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  143489. /**
  143490. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  143491. */
  143492. set snapDistance(value: number);
  143493. get snapDistance(): number;
  143494. /**
  143495. * Ratio for the scale of the gizmo (Default: 1)
  143496. */
  143497. set scaleRatio(value: number);
  143498. get scaleRatio(): number;
  143499. /**
  143500. * Sensitivity factor for dragging (Default: 1)
  143501. */
  143502. set sensitivity(value: number);
  143503. get sensitivity(): number;
  143504. /**
  143505. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  143506. * @param mesh Axis gizmo mesh
  143507. * @param cache Gizmo axis definition used for reactive gizmo UI
  143508. */
  143509. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  143510. /**
  143511. * Disposes of the gizmo
  143512. */
  143513. dispose(): void;
  143514. }
  143515. }
  143516. declare module BABYLON {
  143517. /**
  143518. * Bounding box gizmo
  143519. */
  143520. export class BoundingBoxGizmo extends Gizmo {
  143521. private _lineBoundingBox;
  143522. private _rotateSpheresParent;
  143523. private _scaleBoxesParent;
  143524. private _boundingDimensions;
  143525. private _renderObserver;
  143526. private _pointerObserver;
  143527. private _scaleDragSpeed;
  143528. private _tmpQuaternion;
  143529. private _tmpVector;
  143530. private _tmpRotationMatrix;
  143531. /**
  143532. * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  143533. */
  143534. ignoreChildren: boolean;
  143535. /**
  143536. * 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)
  143537. */
  143538. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  143539. /**
  143540. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  143541. */
  143542. rotationSphereSize: number;
  143543. /**
  143544. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  143545. */
  143546. scaleBoxSize: number;
  143547. /**
  143548. * 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)
  143549. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  143550. */
  143551. fixedDragMeshScreenSize: boolean;
  143552. /**
  143553. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  143554. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  143555. */
  143556. fixedDragMeshBoundsSize: boolean;
  143557. /**
  143558. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  143559. */
  143560. fixedDragMeshScreenSizeDistanceFactor: number;
  143561. /**
  143562. * Fired when a rotation sphere or scale box is dragged
  143563. */
  143564. onDragStartObservable: Observable<{}>;
  143565. /**
  143566. * Fired when a scale box is dragged
  143567. */
  143568. onScaleBoxDragObservable: Observable<{}>;
  143569. /**
  143570. * Fired when a scale box drag is ended
  143571. */
  143572. onScaleBoxDragEndObservable: Observable<{}>;
  143573. /**
  143574. * Fired when a rotation sphere is dragged
  143575. */
  143576. onRotationSphereDragObservable: Observable<{}>;
  143577. /**
  143578. * Fired when a rotation sphere drag is ended
  143579. */
  143580. onRotationSphereDragEndObservable: Observable<{}>;
  143581. /**
  143582. * 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)
  143583. */
  143584. scalePivot: Nullable<Vector3>;
  143585. /**
  143586. * Mesh used as a pivot to rotate the attached node
  143587. */
  143588. private _anchorMesh;
  143589. private _existingMeshScale;
  143590. private _dragMesh;
  143591. private pointerDragBehavior;
  143592. private coloredMaterial;
  143593. private hoverColoredMaterial;
  143594. /**
  143595. * Sets the color of the bounding box gizmo
  143596. * @param color the color to set
  143597. */
  143598. setColor(color: Color3): void;
  143599. /**
  143600. * Creates an BoundingBoxGizmo
  143601. * @param gizmoLayer The utility layer the gizmo will be added to
  143602. * @param color The color of the gizmo
  143603. */
  143604. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  143605. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  143606. private _selectNode;
  143607. /**
  143608. * Updates the bounding box information for the Gizmo
  143609. */
  143610. updateBoundingBox(): void;
  143611. private _updateRotationSpheres;
  143612. private _updateScaleBoxes;
  143613. /**
  143614. * Enables rotation on the specified axis and disables rotation on the others
  143615. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  143616. */
  143617. setEnabledRotationAxis(axis: string): void;
  143618. /**
  143619. * Enables/disables scaling
  143620. * @param enable if scaling should be enabled
  143621. * @param homogeneousScaling defines if scaling should only be homogeneous
  143622. */
  143623. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  143624. private _updateDummy;
  143625. /**
  143626. * Enables a pointer drag behavior on the bounding box of the gizmo
  143627. */
  143628. enableDragBehavior(): void;
  143629. /**
  143630. * Disposes of the gizmo
  143631. */
  143632. dispose(): void;
  143633. /**
  143634. * 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)
  143635. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  143636. * @returns the bounding box mesh with the passed in mesh as a child
  143637. */
  143638. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  143639. /**
  143640. * CustomMeshes are not supported by this gizmo
  143641. * @param mesh The mesh to replace the default mesh of the gizmo
  143642. */
  143643. setCustomMesh(mesh: Mesh): void;
  143644. }
  143645. }
  143646. declare module BABYLON {
  143647. /**
  143648. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  143649. */
  143650. export class GizmoManager implements IDisposable {
  143651. private scene;
  143652. /**
  143653. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  143654. */
  143655. gizmos: {
  143656. positionGizmo: Nullable<PositionGizmo>;
  143657. rotationGizmo: Nullable<RotationGizmo>;
  143658. scaleGizmo: Nullable<ScaleGizmo>;
  143659. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  143660. };
  143661. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  143662. clearGizmoOnEmptyPointerEvent: boolean;
  143663. /** Fires an event when the manager is attached to a mesh */
  143664. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  143665. /** Fires an event when the manager is attached to a node */
  143666. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  143667. private _gizmosEnabled;
  143668. private _pointerObservers;
  143669. private _attachedMesh;
  143670. private _attachedNode;
  143671. private _boundingBoxColor;
  143672. private _defaultUtilityLayer;
  143673. private _defaultKeepDepthUtilityLayer;
  143674. private _thickness;
  143675. /** Node Caching for quick lookup */
  143676. private _gizmoAxisCache;
  143677. /**
  143678. * When bounding box gizmo is enabled, this can be used to track drag/end events
  143679. */
  143680. boundingBoxDragBehavior: SixDofDragBehavior;
  143681. /**
  143682. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  143683. */
  143684. attachableMeshes: Nullable<Array<AbstractMesh>>;
  143685. /**
  143686. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  143687. */
  143688. attachableNodes: Nullable<Array<Node>>;
  143689. /**
  143690. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  143691. */
  143692. usePointerToAttachGizmos: boolean;
  143693. /**
  143694. * Utility layer that the bounding box gizmo belongs to
  143695. */
  143696. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  143697. /**
  143698. * Utility layer that all gizmos besides bounding box belong to
  143699. */
  143700. get utilityLayer(): UtilityLayerRenderer;
  143701. /**
  143702. * True when the mouse pointer is hovering a gizmo mesh
  143703. */
  143704. get isHovered(): boolean;
  143705. /**
  143706. * Instantiates a gizmo manager
  143707. * @param scene the scene to overlay the gizmos on top of
  143708. * @param thickness display gizmo axis thickness
  143709. * @param utilityLayer the layer where gizmos are rendered
  143710. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  143711. */
  143712. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  143713. /**
  143714. * Subscribes to pointer down events, for attaching and detaching mesh
  143715. * @param scene The scene layer the observer will be added to
  143716. */
  143717. private _attachToMeshPointerObserver;
  143718. /**
  143719. * Attaches a set of gizmos to the specified mesh
  143720. * @param mesh The mesh the gizmo's should be attached to
  143721. */
  143722. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  143723. /**
  143724. * Attaches a set of gizmos to the specified node
  143725. * @param node The node the gizmo's should be attached to
  143726. */
  143727. attachToNode(node: Nullable<Node>): void;
  143728. /**
  143729. * If the position gizmo is enabled
  143730. */
  143731. set positionGizmoEnabled(value: boolean);
  143732. get positionGizmoEnabled(): boolean;
  143733. /**
  143734. * If the rotation gizmo is enabled
  143735. */
  143736. set rotationGizmoEnabled(value: boolean);
  143737. get rotationGizmoEnabled(): boolean;
  143738. /**
  143739. * If the scale gizmo is enabled
  143740. */
  143741. set scaleGizmoEnabled(value: boolean);
  143742. get scaleGizmoEnabled(): boolean;
  143743. /**
  143744. * If the boundingBox gizmo is enabled
  143745. */
  143746. set boundingBoxGizmoEnabled(value: boolean);
  143747. get boundingBoxGizmoEnabled(): boolean;
  143748. /**
  143749. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  143750. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  143751. */
  143752. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  143753. /**
  143754. * Disposes of the gizmo manager
  143755. */
  143756. dispose(): void;
  143757. }
  143758. }
  143759. declare module BABYLON {
  143760. /**
  143761. * Gizmo that enables dragging a mesh along 3 axis
  143762. */
  143763. export class PositionGizmo extends Gizmo {
  143764. /**
  143765. * Internal gizmo used for interactions on the x axis
  143766. */
  143767. xGizmo: AxisDragGizmo;
  143768. /**
  143769. * Internal gizmo used for interactions on the y axis
  143770. */
  143771. yGizmo: AxisDragGizmo;
  143772. /**
  143773. * Internal gizmo used for interactions on the z axis
  143774. */
  143775. zGizmo: AxisDragGizmo;
  143776. /**
  143777. * Internal gizmo used for interactions on the yz plane
  143778. */
  143779. xPlaneGizmo: PlaneDragGizmo;
  143780. /**
  143781. * Internal gizmo used for interactions on the xz plane
  143782. */
  143783. yPlaneGizmo: PlaneDragGizmo;
  143784. /**
  143785. * Internal gizmo used for interactions on the xy plane
  143786. */
  143787. zPlaneGizmo: PlaneDragGizmo;
  143788. /**
  143789. * private variables
  143790. */
  143791. private _meshAttached;
  143792. private _nodeAttached;
  143793. private _snapDistance;
  143794. private _observables;
  143795. /** Node Caching for quick lookup */
  143796. private _gizmoAxisCache;
  143797. /** Fires an event when any of it's sub gizmos are dragged */
  143798. onDragStartObservable: Observable<unknown>;
  143799. /** Fires an event when any of it's sub gizmos are released from dragging */
  143800. onDragEndObservable: Observable<unknown>;
  143801. /**
  143802. * If set to true, planar drag is enabled
  143803. */
  143804. private _planarGizmoEnabled;
  143805. get attachedMesh(): Nullable<AbstractMesh>;
  143806. set attachedMesh(mesh: Nullable<AbstractMesh>);
  143807. get attachedNode(): Nullable<Node>;
  143808. set attachedNode(node: Nullable<Node>);
  143809. /**
  143810. * True when the mouse pointer is hovering a gizmo mesh
  143811. */
  143812. get isHovered(): boolean;
  143813. /**
  143814. * Creates a PositionGizmo
  143815. * @param gizmoLayer The utility layer the gizmo will be added to
  143816. @param thickness display gizmo axis thickness
  143817. */
  143818. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  143819. /**
  143820. * If the planar drag gizmo is enabled
  143821. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  143822. */
  143823. set planarGizmoEnabled(value: boolean);
  143824. get planarGizmoEnabled(): boolean;
  143825. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  143826. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  143827. /**
  143828. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  143829. */
  143830. set snapDistance(value: number);
  143831. get snapDistance(): number;
  143832. /**
  143833. * Ratio for the scale of the gizmo (Default: 1)
  143834. */
  143835. set scaleRatio(value: number);
  143836. get scaleRatio(): number;
  143837. /**
  143838. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  143839. * @param mesh Axis gizmo mesh
  143840. * @param cache Gizmo axis definition used for reactive gizmo UI
  143841. */
  143842. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  143843. /**
  143844. * Disposes of the gizmo
  143845. */
  143846. dispose(): void;
  143847. /**
  143848. * CustomMeshes are not supported by this gizmo
  143849. * @param mesh The mesh to replace the default mesh of the gizmo
  143850. */
  143851. setCustomMesh(mesh: Mesh): void;
  143852. }
  143853. }
  143854. declare module BABYLON {
  143855. /**
  143856. * Single axis drag gizmo
  143857. */
  143858. export class AxisDragGizmo extends Gizmo {
  143859. /**
  143860. * Drag behavior responsible for the gizmos dragging interactions
  143861. */
  143862. dragBehavior: PointerDragBehavior;
  143863. private _pointerObserver;
  143864. /**
  143865. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  143866. */
  143867. snapDistance: number;
  143868. /**
  143869. * Event that fires each time the gizmo snaps to a new location.
  143870. * * snapDistance is the the change in distance
  143871. */
  143872. onSnapObservable: Observable<{
  143873. snapDistance: number;
  143874. }>;
  143875. private _isEnabled;
  143876. private _parent;
  143877. private _gizmoMesh;
  143878. private _coloredMaterial;
  143879. private _hoverMaterial;
  143880. private _disableMaterial;
  143881. private _dragging;
  143882. /** @hidden */
  143883. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  143884. /** @hidden */
  143885. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  143886. /**
  143887. * Creates an AxisDragGizmo
  143888. * @param gizmoLayer The utility layer the gizmo will be added to
  143889. * @param dragAxis The axis which the gizmo will be able to drag on
  143890. * @param color The color of the gizmo
  143891. * @param thickness display gizmo axis thickness
  143892. */
  143893. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  143894. protected _attachedNodeChanged(value: Nullable<Node>): void;
  143895. /**
  143896. * If the gizmo is enabled
  143897. */
  143898. set isEnabled(value: boolean);
  143899. get isEnabled(): boolean;
  143900. /**
  143901. * Disposes of the gizmo
  143902. */
  143903. dispose(): void;
  143904. }
  143905. }
  143906. declare module BABYLON.Debug {
  143907. /**
  143908. * The Axes viewer will show 3 axes in a specific point in space
  143909. */
  143910. export class AxesViewer {
  143911. private _xAxis;
  143912. private _yAxis;
  143913. private _zAxis;
  143914. private _scaleLinesFactor;
  143915. private _instanced;
  143916. /**
  143917. * Gets the hosting scene
  143918. */
  143919. scene: Nullable<Scene>;
  143920. /**
  143921. * Gets or sets a number used to scale line length
  143922. */
  143923. scaleLines: number;
  143924. /** Gets the node hierarchy used to render x-axis */
  143925. get xAxis(): TransformNode;
  143926. /** Gets the node hierarchy used to render y-axis */
  143927. get yAxis(): TransformNode;
  143928. /** Gets the node hierarchy used to render z-axis */
  143929. get zAxis(): TransformNode;
  143930. /**
  143931. * Creates a new AxesViewer
  143932. * @param scene defines the hosting scene
  143933. * @param scaleLines defines a number used to scale line length (1 by default)
  143934. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  143935. * @param xAxis defines the node hierarchy used to render the x-axis
  143936. * @param yAxis defines the node hierarchy used to render the y-axis
  143937. * @param zAxis defines the node hierarchy used to render the z-axis
  143938. */
  143939. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  143940. /**
  143941. * Force the viewer to update
  143942. * @param position defines the position of the viewer
  143943. * @param xaxis defines the x axis of the viewer
  143944. * @param yaxis defines the y axis of the viewer
  143945. * @param zaxis defines the z axis of the viewer
  143946. */
  143947. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  143948. /**
  143949. * Creates an instance of this axes viewer.
  143950. * @returns a new axes viewer with instanced meshes
  143951. */
  143952. createInstance(): AxesViewer;
  143953. /** Releases resources */
  143954. dispose(): void;
  143955. private static _SetRenderingGroupId;
  143956. }
  143957. }
  143958. declare module BABYLON.Debug {
  143959. /**
  143960. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  143961. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  143962. */
  143963. export class BoneAxesViewer extends AxesViewer {
  143964. /**
  143965. * Gets or sets the target mesh where to display the axes viewer
  143966. */
  143967. mesh: Nullable<Mesh>;
  143968. /**
  143969. * Gets or sets the target bone where to display the axes viewer
  143970. */
  143971. bone: Nullable<Bone>;
  143972. /** Gets current position */
  143973. pos: Vector3;
  143974. /** Gets direction of X axis */
  143975. xaxis: Vector3;
  143976. /** Gets direction of Y axis */
  143977. yaxis: Vector3;
  143978. /** Gets direction of Z axis */
  143979. zaxis: Vector3;
  143980. /**
  143981. * Creates a new BoneAxesViewer
  143982. * @param scene defines the hosting scene
  143983. * @param bone defines the target bone
  143984. * @param mesh defines the target mesh
  143985. * @param scaleLines defines a scaling factor for line length (1 by default)
  143986. */
  143987. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  143988. /**
  143989. * Force the viewer to update
  143990. */
  143991. update(): void;
  143992. /** Releases resources */
  143993. dispose(): void;
  143994. }
  143995. }
  143996. declare module BABYLON {
  143997. /**
  143998. * Interface used to define scene explorer extensibility option
  143999. */
  144000. export interface IExplorerExtensibilityOption {
  144001. /**
  144002. * Define the option label
  144003. */
  144004. label: string;
  144005. /**
  144006. * Defines the action to execute on click
  144007. */
  144008. action: (entity: any) => void;
  144009. }
  144010. /**
  144011. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  144012. */
  144013. export interface IExplorerExtensibilityGroup {
  144014. /**
  144015. * Defines a predicate to test if a given type mut be extended
  144016. */
  144017. predicate: (entity: any) => boolean;
  144018. /**
  144019. * Gets the list of options added to a type
  144020. */
  144021. entries: IExplorerExtensibilityOption[];
  144022. }
  144023. /**
  144024. * Interface used to define the options to use to create the Inspector
  144025. */
  144026. export interface IInspectorOptions {
  144027. /**
  144028. * Display in overlay mode (default: false)
  144029. */
  144030. overlay?: boolean;
  144031. /**
  144032. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  144033. */
  144034. globalRoot?: HTMLElement;
  144035. /**
  144036. * Display the Scene explorer
  144037. */
  144038. showExplorer?: boolean;
  144039. /**
  144040. * Display the property inspector
  144041. */
  144042. showInspector?: boolean;
  144043. /**
  144044. * Display in embed mode (both panes on the right)
  144045. */
  144046. embedMode?: boolean;
  144047. /**
  144048. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  144049. */
  144050. handleResize?: boolean;
  144051. /**
  144052. * Allow the panes to popup (default: true)
  144053. */
  144054. enablePopup?: boolean;
  144055. /**
  144056. * Allow the panes to be closed by users (default: true)
  144057. */
  144058. enableClose?: boolean;
  144059. /**
  144060. * Optional list of extensibility entries
  144061. */
  144062. explorerExtensibility?: IExplorerExtensibilityGroup[];
  144063. /**
  144064. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  144065. */
  144066. inspectorURL?: string;
  144067. /**
  144068. * Optional initial tab (default to DebugLayerTab.Properties)
  144069. */
  144070. initialTab?: DebugLayerTab;
  144071. }
  144072. interface Scene {
  144073. /**
  144074. * @hidden
  144075. * Backing field
  144076. */
  144077. _debugLayer: DebugLayer;
  144078. /**
  144079. * Gets the debug layer (aka Inspector) associated with the scene
  144080. * @see https://doc.babylonjs.com/features/playground_debuglayer
  144081. */
  144082. debugLayer: DebugLayer;
  144083. }
  144084. /**
  144085. * Enum of inspector action tab
  144086. */
  144087. export enum DebugLayerTab {
  144088. /**
  144089. * Properties tag (default)
  144090. */
  144091. Properties = 0,
  144092. /**
  144093. * Debug tab
  144094. */
  144095. Debug = 1,
  144096. /**
  144097. * Statistics tab
  144098. */
  144099. Statistics = 2,
  144100. /**
  144101. * Tools tab
  144102. */
  144103. Tools = 3,
  144104. /**
  144105. * Settings tab
  144106. */
  144107. Settings = 4
  144108. }
  144109. /**
  144110. * The debug layer (aka Inspector) is the go to tool in order to better understand
  144111. * what is happening in your scene
  144112. * @see https://doc.babylonjs.com/features/playground_debuglayer
  144113. */
  144114. export class DebugLayer {
  144115. /**
  144116. * Define the url to get the inspector script from.
  144117. * By default it uses the babylonjs CDN.
  144118. * @ignoreNaming
  144119. */
  144120. static InspectorURL: string;
  144121. private _scene;
  144122. private BJSINSPECTOR;
  144123. private _onPropertyChangedObservable?;
  144124. /**
  144125. * Observable triggered when a property is changed through the inspector.
  144126. */
  144127. get onPropertyChangedObservable(): any;
  144128. /**
  144129. * Instantiates a new debug layer.
  144130. * The debug layer (aka Inspector) is the go to tool in order to better understand
  144131. * what is happening in your scene
  144132. * @see https://doc.babylonjs.com/features/playground_debuglayer
  144133. * @param scene Defines the scene to inspect
  144134. */
  144135. constructor(scene: Scene);
  144136. /** Creates the inspector window. */
  144137. private _createInspector;
  144138. /**
  144139. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  144140. * @param entity defines the entity to select
  144141. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  144142. */
  144143. select(entity: any, lineContainerTitles?: string | string[]): void;
  144144. /** Get the inspector from bundle or global */
  144145. private _getGlobalInspector;
  144146. /**
  144147. * Get if the inspector is visible or not.
  144148. * @returns true if visible otherwise, false
  144149. */
  144150. isVisible(): boolean;
  144151. /**
  144152. * Hide the inspector and close its window.
  144153. */
  144154. hide(): void;
  144155. /**
  144156. * Update the scene in the inspector
  144157. */
  144158. setAsActiveScene(): void;
  144159. /**
  144160. * Launch the debugLayer.
  144161. * @param config Define the configuration of the inspector
  144162. * @return a promise fulfilled when the debug layer is visible
  144163. */
  144164. show(config?: IInspectorOptions): Promise<DebugLayer>;
  144165. }
  144166. }
  144167. declare module BABYLON.Debug {
  144168. /**
  144169. * Used to show the physics impostor around the specific mesh
  144170. */
  144171. export class PhysicsViewer {
  144172. /** @hidden */
  144173. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  144174. /** @hidden */
  144175. protected _meshes: Array<Nullable<AbstractMesh>>;
  144176. /** @hidden */
  144177. protected _scene: Nullable<Scene>;
  144178. /** @hidden */
  144179. protected _numMeshes: number;
  144180. /** @hidden */
  144181. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  144182. private _renderFunction;
  144183. private _utilityLayer;
  144184. private _debugBoxMesh;
  144185. private _debugSphereMesh;
  144186. private _debugCylinderMesh;
  144187. private _debugMaterial;
  144188. private _debugMeshMeshes;
  144189. /**
  144190. * Creates a new PhysicsViewer
  144191. * @param scene defines the hosting scene
  144192. */
  144193. constructor(scene: Scene);
  144194. /** @hidden */
  144195. protected _updateDebugMeshes(): void;
  144196. /**
  144197. * Renders a specified physic impostor
  144198. * @param impostor defines the impostor to render
  144199. * @param targetMesh defines the mesh represented by the impostor
  144200. * @returns the new debug mesh used to render the impostor
  144201. */
  144202. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  144203. /**
  144204. * Hides a specified physic impostor
  144205. * @param impostor defines the impostor to hide
  144206. */
  144207. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  144208. private _getDebugMaterial;
  144209. private _getDebugBoxMesh;
  144210. private _getDebugSphereMesh;
  144211. private _getDebugCylinderMesh;
  144212. private _getDebugMeshMesh;
  144213. private _getDebugMesh;
  144214. /** Releases all resources */
  144215. dispose(): void;
  144216. }
  144217. }
  144218. declare module BABYLON {
  144219. /**
  144220. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  144221. * in order to better appreciate the issue one might have.
  144222. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  144223. */
  144224. export class RayHelper {
  144225. /**
  144226. * Defines the ray we are currently tryin to visualize.
  144227. */
  144228. ray: Nullable<Ray>;
  144229. private _renderPoints;
  144230. private _renderLine;
  144231. private _renderFunction;
  144232. private _scene;
  144233. private _onAfterRenderObserver;
  144234. private _onAfterStepObserver;
  144235. private _attachedToMesh;
  144236. private _meshSpaceDirection;
  144237. private _meshSpaceOrigin;
  144238. /**
  144239. * Helper function to create a colored helper in a scene in one line.
  144240. * @param ray Defines the ray we are currently tryin to visualize
  144241. * @param scene Defines the scene the ray is used in
  144242. * @param color Defines the color we want to see the ray in
  144243. * @returns The newly created ray helper.
  144244. */
  144245. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  144246. /**
  144247. * Instantiate a new ray helper.
  144248. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  144249. * in order to better appreciate the issue one might have.
  144250. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  144251. * @param ray Defines the ray we are currently tryin to visualize
  144252. */
  144253. constructor(ray: Ray);
  144254. /**
  144255. * Shows the ray we are willing to debug.
  144256. * @param scene Defines the scene the ray needs to be rendered in
  144257. * @param color Defines the color the ray needs to be rendered in
  144258. */
  144259. show(scene: Scene, color?: Color3): void;
  144260. /**
  144261. * Hides the ray we are debugging.
  144262. */
  144263. hide(): void;
  144264. private _render;
  144265. /**
  144266. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  144267. * @param mesh Defines the mesh we want the helper attached to
  144268. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  144269. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  144270. * @param length Defines the length of the ray
  144271. */
  144272. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  144273. /**
  144274. * Detach the ray helper from the mesh it has previously been attached to.
  144275. */
  144276. detachFromMesh(): void;
  144277. private _updateToMesh;
  144278. /**
  144279. * Dispose the helper and release its associated resources.
  144280. */
  144281. dispose(): void;
  144282. }
  144283. }
  144284. declare module BABYLON {
  144285. /**
  144286. * Defines the options associated with the creation of a SkeletonViewer.
  144287. */
  144288. export interface ISkeletonViewerOptions {
  144289. /** Should the system pause animations before building the Viewer? */
  144290. pauseAnimations: boolean;
  144291. /** Should the system return the skeleton to rest before building? */
  144292. returnToRest: boolean;
  144293. /** public Display Mode of the Viewer */
  144294. displayMode: number;
  144295. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  144296. displayOptions: ISkeletonViewerDisplayOptions;
  144297. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  144298. computeBonesUsingShaders: boolean;
  144299. /** Flag ignore non weighted bones */
  144300. useAllBones: boolean;
  144301. }
  144302. /**
  144303. * Defines how to display the various bone meshes for the viewer.
  144304. */
  144305. export interface ISkeletonViewerDisplayOptions {
  144306. /** How far down to start tapering the bone spurs */
  144307. midStep?: number;
  144308. /** How big is the midStep? */
  144309. midStepFactor?: number;
  144310. /** Base for the Sphere Size */
  144311. sphereBaseSize?: number;
  144312. /** The ratio of the sphere to the longest bone in units */
  144313. sphereScaleUnit?: number;
  144314. /** Ratio for the Sphere Size */
  144315. sphereFactor?: number;
  144316. /** Whether a spur should attach its far end to the child bone position */
  144317. spurFollowsChild?: boolean;
  144318. /** Whether to show local axes or not */
  144319. showLocalAxes?: boolean;
  144320. /** Length of each local axis */
  144321. localAxesSize?: number;
  144322. }
  144323. /**
  144324. * Defines the constructor options for the BoneWeight Shader.
  144325. */
  144326. export interface IBoneWeightShaderOptions {
  144327. /** Skeleton to Map */
  144328. skeleton: Skeleton;
  144329. /** Colors for Uninfluenced bones */
  144330. colorBase?: Color3;
  144331. /** Colors for 0.0-0.25 Weight bones */
  144332. colorZero?: Color3;
  144333. /** Color for 0.25-0.5 Weight Influence */
  144334. colorQuarter?: Color3;
  144335. /** Color for 0.5-0.75 Weight Influence */
  144336. colorHalf?: Color3;
  144337. /** Color for 0.75-1 Weight Influence */
  144338. colorFull?: Color3;
  144339. /** Color for Zero Weight Influence */
  144340. targetBoneIndex?: number;
  144341. }
  144342. /**
  144343. * Simple structure of the gradient steps for the Color Map.
  144344. */
  144345. export interface ISkeletonMapShaderColorMapKnot {
  144346. /** Color of the Knot */
  144347. color: Color3;
  144348. /** Location of the Knot */
  144349. location: number;
  144350. }
  144351. /**
  144352. * Defines the constructor options for the SkeletonMap Shader.
  144353. */
  144354. export interface ISkeletonMapShaderOptions {
  144355. /** Skeleton to Map */
  144356. skeleton: Skeleton;
  144357. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  144358. colorMap?: ISkeletonMapShaderColorMapKnot[];
  144359. }
  144360. }
  144361. declare module BABYLON {
  144362. /**
  144363. * Class containing static functions to help procedurally build meshes
  144364. */
  144365. export class RibbonBuilder {
  144366. /**
  144367. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144368. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144369. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144370. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144371. * * 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
  144372. * * 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
  144373. * * 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
  144374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144377. * * 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
  144378. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144379. * * 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
  144380. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144382. * @param name defines the name of the mesh
  144383. * @param options defines the options used to create the mesh
  144384. * @param scene defines the hosting scene
  144385. * @returns the ribbon mesh
  144386. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144387. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144388. */
  144389. static CreateRibbon(name: string, options: {
  144390. pathArray: Vector3[][];
  144391. closeArray?: boolean;
  144392. closePath?: boolean;
  144393. offset?: number;
  144394. updatable?: boolean;
  144395. sideOrientation?: number;
  144396. frontUVs?: Vector4;
  144397. backUVs?: Vector4;
  144398. instance?: Mesh;
  144399. invertUV?: boolean;
  144400. uvs?: Vector2[];
  144401. colors?: Color4[];
  144402. }, scene?: Nullable<Scene>): Mesh;
  144403. }
  144404. }
  144405. declare module BABYLON {
  144406. /**
  144407. * Class containing static functions to help procedurally build meshes
  144408. */
  144409. export class ShapeBuilder {
  144410. /**
  144411. * 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.
  144412. * * 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.
  144413. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144414. * * 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.
  144415. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144416. * * 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
  144417. * * 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
  144418. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144423. * @param name defines the name of the mesh
  144424. * @param options defines the options used to create the mesh
  144425. * @param scene defines the hosting scene
  144426. * @returns the extruded shape mesh
  144427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144429. */
  144430. static ExtrudeShape(name: string, options: {
  144431. shape: Vector3[];
  144432. path: Vector3[];
  144433. scale?: number;
  144434. rotation?: number;
  144435. cap?: number;
  144436. updatable?: boolean;
  144437. sideOrientation?: number;
  144438. frontUVs?: Vector4;
  144439. backUVs?: Vector4;
  144440. instance?: Mesh;
  144441. invertUV?: boolean;
  144442. }, scene?: Nullable<Scene>): Mesh;
  144443. /**
  144444. * Creates an custom extruded shape mesh.
  144445. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144446. * * 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.
  144447. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144448. * * 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 beginning of the path
  144449. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144450. * * 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 beginning of the path
  144451. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144452. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144453. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144454. * * 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
  144455. * * 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
  144456. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144461. * @param name defines the name of the mesh
  144462. * @param options defines the options used to create the mesh
  144463. * @param scene defines the hosting scene
  144464. * @returns the custom extruded shape mesh
  144465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144468. */
  144469. static ExtrudeShapeCustom(name: string, options: {
  144470. shape: Vector3[];
  144471. path: Vector3[];
  144472. scaleFunction?: any;
  144473. rotationFunction?: any;
  144474. ribbonCloseArray?: boolean;
  144475. ribbonClosePath?: boolean;
  144476. cap?: number;
  144477. updatable?: boolean;
  144478. sideOrientation?: number;
  144479. frontUVs?: Vector4;
  144480. backUVs?: Vector4;
  144481. instance?: Mesh;
  144482. invertUV?: boolean;
  144483. }, scene?: Nullable<Scene>): Mesh;
  144484. private static _ExtrudeShapeGeneric;
  144485. }
  144486. }
  144487. declare module BABYLON.Debug {
  144488. /**
  144489. * Class used to render a debug view of a given skeleton
  144490. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  144491. */
  144492. export class SkeletonViewer {
  144493. /** defines the skeleton to render */
  144494. skeleton: Skeleton;
  144495. /** defines the mesh attached to the skeleton */
  144496. mesh: AbstractMesh;
  144497. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  144498. autoUpdateBonesMatrices: boolean;
  144499. /** defines the rendering group id to use with the viewer */
  144500. renderingGroupId: number;
  144501. /** is the options for the viewer */
  144502. options: Partial<ISkeletonViewerOptions>;
  144503. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  144504. static readonly DISPLAY_LINES: number;
  144505. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  144506. static readonly DISPLAY_SPHERES: number;
  144507. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  144508. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  144509. /** public static method to create a BoneWeight Shader
  144510. * @param options The constructor options
  144511. * @param scene The scene that the shader is scoped to
  144512. * @returns The created ShaderMaterial
  144513. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  144514. */
  144515. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  144516. /** public static method to create a BoneWeight Shader
  144517. * @param options The constructor options
  144518. * @param scene The scene that the shader is scoped to
  144519. * @returns The created ShaderMaterial
  144520. */
  144521. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  144522. /** private static method to create a BoneWeight Shader
  144523. * @param size The size of the buffer to create (usually the bone count)
  144524. * @param colorMap The gradient data to generate
  144525. * @param scene The scene that the shader is scoped to
  144526. * @returns an Array of floats from the color gradient values
  144527. */
  144528. private static _CreateBoneMapColorBuffer;
  144529. /** If SkeletonViewer scene scope. */
  144530. private _scene;
  144531. /** Gets or sets the color used to render the skeleton */
  144532. color: Color3;
  144533. /** Array of the points of the skeleton fo the line view. */
  144534. private _debugLines;
  144535. /** The SkeletonViewers Mesh. */
  144536. private _debugMesh;
  144537. /** The local axes Meshes. */
  144538. private _localAxes;
  144539. /** If SkeletonViewer is enabled. */
  144540. private _isEnabled;
  144541. /** If SkeletonViewer is ready. */
  144542. private _ready;
  144543. /** SkeletonViewer render observable. */
  144544. private _obs;
  144545. /** The Utility Layer to render the gizmos in. */
  144546. private _utilityLayer;
  144547. private _boneIndices;
  144548. /** Gets the Scene. */
  144549. get scene(): Scene;
  144550. /** Gets the utilityLayer. */
  144551. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  144552. /** Checks Ready Status. */
  144553. get isReady(): Boolean;
  144554. /** Sets Ready Status. */
  144555. set ready(value: boolean);
  144556. /** Gets the debugMesh */
  144557. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  144558. /** Sets the debugMesh */
  144559. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  144560. /** Gets the displayMode */
  144561. get displayMode(): number;
  144562. /** Sets the displayMode */
  144563. set displayMode(value: number);
  144564. /**
  144565. * Creates a new SkeletonViewer
  144566. * @param skeleton defines the skeleton to render
  144567. * @param mesh defines the mesh attached to the skeleton
  144568. * @param scene defines the hosting scene
  144569. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  144570. * @param renderingGroupId defines the rendering group id to use with the viewer
  144571. * @param options All of the extra constructor options for the SkeletonViewer
  144572. */
  144573. constructor(
  144574. /** defines the skeleton to render */
  144575. skeleton: Skeleton,
  144576. /** defines the mesh attached to the skeleton */
  144577. mesh: AbstractMesh,
  144578. /** The Scene scope*/
  144579. scene: Scene,
  144580. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  144581. autoUpdateBonesMatrices?: boolean,
  144582. /** defines the rendering group id to use with the viewer */
  144583. renderingGroupId?: number,
  144584. /** is the options for the viewer */
  144585. options?: Partial<ISkeletonViewerOptions>);
  144586. /** The Dynamic bindings for the update functions */
  144587. private _bindObs;
  144588. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  144589. update(): void;
  144590. /** Gets or sets a boolean indicating if the viewer is enabled */
  144591. set isEnabled(value: boolean);
  144592. get isEnabled(): boolean;
  144593. private _getBonePosition;
  144594. private _getLinesForBonesWithLength;
  144595. private _getLinesForBonesNoLength;
  144596. /** function to revert the mesh and scene back to the initial state. */
  144597. private _revert;
  144598. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  144599. private _getAbsoluteBindPoseToRef;
  144600. /** function to build and bind sphere joint points and spur bone representations. */
  144601. private _buildSpheresAndSpurs;
  144602. private _buildLocalAxes;
  144603. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  144604. private _displayLinesUpdate;
  144605. /** Changes the displayMode of the skeleton viewer
  144606. * @param mode The displayMode numerical value
  144607. */
  144608. changeDisplayMode(mode: number): void;
  144609. /** Sets a display option of the skeleton viewer
  144610. *
  144611. * | Option | Type | Default | Description |
  144612. * | ---------------- | ------- | ------- | ----------- |
  144613. * | 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`. |
  144614. * | 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`. |
  144615. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  144616. * | 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`. |
  144617. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  144618. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  144619. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  144620. *
  144621. * @param option String of the option name
  144622. * @param value The numerical option value
  144623. */
  144624. changeDisplayOptions(option: string, value: number): void;
  144625. /** Release associated resources */
  144626. dispose(): void;
  144627. }
  144628. }
  144629. declare module BABYLON {
  144630. /**
  144631. * Enum for Device Types
  144632. */
  144633. export enum DeviceType {
  144634. /** Generic */
  144635. Generic = 0,
  144636. /** Keyboard */
  144637. Keyboard = 1,
  144638. /** Mouse */
  144639. Mouse = 2,
  144640. /** Touch Pointers */
  144641. Touch = 3,
  144642. /** PS4 Dual Shock */
  144643. DualShock = 4,
  144644. /** Xbox */
  144645. Xbox = 5,
  144646. /** Switch Controller */
  144647. Switch = 6
  144648. }
  144649. /**
  144650. * Enum for All Pointers (Touch/Mouse)
  144651. */
  144652. export enum PointerInput {
  144653. /** Horizontal Axis */
  144654. Horizontal = 0,
  144655. /** Vertical Axis */
  144656. Vertical = 1,
  144657. /** Left Click or Touch */
  144658. LeftClick = 2,
  144659. /** Middle Click */
  144660. MiddleClick = 3,
  144661. /** Right Click */
  144662. RightClick = 4,
  144663. /** Browser Back */
  144664. BrowserBack = 5,
  144665. /** Browser Forward */
  144666. BrowserForward = 6
  144667. }
  144668. /**
  144669. * Enum for Dual Shock Gamepad
  144670. */
  144671. export enum DualShockInput {
  144672. /** Cross */
  144673. Cross = 0,
  144674. /** Circle */
  144675. Circle = 1,
  144676. /** Square */
  144677. Square = 2,
  144678. /** Triangle */
  144679. Triangle = 3,
  144680. /** L1 */
  144681. L1 = 4,
  144682. /** R1 */
  144683. R1 = 5,
  144684. /** L2 */
  144685. L2 = 6,
  144686. /** R2 */
  144687. R2 = 7,
  144688. /** Share */
  144689. Share = 8,
  144690. /** Options */
  144691. Options = 9,
  144692. /** L3 */
  144693. L3 = 10,
  144694. /** R3 */
  144695. R3 = 11,
  144696. /** DPadUp */
  144697. DPadUp = 12,
  144698. /** DPadDown */
  144699. DPadDown = 13,
  144700. /** DPadLeft */
  144701. DPadLeft = 14,
  144702. /** DRight */
  144703. DPadRight = 15,
  144704. /** Home */
  144705. Home = 16,
  144706. /** TouchPad */
  144707. TouchPad = 17,
  144708. /** LStickXAxis */
  144709. LStickXAxis = 18,
  144710. /** LStickYAxis */
  144711. LStickYAxis = 19,
  144712. /** RStickXAxis */
  144713. RStickXAxis = 20,
  144714. /** RStickYAxis */
  144715. RStickYAxis = 21
  144716. }
  144717. /**
  144718. * Enum for Xbox Gamepad
  144719. */
  144720. export enum XboxInput {
  144721. /** A */
  144722. A = 0,
  144723. /** B */
  144724. B = 1,
  144725. /** X */
  144726. X = 2,
  144727. /** Y */
  144728. Y = 3,
  144729. /** LB */
  144730. LB = 4,
  144731. /** RB */
  144732. RB = 5,
  144733. /** LT */
  144734. LT = 6,
  144735. /** RT */
  144736. RT = 7,
  144737. /** Back */
  144738. Back = 8,
  144739. /** Start */
  144740. Start = 9,
  144741. /** LS */
  144742. LS = 10,
  144743. /** RS */
  144744. RS = 11,
  144745. /** DPadUp */
  144746. DPadUp = 12,
  144747. /** DPadDown */
  144748. DPadDown = 13,
  144749. /** DPadLeft */
  144750. DPadLeft = 14,
  144751. /** DRight */
  144752. DPadRight = 15,
  144753. /** Home */
  144754. Home = 16,
  144755. /** LStickXAxis */
  144756. LStickXAxis = 17,
  144757. /** LStickYAxis */
  144758. LStickYAxis = 18,
  144759. /** RStickXAxis */
  144760. RStickXAxis = 19,
  144761. /** RStickYAxis */
  144762. RStickYAxis = 20
  144763. }
  144764. /**
  144765. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  144766. */
  144767. export enum SwitchInput {
  144768. /** B */
  144769. B = 0,
  144770. /** A */
  144771. A = 1,
  144772. /** Y */
  144773. Y = 2,
  144774. /** X */
  144775. X = 3,
  144776. /** L */
  144777. L = 4,
  144778. /** R */
  144779. R = 5,
  144780. /** ZL */
  144781. ZL = 6,
  144782. /** ZR */
  144783. ZR = 7,
  144784. /** Minus */
  144785. Minus = 8,
  144786. /** Plus */
  144787. Plus = 9,
  144788. /** LS */
  144789. LS = 10,
  144790. /** RS */
  144791. RS = 11,
  144792. /** DPadUp */
  144793. DPadUp = 12,
  144794. /** DPadDown */
  144795. DPadDown = 13,
  144796. /** DPadLeft */
  144797. DPadLeft = 14,
  144798. /** DRight */
  144799. DPadRight = 15,
  144800. /** Home */
  144801. Home = 16,
  144802. /** Capture */
  144803. Capture = 17,
  144804. /** LStickXAxis */
  144805. LStickXAxis = 18,
  144806. /** LStickYAxis */
  144807. LStickYAxis = 19,
  144808. /** RStickXAxis */
  144809. RStickXAxis = 20,
  144810. /** RStickYAxis */
  144811. RStickYAxis = 21
  144812. }
  144813. }
  144814. declare module BABYLON {
  144815. /**
  144816. * This class will take all inputs from Keyboard, Pointer, and
  144817. * any Gamepads and provide a polling system that all devices
  144818. * will use. This class assumes that there will only be one
  144819. * pointer device and one keyboard.
  144820. */
  144821. export class DeviceInputSystem implements IDisposable {
  144822. /**
  144823. * Returns onDeviceConnected callback property
  144824. * @returns Callback with function to execute when a device is connected
  144825. */
  144826. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  144827. /**
  144828. * Sets callback function when a device is connected and executes against all connected devices
  144829. * @param callback Function to execute when a device is connected
  144830. */
  144831. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  144832. /**
  144833. * Callback to be triggered when a device is disconnected
  144834. */
  144835. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  144836. /**
  144837. * Callback to be triggered when event driven input is updated
  144838. */
  144839. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  144840. private _inputs;
  144841. private _gamepads;
  144842. private _keyboardActive;
  144843. private _pointerActive;
  144844. private _elementToAttachTo;
  144845. private _keyboardDownEvent;
  144846. private _keyboardUpEvent;
  144847. private _pointerMoveEvent;
  144848. private _pointerDownEvent;
  144849. private _pointerUpEvent;
  144850. private _gamepadConnectedEvent;
  144851. private _gamepadDisconnectedEvent;
  144852. private _onDeviceConnected;
  144853. private static _MAX_KEYCODES;
  144854. private static _MAX_POINTER_INPUTS;
  144855. private constructor();
  144856. /**
  144857. * Creates a new DeviceInputSystem instance
  144858. * @param engine Engine to pull input element from
  144859. * @returns The new instance
  144860. */
  144861. static Create(engine: Engine): DeviceInputSystem;
  144862. /**
  144863. * Checks for current device input value, given an id and input index
  144864. * @param deviceName Id of connected device
  144865. * @param inputIndex Index of device input
  144866. * @returns Current value of input
  144867. */
  144868. /**
  144869. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  144870. * @param deviceType Enum specifiying device type
  144871. * @param deviceSlot "Slot" or index that device is referenced in
  144872. * @param inputIndex Id of input to be checked
  144873. * @returns Current value of input
  144874. */
  144875. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  144876. /**
  144877. * Dispose of all the eventlisteners
  144878. */
  144879. dispose(): void;
  144880. /**
  144881. * Checks for existing connections to devices and register them, if necessary
  144882. * Currently handles gamepads and mouse
  144883. */
  144884. private _checkForConnectedDevices;
  144885. /**
  144886. * Add a gamepad to the DeviceInputSystem
  144887. * @param gamepad A single DOM Gamepad object
  144888. */
  144889. private _addGamePad;
  144890. /**
  144891. * Add pointer device to DeviceInputSystem
  144892. * @param deviceType Type of Pointer to add
  144893. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  144894. * @param currentX Current X at point of adding
  144895. * @param currentY Current Y at point of adding
  144896. */
  144897. private _addPointerDevice;
  144898. /**
  144899. * Add device and inputs to device array
  144900. * @param deviceType Enum specifiying device type
  144901. * @param deviceSlot "Slot" or index that device is referenced in
  144902. * @param numberOfInputs Number of input entries to create for given device
  144903. */
  144904. private _registerDevice;
  144905. /**
  144906. * Given a specific device name, remove that device from the device map
  144907. * @param deviceType Enum specifiying device type
  144908. * @param deviceSlot "Slot" or index that device is referenced in
  144909. */
  144910. private _unregisterDevice;
  144911. /**
  144912. * Handle all actions that come from keyboard interaction
  144913. */
  144914. private _handleKeyActions;
  144915. /**
  144916. * Handle all actions that come from pointer interaction
  144917. */
  144918. private _handlePointerActions;
  144919. /**
  144920. * Handle all actions that come from gamepad interaction
  144921. */
  144922. private _handleGamepadActions;
  144923. /**
  144924. * Update all non-event based devices with each frame
  144925. * @param deviceType Enum specifiying device type
  144926. * @param deviceSlot "Slot" or index that device is referenced in
  144927. * @param inputIndex Id of input to be checked
  144928. */
  144929. private _updateDevice;
  144930. /**
  144931. * Gets DeviceType from the device name
  144932. * @param deviceName Name of Device from DeviceInputSystem
  144933. * @returns DeviceType enum value
  144934. */
  144935. private _getGamepadDeviceType;
  144936. }
  144937. }
  144938. declare module BABYLON {
  144939. /**
  144940. * Type to handle enforcement of inputs
  144941. */
  144942. 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;
  144943. }
  144944. declare module BABYLON {
  144945. /**
  144946. * Class that handles all input for a specific device
  144947. */
  144948. export class DeviceSource<T extends DeviceType> {
  144949. /** Type of device */
  144950. readonly deviceType: DeviceType;
  144951. /** "Slot" or index that device is referenced in */
  144952. readonly deviceSlot: number;
  144953. /**
  144954. * Observable to handle device input changes per device
  144955. */
  144956. readonly onInputChangedObservable: Observable<{
  144957. inputIndex: DeviceInput<T>;
  144958. previousState: Nullable<number>;
  144959. currentState: Nullable<number>;
  144960. }>;
  144961. private readonly _deviceInputSystem;
  144962. /**
  144963. * Default Constructor
  144964. * @param deviceInputSystem Reference to DeviceInputSystem
  144965. * @param deviceType Type of device
  144966. * @param deviceSlot "Slot" or index that device is referenced in
  144967. */
  144968. constructor(deviceInputSystem: DeviceInputSystem,
  144969. /** Type of device */
  144970. deviceType: DeviceType,
  144971. /** "Slot" or index that device is referenced in */
  144972. deviceSlot?: number);
  144973. /**
  144974. * Get input for specific input
  144975. * @param inputIndex index of specific input on device
  144976. * @returns Input value from DeviceInputSystem
  144977. */
  144978. getInput(inputIndex: DeviceInput<T>): number;
  144979. }
  144980. /**
  144981. * Class to keep track of devices
  144982. */
  144983. export class DeviceSourceManager implements IDisposable {
  144984. /**
  144985. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  144986. */
  144987. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  144988. /**
  144989. * Observable to be triggered when after a device is disconnected
  144990. */
  144991. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  144992. private readonly _devices;
  144993. private readonly _firstDevice;
  144994. private readonly _deviceInputSystem;
  144995. /**
  144996. * Default Constructor
  144997. * @param engine engine to pull input element from
  144998. */
  144999. constructor(engine: Engine);
  145000. /**
  145001. * Gets a DeviceSource, given a type and slot
  145002. * @param deviceType Enum specifying device type
  145003. * @param deviceSlot "Slot" or index that device is referenced in
  145004. * @returns DeviceSource object
  145005. */
  145006. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  145007. /**
  145008. * Gets an array of DeviceSource objects for a given device type
  145009. * @param deviceType Enum specifying device type
  145010. * @returns Array of DeviceSource objects
  145011. */
  145012. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  145013. /**
  145014. * Returns a read-only list of all available devices
  145015. * @returns Read-only array with active devices
  145016. */
  145017. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  145018. /**
  145019. * Dispose of DeviceInputSystem and other parts
  145020. */
  145021. dispose(): void;
  145022. /**
  145023. * Function to add device name to device list
  145024. * @param deviceType Enum specifying device type
  145025. * @param deviceSlot "Slot" or index that device is referenced in
  145026. */
  145027. private _addDevice;
  145028. /**
  145029. * Function to remove device name to device list
  145030. * @param deviceType Enum specifying device type
  145031. * @param deviceSlot "Slot" or index that device is referenced in
  145032. */
  145033. private _removeDevice;
  145034. /**
  145035. * Updates array storing first connected device of each type
  145036. * @param type Type of Device
  145037. */
  145038. private _updateFirstDevices;
  145039. }
  145040. }
  145041. declare module BABYLON {
  145042. /**
  145043. * Options to create the null engine
  145044. */
  145045. export class NullEngineOptions {
  145046. /**
  145047. * Render width (Default: 512)
  145048. */
  145049. renderWidth: number;
  145050. /**
  145051. * Render height (Default: 256)
  145052. */
  145053. renderHeight: number;
  145054. /**
  145055. * Texture size (Default: 512)
  145056. */
  145057. textureSize: number;
  145058. /**
  145059. * If delta time between frames should be constant
  145060. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  145061. */
  145062. deterministicLockstep: boolean;
  145063. /**
  145064. * Maximum about of steps between frames (Default: 4)
  145065. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  145066. */
  145067. lockstepMaxSteps: number;
  145068. /**
  145069. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  145070. */
  145071. useHighPrecisionMatrix?: boolean;
  145072. }
  145073. /**
  145074. * The null engine class provides support for headless version of babylon.js.
  145075. * This can be used in server side scenario or for testing purposes
  145076. */
  145077. export class NullEngine extends Engine {
  145078. private _options;
  145079. /**
  145080. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  145081. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  145082. * @returns true if engine is in deterministic lock step mode
  145083. */
  145084. isDeterministicLockStep(): boolean;
  145085. /**
  145086. * Gets the max steps when engine is running in deterministic lock step
  145087. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  145088. * @returns the max steps
  145089. */
  145090. getLockstepMaxSteps(): number;
  145091. /**
  145092. * Gets the current hardware scaling level.
  145093. * By default the hardware scaling level is computed from the window device ratio.
  145094. * 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.
  145095. * @returns a number indicating the current hardware scaling level
  145096. */
  145097. getHardwareScalingLevel(): number;
  145098. constructor(options?: NullEngineOptions);
  145099. /**
  145100. * Creates a vertex buffer
  145101. * @param vertices the data for the vertex buffer
  145102. * @returns the new WebGL static buffer
  145103. */
  145104. createVertexBuffer(vertices: FloatArray): DataBuffer;
  145105. /**
  145106. * Creates a new index buffer
  145107. * @param indices defines the content of the index buffer
  145108. * @param updatable defines if the index buffer must be updatable
  145109. * @returns a new webGL buffer
  145110. */
  145111. createIndexBuffer(indices: IndicesArray): DataBuffer;
  145112. /**
  145113. * Clear the current render buffer or the current render target (if any is set up)
  145114. * @param color defines the color to use
  145115. * @param backBuffer defines if the back buffer must be cleared
  145116. * @param depth defines if the depth buffer must be cleared
  145117. * @param stencil defines if the stencil buffer must be cleared
  145118. */
  145119. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  145120. /**
  145121. * Gets the current render width
  145122. * @param useScreen defines if screen size must be used (or the current render target if any)
  145123. * @returns a number defining the current render width
  145124. */
  145125. getRenderWidth(useScreen?: boolean): number;
  145126. /**
  145127. * Gets the current render height
  145128. * @param useScreen defines if screen size must be used (or the current render target if any)
  145129. * @returns a number defining the current render height
  145130. */
  145131. getRenderHeight(useScreen?: boolean): number;
  145132. /**
  145133. * Set the WebGL's viewport
  145134. * @param viewport defines the viewport element to be used
  145135. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  145136. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  145137. */
  145138. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  145139. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  145140. /**
  145141. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  145142. * @param pipelineContext defines the pipeline context to use
  145143. * @param uniformsNames defines the list of uniform names
  145144. * @returns an array of webGL uniform locations
  145145. */
  145146. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  145147. /**
  145148. * Gets the lsit of active attributes for a given webGL program
  145149. * @param pipelineContext defines the pipeline context to use
  145150. * @param attributesNames defines the list of attribute names to get
  145151. * @returns an array of indices indicating the offset of each attribute
  145152. */
  145153. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  145154. /**
  145155. * Binds an effect to the webGL context
  145156. * @param effect defines the effect to bind
  145157. */
  145158. bindSamplers(effect: Effect): void;
  145159. /**
  145160. * Activates an effect, making it the current one (ie. the one used for rendering)
  145161. * @param effect defines the effect to activate
  145162. */
  145163. enableEffect(effect: Effect): void;
  145164. /**
  145165. * Set various states to the webGL context
  145166. * @param culling defines backface culling state
  145167. * @param zOffset defines the value to apply to zOffset (0 by default)
  145168. * @param force defines if states must be applied even if cache is up to date
  145169. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  145170. */
  145171. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  145172. /**
  145173. * Set the value of an uniform to an array of int32
  145174. * @param uniform defines the webGL uniform location where to store the value
  145175. * @param array defines the array of int32 to store
  145176. * @returns true if value was set
  145177. */
  145178. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  145179. /**
  145180. * Set the value of an uniform to an array of int32 (stored as vec2)
  145181. * @param uniform defines the webGL uniform location where to store the value
  145182. * @param array defines the array of int32 to store
  145183. * @returns true if value was set
  145184. */
  145185. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  145186. /**
  145187. * Set the value of an uniform to an array of int32 (stored as vec3)
  145188. * @param uniform defines the webGL uniform location where to store the value
  145189. * @param array defines the array of int32 to store
  145190. * @returns true if value was set
  145191. */
  145192. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  145193. /**
  145194. * Set the value of an uniform to an array of int32 (stored as vec4)
  145195. * @param uniform defines the webGL uniform location where to store the value
  145196. * @param array defines the array of int32 to store
  145197. * @returns true if value was set
  145198. */
  145199. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  145200. /**
  145201. * Set the value of an uniform to an array of float32
  145202. * @param uniform defines the webGL uniform location where to store the value
  145203. * @param array defines the array of float32 to store
  145204. * @returns true if value was set
  145205. */
  145206. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  145207. /**
  145208. * Set the value of an uniform to an array of float32 (stored as vec2)
  145209. * @param uniform defines the webGL uniform location where to store the value
  145210. * @param array defines the array of float32 to store
  145211. * @returns true if value was set
  145212. */
  145213. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  145214. /**
  145215. * Set the value of an uniform to an array of float32 (stored as vec3)
  145216. * @param uniform defines the webGL uniform location where to store the value
  145217. * @param array defines the array of float32 to store
  145218. * @returns true if value was set
  145219. */
  145220. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  145221. /**
  145222. * Set the value of an uniform to an array of float32 (stored as vec4)
  145223. * @param uniform defines the webGL uniform location where to store the value
  145224. * @param array defines the array of float32 to store
  145225. * @returns true if value was set
  145226. */
  145227. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  145228. /**
  145229. * Set the value of an uniform to an array of number
  145230. * @param uniform defines the webGL uniform location where to store the value
  145231. * @param array defines the array of number to store
  145232. * @returns true if value was set
  145233. */
  145234. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  145235. /**
  145236. * Set the value of an uniform to an array of number (stored as vec2)
  145237. * @param uniform defines the webGL uniform location where to store the value
  145238. * @param array defines the array of number to store
  145239. * @returns true if value was set
  145240. */
  145241. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  145242. /**
  145243. * Set the value of an uniform to an array of number (stored as vec3)
  145244. * @param uniform defines the webGL uniform location where to store the value
  145245. * @param array defines the array of number to store
  145246. * @returns true if value was set
  145247. */
  145248. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  145249. /**
  145250. * Set the value of an uniform to an array of number (stored as vec4)
  145251. * @param uniform defines the webGL uniform location where to store the value
  145252. * @param array defines the array of number to store
  145253. * @returns true if value was set
  145254. */
  145255. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  145256. /**
  145257. * Set the value of an uniform to an array of float32 (stored as matrices)
  145258. * @param uniform defines the webGL uniform location where to store the value
  145259. * @param matrices defines the array of float32 to store
  145260. * @returns true if value was set
  145261. */
  145262. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  145263. /**
  145264. * Set the value of an uniform to a matrix (3x3)
  145265. * @param uniform defines the webGL uniform location where to store the value
  145266. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  145267. * @returns true if value was set
  145268. */
  145269. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  145270. /**
  145271. * Set the value of an uniform to a matrix (2x2)
  145272. * @param uniform defines the webGL uniform location where to store the value
  145273. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  145274. * @returns true if value was set
  145275. */
  145276. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  145277. /**
  145278. * Set the value of an uniform to a number (float)
  145279. * @param uniform defines the webGL uniform location where to store the value
  145280. * @param value defines the float number to store
  145281. * @returns true if value was set
  145282. */
  145283. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  145284. /**
  145285. * Set the value of an uniform to a vec2
  145286. * @param uniform defines the webGL uniform location where to store the value
  145287. * @param x defines the 1st component of the value
  145288. * @param y defines the 2nd component of the value
  145289. * @returns true if value was set
  145290. */
  145291. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  145292. /**
  145293. * Set the value of an uniform to a vec3
  145294. * @param uniform defines the webGL uniform location where to store the value
  145295. * @param x defines the 1st component of the value
  145296. * @param y defines the 2nd component of the value
  145297. * @param z defines the 3rd component of the value
  145298. * @returns true if value was set
  145299. */
  145300. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  145301. /**
  145302. * Set the value of an uniform to a boolean
  145303. * @param uniform defines the webGL uniform location where to store the value
  145304. * @param bool defines the boolean to store
  145305. * @returns true if value was set
  145306. */
  145307. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  145308. /**
  145309. * Set the value of an uniform to a vec4
  145310. * @param uniform defines the webGL uniform location where to store the value
  145311. * @param x defines the 1st component of the value
  145312. * @param y defines the 2nd component of the value
  145313. * @param z defines the 3rd component of the value
  145314. * @param w defines the 4th component of the value
  145315. * @returns true if value was set
  145316. */
  145317. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  145318. /**
  145319. * Sets the current alpha mode
  145320. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  145321. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  145322. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  145323. */
  145324. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  145325. /**
  145326. * Bind webGl buffers directly to the webGL context
  145327. * @param vertexBuffers defines the vertex buffer to bind
  145328. * @param indexBuffer defines the index buffer to bind
  145329. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  145330. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  145331. * @param effect defines the effect associated with the vertex buffer
  145332. */
  145333. bindBuffers(vertexBuffers: {
  145334. [key: string]: VertexBuffer;
  145335. }, indexBuffer: DataBuffer, effect: Effect): void;
  145336. /**
  145337. * Force the entire cache to be cleared
  145338. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  145339. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  145340. */
  145341. wipeCaches(bruteForce?: boolean): void;
  145342. /**
  145343. * Send a draw order
  145344. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  145345. * @param indexStart defines the starting index
  145346. * @param indexCount defines the number of index to draw
  145347. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  145348. */
  145349. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  145350. /**
  145351. * Draw a list of indexed primitives
  145352. * @param fillMode defines the primitive to use
  145353. * @param indexStart defines the starting index
  145354. * @param indexCount defines the number of index to draw
  145355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  145356. */
  145357. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  145358. /**
  145359. * Draw a list of unindexed primitives
  145360. * @param fillMode defines the primitive to use
  145361. * @param verticesStart defines the index of first vertex to draw
  145362. * @param verticesCount defines the count of vertices to draw
  145363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  145364. */
  145365. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  145366. /** @hidden */
  145367. protected _createTexture(): WebGLTexture;
  145368. /** @hidden */
  145369. _releaseTexture(texture: InternalTexture): void;
  145370. /**
  145371. * Usually called from Texture.ts.
  145372. * Passed information to create a WebGLTexture
  145373. * @param urlArg defines a value which contains one of the following:
  145374. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  145375. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  145376. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  145377. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  145378. * @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)
  145379. * @param scene needed for loading to the correct scene
  145380. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  145381. * @param onLoad optional callback to be called upon successful completion
  145382. * @param onError optional callback to be called upon failure
  145383. * @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
  145384. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  145385. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  145386. * @param forcedExtension defines the extension to use to pick the right loader
  145387. * @param mimeType defines an optional mime type
  145388. * @returns a InternalTexture for assignment back into BABYLON.Texture
  145389. */
  145390. 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;
  145391. /**
  145392. * Creates a new render target texture
  145393. * @param size defines the size of the texture
  145394. * @param options defines the options used to create the texture
  145395. * @returns a new render target texture stored in an InternalTexture
  145396. */
  145397. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  145398. /**
  145399. * Update the sampling mode of a given texture
  145400. * @param samplingMode defines the required sampling mode
  145401. * @param texture defines the texture to update
  145402. */
  145403. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  145404. /**
  145405. * Binds the frame buffer to the specified texture.
  145406. * @param texture The texture to render to or null for the default canvas
  145407. * @param faceIndex The face of the texture to render to in case of cube texture
  145408. * @param requiredWidth The width of the target to render to
  145409. * @param requiredHeight The height of the target to render to
  145410. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  145411. * @param lodLevel defines le lod level to bind to the frame buffer
  145412. */
  145413. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  145414. /**
  145415. * Unbind the current render target texture from the webGL context
  145416. * @param texture defines the render target texture to unbind
  145417. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  145418. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  145419. */
  145420. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  145421. /**
  145422. * Creates a dynamic vertex buffer
  145423. * @param vertices the data for the dynamic vertex buffer
  145424. * @returns the new WebGL dynamic buffer
  145425. */
  145426. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  145427. /**
  145428. * Update the content of a dynamic texture
  145429. * @param texture defines the texture to update
  145430. * @param canvas defines the canvas containing the source
  145431. * @param invertY defines if data must be stored with Y axis inverted
  145432. * @param premulAlpha defines if alpha is stored as premultiplied
  145433. * @param format defines the format of the data
  145434. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  145435. */
  145436. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  145437. /**
  145438. * Gets a boolean indicating if all created effects are ready
  145439. * @returns true if all effects are ready
  145440. */
  145441. areAllEffectsReady(): boolean;
  145442. /**
  145443. * @hidden
  145444. * Get the current error code of the webGL context
  145445. * @returns the error code
  145446. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  145447. */
  145448. getError(): number;
  145449. /** @hidden */
  145450. _getUnpackAlignement(): number;
  145451. /** @hidden */
  145452. _unpackFlipY(value: boolean): void;
  145453. /**
  145454. * Update a dynamic index buffer
  145455. * @param indexBuffer defines the target index buffer
  145456. * @param indices defines the data to update
  145457. * @param offset defines the offset in the target index buffer where update should start
  145458. */
  145459. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  145460. /**
  145461. * Updates a dynamic vertex buffer.
  145462. * @param vertexBuffer the vertex buffer to update
  145463. * @param vertices the data used to update the vertex buffer
  145464. * @param byteOffset the byte offset of the data (optional)
  145465. * @param byteLength the byte length of the data (optional)
  145466. */
  145467. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  145468. /** @hidden */
  145469. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  145470. /** @hidden */
  145471. _bindTexture(channel: number, texture: InternalTexture): void;
  145472. protected _deleteBuffer(buffer: WebGLBuffer): void;
  145473. /**
  145474. * 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
  145475. */
  145476. releaseEffects(): void;
  145477. displayLoadingUI(): void;
  145478. hideLoadingUI(): void;
  145479. /** @hidden */
  145480. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145481. /** @hidden */
  145482. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145483. /** @hidden */
  145484. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  145485. /** @hidden */
  145486. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  145487. }
  145488. }
  145489. declare module BABYLON {
  145490. /** @hidden */
  145491. export class _OcclusionDataStorage {
  145492. /** @hidden */
  145493. occlusionInternalRetryCounter: number;
  145494. /** @hidden */
  145495. isOcclusionQueryInProgress: boolean;
  145496. /** @hidden */
  145497. isOccluded: boolean;
  145498. /** @hidden */
  145499. occlusionRetryCount: number;
  145500. /** @hidden */
  145501. occlusionType: number;
  145502. /** @hidden */
  145503. occlusionQueryAlgorithmType: number;
  145504. }
  145505. interface Engine {
  145506. /**
  145507. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  145508. * @return the new query
  145509. */
  145510. createQuery(): WebGLQuery;
  145511. /**
  145512. * Delete and release a webGL query
  145513. * @param query defines the query to delete
  145514. * @return the current engine
  145515. */
  145516. deleteQuery(query: WebGLQuery): Engine;
  145517. /**
  145518. * Check if a given query has resolved and got its value
  145519. * @param query defines the query to check
  145520. * @returns true if the query got its value
  145521. */
  145522. isQueryResultAvailable(query: WebGLQuery): boolean;
  145523. /**
  145524. * Gets the value of a given query
  145525. * @param query defines the query to check
  145526. * @returns the value of the query
  145527. */
  145528. getQueryResult(query: WebGLQuery): number;
  145529. /**
  145530. * Initiates an occlusion query
  145531. * @param algorithmType defines the algorithm to use
  145532. * @param query defines the query to use
  145533. * @returns the current engine
  145534. * @see https://doc.babylonjs.com/features/occlusionquery
  145535. */
  145536. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  145537. /**
  145538. * Ends an occlusion query
  145539. * @see https://doc.babylonjs.com/features/occlusionquery
  145540. * @param algorithmType defines the algorithm to use
  145541. * @returns the current engine
  145542. */
  145543. endOcclusionQuery(algorithmType: number): Engine;
  145544. /**
  145545. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  145546. * Please note that only one query can be issued at a time
  145547. * @returns a time token used to track the time span
  145548. */
  145549. startTimeQuery(): Nullable<_TimeToken>;
  145550. /**
  145551. * Ends a time query
  145552. * @param token defines the token used to measure the time span
  145553. * @returns the time spent (in ns)
  145554. */
  145555. endTimeQuery(token: _TimeToken): int;
  145556. /** @hidden */
  145557. _currentNonTimestampToken: Nullable<_TimeToken>;
  145558. /** @hidden */
  145559. _createTimeQuery(): WebGLQuery;
  145560. /** @hidden */
  145561. _deleteTimeQuery(query: WebGLQuery): void;
  145562. /** @hidden */
  145563. _getGlAlgorithmType(algorithmType: number): number;
  145564. /** @hidden */
  145565. _getTimeQueryResult(query: WebGLQuery): any;
  145566. /** @hidden */
  145567. _getTimeQueryAvailability(query: WebGLQuery): any;
  145568. }
  145569. interface AbstractMesh {
  145570. /**
  145571. * Backing filed
  145572. * @hidden
  145573. */
  145574. __occlusionDataStorage: _OcclusionDataStorage;
  145575. /**
  145576. * Access property
  145577. * @hidden
  145578. */
  145579. _occlusionDataStorage: _OcclusionDataStorage;
  145580. /**
  145581. * 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 decides to show or hide the object.
  145582. * The default value is -1 which means don't break the query and wait till the result
  145583. * @see https://doc.babylonjs.com/features/occlusionquery
  145584. */
  145585. occlusionRetryCount: number;
  145586. /**
  145587. * 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:
  145588. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  145589. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  145590. * * 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.
  145591. * @see https://doc.babylonjs.com/features/occlusionquery
  145592. */
  145593. occlusionType: number;
  145594. /**
  145595. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  145596. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  145597. * * 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.
  145598. * @see https://doc.babylonjs.com/features/occlusionquery
  145599. */
  145600. occlusionQueryAlgorithmType: number;
  145601. /**
  145602. * Gets or sets whether the mesh is occluded or not, it is used also to set the initial state of the mesh to be occluded or not
  145603. * @see https://doc.babylonjs.com/features/occlusionquery
  145604. */
  145605. isOccluded: boolean;
  145606. /**
  145607. * Flag to check the progress status of the query
  145608. * @see https://doc.babylonjs.com/features/occlusionquery
  145609. */
  145610. isOcclusionQueryInProgress: boolean;
  145611. }
  145612. }
  145613. declare module BABYLON {
  145614. /** @hidden */
  145615. export var _forceTransformFeedbackToBundle: boolean;
  145616. interface Engine {
  145617. /**
  145618. * Creates a webGL transform feedback object
  145619. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  145620. * @returns the webGL transform feedback object
  145621. */
  145622. createTransformFeedback(): WebGLTransformFeedback;
  145623. /**
  145624. * Delete a webGL transform feedback object
  145625. * @param value defines the webGL transform feedback object to delete
  145626. */
  145627. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  145628. /**
  145629. * Bind a webGL transform feedback object to the webgl context
  145630. * @param value defines the webGL transform feedback object to bind
  145631. */
  145632. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  145633. /**
  145634. * Begins a transform feedback operation
  145635. * @param usePoints defines if points or triangles must be used
  145636. */
  145637. beginTransformFeedback(usePoints: boolean): void;
  145638. /**
  145639. * Ends a transform feedback operation
  145640. */
  145641. endTransformFeedback(): void;
  145642. /**
  145643. * Specify the varyings to use with transform feedback
  145644. * @param program defines the associated webGL program
  145645. * @param value defines the list of strings representing the varying names
  145646. */
  145647. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  145648. /**
  145649. * Bind a webGL buffer for a transform feedback operation
  145650. * @param value defines the webGL buffer to bind
  145651. */
  145652. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  145653. }
  145654. }
  145655. declare module BABYLON {
  145656. /**
  145657. * Class used to define an additional view for the engine
  145658. * @see https://doc.babylonjs.com/how_to/multi_canvases
  145659. */
  145660. export class EngineView {
  145661. /** Defines the canvas where to render the view */
  145662. target: HTMLCanvasElement;
  145663. /** Defines an optional camera used to render the view (will use active camera else) */
  145664. camera?: Camera;
  145665. }
  145666. interface Engine {
  145667. /**
  145668. * Gets or sets the HTML element to use for attaching events
  145669. */
  145670. inputElement: Nullable<HTMLElement>;
  145671. /**
  145672. * Gets the current engine view
  145673. * @see https://doc.babylonjs.com/how_to/multi_canvases
  145674. */
  145675. activeView: Nullable<EngineView>;
  145676. /** Gets or sets the list of views */
  145677. views: EngineView[];
  145678. /**
  145679. * Register a new child canvas
  145680. * @param canvas defines the canvas to register
  145681. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  145682. * @returns the associated view
  145683. */
  145684. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  145685. /**
  145686. * Remove a registered child canvas
  145687. * @param canvas defines the canvas to remove
  145688. * @returns the current engine
  145689. */
  145690. unRegisterView(canvas: HTMLCanvasElement): Engine;
  145691. }
  145692. }
  145693. declare module BABYLON {
  145694. interface Engine {
  145695. /** @hidden */
  145696. _excludedCompressedTextures: string[];
  145697. /** @hidden */
  145698. _textureFormatInUse: string;
  145699. /**
  145700. * Gets the list of texture formats supported
  145701. */
  145702. readonly texturesSupported: Array<string>;
  145703. /**
  145704. * Gets the texture format in use
  145705. */
  145706. readonly textureFormatInUse: Nullable<string>;
  145707. /**
  145708. * Set the compressed texture extensions or file names to skip.
  145709. *
  145710. * @param skippedFiles defines the list of those texture files you want to skip
  145711. * Example: [".dds", ".env", "myfile.png"]
  145712. */
  145713. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  145714. /**
  145715. * Set the compressed texture format to use, based on the formats you have, and the formats
  145716. * supported by the hardware / browser.
  145717. *
  145718. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  145719. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  145720. * to API arguments needed to compressed textures. This puts the burden on the container
  145721. * generator to house the arcane code for determining these for current & future formats.
  145722. *
  145723. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  145724. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  145725. *
  145726. * Note: The result of this call is not taken into account when a texture is base64.
  145727. *
  145728. * @param formatsAvailable defines the list of those format families you have created
  145729. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  145730. *
  145731. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  145732. * @returns The extension selected.
  145733. */
  145734. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  145735. }
  145736. }
  145737. declare module BABYLON {
  145738. /** @hidden */
  145739. export var rgbdEncodePixelShader: {
  145740. name: string;
  145741. shader: string;
  145742. };
  145743. }
  145744. declare module BABYLON {
  145745. /**
  145746. * Raw texture data and descriptor sufficient for WebGL texture upload
  145747. */
  145748. export interface EnvironmentTextureInfo {
  145749. /**
  145750. * Version of the environment map
  145751. */
  145752. version: number;
  145753. /**
  145754. * Width of image
  145755. */
  145756. width: number;
  145757. /**
  145758. * Irradiance information stored in the file.
  145759. */
  145760. irradiance: any;
  145761. /**
  145762. * Specular information stored in the file.
  145763. */
  145764. specular: any;
  145765. }
  145766. /**
  145767. * Defines One Image in the file. It requires only the position in the file
  145768. * as well as the length.
  145769. */
  145770. interface BufferImageData {
  145771. /**
  145772. * Length of the image data.
  145773. */
  145774. length: number;
  145775. /**
  145776. * Position of the data from the null terminator delimiting the end of the JSON.
  145777. */
  145778. position: number;
  145779. }
  145780. /**
  145781. * Defines the specular data enclosed in the file.
  145782. * This corresponds to the version 1 of the data.
  145783. */
  145784. export interface EnvironmentTextureSpecularInfoV1 {
  145785. /**
  145786. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  145787. */
  145788. specularDataPosition?: number;
  145789. /**
  145790. * This contains all the images data needed to reconstruct the cubemap.
  145791. */
  145792. mipmaps: Array<BufferImageData>;
  145793. /**
  145794. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  145795. */
  145796. lodGenerationScale: number;
  145797. }
  145798. /**
  145799. * Sets of helpers addressing the serialization and deserialization of environment texture
  145800. * stored in a BabylonJS env file.
  145801. * Those files are usually stored as .env files.
  145802. */
  145803. export class EnvironmentTextureTools {
  145804. /**
  145805. * Magic number identifying the env file.
  145806. */
  145807. private static _MagicBytes;
  145808. /**
  145809. * Gets the environment info from an env file.
  145810. * @param data The array buffer containing the .env bytes.
  145811. * @returns the environment file info (the json header) if successfully parsed.
  145812. */
  145813. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  145814. /**
  145815. * Creates an environment texture from a loaded cube texture.
  145816. * @param texture defines the cube texture to convert in env file
  145817. * @return a promise containing the environment data if successful.
  145818. */
  145819. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  145820. /**
  145821. * Creates a JSON representation of the spherical data.
  145822. * @param texture defines the texture containing the polynomials
  145823. * @return the JSON representation of the spherical info
  145824. */
  145825. private static _CreateEnvTextureIrradiance;
  145826. /**
  145827. * Creates the ArrayBufferViews used for initializing environment texture image data.
  145828. * @param data the image data
  145829. * @param info parameters that determine what views will be created for accessing the underlying buffer
  145830. * @return the views described by info providing access to the underlying buffer
  145831. */
  145832. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  145833. /**
  145834. * Uploads the texture info contained in the env file to the GPU.
  145835. * @param texture defines the internal texture to upload to
  145836. * @param data defines the data to load
  145837. * @param info defines the texture info retrieved through the GetEnvInfo method
  145838. * @returns a promise
  145839. */
  145840. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  145841. private static _OnImageReadyAsync;
  145842. /**
  145843. * Uploads the levels of image data to the GPU.
  145844. * @param texture defines the internal texture to upload to
  145845. * @param imageData defines the array buffer views of image data [mipmap][face]
  145846. * @returns a promise
  145847. */
  145848. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  145849. /**
  145850. * Uploads spherical polynomials information to the texture.
  145851. * @param texture defines the texture we are trying to upload the information to
  145852. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  145853. */
  145854. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  145855. /** @hidden */
  145856. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  145857. }
  145858. }
  145859. declare module BABYLON {
  145860. /**
  145861. * Container for accessors for natively-stored mesh data buffers.
  145862. */
  145863. class NativeDataBuffer extends DataBuffer {
  145864. /**
  145865. * Accessor value used to identify/retrieve a natively-stored index buffer.
  145866. */
  145867. nativeIndexBuffer?: any;
  145868. /**
  145869. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  145870. */
  145871. nativeVertexBuffer?: any;
  145872. }
  145873. /** @hidden */
  145874. class NativeTexture extends InternalTexture {
  145875. getInternalTexture(): InternalTexture;
  145876. getViewCount(): number;
  145877. }
  145878. /** @hidden */
  145879. export class NativeEngine extends Engine {
  145880. private readonly _native;
  145881. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  145882. private readonly INVALID_HANDLE;
  145883. private _boundBuffersVertexArray;
  145884. private _currentDepthTest;
  145885. getHardwareScalingLevel(): number;
  145886. constructor();
  145887. dispose(): void;
  145888. /**
  145889. * Can be used to override the current requestAnimationFrame requester.
  145890. * @hidden
  145891. */
  145892. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  145893. /**
  145894. * Override default engine behavior.
  145895. * @param color
  145896. * @param backBuffer
  145897. * @param depth
  145898. * @param stencil
  145899. */
  145900. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  145901. /**
  145902. * Gets host document
  145903. * @returns the host document object
  145904. */
  145905. getHostDocument(): Nullable<Document>;
  145906. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  145907. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  145908. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  145909. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  145910. [key: string]: VertexBuffer;
  145911. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  145912. bindBuffers(vertexBuffers: {
  145913. [key: string]: VertexBuffer;
  145914. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  145915. recordVertexArrayObject(vertexBuffers: {
  145916. [key: string]: VertexBuffer;
  145917. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  145918. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  145919. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  145920. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  145921. /**
  145922. * Draw a list of indexed primitives
  145923. * @param fillMode defines the primitive to use
  145924. * @param indexStart defines the starting index
  145925. * @param indexCount defines the number of index to draw
  145926. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  145927. */
  145928. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  145929. /**
  145930. * Draw a list of unindexed primitives
  145931. * @param fillMode defines the primitive to use
  145932. * @param verticesStart defines the index of first vertex to draw
  145933. * @param verticesCount defines the count of vertices to draw
  145934. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  145935. */
  145936. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  145937. createPipelineContext(): IPipelineContext;
  145938. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  145939. /** @hidden */
  145940. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  145941. /** @hidden */
  145942. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  145943. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  145944. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  145945. protected _setProgram(program: WebGLProgram): void;
  145946. _releaseEffect(effect: Effect): void;
  145947. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  145948. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  145949. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  145950. bindSamplers(effect: Effect): void;
  145951. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  145952. getRenderWidth(useScreen?: boolean): number;
  145953. getRenderHeight(useScreen?: boolean): number;
  145954. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  145955. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  145956. /**
  145957. * Set the z offset to apply to current rendering
  145958. * @param value defines the offset to apply
  145959. */
  145960. setZOffset(value: number): void;
  145961. /**
  145962. * Gets the current value of the zOffset
  145963. * @returns the current zOffset state
  145964. */
  145965. getZOffset(): number;
  145966. /**
  145967. * Enable or disable depth buffering
  145968. * @param enable defines the state to set
  145969. */
  145970. setDepthBuffer(enable: boolean): void;
  145971. /**
  145972. * Gets a boolean indicating if depth writing is enabled
  145973. * @returns the current depth writing state
  145974. */
  145975. getDepthWrite(): boolean;
  145976. setDepthFunctionToGreater(): void;
  145977. setDepthFunctionToGreaterOrEqual(): void;
  145978. setDepthFunctionToLess(): void;
  145979. setDepthFunctionToLessOrEqual(): void;
  145980. /**
  145981. * Enable or disable depth writing
  145982. * @param enable defines the state to set
  145983. */
  145984. setDepthWrite(enable: boolean): void;
  145985. /**
  145986. * Enable or disable color writing
  145987. * @param enable defines the state to set
  145988. */
  145989. setColorWrite(enable: boolean): void;
  145990. /**
  145991. * Gets a boolean indicating if color writing is enabled
  145992. * @returns the current color writing state
  145993. */
  145994. getColorWrite(): boolean;
  145995. /**
  145996. * Sets alpha constants used by some alpha blending modes
  145997. * @param r defines the red component
  145998. * @param g defines the green component
  145999. * @param b defines the blue component
  146000. * @param a defines the alpha component
  146001. */
  146002. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  146003. /**
  146004. * Sets the current alpha mode
  146005. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  146006. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  146007. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  146008. */
  146009. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  146010. /**
  146011. * Gets the current alpha mode
  146012. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  146013. * @returns the current alpha mode
  146014. */
  146015. getAlphaMode(): number;
  146016. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  146017. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  146018. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  146019. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  146020. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  146021. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  146022. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  146023. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  146024. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  146025. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  146026. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  146027. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  146028. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  146029. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  146030. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  146031. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  146032. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  146033. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  146034. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  146035. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  146036. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  146037. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  146038. wipeCaches(bruteForce?: boolean): void;
  146039. protected _createTexture(): WebGLTexture;
  146040. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  146041. /**
  146042. * Update the content of a dynamic texture
  146043. * @param texture defines the texture to update
  146044. * @param canvas defines the canvas containing the source
  146045. * @param invertY defines if data must be stored with Y axis inverted
  146046. * @param premulAlpha defines if alpha is stored as premultiplied
  146047. * @param format defines the format of the data
  146048. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  146049. */
  146050. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  146051. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  146052. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  146053. /**
  146054. * Usually called from Texture.ts.
  146055. * Passed information to create a WebGLTexture
  146056. * @param url defines a value which contains one of the following:
  146057. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  146058. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  146059. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  146060. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  146061. * @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)
  146062. * @param scene needed for loading to the correct scene
  146063. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  146064. * @param onLoad optional callback to be called upon successful completion
  146065. * @param onError optional callback to be called upon failure
  146066. * @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
  146067. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  146068. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  146069. * @param forcedExtension defines the extension to use to pick the right loader
  146070. * @param mimeType defines an optional mime type
  146071. * @param loaderOptions options to be passed to the loader
  146072. * @returns a InternalTexture for assignment back into BABYLON.Texture
  146073. */
  146074. 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;
  146075. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  146076. _releaseFramebufferObjects(texture: InternalTexture): void;
  146077. /**
  146078. * Creates a cube texture
  146079. * @param rootUrl defines the url where the files to load is located
  146080. * @param scene defines the current scene
  146081. * @param files defines the list of files to load (1 per face)
  146082. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  146083. * @param onLoad defines an optional callback raised when the texture is loaded
  146084. * @param onError defines an optional callback raised if there is an issue to load the texture
  146085. * @param format defines the format of the data
  146086. * @param forcedExtension defines the extension to use to pick the right loader
  146087. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  146088. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  146089. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  146090. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  146091. * @returns the cube texture as an InternalTexture
  146092. */
  146093. 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;
  146094. createRenderTargetTexture(size: number | {
  146095. width: number;
  146096. height: number;
  146097. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  146098. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  146099. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  146100. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  146101. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  146102. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  146103. /**
  146104. * Updates a dynamic vertex buffer.
  146105. * @param vertexBuffer the vertex buffer to update
  146106. * @param data the data used to update the vertex buffer
  146107. * @param byteOffset the byte offset of the data (optional)
  146108. * @param byteLength the byte length of the data (optional)
  146109. */
  146110. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  146111. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  146112. private _updateAnisotropicLevel;
  146113. private _getAddressMode;
  146114. /** @hidden */
  146115. _bindTexture(channel: number, texture: InternalTexture): void;
  146116. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  146117. releaseEffects(): void;
  146118. /** @hidden */
  146119. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  146120. /** @hidden */
  146121. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  146122. /** @hidden */
  146123. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  146124. /** @hidden */
  146125. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  146126. private _getNativeSamplingMode;
  146127. private _getNativeTextureFormat;
  146128. private _getNativeAlphaMode;
  146129. private _getNativeAttribType;
  146130. }
  146131. }
  146132. declare module BABYLON {
  146133. /**
  146134. * Helper class to create the best engine depending on the current hardware
  146135. */
  146136. export class EngineFactory {
  146137. /**
  146138. * Creates an engine based on the capabilities of the underlying hardware
  146139. * @param canvas Defines the canvas to use to display the result
  146140. * @param options Defines the options passed to the engine to create the context dependencies
  146141. * @returns a promise that resolves with the created engine
  146142. */
  146143. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  146144. }
  146145. }
  146146. declare module BABYLON {
  146147. /**
  146148. * Gather the list of clipboard event types as constants.
  146149. */
  146150. export class ClipboardEventTypes {
  146151. /**
  146152. * The clipboard event is fired when a copy command is active (pressed).
  146153. */
  146154. static readonly COPY: number;
  146155. /**
  146156. * The clipboard event is fired when a cut command is active (pressed).
  146157. */
  146158. static readonly CUT: number;
  146159. /**
  146160. * The clipboard event is fired when a paste command is active (pressed).
  146161. */
  146162. static readonly PASTE: number;
  146163. }
  146164. /**
  146165. * This class is used to store clipboard related info for the onClipboardObservable event.
  146166. */
  146167. export class ClipboardInfo {
  146168. /**
  146169. * Defines the type of event (BABYLON.ClipboardEventTypes)
  146170. */
  146171. type: number;
  146172. /**
  146173. * Defines the related dom event
  146174. */
  146175. event: ClipboardEvent;
  146176. /**
  146177. *Creates an instance of ClipboardInfo.
  146178. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  146179. * @param event Defines the related dom event
  146180. */
  146181. constructor(
  146182. /**
  146183. * Defines the type of event (BABYLON.ClipboardEventTypes)
  146184. */
  146185. type: number,
  146186. /**
  146187. * Defines the related dom event
  146188. */
  146189. event: ClipboardEvent);
  146190. /**
  146191. * Get the clipboard event's type from the keycode.
  146192. * @param keyCode Defines the keyCode for the current keyboard event.
  146193. * @return {number}
  146194. */
  146195. static GetTypeFromCharacter(keyCode: number): number;
  146196. }
  146197. }
  146198. declare module BABYLON {
  146199. /**
  146200. * Google Daydream controller
  146201. */
  146202. export class DaydreamController extends WebVRController {
  146203. /**
  146204. * Base Url for the controller model.
  146205. */
  146206. static MODEL_BASE_URL: string;
  146207. /**
  146208. * File name for the controller model.
  146209. */
  146210. static MODEL_FILENAME: string;
  146211. /**
  146212. * Gamepad Id prefix used to identify Daydream Controller.
  146213. */
  146214. static readonly GAMEPAD_ID_PREFIX: string;
  146215. /**
  146216. * Creates a new DaydreamController from a gamepad
  146217. * @param vrGamepad the gamepad that the controller should be created from
  146218. */
  146219. constructor(vrGamepad: any);
  146220. /**
  146221. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  146222. * @param scene scene in which to add meshes
  146223. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  146224. */
  146225. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  146226. /**
  146227. * Called once for each button that changed state since the last frame
  146228. * @param buttonIdx Which button index changed
  146229. * @param state New state of the button
  146230. * @param changes Which properties on the state changed since last frame
  146231. */
  146232. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  146233. }
  146234. }
  146235. declare module BABYLON {
  146236. /**
  146237. * Gear VR Controller
  146238. */
  146239. export class GearVRController extends WebVRController {
  146240. /**
  146241. * Base Url for the controller model.
  146242. */
  146243. static MODEL_BASE_URL: string;
  146244. /**
  146245. * File name for the controller model.
  146246. */
  146247. static MODEL_FILENAME: string;
  146248. /**
  146249. * Gamepad Id prefix used to identify this controller.
  146250. */
  146251. static readonly GAMEPAD_ID_PREFIX: string;
  146252. private readonly _buttonIndexToObservableNameMap;
  146253. /**
  146254. * Creates a new GearVRController from a gamepad
  146255. * @param vrGamepad the gamepad that the controller should be created from
  146256. */
  146257. constructor(vrGamepad: any);
  146258. /**
  146259. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  146260. * @param scene scene in which to add meshes
  146261. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  146262. */
  146263. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  146264. /**
  146265. * Called once for each button that changed state since the last frame
  146266. * @param buttonIdx Which button index changed
  146267. * @param state New state of the button
  146268. * @param changes Which properties on the state changed since last frame
  146269. */
  146270. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  146271. }
  146272. }
  146273. declare module BABYLON {
  146274. /**
  146275. * Generic Controller
  146276. */
  146277. export class GenericController extends WebVRController {
  146278. /**
  146279. * Base Url for the controller model.
  146280. */
  146281. static readonly MODEL_BASE_URL: string;
  146282. /**
  146283. * File name for the controller model.
  146284. */
  146285. static readonly MODEL_FILENAME: string;
  146286. /**
  146287. * Creates a new GenericController from a gamepad
  146288. * @param vrGamepad the gamepad that the controller should be created from
  146289. */
  146290. constructor(vrGamepad: any);
  146291. /**
  146292. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  146293. * @param scene scene in which to add meshes
  146294. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  146295. */
  146296. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  146297. /**
  146298. * Called once for each button that changed state since the last frame
  146299. * @param buttonIdx Which button index changed
  146300. * @param state New state of the button
  146301. * @param changes Which properties on the state changed since last frame
  146302. */
  146303. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  146304. }
  146305. }
  146306. declare module BABYLON {
  146307. /**
  146308. * Oculus Touch Controller
  146309. */
  146310. export class OculusTouchController extends WebVRController {
  146311. /**
  146312. * Base Url for the controller model.
  146313. */
  146314. static MODEL_BASE_URL: string;
  146315. /**
  146316. * File name for the left controller model.
  146317. */
  146318. static MODEL_LEFT_FILENAME: string;
  146319. /**
  146320. * File name for the right controller model.
  146321. */
  146322. static MODEL_RIGHT_FILENAME: string;
  146323. /**
  146324. * Base Url for the Quest controller model.
  146325. */
  146326. static QUEST_MODEL_BASE_URL: string;
  146327. /**
  146328. * @hidden
  146329. * If the controllers are running on a device that needs the updated Quest controller models
  146330. */
  146331. static _IsQuest: boolean;
  146332. /**
  146333. * Fired when the secondary trigger on this controller is modified
  146334. */
  146335. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  146336. /**
  146337. * Fired when the thumb rest on this controller is modified
  146338. */
  146339. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  146340. /**
  146341. * Creates a new OculusTouchController from a gamepad
  146342. * @param vrGamepad the gamepad that the controller should be created from
  146343. */
  146344. constructor(vrGamepad: any);
  146345. /**
  146346. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  146347. * @param scene scene in which to add meshes
  146348. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  146349. */
  146350. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  146351. /**
  146352. * Fired when the A button on this controller is modified
  146353. */
  146354. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146355. /**
  146356. * Fired when the B button on this controller is modified
  146357. */
  146358. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146359. /**
  146360. * Fired when the X button on this controller is modified
  146361. */
  146362. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146363. /**
  146364. * Fired when the Y button on this controller is modified
  146365. */
  146366. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146367. /**
  146368. * Called once for each button that changed state since the last frame
  146369. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  146370. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  146371. * 2) secondary trigger (same)
  146372. * 3) A (right) X (left), touch, pressed = value
  146373. * 4) B / Y
  146374. * 5) thumb rest
  146375. * @param buttonIdx Which button index changed
  146376. * @param state New state of the button
  146377. * @param changes Which properties on the state changed since last frame
  146378. */
  146379. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  146380. }
  146381. }
  146382. declare module BABYLON {
  146383. /**
  146384. * Vive Controller
  146385. */
  146386. export class ViveController extends WebVRController {
  146387. /**
  146388. * Base Url for the controller model.
  146389. */
  146390. static MODEL_BASE_URL: string;
  146391. /**
  146392. * File name for the controller model.
  146393. */
  146394. static MODEL_FILENAME: string;
  146395. /**
  146396. * Creates a new ViveController from a gamepad
  146397. * @param vrGamepad the gamepad that the controller should be created from
  146398. */
  146399. constructor(vrGamepad: any);
  146400. /**
  146401. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  146402. * @param scene scene in which to add meshes
  146403. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  146404. */
  146405. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  146406. /**
  146407. * Fired when the left button on this controller is modified
  146408. */
  146409. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146410. /**
  146411. * Fired when the right button on this controller is modified
  146412. */
  146413. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146414. /**
  146415. * Fired when the menu button on this controller is modified
  146416. */
  146417. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146418. /**
  146419. * Called once for each button that changed state since the last frame
  146420. * Vive mapping:
  146421. * 0: touchpad
  146422. * 1: trigger
  146423. * 2: left AND right buttons
  146424. * 3: menu button
  146425. * @param buttonIdx Which button index changed
  146426. * @param state New state of the button
  146427. * @param changes Which properties on the state changed since last frame
  146428. */
  146429. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  146430. }
  146431. }
  146432. declare module BABYLON {
  146433. /**
  146434. * Defines the WindowsMotionController object that the state of the windows motion controller
  146435. */
  146436. export class WindowsMotionController extends WebVRController {
  146437. /**
  146438. * The base url used to load the left and right controller models
  146439. */
  146440. static MODEL_BASE_URL: string;
  146441. /**
  146442. * The name of the left controller model file
  146443. */
  146444. static MODEL_LEFT_FILENAME: string;
  146445. /**
  146446. * The name of the right controller model file
  146447. */
  146448. static MODEL_RIGHT_FILENAME: string;
  146449. /**
  146450. * The controller name prefix for this controller type
  146451. */
  146452. static readonly GAMEPAD_ID_PREFIX: string;
  146453. /**
  146454. * The controller id pattern for this controller type
  146455. */
  146456. private static readonly GAMEPAD_ID_PATTERN;
  146457. private _loadedMeshInfo;
  146458. protected readonly _mapping: {
  146459. buttons: string[];
  146460. buttonMeshNames: {
  146461. trigger: string;
  146462. menu: string;
  146463. grip: string;
  146464. thumbstick: string;
  146465. trackpad: string;
  146466. };
  146467. buttonObservableNames: {
  146468. trigger: string;
  146469. menu: string;
  146470. grip: string;
  146471. thumbstick: string;
  146472. trackpad: string;
  146473. };
  146474. axisMeshNames: string[];
  146475. pointingPoseMeshName: string;
  146476. };
  146477. /**
  146478. * Fired when the trackpad on this controller is clicked
  146479. */
  146480. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  146481. /**
  146482. * Fired when the trackpad on this controller is modified
  146483. */
  146484. onTrackpadValuesChangedObservable: Observable<StickValues>;
  146485. /**
  146486. * The current x and y values of this controller's trackpad
  146487. */
  146488. trackpad: StickValues;
  146489. /**
  146490. * Creates a new WindowsMotionController from a gamepad
  146491. * @param vrGamepad the gamepad that the controller should be created from
  146492. */
  146493. constructor(vrGamepad: any);
  146494. /**
  146495. * Fired when the trigger on this controller is modified
  146496. */
  146497. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146498. /**
  146499. * Fired when the menu button on this controller is modified
  146500. */
  146501. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146502. /**
  146503. * Fired when the grip button on this controller is modified
  146504. */
  146505. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146506. /**
  146507. * Fired when the thumbstick button on this controller is modified
  146508. */
  146509. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146510. /**
  146511. * Fired when the touchpad button on this controller is modified
  146512. */
  146513. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146514. /**
  146515. * Fired when the touchpad values on this controller are modified
  146516. */
  146517. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  146518. protected _updateTrackpad(): void;
  146519. /**
  146520. * Called once per frame by the engine.
  146521. */
  146522. update(): void;
  146523. /**
  146524. * Called once for each button that changed state since the last frame
  146525. * @param buttonIdx Which button index changed
  146526. * @param state New state of the button
  146527. * @param changes Which properties on the state changed since last frame
  146528. */
  146529. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  146530. /**
  146531. * Moves the buttons on the controller mesh based on their current state
  146532. * @param buttonName the name of the button to move
  146533. * @param buttonValue the value of the button which determines the buttons new position
  146534. */
  146535. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  146536. /**
  146537. * Moves the axis on the controller mesh based on its current state
  146538. * @param axis the index of the axis
  146539. * @param axisValue the value of the axis which determines the meshes new position
  146540. * @hidden
  146541. */
  146542. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  146543. /**
  146544. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  146545. * @param scene scene in which to add meshes
  146546. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  146547. */
  146548. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  146549. /**
  146550. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  146551. * can be transformed by button presses and axes values, based on this._mapping.
  146552. *
  146553. * @param scene scene in which the meshes exist
  146554. * @param meshes list of meshes that make up the controller model to process
  146555. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  146556. */
  146557. private processModel;
  146558. private createMeshInfo;
  146559. /**
  146560. * Gets the ray of the controller in the direction the controller is pointing
  146561. * @param length the length the resulting ray should be
  146562. * @returns a ray in the direction the controller is pointing
  146563. */
  146564. getForwardRay(length?: number): Ray;
  146565. /**
  146566. * Disposes of the controller
  146567. */
  146568. dispose(): void;
  146569. }
  146570. /**
  146571. * This class represents a new windows motion controller in XR.
  146572. */
  146573. export class XRWindowsMotionController extends WindowsMotionController {
  146574. /**
  146575. * Changing the original WIndowsMotionController mapping to fir the new mapping
  146576. */
  146577. protected readonly _mapping: {
  146578. buttons: string[];
  146579. buttonMeshNames: {
  146580. trigger: string;
  146581. menu: string;
  146582. grip: string;
  146583. thumbstick: string;
  146584. trackpad: string;
  146585. };
  146586. buttonObservableNames: {
  146587. trigger: string;
  146588. menu: string;
  146589. grip: string;
  146590. thumbstick: string;
  146591. trackpad: string;
  146592. };
  146593. axisMeshNames: string[];
  146594. pointingPoseMeshName: string;
  146595. };
  146596. /**
  146597. * Construct a new XR-Based windows motion controller
  146598. *
  146599. * @param gamepadInfo the gamepad object from the browser
  146600. */
  146601. constructor(gamepadInfo: any);
  146602. /**
  146603. * holds the thumbstick values (X,Y)
  146604. */
  146605. thumbstickValues: StickValues;
  146606. /**
  146607. * Fired when the thumbstick on this controller is clicked
  146608. */
  146609. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  146610. /**
  146611. * Fired when the thumbstick on this controller is modified
  146612. */
  146613. onThumbstickValuesChangedObservable: Observable<StickValues>;
  146614. /**
  146615. * Fired when the touchpad button on this controller is modified
  146616. */
  146617. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  146618. /**
  146619. * Fired when the touchpad values on this controller are modified
  146620. */
  146621. onTrackpadValuesChangedObservable: Observable<StickValues>;
  146622. /**
  146623. * Fired when the thumbstick button on this controller is modified
  146624. * here to prevent breaking changes
  146625. */
  146626. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  146627. /**
  146628. * updating the thumbstick(!) and not the trackpad.
  146629. * This is named this way due to the difference between WebVR and XR and to avoid
  146630. * changing the parent class.
  146631. */
  146632. protected _updateTrackpad(): void;
  146633. /**
  146634. * Disposes the class with joy
  146635. */
  146636. dispose(): void;
  146637. }
  146638. }
  146639. declare module BABYLON {
  146640. /**
  146641. * A directional light is defined by a direction (what a surprise!).
  146642. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  146643. * 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.
  146644. * Documentation: https://doc.babylonjs.com/babylon101/lights
  146645. */
  146646. export class DirectionalLight extends ShadowLight {
  146647. private _shadowFrustumSize;
  146648. /**
  146649. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  146650. */
  146651. get shadowFrustumSize(): number;
  146652. /**
  146653. * Specifies a fix frustum size for the shadow generation.
  146654. */
  146655. set shadowFrustumSize(value: number);
  146656. private _shadowOrthoScale;
  146657. /**
  146658. * Gets the shadow projection scale against the optimal computed one.
  146659. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  146660. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  146661. */
  146662. get shadowOrthoScale(): number;
  146663. /**
  146664. * Sets the shadow projection scale against the optimal computed one.
  146665. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  146666. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  146667. */
  146668. set shadowOrthoScale(value: number);
  146669. /**
  146670. * Automatically compute the projection matrix to best fit (including all the casters)
  146671. * on each frame.
  146672. */
  146673. autoUpdateExtends: boolean;
  146674. /**
  146675. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  146676. * on each frame. autoUpdateExtends must be set to true for this to work
  146677. */
  146678. autoCalcShadowZBounds: boolean;
  146679. private _orthoLeft;
  146680. private _orthoRight;
  146681. private _orthoTop;
  146682. private _orthoBottom;
  146683. /**
  146684. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  146685. * The directional light is emitted from everywhere in the given direction.
  146686. * It can cast shadows.
  146687. * Documentation : https://doc.babylonjs.com/babylon101/lights
  146688. * @param name The friendly name of the light
  146689. * @param direction The direction of the light
  146690. * @param scene The scene the light belongs to
  146691. */
  146692. constructor(name: string, direction: Vector3, scene: Scene);
  146693. /**
  146694. * Returns the string "DirectionalLight".
  146695. * @return The class name
  146696. */
  146697. getClassName(): string;
  146698. /**
  146699. * Returns the integer 1.
  146700. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  146701. */
  146702. getTypeID(): number;
  146703. /**
  146704. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  146705. * Returns the DirectionalLight Shadow projection matrix.
  146706. */
  146707. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  146708. /**
  146709. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  146710. * Returns the DirectionalLight Shadow projection matrix.
  146711. */
  146712. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  146713. /**
  146714. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  146715. * Returns the DirectionalLight Shadow projection matrix.
  146716. */
  146717. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  146718. protected _buildUniformLayout(): void;
  146719. /**
  146720. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  146721. * @param effect The effect to update
  146722. * @param lightIndex The index of the light in the effect to update
  146723. * @returns The directional light
  146724. */
  146725. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  146726. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  146727. /**
  146728. * Gets the minZ used for shadow according to both the scene and the light.
  146729. *
  146730. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  146731. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  146732. * @param activeCamera The camera we are returning the min for
  146733. * @returns the depth min z
  146734. */
  146735. getDepthMinZ(activeCamera: Camera): number;
  146736. /**
  146737. * Gets the maxZ used for shadow according to both the scene and the light.
  146738. *
  146739. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  146740. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  146741. * @param activeCamera The camera we are returning the max for
  146742. * @returns the depth max z
  146743. */
  146744. getDepthMaxZ(activeCamera: Camera): number;
  146745. /**
  146746. * Prepares the list of defines specific to the light type.
  146747. * @param defines the list of defines
  146748. * @param lightIndex defines the index of the light for the effect
  146749. */
  146750. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  146751. }
  146752. }
  146753. declare module BABYLON {
  146754. /**
  146755. * Class containing static functions to help procedurally build meshes
  146756. */
  146757. export class HemisphereBuilder {
  146758. /**
  146759. * Creates a hemisphere mesh
  146760. * @param name defines the name of the mesh
  146761. * @param options defines the options used to create the mesh
  146762. * @param scene defines the hosting scene
  146763. * @returns the hemisphere mesh
  146764. */
  146765. static CreateHemisphere(name: string, options: {
  146766. segments?: number;
  146767. diameter?: number;
  146768. sideOrientation?: number;
  146769. }, scene: any): Mesh;
  146770. }
  146771. }
  146772. declare module BABYLON {
  146773. /**
  146774. * A spot light is defined by a position, a direction, an angle, and an exponent.
  146775. * These values define a cone of light starting from the position, emitting toward the direction.
  146776. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  146777. * and the exponent defines the speed of the decay of the light with distance (reach).
  146778. * Documentation: https://doc.babylonjs.com/babylon101/lights
  146779. */
  146780. export class SpotLight extends ShadowLight {
  146781. private _angle;
  146782. private _innerAngle;
  146783. private _cosHalfAngle;
  146784. private _lightAngleScale;
  146785. private _lightAngleOffset;
  146786. /**
  146787. * Gets the cone angle of the spot light in Radians.
  146788. */
  146789. get angle(): number;
  146790. /**
  146791. * Sets the cone angle of the spot light in Radians.
  146792. */
  146793. set angle(value: number);
  146794. /**
  146795. * Only used in gltf falloff mode, this defines the angle where
  146796. * the directional falloff will start before cutting at angle which could be seen
  146797. * as outer angle.
  146798. */
  146799. get innerAngle(): number;
  146800. /**
  146801. * Only used in gltf falloff mode, this defines the angle where
  146802. * the directional falloff will start before cutting at angle which could be seen
  146803. * as outer angle.
  146804. */
  146805. set innerAngle(value: number);
  146806. private _shadowAngleScale;
  146807. /**
  146808. * Allows scaling the angle of the light for shadow generation only.
  146809. */
  146810. get shadowAngleScale(): number;
  146811. /**
  146812. * Allows scaling the angle of the light for shadow generation only.
  146813. */
  146814. set shadowAngleScale(value: number);
  146815. /**
  146816. * The light decay speed with the distance from the emission spot.
  146817. */
  146818. exponent: number;
  146819. private _projectionTextureMatrix;
  146820. /**
  146821. * Allows reading the projection texture
  146822. */
  146823. get projectionTextureMatrix(): Matrix;
  146824. protected _projectionTextureLightNear: number;
  146825. /**
  146826. * Gets the near clip of the Spotlight for texture projection.
  146827. */
  146828. get projectionTextureLightNear(): number;
  146829. /**
  146830. * Sets the near clip of the Spotlight for texture projection.
  146831. */
  146832. set projectionTextureLightNear(value: number);
  146833. protected _projectionTextureLightFar: number;
  146834. /**
  146835. * Gets the far clip of the Spotlight for texture projection.
  146836. */
  146837. get projectionTextureLightFar(): number;
  146838. /**
  146839. * Sets the far clip of the Spotlight for texture projection.
  146840. */
  146841. set projectionTextureLightFar(value: number);
  146842. protected _projectionTextureUpDirection: Vector3;
  146843. /**
  146844. * Gets the Up vector of the Spotlight for texture projection.
  146845. */
  146846. get projectionTextureUpDirection(): Vector3;
  146847. /**
  146848. * Sets the Up vector of the Spotlight for texture projection.
  146849. */
  146850. set projectionTextureUpDirection(value: Vector3);
  146851. private _projectionTexture;
  146852. /**
  146853. * Gets the projection texture of the light.
  146854. */
  146855. get projectionTexture(): Nullable<BaseTexture>;
  146856. /**
  146857. * Sets the projection texture of the light.
  146858. */
  146859. set projectionTexture(value: Nullable<BaseTexture>);
  146860. private static _IsProceduralTexture;
  146861. private static _IsTexture;
  146862. private _projectionTextureViewLightDirty;
  146863. private _projectionTextureProjectionLightDirty;
  146864. private _projectionTextureDirty;
  146865. private _projectionTextureViewTargetVector;
  146866. private _projectionTextureViewLightMatrix;
  146867. private _projectionTextureProjectionLightMatrix;
  146868. private _projectionTextureScalingMatrix;
  146869. /**
  146870. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  146871. * It can cast shadows.
  146872. * Documentation : https://doc.babylonjs.com/babylon101/lights
  146873. * @param name The light friendly name
  146874. * @param position The position of the spot light in the scene
  146875. * @param direction The direction of the light in the scene
  146876. * @param angle The cone angle of the light in Radians
  146877. * @param exponent The light decay speed with the distance from the emission spot
  146878. * @param scene The scene the lights belongs to
  146879. */
  146880. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  146881. /**
  146882. * Returns the string "SpotLight".
  146883. * @returns the class name
  146884. */
  146885. getClassName(): string;
  146886. /**
  146887. * Returns the integer 2.
  146888. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  146889. */
  146890. getTypeID(): number;
  146891. /**
  146892. * Overrides the direction setter to recompute the projection texture view light Matrix.
  146893. */
  146894. protected _setDirection(value: Vector3): void;
  146895. /**
  146896. * Overrides the position setter to recompute the projection texture view light Matrix.
  146897. */
  146898. protected _setPosition(value: Vector3): void;
  146899. /**
  146900. * 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.
  146901. * Returns the SpotLight.
  146902. */
  146903. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  146904. protected _computeProjectionTextureViewLightMatrix(): void;
  146905. protected _computeProjectionTextureProjectionLightMatrix(): void;
  146906. /**
  146907. * Main function for light texture projection matrix computing.
  146908. */
  146909. protected _computeProjectionTextureMatrix(): void;
  146910. protected _buildUniformLayout(): void;
  146911. private _computeAngleValues;
  146912. /**
  146913. * Sets the passed Effect "effect" with the Light textures.
  146914. * @param effect The effect to update
  146915. * @param lightIndex The index of the light in the effect to update
  146916. * @returns The light
  146917. */
  146918. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  146919. /**
  146920. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  146921. * @param effect The effect to update
  146922. * @param lightIndex The index of the light in the effect to update
  146923. * @returns The spot light
  146924. */
  146925. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  146926. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  146927. /**
  146928. * Disposes the light and the associated resources.
  146929. */
  146930. dispose(): void;
  146931. /**
  146932. * Prepares the list of defines specific to the light type.
  146933. * @param defines the list of defines
  146934. * @param lightIndex defines the index of the light for the effect
  146935. */
  146936. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  146937. }
  146938. }
  146939. declare module BABYLON {
  146940. /**
  146941. * Gizmo that enables viewing a light
  146942. */
  146943. export class LightGizmo extends Gizmo {
  146944. private _lightMesh;
  146945. private _material;
  146946. private _cachedPosition;
  146947. private _cachedForward;
  146948. private _attachedMeshParent;
  146949. private _pointerObserver;
  146950. /**
  146951. * Event that fires each time the gizmo is clicked
  146952. */
  146953. onClickedObservable: Observable<Light>;
  146954. /**
  146955. * Creates a LightGizmo
  146956. * @param gizmoLayer The utility layer the gizmo will be added to
  146957. */
  146958. constructor(gizmoLayer?: UtilityLayerRenderer);
  146959. private _light;
  146960. /**
  146961. * The light that the gizmo is attached to
  146962. */
  146963. set light(light: Nullable<Light>);
  146964. get light(): Nullable<Light>;
  146965. /**
  146966. * Gets the material used to render the light gizmo
  146967. */
  146968. get material(): StandardMaterial;
  146969. /**
  146970. * @hidden
  146971. * Updates the gizmo to match the attached mesh's position/rotation
  146972. */
  146973. protected _update(): void;
  146974. private static _Scale;
  146975. /**
  146976. * Creates the lines for a light mesh
  146977. */
  146978. private static _CreateLightLines;
  146979. /**
  146980. * Disposes of the light gizmo
  146981. */
  146982. dispose(): void;
  146983. private static _CreateHemisphericLightMesh;
  146984. private static _CreatePointLightMesh;
  146985. private static _CreateSpotLightMesh;
  146986. private static _CreateDirectionalLightMesh;
  146987. }
  146988. }
  146989. declare module BABYLON {
  146990. /**
  146991. * Gizmo that enables viewing a camera
  146992. */
  146993. export class CameraGizmo extends Gizmo {
  146994. private _cameraMesh;
  146995. private _cameraLinesMesh;
  146996. private _material;
  146997. private _pointerObserver;
  146998. /**
  146999. * Event that fires each time the gizmo is clicked
  147000. */
  147001. onClickedObservable: Observable<Camera>;
  147002. /**
  147003. * Creates a CameraGizmo
  147004. * @param gizmoLayer The utility layer the gizmo will be added to
  147005. */
  147006. constructor(gizmoLayer?: UtilityLayerRenderer);
  147007. private _camera;
  147008. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  147009. get displayFrustum(): boolean;
  147010. set displayFrustum(value: boolean);
  147011. /**
  147012. * The camera that the gizmo is attached to
  147013. */
  147014. set camera(camera: Nullable<Camera>);
  147015. get camera(): Nullable<Camera>;
  147016. /**
  147017. * Gets the material used to render the camera gizmo
  147018. */
  147019. get material(): StandardMaterial;
  147020. /**
  147021. * @hidden
  147022. * Updates the gizmo to match the attached mesh's position/rotation
  147023. */
  147024. protected _update(): void;
  147025. private static _Scale;
  147026. private _invProjection;
  147027. /**
  147028. * Disposes of the camera gizmo
  147029. */
  147030. dispose(): void;
  147031. private static _CreateCameraMesh;
  147032. private static _CreateCameraFrustum;
  147033. }
  147034. }
  147035. declare module BABYLON {
  147036. /** @hidden */
  147037. export var backgroundFragmentDeclaration: {
  147038. name: string;
  147039. shader: string;
  147040. };
  147041. }
  147042. declare module BABYLON {
  147043. /** @hidden */
  147044. export var backgroundUboDeclaration: {
  147045. name: string;
  147046. shader: string;
  147047. };
  147048. }
  147049. declare module BABYLON {
  147050. /** @hidden */
  147051. export var backgroundPixelShader: {
  147052. name: string;
  147053. shader: string;
  147054. };
  147055. }
  147056. declare module BABYLON {
  147057. /** @hidden */
  147058. export var backgroundVertexDeclaration: {
  147059. name: string;
  147060. shader: string;
  147061. };
  147062. }
  147063. declare module BABYLON {
  147064. /** @hidden */
  147065. export var backgroundVertexShader: {
  147066. name: string;
  147067. shader: string;
  147068. };
  147069. }
  147070. declare module BABYLON {
  147071. /**
  147072. * Background material used to create an efficient environment around your scene.
  147073. */
  147074. export class BackgroundMaterial extends PushMaterial {
  147075. /**
  147076. * Standard reflectance value at parallel view angle.
  147077. */
  147078. static StandardReflectance0: number;
  147079. /**
  147080. * Standard reflectance value at grazing angle.
  147081. */
  147082. static StandardReflectance90: number;
  147083. protected _primaryColor: Color3;
  147084. /**
  147085. * Key light Color (multiply against the environment texture)
  147086. */
  147087. primaryColor: Color3;
  147088. protected __perceptualColor: Nullable<Color3>;
  147089. /**
  147090. * Experimental Internal Use Only.
  147091. *
  147092. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  147093. * This acts as a helper to set the primary color to a more "human friendly" value.
  147094. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  147095. * output color as close as possible from the chosen value.
  147096. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  147097. * part of lighting setup.)
  147098. */
  147099. get _perceptualColor(): Nullable<Color3>;
  147100. set _perceptualColor(value: Nullable<Color3>);
  147101. protected _primaryColorShadowLevel: float;
  147102. /**
  147103. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  147104. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  147105. */
  147106. get primaryColorShadowLevel(): float;
  147107. set primaryColorShadowLevel(value: float);
  147108. protected _primaryColorHighlightLevel: float;
  147109. /**
  147110. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  147111. * The primary color is used at the level chosen to define what the white area would look.
  147112. */
  147113. get primaryColorHighlightLevel(): float;
  147114. set primaryColorHighlightLevel(value: float);
  147115. protected _reflectionTexture: Nullable<BaseTexture>;
  147116. /**
  147117. * Reflection Texture used in the material.
  147118. * Should be author in a specific way for the best result (refer to the documentation).
  147119. */
  147120. reflectionTexture: Nullable<BaseTexture>;
  147121. protected _reflectionBlur: float;
  147122. /**
  147123. * Reflection Texture level of blur.
  147124. *
  147125. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  147126. * texture twice.
  147127. */
  147128. reflectionBlur: float;
  147129. protected _diffuseTexture: Nullable<BaseTexture>;
  147130. /**
  147131. * Diffuse Texture used in the material.
  147132. * Should be author in a specific way for the best result (refer to the documentation).
  147133. */
  147134. diffuseTexture: Nullable<BaseTexture>;
  147135. protected _shadowLights: Nullable<IShadowLight[]>;
  147136. /**
  147137. * Specify the list of lights casting shadow on the material.
  147138. * All scene shadow lights will be included if null.
  147139. */
  147140. shadowLights: Nullable<IShadowLight[]>;
  147141. protected _shadowLevel: float;
  147142. /**
  147143. * Helps adjusting the shadow to a softer level if required.
  147144. * 0 means black shadows and 1 means no shadows.
  147145. */
  147146. shadowLevel: float;
  147147. protected _sceneCenter: Vector3;
  147148. /**
  147149. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  147150. * It is usually zero but might be interesting to modify according to your setup.
  147151. */
  147152. sceneCenter: Vector3;
  147153. protected _opacityFresnel: boolean;
  147154. /**
  147155. * This helps specifying that the material is falling off to the sky box at grazing angle.
  147156. * This helps ensuring a nice transition when the camera goes under the ground.
  147157. */
  147158. opacityFresnel: boolean;
  147159. protected _reflectionFresnel: boolean;
  147160. /**
  147161. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  147162. * This helps adding a mirror texture on the ground.
  147163. */
  147164. reflectionFresnel: boolean;
  147165. protected _reflectionFalloffDistance: number;
  147166. /**
  147167. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  147168. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  147169. */
  147170. reflectionFalloffDistance: number;
  147171. protected _reflectionAmount: number;
  147172. /**
  147173. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  147174. */
  147175. reflectionAmount: number;
  147176. protected _reflectionReflectance0: number;
  147177. /**
  147178. * This specifies the weight of the reflection at grazing angle.
  147179. */
  147180. reflectionReflectance0: number;
  147181. protected _reflectionReflectance90: number;
  147182. /**
  147183. * This specifies the weight of the reflection at a perpendicular point of view.
  147184. */
  147185. reflectionReflectance90: number;
  147186. /**
  147187. * Sets the reflection reflectance fresnel values according to the default standard
  147188. * empirically know to work well :-)
  147189. */
  147190. set reflectionStandardFresnelWeight(value: number);
  147191. protected _useRGBColor: boolean;
  147192. /**
  147193. * Helps to directly use the maps channels instead of their level.
  147194. */
  147195. useRGBColor: boolean;
  147196. protected _enableNoise: boolean;
  147197. /**
  147198. * This helps reducing the banding effect that could occur on the background.
  147199. */
  147200. enableNoise: boolean;
  147201. /**
  147202. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  147203. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  147204. * Recommended to be keep at 1.0 except for special cases.
  147205. */
  147206. get fovMultiplier(): number;
  147207. set fovMultiplier(value: number);
  147208. private _fovMultiplier;
  147209. /**
  147210. * Enable the FOV adjustment feature controlled by fovMultiplier.
  147211. */
  147212. useEquirectangularFOV: boolean;
  147213. private _maxSimultaneousLights;
  147214. /**
  147215. * Number of Simultaneous lights allowed on the material.
  147216. */
  147217. maxSimultaneousLights: int;
  147218. private _shadowOnly;
  147219. /**
  147220. * Make the material only render shadows
  147221. */
  147222. shadowOnly: boolean;
  147223. /**
  147224. * Default configuration related to image processing available in the Background Material.
  147225. */
  147226. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  147227. /**
  147228. * Keep track of the image processing observer to allow dispose and replace.
  147229. */
  147230. private _imageProcessingObserver;
  147231. /**
  147232. * Attaches a new image processing configuration to the PBR Material.
  147233. * @param configuration (if null the scene configuration will be use)
  147234. */
  147235. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  147236. /**
  147237. * Gets the image processing configuration used either in this material.
  147238. */
  147239. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  147240. /**
  147241. * Sets the Default image processing configuration used either in the this material.
  147242. *
  147243. * If sets to null, the scene one is in use.
  147244. */
  147245. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  147246. /**
  147247. * Gets whether the color curves effect is enabled.
  147248. */
  147249. get cameraColorCurvesEnabled(): boolean;
  147250. /**
  147251. * Sets whether the color curves effect is enabled.
  147252. */
  147253. set cameraColorCurvesEnabled(value: boolean);
  147254. /**
  147255. * Gets whether the color grading effect is enabled.
  147256. */
  147257. get cameraColorGradingEnabled(): boolean;
  147258. /**
  147259. * Gets whether the color grading effect is enabled.
  147260. */
  147261. set cameraColorGradingEnabled(value: boolean);
  147262. /**
  147263. * Gets whether tonemapping is enabled or not.
  147264. */
  147265. get cameraToneMappingEnabled(): boolean;
  147266. /**
  147267. * Sets whether tonemapping is enabled or not
  147268. */
  147269. set cameraToneMappingEnabled(value: boolean);
  147270. /**
  147271. * The camera exposure used on this material.
  147272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  147273. * This corresponds to a photographic exposure.
  147274. */
  147275. get cameraExposure(): float;
  147276. /**
  147277. * The camera exposure used on this material.
  147278. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  147279. * This corresponds to a photographic exposure.
  147280. */
  147281. set cameraExposure(value: float);
  147282. /**
  147283. * Gets The camera contrast used on this material.
  147284. */
  147285. get cameraContrast(): float;
  147286. /**
  147287. * Sets The camera contrast used on this material.
  147288. */
  147289. set cameraContrast(value: float);
  147290. /**
  147291. * Gets the Color Grading 2D Lookup Texture.
  147292. */
  147293. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  147294. /**
  147295. * Sets the Color Grading 2D Lookup Texture.
  147296. */
  147297. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  147298. /**
  147299. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  147300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  147301. * 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;
  147302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  147303. */
  147304. get cameraColorCurves(): Nullable<ColorCurves>;
  147305. /**
  147306. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  147307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  147308. * 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;
  147309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  147310. */
  147311. set cameraColorCurves(value: Nullable<ColorCurves>);
  147312. /**
  147313. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  147314. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  147315. */
  147316. switchToBGR: boolean;
  147317. private _renderTargets;
  147318. private _reflectionControls;
  147319. private _white;
  147320. private _primaryShadowColor;
  147321. private _primaryHighlightColor;
  147322. /**
  147323. * Instantiates a Background Material in the given scene
  147324. * @param name The friendly name of the material
  147325. * @param scene The scene to add the material to
  147326. */
  147327. constructor(name: string, scene: Scene);
  147328. /**
  147329. * Gets a boolean indicating that current material needs to register RTT
  147330. */
  147331. get hasRenderTargetTextures(): boolean;
  147332. /**
  147333. * The entire material has been created in order to prevent overdraw.
  147334. * @returns false
  147335. */
  147336. needAlphaTesting(): boolean;
  147337. /**
  147338. * The entire material has been created in order to prevent overdraw.
  147339. * @returns true if blending is enable
  147340. */
  147341. needAlphaBlending(): boolean;
  147342. /**
  147343. * Checks whether the material is ready to be rendered for a given mesh.
  147344. * @param mesh The mesh to render
  147345. * @param subMesh The submesh to check against
  147346. * @param useInstances Specify wether or not the material is used with instances
  147347. * @returns true if all the dependencies are ready (Textures, Effects...)
  147348. */
  147349. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  147350. /**
  147351. * Compute the primary color according to the chosen perceptual color.
  147352. */
  147353. private _computePrimaryColorFromPerceptualColor;
  147354. /**
  147355. * Compute the highlights and shadow colors according to their chosen levels.
  147356. */
  147357. private _computePrimaryColors;
  147358. /**
  147359. * Build the uniform buffer used in the material.
  147360. */
  147361. buildUniformLayout(): void;
  147362. /**
  147363. * Unbind the material.
  147364. */
  147365. unbind(): void;
  147366. /**
  147367. * Bind only the world matrix to the material.
  147368. * @param world The world matrix to bind.
  147369. */
  147370. bindOnlyWorldMatrix(world: Matrix): void;
  147371. /**
  147372. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  147373. * @param world The world matrix to bind.
  147374. * @param subMesh The submesh to bind for.
  147375. */
  147376. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  147377. /**
  147378. * Checks to see if a texture is used in the material.
  147379. * @param texture - Base texture to use.
  147380. * @returns - Boolean specifying if a texture is used in the material.
  147381. */
  147382. hasTexture(texture: BaseTexture): boolean;
  147383. /**
  147384. * Dispose the material.
  147385. * @param forceDisposeEffect Force disposal of the associated effect.
  147386. * @param forceDisposeTextures Force disposal of the associated textures.
  147387. */
  147388. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  147389. /**
  147390. * Clones the material.
  147391. * @param name The cloned name.
  147392. * @returns The cloned material.
  147393. */
  147394. clone(name: string): BackgroundMaterial;
  147395. /**
  147396. * Serializes the current material to its JSON representation.
  147397. * @returns The JSON representation.
  147398. */
  147399. serialize(): any;
  147400. /**
  147401. * Gets the class name of the material
  147402. * @returns "BackgroundMaterial"
  147403. */
  147404. getClassName(): string;
  147405. /**
  147406. * Parse a JSON input to create back a background material.
  147407. * @param source The JSON data to parse
  147408. * @param scene The scene to create the parsed material in
  147409. * @param rootUrl The root url of the assets the material depends upon
  147410. * @returns the instantiated BackgroundMaterial.
  147411. */
  147412. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  147413. }
  147414. }
  147415. declare module BABYLON {
  147416. /**
  147417. * Represents the different options available during the creation of
  147418. * a Environment helper.
  147419. *
  147420. * This can control the default ground, skybox and image processing setup of your scene.
  147421. */
  147422. export interface IEnvironmentHelperOptions {
  147423. /**
  147424. * Specifies whether or not to create a ground.
  147425. * True by default.
  147426. */
  147427. createGround: boolean;
  147428. /**
  147429. * Specifies the ground size.
  147430. * 15 by default.
  147431. */
  147432. groundSize: number;
  147433. /**
  147434. * The texture used on the ground for the main color.
  147435. * Comes from the BabylonJS CDN by default.
  147436. *
  147437. * Remarks: Can be either a texture or a url.
  147438. */
  147439. groundTexture: string | BaseTexture;
  147440. /**
  147441. * The color mixed in the ground texture by default.
  147442. * BabylonJS clearColor by default.
  147443. */
  147444. groundColor: Color3;
  147445. /**
  147446. * Specifies the ground opacity.
  147447. * 1 by default.
  147448. */
  147449. groundOpacity: number;
  147450. /**
  147451. * Enables the ground to receive shadows.
  147452. * True by default.
  147453. */
  147454. enableGroundShadow: boolean;
  147455. /**
  147456. * Helps preventing the shadow to be fully black on the ground.
  147457. * 0.5 by default.
  147458. */
  147459. groundShadowLevel: number;
  147460. /**
  147461. * Creates a mirror texture attach to the ground.
  147462. * false by default.
  147463. */
  147464. enableGroundMirror: boolean;
  147465. /**
  147466. * Specifies the ground mirror size ratio.
  147467. * 0.3 by default as the default kernel is 64.
  147468. */
  147469. groundMirrorSizeRatio: number;
  147470. /**
  147471. * Specifies the ground mirror blur kernel size.
  147472. * 64 by default.
  147473. */
  147474. groundMirrorBlurKernel: number;
  147475. /**
  147476. * Specifies the ground mirror visibility amount.
  147477. * 1 by default
  147478. */
  147479. groundMirrorAmount: number;
  147480. /**
  147481. * Specifies the ground mirror reflectance weight.
  147482. * This uses the standard weight of the background material to setup the fresnel effect
  147483. * of the mirror.
  147484. * 1 by default.
  147485. */
  147486. groundMirrorFresnelWeight: number;
  147487. /**
  147488. * Specifies the ground mirror Falloff distance.
  147489. * This can helps reducing the size of the reflection.
  147490. * 0 by Default.
  147491. */
  147492. groundMirrorFallOffDistance: number;
  147493. /**
  147494. * Specifies the ground mirror texture type.
  147495. * Unsigned Int by Default.
  147496. */
  147497. groundMirrorTextureType: number;
  147498. /**
  147499. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  147500. * the shown objects.
  147501. */
  147502. groundYBias: number;
  147503. /**
  147504. * Specifies whether or not to create a skybox.
  147505. * True by default.
  147506. */
  147507. createSkybox: boolean;
  147508. /**
  147509. * Specifies the skybox size.
  147510. * 20 by default.
  147511. */
  147512. skyboxSize: number;
  147513. /**
  147514. * The texture used on the skybox for the main color.
  147515. * Comes from the BabylonJS CDN by default.
  147516. *
  147517. * Remarks: Can be either a texture or a url.
  147518. */
  147519. skyboxTexture: string | BaseTexture;
  147520. /**
  147521. * The color mixed in the skybox texture by default.
  147522. * BabylonJS clearColor by default.
  147523. */
  147524. skyboxColor: Color3;
  147525. /**
  147526. * The background rotation around the Y axis of the scene.
  147527. * This helps aligning the key lights of your scene with the background.
  147528. * 0 by default.
  147529. */
  147530. backgroundYRotation: number;
  147531. /**
  147532. * Compute automatically the size of the elements to best fit with the scene.
  147533. */
  147534. sizeAuto: boolean;
  147535. /**
  147536. * Default position of the rootMesh if autoSize is not true.
  147537. */
  147538. rootPosition: Vector3;
  147539. /**
  147540. * Sets up the image processing in the scene.
  147541. * true by default.
  147542. */
  147543. setupImageProcessing: boolean;
  147544. /**
  147545. * The texture used as your environment texture in the scene.
  147546. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  147547. *
  147548. * Remarks: Can be either a texture or a url.
  147549. */
  147550. environmentTexture: string | BaseTexture;
  147551. /**
  147552. * The value of the exposure to apply to the scene.
  147553. * 0.6 by default if setupImageProcessing is true.
  147554. */
  147555. cameraExposure: number;
  147556. /**
  147557. * The value of the contrast to apply to the scene.
  147558. * 1.6 by default if setupImageProcessing is true.
  147559. */
  147560. cameraContrast: number;
  147561. /**
  147562. * Specifies whether or not tonemapping should be enabled in the scene.
  147563. * true by default if setupImageProcessing is true.
  147564. */
  147565. toneMappingEnabled: boolean;
  147566. }
  147567. /**
  147568. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  147569. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  147570. * It also helps with the default setup of your imageProcessing configuration.
  147571. */
  147572. export class EnvironmentHelper {
  147573. /**
  147574. * Default ground texture URL.
  147575. */
  147576. private static _groundTextureCDNUrl;
  147577. /**
  147578. * Default skybox texture URL.
  147579. */
  147580. private static _skyboxTextureCDNUrl;
  147581. /**
  147582. * Default environment texture URL.
  147583. */
  147584. private static _environmentTextureCDNUrl;
  147585. /**
  147586. * Creates the default options for the helper.
  147587. */
  147588. private static _getDefaultOptions;
  147589. private _rootMesh;
  147590. /**
  147591. * Gets the root mesh created by the helper.
  147592. */
  147593. get rootMesh(): Mesh;
  147594. private _skybox;
  147595. /**
  147596. * Gets the skybox created by the helper.
  147597. */
  147598. get skybox(): Nullable<Mesh>;
  147599. private _skyboxTexture;
  147600. /**
  147601. * Gets the skybox texture created by the helper.
  147602. */
  147603. get skyboxTexture(): Nullable<BaseTexture>;
  147604. private _skyboxMaterial;
  147605. /**
  147606. * Gets the skybox material created by the helper.
  147607. */
  147608. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  147609. private _ground;
  147610. /**
  147611. * Gets the ground mesh created by the helper.
  147612. */
  147613. get ground(): Nullable<Mesh>;
  147614. private _groundTexture;
  147615. /**
  147616. * Gets the ground texture created by the helper.
  147617. */
  147618. get groundTexture(): Nullable<BaseTexture>;
  147619. private _groundMirror;
  147620. /**
  147621. * Gets the ground mirror created by the helper.
  147622. */
  147623. get groundMirror(): Nullable<MirrorTexture>;
  147624. /**
  147625. * Gets the ground mirror render list to helps pushing the meshes
  147626. * you wish in the ground reflection.
  147627. */
  147628. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  147629. private _groundMaterial;
  147630. /**
  147631. * Gets the ground material created by the helper.
  147632. */
  147633. get groundMaterial(): Nullable<BackgroundMaterial>;
  147634. /**
  147635. * Stores the creation options.
  147636. */
  147637. private readonly _scene;
  147638. private _options;
  147639. /**
  147640. * This observable will be notified with any error during the creation of the environment,
  147641. * mainly texture creation errors.
  147642. */
  147643. onErrorObservable: Observable<{
  147644. message?: string;
  147645. exception?: any;
  147646. }>;
  147647. /**
  147648. * constructor
  147649. * @param options Defines the options we want to customize the helper
  147650. * @param scene The scene to add the material to
  147651. */
  147652. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  147653. /**
  147654. * Updates the background according to the new options
  147655. * @param options
  147656. */
  147657. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  147658. /**
  147659. * Sets the primary color of all the available elements.
  147660. * @param color the main color to affect to the ground and the background
  147661. */
  147662. setMainColor(color: Color3): void;
  147663. /**
  147664. * Setup the image processing according to the specified options.
  147665. */
  147666. private _setupImageProcessing;
  147667. /**
  147668. * Setup the environment texture according to the specified options.
  147669. */
  147670. private _setupEnvironmentTexture;
  147671. /**
  147672. * Setup the background according to the specified options.
  147673. */
  147674. private _setupBackground;
  147675. /**
  147676. * Get the scene sizes according to the setup.
  147677. */
  147678. private _getSceneSize;
  147679. /**
  147680. * Setup the ground according to the specified options.
  147681. */
  147682. private _setupGround;
  147683. /**
  147684. * Setup the ground material according to the specified options.
  147685. */
  147686. private _setupGroundMaterial;
  147687. /**
  147688. * Setup the ground diffuse texture according to the specified options.
  147689. */
  147690. private _setupGroundDiffuseTexture;
  147691. /**
  147692. * Setup the ground mirror texture according to the specified options.
  147693. */
  147694. private _setupGroundMirrorTexture;
  147695. /**
  147696. * Setup the ground to receive the mirror texture.
  147697. */
  147698. private _setupMirrorInGroundMaterial;
  147699. /**
  147700. * Setup the skybox according to the specified options.
  147701. */
  147702. private _setupSkybox;
  147703. /**
  147704. * Setup the skybox material according to the specified options.
  147705. */
  147706. private _setupSkyboxMaterial;
  147707. /**
  147708. * Setup the skybox reflection texture according to the specified options.
  147709. */
  147710. private _setupSkyboxReflectionTexture;
  147711. private _errorHandler;
  147712. /**
  147713. * Dispose all the elements created by the Helper.
  147714. */
  147715. dispose(): void;
  147716. }
  147717. }
  147718. declare module BABYLON {
  147719. /**
  147720. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  147721. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  147722. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  147723. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  147724. */
  147725. export abstract class TextureDome<T extends Texture> extends TransformNode {
  147726. protected onError: Nullable<(message?: string, exception?: any) => void>;
  147727. /**
  147728. * Define the source as a Monoscopic panoramic 360/180.
  147729. */
  147730. static readonly MODE_MONOSCOPIC: number;
  147731. /**
  147732. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  147733. */
  147734. static readonly MODE_TOPBOTTOM: number;
  147735. /**
  147736. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  147737. */
  147738. static readonly MODE_SIDEBYSIDE: number;
  147739. private _halfDome;
  147740. private _crossEye;
  147741. protected _useDirectMapping: boolean;
  147742. /**
  147743. * The texture being displayed on the sphere
  147744. */
  147745. protected _texture: T;
  147746. /**
  147747. * Gets the texture being displayed on the sphere
  147748. */
  147749. get texture(): T;
  147750. /**
  147751. * Sets the texture being displayed on the sphere
  147752. */
  147753. set texture(newTexture: T);
  147754. /**
  147755. * The skybox material
  147756. */
  147757. protected _material: BackgroundMaterial;
  147758. /**
  147759. * The surface used for the dome
  147760. */
  147761. protected _mesh: Mesh;
  147762. /**
  147763. * Gets the mesh used for the dome.
  147764. */
  147765. get mesh(): Mesh;
  147766. /**
  147767. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  147768. */
  147769. private _halfDomeMask;
  147770. /**
  147771. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  147772. * Also see the options.resolution property.
  147773. */
  147774. get fovMultiplier(): number;
  147775. set fovMultiplier(value: number);
  147776. protected _textureMode: number;
  147777. /**
  147778. * Gets or set the current texture mode for the texture. It can be:
  147779. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  147780. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  147781. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  147782. */
  147783. get textureMode(): number;
  147784. /**
  147785. * Sets the current texture mode for the texture. It can be:
  147786. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  147787. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  147788. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  147789. */
  147790. set textureMode(value: number);
  147791. /**
  147792. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  147793. */
  147794. get halfDome(): boolean;
  147795. /**
  147796. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  147797. */
  147798. set halfDome(enabled: boolean);
  147799. /**
  147800. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  147801. */
  147802. set crossEye(enabled: boolean);
  147803. /**
  147804. * Is it a cross-eye texture?
  147805. */
  147806. get crossEye(): boolean;
  147807. /**
  147808. * The background material of this dome.
  147809. */
  147810. get material(): BackgroundMaterial;
  147811. /**
  147812. * Oberserver used in Stereoscopic VR Mode.
  147813. */
  147814. private _onBeforeCameraRenderObserver;
  147815. /**
  147816. * Observable raised when an error occurred while loading the texture
  147817. */
  147818. onLoadErrorObservable: Observable<string>;
  147819. /**
  147820. * Observable raised when the texture finished loading
  147821. */
  147822. onLoadObservable: Observable<void>;
  147823. /**
  147824. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  147825. * @param name Element's name, child elements will append suffixes for their own names.
  147826. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  147827. * @param options An object containing optional or exposed sub element properties
  147828. */
  147829. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  147830. resolution?: number;
  147831. clickToPlay?: boolean;
  147832. autoPlay?: boolean;
  147833. loop?: boolean;
  147834. size?: number;
  147835. poster?: string;
  147836. faceForward?: boolean;
  147837. useDirectMapping?: boolean;
  147838. halfDomeMode?: boolean;
  147839. crossEyeMode?: boolean;
  147840. generateMipMaps?: boolean;
  147841. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  147842. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  147843. protected _changeTextureMode(value: number): void;
  147844. /**
  147845. * Releases resources associated with this node.
  147846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  147847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  147848. */
  147849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  147850. }
  147851. }
  147852. declare module BABYLON {
  147853. /**
  147854. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  147855. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  147856. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  147857. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  147858. */
  147859. export class PhotoDome extends TextureDome<Texture> {
  147860. /**
  147861. * Define the image as a Monoscopic panoramic 360 image.
  147862. */
  147863. static readonly MODE_MONOSCOPIC: number;
  147864. /**
  147865. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  147866. */
  147867. static readonly MODE_TOPBOTTOM: number;
  147868. /**
  147869. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  147870. */
  147871. static readonly MODE_SIDEBYSIDE: number;
  147872. /**
  147873. * Gets or sets the texture being displayed on the sphere
  147874. */
  147875. get photoTexture(): Texture;
  147876. /**
  147877. * sets the texture being displayed on the sphere
  147878. */
  147879. set photoTexture(value: Texture);
  147880. /**
  147881. * Gets the current video mode for the video. It can be:
  147882. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  147883. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  147884. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  147885. */
  147886. get imageMode(): number;
  147887. /**
  147888. * Sets the current video mode for the video. It can be:
  147889. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  147890. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  147891. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  147892. */
  147893. set imageMode(value: number);
  147894. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  147895. }
  147896. }
  147897. declare module BABYLON {
  147898. /**
  147899. * Direct draw surface info
  147900. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  147901. */
  147902. export interface DDSInfo {
  147903. /**
  147904. * Width of the texture
  147905. */
  147906. width: number;
  147907. /**
  147908. * Width of the texture
  147909. */
  147910. height: number;
  147911. /**
  147912. * Number of Mipmaps for the texture
  147913. * @see https://en.wikipedia.org/wiki/Mipmap
  147914. */
  147915. mipmapCount: number;
  147916. /**
  147917. * If the textures format is a known fourCC format
  147918. * @see https://www.fourcc.org/
  147919. */
  147920. isFourCC: boolean;
  147921. /**
  147922. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  147923. */
  147924. isRGB: boolean;
  147925. /**
  147926. * If the texture is a lumincance format
  147927. */
  147928. isLuminance: boolean;
  147929. /**
  147930. * If this is a cube texture
  147931. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  147932. */
  147933. isCube: boolean;
  147934. /**
  147935. * If the texture is a compressed format eg. FOURCC_DXT1
  147936. */
  147937. isCompressed: boolean;
  147938. /**
  147939. * The dxgiFormat of the texture
  147940. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  147941. */
  147942. dxgiFormat: number;
  147943. /**
  147944. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  147945. */
  147946. textureType: number;
  147947. /**
  147948. * Sphericle polynomial created for the dds texture
  147949. */
  147950. sphericalPolynomial?: SphericalPolynomial;
  147951. }
  147952. /**
  147953. * Class used to provide DDS decompression tools
  147954. */
  147955. export class DDSTools {
  147956. /**
  147957. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  147958. */
  147959. static StoreLODInAlphaChannel: boolean;
  147960. /**
  147961. * Gets DDS information from an array buffer
  147962. * @param data defines the array buffer view to read data from
  147963. * @returns the DDS information
  147964. */
  147965. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  147966. private static _FloatView;
  147967. private static _Int32View;
  147968. private static _ToHalfFloat;
  147969. private static _FromHalfFloat;
  147970. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  147971. private static _GetHalfFloatRGBAArrayBuffer;
  147972. private static _GetFloatRGBAArrayBuffer;
  147973. private static _GetFloatAsUIntRGBAArrayBuffer;
  147974. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  147975. private static _GetRGBAArrayBuffer;
  147976. private static _ExtractLongWordOrder;
  147977. private static _GetRGBArrayBuffer;
  147978. private static _GetLuminanceArrayBuffer;
  147979. /**
  147980. * Uploads DDS Levels to a Babylon Texture
  147981. * @hidden
  147982. */
  147983. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  147984. }
  147985. interface ThinEngine {
  147986. /**
  147987. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  147988. * @param rootUrl defines the url where the file to load is located
  147989. * @param scene defines the current scene
  147990. * @param lodScale defines scale to apply to the mip map selection
  147991. * @param lodOffset defines offset to apply to the mip map selection
  147992. * @param onLoad defines an optional callback raised when the texture is loaded
  147993. * @param onError defines an optional callback raised if there is an issue to load the texture
  147994. * @param format defines the format of the data
  147995. * @param forcedExtension defines the extension to use to pick the right loader
  147996. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  147997. * @returns the cube texture as an InternalTexture
  147998. */
  147999. 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;
  148000. }
  148001. }
  148002. declare module BABYLON {
  148003. /**
  148004. * Implementation of the DDS Texture Loader.
  148005. * @hidden
  148006. */
  148007. export class _DDSTextureLoader implements IInternalTextureLoader {
  148008. /**
  148009. * Defines whether the loader supports cascade loading the different faces.
  148010. */
  148011. readonly supportCascades: boolean;
  148012. /**
  148013. * This returns if the loader support the current file information.
  148014. * @param extension defines the file extension of the file being loaded
  148015. * @returns true if the loader can load the specified file
  148016. */
  148017. canLoad(extension: string): boolean;
  148018. /**
  148019. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  148020. * @param data contains the texture data
  148021. * @param texture defines the BabylonJS internal texture
  148022. * @param createPolynomials will be true if polynomials have been requested
  148023. * @param onLoad defines the callback to trigger once the texture is ready
  148024. * @param onError defines the callback to trigger in case of error
  148025. */
  148026. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  148027. /**
  148028. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  148029. * @param data contains the texture data
  148030. * @param texture defines the BabylonJS internal texture
  148031. * @param callback defines the method to call once ready to upload
  148032. */
  148033. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  148034. }
  148035. }
  148036. declare module BABYLON {
  148037. /**
  148038. * Implementation of the ENV Texture Loader.
  148039. * @hidden
  148040. */
  148041. export class _ENVTextureLoader implements IInternalTextureLoader {
  148042. /**
  148043. * Defines whether the loader supports cascade loading the different faces.
  148044. */
  148045. readonly supportCascades: boolean;
  148046. /**
  148047. * This returns if the loader support the current file information.
  148048. * @param extension defines the file extension of the file being loaded
  148049. * @returns true if the loader can load the specified file
  148050. */
  148051. canLoad(extension: string): boolean;
  148052. /**
  148053. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  148054. * @param data contains the texture data
  148055. * @param texture defines the BabylonJS internal texture
  148056. * @param createPolynomials will be true if polynomials have been requested
  148057. * @param onLoad defines the callback to trigger once the texture is ready
  148058. * @param onError defines the callback to trigger in case of error
  148059. */
  148060. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  148061. /**
  148062. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  148063. * @param data contains the texture data
  148064. * @param texture defines the BabylonJS internal texture
  148065. * @param callback defines the method to call once ready to upload
  148066. */
  148067. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  148068. }
  148069. }
  148070. declare module BABYLON {
  148071. /**
  148072. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  148073. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  148074. */
  148075. export class KhronosTextureContainer {
  148076. /** contents of the KTX container file */
  148077. data: ArrayBufferView;
  148078. private static HEADER_LEN;
  148079. private static COMPRESSED_2D;
  148080. private static COMPRESSED_3D;
  148081. private static TEX_2D;
  148082. private static TEX_3D;
  148083. /**
  148084. * Gets the openGL type
  148085. */
  148086. glType: number;
  148087. /**
  148088. * Gets the openGL type size
  148089. */
  148090. glTypeSize: number;
  148091. /**
  148092. * Gets the openGL format
  148093. */
  148094. glFormat: number;
  148095. /**
  148096. * Gets the openGL internal format
  148097. */
  148098. glInternalFormat: number;
  148099. /**
  148100. * Gets the base internal format
  148101. */
  148102. glBaseInternalFormat: number;
  148103. /**
  148104. * Gets image width in pixel
  148105. */
  148106. pixelWidth: number;
  148107. /**
  148108. * Gets image height in pixel
  148109. */
  148110. pixelHeight: number;
  148111. /**
  148112. * Gets image depth in pixels
  148113. */
  148114. pixelDepth: number;
  148115. /**
  148116. * Gets the number of array elements
  148117. */
  148118. numberOfArrayElements: number;
  148119. /**
  148120. * Gets the number of faces
  148121. */
  148122. numberOfFaces: number;
  148123. /**
  148124. * Gets the number of mipmap levels
  148125. */
  148126. numberOfMipmapLevels: number;
  148127. /**
  148128. * Gets the bytes of key value data
  148129. */
  148130. bytesOfKeyValueData: number;
  148131. /**
  148132. * Gets the load type
  148133. */
  148134. loadType: number;
  148135. /**
  148136. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  148137. */
  148138. isInvalid: boolean;
  148139. /**
  148140. * Creates a new KhronosTextureContainer
  148141. * @param data contents of the KTX container file
  148142. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  148143. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  148144. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  148145. */
  148146. constructor(
  148147. /** contents of the KTX container file */
  148148. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  148149. /**
  148150. * Uploads KTX content to a Babylon Texture.
  148151. * It is assumed that the texture has already been created & is currently bound
  148152. * @hidden
  148153. */
  148154. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  148155. private _upload2DCompressedLevels;
  148156. /**
  148157. * Checks if the given data starts with a KTX file identifier.
  148158. * @param data the data to check
  148159. * @returns true if the data is a KTX file or false otherwise
  148160. */
  148161. static IsValid(data: ArrayBufferView): boolean;
  148162. }
  148163. }
  148164. declare module BABYLON {
  148165. /**
  148166. * Helper class to push actions to a pool of workers.
  148167. */
  148168. export class WorkerPool implements IDisposable {
  148169. private _workerInfos;
  148170. private _pendingActions;
  148171. /**
  148172. * Constructor
  148173. * @param workers Array of workers to use for actions
  148174. */
  148175. constructor(workers: Array<Worker>);
  148176. /**
  148177. * Terminates all workers and clears any pending actions.
  148178. */
  148179. dispose(): void;
  148180. /**
  148181. * Pushes an action to the worker pool. If all the workers are active, the action will be
  148182. * pended until a worker has completed its action.
  148183. * @param action The action to perform. Call onComplete when the action is complete.
  148184. */
  148185. push(action: (worker: Worker, onComplete: () => void) => void): void;
  148186. private _execute;
  148187. }
  148188. }
  148189. declare module BABYLON {
  148190. /**
  148191. * Class for loading KTX2 files
  148192. */
  148193. export class KhronosTextureContainer2 {
  148194. private static _WorkerPoolPromise?;
  148195. private static _Initialized;
  148196. private static _Ktx2Decoder;
  148197. /**
  148198. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  148199. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  148200. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  148201. * Urls you can change:
  148202. * URLConfig.jsDecoderModule
  148203. * URLConfig.wasmUASTCToASTC
  148204. * URLConfig.wasmUASTCToBC7
  148205. * URLConfig.wasmUASTCToRGBA_UNORM
  148206. * URLConfig.wasmUASTCToRGBA_SRGB
  148207. * URLConfig.jsMSCTranscoder
  148208. * URLConfig.wasmMSCTranscoder
  148209. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  148210. */
  148211. static URLConfig: {
  148212. jsDecoderModule: string;
  148213. wasmUASTCToASTC: null;
  148214. wasmUASTCToBC7: null;
  148215. wasmUASTCToRGBA_UNORM: null;
  148216. wasmUASTCToRGBA_SRGB: null;
  148217. jsMSCTranscoder: null;
  148218. wasmMSCTranscoder: null;
  148219. };
  148220. /**
  148221. * Default number of workers used to handle data decoding
  148222. */
  148223. static DefaultNumWorkers: number;
  148224. private static GetDefaultNumWorkers;
  148225. private _engine;
  148226. private static _CreateWorkerPool;
  148227. /**
  148228. * Constructor
  148229. * @param engine The engine to use
  148230. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  148231. */
  148232. constructor(engine: ThinEngine, numWorkers?: number);
  148233. /** @hidden */
  148234. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  148235. /**
  148236. * Stop all async operations and release resources.
  148237. */
  148238. dispose(): void;
  148239. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  148240. /**
  148241. * Checks if the given data starts with a KTX2 file identifier.
  148242. * @param data the data to check
  148243. * @returns true if the data is a KTX2 file or false otherwise
  148244. */
  148245. static IsValid(data: ArrayBufferView): boolean;
  148246. }
  148247. }
  148248. declare module BABYLON {
  148249. /**
  148250. * Implementation of the KTX Texture Loader.
  148251. * @hidden
  148252. */
  148253. export class _KTXTextureLoader implements IInternalTextureLoader {
  148254. /**
  148255. * Defines whether the loader supports cascade loading the different faces.
  148256. */
  148257. readonly supportCascades: boolean;
  148258. /**
  148259. * This returns if the loader support the current file information.
  148260. * @param extension defines the file extension of the file being loaded
  148261. * @param mimeType defines the optional mime type of the file being loaded
  148262. * @returns true if the loader can load the specified file
  148263. */
  148264. canLoad(extension: string, mimeType?: string): boolean;
  148265. /**
  148266. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  148267. * @param data contains the texture data
  148268. * @param texture defines the BabylonJS internal texture
  148269. * @param createPolynomials will be true if polynomials have been requested
  148270. * @param onLoad defines the callback to trigger once the texture is ready
  148271. * @param onError defines the callback to trigger in case of error
  148272. */
  148273. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  148274. /**
  148275. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  148276. * @param data contains the texture data
  148277. * @param texture defines the BabylonJS internal texture
  148278. * @param callback defines the method to call once ready to upload
  148279. */
  148280. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  148281. }
  148282. }
  148283. declare module BABYLON {
  148284. /** @hidden */
  148285. export var _forceSceneHelpersToBundle: boolean;
  148286. interface Scene {
  148287. /**
  148288. * Creates a default light for the scene.
  148289. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  148290. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  148291. */
  148292. createDefaultLight(replace?: boolean): void;
  148293. /**
  148294. * Creates a default camera for the scene.
  148295. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  148296. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  148297. * @param replace has default false, when true replaces the active camera in the scene
  148298. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  148299. */
  148300. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  148301. /**
  148302. * Creates a default camera and a default light.
  148303. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  148304. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  148305. * @param replace has the default false, when true replaces the active camera/light in the scene
  148306. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  148307. */
  148308. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  148309. /**
  148310. * Creates a new sky box
  148311. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  148312. * @param environmentTexture defines the texture to use as environment texture
  148313. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  148314. * @param scale defines the overall scale of the skybox
  148315. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  148316. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  148317. * @returns a new mesh holding the sky box
  148318. */
  148319. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  148320. /**
  148321. * Creates a new environment
  148322. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  148323. * @param options defines the options you can use to configure the environment
  148324. * @returns the new EnvironmentHelper
  148325. */
  148326. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  148327. /**
  148328. * Creates a new VREXperienceHelper
  148329. * @see https://doc.babylonjs.com/how_to/webvr_helper
  148330. * @param webVROptions defines the options used to create the new VREXperienceHelper
  148331. * @returns a new VREXperienceHelper
  148332. */
  148333. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  148334. /**
  148335. * Creates a new WebXRDefaultExperience
  148336. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  148337. * @param options experience options
  148338. * @returns a promise for a new WebXRDefaultExperience
  148339. */
  148340. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  148341. }
  148342. }
  148343. declare module BABYLON {
  148344. /**
  148345. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  148346. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  148347. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  148348. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  148349. */
  148350. export class VideoDome extends TextureDome<VideoTexture> {
  148351. /**
  148352. * Define the video source as a Monoscopic panoramic 360 video.
  148353. */
  148354. static readonly MODE_MONOSCOPIC: number;
  148355. /**
  148356. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  148357. */
  148358. static readonly MODE_TOPBOTTOM: number;
  148359. /**
  148360. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  148361. */
  148362. static readonly MODE_SIDEBYSIDE: number;
  148363. /**
  148364. * Get the video texture associated with this video dome
  148365. */
  148366. get videoTexture(): VideoTexture;
  148367. /**
  148368. * Get the video mode of this dome
  148369. */
  148370. get videoMode(): number;
  148371. /**
  148372. * Set the video mode of this dome.
  148373. * @see textureMode
  148374. */
  148375. set videoMode(value: number);
  148376. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  148377. }
  148378. }
  148379. declare module BABYLON {
  148380. /**
  148381. * This class can be used to get instrumentation data from a Babylon engine
  148382. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  148383. */
  148384. export class EngineInstrumentation implements IDisposable {
  148385. /**
  148386. * Define the instrumented engine.
  148387. */
  148388. engine: Engine;
  148389. private _captureGPUFrameTime;
  148390. private _gpuFrameTimeToken;
  148391. private _gpuFrameTime;
  148392. private _captureShaderCompilationTime;
  148393. private _shaderCompilationTime;
  148394. private _onBeginFrameObserver;
  148395. private _onEndFrameObserver;
  148396. private _onBeforeShaderCompilationObserver;
  148397. private _onAfterShaderCompilationObserver;
  148398. /**
  148399. * Gets the perf counter used for GPU frame time
  148400. */
  148401. get gpuFrameTimeCounter(): PerfCounter;
  148402. /**
  148403. * Gets the GPU frame time capture status
  148404. */
  148405. get captureGPUFrameTime(): boolean;
  148406. /**
  148407. * Enable or disable the GPU frame time capture
  148408. */
  148409. set captureGPUFrameTime(value: boolean);
  148410. /**
  148411. * Gets the perf counter used for shader compilation time
  148412. */
  148413. get shaderCompilationTimeCounter(): PerfCounter;
  148414. /**
  148415. * Gets the shader compilation time capture status
  148416. */
  148417. get captureShaderCompilationTime(): boolean;
  148418. /**
  148419. * Enable or disable the shader compilation time capture
  148420. */
  148421. set captureShaderCompilationTime(value: boolean);
  148422. /**
  148423. * Instantiates a new engine instrumentation.
  148424. * This class can be used to get instrumentation data from a Babylon engine
  148425. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  148426. * @param engine Defines the engine to instrument
  148427. */
  148428. constructor(
  148429. /**
  148430. * Define the instrumented engine.
  148431. */
  148432. engine: Engine);
  148433. /**
  148434. * Dispose and release associated resources.
  148435. */
  148436. dispose(): void;
  148437. }
  148438. }
  148439. declare module BABYLON {
  148440. /**
  148441. * This class can be used to get instrumentation data from a Babylon engine
  148442. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  148443. */
  148444. export class SceneInstrumentation implements IDisposable {
  148445. /**
  148446. * Defines the scene to instrument
  148447. */
  148448. scene: Scene;
  148449. private _captureActiveMeshesEvaluationTime;
  148450. private _activeMeshesEvaluationTime;
  148451. private _captureRenderTargetsRenderTime;
  148452. private _renderTargetsRenderTime;
  148453. private _captureFrameTime;
  148454. private _frameTime;
  148455. private _captureRenderTime;
  148456. private _renderTime;
  148457. private _captureInterFrameTime;
  148458. private _interFrameTime;
  148459. private _captureParticlesRenderTime;
  148460. private _particlesRenderTime;
  148461. private _captureSpritesRenderTime;
  148462. private _spritesRenderTime;
  148463. private _capturePhysicsTime;
  148464. private _physicsTime;
  148465. private _captureAnimationsTime;
  148466. private _animationsTime;
  148467. private _captureCameraRenderTime;
  148468. private _cameraRenderTime;
  148469. private _onBeforeActiveMeshesEvaluationObserver;
  148470. private _onAfterActiveMeshesEvaluationObserver;
  148471. private _onBeforeRenderTargetsRenderObserver;
  148472. private _onAfterRenderTargetsRenderObserver;
  148473. private _onAfterRenderObserver;
  148474. private _onBeforeDrawPhaseObserver;
  148475. private _onAfterDrawPhaseObserver;
  148476. private _onBeforeAnimationsObserver;
  148477. private _onBeforeParticlesRenderingObserver;
  148478. private _onAfterParticlesRenderingObserver;
  148479. private _onBeforeSpritesRenderingObserver;
  148480. private _onAfterSpritesRenderingObserver;
  148481. private _onBeforePhysicsObserver;
  148482. private _onAfterPhysicsObserver;
  148483. private _onAfterAnimationsObserver;
  148484. private _onBeforeCameraRenderObserver;
  148485. private _onAfterCameraRenderObserver;
  148486. /**
  148487. * Gets the perf counter used for active meshes evaluation time
  148488. */
  148489. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  148490. /**
  148491. * Gets the active meshes evaluation time capture status
  148492. */
  148493. get captureActiveMeshesEvaluationTime(): boolean;
  148494. /**
  148495. * Enable or disable the active meshes evaluation time capture
  148496. */
  148497. set captureActiveMeshesEvaluationTime(value: boolean);
  148498. /**
  148499. * Gets the perf counter used for render targets render time
  148500. */
  148501. get renderTargetsRenderTimeCounter(): PerfCounter;
  148502. /**
  148503. * Gets the render targets render time capture status
  148504. */
  148505. get captureRenderTargetsRenderTime(): boolean;
  148506. /**
  148507. * Enable or disable the render targets render time capture
  148508. */
  148509. set captureRenderTargetsRenderTime(value: boolean);
  148510. /**
  148511. * Gets the perf counter used for particles render time
  148512. */
  148513. get particlesRenderTimeCounter(): PerfCounter;
  148514. /**
  148515. * Gets the particles render time capture status
  148516. */
  148517. get captureParticlesRenderTime(): boolean;
  148518. /**
  148519. * Enable or disable the particles render time capture
  148520. */
  148521. set captureParticlesRenderTime(value: boolean);
  148522. /**
  148523. * Gets the perf counter used for sprites render time
  148524. */
  148525. get spritesRenderTimeCounter(): PerfCounter;
  148526. /**
  148527. * Gets the sprites render time capture status
  148528. */
  148529. get captureSpritesRenderTime(): boolean;
  148530. /**
  148531. * Enable or disable the sprites render time capture
  148532. */
  148533. set captureSpritesRenderTime(value: boolean);
  148534. /**
  148535. * Gets the perf counter used for physics time
  148536. */
  148537. get physicsTimeCounter(): PerfCounter;
  148538. /**
  148539. * Gets the physics time capture status
  148540. */
  148541. get capturePhysicsTime(): boolean;
  148542. /**
  148543. * Enable or disable the physics time capture
  148544. */
  148545. set capturePhysicsTime(value: boolean);
  148546. /**
  148547. * Gets the perf counter used for animations time
  148548. */
  148549. get animationsTimeCounter(): PerfCounter;
  148550. /**
  148551. * Gets the animations time capture status
  148552. */
  148553. get captureAnimationsTime(): boolean;
  148554. /**
  148555. * Enable or disable the animations time capture
  148556. */
  148557. set captureAnimationsTime(value: boolean);
  148558. /**
  148559. * Gets the perf counter used for frame time capture
  148560. */
  148561. get frameTimeCounter(): PerfCounter;
  148562. /**
  148563. * Gets the frame time capture status
  148564. */
  148565. get captureFrameTime(): boolean;
  148566. /**
  148567. * Enable or disable the frame time capture
  148568. */
  148569. set captureFrameTime(value: boolean);
  148570. /**
  148571. * Gets the perf counter used for inter-frames time capture
  148572. */
  148573. get interFrameTimeCounter(): PerfCounter;
  148574. /**
  148575. * Gets the inter-frames time capture status
  148576. */
  148577. get captureInterFrameTime(): boolean;
  148578. /**
  148579. * Enable or disable the inter-frames time capture
  148580. */
  148581. set captureInterFrameTime(value: boolean);
  148582. /**
  148583. * Gets the perf counter used for render time capture
  148584. */
  148585. get renderTimeCounter(): PerfCounter;
  148586. /**
  148587. * Gets the render time capture status
  148588. */
  148589. get captureRenderTime(): boolean;
  148590. /**
  148591. * Enable or disable the render time capture
  148592. */
  148593. set captureRenderTime(value: boolean);
  148594. /**
  148595. * Gets the perf counter used for camera render time capture
  148596. */
  148597. get cameraRenderTimeCounter(): PerfCounter;
  148598. /**
  148599. * Gets the camera render time capture status
  148600. */
  148601. get captureCameraRenderTime(): boolean;
  148602. /**
  148603. * Enable or disable the camera render time capture
  148604. */
  148605. set captureCameraRenderTime(value: boolean);
  148606. /**
  148607. * Gets the perf counter used for draw calls
  148608. */
  148609. get drawCallsCounter(): PerfCounter;
  148610. /**
  148611. * Instantiates a new scene instrumentation.
  148612. * This class can be used to get instrumentation data from a Babylon engine
  148613. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  148614. * @param scene Defines the scene to instrument
  148615. */
  148616. constructor(
  148617. /**
  148618. * Defines the scene to instrument
  148619. */
  148620. scene: Scene);
  148621. /**
  148622. * Dispose and release associated resources.
  148623. */
  148624. dispose(): void;
  148625. }
  148626. }
  148627. declare module BABYLON {
  148628. /** @hidden */
  148629. export var glowMapGenerationPixelShader: {
  148630. name: string;
  148631. shader: string;
  148632. };
  148633. }
  148634. declare module BABYLON {
  148635. /** @hidden */
  148636. export var glowMapGenerationVertexShader: {
  148637. name: string;
  148638. shader: string;
  148639. };
  148640. }
  148641. declare module BABYLON {
  148642. /**
  148643. * Effect layer options. This helps customizing the behaviour
  148644. * of the effect layer.
  148645. */
  148646. export interface IEffectLayerOptions {
  148647. /**
  148648. * Multiplication factor apply to the canvas size to compute the render target size
  148649. * used to generated the objects (the smaller the faster).
  148650. */
  148651. mainTextureRatio: number;
  148652. /**
  148653. * Enforces a fixed size texture to ensure effect stability across devices.
  148654. */
  148655. mainTextureFixedSize?: number;
  148656. /**
  148657. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  148658. */
  148659. alphaBlendingMode: number;
  148660. /**
  148661. * The camera attached to the layer.
  148662. */
  148663. camera: Nullable<Camera>;
  148664. /**
  148665. * The rendering group to draw the layer in.
  148666. */
  148667. renderingGroupId: number;
  148668. }
  148669. /**
  148670. * The effect layer Helps adding post process effect blended with the main pass.
  148671. *
  148672. * This can be for instance use to generate glow or highlight effects on the scene.
  148673. *
  148674. * The effect layer class can not be used directly and is intented to inherited from to be
  148675. * customized per effects.
  148676. */
  148677. export abstract class EffectLayer {
  148678. private _vertexBuffers;
  148679. private _indexBuffer;
  148680. private _cachedDefines;
  148681. private _effectLayerMapGenerationEffect;
  148682. private _effectLayerOptions;
  148683. private _mergeEffect;
  148684. protected _scene: Scene;
  148685. protected _engine: Engine;
  148686. protected _maxSize: number;
  148687. protected _mainTextureDesiredSize: ISize;
  148688. protected _mainTexture: RenderTargetTexture;
  148689. protected _shouldRender: boolean;
  148690. protected _postProcesses: PostProcess[];
  148691. protected _textures: BaseTexture[];
  148692. protected _emissiveTextureAndColor: {
  148693. texture: Nullable<BaseTexture>;
  148694. color: Color4;
  148695. };
  148696. /**
  148697. * The name of the layer
  148698. */
  148699. name: string;
  148700. /**
  148701. * The clear color of the texture used to generate the glow map.
  148702. */
  148703. neutralColor: Color4;
  148704. /**
  148705. * Specifies whether the highlight layer is enabled or not.
  148706. */
  148707. isEnabled: boolean;
  148708. /**
  148709. * Gets the camera attached to the layer.
  148710. */
  148711. get camera(): Nullable<Camera>;
  148712. /**
  148713. * Gets the rendering group id the layer should render in.
  148714. */
  148715. get renderingGroupId(): number;
  148716. set renderingGroupId(renderingGroupId: number);
  148717. /**
  148718. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  148719. */
  148720. disableBoundingBoxesFromEffectLayer: boolean;
  148721. /**
  148722. * An event triggered when the effect layer has been disposed.
  148723. */
  148724. onDisposeObservable: Observable<EffectLayer>;
  148725. /**
  148726. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  148727. */
  148728. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  148729. /**
  148730. * An event triggered when the generated texture is being merged in the scene.
  148731. */
  148732. onBeforeComposeObservable: Observable<EffectLayer>;
  148733. /**
  148734. * An event triggered when the mesh is rendered into the effect render target.
  148735. */
  148736. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  148737. /**
  148738. * An event triggered after the mesh has been rendered into the effect render target.
  148739. */
  148740. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  148741. /**
  148742. * An event triggered when the generated texture has been merged in the scene.
  148743. */
  148744. onAfterComposeObservable: Observable<EffectLayer>;
  148745. /**
  148746. * An event triggered when the effect layer changes its size.
  148747. */
  148748. onSizeChangedObservable: Observable<EffectLayer>;
  148749. /** @hidden */
  148750. static _SceneComponentInitialization: (scene: Scene) => void;
  148751. /**
  148752. * Instantiates a new effect Layer and references it in the scene.
  148753. * @param name The name of the layer
  148754. * @param scene The scene to use the layer in
  148755. */
  148756. constructor(
  148757. /** The Friendly of the effect in the scene */
  148758. name: string, scene: Scene);
  148759. /**
  148760. * Get the effect name of the layer.
  148761. * @return The effect name
  148762. */
  148763. abstract getEffectName(): string;
  148764. /**
  148765. * Checks for the readiness of the element composing the layer.
  148766. * @param subMesh the mesh to check for
  148767. * @param useInstances specify whether or not to use instances to render the mesh
  148768. * @return true if ready otherwise, false
  148769. */
  148770. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148771. /**
  148772. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  148773. * @returns true if the effect requires stencil during the main canvas render pass.
  148774. */
  148775. abstract needStencil(): boolean;
  148776. /**
  148777. * Create the merge effect. This is the shader use to blit the information back
  148778. * to the main canvas at the end of the scene rendering.
  148779. * @returns The effect containing the shader used to merge the effect on the main canvas
  148780. */
  148781. protected abstract _createMergeEffect(): Effect;
  148782. /**
  148783. * Creates the render target textures and post processes used in the effect layer.
  148784. */
  148785. protected abstract _createTextureAndPostProcesses(): void;
  148786. /**
  148787. * Implementation specific of rendering the generating effect on the main canvas.
  148788. * @param effect The effect used to render through
  148789. */
  148790. protected abstract _internalRender(effect: Effect): void;
  148791. /**
  148792. * Sets the required values for both the emissive texture and and the main color.
  148793. */
  148794. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  148795. /**
  148796. * Free any resources and references associated to a mesh.
  148797. * Internal use
  148798. * @param mesh The mesh to free.
  148799. */
  148800. abstract _disposeMesh(mesh: Mesh): void;
  148801. /**
  148802. * Serializes this layer (Glow or Highlight for example)
  148803. * @returns a serialized layer object
  148804. */
  148805. abstract serialize?(): any;
  148806. /**
  148807. * Initializes the effect layer with the required options.
  148808. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  148809. */
  148810. protected _init(options: Partial<IEffectLayerOptions>): void;
  148811. /**
  148812. * Generates the index buffer of the full screen quad blending to the main canvas.
  148813. */
  148814. private _generateIndexBuffer;
  148815. /**
  148816. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  148817. */
  148818. private _generateVertexBuffer;
  148819. /**
  148820. * Sets the main texture desired size which is the closest power of two
  148821. * of the engine canvas size.
  148822. */
  148823. private _setMainTextureSize;
  148824. /**
  148825. * Creates the main texture for the effect layer.
  148826. */
  148827. protected _createMainTexture(): void;
  148828. /**
  148829. * Adds specific effects defines.
  148830. * @param defines The defines to add specifics to.
  148831. */
  148832. protected _addCustomEffectDefines(defines: string[]): void;
  148833. /**
  148834. * Checks for the readiness of the element composing the layer.
  148835. * @param subMesh the mesh to check for
  148836. * @param useInstances specify whether or not to use instances to render the mesh
  148837. * @param emissiveTexture the associated emissive texture used to generate the glow
  148838. * @return true if ready otherwise, false
  148839. */
  148840. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  148841. /**
  148842. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  148843. */
  148844. render(): void;
  148845. /**
  148846. * Determine if a given mesh will be used in the current effect.
  148847. * @param mesh mesh to test
  148848. * @returns true if the mesh will be used
  148849. */
  148850. hasMesh(mesh: AbstractMesh): boolean;
  148851. /**
  148852. * Returns true if the layer contains information to display, otherwise false.
  148853. * @returns true if the glow layer should be rendered
  148854. */
  148855. shouldRender(): boolean;
  148856. /**
  148857. * Returns true if the mesh should render, otherwise false.
  148858. * @param mesh The mesh to render
  148859. * @returns true if it should render otherwise false
  148860. */
  148861. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  148862. /**
  148863. * Returns true if the mesh can be rendered, otherwise false.
  148864. * @param mesh The mesh to render
  148865. * @param material The material used on the mesh
  148866. * @returns true if it can be rendered otherwise false
  148867. */
  148868. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  148869. /**
  148870. * Returns true if the mesh should render, otherwise false.
  148871. * @param mesh The mesh to render
  148872. * @returns true if it should render otherwise false
  148873. */
  148874. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  148875. /**
  148876. * Renders the submesh passed in parameter to the generation map.
  148877. */
  148878. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  148879. /**
  148880. * Defines whether the current material of the mesh should be use to render the effect.
  148881. * @param mesh defines the current mesh to render
  148882. */
  148883. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  148884. /**
  148885. * Rebuild the required buffers.
  148886. * @hidden Internal use only.
  148887. */
  148888. _rebuild(): void;
  148889. /**
  148890. * Dispose only the render target textures and post process.
  148891. */
  148892. private _disposeTextureAndPostProcesses;
  148893. /**
  148894. * Dispose the highlight layer and free resources.
  148895. */
  148896. dispose(): void;
  148897. /**
  148898. * Gets the class name of the effect layer
  148899. * @returns the string with the class name of the effect layer
  148900. */
  148901. getClassName(): string;
  148902. /**
  148903. * Creates an effect layer from parsed effect layer data
  148904. * @param parsedEffectLayer defines effect layer data
  148905. * @param scene defines the current scene
  148906. * @param rootUrl defines the root URL containing the effect layer information
  148907. * @returns a parsed effect Layer
  148908. */
  148909. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  148910. }
  148911. }
  148912. declare module BABYLON {
  148913. interface AbstractScene {
  148914. /**
  148915. * The list of effect layers (highlights/glow) added to the scene
  148916. * @see https://doc.babylonjs.com/how_to/highlight_layer
  148917. * @see https://doc.babylonjs.com/how_to/glow_layer
  148918. */
  148919. effectLayers: Array<EffectLayer>;
  148920. /**
  148921. * Removes the given effect layer from this scene.
  148922. * @param toRemove defines the effect layer to remove
  148923. * @returns the index of the removed effect layer
  148924. */
  148925. removeEffectLayer(toRemove: EffectLayer): number;
  148926. /**
  148927. * Adds the given effect layer to this scene
  148928. * @param newEffectLayer defines the effect layer to add
  148929. */
  148930. addEffectLayer(newEffectLayer: EffectLayer): void;
  148931. }
  148932. /**
  148933. * Defines the layer scene component responsible to manage any effect layers
  148934. * in a given scene.
  148935. */
  148936. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  148937. /**
  148938. * The component name helpful to identify the component in the list of scene components.
  148939. */
  148940. readonly name: string;
  148941. /**
  148942. * The scene the component belongs to.
  148943. */
  148944. scene: Scene;
  148945. private _engine;
  148946. private _renderEffects;
  148947. private _needStencil;
  148948. private _previousStencilState;
  148949. /**
  148950. * Creates a new instance of the component for the given scene
  148951. * @param scene Defines the scene to register the component in
  148952. */
  148953. constructor(scene: Scene);
  148954. /**
  148955. * Registers the component in a given scene
  148956. */
  148957. register(): void;
  148958. /**
  148959. * Rebuilds the elements related to this component in case of
  148960. * context lost for instance.
  148961. */
  148962. rebuild(): void;
  148963. /**
  148964. * Serializes the component data to the specified json object
  148965. * @param serializationObject The object to serialize to
  148966. */
  148967. serialize(serializationObject: any): void;
  148968. /**
  148969. * Adds all the elements from the container to the scene
  148970. * @param container the container holding the elements
  148971. */
  148972. addFromContainer(container: AbstractScene): void;
  148973. /**
  148974. * Removes all the elements in the container from the scene
  148975. * @param container contains the elements to remove
  148976. * @param dispose if the removed element should be disposed (default: false)
  148977. */
  148978. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148979. /**
  148980. * Disposes the component and the associated resources.
  148981. */
  148982. dispose(): void;
  148983. private _isReadyForMesh;
  148984. private _renderMainTexture;
  148985. private _setStencil;
  148986. private _setStencilBack;
  148987. private _draw;
  148988. private _drawCamera;
  148989. private _drawRenderingGroup;
  148990. }
  148991. }
  148992. declare module BABYLON {
  148993. /** @hidden */
  148994. export var glowMapMergePixelShader: {
  148995. name: string;
  148996. shader: string;
  148997. };
  148998. }
  148999. declare module BABYLON {
  149000. /** @hidden */
  149001. export var glowMapMergeVertexShader: {
  149002. name: string;
  149003. shader: string;
  149004. };
  149005. }
  149006. declare module BABYLON {
  149007. interface AbstractScene {
  149008. /**
  149009. * Return a the first highlight layer of the scene with a given name.
  149010. * @param name The name of the highlight layer to look for.
  149011. * @return The highlight layer if found otherwise null.
  149012. */
  149013. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  149014. }
  149015. /**
  149016. * Glow layer options. This helps customizing the behaviour
  149017. * of the glow layer.
  149018. */
  149019. export interface IGlowLayerOptions {
  149020. /**
  149021. * Multiplication factor apply to the canvas size to compute the render target size
  149022. * used to generated the glowing objects (the smaller the faster).
  149023. */
  149024. mainTextureRatio: number;
  149025. /**
  149026. * Enforces a fixed size texture to ensure resize independent blur.
  149027. */
  149028. mainTextureFixedSize?: number;
  149029. /**
  149030. * How big is the kernel of the blur texture.
  149031. */
  149032. blurKernelSize: number;
  149033. /**
  149034. * The camera attached to the layer.
  149035. */
  149036. camera: Nullable<Camera>;
  149037. /**
  149038. * Enable MSAA by choosing the number of samples.
  149039. */
  149040. mainTextureSamples?: number;
  149041. /**
  149042. * The rendering group to draw the layer in.
  149043. */
  149044. renderingGroupId: number;
  149045. }
  149046. /**
  149047. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  149048. *
  149049. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  149050. *
  149051. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  149052. */
  149053. export class GlowLayer extends EffectLayer {
  149054. /**
  149055. * Effect Name of the layer.
  149056. */
  149057. static readonly EffectName: string;
  149058. /**
  149059. * The default blur kernel size used for the glow.
  149060. */
  149061. static DefaultBlurKernelSize: number;
  149062. /**
  149063. * The default texture size ratio used for the glow.
  149064. */
  149065. static DefaultTextureRatio: number;
  149066. /**
  149067. * Sets the kernel size of the blur.
  149068. */
  149069. set blurKernelSize(value: number);
  149070. /**
  149071. * Gets the kernel size of the blur.
  149072. */
  149073. get blurKernelSize(): number;
  149074. /**
  149075. * Sets the glow intensity.
  149076. */
  149077. set intensity(value: number);
  149078. /**
  149079. * Gets the glow intensity.
  149080. */
  149081. get intensity(): number;
  149082. private _options;
  149083. private _intensity;
  149084. private _horizontalBlurPostprocess1;
  149085. private _verticalBlurPostprocess1;
  149086. private _horizontalBlurPostprocess2;
  149087. private _verticalBlurPostprocess2;
  149088. private _blurTexture1;
  149089. private _blurTexture2;
  149090. private _postProcesses1;
  149091. private _postProcesses2;
  149092. private _includedOnlyMeshes;
  149093. private _excludedMeshes;
  149094. private _meshesUsingTheirOwnMaterials;
  149095. /**
  149096. * Callback used to let the user override the color selection on a per mesh basis
  149097. */
  149098. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  149099. /**
  149100. * Callback used to let the user override the texture selection on a per mesh basis
  149101. */
  149102. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  149103. /**
  149104. * Instantiates a new glow Layer and references it to the scene.
  149105. * @param name The name of the layer
  149106. * @param scene The scene to use the layer in
  149107. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  149108. */
  149109. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  149110. /**
  149111. * Get the effect name of the layer.
  149112. * @return The effect name
  149113. */
  149114. getEffectName(): string;
  149115. /**
  149116. * Create the merge effect. This is the shader use to blit the information back
  149117. * to the main canvas at the end of the scene rendering.
  149118. */
  149119. protected _createMergeEffect(): Effect;
  149120. /**
  149121. * Creates the render target textures and post processes used in the glow layer.
  149122. */
  149123. protected _createTextureAndPostProcesses(): void;
  149124. /**
  149125. * Checks for the readiness of the element composing the layer.
  149126. * @param subMesh the mesh to check for
  149127. * @param useInstances specify whether or not to use instances to render the mesh
  149128. * @param emissiveTexture the associated emissive texture used to generate the glow
  149129. * @return true if ready otherwise, false
  149130. */
  149131. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149132. /**
  149133. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  149134. */
  149135. needStencil(): boolean;
  149136. /**
  149137. * Returns true if the mesh can be rendered, otherwise false.
  149138. * @param mesh The mesh to render
  149139. * @param material The material used on the mesh
  149140. * @returns true if it can be rendered otherwise false
  149141. */
  149142. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  149143. /**
  149144. * Implementation specific of rendering the generating effect on the main canvas.
  149145. * @param effect The effect used to render through
  149146. */
  149147. protected _internalRender(effect: Effect): void;
  149148. /**
  149149. * Sets the required values for both the emissive texture and and the main color.
  149150. */
  149151. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  149152. /**
  149153. * Returns true if the mesh should render, otherwise false.
  149154. * @param mesh The mesh to render
  149155. * @returns true if it should render otherwise false
  149156. */
  149157. protected _shouldRenderMesh(mesh: Mesh): boolean;
  149158. /**
  149159. * Adds specific effects defines.
  149160. * @param defines The defines to add specifics to.
  149161. */
  149162. protected _addCustomEffectDefines(defines: string[]): void;
  149163. /**
  149164. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  149165. * @param mesh The mesh to exclude from the glow layer
  149166. */
  149167. addExcludedMesh(mesh: Mesh): void;
  149168. /**
  149169. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  149170. * @param mesh The mesh to remove
  149171. */
  149172. removeExcludedMesh(mesh: Mesh): void;
  149173. /**
  149174. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  149175. * @param mesh The mesh to include in the glow layer
  149176. */
  149177. addIncludedOnlyMesh(mesh: Mesh): void;
  149178. /**
  149179. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  149180. * @param mesh The mesh to remove
  149181. */
  149182. removeIncludedOnlyMesh(mesh: Mesh): void;
  149183. /**
  149184. * Determine if a given mesh will be used in the glow layer
  149185. * @param mesh The mesh to test
  149186. * @returns true if the mesh will be highlighted by the current glow layer
  149187. */
  149188. hasMesh(mesh: AbstractMesh): boolean;
  149189. /**
  149190. * Defines whether the current material of the mesh should be use to render the effect.
  149191. * @param mesh defines the current mesh to render
  149192. */
  149193. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  149194. /**
  149195. * Add a mesh to be rendered through its own material and not with emissive only.
  149196. * @param mesh The mesh for which we need to use its material
  149197. */
  149198. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  149199. /**
  149200. * Remove a mesh from being rendered through its own material and not with emissive only.
  149201. * @param mesh The mesh for which we need to not use its material
  149202. */
  149203. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  149204. /**
  149205. * Free any resources and references associated to a mesh.
  149206. * Internal use
  149207. * @param mesh The mesh to free.
  149208. * @hidden
  149209. */
  149210. _disposeMesh(mesh: Mesh): void;
  149211. /**
  149212. * Gets the class name of the effect layer
  149213. * @returns the string with the class name of the effect layer
  149214. */
  149215. getClassName(): string;
  149216. /**
  149217. * Serializes this glow layer
  149218. * @returns a serialized glow layer object
  149219. */
  149220. serialize(): any;
  149221. /**
  149222. * Creates a Glow Layer from parsed glow layer data
  149223. * @param parsedGlowLayer defines glow layer data
  149224. * @param scene defines the current scene
  149225. * @param rootUrl defines the root URL containing the glow layer information
  149226. * @returns a parsed Glow Layer
  149227. */
  149228. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  149229. }
  149230. }
  149231. declare module BABYLON {
  149232. /** @hidden */
  149233. export var glowBlurPostProcessPixelShader: {
  149234. name: string;
  149235. shader: string;
  149236. };
  149237. }
  149238. declare module BABYLON {
  149239. interface AbstractScene {
  149240. /**
  149241. * Return a the first highlight layer of the scene with a given name.
  149242. * @param name The name of the highlight layer to look for.
  149243. * @return The highlight layer if found otherwise null.
  149244. */
  149245. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  149246. }
  149247. /**
  149248. * Highlight layer options. This helps customizing the behaviour
  149249. * of the highlight layer.
  149250. */
  149251. export interface IHighlightLayerOptions {
  149252. /**
  149253. * Multiplication factor apply to the canvas size to compute the render target size
  149254. * used to generated the glowing objects (the smaller the faster).
  149255. */
  149256. mainTextureRatio: number;
  149257. /**
  149258. * Enforces a fixed size texture to ensure resize independent blur.
  149259. */
  149260. mainTextureFixedSize?: number;
  149261. /**
  149262. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  149263. * of the picture to blur (the smaller the faster).
  149264. */
  149265. blurTextureSizeRatio: number;
  149266. /**
  149267. * How big in texel of the blur texture is the vertical blur.
  149268. */
  149269. blurVerticalSize: number;
  149270. /**
  149271. * How big in texel of the blur texture is the horizontal blur.
  149272. */
  149273. blurHorizontalSize: number;
  149274. /**
  149275. * Alpha blending mode used to apply the blur. Default is combine.
  149276. */
  149277. alphaBlendingMode: number;
  149278. /**
  149279. * The camera attached to the layer.
  149280. */
  149281. camera: Nullable<Camera>;
  149282. /**
  149283. * Should we display highlight as a solid stroke?
  149284. */
  149285. isStroke?: boolean;
  149286. /**
  149287. * The rendering group to draw the layer in.
  149288. */
  149289. renderingGroupId: number;
  149290. }
  149291. /**
  149292. * The highlight layer Helps adding a glow effect around a mesh.
  149293. *
  149294. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  149295. * glowy meshes to your scene.
  149296. *
  149297. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  149298. */
  149299. export class HighlightLayer extends EffectLayer {
  149300. name: string;
  149301. /**
  149302. * Effect Name of the highlight layer.
  149303. */
  149304. static readonly EffectName: string;
  149305. /**
  149306. * The neutral color used during the preparation of the glow effect.
  149307. * This is black by default as the blend operation is a blend operation.
  149308. */
  149309. static NeutralColor: Color4;
  149310. /**
  149311. * Stencil value used for glowing meshes.
  149312. */
  149313. static GlowingMeshStencilReference: number;
  149314. /**
  149315. * Stencil value used for the other meshes in the scene.
  149316. */
  149317. static NormalMeshStencilReference: number;
  149318. /**
  149319. * Specifies whether or not the inner glow is ACTIVE in the layer.
  149320. */
  149321. innerGlow: boolean;
  149322. /**
  149323. * Specifies whether or not the outer glow is ACTIVE in the layer.
  149324. */
  149325. outerGlow: boolean;
  149326. /**
  149327. * Specifies the horizontal size of the blur.
  149328. */
  149329. set blurHorizontalSize(value: number);
  149330. /**
  149331. * Specifies the vertical size of the blur.
  149332. */
  149333. set blurVerticalSize(value: number);
  149334. /**
  149335. * Gets the horizontal size of the blur.
  149336. */
  149337. get blurHorizontalSize(): number;
  149338. /**
  149339. * Gets the vertical size of the blur.
  149340. */
  149341. get blurVerticalSize(): number;
  149342. /**
  149343. * An event triggered when the highlight layer is being blurred.
  149344. */
  149345. onBeforeBlurObservable: Observable<HighlightLayer>;
  149346. /**
  149347. * An event triggered when the highlight layer has been blurred.
  149348. */
  149349. onAfterBlurObservable: Observable<HighlightLayer>;
  149350. private _instanceGlowingMeshStencilReference;
  149351. private _options;
  149352. private _downSamplePostprocess;
  149353. private _horizontalBlurPostprocess;
  149354. private _verticalBlurPostprocess;
  149355. private _blurTexture;
  149356. private _meshes;
  149357. private _excludedMeshes;
  149358. /**
  149359. * Instantiates a new highlight Layer and references it to the scene..
  149360. * @param name The name of the layer
  149361. * @param scene The scene to use the layer in
  149362. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  149363. */
  149364. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  149365. /**
  149366. * Get the effect name of the layer.
  149367. * @return The effect name
  149368. */
  149369. getEffectName(): string;
  149370. /**
  149371. * Create the merge effect. This is the shader use to blit the information back
  149372. * to the main canvas at the end of the scene rendering.
  149373. */
  149374. protected _createMergeEffect(): Effect;
  149375. /**
  149376. * Creates the render target textures and post processes used in the highlight layer.
  149377. */
  149378. protected _createTextureAndPostProcesses(): void;
  149379. /**
  149380. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  149381. */
  149382. needStencil(): boolean;
  149383. /**
  149384. * Checks for the readiness of the element composing the layer.
  149385. * @param subMesh the mesh to check for
  149386. * @param useInstances specify wether or not to use instances to render the mesh
  149387. * @param emissiveTexture the associated emissive texture used to generate the glow
  149388. * @return true if ready otherwise, false
  149389. */
  149390. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149391. /**
  149392. * Implementation specific of rendering the generating effect on the main canvas.
  149393. * @param effect The effect used to render through
  149394. */
  149395. protected _internalRender(effect: Effect): void;
  149396. /**
  149397. * Returns true if the layer contains information to display, otherwise false.
  149398. */
  149399. shouldRender(): boolean;
  149400. /**
  149401. * Returns true if the mesh should render, otherwise false.
  149402. * @param mesh The mesh to render
  149403. * @returns true if it should render otherwise false
  149404. */
  149405. protected _shouldRenderMesh(mesh: Mesh): boolean;
  149406. /**
  149407. * Returns true if the mesh can be rendered, otherwise false.
  149408. * @param mesh The mesh to render
  149409. * @param material The material used on the mesh
  149410. * @returns true if it can be rendered otherwise false
  149411. */
  149412. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  149413. /**
  149414. * Adds specific effects defines.
  149415. * @param defines The defines to add specifics to.
  149416. */
  149417. protected _addCustomEffectDefines(defines: string[]): void;
  149418. /**
  149419. * Sets the required values for both the emissive texture and and the main color.
  149420. */
  149421. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  149422. /**
  149423. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  149424. * @param mesh The mesh to exclude from the highlight layer
  149425. */
  149426. addExcludedMesh(mesh: Mesh): void;
  149427. /**
  149428. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  149429. * @param mesh The mesh to highlight
  149430. */
  149431. removeExcludedMesh(mesh: Mesh): void;
  149432. /**
  149433. * Determine if a given mesh will be highlighted by the current HighlightLayer
  149434. * @param mesh mesh to test
  149435. * @returns true if the mesh will be highlighted by the current HighlightLayer
  149436. */
  149437. hasMesh(mesh: AbstractMesh): boolean;
  149438. /**
  149439. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  149440. * @param mesh The mesh to highlight
  149441. * @param color The color of the highlight
  149442. * @param glowEmissiveOnly Extract the glow from the emissive texture
  149443. */
  149444. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  149445. /**
  149446. * Remove a mesh from the highlight layer in order to make it stop glowing.
  149447. * @param mesh The mesh to highlight
  149448. */
  149449. removeMesh(mesh: Mesh): void;
  149450. /**
  149451. * Remove all the meshes currently referenced in the highlight layer
  149452. */
  149453. removeAllMeshes(): void;
  149454. /**
  149455. * Force the stencil to the normal expected value for none glowing parts
  149456. */
  149457. private _defaultStencilReference;
  149458. /**
  149459. * Free any resources and references associated to a mesh.
  149460. * Internal use
  149461. * @param mesh The mesh to free.
  149462. * @hidden
  149463. */
  149464. _disposeMesh(mesh: Mesh): void;
  149465. /**
  149466. * Dispose the highlight layer and free resources.
  149467. */
  149468. dispose(): void;
  149469. /**
  149470. * Gets the class name of the effect layer
  149471. * @returns the string with the class name of the effect layer
  149472. */
  149473. getClassName(): string;
  149474. /**
  149475. * Serializes this Highlight layer
  149476. * @returns a serialized Highlight layer object
  149477. */
  149478. serialize(): any;
  149479. /**
  149480. * Creates a Highlight layer from parsed Highlight layer data
  149481. * @param parsedHightlightLayer defines the Highlight layer data
  149482. * @param scene defines the current scene
  149483. * @param rootUrl defines the root URL containing the Highlight layer information
  149484. * @returns a parsed Highlight layer
  149485. */
  149486. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  149487. }
  149488. }
  149489. declare module BABYLON {
  149490. interface AbstractScene {
  149491. /**
  149492. * The list of layers (background and foreground) of the scene
  149493. */
  149494. layers: Array<Layer>;
  149495. }
  149496. /**
  149497. * Defines the layer scene component responsible to manage any layers
  149498. * in a given scene.
  149499. */
  149500. export class LayerSceneComponent implements ISceneComponent {
  149501. /**
  149502. * The component name helpful to identify the component in the list of scene components.
  149503. */
  149504. readonly name: string;
  149505. /**
  149506. * The scene the component belongs to.
  149507. */
  149508. scene: Scene;
  149509. private _engine;
  149510. /**
  149511. * Creates a new instance of the component for the given scene
  149512. * @param scene Defines the scene to register the component in
  149513. */
  149514. constructor(scene: Scene);
  149515. /**
  149516. * Registers the component in a given scene
  149517. */
  149518. register(): void;
  149519. /**
  149520. * Rebuilds the elements related to this component in case of
  149521. * context lost for instance.
  149522. */
  149523. rebuild(): void;
  149524. /**
  149525. * Disposes the component and the associated resources.
  149526. */
  149527. dispose(): void;
  149528. private _draw;
  149529. private _drawCameraPredicate;
  149530. private _drawCameraBackground;
  149531. private _drawCameraForeground;
  149532. private _drawRenderTargetPredicate;
  149533. private _drawRenderTargetBackground;
  149534. private _drawRenderTargetForeground;
  149535. /**
  149536. * Adds all the elements from the container to the scene
  149537. * @param container the container holding the elements
  149538. */
  149539. addFromContainer(container: AbstractScene): void;
  149540. /**
  149541. * Removes all the elements in the container from the scene
  149542. * @param container contains the elements to remove
  149543. * @param dispose if the removed element should be disposed (default: false)
  149544. */
  149545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149546. }
  149547. }
  149548. declare module BABYLON {
  149549. /** @hidden */
  149550. export var layerPixelShader: {
  149551. name: string;
  149552. shader: string;
  149553. };
  149554. }
  149555. declare module BABYLON {
  149556. /** @hidden */
  149557. export var layerVertexShader: {
  149558. name: string;
  149559. shader: string;
  149560. };
  149561. }
  149562. declare module BABYLON {
  149563. /**
  149564. * This represents a full screen 2d layer.
  149565. * This can be useful to display a picture in the background of your scene for instance.
  149566. * @see https://www.babylonjs-playground.com/#08A2BS#1
  149567. */
  149568. export class Layer {
  149569. /**
  149570. * Define the name of the layer.
  149571. */
  149572. name: string;
  149573. /**
  149574. * Define the texture the layer should display.
  149575. */
  149576. texture: Nullable<Texture>;
  149577. /**
  149578. * Is the layer in background or foreground.
  149579. */
  149580. isBackground: boolean;
  149581. /**
  149582. * Define the color of the layer (instead of texture).
  149583. */
  149584. color: Color4;
  149585. /**
  149586. * Define the scale of the layer in order to zoom in out of the texture.
  149587. */
  149588. scale: Vector2;
  149589. /**
  149590. * Define an offset for the layer in order to shift the texture.
  149591. */
  149592. offset: Vector2;
  149593. /**
  149594. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  149595. */
  149596. alphaBlendingMode: number;
  149597. /**
  149598. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  149599. * Alpha test will not mix with the background color in case of transparency.
  149600. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  149601. */
  149602. alphaTest: boolean;
  149603. /**
  149604. * Define a mask to restrict the layer to only some of the scene cameras.
  149605. */
  149606. layerMask: number;
  149607. /**
  149608. * Define the list of render target the layer is visible into.
  149609. */
  149610. renderTargetTextures: RenderTargetTexture[];
  149611. /**
  149612. * Define if the layer is only used in renderTarget or if it also
  149613. * renders in the main frame buffer of the canvas.
  149614. */
  149615. renderOnlyInRenderTargetTextures: boolean;
  149616. private _scene;
  149617. private _vertexBuffers;
  149618. private _indexBuffer;
  149619. private _effect;
  149620. private _previousDefines;
  149621. /**
  149622. * An event triggered when the layer is disposed.
  149623. */
  149624. onDisposeObservable: Observable<Layer>;
  149625. private _onDisposeObserver;
  149626. /**
  149627. * Back compatibility with callback before the onDisposeObservable existed.
  149628. * The set callback will be triggered when the layer has been disposed.
  149629. */
  149630. set onDispose(callback: () => void);
  149631. /**
  149632. * An event triggered before rendering the scene
  149633. */
  149634. onBeforeRenderObservable: Observable<Layer>;
  149635. private _onBeforeRenderObserver;
  149636. /**
  149637. * Back compatibility with callback before the onBeforeRenderObservable existed.
  149638. * The set callback will be triggered just before rendering the layer.
  149639. */
  149640. set onBeforeRender(callback: () => void);
  149641. /**
  149642. * An event triggered after rendering the scene
  149643. */
  149644. onAfterRenderObservable: Observable<Layer>;
  149645. private _onAfterRenderObserver;
  149646. /**
  149647. * Back compatibility with callback before the onAfterRenderObservable existed.
  149648. * The set callback will be triggered just after rendering the layer.
  149649. */
  149650. set onAfterRender(callback: () => void);
  149651. /**
  149652. * Instantiates a new layer.
  149653. * This represents a full screen 2d layer.
  149654. * This can be useful to display a picture in the background of your scene for instance.
  149655. * @see https://www.babylonjs-playground.com/#08A2BS#1
  149656. * @param name Define the name of the layer in the scene
  149657. * @param imgUrl Define the url of the texture to display in the layer
  149658. * @param scene Define the scene the layer belongs to
  149659. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  149660. * @param color Defines a color for the layer
  149661. */
  149662. constructor(
  149663. /**
  149664. * Define the name of the layer.
  149665. */
  149666. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  149667. private _createIndexBuffer;
  149668. /** @hidden */
  149669. _rebuild(): void;
  149670. /**
  149671. * Renders the layer in the scene.
  149672. */
  149673. render(): void;
  149674. /**
  149675. * Disposes and releases the associated resources.
  149676. */
  149677. dispose(): void;
  149678. }
  149679. }
  149680. declare module BABYLON {
  149681. /** @hidden */
  149682. export var lensFlarePixelShader: {
  149683. name: string;
  149684. shader: string;
  149685. };
  149686. }
  149687. declare module BABYLON {
  149688. /** @hidden */
  149689. export var lensFlareVertexShader: {
  149690. name: string;
  149691. shader: string;
  149692. };
  149693. }
  149694. declare module BABYLON {
  149695. /**
  149696. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  149697. * It is usually composed of several `lensFlare`.
  149698. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  149699. */
  149700. export class LensFlareSystem {
  149701. /**
  149702. * Define the name of the lens flare system
  149703. */
  149704. name: string;
  149705. /**
  149706. * List of lens flares used in this system.
  149707. */
  149708. lensFlares: LensFlare[];
  149709. /**
  149710. * Define a limit from the border the lens flare can be visible.
  149711. */
  149712. borderLimit: number;
  149713. /**
  149714. * Define a viewport border we do not want to see the lens flare in.
  149715. */
  149716. viewportBorder: number;
  149717. /**
  149718. * Define a predicate which could limit the list of meshes able to occlude the effect.
  149719. */
  149720. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  149721. /**
  149722. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  149723. */
  149724. layerMask: number;
  149725. /**
  149726. * Define the id of the lens flare system in the scene.
  149727. * (equal to name by default)
  149728. */
  149729. id: string;
  149730. private _scene;
  149731. private _emitter;
  149732. private _vertexBuffers;
  149733. private _indexBuffer;
  149734. private _effect;
  149735. private _positionX;
  149736. private _positionY;
  149737. private _isEnabled;
  149738. /** @hidden */
  149739. static _SceneComponentInitialization: (scene: Scene) => void;
  149740. /**
  149741. * Instantiates a lens flare system.
  149742. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  149743. * It is usually composed of several `lensFlare`.
  149744. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  149745. * @param name Define the name of the lens flare system in the scene
  149746. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  149747. * @param scene Define the scene the lens flare system belongs to
  149748. */
  149749. constructor(
  149750. /**
  149751. * Define the name of the lens flare system
  149752. */
  149753. name: string, emitter: any, scene: Scene);
  149754. /**
  149755. * Define if the lens flare system is enabled.
  149756. */
  149757. get isEnabled(): boolean;
  149758. set isEnabled(value: boolean);
  149759. /**
  149760. * Get the scene the effects belongs to.
  149761. * @returns the scene holding the lens flare system
  149762. */
  149763. getScene(): Scene;
  149764. /**
  149765. * Get the emitter of the lens flare system.
  149766. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  149767. * @returns the emitter of the lens flare system
  149768. */
  149769. getEmitter(): any;
  149770. /**
  149771. * Set the emitter of the lens flare system.
  149772. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  149773. * @param newEmitter Define the new emitter of the system
  149774. */
  149775. setEmitter(newEmitter: any): void;
  149776. /**
  149777. * Get the lens flare system emitter position.
  149778. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  149779. * @returns the position
  149780. */
  149781. getEmitterPosition(): Vector3;
  149782. /**
  149783. * @hidden
  149784. */
  149785. computeEffectivePosition(globalViewport: Viewport): boolean;
  149786. /** @hidden */
  149787. _isVisible(): boolean;
  149788. /**
  149789. * @hidden
  149790. */
  149791. render(): boolean;
  149792. /**
  149793. * Dispose and release the lens flare with its associated resources.
  149794. */
  149795. dispose(): void;
  149796. /**
  149797. * Parse a lens flare system from a JSON representation
  149798. * @param parsedLensFlareSystem Define the JSON to parse
  149799. * @param scene Define the scene the parsed system should be instantiated in
  149800. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  149801. * @returns the parsed system
  149802. */
  149803. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  149804. /**
  149805. * Serialize the current Lens Flare System into a JSON representation.
  149806. * @returns the serialized JSON
  149807. */
  149808. serialize(): any;
  149809. }
  149810. }
  149811. declare module BABYLON {
  149812. /**
  149813. * This represents one of the lens effect in a `lensFlareSystem`.
  149814. * It controls one of the individual texture used in the effect.
  149815. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  149816. */
  149817. export class LensFlare {
  149818. /**
  149819. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  149820. */
  149821. size: number;
  149822. /**
  149823. * 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.
  149824. */
  149825. position: number;
  149826. /**
  149827. * Define the lens color.
  149828. */
  149829. color: Color3;
  149830. /**
  149831. * Define the lens texture.
  149832. */
  149833. texture: Nullable<Texture>;
  149834. /**
  149835. * Define the alpha mode to render this particular lens.
  149836. */
  149837. alphaMode: number;
  149838. private _system;
  149839. /**
  149840. * Creates a new Lens Flare.
  149841. * This represents one of the lens effect in a `lensFlareSystem`.
  149842. * It controls one of the individual texture used in the effect.
  149843. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  149844. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  149845. * @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.
  149846. * @param color Define the lens color
  149847. * @param imgUrl Define the lens texture url
  149848. * @param system Define the `lensFlareSystem` this flare is part of
  149849. * @returns The newly created Lens Flare
  149850. */
  149851. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  149852. /**
  149853. * Instantiates a new Lens Flare.
  149854. * This represents one of the lens effect in a `lensFlareSystem`.
  149855. * It controls one of the individual texture used in the effect.
  149856. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  149857. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  149858. * @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.
  149859. * @param color Define the lens color
  149860. * @param imgUrl Define the lens texture url
  149861. * @param system Define the `lensFlareSystem` this flare is part of
  149862. */
  149863. constructor(
  149864. /**
  149865. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  149866. */
  149867. size: number,
  149868. /**
  149869. * 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.
  149870. */
  149871. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  149872. /**
  149873. * Dispose and release the lens flare with its associated resources.
  149874. */
  149875. dispose(): void;
  149876. }
  149877. }
  149878. declare module BABYLON {
  149879. interface AbstractScene {
  149880. /**
  149881. * The list of lens flare system added to the scene
  149882. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  149883. */
  149884. lensFlareSystems: Array<LensFlareSystem>;
  149885. /**
  149886. * Removes the given lens flare system from this scene.
  149887. * @param toRemove The lens flare system to remove
  149888. * @returns The index of the removed lens flare system
  149889. */
  149890. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  149891. /**
  149892. * Adds the given lens flare system to this scene
  149893. * @param newLensFlareSystem The lens flare system to add
  149894. */
  149895. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  149896. /**
  149897. * Gets a lens flare system using its name
  149898. * @param name defines the name to look for
  149899. * @returns the lens flare system or null if not found
  149900. */
  149901. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  149902. /**
  149903. * Gets a lens flare system using its id
  149904. * @param id defines the id to look for
  149905. * @returns the lens flare system or null if not found
  149906. */
  149907. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  149908. }
  149909. /**
  149910. * Defines the lens flare scene component responsible to manage any lens flares
  149911. * in a given scene.
  149912. */
  149913. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  149914. /**
  149915. * The component name helpful to identify the component in the list of scene components.
  149916. */
  149917. readonly name: string;
  149918. /**
  149919. * The scene the component belongs to.
  149920. */
  149921. scene: Scene;
  149922. /**
  149923. * Creates a new instance of the component for the given scene
  149924. * @param scene Defines the scene to register the component in
  149925. */
  149926. constructor(scene: Scene);
  149927. /**
  149928. * Registers the component in a given scene
  149929. */
  149930. register(): void;
  149931. /**
  149932. * Rebuilds the elements related to this component in case of
  149933. * context lost for instance.
  149934. */
  149935. rebuild(): void;
  149936. /**
  149937. * Adds all the elements from the container to the scene
  149938. * @param container the container holding the elements
  149939. */
  149940. addFromContainer(container: AbstractScene): void;
  149941. /**
  149942. * Removes all the elements in the container from the scene
  149943. * @param container contains the elements to remove
  149944. * @param dispose if the removed element should be disposed (default: false)
  149945. */
  149946. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149947. /**
  149948. * Serializes the component data to the specified json object
  149949. * @param serializationObject The object to serialize to
  149950. */
  149951. serialize(serializationObject: any): void;
  149952. /**
  149953. * Disposes the component and the associated resources.
  149954. */
  149955. dispose(): void;
  149956. private _draw;
  149957. }
  149958. }
  149959. declare module BABYLON {
  149960. /** @hidden */
  149961. export var depthPixelShader: {
  149962. name: string;
  149963. shader: string;
  149964. };
  149965. }
  149966. declare module BABYLON {
  149967. /** @hidden */
  149968. export var depthVertexShader: {
  149969. name: string;
  149970. shader: string;
  149971. };
  149972. }
  149973. declare module BABYLON {
  149974. /**
  149975. * This represents a depth renderer in Babylon.
  149976. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  149977. */
  149978. export class DepthRenderer {
  149979. private _scene;
  149980. private _depthMap;
  149981. private _effect;
  149982. private readonly _storeNonLinearDepth;
  149983. private readonly _clearColor;
  149984. /** Get if the depth renderer is using packed depth or not */
  149985. readonly isPacked: boolean;
  149986. private _cachedDefines;
  149987. private _camera;
  149988. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  149989. enabled: boolean;
  149990. /**
  149991. * Specifies that the depth renderer will only be used within
  149992. * the camera it is created for.
  149993. * This can help forcing its rendering during the camera processing.
  149994. */
  149995. useOnlyInActiveCamera: boolean;
  149996. /** @hidden */
  149997. static _SceneComponentInitialization: (scene: Scene) => void;
  149998. /**
  149999. * Instantiates a depth renderer
  150000. * @param scene The scene the renderer belongs to
  150001. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  150002. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  150003. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  150004. */
  150005. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  150006. /**
  150007. * Creates the depth rendering effect and checks if the effect is ready.
  150008. * @param subMesh The submesh to be used to render the depth map of
  150009. * @param useInstances If multiple world instances should be used
  150010. * @returns if the depth renderer is ready to render the depth map
  150011. */
  150012. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150013. /**
  150014. * Gets the texture which the depth map will be written to.
  150015. * @returns The depth map texture
  150016. */
  150017. getDepthMap(): RenderTargetTexture;
  150018. /**
  150019. * Disposes of the depth renderer.
  150020. */
  150021. dispose(): void;
  150022. }
  150023. }
  150024. declare module BABYLON {
  150025. /** @hidden */
  150026. export var minmaxReduxPixelShader: {
  150027. name: string;
  150028. shader: string;
  150029. };
  150030. }
  150031. declare module BABYLON {
  150032. /**
  150033. * This class computes a min/max reduction from a texture: it means it computes the minimum
  150034. * and maximum values from all values of the texture.
  150035. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  150036. * The source values are read from the red channel of the texture.
  150037. */
  150038. export class MinMaxReducer {
  150039. /**
  150040. * Observable triggered when the computation has been performed
  150041. */
  150042. onAfterReductionPerformed: Observable<{
  150043. min: number;
  150044. max: number;
  150045. }>;
  150046. protected _camera: Camera;
  150047. protected _sourceTexture: Nullable<RenderTargetTexture>;
  150048. protected _reductionSteps: Nullable<Array<PostProcess>>;
  150049. protected _postProcessManager: PostProcessManager;
  150050. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  150051. protected _forceFullscreenViewport: boolean;
  150052. /**
  150053. * Creates a min/max reducer
  150054. * @param camera The camera to use for the post processes
  150055. */
  150056. constructor(camera: Camera);
  150057. /**
  150058. * Gets the texture used to read the values from.
  150059. */
  150060. get sourceTexture(): Nullable<RenderTargetTexture>;
  150061. /**
  150062. * Sets the source texture to read the values from.
  150063. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  150064. * because in such textures '1' value must not be taken into account to compute the maximum
  150065. * as this value is used to clear the texture.
  150066. * Note that the computation is not activated by calling this function, you must call activate() for that!
  150067. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  150068. * @param depthRedux Indicates if the texture is a depth texture or not
  150069. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  150070. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  150071. */
  150072. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  150073. /**
  150074. * Defines the refresh rate of the computation.
  150075. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  150076. */
  150077. get refreshRate(): number;
  150078. set refreshRate(value: number);
  150079. protected _activated: boolean;
  150080. /**
  150081. * Gets the activation status of the reducer
  150082. */
  150083. get activated(): boolean;
  150084. /**
  150085. * Activates the reduction computation.
  150086. * When activated, the observers registered in onAfterReductionPerformed are
  150087. * called after the computation is performed
  150088. */
  150089. activate(): void;
  150090. /**
  150091. * Deactivates the reduction computation.
  150092. */
  150093. deactivate(): void;
  150094. /**
  150095. * Disposes the min/max reducer
  150096. * @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.
  150097. */
  150098. dispose(disposeAll?: boolean): void;
  150099. }
  150100. }
  150101. declare module BABYLON {
  150102. /**
  150103. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  150104. */
  150105. export class DepthReducer extends MinMaxReducer {
  150106. private _depthRenderer;
  150107. private _depthRendererId;
  150108. /**
  150109. * Gets the depth renderer used for the computation.
  150110. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  150111. */
  150112. get depthRenderer(): Nullable<DepthRenderer>;
  150113. /**
  150114. * Creates a depth reducer
  150115. * @param camera The camera used to render the depth texture
  150116. */
  150117. constructor(camera: Camera);
  150118. /**
  150119. * Sets the depth renderer to use to generate the depth map
  150120. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  150121. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  150122. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  150123. */
  150124. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  150125. /** @hidden */
  150126. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  150127. /**
  150128. * Activates the reduction computation.
  150129. * When activated, the observers registered in onAfterReductionPerformed are
  150130. * called after the computation is performed
  150131. */
  150132. activate(): void;
  150133. /**
  150134. * Deactivates the reduction computation.
  150135. */
  150136. deactivate(): void;
  150137. /**
  150138. * Disposes the depth reducer
  150139. * @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.
  150140. */
  150141. dispose(disposeAll?: boolean): void;
  150142. }
  150143. }
  150144. declare module BABYLON {
  150145. /**
  150146. * A CSM implementation allowing casting shadows on large scenes.
  150147. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  150148. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  150149. */
  150150. export class CascadedShadowGenerator extends ShadowGenerator {
  150151. private static readonly frustumCornersNDCSpace;
  150152. /**
  150153. * Name of the CSM class
  150154. */
  150155. static CLASSNAME: string;
  150156. /**
  150157. * Defines the default number of cascades used by the CSM.
  150158. */
  150159. static readonly DEFAULT_CASCADES_COUNT: number;
  150160. /**
  150161. * Defines the minimum number of cascades used by the CSM.
  150162. */
  150163. static readonly MIN_CASCADES_COUNT: number;
  150164. /**
  150165. * Defines the maximum number of cascades used by the CSM.
  150166. */
  150167. static readonly MAX_CASCADES_COUNT: number;
  150168. protected _validateFilter(filter: number): number;
  150169. /**
  150170. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  150171. */
  150172. penumbraDarkness: number;
  150173. private _numCascades;
  150174. /**
  150175. * Gets or set the number of cascades used by the CSM.
  150176. */
  150177. get numCascades(): number;
  150178. set numCascades(value: number);
  150179. /**
  150180. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  150181. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  150182. */
  150183. stabilizeCascades: boolean;
  150184. private _freezeShadowCastersBoundingInfo;
  150185. private _freezeShadowCastersBoundingInfoObservable;
  150186. /**
  150187. * Enables or disables the shadow casters bounding info computation.
  150188. * If your shadow casters don't move, you can disable this feature.
  150189. * If it is enabled, the bounding box computation is done every frame.
  150190. */
  150191. get freezeShadowCastersBoundingInfo(): boolean;
  150192. set freezeShadowCastersBoundingInfo(freeze: boolean);
  150193. private _scbiMin;
  150194. private _scbiMax;
  150195. protected _computeShadowCastersBoundingInfo(): void;
  150196. protected _shadowCastersBoundingInfo: BoundingInfo;
  150197. /**
  150198. * Gets or sets the shadow casters bounding info.
  150199. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  150200. * so that the system won't overwrite the bounds you provide
  150201. */
  150202. get shadowCastersBoundingInfo(): BoundingInfo;
  150203. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  150204. protected _breaksAreDirty: boolean;
  150205. protected _minDistance: number;
  150206. protected _maxDistance: number;
  150207. /**
  150208. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  150209. *
  150210. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  150211. * If you don't know these values, simply leave them to their defaults and don't call this function.
  150212. * @param min minimal distance for the breaks (default to 0.)
  150213. * @param max maximal distance for the breaks (default to 1.)
  150214. */
  150215. setMinMaxDistance(min: number, max: number): void;
  150216. /** Gets the minimal distance used in the cascade break computation */
  150217. get minDistance(): number;
  150218. /** Gets the maximal distance used in the cascade break computation */
  150219. get maxDistance(): number;
  150220. /**
  150221. * Gets the class name of that object
  150222. * @returns "CascadedShadowGenerator"
  150223. */
  150224. getClassName(): string;
  150225. private _cascadeMinExtents;
  150226. private _cascadeMaxExtents;
  150227. /**
  150228. * Gets a cascade minimum extents
  150229. * @param cascadeIndex index of the cascade
  150230. * @returns the minimum cascade extents
  150231. */
  150232. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  150233. /**
  150234. * Gets a cascade maximum extents
  150235. * @param cascadeIndex index of the cascade
  150236. * @returns the maximum cascade extents
  150237. */
  150238. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  150239. private _cascades;
  150240. private _currentLayer;
  150241. private _viewSpaceFrustumsZ;
  150242. private _viewMatrices;
  150243. private _projectionMatrices;
  150244. private _transformMatrices;
  150245. private _transformMatricesAsArray;
  150246. private _frustumLengths;
  150247. private _lightSizeUVCorrection;
  150248. private _depthCorrection;
  150249. private _frustumCornersWorldSpace;
  150250. private _frustumCenter;
  150251. private _shadowCameraPos;
  150252. private _shadowMaxZ;
  150253. /**
  150254. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  150255. * It defaults to camera.maxZ
  150256. */
  150257. get shadowMaxZ(): number;
  150258. /**
  150259. * Sets the shadow max z distance.
  150260. */
  150261. set shadowMaxZ(value: number);
  150262. protected _debug: boolean;
  150263. /**
  150264. * Gets or sets the debug flag.
  150265. * When enabled, the cascades are materialized by different colors on the screen.
  150266. */
  150267. get debug(): boolean;
  150268. set debug(dbg: boolean);
  150269. private _depthClamp;
  150270. /**
  150271. * Gets or sets the depth clamping value.
  150272. *
  150273. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  150274. * to account for the shadow casters far away.
  150275. *
  150276. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  150277. */
  150278. get depthClamp(): boolean;
  150279. set depthClamp(value: boolean);
  150280. private _cascadeBlendPercentage;
  150281. /**
  150282. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  150283. * It defaults to 0.1 (10% blending).
  150284. */
  150285. get cascadeBlendPercentage(): number;
  150286. set cascadeBlendPercentage(value: number);
  150287. private _lambda;
  150288. /**
  150289. * Gets or set the lambda parameter.
  150290. * This parameter is used to split the camera frustum and create the cascades.
  150291. * 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.
  150292. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  150293. */
  150294. get lambda(): number;
  150295. set lambda(value: number);
  150296. /**
  150297. * Gets the view matrix corresponding to a given cascade
  150298. * @param cascadeNum cascade to retrieve the view matrix from
  150299. * @returns the cascade view matrix
  150300. */
  150301. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  150302. /**
  150303. * Gets the projection matrix corresponding to a given cascade
  150304. * @param cascadeNum cascade to retrieve the projection matrix from
  150305. * @returns the cascade projection matrix
  150306. */
  150307. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  150308. /**
  150309. * Gets the transformation matrix corresponding to a given cascade
  150310. * @param cascadeNum cascade to retrieve the transformation matrix from
  150311. * @returns the cascade transformation matrix
  150312. */
  150313. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  150314. private _depthRenderer;
  150315. /**
  150316. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  150317. *
  150318. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  150319. *
  150320. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  150321. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  150322. * @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
  150323. */
  150324. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  150325. private _depthReducer;
  150326. private _autoCalcDepthBounds;
  150327. /**
  150328. * Gets or sets the autoCalcDepthBounds property.
  150329. *
  150330. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  150331. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  150332. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  150333. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  150334. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  150335. */
  150336. get autoCalcDepthBounds(): boolean;
  150337. set autoCalcDepthBounds(value: boolean);
  150338. /**
  150339. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  150340. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  150341. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  150342. * for setting the refresh rate on the renderer yourself!
  150343. */
  150344. get autoCalcDepthBoundsRefreshRate(): number;
  150345. set autoCalcDepthBoundsRefreshRate(value: number);
  150346. /**
  150347. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  150348. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  150349. * you change the camera near/far planes!
  150350. */
  150351. splitFrustum(): void;
  150352. private _splitFrustum;
  150353. private _computeMatrices;
  150354. private _computeFrustumInWorldSpace;
  150355. private _computeCascadeFrustum;
  150356. /**
  150357. * Support test.
  150358. */
  150359. static get IsSupported(): boolean;
  150360. /** @hidden */
  150361. static _SceneComponentInitialization: (scene: Scene) => void;
  150362. /**
  150363. * Creates a Cascaded Shadow Generator object.
  150364. * A ShadowGenerator is the required tool to use the shadows.
  150365. * Each directional light casting shadows needs to use its own ShadowGenerator.
  150366. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  150367. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  150368. * @param light The directional light object generating the shadows.
  150369. * @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.
  150370. */
  150371. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  150372. protected _initializeGenerator(): void;
  150373. protected _createTargetRenderTexture(): void;
  150374. protected _initializeShadowMap(): void;
  150375. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  150376. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  150377. /**
  150378. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  150379. * @param defines Defines of the material we want to update
  150380. * @param lightIndex Index of the light in the enabled light list of the material
  150381. */
  150382. prepareDefines(defines: any, lightIndex: number): void;
  150383. /**
  150384. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  150385. * defined in the generator but impacting the effect).
  150386. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  150387. * @param effect The effect we are binfing the information for
  150388. */
  150389. bindShadowLight(lightIndex: string, effect: Effect): void;
  150390. /**
  150391. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  150392. * (eq to view projection * shadow projection matrices)
  150393. * @returns The transform matrix used to create the shadow map
  150394. */
  150395. getTransformMatrix(): Matrix;
  150396. /**
  150397. * Disposes the ShadowGenerator.
  150398. * Returns nothing.
  150399. */
  150400. dispose(): void;
  150401. /**
  150402. * Serializes the shadow generator setup to a json object.
  150403. * @returns The serialized JSON object
  150404. */
  150405. serialize(): any;
  150406. /**
  150407. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  150408. * @param parsedShadowGenerator The JSON object to parse
  150409. * @param scene The scene to create the shadow map for
  150410. * @returns The parsed shadow generator
  150411. */
  150412. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  150413. }
  150414. }
  150415. declare module BABYLON {
  150416. /**
  150417. * Defines the shadow generator component responsible to manage any shadow generators
  150418. * in a given scene.
  150419. */
  150420. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  150421. /**
  150422. * The component name helpful to identify the component in the list of scene components.
  150423. */
  150424. readonly name: string;
  150425. /**
  150426. * The scene the component belongs to.
  150427. */
  150428. scene: Scene;
  150429. /**
  150430. * Creates a new instance of the component for the given scene
  150431. * @param scene Defines the scene to register the component in
  150432. */
  150433. constructor(scene: Scene);
  150434. /**
  150435. * Registers the component in a given scene
  150436. */
  150437. register(): void;
  150438. /**
  150439. * Rebuilds the elements related to this component in case of
  150440. * context lost for instance.
  150441. */
  150442. rebuild(): void;
  150443. /**
  150444. * Serializes the component data to the specified json object
  150445. * @param serializationObject The object to serialize to
  150446. */
  150447. serialize(serializationObject: any): void;
  150448. /**
  150449. * Adds all the elements from the container to the scene
  150450. * @param container the container holding the elements
  150451. */
  150452. addFromContainer(container: AbstractScene): void;
  150453. /**
  150454. * Removes all the elements in the container from the scene
  150455. * @param container contains the elements to remove
  150456. * @param dispose if the removed element should be disposed (default: false)
  150457. */
  150458. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  150459. /**
  150460. * Rebuilds the elements related to this component in case of
  150461. * context lost for instance.
  150462. */
  150463. dispose(): void;
  150464. private _gatherRenderTargets;
  150465. }
  150466. }
  150467. declare module BABYLON {
  150468. /**
  150469. * A point light is a light defined by an unique point in world space.
  150470. * The light is emitted in every direction from this point.
  150471. * A good example of a point light is a standard light bulb.
  150472. * Documentation: https://doc.babylonjs.com/babylon101/lights
  150473. */
  150474. export class PointLight extends ShadowLight {
  150475. private _shadowAngle;
  150476. /**
  150477. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  150478. * This specifies what angle the shadow will use to be created.
  150479. *
  150480. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  150481. */
  150482. get shadowAngle(): number;
  150483. /**
  150484. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  150485. * This specifies what angle the shadow will use to be created.
  150486. *
  150487. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  150488. */
  150489. set shadowAngle(value: number);
  150490. /**
  150491. * Gets the direction if it has been set.
  150492. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  150493. */
  150494. get direction(): Vector3;
  150495. /**
  150496. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  150497. */
  150498. set direction(value: Vector3);
  150499. /**
  150500. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  150501. * A PointLight emits the light in every direction.
  150502. * It can cast shadows.
  150503. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  150504. * ```javascript
  150505. * var pointLight = new PointLight("pl", camera.position, scene);
  150506. * ```
  150507. * Documentation : https://doc.babylonjs.com/babylon101/lights
  150508. * @param name The light friendly name
  150509. * @param position The position of the point light in the scene
  150510. * @param scene The scene the lights belongs to
  150511. */
  150512. constructor(name: string, position: Vector3, scene: Scene);
  150513. /**
  150514. * Returns the string "PointLight"
  150515. * @returns the class name
  150516. */
  150517. getClassName(): string;
  150518. /**
  150519. * Returns the integer 0.
  150520. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  150521. */
  150522. getTypeID(): number;
  150523. /**
  150524. * Specifies whether or not the shadowmap should be a cube texture.
  150525. * @returns true if the shadowmap needs to be a cube texture.
  150526. */
  150527. needCube(): boolean;
  150528. /**
  150529. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  150530. * @param faceIndex The index of the face we are computed the direction to generate shadow
  150531. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  150532. */
  150533. getShadowDirection(faceIndex?: number): Vector3;
  150534. /**
  150535. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  150536. * - fov = PI / 2
  150537. * - aspect ratio : 1.0
  150538. * - z-near and far equal to the active camera minZ and maxZ.
  150539. * Returns the PointLight.
  150540. */
  150541. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  150542. protected _buildUniformLayout(): void;
  150543. /**
  150544. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  150545. * @param effect The effect to update
  150546. * @param lightIndex The index of the light in the effect to update
  150547. * @returns The point light
  150548. */
  150549. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  150550. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  150551. /**
  150552. * Prepares the list of defines specific to the light type.
  150553. * @param defines the list of defines
  150554. * @param lightIndex defines the index of the light for the effect
  150555. */
  150556. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  150557. }
  150558. }
  150559. declare module BABYLON {
  150560. /**
  150561. * Header information of HDR texture files.
  150562. */
  150563. export interface HDRInfo {
  150564. /**
  150565. * The height of the texture in pixels.
  150566. */
  150567. height: number;
  150568. /**
  150569. * The width of the texture in pixels.
  150570. */
  150571. width: number;
  150572. /**
  150573. * The index of the beginning of the data in the binary file.
  150574. */
  150575. dataPosition: number;
  150576. }
  150577. /**
  150578. * This groups tools to convert HDR texture to native colors array.
  150579. */
  150580. export class HDRTools {
  150581. private static Ldexp;
  150582. private static Rgbe2float;
  150583. private static readStringLine;
  150584. /**
  150585. * Reads header information from an RGBE texture stored in a native array.
  150586. * More information on this format are available here:
  150587. * https://en.wikipedia.org/wiki/RGBE_image_format
  150588. *
  150589. * @param uint8array The binary file stored in native array.
  150590. * @return The header information.
  150591. */
  150592. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  150593. /**
  150594. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  150595. * This RGBE texture needs to store the information as a panorama.
  150596. *
  150597. * More information on this format are available here:
  150598. * https://en.wikipedia.org/wiki/RGBE_image_format
  150599. *
  150600. * @param buffer The binary file stored in an array buffer.
  150601. * @param size The expected size of the extracted cubemap.
  150602. * @return The Cube Map information.
  150603. */
  150604. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  150605. /**
  150606. * Returns the pixels data extracted from an RGBE texture.
  150607. * This pixels will be stored left to right up to down in the R G B order in one array.
  150608. *
  150609. * More information on this format are available here:
  150610. * https://en.wikipedia.org/wiki/RGBE_image_format
  150611. *
  150612. * @param uint8array The binary file stored in an array buffer.
  150613. * @param hdrInfo The header information of the file.
  150614. * @return The pixels data in RGB right to left up to down order.
  150615. */
  150616. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  150617. private static RGBE_ReadPixels_RLE;
  150618. private static RGBE_ReadPixels_NOT_RLE;
  150619. }
  150620. }
  150621. declare module BABYLON {
  150622. /**
  150623. * Effect Render Options
  150624. */
  150625. export interface IEffectRendererOptions {
  150626. /**
  150627. * Defines the vertices positions.
  150628. */
  150629. positions?: number[];
  150630. /**
  150631. * Defines the indices.
  150632. */
  150633. indices?: number[];
  150634. }
  150635. /**
  150636. * Helper class to render one or more effects.
  150637. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  150638. */
  150639. export class EffectRenderer {
  150640. private engine;
  150641. private static _DefaultOptions;
  150642. private _vertexBuffers;
  150643. private _indexBuffer;
  150644. private _fullscreenViewport;
  150645. /**
  150646. * Creates an effect renderer
  150647. * @param engine the engine to use for rendering
  150648. * @param options defines the options of the effect renderer
  150649. */
  150650. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  150651. /**
  150652. * Sets the current viewport in normalized coordinates 0-1
  150653. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  150654. */
  150655. setViewport(viewport?: Viewport): void;
  150656. /**
  150657. * Binds the embedded attributes buffer to the effect.
  150658. * @param effect Defines the effect to bind the attributes for
  150659. */
  150660. bindBuffers(effect: Effect): void;
  150661. /**
  150662. * Sets the current effect wrapper to use during draw.
  150663. * The effect needs to be ready before calling this api.
  150664. * This also sets the default full screen position attribute.
  150665. * @param effectWrapper Defines the effect to draw with
  150666. */
  150667. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  150668. /**
  150669. * Restores engine states
  150670. */
  150671. restoreStates(): void;
  150672. /**
  150673. * Draws a full screen quad.
  150674. */
  150675. draw(): void;
  150676. private isRenderTargetTexture;
  150677. /**
  150678. * renders one or more effects to a specified texture
  150679. * @param effectWrapper the effect to renderer
  150680. * @param outputTexture texture to draw to, if null it will render to the screen.
  150681. */
  150682. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  150683. /**
  150684. * Disposes of the effect renderer
  150685. */
  150686. dispose(): void;
  150687. }
  150688. /**
  150689. * Options to create an EffectWrapper
  150690. */
  150691. interface EffectWrapperCreationOptions {
  150692. /**
  150693. * Engine to use to create the effect
  150694. */
  150695. engine: ThinEngine;
  150696. /**
  150697. * Fragment shader for the effect
  150698. */
  150699. fragmentShader: string;
  150700. /**
  150701. * Use the shader store instead of direct source code
  150702. */
  150703. useShaderStore?: boolean;
  150704. /**
  150705. * Vertex shader for the effect
  150706. */
  150707. vertexShader?: string;
  150708. /**
  150709. * Attributes to use in the shader
  150710. */
  150711. attributeNames?: Array<string>;
  150712. /**
  150713. * Uniforms to use in the shader
  150714. */
  150715. uniformNames?: Array<string>;
  150716. /**
  150717. * Texture sampler names to use in the shader
  150718. */
  150719. samplerNames?: Array<string>;
  150720. /**
  150721. * Defines to use in the shader
  150722. */
  150723. defines?: Array<string>;
  150724. /**
  150725. * Callback when effect is compiled
  150726. */
  150727. onCompiled?: Nullable<(effect: Effect) => void>;
  150728. /**
  150729. * The friendly name of the effect displayed in Spector.
  150730. */
  150731. name?: string;
  150732. }
  150733. /**
  150734. * Wraps an effect to be used for rendering
  150735. */
  150736. export class EffectWrapper {
  150737. /**
  150738. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  150739. */
  150740. onApplyObservable: Observable<{}>;
  150741. /**
  150742. * The underlying effect
  150743. */
  150744. effect: Effect;
  150745. /**
  150746. * Creates an effect to be renderer
  150747. * @param creationOptions options to create the effect
  150748. */
  150749. constructor(creationOptions: EffectWrapperCreationOptions);
  150750. /**
  150751. * Disposes of the effect wrapper
  150752. */
  150753. dispose(): void;
  150754. }
  150755. }
  150756. declare module BABYLON {
  150757. /** @hidden */
  150758. export var hdrFilteringVertexShader: {
  150759. name: string;
  150760. shader: string;
  150761. };
  150762. }
  150763. declare module BABYLON {
  150764. /** @hidden */
  150765. export var hdrFilteringPixelShader: {
  150766. name: string;
  150767. shader: string;
  150768. };
  150769. }
  150770. declare module BABYLON {
  150771. /**
  150772. * Options for texture filtering
  150773. */
  150774. interface IHDRFilteringOptions {
  150775. /**
  150776. * Scales pixel intensity for the input HDR map.
  150777. */
  150778. hdrScale?: number;
  150779. /**
  150780. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  150781. */
  150782. quality?: number;
  150783. }
  150784. /**
  150785. * Filters HDR maps to get correct renderings of PBR reflections
  150786. */
  150787. export class HDRFiltering {
  150788. private _engine;
  150789. private _effectRenderer;
  150790. private _effectWrapper;
  150791. private _lodGenerationOffset;
  150792. private _lodGenerationScale;
  150793. /**
  150794. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  150795. * you care about baking speed.
  150796. */
  150797. quality: number;
  150798. /**
  150799. * Scales pixel intensity for the input HDR map.
  150800. */
  150801. hdrScale: number;
  150802. /**
  150803. * Instantiates HDR filter for reflection maps
  150804. *
  150805. * @param engine Thin engine
  150806. * @param options Options
  150807. */
  150808. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  150809. private _createRenderTarget;
  150810. private _prefilterInternal;
  150811. private _createEffect;
  150812. /**
  150813. * Get a value indicating if the filter is ready to be used
  150814. * @param texture Texture to filter
  150815. * @returns true if the filter is ready
  150816. */
  150817. isReady(texture: BaseTexture): boolean;
  150818. /**
  150819. * Prefilters a cube texture to have mipmap levels representing roughness values.
  150820. * Prefiltering will be invoked at the end of next rendering pass.
  150821. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  150822. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  150823. * @param texture Texture to filter
  150824. * @param onFinished Callback when filtering is done
  150825. * @return Promise called when prefiltering is done
  150826. */
  150827. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  150828. }
  150829. }
  150830. declare module BABYLON {
  150831. /**
  150832. * This represents a texture coming from an HDR input.
  150833. *
  150834. * The only supported format is currently panorama picture stored in RGBE format.
  150835. * Example of such files can be found on HDRLib: http://hdrlib.com/
  150836. */
  150837. export class HDRCubeTexture extends BaseTexture {
  150838. private static _facesMapping;
  150839. private _generateHarmonics;
  150840. private _noMipmap;
  150841. private _prefilterOnLoad;
  150842. private _textureMatrix;
  150843. private _size;
  150844. private _onLoad;
  150845. private _onError;
  150846. /**
  150847. * The texture URL.
  150848. */
  150849. url: string;
  150850. protected _isBlocking: boolean;
  150851. /**
  150852. * Sets whether or not the texture is blocking during loading.
  150853. */
  150854. set isBlocking(value: boolean);
  150855. /**
  150856. * Gets whether or not the texture is blocking during loading.
  150857. */
  150858. get isBlocking(): boolean;
  150859. protected _rotationY: number;
  150860. /**
  150861. * Sets texture matrix rotation angle around Y axis in radians.
  150862. */
  150863. set rotationY(value: number);
  150864. /**
  150865. * Gets texture matrix rotation angle around Y axis radians.
  150866. */
  150867. get rotationY(): number;
  150868. /**
  150869. * Gets or sets the center of the bounding box associated with the cube texture
  150870. * It must define where the camera used to render the texture was set
  150871. */
  150872. boundingBoxPosition: Vector3;
  150873. private _boundingBoxSize;
  150874. /**
  150875. * Gets or sets the size of the bounding box associated with the cube texture
  150876. * When defined, the cubemap will switch to local mode
  150877. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  150878. * @example https://www.babylonjs-playground.com/#RNASML
  150879. */
  150880. set boundingBoxSize(value: Vector3);
  150881. get boundingBoxSize(): Vector3;
  150882. /**
  150883. * Instantiates an HDRTexture from the following parameters.
  150884. *
  150885. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  150886. * @param sceneOrEngine The scene or engine the texture will be used in
  150887. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  150888. * @param noMipmap Forces to not generate the mipmap if true
  150889. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  150890. * @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)
  150891. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  150892. */
  150893. 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>);
  150894. /**
  150895. * Get the current class name of the texture useful for serialization or dynamic coding.
  150896. * @returns "HDRCubeTexture"
  150897. */
  150898. getClassName(): string;
  150899. /**
  150900. * Occurs when the file is raw .hdr file.
  150901. */
  150902. private loadTexture;
  150903. clone(): HDRCubeTexture;
  150904. delayLoad(): void;
  150905. /**
  150906. * Get the texture reflection matrix used to rotate/transform the reflection.
  150907. * @returns the reflection matrix
  150908. */
  150909. getReflectionTextureMatrix(): Matrix;
  150910. /**
  150911. * Set the texture reflection matrix used to rotate/transform the reflection.
  150912. * @param value Define the reflection matrix to set
  150913. */
  150914. setReflectionTextureMatrix(value: Matrix): void;
  150915. /**
  150916. * Parses a JSON representation of an HDR Texture in order to create the texture
  150917. * @param parsedTexture Define the JSON representation
  150918. * @param scene Define the scene the texture should be created in
  150919. * @param rootUrl Define the root url in case we need to load relative dependencies
  150920. * @returns the newly created texture after parsing
  150921. */
  150922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  150923. serialize(): any;
  150924. }
  150925. }
  150926. declare module BABYLON {
  150927. /**
  150928. * Class used to control physics engine
  150929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150930. */
  150931. export class PhysicsEngine implements IPhysicsEngine {
  150932. private _physicsPlugin;
  150933. /**
  150934. * Global value used to control the smallest number supported by the simulation
  150935. */
  150936. static Epsilon: number;
  150937. private _impostors;
  150938. private _joints;
  150939. private _subTimeStep;
  150940. /**
  150941. * Gets the gravity vector used by the simulation
  150942. */
  150943. gravity: Vector3;
  150944. /**
  150945. * Factory used to create the default physics plugin.
  150946. * @returns The default physics plugin
  150947. */
  150948. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  150949. /**
  150950. * Creates a new Physics Engine
  150951. * @param gravity defines the gravity vector used by the simulation
  150952. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  150953. */
  150954. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  150955. /**
  150956. * Sets the gravity vector used by the simulation
  150957. * @param gravity defines the gravity vector to use
  150958. */
  150959. setGravity(gravity: Vector3): void;
  150960. /**
  150961. * Set the time step of the physics engine.
  150962. * Default is 1/60.
  150963. * To slow it down, enter 1/600 for example.
  150964. * To speed it up, 1/30
  150965. * @param newTimeStep defines the new timestep to apply to this world.
  150966. */
  150967. setTimeStep(newTimeStep?: number): void;
  150968. /**
  150969. * Get the time step of the physics engine.
  150970. * @returns the current time step
  150971. */
  150972. getTimeStep(): number;
  150973. /**
  150974. * Set the sub time step of the physics engine.
  150975. * Default is 0 meaning there is no sub steps
  150976. * To increase physics resolution precision, set a small value (like 1 ms)
  150977. * @param subTimeStep defines the new sub timestep used for physics resolution.
  150978. */
  150979. setSubTimeStep(subTimeStep?: number): void;
  150980. /**
  150981. * Get the sub time step of the physics engine.
  150982. * @returns the current sub time step
  150983. */
  150984. getSubTimeStep(): number;
  150985. /**
  150986. * Release all resources
  150987. */
  150988. dispose(): void;
  150989. /**
  150990. * Gets the name of the current physics plugin
  150991. * @returns the name of the plugin
  150992. */
  150993. getPhysicsPluginName(): string;
  150994. /**
  150995. * Adding a new impostor for the impostor tracking.
  150996. * This will be done by the impostor itself.
  150997. * @param impostor the impostor to add
  150998. */
  150999. addImpostor(impostor: PhysicsImpostor): void;
  151000. /**
  151001. * Remove an impostor from the engine.
  151002. * This impostor and its mesh will not longer be updated by the physics engine.
  151003. * @param impostor the impostor to remove
  151004. */
  151005. removeImpostor(impostor: PhysicsImpostor): void;
  151006. /**
  151007. * Add a joint to the physics engine
  151008. * @param mainImpostor defines the main impostor to which the joint is added.
  151009. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  151010. * @param joint defines the joint that will connect both impostors.
  151011. */
  151012. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  151013. /**
  151014. * Removes a joint from the simulation
  151015. * @param mainImpostor defines the impostor used with the joint
  151016. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  151017. * @param joint defines the joint to remove
  151018. */
  151019. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  151020. /**
  151021. * Called by the scene. No need to call it.
  151022. * @param delta defines the timespan between frames
  151023. */
  151024. _step(delta: number): void;
  151025. /**
  151026. * Gets the current plugin used to run the simulation
  151027. * @returns current plugin
  151028. */
  151029. getPhysicsPlugin(): IPhysicsEnginePlugin;
  151030. /**
  151031. * Gets the list of physic impostors
  151032. * @returns an array of PhysicsImpostor
  151033. */
  151034. getImpostors(): Array<PhysicsImpostor>;
  151035. /**
  151036. * Gets the impostor for a physics enabled object
  151037. * @param object defines the object impersonated by the impostor
  151038. * @returns the PhysicsImpostor or null if not found
  151039. */
  151040. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  151041. /**
  151042. * Gets the impostor for a physics body object
  151043. * @param body defines physics body used by the impostor
  151044. * @returns the PhysicsImpostor or null if not found
  151045. */
  151046. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  151047. /**
  151048. * Does a raycast in the physics world
  151049. * @param from when should the ray start?
  151050. * @param to when should the ray end?
  151051. * @returns PhysicsRaycastResult
  151052. */
  151053. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  151054. }
  151055. }
  151056. declare module BABYLON {
  151057. /** @hidden */
  151058. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  151059. private _useDeltaForWorldStep;
  151060. world: any;
  151061. name: string;
  151062. private _physicsMaterials;
  151063. private _fixedTimeStep;
  151064. private _cannonRaycastResult;
  151065. private _raycastResult;
  151066. private _physicsBodysToRemoveAfterStep;
  151067. private _firstFrame;
  151068. BJSCANNON: any;
  151069. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  151070. setGravity(gravity: Vector3): void;
  151071. setTimeStep(timeStep: number): void;
  151072. getTimeStep(): number;
  151073. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  151074. private _removeMarkedPhysicsBodiesFromWorld;
  151075. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  151076. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  151077. generatePhysicsBody(impostor: PhysicsImpostor): void;
  151078. private _processChildMeshes;
  151079. removePhysicsBody(impostor: PhysicsImpostor): void;
  151080. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  151081. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  151082. private _addMaterial;
  151083. private _checkWithEpsilon;
  151084. private _createShape;
  151085. private _createHeightmap;
  151086. private _minus90X;
  151087. private _plus90X;
  151088. private _tmpPosition;
  151089. private _tmpDeltaPosition;
  151090. private _tmpUnityRotation;
  151091. private _updatePhysicsBodyTransformation;
  151092. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  151093. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  151094. isSupported(): boolean;
  151095. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  151096. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  151097. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  151098. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  151099. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  151100. getBodyMass(impostor: PhysicsImpostor): number;
  151101. getBodyFriction(impostor: PhysicsImpostor): number;
  151102. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  151103. getBodyRestitution(impostor: PhysicsImpostor): number;
  151104. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  151105. sleepBody(impostor: PhysicsImpostor): void;
  151106. wakeUpBody(impostor: PhysicsImpostor): void;
  151107. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  151108. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  151109. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  151110. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  151111. getRadius(impostor: PhysicsImpostor): number;
  151112. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  151113. dispose(): void;
  151114. private _extendNamespace;
  151115. /**
  151116. * Does a raycast in the physics world
  151117. * @param from when should the ray start?
  151118. * @param to when should the ray end?
  151119. * @returns PhysicsRaycastResult
  151120. */
  151121. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  151122. }
  151123. }
  151124. declare module BABYLON {
  151125. /** @hidden */
  151126. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  151127. private _useDeltaForWorldStep;
  151128. world: any;
  151129. name: string;
  151130. BJSOIMO: any;
  151131. private _raycastResult;
  151132. private _fixedTimeStep;
  151133. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  151134. setGravity(gravity: Vector3): void;
  151135. setTimeStep(timeStep: number): void;
  151136. getTimeStep(): number;
  151137. private _tmpImpostorsArray;
  151138. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  151139. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  151140. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  151141. generatePhysicsBody(impostor: PhysicsImpostor): void;
  151142. private _tmpPositionVector;
  151143. removePhysicsBody(impostor: PhysicsImpostor): void;
  151144. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  151145. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  151146. isSupported(): boolean;
  151147. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  151148. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  151149. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  151150. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  151151. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  151152. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  151153. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  151154. getBodyMass(impostor: PhysicsImpostor): number;
  151155. getBodyFriction(impostor: PhysicsImpostor): number;
  151156. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  151157. getBodyRestitution(impostor: PhysicsImpostor): number;
  151158. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  151159. sleepBody(impostor: PhysicsImpostor): void;
  151160. wakeUpBody(impostor: PhysicsImpostor): void;
  151161. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  151162. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  151163. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  151164. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  151165. getRadius(impostor: PhysicsImpostor): number;
  151166. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  151167. dispose(): void;
  151168. /**
  151169. * Does a raycast in the physics world
  151170. * @param from when should the ray start?
  151171. * @param to when should the ray end?
  151172. * @returns PhysicsRaycastResult
  151173. */
  151174. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  151175. }
  151176. }
  151177. declare module BABYLON {
  151178. /**
  151179. * AmmoJS Physics plugin
  151180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  151181. * @see https://github.com/kripken/ammo.js/
  151182. */
  151183. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  151184. private _useDeltaForWorldStep;
  151185. /**
  151186. * Reference to the Ammo library
  151187. */
  151188. bjsAMMO: any;
  151189. /**
  151190. * Created ammoJS world which physics bodies are added to
  151191. */
  151192. world: any;
  151193. /**
  151194. * Name of the plugin
  151195. */
  151196. name: string;
  151197. private _timeStep;
  151198. private _fixedTimeStep;
  151199. private _maxSteps;
  151200. private _tmpQuaternion;
  151201. private _tmpAmmoTransform;
  151202. private _tmpAmmoQuaternion;
  151203. private _tmpAmmoConcreteContactResultCallback;
  151204. private _collisionConfiguration;
  151205. private _dispatcher;
  151206. private _overlappingPairCache;
  151207. private _solver;
  151208. private _softBodySolver;
  151209. private _tmpAmmoVectorA;
  151210. private _tmpAmmoVectorB;
  151211. private _tmpAmmoVectorC;
  151212. private _tmpAmmoVectorD;
  151213. private _tmpContactCallbackResult;
  151214. private _tmpAmmoVectorRCA;
  151215. private _tmpAmmoVectorRCB;
  151216. private _raycastResult;
  151217. private _tmpContactPoint;
  151218. private static readonly DISABLE_COLLISION_FLAG;
  151219. private static readonly KINEMATIC_FLAG;
  151220. private static readonly DISABLE_DEACTIVATION_FLAG;
  151221. /**
  151222. * Initializes the ammoJS plugin
  151223. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  151224. * @param ammoInjection can be used to inject your own ammo reference
  151225. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  151226. */
  151227. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  151228. /**
  151229. * Sets the gravity of the physics world (m/(s^2))
  151230. * @param gravity Gravity to set
  151231. */
  151232. setGravity(gravity: Vector3): void;
  151233. /**
  151234. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  151235. * @param timeStep timestep to use in seconds
  151236. */
  151237. setTimeStep(timeStep: number): void;
  151238. /**
  151239. * 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)
  151240. * @param fixedTimeStep fixedTimeStep to use in seconds
  151241. */
  151242. setFixedTimeStep(fixedTimeStep: number): void;
  151243. /**
  151244. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  151245. * @param maxSteps the maximum number of steps by the physics engine per frame
  151246. */
  151247. setMaxSteps(maxSteps: number): void;
  151248. /**
  151249. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  151250. * @returns the current timestep in seconds
  151251. */
  151252. getTimeStep(): number;
  151253. /**
  151254. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  151255. */
  151256. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  151257. private _isImpostorInContact;
  151258. private _isImpostorPairInContact;
  151259. private _stepSimulation;
  151260. /**
  151261. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  151262. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  151263. * After the step the babylon meshes are set to the position of the physics imposters
  151264. * @param delta amount of time to step forward
  151265. * @param impostors array of imposters to update before/after the step
  151266. */
  151267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  151268. /**
  151269. * Update babylon mesh to match physics world object
  151270. * @param impostor imposter to match
  151271. */
  151272. private _afterSoftStep;
  151273. /**
  151274. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  151275. * @param impostor imposter to match
  151276. */
  151277. private _ropeStep;
  151278. /**
  151279. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  151280. * @param impostor imposter to match
  151281. */
  151282. private _softbodyOrClothStep;
  151283. private _tmpMatrix;
  151284. /**
  151285. * Applies an impulse on the imposter
  151286. * @param impostor imposter to apply impulse to
  151287. * @param force amount of force to be applied to the imposter
  151288. * @param contactPoint the location to apply the impulse on the imposter
  151289. */
  151290. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  151291. /**
  151292. * Applies a force on the imposter
  151293. * @param impostor imposter to apply force
  151294. * @param force amount of force to be applied to the imposter
  151295. * @param contactPoint the location to apply the force on the imposter
  151296. */
  151297. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  151298. /**
  151299. * Creates a physics body using the plugin
  151300. * @param impostor the imposter to create the physics body on
  151301. */
  151302. generatePhysicsBody(impostor: PhysicsImpostor): void;
  151303. /**
  151304. * Removes the physics body from the imposter and disposes of the body's memory
  151305. * @param impostor imposter to remove the physics body from
  151306. */
  151307. removePhysicsBody(impostor: PhysicsImpostor): void;
  151308. /**
  151309. * Generates a joint
  151310. * @param impostorJoint the imposter joint to create the joint with
  151311. */
  151312. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  151313. /**
  151314. * Removes a joint
  151315. * @param impostorJoint the imposter joint to remove the joint from
  151316. */
  151317. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  151318. private _addMeshVerts;
  151319. /**
  151320. * Initialise the soft body vertices to match its object's (mesh) vertices
  151321. * Softbody vertices (nodes) are in world space and to match this
  151322. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  151323. * @param impostor to create the softbody for
  151324. */
  151325. private _softVertexData;
  151326. /**
  151327. * Create an impostor's soft body
  151328. * @param impostor to create the softbody for
  151329. */
  151330. private _createSoftbody;
  151331. /**
  151332. * Create cloth for an impostor
  151333. * @param impostor to create the softbody for
  151334. */
  151335. private _createCloth;
  151336. /**
  151337. * Create rope for an impostor
  151338. * @param impostor to create the softbody for
  151339. */
  151340. private _createRope;
  151341. /**
  151342. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  151343. * @param impostor to create the custom physics shape for
  151344. */
  151345. private _createCustom;
  151346. private _addHullVerts;
  151347. private _createShape;
  151348. /**
  151349. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  151350. * @param impostor imposter containing the physics body and babylon object
  151351. */
  151352. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  151353. /**
  151354. * Sets the babylon object's position/rotation from the physics body's position/rotation
  151355. * @param impostor imposter containing the physics body and babylon object
  151356. * @param newPosition new position
  151357. * @param newRotation new rotation
  151358. */
  151359. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  151360. /**
  151361. * If this plugin is supported
  151362. * @returns true if its supported
  151363. */
  151364. isSupported(): boolean;
  151365. /**
  151366. * Sets the linear velocity of the physics body
  151367. * @param impostor imposter to set the velocity on
  151368. * @param velocity velocity to set
  151369. */
  151370. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  151371. /**
  151372. * Sets the angular velocity of the physics body
  151373. * @param impostor imposter to set the velocity on
  151374. * @param velocity velocity to set
  151375. */
  151376. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  151377. /**
  151378. * gets the linear velocity
  151379. * @param impostor imposter to get linear velocity from
  151380. * @returns linear velocity
  151381. */
  151382. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  151383. /**
  151384. * gets the angular velocity
  151385. * @param impostor imposter to get angular velocity from
  151386. * @returns angular velocity
  151387. */
  151388. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  151389. /**
  151390. * Sets the mass of physics body
  151391. * @param impostor imposter to set the mass on
  151392. * @param mass mass to set
  151393. */
  151394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  151395. /**
  151396. * Gets the mass of the physics body
  151397. * @param impostor imposter to get the mass from
  151398. * @returns mass
  151399. */
  151400. getBodyMass(impostor: PhysicsImpostor): number;
  151401. /**
  151402. * Gets friction of the impostor
  151403. * @param impostor impostor to get friction from
  151404. * @returns friction value
  151405. */
  151406. getBodyFriction(impostor: PhysicsImpostor): number;
  151407. /**
  151408. * Sets friction of the impostor
  151409. * @param impostor impostor to set friction on
  151410. * @param friction friction value
  151411. */
  151412. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  151413. /**
  151414. * Gets restitution of the impostor
  151415. * @param impostor impostor to get restitution from
  151416. * @returns restitution value
  151417. */
  151418. getBodyRestitution(impostor: PhysicsImpostor): number;
  151419. /**
  151420. * Sets restitution of the impostor
  151421. * @param impostor impostor to set resitution on
  151422. * @param restitution resitution value
  151423. */
  151424. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  151425. /**
  151426. * Gets pressure inside the impostor
  151427. * @param impostor impostor to get pressure from
  151428. * @returns pressure value
  151429. */
  151430. getBodyPressure(impostor: PhysicsImpostor): number;
  151431. /**
  151432. * Sets pressure inside a soft body impostor
  151433. * Cloth and rope must remain 0 pressure
  151434. * @param impostor impostor to set pressure on
  151435. * @param pressure pressure value
  151436. */
  151437. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  151438. /**
  151439. * Gets stiffness of the impostor
  151440. * @param impostor impostor to get stiffness from
  151441. * @returns pressure value
  151442. */
  151443. getBodyStiffness(impostor: PhysicsImpostor): number;
  151444. /**
  151445. * Sets stiffness of the impostor
  151446. * @param impostor impostor to set stiffness on
  151447. * @param stiffness stiffness value from 0 to 1
  151448. */
  151449. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  151450. /**
  151451. * Gets velocityIterations of the impostor
  151452. * @param impostor impostor to get velocity iterations from
  151453. * @returns velocityIterations value
  151454. */
  151455. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  151456. /**
  151457. * Sets velocityIterations of the impostor
  151458. * @param impostor impostor to set velocity iterations on
  151459. * @param velocityIterations velocityIterations value
  151460. */
  151461. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  151462. /**
  151463. * Gets positionIterations of the impostor
  151464. * @param impostor impostor to get position iterations from
  151465. * @returns positionIterations value
  151466. */
  151467. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  151468. /**
  151469. * Sets positionIterations of the impostor
  151470. * @param impostor impostor to set position on
  151471. * @param positionIterations positionIterations value
  151472. */
  151473. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  151474. /**
  151475. * Append an anchor to a cloth object
  151476. * @param impostor is the cloth impostor to add anchor to
  151477. * @param otherImpostor is the rigid impostor to anchor to
  151478. * @param width ratio across width from 0 to 1
  151479. * @param height ratio up height from 0 to 1
  151480. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  151481. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  151482. */
  151483. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  151484. /**
  151485. * Append an hook to a rope object
  151486. * @param impostor is the rope impostor to add hook to
  151487. * @param otherImpostor is the rigid impostor to hook to
  151488. * @param length ratio along the rope from 0 to 1
  151489. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  151490. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  151491. */
  151492. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  151493. /**
  151494. * Sleeps the physics body and stops it from being active
  151495. * @param impostor impostor to sleep
  151496. */
  151497. sleepBody(impostor: PhysicsImpostor): void;
  151498. /**
  151499. * Activates the physics body
  151500. * @param impostor impostor to activate
  151501. */
  151502. wakeUpBody(impostor: PhysicsImpostor): void;
  151503. /**
  151504. * Updates the distance parameters of the joint
  151505. * @param joint joint to update
  151506. * @param maxDistance maximum distance of the joint
  151507. * @param minDistance minimum distance of the joint
  151508. */
  151509. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  151510. /**
  151511. * Sets a motor on the joint
  151512. * @param joint joint to set motor on
  151513. * @param speed speed of the motor
  151514. * @param maxForce maximum force of the motor
  151515. * @param motorIndex index of the motor
  151516. */
  151517. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  151518. /**
  151519. * Sets the motors limit
  151520. * @param joint joint to set limit on
  151521. * @param upperLimit upper limit
  151522. * @param lowerLimit lower limit
  151523. */
  151524. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  151525. /**
  151526. * Syncs the position and rotation of a mesh with the impostor
  151527. * @param mesh mesh to sync
  151528. * @param impostor impostor to update the mesh with
  151529. */
  151530. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  151531. /**
  151532. * Gets the radius of the impostor
  151533. * @param impostor impostor to get radius from
  151534. * @returns the radius
  151535. */
  151536. getRadius(impostor: PhysicsImpostor): number;
  151537. /**
  151538. * Gets the box size of the impostor
  151539. * @param impostor impostor to get box size from
  151540. * @param result the resulting box size
  151541. */
  151542. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  151543. /**
  151544. * Disposes of the impostor
  151545. */
  151546. dispose(): void;
  151547. /**
  151548. * Does a raycast in the physics world
  151549. * @param from when should the ray start?
  151550. * @param to when should the ray end?
  151551. * @returns PhysicsRaycastResult
  151552. */
  151553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  151554. }
  151555. }
  151556. declare module BABYLON {
  151557. interface AbstractScene {
  151558. /**
  151559. * The list of reflection probes added to the scene
  151560. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  151561. */
  151562. reflectionProbes: Array<ReflectionProbe>;
  151563. /**
  151564. * Removes the given reflection probe from this scene.
  151565. * @param toRemove The reflection probe to remove
  151566. * @returns The index of the removed reflection probe
  151567. */
  151568. removeReflectionProbe(toRemove: ReflectionProbe): number;
  151569. /**
  151570. * Adds the given reflection probe to this scene.
  151571. * @param newReflectionProbe The reflection probe to add
  151572. */
  151573. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  151574. }
  151575. /**
  151576. * Class used to generate realtime reflection / refraction cube textures
  151577. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  151578. */
  151579. export class ReflectionProbe {
  151580. /** defines the name of the probe */
  151581. name: string;
  151582. private _scene;
  151583. private _renderTargetTexture;
  151584. private _projectionMatrix;
  151585. private _viewMatrix;
  151586. private _target;
  151587. private _add;
  151588. private _attachedMesh;
  151589. private _invertYAxis;
  151590. /** Gets or sets probe position (center of the cube map) */
  151591. position: Vector3;
  151592. /**
  151593. * Creates a new reflection probe
  151594. * @param name defines the name of the probe
  151595. * @param size defines the texture resolution (for each face)
  151596. * @param scene defines the hosting scene
  151597. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  151598. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  151599. */
  151600. constructor(
  151601. /** defines the name of the probe */
  151602. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  151603. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  151604. get samples(): number;
  151605. set samples(value: number);
  151606. /** Gets or sets the refresh rate to use (on every frame by default) */
  151607. get refreshRate(): number;
  151608. set refreshRate(value: number);
  151609. /**
  151610. * Gets the hosting scene
  151611. * @returns a Scene
  151612. */
  151613. getScene(): Scene;
  151614. /** Gets the internal CubeTexture used to render to */
  151615. get cubeTexture(): RenderTargetTexture;
  151616. /** Gets the list of meshes to render */
  151617. get renderList(): Nullable<AbstractMesh[]>;
  151618. /**
  151619. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  151620. * @param mesh defines the mesh to attach to
  151621. */
  151622. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  151623. /**
  151624. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  151625. * @param renderingGroupId The rendering group id corresponding to its index
  151626. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  151627. */
  151628. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  151629. /**
  151630. * Clean all associated resources
  151631. */
  151632. dispose(): void;
  151633. /**
  151634. * Converts the reflection probe information to a readable string for debug purpose.
  151635. * @param fullDetails Supports for multiple levels of logging within scene loading
  151636. * @returns the human readable reflection probe info
  151637. */
  151638. toString(fullDetails?: boolean): string;
  151639. /**
  151640. * Get the class name of the refection probe.
  151641. * @returns "ReflectionProbe"
  151642. */
  151643. getClassName(): string;
  151644. /**
  151645. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  151646. * @returns The JSON representation of the texture
  151647. */
  151648. serialize(): any;
  151649. /**
  151650. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  151651. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  151652. * @param scene Define the scene the parsed reflection probe should be instantiated in
  151653. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  151654. * @returns The parsed reflection probe if successful
  151655. */
  151656. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  151657. }
  151658. }
  151659. declare module BABYLON {
  151660. /** @hidden */
  151661. export var _BabylonLoaderRegistered: boolean;
  151662. /**
  151663. * Helps setting up some configuration for the babylon file loader.
  151664. */
  151665. export class BabylonFileLoaderConfiguration {
  151666. /**
  151667. * The loader does not allow injecting custom physics engine into the plugins.
  151668. * Unfortunately in ES6, we need to manually inject them into the plugin.
  151669. * So you could set this variable to your engine import to make it work.
  151670. */
  151671. static LoaderInjectedPhysicsEngine: any;
  151672. }
  151673. }
  151674. declare module BABYLON {
  151675. /**
  151676. * A material to use for fast depth-only rendering.
  151677. */
  151678. export class OcclusionMaterial extends ShaderMaterial {
  151679. constructor(name: string, scene: Scene);
  151680. }
  151681. }
  151682. declare module BABYLON {
  151683. /**
  151684. * The Physically based simple base material of BJS.
  151685. *
  151686. * This enables better naming and convention enforcements on top of the pbrMaterial.
  151687. * It is used as the base class for both the specGloss and metalRough conventions.
  151688. */
  151689. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  151690. /**
  151691. * Number of Simultaneous lights allowed on the material.
  151692. */
  151693. maxSimultaneousLights: number;
  151694. /**
  151695. * If sets to true, disables all the lights affecting the material.
  151696. */
  151697. disableLighting: boolean;
  151698. /**
  151699. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  151700. */
  151701. environmentTexture: BaseTexture;
  151702. /**
  151703. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  151704. */
  151705. invertNormalMapX: boolean;
  151706. /**
  151707. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  151708. */
  151709. invertNormalMapY: boolean;
  151710. /**
  151711. * Normal map used in the model.
  151712. */
  151713. normalTexture: BaseTexture;
  151714. /**
  151715. * Emissivie color used to self-illuminate the model.
  151716. */
  151717. emissiveColor: Color3;
  151718. /**
  151719. * Emissivie texture used to self-illuminate the model.
  151720. */
  151721. emissiveTexture: BaseTexture;
  151722. /**
  151723. * Occlusion Channel Strength.
  151724. */
  151725. occlusionStrength: number;
  151726. /**
  151727. * Occlusion Texture of the material (adding extra occlusion effects).
  151728. */
  151729. occlusionTexture: BaseTexture;
  151730. /**
  151731. * Defines the alpha limits in alpha test mode.
  151732. */
  151733. alphaCutOff: number;
  151734. /**
  151735. * Gets the current double sided mode.
  151736. */
  151737. get doubleSided(): boolean;
  151738. /**
  151739. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  151740. */
  151741. set doubleSided(value: boolean);
  151742. /**
  151743. * Stores the pre-calculated light information of a mesh in a texture.
  151744. */
  151745. lightmapTexture: BaseTexture;
  151746. /**
  151747. * If true, the light map contains occlusion information instead of lighting info.
  151748. */
  151749. useLightmapAsShadowmap: boolean;
  151750. /**
  151751. * Instantiates a new PBRMaterial instance.
  151752. *
  151753. * @param name The material name
  151754. * @param scene The scene the material will be use in.
  151755. */
  151756. constructor(name: string, scene: Scene);
  151757. getClassName(): string;
  151758. }
  151759. }
  151760. declare module BABYLON {
  151761. /**
  151762. * The PBR material of BJS following the metal roughness convention.
  151763. *
  151764. * This fits to the PBR convention in the GLTF definition:
  151765. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  151766. */
  151767. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  151768. /**
  151769. * The base color has two different interpretations depending on the value of metalness.
  151770. * When the material is a metal, the base color is the specific measured reflectance value
  151771. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  151772. * of the material.
  151773. */
  151774. baseColor: Color3;
  151775. /**
  151776. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  151777. * well as opacity information in the alpha channel.
  151778. */
  151779. baseTexture: BaseTexture;
  151780. /**
  151781. * Specifies the metallic scalar value of the material.
  151782. * Can also be used to scale the metalness values of the metallic texture.
  151783. */
  151784. metallic: number;
  151785. /**
  151786. * Specifies the roughness scalar value of the material.
  151787. * Can also be used to scale the roughness values of the metallic texture.
  151788. */
  151789. roughness: number;
  151790. /**
  151791. * Texture containing both the metallic value in the B channel and the
  151792. * roughness value in the G channel to keep better precision.
  151793. */
  151794. metallicRoughnessTexture: BaseTexture;
  151795. /**
  151796. * Instantiates a new PBRMetalRoughnessMaterial instance.
  151797. *
  151798. * @param name The material name
  151799. * @param scene The scene the material will be use in.
  151800. */
  151801. constructor(name: string, scene: Scene);
  151802. /**
  151803. * Return the current class name of the material.
  151804. */
  151805. getClassName(): string;
  151806. /**
  151807. * Makes a duplicate of the current material.
  151808. * @param name - name to use for the new material.
  151809. */
  151810. clone(name: string): PBRMetallicRoughnessMaterial;
  151811. /**
  151812. * Serialize the material to a parsable JSON object.
  151813. */
  151814. serialize(): any;
  151815. /**
  151816. * Parses a JSON object corresponding to the serialize function.
  151817. */
  151818. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  151819. }
  151820. }
  151821. declare module BABYLON {
  151822. /**
  151823. * The PBR material of BJS following the specular glossiness convention.
  151824. *
  151825. * This fits to the PBR convention in the GLTF definition:
  151826. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  151827. */
  151828. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  151829. /**
  151830. * Specifies the diffuse color of the material.
  151831. */
  151832. diffuseColor: Color3;
  151833. /**
  151834. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  151835. * channel.
  151836. */
  151837. diffuseTexture: BaseTexture;
  151838. /**
  151839. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  151840. */
  151841. specularColor: Color3;
  151842. /**
  151843. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  151844. */
  151845. glossiness: number;
  151846. /**
  151847. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  151848. */
  151849. specularGlossinessTexture: BaseTexture;
  151850. /**
  151851. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  151852. */
  151853. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  151854. /**
  151855. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  151856. *
  151857. * @param name The material name
  151858. * @param scene The scene the material will be use in.
  151859. */
  151860. constructor(name: string, scene: Scene);
  151861. /**
  151862. * Return the current class name of the material.
  151863. */
  151864. getClassName(): string;
  151865. /**
  151866. * Makes a duplicate of the current material.
  151867. * @param name - name to use for the new material.
  151868. */
  151869. clone(name: string): PBRSpecularGlossinessMaterial;
  151870. /**
  151871. * Serialize the material to a parsable JSON object.
  151872. */
  151873. serialize(): any;
  151874. /**
  151875. * Parses a JSON object corresponding to the serialize function.
  151876. */
  151877. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  151878. }
  151879. }
  151880. declare module BABYLON {
  151881. /**
  151882. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  151883. * It can help converting any input color in a desired output one. This can then be used to create effects
  151884. * from sepia, black and white to sixties or futuristic rendering...
  151885. *
  151886. * The only supported format is currently 3dl.
  151887. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  151888. */
  151889. export class ColorGradingTexture extends BaseTexture {
  151890. /**
  151891. * The texture URL.
  151892. */
  151893. url: string;
  151894. /**
  151895. * Empty line regex stored for GC.
  151896. */
  151897. private static _noneEmptyLineRegex;
  151898. private _textureMatrix;
  151899. private _onLoad;
  151900. /**
  151901. * Instantiates a ColorGradingTexture from the following parameters.
  151902. *
  151903. * @param url The location of the color grading data (currently only supporting 3dl)
  151904. * @param sceneOrEngine The scene or engine the texture will be used in
  151905. * @param onLoad defines a callback triggered when the texture has been loaded
  151906. */
  151907. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  151908. /**
  151909. * Fires the onload event from the constructor if requested.
  151910. */
  151911. private _triggerOnLoad;
  151912. /**
  151913. * Returns the texture matrix used in most of the material.
  151914. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  151915. */
  151916. getTextureMatrix(): Matrix;
  151917. /**
  151918. * Occurs when the file being loaded is a .3dl LUT file.
  151919. */
  151920. private load3dlTexture;
  151921. /**
  151922. * Starts the loading process of the texture.
  151923. */
  151924. private loadTexture;
  151925. /**
  151926. * Clones the color grading texture.
  151927. */
  151928. clone(): ColorGradingTexture;
  151929. /**
  151930. * Called during delayed load for textures.
  151931. */
  151932. delayLoad(): void;
  151933. /**
  151934. * Parses a color grading texture serialized by Babylon.
  151935. * @param parsedTexture The texture information being parsedTexture
  151936. * @param scene The scene to load the texture in
  151937. * @param rootUrl The root url of the data assets to load
  151938. * @return A color grading texture
  151939. */
  151940. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  151941. /**
  151942. * Serializes the LUT texture to json format.
  151943. */
  151944. serialize(): any;
  151945. }
  151946. }
  151947. declare module BABYLON {
  151948. /**
  151949. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  151950. */
  151951. export class EquiRectangularCubeTexture extends BaseTexture {
  151952. /** The six faces of the cube. */
  151953. private static _FacesMapping;
  151954. private _noMipmap;
  151955. private _onLoad;
  151956. private _onError;
  151957. /** The size of the cubemap. */
  151958. private _size;
  151959. /** The buffer of the image. */
  151960. private _buffer;
  151961. /** The width of the input image. */
  151962. private _width;
  151963. /** The height of the input image. */
  151964. private _height;
  151965. /** The URL to the image. */
  151966. url: string;
  151967. /**
  151968. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  151969. * @param url The location of the image
  151970. * @param scene The scene the texture will be used in
  151971. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  151972. * @param noMipmap Forces to not generate the mipmap if true
  151973. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151974. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151975. * @param onLoad — defines a callback called when texture is loaded
  151976. * @param onError — defines a callback called if there is an error
  151977. */
  151978. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  151979. /**
  151980. * Load the image data, by putting the image on a canvas and extracting its buffer.
  151981. */
  151982. private loadImage;
  151983. /**
  151984. * Convert the image buffer into a cubemap and create a CubeTexture.
  151985. */
  151986. private loadTexture;
  151987. /**
  151988. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  151989. * @param buffer The ArrayBuffer that should be converted.
  151990. * @returns The buffer as Float32Array.
  151991. */
  151992. private getFloat32ArrayFromArrayBuffer;
  151993. /**
  151994. * Get the current class name of the texture useful for serialization or dynamic coding.
  151995. * @returns "EquiRectangularCubeTexture"
  151996. */
  151997. getClassName(): string;
  151998. /**
  151999. * Create a clone of the current EquiRectangularCubeTexture and return it.
  152000. * @returns A clone of the current EquiRectangularCubeTexture.
  152001. */
  152002. clone(): EquiRectangularCubeTexture;
  152003. }
  152004. }
  152005. declare module BABYLON {
  152006. /**
  152007. * Defines the options related to the creation of an HtmlElementTexture
  152008. */
  152009. export interface IHtmlElementTextureOptions {
  152010. /**
  152011. * Defines whether mip maps should be created or not.
  152012. */
  152013. generateMipMaps?: boolean;
  152014. /**
  152015. * Defines the sampling mode of the texture.
  152016. */
  152017. samplingMode?: number;
  152018. /**
  152019. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  152020. */
  152021. engine: Nullable<ThinEngine>;
  152022. /**
  152023. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  152024. */
  152025. scene: Nullable<Scene>;
  152026. }
  152027. /**
  152028. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  152029. * To be as efficient as possible depending on your constraints nothing aside the first upload
  152030. * is automatically managed.
  152031. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  152032. * in your application.
  152033. *
  152034. * As the update is not automatic, you need to call them manually.
  152035. */
  152036. export class HtmlElementTexture extends BaseTexture {
  152037. /**
  152038. * The texture URL.
  152039. */
  152040. element: HTMLVideoElement | HTMLCanvasElement;
  152041. private static readonly DefaultOptions;
  152042. private _textureMatrix;
  152043. private _isVideo;
  152044. private _generateMipMaps;
  152045. private _samplingMode;
  152046. /**
  152047. * Instantiates a HtmlElementTexture from the following parameters.
  152048. *
  152049. * @param name Defines the name of the texture
  152050. * @param element Defines the video or canvas the texture is filled with
  152051. * @param options Defines the other none mandatory texture creation options
  152052. */
  152053. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  152054. private _createInternalTexture;
  152055. /**
  152056. * Returns the texture matrix used in most of the material.
  152057. */
  152058. getTextureMatrix(): Matrix;
  152059. /**
  152060. * Updates the content of the texture.
  152061. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  152062. */
  152063. update(invertY?: Nullable<boolean>): void;
  152064. }
  152065. }
  152066. declare module BABYLON {
  152067. /**
  152068. * Based on jsTGALoader - Javascript loader for TGA file
  152069. * By Vincent Thibault
  152070. * @see http://blog.robrowser.com/javascript-tga-loader.html
  152071. */
  152072. export class TGATools {
  152073. private static _TYPE_INDEXED;
  152074. private static _TYPE_RGB;
  152075. private static _TYPE_GREY;
  152076. private static _TYPE_RLE_INDEXED;
  152077. private static _TYPE_RLE_RGB;
  152078. private static _TYPE_RLE_GREY;
  152079. private static _ORIGIN_MASK;
  152080. private static _ORIGIN_SHIFT;
  152081. private static _ORIGIN_BL;
  152082. private static _ORIGIN_BR;
  152083. private static _ORIGIN_UL;
  152084. private static _ORIGIN_UR;
  152085. /**
  152086. * Gets the header of a TGA file
  152087. * @param data defines the TGA data
  152088. * @returns the header
  152089. */
  152090. static GetTGAHeader(data: Uint8Array): any;
  152091. /**
  152092. * Uploads TGA content to a Babylon Texture
  152093. * @hidden
  152094. */
  152095. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  152096. /** @hidden */
  152097. 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;
  152098. /** @hidden */
  152099. 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;
  152100. /** @hidden */
  152101. 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;
  152102. /** @hidden */
  152103. 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;
  152104. /** @hidden */
  152105. 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;
  152106. /** @hidden */
  152107. 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;
  152108. }
  152109. }
  152110. declare module BABYLON {
  152111. /**
  152112. * Implementation of the TGA Texture Loader.
  152113. * @hidden
  152114. */
  152115. export class _TGATextureLoader implements IInternalTextureLoader {
  152116. /**
  152117. * Defines whether the loader supports cascade loading the different faces.
  152118. */
  152119. readonly supportCascades: boolean;
  152120. /**
  152121. * This returns if the loader support the current file information.
  152122. * @param extension defines the file extension of the file being loaded
  152123. * @returns true if the loader can load the specified file
  152124. */
  152125. canLoad(extension: string): boolean;
  152126. /**
  152127. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  152128. * @param data contains the texture data
  152129. * @param texture defines the BabylonJS internal texture
  152130. * @param createPolynomials will be true if polynomials have been requested
  152131. * @param onLoad defines the callback to trigger once the texture is ready
  152132. * @param onError defines the callback to trigger in case of error
  152133. */
  152134. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  152135. /**
  152136. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  152137. * @param data contains the texture data
  152138. * @param texture defines the BabylonJS internal texture
  152139. * @param callback defines the method to call once ready to upload
  152140. */
  152141. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  152142. }
  152143. }
  152144. declare module BABYLON {
  152145. /**
  152146. * Implementation of the HDR Texture Loader.
  152147. * @hidden
  152148. */
  152149. export class _HDRTextureLoader implements IInternalTextureLoader {
  152150. /**
  152151. * Defines whether the loader supports cascade loading the different faces.
  152152. */
  152153. readonly supportCascades: boolean;
  152154. /**
  152155. * This returns if the loader support the current file information.
  152156. * @param extension defines the file extension of the file being loaded
  152157. * @returns true if the loader can load the specified file
  152158. */
  152159. canLoad(extension: string): boolean;
  152160. /**
  152161. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  152162. * @param data contains the texture data
  152163. * @param texture defines the BabylonJS internal texture
  152164. * @param createPolynomials will be true if polynomials have been requested
  152165. * @param onLoad defines the callback to trigger once the texture is ready
  152166. * @param onError defines the callback to trigger in case of error
  152167. */
  152168. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  152169. /**
  152170. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  152171. * @param data contains the texture data
  152172. * @param texture defines the BabylonJS internal texture
  152173. * @param callback defines the method to call once ready to upload
  152174. */
  152175. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  152176. }
  152177. }
  152178. declare module BABYLON {
  152179. /**
  152180. * Info about the .basis files
  152181. */
  152182. class BasisFileInfo {
  152183. /**
  152184. * If the file has alpha
  152185. */
  152186. hasAlpha: boolean;
  152187. /**
  152188. * Info about each image of the basis file
  152189. */
  152190. images: Array<{
  152191. levels: Array<{
  152192. width: number;
  152193. height: number;
  152194. transcodedPixels: ArrayBufferView;
  152195. }>;
  152196. }>;
  152197. }
  152198. /**
  152199. * Result of transcoding a basis file
  152200. */
  152201. class TranscodeResult {
  152202. /**
  152203. * Info about the .basis file
  152204. */
  152205. fileInfo: BasisFileInfo;
  152206. /**
  152207. * Format to use when loading the file
  152208. */
  152209. format: number;
  152210. }
  152211. /**
  152212. * Configuration options for the Basis transcoder
  152213. */
  152214. export class BasisTranscodeConfiguration {
  152215. /**
  152216. * Supported compression formats used to determine the supported output format of the transcoder
  152217. */
  152218. supportedCompressionFormats?: {
  152219. /**
  152220. * etc1 compression format
  152221. */
  152222. etc1?: boolean;
  152223. /**
  152224. * s3tc compression format
  152225. */
  152226. s3tc?: boolean;
  152227. /**
  152228. * pvrtc compression format
  152229. */
  152230. pvrtc?: boolean;
  152231. /**
  152232. * etc2 compression format
  152233. */
  152234. etc2?: boolean;
  152235. };
  152236. /**
  152237. * If mipmap levels should be loaded for transcoded images (Default: true)
  152238. */
  152239. loadMipmapLevels?: boolean;
  152240. /**
  152241. * Index of a single image to load (Default: all images)
  152242. */
  152243. loadSingleImage?: number;
  152244. }
  152245. /**
  152246. * Used to load .Basis files
  152247. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  152248. */
  152249. export class BasisTools {
  152250. private static _IgnoreSupportedFormats;
  152251. /**
  152252. * URL to use when loading the basis transcoder
  152253. */
  152254. static JSModuleURL: string;
  152255. /**
  152256. * URL to use when loading the wasm module for the transcoder
  152257. */
  152258. static WasmModuleURL: string;
  152259. /**
  152260. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  152261. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  152262. * @returns internal format corresponding to the Basis format
  152263. */
  152264. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  152265. private static _WorkerPromise;
  152266. private static _Worker;
  152267. private static _actionId;
  152268. private static _CreateWorkerAsync;
  152269. /**
  152270. * Transcodes a loaded image file to compressed pixel data
  152271. * @param data image data to transcode
  152272. * @param config configuration options for the transcoding
  152273. * @returns a promise resulting in the transcoded image
  152274. */
  152275. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  152276. /**
  152277. * Loads a texture from the transcode result
  152278. * @param texture texture load to
  152279. * @param transcodeResult the result of transcoding the basis file to load from
  152280. */
  152281. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  152282. }
  152283. }
  152284. declare module BABYLON {
  152285. /**
  152286. * Loader for .basis file format
  152287. */
  152288. export class _BasisTextureLoader implements IInternalTextureLoader {
  152289. /**
  152290. * Defines whether the loader supports cascade loading the different faces.
  152291. */
  152292. readonly supportCascades: boolean;
  152293. /**
  152294. * This returns if the loader support the current file information.
  152295. * @param extension defines the file extension of the file being loaded
  152296. * @returns true if the loader can load the specified file
  152297. */
  152298. canLoad(extension: string): boolean;
  152299. /**
  152300. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  152301. * @param data contains the texture data
  152302. * @param texture defines the BabylonJS internal texture
  152303. * @param createPolynomials will be true if polynomials have been requested
  152304. * @param onLoad defines the callback to trigger once the texture is ready
  152305. * @param onError defines the callback to trigger in case of error
  152306. */
  152307. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  152308. /**
  152309. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  152310. * @param data contains the texture data
  152311. * @param texture defines the BabylonJS internal texture
  152312. * @param callback defines the method to call once ready to upload
  152313. */
  152314. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  152315. }
  152316. }
  152317. declare module BABYLON {
  152318. /**
  152319. * Defines the basic options interface of a TexturePacker Frame
  152320. */
  152321. export interface ITexturePackerFrame {
  152322. /**
  152323. * The frame ID
  152324. */
  152325. id: number;
  152326. /**
  152327. * The frames Scale
  152328. */
  152329. scale: Vector2;
  152330. /**
  152331. * The Frames offset
  152332. */
  152333. offset: Vector2;
  152334. }
  152335. /**
  152336. * This is a support class for frame Data on texture packer sets.
  152337. */
  152338. export class TexturePackerFrame implements ITexturePackerFrame {
  152339. /**
  152340. * The frame ID
  152341. */
  152342. id: number;
  152343. /**
  152344. * The frames Scale
  152345. */
  152346. scale: Vector2;
  152347. /**
  152348. * The Frames offset
  152349. */
  152350. offset: Vector2;
  152351. /**
  152352. * Initializes a texture package frame.
  152353. * @param id The numerical frame identifier
  152354. * @param scale Scalar Vector2 for UV frame
  152355. * @param offset Vector2 for the frame position in UV units.
  152356. * @returns TexturePackerFrame
  152357. */
  152358. constructor(id: number, scale: Vector2, offset: Vector2);
  152359. }
  152360. }
  152361. declare module BABYLON {
  152362. /**
  152363. * Defines the basic options interface of a TexturePacker
  152364. */
  152365. export interface ITexturePackerOptions {
  152366. /**
  152367. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  152368. */
  152369. map?: string[];
  152370. /**
  152371. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  152372. */
  152373. uvsIn?: string;
  152374. /**
  152375. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  152376. */
  152377. uvsOut?: string;
  152378. /**
  152379. * number representing the layout style. Defaults to LAYOUT_STRIP
  152380. */
  152381. layout?: number;
  152382. /**
  152383. * number of columns if using custom column count layout(2). This defaults to 4.
  152384. */
  152385. colnum?: number;
  152386. /**
  152387. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  152388. */
  152389. updateInputMeshes?: boolean;
  152390. /**
  152391. * boolean flag to dispose all the source textures. Defaults to true.
  152392. */
  152393. disposeSources?: boolean;
  152394. /**
  152395. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  152396. */
  152397. fillBlanks?: boolean;
  152398. /**
  152399. * string value representing the context fill style color. Defaults to 'black'.
  152400. */
  152401. customFillColor?: string;
  152402. /**
  152403. * Width and Height Value of each Frame in the TexturePacker Sets
  152404. */
  152405. frameSize?: number;
  152406. /**
  152407. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  152408. */
  152409. paddingRatio?: number;
  152410. /**
  152411. * Number that declares the fill method for the padding gutter.
  152412. */
  152413. paddingMode?: number;
  152414. /**
  152415. * If in SUBUV_COLOR padding mode what color to use.
  152416. */
  152417. paddingColor?: Color3 | Color4;
  152418. }
  152419. /**
  152420. * Defines the basic interface of a TexturePacker JSON File
  152421. */
  152422. export interface ITexturePackerJSON {
  152423. /**
  152424. * The frame ID
  152425. */
  152426. name: string;
  152427. /**
  152428. * The base64 channel data
  152429. */
  152430. sets: any;
  152431. /**
  152432. * The options of the Packer
  152433. */
  152434. options: ITexturePackerOptions;
  152435. /**
  152436. * The frame data of the Packer
  152437. */
  152438. frames: Array<number>;
  152439. }
  152440. /**
  152441. * This is a support class that generates a series of packed texture sets.
  152442. * @see https://doc.babylonjs.com/babylon101/materials
  152443. */
  152444. export class TexturePacker {
  152445. /** Packer Layout Constant 0 */
  152446. static readonly LAYOUT_STRIP: number;
  152447. /** Packer Layout Constant 1 */
  152448. static readonly LAYOUT_POWER2: number;
  152449. /** Packer Layout Constant 2 */
  152450. static readonly LAYOUT_COLNUM: number;
  152451. /** Packer Layout Constant 0 */
  152452. static readonly SUBUV_WRAP: number;
  152453. /** Packer Layout Constant 1 */
  152454. static readonly SUBUV_EXTEND: number;
  152455. /** Packer Layout Constant 2 */
  152456. static readonly SUBUV_COLOR: number;
  152457. /** The Name of the Texture Package */
  152458. name: string;
  152459. /** The scene scope of the TexturePacker */
  152460. scene: Scene;
  152461. /** The Meshes to target */
  152462. meshes: AbstractMesh[];
  152463. /** Arguments passed with the Constructor */
  152464. options: ITexturePackerOptions;
  152465. /** The promise that is started upon initialization */
  152466. promise: Nullable<Promise<TexturePacker | string>>;
  152467. /** The Container object for the channel sets that are generated */
  152468. sets: object;
  152469. /** The Container array for the frames that are generated */
  152470. frames: TexturePackerFrame[];
  152471. /** The expected number of textures the system is parsing. */
  152472. private _expecting;
  152473. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  152474. private _paddingValue;
  152475. /**
  152476. * Initializes a texture package series from an array of meshes or a single mesh.
  152477. * @param name The name of the package
  152478. * @param meshes The target meshes to compose the package from
  152479. * @param options The arguments that texture packer should follow while building.
  152480. * @param scene The scene which the textures are scoped to.
  152481. * @returns TexturePacker
  152482. */
  152483. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  152484. /**
  152485. * Starts the package process
  152486. * @param resolve The promises resolution function
  152487. * @returns TexturePacker
  152488. */
  152489. private _createFrames;
  152490. /**
  152491. * Calculates the Size of the Channel Sets
  152492. * @returns Vector2
  152493. */
  152494. private _calculateSize;
  152495. /**
  152496. * Calculates the UV data for the frames.
  152497. * @param baseSize the base frameSize
  152498. * @param padding the base frame padding
  152499. * @param dtSize size of the Dynamic Texture for that channel
  152500. * @param dtUnits is 1/dtSize
  152501. * @param update flag to update the input meshes
  152502. */
  152503. private _calculateMeshUVFrames;
  152504. /**
  152505. * Calculates the frames Offset.
  152506. * @param index of the frame
  152507. * @returns Vector2
  152508. */
  152509. private _getFrameOffset;
  152510. /**
  152511. * Updates a Mesh to the frame data
  152512. * @param mesh that is the target
  152513. * @param frameID or the frame index
  152514. */
  152515. private _updateMeshUV;
  152516. /**
  152517. * Updates a Meshes materials to use the texture packer channels
  152518. * @param m is the mesh to target
  152519. * @param force all channels on the packer to be set.
  152520. */
  152521. private _updateTextureReferences;
  152522. /**
  152523. * Public method to set a Mesh to a frame
  152524. * @param m that is the target
  152525. * @param frameID or the frame index
  152526. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  152527. */
  152528. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  152529. /**
  152530. * Starts the async promise to compile the texture packer.
  152531. * @returns Promise<void>
  152532. */
  152533. processAsync(): Promise<void>;
  152534. /**
  152535. * Disposes all textures associated with this packer
  152536. */
  152537. dispose(): void;
  152538. /**
  152539. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  152540. * @param imageType is the image type to use.
  152541. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  152542. */
  152543. download(imageType?: string, quality?: number): void;
  152544. /**
  152545. * Public method to load a texturePacker JSON file.
  152546. * @param data of the JSON file in string format.
  152547. */
  152548. updateFromJSON(data: string): void;
  152549. }
  152550. }
  152551. declare module BABYLON {
  152552. /**
  152553. * 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.
  152554. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  152555. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  152556. */
  152557. export class CustomProceduralTexture extends ProceduralTexture {
  152558. private _animate;
  152559. private _time;
  152560. private _config;
  152561. private _texturePath;
  152562. /**
  152563. * Instantiates a new Custom Procedural Texture.
  152564. * 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.
  152565. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  152566. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  152567. * @param name Define the name of the texture
  152568. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  152569. * @param size Define the size of the texture to create
  152570. * @param scene Define the scene the texture belongs to
  152571. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  152572. * @param generateMipMaps Define if the texture should creates mip maps or not
  152573. */
  152574. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  152575. private _loadJson;
  152576. /**
  152577. * Is the texture ready to be used ? (rendered at least once)
  152578. * @returns true if ready, otherwise, false.
  152579. */
  152580. isReady(): boolean;
  152581. /**
  152582. * Render the texture to its associated render target.
  152583. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  152584. */
  152585. render(useCameraPostProcess?: boolean): void;
  152586. /**
  152587. * Update the list of dependant textures samplers in the shader.
  152588. */
  152589. updateTextures(): void;
  152590. /**
  152591. * Update the uniform values of the procedural texture in the shader.
  152592. */
  152593. updateShaderUniforms(): void;
  152594. /**
  152595. * Define if the texture animates or not.
  152596. */
  152597. get animate(): boolean;
  152598. set animate(value: boolean);
  152599. }
  152600. }
  152601. declare module BABYLON {
  152602. /** @hidden */
  152603. export var noisePixelShader: {
  152604. name: string;
  152605. shader: string;
  152606. };
  152607. }
  152608. declare module BABYLON {
  152609. /**
  152610. * Class used to generate noise procedural textures
  152611. */
  152612. export class NoiseProceduralTexture extends ProceduralTexture {
  152613. /** Gets or sets the start time (default is 0) */
  152614. time: number;
  152615. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  152616. brightness: number;
  152617. /** Defines the number of octaves to process */
  152618. octaves: number;
  152619. /** Defines the level of persistence (0.8 by default) */
  152620. persistence: number;
  152621. /** Gets or sets animation speed factor (default is 1) */
  152622. animationSpeedFactor: number;
  152623. /**
  152624. * Creates a new NoiseProceduralTexture
  152625. * @param name defines the name fo the texture
  152626. * @param size defines the size of the texture (default is 256)
  152627. * @param scene defines the hosting scene
  152628. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  152629. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  152630. */
  152631. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  152632. private _updateShaderUniforms;
  152633. protected _getDefines(): string;
  152634. /** Generate the current state of the procedural texture */
  152635. render(useCameraPostProcess?: boolean): void;
  152636. /**
  152637. * Serializes this noise procedural texture
  152638. * @returns a serialized noise procedural texture object
  152639. */
  152640. serialize(): any;
  152641. /**
  152642. * Clone the texture.
  152643. * @returns the cloned texture
  152644. */
  152645. clone(): NoiseProceduralTexture;
  152646. /**
  152647. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  152648. * @param parsedTexture defines parsed texture data
  152649. * @param scene defines the current scene
  152650. * @param rootUrl defines the root URL containing noise procedural texture information
  152651. * @returns a parsed NoiseProceduralTexture
  152652. */
  152653. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  152654. }
  152655. }
  152656. declare module BABYLON {
  152657. /**
  152658. * Raw cube texture where the raw buffers are passed in
  152659. */
  152660. export class RawCubeTexture extends CubeTexture {
  152661. /**
  152662. * Creates a cube texture where the raw buffers are passed in.
  152663. * @param scene defines the scene the texture is attached to
  152664. * @param data defines the array of data to use to create each face
  152665. * @param size defines the size of the textures
  152666. * @param format defines the format of the data
  152667. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  152668. * @param generateMipMaps defines if the engine should generate the mip levels
  152669. * @param invertY defines if data must be stored with Y axis inverted
  152670. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  152671. * @param compression defines the compression used (null by default)
  152672. */
  152673. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  152674. /**
  152675. * Updates the raw cube texture.
  152676. * @param data defines the data to store
  152677. * @param format defines the data format
  152678. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152679. * @param invertY defines if data must be stored with Y axis inverted
  152680. * @param compression defines the compression used (null by default)
  152681. * @param level defines which level of the texture to update
  152682. */
  152683. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  152684. /**
  152685. * Updates a raw cube texture with RGBD encoded data.
  152686. * @param data defines the array of data [mipmap][face] to use to create each face
  152687. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  152688. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  152689. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  152690. * @returns a promise that resolves when the operation is complete
  152691. */
  152692. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  152693. /**
  152694. * Clones the raw cube texture.
  152695. * @return a new cube texture
  152696. */
  152697. clone(): CubeTexture;
  152698. /** @hidden */
  152699. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  152700. }
  152701. }
  152702. declare module BABYLON {
  152703. /**
  152704. * Class used to store 3D textures containing user data
  152705. */
  152706. export class RawTexture3D extends Texture {
  152707. /** Gets or sets the texture format to use */
  152708. format: number;
  152709. /**
  152710. * Create a new RawTexture3D
  152711. * @param data defines the data of the texture
  152712. * @param width defines the width of the texture
  152713. * @param height defines the height of the texture
  152714. * @param depth defines the depth of the texture
  152715. * @param format defines the texture format to use
  152716. * @param scene defines the hosting scene
  152717. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  152718. * @param invertY defines if texture must be stored with Y axis inverted
  152719. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  152720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  152721. */
  152722. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  152723. /** Gets or sets the texture format to use */
  152724. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  152725. /**
  152726. * Update the texture with new data
  152727. * @param data defines the data to store in the texture
  152728. */
  152729. update(data: ArrayBufferView): void;
  152730. }
  152731. }
  152732. declare module BABYLON {
  152733. /**
  152734. * Creates a refraction texture used by refraction channel of the standard material.
  152735. * It is like a mirror but to see through a material.
  152736. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  152737. */
  152738. export class RefractionTexture extends RenderTargetTexture {
  152739. /**
  152740. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  152741. * 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.
  152742. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  152743. */
  152744. refractionPlane: Plane;
  152745. /**
  152746. * Define how deep under the surface we should see.
  152747. */
  152748. depth: number;
  152749. /**
  152750. * Creates a refraction texture used by refraction channel of the standard material.
  152751. * It is like a mirror but to see through a material.
  152752. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  152753. * @param name Define the texture name
  152754. * @param size Define the size of the underlying texture
  152755. * @param scene Define the scene the refraction belongs to
  152756. * @param generateMipMaps Define if we need to generate mips level for the refraction
  152757. */
  152758. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  152759. /**
  152760. * Clone the refraction texture.
  152761. * @returns the cloned texture
  152762. */
  152763. clone(): RefractionTexture;
  152764. /**
  152765. * Serialize the texture to a JSON representation you could use in Parse later on
  152766. * @returns the serialized JSON representation
  152767. */
  152768. serialize(): any;
  152769. }
  152770. }
  152771. declare module BABYLON {
  152772. /**
  152773. * Block used to add support for vertex skinning (bones)
  152774. */
  152775. export class BonesBlock extends NodeMaterialBlock {
  152776. /**
  152777. * Creates a new BonesBlock
  152778. * @param name defines the block name
  152779. */
  152780. constructor(name: string);
  152781. /**
  152782. * Initialize the block and prepare the context for build
  152783. * @param state defines the state that will be used for the build
  152784. */
  152785. initialize(state: NodeMaterialBuildState): void;
  152786. /**
  152787. * Gets the current class name
  152788. * @returns the class name
  152789. */
  152790. getClassName(): string;
  152791. /**
  152792. * Gets the matrix indices input component
  152793. */
  152794. get matricesIndices(): NodeMaterialConnectionPoint;
  152795. /**
  152796. * Gets the matrix weights input component
  152797. */
  152798. get matricesWeights(): NodeMaterialConnectionPoint;
  152799. /**
  152800. * Gets the extra matrix indices input component
  152801. */
  152802. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  152803. /**
  152804. * Gets the extra matrix weights input component
  152805. */
  152806. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  152807. /**
  152808. * Gets the world input component
  152809. */
  152810. get world(): NodeMaterialConnectionPoint;
  152811. /**
  152812. * Gets the output component
  152813. */
  152814. get output(): NodeMaterialConnectionPoint;
  152815. autoConfigure(material: NodeMaterial): void;
  152816. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  152817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152819. protected _buildBlock(state: NodeMaterialBuildState): this;
  152820. }
  152821. }
  152822. declare module BABYLON {
  152823. /**
  152824. * Block used to add support for instances
  152825. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  152826. */
  152827. export class InstancesBlock extends NodeMaterialBlock {
  152828. /**
  152829. * Creates a new InstancesBlock
  152830. * @param name defines the block name
  152831. */
  152832. constructor(name: string);
  152833. /**
  152834. * Gets the current class name
  152835. * @returns the class name
  152836. */
  152837. getClassName(): string;
  152838. /**
  152839. * Gets the first world row input component
  152840. */
  152841. get world0(): NodeMaterialConnectionPoint;
  152842. /**
  152843. * Gets the second world row input component
  152844. */
  152845. get world1(): NodeMaterialConnectionPoint;
  152846. /**
  152847. * Gets the third world row input component
  152848. */
  152849. get world2(): NodeMaterialConnectionPoint;
  152850. /**
  152851. * Gets the forth world row input component
  152852. */
  152853. get world3(): NodeMaterialConnectionPoint;
  152854. /**
  152855. * Gets the world input component
  152856. */
  152857. get world(): NodeMaterialConnectionPoint;
  152858. /**
  152859. * Gets the output component
  152860. */
  152861. get output(): NodeMaterialConnectionPoint;
  152862. /**
  152863. * Gets the instanceID component
  152864. */
  152865. get instanceID(): NodeMaterialConnectionPoint;
  152866. autoConfigure(material: NodeMaterial): void;
  152867. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  152868. protected _buildBlock(state: NodeMaterialBuildState): this;
  152869. }
  152870. }
  152871. declare module BABYLON {
  152872. /**
  152873. * Block used to add morph targets support to vertex shader
  152874. */
  152875. export class MorphTargetsBlock extends NodeMaterialBlock {
  152876. private _repeatableContentAnchor;
  152877. /**
  152878. * Create a new MorphTargetsBlock
  152879. * @param name defines the block name
  152880. */
  152881. constructor(name: string);
  152882. /**
  152883. * Gets the current class name
  152884. * @returns the class name
  152885. */
  152886. getClassName(): string;
  152887. /**
  152888. * Gets the position input component
  152889. */
  152890. get position(): NodeMaterialConnectionPoint;
  152891. /**
  152892. * Gets the normal input component
  152893. */
  152894. get normal(): NodeMaterialConnectionPoint;
  152895. /**
  152896. * Gets the tangent input component
  152897. */
  152898. get tangent(): NodeMaterialConnectionPoint;
  152899. /**
  152900. * Gets the tangent input component
  152901. */
  152902. get uv(): NodeMaterialConnectionPoint;
  152903. /**
  152904. * Gets the position output component
  152905. */
  152906. get positionOutput(): NodeMaterialConnectionPoint;
  152907. /**
  152908. * Gets the normal output component
  152909. */
  152910. get normalOutput(): NodeMaterialConnectionPoint;
  152911. /**
  152912. * Gets the tangent output component
  152913. */
  152914. get tangentOutput(): NodeMaterialConnectionPoint;
  152915. /**
  152916. * Gets the tangent output component
  152917. */
  152918. get uvOutput(): NodeMaterialConnectionPoint;
  152919. initialize(state: NodeMaterialBuildState): void;
  152920. autoConfigure(material: NodeMaterial): void;
  152921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152923. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  152924. protected _buildBlock(state: NodeMaterialBuildState): this;
  152925. }
  152926. }
  152927. declare module BABYLON {
  152928. /**
  152929. * Block used to get data information from a light
  152930. */
  152931. export class LightInformationBlock extends NodeMaterialBlock {
  152932. private _lightDataUniformName;
  152933. private _lightColorUniformName;
  152934. private _lightTypeDefineName;
  152935. /**
  152936. * Gets or sets the light associated with this block
  152937. */
  152938. light: Nullable<Light>;
  152939. /**
  152940. * Creates a new LightInformationBlock
  152941. * @param name defines the block name
  152942. */
  152943. constructor(name: string);
  152944. /**
  152945. * Gets the current class name
  152946. * @returns the class name
  152947. */
  152948. getClassName(): string;
  152949. /**
  152950. * Gets the world position input component
  152951. */
  152952. get worldPosition(): NodeMaterialConnectionPoint;
  152953. /**
  152954. * Gets the direction output component
  152955. */
  152956. get direction(): NodeMaterialConnectionPoint;
  152957. /**
  152958. * Gets the direction output component
  152959. */
  152960. get color(): NodeMaterialConnectionPoint;
  152961. /**
  152962. * Gets the direction output component
  152963. */
  152964. get intensity(): NodeMaterialConnectionPoint;
  152965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  152966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152967. protected _buildBlock(state: NodeMaterialBuildState): this;
  152968. serialize(): any;
  152969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152970. }
  152971. }
  152972. declare module BABYLON {
  152973. /**
  152974. * Block used to add image processing support to fragment shader
  152975. */
  152976. export class ImageProcessingBlock extends NodeMaterialBlock {
  152977. /**
  152978. * Create a new ImageProcessingBlock
  152979. * @param name defines the block name
  152980. */
  152981. constructor(name: string);
  152982. /**
  152983. * Gets the current class name
  152984. * @returns the class name
  152985. */
  152986. getClassName(): string;
  152987. /**
  152988. * Gets the color input component
  152989. */
  152990. get color(): NodeMaterialConnectionPoint;
  152991. /**
  152992. * Gets the output component
  152993. */
  152994. get output(): NodeMaterialConnectionPoint;
  152995. /**
  152996. * Initialize the block and prepare the context for build
  152997. * @param state defines the state that will be used for the build
  152998. */
  152999. initialize(state: NodeMaterialBuildState): void;
  153000. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  153001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  153003. protected _buildBlock(state: NodeMaterialBuildState): this;
  153004. }
  153005. }
  153006. declare module BABYLON {
  153007. /**
  153008. * Block used to perturb normals based on a normal map
  153009. */
  153010. export class PerturbNormalBlock extends NodeMaterialBlock {
  153011. private _tangentSpaceParameterName;
  153012. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  153013. invertX: boolean;
  153014. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  153015. invertY: boolean;
  153016. /**
  153017. * Create a new PerturbNormalBlock
  153018. * @param name defines the block name
  153019. */
  153020. constructor(name: string);
  153021. /**
  153022. * Gets the current class name
  153023. * @returns the class name
  153024. */
  153025. getClassName(): string;
  153026. /**
  153027. * Gets the world position input component
  153028. */
  153029. get worldPosition(): NodeMaterialConnectionPoint;
  153030. /**
  153031. * Gets the world normal input component
  153032. */
  153033. get worldNormal(): NodeMaterialConnectionPoint;
  153034. /**
  153035. * Gets the world tangent input component
  153036. */
  153037. get worldTangent(): NodeMaterialConnectionPoint;
  153038. /**
  153039. * Gets the uv input component
  153040. */
  153041. get uv(): NodeMaterialConnectionPoint;
  153042. /**
  153043. * Gets the normal map color input component
  153044. */
  153045. get normalMapColor(): NodeMaterialConnectionPoint;
  153046. /**
  153047. * Gets the strength input component
  153048. */
  153049. get strength(): NodeMaterialConnectionPoint;
  153050. /**
  153051. * Gets the output component
  153052. */
  153053. get output(): NodeMaterialConnectionPoint;
  153054. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153055. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  153056. autoConfigure(material: NodeMaterial): void;
  153057. protected _buildBlock(state: NodeMaterialBuildState): this;
  153058. protected _dumpPropertiesCode(): string;
  153059. serialize(): any;
  153060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153061. }
  153062. }
  153063. declare module BABYLON {
  153064. /**
  153065. * Block used to discard a pixel if a value is smaller than a cutoff
  153066. */
  153067. export class DiscardBlock extends NodeMaterialBlock {
  153068. /**
  153069. * Create a new DiscardBlock
  153070. * @param name defines the block name
  153071. */
  153072. constructor(name: string);
  153073. /**
  153074. * Gets the current class name
  153075. * @returns the class name
  153076. */
  153077. getClassName(): string;
  153078. /**
  153079. * Gets the color input component
  153080. */
  153081. get value(): NodeMaterialConnectionPoint;
  153082. /**
  153083. * Gets the cutoff input component
  153084. */
  153085. get cutoff(): NodeMaterialConnectionPoint;
  153086. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  153087. }
  153088. }
  153089. declare module BABYLON {
  153090. /**
  153091. * Block used to test if the fragment shader is front facing
  153092. */
  153093. export class FrontFacingBlock extends NodeMaterialBlock {
  153094. /**
  153095. * Creates a new FrontFacingBlock
  153096. * @param name defines the block name
  153097. */
  153098. constructor(name: string);
  153099. /**
  153100. * Gets the current class name
  153101. * @returns the class name
  153102. */
  153103. getClassName(): string;
  153104. /**
  153105. * Gets the output component
  153106. */
  153107. get output(): NodeMaterialConnectionPoint;
  153108. protected _buildBlock(state: NodeMaterialBuildState): this;
  153109. }
  153110. }
  153111. declare module BABYLON {
  153112. /**
  153113. * Block used to get the derivative value on x and y of a given input
  153114. */
  153115. export class DerivativeBlock extends NodeMaterialBlock {
  153116. /**
  153117. * Create a new DerivativeBlock
  153118. * @param name defines the block name
  153119. */
  153120. constructor(name: string);
  153121. /**
  153122. * Gets the current class name
  153123. * @returns the class name
  153124. */
  153125. getClassName(): string;
  153126. /**
  153127. * Gets the input component
  153128. */
  153129. get input(): NodeMaterialConnectionPoint;
  153130. /**
  153131. * Gets the derivative output on x
  153132. */
  153133. get dx(): NodeMaterialConnectionPoint;
  153134. /**
  153135. * Gets the derivative output on y
  153136. */
  153137. get dy(): NodeMaterialConnectionPoint;
  153138. protected _buildBlock(state: NodeMaterialBuildState): this;
  153139. }
  153140. }
  153141. declare module BABYLON {
  153142. /**
  153143. * Block used to make gl_FragCoord available
  153144. */
  153145. export class FragCoordBlock extends NodeMaterialBlock {
  153146. /**
  153147. * Creates a new FragCoordBlock
  153148. * @param name defines the block name
  153149. */
  153150. constructor(name: string);
  153151. /**
  153152. * Gets the current class name
  153153. * @returns the class name
  153154. */
  153155. getClassName(): string;
  153156. /**
  153157. * Gets the xy component
  153158. */
  153159. get xy(): NodeMaterialConnectionPoint;
  153160. /**
  153161. * Gets the xyz component
  153162. */
  153163. get xyz(): NodeMaterialConnectionPoint;
  153164. /**
  153165. * Gets the xyzw component
  153166. */
  153167. get xyzw(): NodeMaterialConnectionPoint;
  153168. /**
  153169. * Gets the x component
  153170. */
  153171. get x(): NodeMaterialConnectionPoint;
  153172. /**
  153173. * Gets the y component
  153174. */
  153175. get y(): NodeMaterialConnectionPoint;
  153176. /**
  153177. * Gets the z component
  153178. */
  153179. get z(): NodeMaterialConnectionPoint;
  153180. /**
  153181. * Gets the w component
  153182. */
  153183. get output(): NodeMaterialConnectionPoint;
  153184. protected writeOutputs(state: NodeMaterialBuildState): string;
  153185. protected _buildBlock(state: NodeMaterialBuildState): this;
  153186. }
  153187. }
  153188. declare module BABYLON {
  153189. /**
  153190. * Block used to get the screen sizes
  153191. */
  153192. export class ScreenSizeBlock extends NodeMaterialBlock {
  153193. private _varName;
  153194. private _scene;
  153195. /**
  153196. * Creates a new ScreenSizeBlock
  153197. * @param name defines the block name
  153198. */
  153199. constructor(name: string);
  153200. /**
  153201. * Gets the current class name
  153202. * @returns the class name
  153203. */
  153204. getClassName(): string;
  153205. /**
  153206. * Gets the xy component
  153207. */
  153208. get xy(): NodeMaterialConnectionPoint;
  153209. /**
  153210. * Gets the x component
  153211. */
  153212. get x(): NodeMaterialConnectionPoint;
  153213. /**
  153214. * Gets the y component
  153215. */
  153216. get y(): NodeMaterialConnectionPoint;
  153217. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  153218. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  153219. protected _buildBlock(state: NodeMaterialBuildState): this;
  153220. }
  153221. }
  153222. declare module BABYLON {
  153223. /**
  153224. * Block used to add support for scene fog
  153225. */
  153226. export class FogBlock extends NodeMaterialBlock {
  153227. private _fogDistanceName;
  153228. private _fogParameters;
  153229. /**
  153230. * Create a new FogBlock
  153231. * @param name defines the block name
  153232. */
  153233. constructor(name: string);
  153234. /**
  153235. * Gets the current class name
  153236. * @returns the class name
  153237. */
  153238. getClassName(): string;
  153239. /**
  153240. * Gets the world position input component
  153241. */
  153242. get worldPosition(): NodeMaterialConnectionPoint;
  153243. /**
  153244. * Gets the view input component
  153245. */
  153246. get view(): NodeMaterialConnectionPoint;
  153247. /**
  153248. * Gets the color input component
  153249. */
  153250. get input(): NodeMaterialConnectionPoint;
  153251. /**
  153252. * Gets the fog color input component
  153253. */
  153254. get fogColor(): NodeMaterialConnectionPoint;
  153255. /**
  153256. * Gets the output component
  153257. */
  153258. get output(): NodeMaterialConnectionPoint;
  153259. autoConfigure(material: NodeMaterial): void;
  153260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  153262. protected _buildBlock(state: NodeMaterialBuildState): this;
  153263. }
  153264. }
  153265. declare module BABYLON {
  153266. /**
  153267. * Block used to add light in the fragment shader
  153268. */
  153269. export class LightBlock extends NodeMaterialBlock {
  153270. private _lightId;
  153271. /**
  153272. * Gets or sets the light associated with this block
  153273. */
  153274. light: Nullable<Light>;
  153275. /**
  153276. * Create a new LightBlock
  153277. * @param name defines the block name
  153278. */
  153279. constructor(name: string);
  153280. /**
  153281. * Gets the current class name
  153282. * @returns the class name
  153283. */
  153284. getClassName(): string;
  153285. /**
  153286. * Gets the world position input component
  153287. */
  153288. get worldPosition(): NodeMaterialConnectionPoint;
  153289. /**
  153290. * Gets the world normal input component
  153291. */
  153292. get worldNormal(): NodeMaterialConnectionPoint;
  153293. /**
  153294. * Gets the camera (or eye) position component
  153295. */
  153296. get cameraPosition(): NodeMaterialConnectionPoint;
  153297. /**
  153298. * Gets the glossiness component
  153299. */
  153300. get glossiness(): NodeMaterialConnectionPoint;
  153301. /**
  153302. * Gets the glossiness power component
  153303. */
  153304. get glossPower(): NodeMaterialConnectionPoint;
  153305. /**
  153306. * Gets the diffuse color component
  153307. */
  153308. get diffuseColor(): NodeMaterialConnectionPoint;
  153309. /**
  153310. * Gets the specular color component
  153311. */
  153312. get specularColor(): NodeMaterialConnectionPoint;
  153313. /**
  153314. * Gets the view matrix component
  153315. */
  153316. get view(): NodeMaterialConnectionPoint;
  153317. /**
  153318. * Gets the diffuse output component
  153319. */
  153320. get diffuseOutput(): NodeMaterialConnectionPoint;
  153321. /**
  153322. * Gets the specular output component
  153323. */
  153324. get specularOutput(): NodeMaterialConnectionPoint;
  153325. /**
  153326. * Gets the shadow output component
  153327. */
  153328. get shadow(): NodeMaterialConnectionPoint;
  153329. autoConfigure(material: NodeMaterial): void;
  153330. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153331. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  153332. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  153333. private _injectVertexCode;
  153334. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  153335. serialize(): any;
  153336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153337. }
  153338. }
  153339. declare module BABYLON {
  153340. /**
  153341. * Block used to read a reflection texture from a sampler
  153342. */
  153343. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  153344. /**
  153345. * Create a new ReflectionTextureBlock
  153346. * @param name defines the block name
  153347. */
  153348. constructor(name: string);
  153349. /**
  153350. * Gets the current class name
  153351. * @returns the class name
  153352. */
  153353. getClassName(): string;
  153354. /**
  153355. * Gets the world position input component
  153356. */
  153357. get position(): NodeMaterialConnectionPoint;
  153358. /**
  153359. * Gets the world position input component
  153360. */
  153361. get worldPosition(): NodeMaterialConnectionPoint;
  153362. /**
  153363. * Gets the world normal input component
  153364. */
  153365. get worldNormal(): NodeMaterialConnectionPoint;
  153366. /**
  153367. * Gets the world input component
  153368. */
  153369. get world(): NodeMaterialConnectionPoint;
  153370. /**
  153371. * Gets the camera (or eye) position component
  153372. */
  153373. get cameraPosition(): NodeMaterialConnectionPoint;
  153374. /**
  153375. * Gets the view input component
  153376. */
  153377. get view(): NodeMaterialConnectionPoint;
  153378. /**
  153379. * Gets the rgb output component
  153380. */
  153381. get rgb(): NodeMaterialConnectionPoint;
  153382. /**
  153383. * Gets the rgba output component
  153384. */
  153385. get rgba(): NodeMaterialConnectionPoint;
  153386. /**
  153387. * Gets the r output component
  153388. */
  153389. get r(): NodeMaterialConnectionPoint;
  153390. /**
  153391. * Gets the g output component
  153392. */
  153393. get g(): NodeMaterialConnectionPoint;
  153394. /**
  153395. * Gets the b output component
  153396. */
  153397. get b(): NodeMaterialConnectionPoint;
  153398. /**
  153399. * Gets the a output component
  153400. */
  153401. get a(): NodeMaterialConnectionPoint;
  153402. autoConfigure(material: NodeMaterial): void;
  153403. protected _buildBlock(state: NodeMaterialBuildState): this;
  153404. }
  153405. }
  153406. declare module BABYLON {
  153407. /**
  153408. * Block used to add 2 vectors
  153409. */
  153410. export class AddBlock extends NodeMaterialBlock {
  153411. /**
  153412. * Creates a new AddBlock
  153413. * @param name defines the block name
  153414. */
  153415. constructor(name: string);
  153416. /**
  153417. * Gets the current class name
  153418. * @returns the class name
  153419. */
  153420. getClassName(): string;
  153421. /**
  153422. * Gets the left operand input component
  153423. */
  153424. get left(): NodeMaterialConnectionPoint;
  153425. /**
  153426. * Gets the right operand input component
  153427. */
  153428. get right(): NodeMaterialConnectionPoint;
  153429. /**
  153430. * Gets the output component
  153431. */
  153432. get output(): NodeMaterialConnectionPoint;
  153433. protected _buildBlock(state: NodeMaterialBuildState): this;
  153434. }
  153435. }
  153436. declare module BABYLON {
  153437. /**
  153438. * Block used to scale a vector by a float
  153439. */
  153440. export class ScaleBlock extends NodeMaterialBlock {
  153441. /**
  153442. * Creates a new ScaleBlock
  153443. * @param name defines the block name
  153444. */
  153445. constructor(name: string);
  153446. /**
  153447. * Gets the current class name
  153448. * @returns the class name
  153449. */
  153450. getClassName(): string;
  153451. /**
  153452. * Gets the input component
  153453. */
  153454. get input(): NodeMaterialConnectionPoint;
  153455. /**
  153456. * Gets the factor input component
  153457. */
  153458. get factor(): NodeMaterialConnectionPoint;
  153459. /**
  153460. * Gets the output component
  153461. */
  153462. get output(): NodeMaterialConnectionPoint;
  153463. protected _buildBlock(state: NodeMaterialBuildState): this;
  153464. }
  153465. }
  153466. declare module BABYLON {
  153467. /**
  153468. * Block used to clamp a float
  153469. */
  153470. export class ClampBlock extends NodeMaterialBlock {
  153471. /** Gets or sets the minimum range */
  153472. minimum: number;
  153473. /** Gets or sets the maximum range */
  153474. maximum: number;
  153475. /**
  153476. * Creates a new ClampBlock
  153477. * @param name defines the block name
  153478. */
  153479. constructor(name: string);
  153480. /**
  153481. * Gets the current class name
  153482. * @returns the class name
  153483. */
  153484. getClassName(): string;
  153485. /**
  153486. * Gets the value input component
  153487. */
  153488. get value(): NodeMaterialConnectionPoint;
  153489. /**
  153490. * Gets the output component
  153491. */
  153492. get output(): NodeMaterialConnectionPoint;
  153493. protected _buildBlock(state: NodeMaterialBuildState): this;
  153494. protected _dumpPropertiesCode(): string;
  153495. serialize(): any;
  153496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153497. }
  153498. }
  153499. declare module BABYLON {
  153500. /**
  153501. * Block used to apply a cross product between 2 vectors
  153502. */
  153503. export class CrossBlock extends NodeMaterialBlock {
  153504. /**
  153505. * Creates a new CrossBlock
  153506. * @param name defines the block name
  153507. */
  153508. constructor(name: string);
  153509. /**
  153510. * Gets the current class name
  153511. * @returns the class name
  153512. */
  153513. getClassName(): string;
  153514. /**
  153515. * Gets the left operand input component
  153516. */
  153517. get left(): NodeMaterialConnectionPoint;
  153518. /**
  153519. * Gets the right operand input component
  153520. */
  153521. get right(): NodeMaterialConnectionPoint;
  153522. /**
  153523. * Gets the output component
  153524. */
  153525. get output(): NodeMaterialConnectionPoint;
  153526. protected _buildBlock(state: NodeMaterialBuildState): this;
  153527. }
  153528. }
  153529. declare module BABYLON {
  153530. /**
  153531. * Block used to apply a dot product between 2 vectors
  153532. */
  153533. export class DotBlock extends NodeMaterialBlock {
  153534. /**
  153535. * Creates a new DotBlock
  153536. * @param name defines the block name
  153537. */
  153538. constructor(name: string);
  153539. /**
  153540. * Gets the current class name
  153541. * @returns the class name
  153542. */
  153543. getClassName(): string;
  153544. /**
  153545. * Gets the left operand input component
  153546. */
  153547. get left(): NodeMaterialConnectionPoint;
  153548. /**
  153549. * Gets the right operand input component
  153550. */
  153551. get right(): NodeMaterialConnectionPoint;
  153552. /**
  153553. * Gets the output component
  153554. */
  153555. get output(): NodeMaterialConnectionPoint;
  153556. protected _buildBlock(state: NodeMaterialBuildState): this;
  153557. }
  153558. }
  153559. declare module BABYLON {
  153560. /**
  153561. * Block used to normalize a vector
  153562. */
  153563. export class NormalizeBlock extends NodeMaterialBlock {
  153564. /**
  153565. * Creates a new NormalizeBlock
  153566. * @param name defines the block name
  153567. */
  153568. constructor(name: string);
  153569. /**
  153570. * Gets the current class name
  153571. * @returns the class name
  153572. */
  153573. getClassName(): string;
  153574. /**
  153575. * Gets the input component
  153576. */
  153577. get input(): NodeMaterialConnectionPoint;
  153578. /**
  153579. * Gets the output component
  153580. */
  153581. get output(): NodeMaterialConnectionPoint;
  153582. protected _buildBlock(state: NodeMaterialBuildState): this;
  153583. }
  153584. }
  153585. declare module BABYLON {
  153586. /**
  153587. * Block used to create a Color3/4 out of individual inputs (one for each component)
  153588. */
  153589. export class ColorMergerBlock extends NodeMaterialBlock {
  153590. /**
  153591. * Create a new ColorMergerBlock
  153592. * @param name defines the block name
  153593. */
  153594. constructor(name: string);
  153595. /**
  153596. * Gets the current class name
  153597. * @returns the class name
  153598. */
  153599. getClassName(): string;
  153600. /**
  153601. * Gets the rgb component (input)
  153602. */
  153603. get rgbIn(): NodeMaterialConnectionPoint;
  153604. /**
  153605. * Gets the r component (input)
  153606. */
  153607. get r(): NodeMaterialConnectionPoint;
  153608. /**
  153609. * Gets the g component (input)
  153610. */
  153611. get g(): NodeMaterialConnectionPoint;
  153612. /**
  153613. * Gets the b component (input)
  153614. */
  153615. get b(): NodeMaterialConnectionPoint;
  153616. /**
  153617. * Gets the a component (input)
  153618. */
  153619. get a(): NodeMaterialConnectionPoint;
  153620. /**
  153621. * Gets the rgba component (output)
  153622. */
  153623. get rgba(): NodeMaterialConnectionPoint;
  153624. /**
  153625. * Gets the rgb component (output)
  153626. */
  153627. get rgbOut(): NodeMaterialConnectionPoint;
  153628. /**
  153629. * Gets the rgb component (output)
  153630. * @deprecated Please use rgbOut instead.
  153631. */
  153632. get rgb(): NodeMaterialConnectionPoint;
  153633. protected _buildBlock(state: NodeMaterialBuildState): this;
  153634. }
  153635. }
  153636. declare module BABYLON {
  153637. /**
  153638. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  153639. */
  153640. export class VectorSplitterBlock extends NodeMaterialBlock {
  153641. /**
  153642. * Create a new VectorSplitterBlock
  153643. * @param name defines the block name
  153644. */
  153645. constructor(name: string);
  153646. /**
  153647. * Gets the current class name
  153648. * @returns the class name
  153649. */
  153650. getClassName(): string;
  153651. /**
  153652. * Gets the xyzw component (input)
  153653. */
  153654. get xyzw(): NodeMaterialConnectionPoint;
  153655. /**
  153656. * Gets the xyz component (input)
  153657. */
  153658. get xyzIn(): NodeMaterialConnectionPoint;
  153659. /**
  153660. * Gets the xy component (input)
  153661. */
  153662. get xyIn(): NodeMaterialConnectionPoint;
  153663. /**
  153664. * Gets the xyz component (output)
  153665. */
  153666. get xyzOut(): NodeMaterialConnectionPoint;
  153667. /**
  153668. * Gets the xy component (output)
  153669. */
  153670. get xyOut(): NodeMaterialConnectionPoint;
  153671. /**
  153672. * Gets the x component (output)
  153673. */
  153674. get x(): NodeMaterialConnectionPoint;
  153675. /**
  153676. * Gets the y component (output)
  153677. */
  153678. get y(): NodeMaterialConnectionPoint;
  153679. /**
  153680. * Gets the z component (output)
  153681. */
  153682. get z(): NodeMaterialConnectionPoint;
  153683. /**
  153684. * Gets the w component (output)
  153685. */
  153686. get w(): NodeMaterialConnectionPoint;
  153687. protected _inputRename(name: string): string;
  153688. protected _outputRename(name: string): string;
  153689. protected _buildBlock(state: NodeMaterialBuildState): this;
  153690. }
  153691. }
  153692. declare module BABYLON {
  153693. /**
  153694. * Block used to lerp between 2 values
  153695. */
  153696. export class LerpBlock extends NodeMaterialBlock {
  153697. /**
  153698. * Creates a new LerpBlock
  153699. * @param name defines the block name
  153700. */
  153701. constructor(name: string);
  153702. /**
  153703. * Gets the current class name
  153704. * @returns the class name
  153705. */
  153706. getClassName(): string;
  153707. /**
  153708. * Gets the left operand input component
  153709. */
  153710. get left(): NodeMaterialConnectionPoint;
  153711. /**
  153712. * Gets the right operand input component
  153713. */
  153714. get right(): NodeMaterialConnectionPoint;
  153715. /**
  153716. * Gets the gradient operand input component
  153717. */
  153718. get gradient(): NodeMaterialConnectionPoint;
  153719. /**
  153720. * Gets the output component
  153721. */
  153722. get output(): NodeMaterialConnectionPoint;
  153723. protected _buildBlock(state: NodeMaterialBuildState): this;
  153724. }
  153725. }
  153726. declare module BABYLON {
  153727. /**
  153728. * Block used to divide 2 vectors
  153729. */
  153730. export class DivideBlock extends NodeMaterialBlock {
  153731. /**
  153732. * Creates a new DivideBlock
  153733. * @param name defines the block name
  153734. */
  153735. constructor(name: string);
  153736. /**
  153737. * Gets the current class name
  153738. * @returns the class name
  153739. */
  153740. getClassName(): string;
  153741. /**
  153742. * Gets the left operand input component
  153743. */
  153744. get left(): NodeMaterialConnectionPoint;
  153745. /**
  153746. * Gets the right operand input component
  153747. */
  153748. get right(): NodeMaterialConnectionPoint;
  153749. /**
  153750. * Gets the output component
  153751. */
  153752. get output(): NodeMaterialConnectionPoint;
  153753. protected _buildBlock(state: NodeMaterialBuildState): this;
  153754. }
  153755. }
  153756. declare module BABYLON {
  153757. /**
  153758. * Block used to subtract 2 vectors
  153759. */
  153760. export class SubtractBlock extends NodeMaterialBlock {
  153761. /**
  153762. * Creates a new SubtractBlock
  153763. * @param name defines the block name
  153764. */
  153765. constructor(name: string);
  153766. /**
  153767. * Gets the current class name
  153768. * @returns the class name
  153769. */
  153770. getClassName(): string;
  153771. /**
  153772. * Gets the left operand input component
  153773. */
  153774. get left(): NodeMaterialConnectionPoint;
  153775. /**
  153776. * Gets the right operand input component
  153777. */
  153778. get right(): NodeMaterialConnectionPoint;
  153779. /**
  153780. * Gets the output component
  153781. */
  153782. get output(): NodeMaterialConnectionPoint;
  153783. protected _buildBlock(state: NodeMaterialBuildState): this;
  153784. }
  153785. }
  153786. declare module BABYLON {
  153787. /**
  153788. * Block used to step a value
  153789. */
  153790. export class StepBlock extends NodeMaterialBlock {
  153791. /**
  153792. * Creates a new StepBlock
  153793. * @param name defines the block name
  153794. */
  153795. constructor(name: string);
  153796. /**
  153797. * Gets the current class name
  153798. * @returns the class name
  153799. */
  153800. getClassName(): string;
  153801. /**
  153802. * Gets the value operand input component
  153803. */
  153804. get value(): NodeMaterialConnectionPoint;
  153805. /**
  153806. * Gets the edge operand input component
  153807. */
  153808. get edge(): NodeMaterialConnectionPoint;
  153809. /**
  153810. * Gets the output component
  153811. */
  153812. get output(): NodeMaterialConnectionPoint;
  153813. protected _buildBlock(state: NodeMaterialBuildState): this;
  153814. }
  153815. }
  153816. declare module BABYLON {
  153817. /**
  153818. * Block used to get the opposite (1 - x) of a value
  153819. */
  153820. export class OneMinusBlock extends NodeMaterialBlock {
  153821. /**
  153822. * Creates a new OneMinusBlock
  153823. * @param name defines the block name
  153824. */
  153825. constructor(name: string);
  153826. /**
  153827. * Gets the current class name
  153828. * @returns the class name
  153829. */
  153830. getClassName(): string;
  153831. /**
  153832. * Gets the input component
  153833. */
  153834. get input(): NodeMaterialConnectionPoint;
  153835. /**
  153836. * Gets the output component
  153837. */
  153838. get output(): NodeMaterialConnectionPoint;
  153839. protected _buildBlock(state: NodeMaterialBuildState): this;
  153840. }
  153841. }
  153842. declare module BABYLON {
  153843. /**
  153844. * Block used to get the view direction
  153845. */
  153846. export class ViewDirectionBlock extends NodeMaterialBlock {
  153847. /**
  153848. * Creates a new ViewDirectionBlock
  153849. * @param name defines the block name
  153850. */
  153851. constructor(name: string);
  153852. /**
  153853. * Gets the current class name
  153854. * @returns the class name
  153855. */
  153856. getClassName(): string;
  153857. /**
  153858. * Gets the world position component
  153859. */
  153860. get worldPosition(): NodeMaterialConnectionPoint;
  153861. /**
  153862. * Gets the camera position component
  153863. */
  153864. get cameraPosition(): NodeMaterialConnectionPoint;
  153865. /**
  153866. * Gets the output component
  153867. */
  153868. get output(): NodeMaterialConnectionPoint;
  153869. autoConfigure(material: NodeMaterial): void;
  153870. protected _buildBlock(state: NodeMaterialBuildState): this;
  153871. }
  153872. }
  153873. declare module BABYLON {
  153874. /**
  153875. * Block used to compute fresnel value
  153876. */
  153877. export class FresnelBlock extends NodeMaterialBlock {
  153878. /**
  153879. * Create a new FresnelBlock
  153880. * @param name defines the block name
  153881. */
  153882. constructor(name: string);
  153883. /**
  153884. * Gets the current class name
  153885. * @returns the class name
  153886. */
  153887. getClassName(): string;
  153888. /**
  153889. * Gets the world normal input component
  153890. */
  153891. get worldNormal(): NodeMaterialConnectionPoint;
  153892. /**
  153893. * Gets the view direction input component
  153894. */
  153895. get viewDirection(): NodeMaterialConnectionPoint;
  153896. /**
  153897. * Gets the bias input component
  153898. */
  153899. get bias(): NodeMaterialConnectionPoint;
  153900. /**
  153901. * Gets the camera (or eye) position component
  153902. */
  153903. get power(): NodeMaterialConnectionPoint;
  153904. /**
  153905. * Gets the fresnel output component
  153906. */
  153907. get fresnel(): NodeMaterialConnectionPoint;
  153908. autoConfigure(material: NodeMaterial): void;
  153909. protected _buildBlock(state: NodeMaterialBuildState): this;
  153910. }
  153911. }
  153912. declare module BABYLON {
  153913. /**
  153914. * Block used to get the max of 2 values
  153915. */
  153916. export class MaxBlock extends NodeMaterialBlock {
  153917. /**
  153918. * Creates a new MaxBlock
  153919. * @param name defines the block name
  153920. */
  153921. constructor(name: string);
  153922. /**
  153923. * Gets the current class name
  153924. * @returns the class name
  153925. */
  153926. getClassName(): string;
  153927. /**
  153928. * Gets the left operand input component
  153929. */
  153930. get left(): NodeMaterialConnectionPoint;
  153931. /**
  153932. * Gets the right operand input component
  153933. */
  153934. get right(): NodeMaterialConnectionPoint;
  153935. /**
  153936. * Gets the output component
  153937. */
  153938. get output(): NodeMaterialConnectionPoint;
  153939. protected _buildBlock(state: NodeMaterialBuildState): this;
  153940. }
  153941. }
  153942. declare module BABYLON {
  153943. /**
  153944. * Block used to get the min of 2 values
  153945. */
  153946. export class MinBlock extends NodeMaterialBlock {
  153947. /**
  153948. * Creates a new MinBlock
  153949. * @param name defines the block name
  153950. */
  153951. constructor(name: string);
  153952. /**
  153953. * Gets the current class name
  153954. * @returns the class name
  153955. */
  153956. getClassName(): string;
  153957. /**
  153958. * Gets the left operand input component
  153959. */
  153960. get left(): NodeMaterialConnectionPoint;
  153961. /**
  153962. * Gets the right operand input component
  153963. */
  153964. get right(): NodeMaterialConnectionPoint;
  153965. /**
  153966. * Gets the output component
  153967. */
  153968. get output(): NodeMaterialConnectionPoint;
  153969. protected _buildBlock(state: NodeMaterialBuildState): this;
  153970. }
  153971. }
  153972. declare module BABYLON {
  153973. /**
  153974. * Block used to get the distance between 2 values
  153975. */
  153976. export class DistanceBlock extends NodeMaterialBlock {
  153977. /**
  153978. * Creates a new DistanceBlock
  153979. * @param name defines the block name
  153980. */
  153981. constructor(name: string);
  153982. /**
  153983. * Gets the current class name
  153984. * @returns the class name
  153985. */
  153986. getClassName(): string;
  153987. /**
  153988. * Gets the left operand input component
  153989. */
  153990. get left(): NodeMaterialConnectionPoint;
  153991. /**
  153992. * Gets the right operand input component
  153993. */
  153994. get right(): NodeMaterialConnectionPoint;
  153995. /**
  153996. * Gets the output component
  153997. */
  153998. get output(): NodeMaterialConnectionPoint;
  153999. protected _buildBlock(state: NodeMaterialBuildState): this;
  154000. }
  154001. }
  154002. declare module BABYLON {
  154003. /**
  154004. * Block used to get the length of a vector
  154005. */
  154006. export class LengthBlock extends NodeMaterialBlock {
  154007. /**
  154008. * Creates a new LengthBlock
  154009. * @param name defines the block name
  154010. */
  154011. constructor(name: string);
  154012. /**
  154013. * Gets the current class name
  154014. * @returns the class name
  154015. */
  154016. getClassName(): string;
  154017. /**
  154018. * Gets the value input component
  154019. */
  154020. get value(): NodeMaterialConnectionPoint;
  154021. /**
  154022. * Gets the output component
  154023. */
  154024. get output(): NodeMaterialConnectionPoint;
  154025. protected _buildBlock(state: NodeMaterialBuildState): this;
  154026. }
  154027. }
  154028. declare module BABYLON {
  154029. /**
  154030. * Block used to get negative version of a value (i.e. x * -1)
  154031. */
  154032. export class NegateBlock extends NodeMaterialBlock {
  154033. /**
  154034. * Creates a new NegateBlock
  154035. * @param name defines the block name
  154036. */
  154037. constructor(name: string);
  154038. /**
  154039. * Gets the current class name
  154040. * @returns the class name
  154041. */
  154042. getClassName(): string;
  154043. /**
  154044. * Gets the value input component
  154045. */
  154046. get value(): NodeMaterialConnectionPoint;
  154047. /**
  154048. * Gets the output component
  154049. */
  154050. get output(): NodeMaterialConnectionPoint;
  154051. protected _buildBlock(state: NodeMaterialBuildState): this;
  154052. }
  154053. }
  154054. declare module BABYLON {
  154055. /**
  154056. * Block used to get the value of the first parameter raised to the power of the second
  154057. */
  154058. export class PowBlock extends NodeMaterialBlock {
  154059. /**
  154060. * Creates a new PowBlock
  154061. * @param name defines the block name
  154062. */
  154063. constructor(name: string);
  154064. /**
  154065. * Gets the current class name
  154066. * @returns the class name
  154067. */
  154068. getClassName(): string;
  154069. /**
  154070. * Gets the value operand input component
  154071. */
  154072. get value(): NodeMaterialConnectionPoint;
  154073. /**
  154074. * Gets the power operand input component
  154075. */
  154076. get power(): NodeMaterialConnectionPoint;
  154077. /**
  154078. * Gets the output component
  154079. */
  154080. get output(): NodeMaterialConnectionPoint;
  154081. protected _buildBlock(state: NodeMaterialBuildState): this;
  154082. }
  154083. }
  154084. declare module BABYLON {
  154085. /**
  154086. * Block used to get a random number
  154087. */
  154088. export class RandomNumberBlock extends NodeMaterialBlock {
  154089. /**
  154090. * Creates a new RandomNumberBlock
  154091. * @param name defines the block name
  154092. */
  154093. constructor(name: string);
  154094. /**
  154095. * Gets the current class name
  154096. * @returns the class name
  154097. */
  154098. getClassName(): string;
  154099. /**
  154100. * Gets the seed input component
  154101. */
  154102. get seed(): NodeMaterialConnectionPoint;
  154103. /**
  154104. * Gets the output component
  154105. */
  154106. get output(): NodeMaterialConnectionPoint;
  154107. protected _buildBlock(state: NodeMaterialBuildState): this;
  154108. }
  154109. }
  154110. declare module BABYLON {
  154111. /**
  154112. * Block used to compute arc tangent of 2 values
  154113. */
  154114. export class ArcTan2Block extends NodeMaterialBlock {
  154115. /**
  154116. * Creates a new ArcTan2Block
  154117. * @param name defines the block name
  154118. */
  154119. constructor(name: string);
  154120. /**
  154121. * Gets the current class name
  154122. * @returns the class name
  154123. */
  154124. getClassName(): string;
  154125. /**
  154126. * Gets the x operand input component
  154127. */
  154128. get x(): NodeMaterialConnectionPoint;
  154129. /**
  154130. * Gets the y operand input component
  154131. */
  154132. get y(): NodeMaterialConnectionPoint;
  154133. /**
  154134. * Gets the output component
  154135. */
  154136. get output(): NodeMaterialConnectionPoint;
  154137. protected _buildBlock(state: NodeMaterialBuildState): this;
  154138. }
  154139. }
  154140. declare module BABYLON {
  154141. /**
  154142. * Block used to smooth step a value
  154143. */
  154144. export class SmoothStepBlock extends NodeMaterialBlock {
  154145. /**
  154146. * Creates a new SmoothStepBlock
  154147. * @param name defines the block name
  154148. */
  154149. constructor(name: string);
  154150. /**
  154151. * Gets the current class name
  154152. * @returns the class name
  154153. */
  154154. getClassName(): string;
  154155. /**
  154156. * Gets the value operand input component
  154157. */
  154158. get value(): NodeMaterialConnectionPoint;
  154159. /**
  154160. * Gets the first edge operand input component
  154161. */
  154162. get edge0(): NodeMaterialConnectionPoint;
  154163. /**
  154164. * Gets the second edge operand input component
  154165. */
  154166. get edge1(): NodeMaterialConnectionPoint;
  154167. /**
  154168. * Gets the output component
  154169. */
  154170. get output(): NodeMaterialConnectionPoint;
  154171. protected _buildBlock(state: NodeMaterialBuildState): this;
  154172. }
  154173. }
  154174. declare module BABYLON {
  154175. /**
  154176. * Block used to get the reciprocal (1 / x) of a value
  154177. */
  154178. export class ReciprocalBlock extends NodeMaterialBlock {
  154179. /**
  154180. * Creates a new ReciprocalBlock
  154181. * @param name defines the block name
  154182. */
  154183. constructor(name: string);
  154184. /**
  154185. * Gets the current class name
  154186. * @returns the class name
  154187. */
  154188. getClassName(): string;
  154189. /**
  154190. * Gets the input component
  154191. */
  154192. get input(): NodeMaterialConnectionPoint;
  154193. /**
  154194. * Gets the output component
  154195. */
  154196. get output(): NodeMaterialConnectionPoint;
  154197. protected _buildBlock(state: NodeMaterialBuildState): this;
  154198. }
  154199. }
  154200. declare module BABYLON {
  154201. /**
  154202. * Block used to replace a color by another one
  154203. */
  154204. export class ReplaceColorBlock extends NodeMaterialBlock {
  154205. /**
  154206. * Creates a new ReplaceColorBlock
  154207. * @param name defines the block name
  154208. */
  154209. constructor(name: string);
  154210. /**
  154211. * Gets the current class name
  154212. * @returns the class name
  154213. */
  154214. getClassName(): string;
  154215. /**
  154216. * Gets the value input component
  154217. */
  154218. get value(): NodeMaterialConnectionPoint;
  154219. /**
  154220. * Gets the reference input component
  154221. */
  154222. get reference(): NodeMaterialConnectionPoint;
  154223. /**
  154224. * Gets the distance input component
  154225. */
  154226. get distance(): NodeMaterialConnectionPoint;
  154227. /**
  154228. * Gets the replacement input component
  154229. */
  154230. get replacement(): NodeMaterialConnectionPoint;
  154231. /**
  154232. * Gets the output component
  154233. */
  154234. get output(): NodeMaterialConnectionPoint;
  154235. protected _buildBlock(state: NodeMaterialBuildState): this;
  154236. }
  154237. }
  154238. declare module BABYLON {
  154239. /**
  154240. * Block used to posterize a value
  154241. * @see https://en.wikipedia.org/wiki/Posterization
  154242. */
  154243. export class PosterizeBlock extends NodeMaterialBlock {
  154244. /**
  154245. * Creates a new PosterizeBlock
  154246. * @param name defines the block name
  154247. */
  154248. constructor(name: string);
  154249. /**
  154250. * Gets the current class name
  154251. * @returns the class name
  154252. */
  154253. getClassName(): string;
  154254. /**
  154255. * Gets the value input component
  154256. */
  154257. get value(): NodeMaterialConnectionPoint;
  154258. /**
  154259. * Gets the steps input component
  154260. */
  154261. get steps(): NodeMaterialConnectionPoint;
  154262. /**
  154263. * Gets the output component
  154264. */
  154265. get output(): NodeMaterialConnectionPoint;
  154266. protected _buildBlock(state: NodeMaterialBuildState): this;
  154267. }
  154268. }
  154269. declare module BABYLON {
  154270. /**
  154271. * Operations supported by the Wave block
  154272. */
  154273. export enum WaveBlockKind {
  154274. /** SawTooth */
  154275. SawTooth = 0,
  154276. /** Square */
  154277. Square = 1,
  154278. /** Triangle */
  154279. Triangle = 2
  154280. }
  154281. /**
  154282. * Block used to apply wave operation to floats
  154283. */
  154284. export class WaveBlock extends NodeMaterialBlock {
  154285. /**
  154286. * Gets or sets the kibnd of wave to be applied by the block
  154287. */
  154288. kind: WaveBlockKind;
  154289. /**
  154290. * Creates a new WaveBlock
  154291. * @param name defines the block name
  154292. */
  154293. constructor(name: string);
  154294. /**
  154295. * Gets the current class name
  154296. * @returns the class name
  154297. */
  154298. getClassName(): string;
  154299. /**
  154300. * Gets the input component
  154301. */
  154302. get input(): NodeMaterialConnectionPoint;
  154303. /**
  154304. * Gets the output component
  154305. */
  154306. get output(): NodeMaterialConnectionPoint;
  154307. protected _buildBlock(state: NodeMaterialBuildState): this;
  154308. serialize(): any;
  154309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154310. }
  154311. }
  154312. declare module BABYLON {
  154313. /**
  154314. * Class used to store a color step for the GradientBlock
  154315. */
  154316. export class GradientBlockColorStep {
  154317. private _step;
  154318. /**
  154319. * Gets value indicating which step this color is associated with (between 0 and 1)
  154320. */
  154321. get step(): number;
  154322. /**
  154323. * Sets a value indicating which step this color is associated with (between 0 and 1)
  154324. */
  154325. set step(val: number);
  154326. private _color;
  154327. /**
  154328. * Gets the color associated with this step
  154329. */
  154330. get color(): Color3;
  154331. /**
  154332. * Sets the color associated with this step
  154333. */
  154334. set color(val: Color3);
  154335. /**
  154336. * Creates a new GradientBlockColorStep
  154337. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  154338. * @param color defines the color associated with this step
  154339. */
  154340. constructor(step: number, color: Color3);
  154341. }
  154342. /**
  154343. * Block used to return a color from a gradient based on an input value between 0 and 1
  154344. */
  154345. export class GradientBlock extends NodeMaterialBlock {
  154346. /**
  154347. * Gets or sets the list of color steps
  154348. */
  154349. colorSteps: GradientBlockColorStep[];
  154350. /** Gets an observable raised when the value is changed */
  154351. onValueChangedObservable: Observable<GradientBlock>;
  154352. /** calls observable when the value is changed*/
  154353. colorStepsUpdated(): void;
  154354. /**
  154355. * Creates a new GradientBlock
  154356. * @param name defines the block name
  154357. */
  154358. constructor(name: string);
  154359. /**
  154360. * Gets the current class name
  154361. * @returns the class name
  154362. */
  154363. getClassName(): string;
  154364. /**
  154365. * Gets the gradient input component
  154366. */
  154367. get gradient(): NodeMaterialConnectionPoint;
  154368. /**
  154369. * Gets the output component
  154370. */
  154371. get output(): NodeMaterialConnectionPoint;
  154372. private _writeColorConstant;
  154373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  154374. serialize(): any;
  154375. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154376. protected _dumpPropertiesCode(): string;
  154377. }
  154378. }
  154379. declare module BABYLON {
  154380. /**
  154381. * Block used to normalize lerp between 2 values
  154382. */
  154383. export class NLerpBlock extends NodeMaterialBlock {
  154384. /**
  154385. * Creates a new NLerpBlock
  154386. * @param name defines the block name
  154387. */
  154388. constructor(name: string);
  154389. /**
  154390. * Gets the current class name
  154391. * @returns the class name
  154392. */
  154393. getClassName(): string;
  154394. /**
  154395. * Gets the left operand input component
  154396. */
  154397. get left(): NodeMaterialConnectionPoint;
  154398. /**
  154399. * Gets the right operand input component
  154400. */
  154401. get right(): NodeMaterialConnectionPoint;
  154402. /**
  154403. * Gets the gradient operand input component
  154404. */
  154405. get gradient(): NodeMaterialConnectionPoint;
  154406. /**
  154407. * Gets the output component
  154408. */
  154409. get output(): NodeMaterialConnectionPoint;
  154410. protected _buildBlock(state: NodeMaterialBuildState): this;
  154411. }
  154412. }
  154413. declare module BABYLON {
  154414. /**
  154415. * block used to Generate a Worley Noise 3D Noise Pattern
  154416. */
  154417. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  154418. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  154419. manhattanDistance: boolean;
  154420. /**
  154421. * Creates a new WorleyNoise3DBlock
  154422. * @param name defines the block name
  154423. */
  154424. constructor(name: string);
  154425. /**
  154426. * Gets the current class name
  154427. * @returns the class name
  154428. */
  154429. getClassName(): string;
  154430. /**
  154431. * Gets the seed input component
  154432. */
  154433. get seed(): NodeMaterialConnectionPoint;
  154434. /**
  154435. * Gets the jitter input component
  154436. */
  154437. get jitter(): NodeMaterialConnectionPoint;
  154438. /**
  154439. * Gets the output component
  154440. */
  154441. get output(): NodeMaterialConnectionPoint;
  154442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  154443. /**
  154444. * Exposes the properties to the UI?
  154445. */
  154446. protected _dumpPropertiesCode(): string;
  154447. /**
  154448. * Exposes the properties to the Serialize?
  154449. */
  154450. serialize(): any;
  154451. /**
  154452. * Exposes the properties to the deserialize?
  154453. */
  154454. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154455. }
  154456. }
  154457. declare module BABYLON {
  154458. /**
  154459. * block used to Generate a Simplex Perlin 3d Noise Pattern
  154460. */
  154461. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  154462. /**
  154463. * Creates a new SimplexPerlin3DBlock
  154464. * @param name defines the block name
  154465. */
  154466. constructor(name: string);
  154467. /**
  154468. * Gets the current class name
  154469. * @returns the class name
  154470. */
  154471. getClassName(): string;
  154472. /**
  154473. * Gets the seed operand input component
  154474. */
  154475. get seed(): NodeMaterialConnectionPoint;
  154476. /**
  154477. * Gets the output component
  154478. */
  154479. get output(): NodeMaterialConnectionPoint;
  154480. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  154481. }
  154482. }
  154483. declare module BABYLON {
  154484. /**
  154485. * Block used to blend normals
  154486. */
  154487. export class NormalBlendBlock extends NodeMaterialBlock {
  154488. /**
  154489. * Creates a new NormalBlendBlock
  154490. * @param name defines the block name
  154491. */
  154492. constructor(name: string);
  154493. /**
  154494. * Gets the current class name
  154495. * @returns the class name
  154496. */
  154497. getClassName(): string;
  154498. /**
  154499. * Gets the first input component
  154500. */
  154501. get normalMap0(): NodeMaterialConnectionPoint;
  154502. /**
  154503. * Gets the second input component
  154504. */
  154505. get normalMap1(): NodeMaterialConnectionPoint;
  154506. /**
  154507. * Gets the output component
  154508. */
  154509. get output(): NodeMaterialConnectionPoint;
  154510. protected _buildBlock(state: NodeMaterialBuildState): this;
  154511. }
  154512. }
  154513. declare module BABYLON {
  154514. /**
  154515. * Block used to rotate a 2d vector by a given angle
  154516. */
  154517. export class Rotate2dBlock extends NodeMaterialBlock {
  154518. /**
  154519. * Creates a new Rotate2dBlock
  154520. * @param name defines the block name
  154521. */
  154522. constructor(name: string);
  154523. /**
  154524. * Gets the current class name
  154525. * @returns the class name
  154526. */
  154527. getClassName(): string;
  154528. /**
  154529. * Gets the input vector
  154530. */
  154531. get input(): NodeMaterialConnectionPoint;
  154532. /**
  154533. * Gets the input angle
  154534. */
  154535. get angle(): NodeMaterialConnectionPoint;
  154536. /**
  154537. * Gets the output component
  154538. */
  154539. get output(): NodeMaterialConnectionPoint;
  154540. autoConfigure(material: NodeMaterial): void;
  154541. protected _buildBlock(state: NodeMaterialBuildState): this;
  154542. }
  154543. }
  154544. declare module BABYLON {
  154545. /**
  154546. * Block used to get the reflected vector from a direction and a normal
  154547. */
  154548. export class ReflectBlock extends NodeMaterialBlock {
  154549. /**
  154550. * Creates a new ReflectBlock
  154551. * @param name defines the block name
  154552. */
  154553. constructor(name: string);
  154554. /**
  154555. * Gets the current class name
  154556. * @returns the class name
  154557. */
  154558. getClassName(): string;
  154559. /**
  154560. * Gets the incident component
  154561. */
  154562. get incident(): NodeMaterialConnectionPoint;
  154563. /**
  154564. * Gets the normal component
  154565. */
  154566. get normal(): NodeMaterialConnectionPoint;
  154567. /**
  154568. * Gets the output component
  154569. */
  154570. get output(): NodeMaterialConnectionPoint;
  154571. protected _buildBlock(state: NodeMaterialBuildState): this;
  154572. }
  154573. }
  154574. declare module BABYLON {
  154575. /**
  154576. * Block used to get the refracted vector from a direction and a normal
  154577. */
  154578. export class RefractBlock extends NodeMaterialBlock {
  154579. /**
  154580. * Creates a new RefractBlock
  154581. * @param name defines the block name
  154582. */
  154583. constructor(name: string);
  154584. /**
  154585. * Gets the current class name
  154586. * @returns the class name
  154587. */
  154588. getClassName(): string;
  154589. /**
  154590. * Gets the incident component
  154591. */
  154592. get incident(): NodeMaterialConnectionPoint;
  154593. /**
  154594. * Gets the normal component
  154595. */
  154596. get normal(): NodeMaterialConnectionPoint;
  154597. /**
  154598. * Gets the index of refraction component
  154599. */
  154600. get ior(): NodeMaterialConnectionPoint;
  154601. /**
  154602. * Gets the output component
  154603. */
  154604. get output(): NodeMaterialConnectionPoint;
  154605. protected _buildBlock(state: NodeMaterialBuildState): this;
  154606. }
  154607. }
  154608. declare module BABYLON {
  154609. /**
  154610. * Block used to desaturate a color
  154611. */
  154612. export class DesaturateBlock extends NodeMaterialBlock {
  154613. /**
  154614. * Creates a new DesaturateBlock
  154615. * @param name defines the block name
  154616. */
  154617. constructor(name: string);
  154618. /**
  154619. * Gets the current class name
  154620. * @returns the class name
  154621. */
  154622. getClassName(): string;
  154623. /**
  154624. * Gets the color operand input component
  154625. */
  154626. get color(): NodeMaterialConnectionPoint;
  154627. /**
  154628. * Gets the level operand input component
  154629. */
  154630. get level(): NodeMaterialConnectionPoint;
  154631. /**
  154632. * Gets the output component
  154633. */
  154634. get output(): NodeMaterialConnectionPoint;
  154635. protected _buildBlock(state: NodeMaterialBuildState): this;
  154636. }
  154637. }
  154638. declare module BABYLON {
  154639. /**
  154640. * Block used to implement the reflection module of the PBR material
  154641. */
  154642. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  154643. /** @hidden */
  154644. _defineLODReflectionAlpha: string;
  154645. /** @hidden */
  154646. _defineLinearSpecularReflection: string;
  154647. private _vEnvironmentIrradianceName;
  154648. /** @hidden */
  154649. _vReflectionMicrosurfaceInfosName: string;
  154650. /** @hidden */
  154651. _vReflectionInfosName: string;
  154652. /** @hidden */
  154653. _vReflectionFilteringInfoName: string;
  154654. private _scene;
  154655. /**
  154656. * The properties below are set by the main PBR block prior to calling methods of this class.
  154657. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  154658. * It's less burden on the user side in the editor part.
  154659. */
  154660. /** @hidden */
  154661. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  154662. /** @hidden */
  154663. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  154664. /** @hidden */
  154665. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  154666. /** @hidden */
  154667. viewConnectionPoint: NodeMaterialConnectionPoint;
  154668. /**
  154669. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  154670. * diffuse part of the IBL.
  154671. */
  154672. useSphericalHarmonics: boolean;
  154673. /**
  154674. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  154675. */
  154676. forceIrradianceInFragment: boolean;
  154677. /**
  154678. * Create a new ReflectionBlock
  154679. * @param name defines the block name
  154680. */
  154681. constructor(name: string);
  154682. /**
  154683. * Gets the current class name
  154684. * @returns the class name
  154685. */
  154686. getClassName(): string;
  154687. /**
  154688. * Gets the position input component
  154689. */
  154690. get position(): NodeMaterialConnectionPoint;
  154691. /**
  154692. * Gets the world position input component
  154693. */
  154694. get worldPosition(): NodeMaterialConnectionPoint;
  154695. /**
  154696. * Gets the world normal input component
  154697. */
  154698. get worldNormal(): NodeMaterialConnectionPoint;
  154699. /**
  154700. * Gets the world input component
  154701. */
  154702. get world(): NodeMaterialConnectionPoint;
  154703. /**
  154704. * Gets the camera (or eye) position component
  154705. */
  154706. get cameraPosition(): NodeMaterialConnectionPoint;
  154707. /**
  154708. * Gets the view input component
  154709. */
  154710. get view(): NodeMaterialConnectionPoint;
  154711. /**
  154712. * Gets the color input component
  154713. */
  154714. get color(): NodeMaterialConnectionPoint;
  154715. /**
  154716. * Gets the reflection object output component
  154717. */
  154718. get reflection(): NodeMaterialConnectionPoint;
  154719. /**
  154720. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  154721. */
  154722. get hasTexture(): boolean;
  154723. /**
  154724. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  154725. */
  154726. get reflectionColor(): string;
  154727. protected _getTexture(): Nullable<BaseTexture>;
  154728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154729. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  154730. /**
  154731. * Gets the code to inject in the vertex shader
  154732. * @param state current state of the node material building
  154733. * @returns the shader code
  154734. */
  154735. handleVertexSide(state: NodeMaterialBuildState): string;
  154736. /**
  154737. * Gets the main code of the block (fragment side)
  154738. * @param state current state of the node material building
  154739. * @param normalVarName name of the existing variable corresponding to the normal
  154740. * @returns the shader code
  154741. */
  154742. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  154743. protected _buildBlock(state: NodeMaterialBuildState): this;
  154744. protected _dumpPropertiesCode(): string;
  154745. serialize(): any;
  154746. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154747. }
  154748. }
  154749. declare module BABYLON {
  154750. /**
  154751. * Block used to implement the sheen module of the PBR material
  154752. */
  154753. export class SheenBlock extends NodeMaterialBlock {
  154754. /**
  154755. * Create a new SheenBlock
  154756. * @param name defines the block name
  154757. */
  154758. constructor(name: string);
  154759. /**
  154760. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  154761. * It allows the strength of the sheen effect to not depend on the base color of the material,
  154762. * making it easier to setup and tweak the effect
  154763. */
  154764. albedoScaling: boolean;
  154765. /**
  154766. * Defines if the sheen is linked to the sheen color.
  154767. */
  154768. linkSheenWithAlbedo: boolean;
  154769. /**
  154770. * Initialize the block and prepare the context for build
  154771. * @param state defines the state that will be used for the build
  154772. */
  154773. initialize(state: NodeMaterialBuildState): void;
  154774. /**
  154775. * Gets the current class name
  154776. * @returns the class name
  154777. */
  154778. getClassName(): string;
  154779. /**
  154780. * Gets the intensity input component
  154781. */
  154782. get intensity(): NodeMaterialConnectionPoint;
  154783. /**
  154784. * Gets the color input component
  154785. */
  154786. get color(): NodeMaterialConnectionPoint;
  154787. /**
  154788. * Gets the roughness input component
  154789. */
  154790. get roughness(): NodeMaterialConnectionPoint;
  154791. /**
  154792. * Gets the sheen object output component
  154793. */
  154794. get sheen(): NodeMaterialConnectionPoint;
  154795. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154796. /**
  154797. * Gets the main code of the block (fragment side)
  154798. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  154799. * @returns the shader code
  154800. */
  154801. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  154802. protected _buildBlock(state: NodeMaterialBuildState): this;
  154803. protected _dumpPropertiesCode(): string;
  154804. serialize(): any;
  154805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154806. }
  154807. }
  154808. declare module BABYLON {
  154809. /**
  154810. * Block used to implement the anisotropy module of the PBR material
  154811. */
  154812. export class AnisotropyBlock extends NodeMaterialBlock {
  154813. /**
  154814. * The two properties below are set by the main PBR block prior to calling methods of this class.
  154815. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  154816. * It's less burden on the user side in the editor part.
  154817. */
  154818. /** @hidden */
  154819. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  154820. /** @hidden */
  154821. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  154822. /**
  154823. * Create a new AnisotropyBlock
  154824. * @param name defines the block name
  154825. */
  154826. constructor(name: string);
  154827. /**
  154828. * Initialize the block and prepare the context for build
  154829. * @param state defines the state that will be used for the build
  154830. */
  154831. initialize(state: NodeMaterialBuildState): void;
  154832. /**
  154833. * Gets the current class name
  154834. * @returns the class name
  154835. */
  154836. getClassName(): string;
  154837. /**
  154838. * Gets the intensity input component
  154839. */
  154840. get intensity(): NodeMaterialConnectionPoint;
  154841. /**
  154842. * Gets the direction input component
  154843. */
  154844. get direction(): NodeMaterialConnectionPoint;
  154845. /**
  154846. * Gets the uv input component
  154847. */
  154848. get uv(): NodeMaterialConnectionPoint;
  154849. /**
  154850. * Gets the worldTangent input component
  154851. */
  154852. get worldTangent(): NodeMaterialConnectionPoint;
  154853. /**
  154854. * Gets the anisotropy object output component
  154855. */
  154856. get anisotropy(): NodeMaterialConnectionPoint;
  154857. private _generateTBNSpace;
  154858. /**
  154859. * Gets the main code of the block (fragment side)
  154860. * @param state current state of the node material building
  154861. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  154862. * @returns the shader code
  154863. */
  154864. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  154865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154866. protected _buildBlock(state: NodeMaterialBuildState): this;
  154867. }
  154868. }
  154869. declare module BABYLON {
  154870. /**
  154871. * Block used to implement the clear coat module of the PBR material
  154872. */
  154873. export class ClearCoatBlock extends NodeMaterialBlock {
  154874. private _scene;
  154875. /**
  154876. * Create a new ClearCoatBlock
  154877. * @param name defines the block name
  154878. */
  154879. constructor(name: string);
  154880. /**
  154881. * Defines if the F0 value should be remapped to account for the interface change in the material.
  154882. */
  154883. remapF0OnInterfaceChange: boolean;
  154884. /**
  154885. * Initialize the block and prepare the context for build
  154886. * @param state defines the state that will be used for the build
  154887. */
  154888. initialize(state: NodeMaterialBuildState): void;
  154889. /**
  154890. * Gets the current class name
  154891. * @returns the class name
  154892. */
  154893. getClassName(): string;
  154894. /**
  154895. * Gets the intensity input component
  154896. */
  154897. get intensity(): NodeMaterialConnectionPoint;
  154898. /**
  154899. * Gets the roughness input component
  154900. */
  154901. get roughness(): NodeMaterialConnectionPoint;
  154902. /**
  154903. * Gets the ior input component
  154904. */
  154905. get indexOfRefraction(): NodeMaterialConnectionPoint;
  154906. /**
  154907. * Gets the bump texture input component
  154908. */
  154909. get normalMapColor(): NodeMaterialConnectionPoint;
  154910. /**
  154911. * Gets the uv input component
  154912. */
  154913. get uv(): NodeMaterialConnectionPoint;
  154914. /**
  154915. * Gets the tint color input component
  154916. */
  154917. get tintColor(): NodeMaterialConnectionPoint;
  154918. /**
  154919. * Gets the tint "at distance" input component
  154920. */
  154921. get tintAtDistance(): NodeMaterialConnectionPoint;
  154922. /**
  154923. * Gets the tint thickness input component
  154924. */
  154925. get tintThickness(): NodeMaterialConnectionPoint;
  154926. /**
  154927. * Gets the world tangent input component
  154928. */
  154929. get worldTangent(): NodeMaterialConnectionPoint;
  154930. /**
  154931. * Gets the clear coat object output component
  154932. */
  154933. get clearcoat(): NodeMaterialConnectionPoint;
  154934. autoConfigure(material: NodeMaterial): void;
  154935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  154936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  154937. private _generateTBNSpace;
  154938. /**
  154939. * Gets the main code of the block (fragment side)
  154940. * @param state current state of the node material building
  154941. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  154942. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  154943. * @param worldPosVarName name of the variable holding the world position
  154944. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  154945. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  154946. * @param worldNormalVarName name of the variable holding the world normal
  154947. * @returns the shader code
  154948. */
  154949. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  154950. protected _buildBlock(state: NodeMaterialBuildState): this;
  154951. protected _dumpPropertiesCode(): string;
  154952. serialize(): any;
  154953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  154954. }
  154955. }
  154956. declare module BABYLON {
  154957. /**
  154958. * Block used to implement the sub surface module of the PBR material
  154959. */
  154960. export class SubSurfaceBlock extends NodeMaterialBlock {
  154961. /**
  154962. * Create a new SubSurfaceBlock
  154963. * @param name defines the block name
  154964. */
  154965. constructor(name: string);
  154966. /**
  154967. * Initialize the block and prepare the context for build
  154968. * @param state defines the state that will be used for the build
  154969. */
  154970. initialize(state: NodeMaterialBuildState): void;
  154971. /**
  154972. * Gets the current class name
  154973. * @returns the class name
  154974. */
  154975. getClassName(): string;
  154976. /**
  154977. * Gets the thickness component
  154978. */
  154979. get thickness(): NodeMaterialConnectionPoint;
  154980. /**
  154981. * Gets the tint color input component
  154982. */
  154983. get tintColor(): NodeMaterialConnectionPoint;
  154984. /**
  154985. * Gets the translucency intensity input component
  154986. */
  154987. get translucencyIntensity(): NodeMaterialConnectionPoint;
  154988. /**
  154989. * Gets the translucency diffusion distance input component
  154990. */
  154991. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  154992. /**
  154993. * Gets the refraction object parameters
  154994. */
  154995. get refraction(): NodeMaterialConnectionPoint;
  154996. /**
  154997. * Gets the sub surface object output component
  154998. */
  154999. get subsurface(): NodeMaterialConnectionPoint;
  155000. autoConfigure(material: NodeMaterial): void;
  155001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  155002. /**
  155003. * Gets the main code of the block (fragment side)
  155004. * @param state current state of the node material building
  155005. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  155006. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  155007. * @param worldPosVarName name of the variable holding the world position
  155008. * @returns the shader code
  155009. */
  155010. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  155011. protected _buildBlock(state: NodeMaterialBuildState): this;
  155012. }
  155013. }
  155014. declare module BABYLON {
  155015. /**
  155016. * Block used to implement the PBR metallic/roughness model
  155017. */
  155018. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  155019. /**
  155020. * Gets or sets the light associated with this block
  155021. */
  155022. light: Nullable<Light>;
  155023. private _lightId;
  155024. private _scene;
  155025. private _environmentBRDFTexture;
  155026. private _environmentBrdfSamplerName;
  155027. private _vNormalWName;
  155028. private _invertNormalName;
  155029. private _metallicReflectanceColor;
  155030. private _metallicF0Factor;
  155031. private _vMetallicReflectanceFactorsName;
  155032. /**
  155033. * Create a new ReflectionBlock
  155034. * @param name defines the block name
  155035. */
  155036. constructor(name: string);
  155037. /**
  155038. * Intensity of the direct lights e.g. the four lights available in your scene.
  155039. * This impacts both the direct diffuse and specular highlights.
  155040. */
  155041. directIntensity: number;
  155042. /**
  155043. * Intensity of the environment e.g. how much the environment will light the object
  155044. * either through harmonics for rough material or through the reflection for shiny ones.
  155045. */
  155046. environmentIntensity: number;
  155047. /**
  155048. * This is a special control allowing the reduction of the specular highlights coming from the
  155049. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  155050. */
  155051. specularIntensity: number;
  155052. /**
  155053. * Defines the falloff type used in this material.
  155054. * It by default is Physical.
  155055. */
  155056. lightFalloff: number;
  155057. /**
  155058. * Specifies that alpha test should be used
  155059. */
  155060. useAlphaTest: boolean;
  155061. /**
  155062. * Defines the alpha limits in alpha test mode.
  155063. */
  155064. alphaTestCutoff: number;
  155065. /**
  155066. * Specifies that alpha blending should be used
  155067. */
  155068. useAlphaBlending: boolean;
  155069. /**
  155070. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  155071. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  155072. */
  155073. useRadianceOverAlpha: boolean;
  155074. /**
  155075. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  155076. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  155077. */
  155078. useSpecularOverAlpha: boolean;
  155079. /**
  155080. * Enables specular anti aliasing in the PBR shader.
  155081. * It will both interacts on the Geometry for analytical and IBL lighting.
  155082. * It also prefilter the roughness map based on the bump values.
  155083. */
  155084. enableSpecularAntiAliasing: boolean;
  155085. /**
  155086. * Enables realtime filtering on the texture.
  155087. */
  155088. realTimeFiltering: boolean;
  155089. /**
  155090. * Quality switch for realtime filtering
  155091. */
  155092. realTimeFilteringQuality: number;
  155093. /**
  155094. * Defines if the material uses energy conservation.
  155095. */
  155096. useEnergyConservation: boolean;
  155097. /**
  155098. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  155099. * too much the area relying on ambient texture to define their ambient occlusion.
  155100. */
  155101. useRadianceOcclusion: boolean;
  155102. /**
  155103. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  155104. * makes the reflect vector face the model (under horizon).
  155105. */
  155106. useHorizonOcclusion: boolean;
  155107. /**
  155108. * If set to true, no lighting calculations will be applied.
  155109. */
  155110. unlit: boolean;
  155111. /**
  155112. * Force normal to face away from face.
  155113. */
  155114. forceNormalForward: boolean;
  155115. /**
  155116. * Defines the material debug mode.
  155117. * It helps seeing only some components of the material while troubleshooting.
  155118. */
  155119. debugMode: number;
  155120. /**
  155121. * Specify from where on screen the debug mode should start.
  155122. * The value goes from -1 (full screen) to 1 (not visible)
  155123. * It helps with side by side comparison against the final render
  155124. * This defaults to 0
  155125. */
  155126. debugLimit: number;
  155127. /**
  155128. * As the default viewing range might not be enough (if the ambient is really small for instance)
  155129. * You can use the factor to better multiply the final value.
  155130. */
  155131. debugFactor: number;
  155132. /**
  155133. * Initialize the block and prepare the context for build
  155134. * @param state defines the state that will be used for the build
  155135. */
  155136. initialize(state: NodeMaterialBuildState): void;
  155137. /**
  155138. * Gets the current class name
  155139. * @returns the class name
  155140. */
  155141. getClassName(): string;
  155142. /**
  155143. * Gets the world position input component
  155144. */
  155145. get worldPosition(): NodeMaterialConnectionPoint;
  155146. /**
  155147. * Gets the world normal input component
  155148. */
  155149. get worldNormal(): NodeMaterialConnectionPoint;
  155150. /**
  155151. * Gets the view matrix parameter
  155152. */
  155153. get view(): NodeMaterialConnectionPoint;
  155154. /**
  155155. * Gets the camera position input component
  155156. */
  155157. get cameraPosition(): NodeMaterialConnectionPoint;
  155158. /**
  155159. * Gets the perturbed normal input component
  155160. */
  155161. get perturbedNormal(): NodeMaterialConnectionPoint;
  155162. /**
  155163. * Gets the base color input component
  155164. */
  155165. get baseColor(): NodeMaterialConnectionPoint;
  155166. /**
  155167. * Gets the metallic input component
  155168. */
  155169. get metallic(): NodeMaterialConnectionPoint;
  155170. /**
  155171. * Gets the roughness input component
  155172. */
  155173. get roughness(): NodeMaterialConnectionPoint;
  155174. /**
  155175. * Gets the ambient occlusion input component
  155176. */
  155177. get ambientOcc(): NodeMaterialConnectionPoint;
  155178. /**
  155179. * Gets the opacity input component
  155180. */
  155181. get opacity(): NodeMaterialConnectionPoint;
  155182. /**
  155183. * Gets the index of refraction input component
  155184. */
  155185. get indexOfRefraction(): NodeMaterialConnectionPoint;
  155186. /**
  155187. * Gets the ambient color input component
  155188. */
  155189. get ambientColor(): NodeMaterialConnectionPoint;
  155190. /**
  155191. * Gets the reflection object parameters
  155192. */
  155193. get reflection(): NodeMaterialConnectionPoint;
  155194. /**
  155195. * Gets the clear coat object parameters
  155196. */
  155197. get clearcoat(): NodeMaterialConnectionPoint;
  155198. /**
  155199. * Gets the sheen object parameters
  155200. */
  155201. get sheen(): NodeMaterialConnectionPoint;
  155202. /**
  155203. * Gets the sub surface object parameters
  155204. */
  155205. get subsurface(): NodeMaterialConnectionPoint;
  155206. /**
  155207. * Gets the anisotropy object parameters
  155208. */
  155209. get anisotropy(): NodeMaterialConnectionPoint;
  155210. /**
  155211. * Gets the ambient output component
  155212. */
  155213. get ambientClr(): NodeMaterialConnectionPoint;
  155214. /**
  155215. * Gets the diffuse output component
  155216. */
  155217. get diffuseDir(): NodeMaterialConnectionPoint;
  155218. /**
  155219. * Gets the specular output component
  155220. */
  155221. get specularDir(): NodeMaterialConnectionPoint;
  155222. /**
  155223. * Gets the clear coat output component
  155224. */
  155225. get clearcoatDir(): NodeMaterialConnectionPoint;
  155226. /**
  155227. * Gets the sheen output component
  155228. */
  155229. get sheenDir(): NodeMaterialConnectionPoint;
  155230. /**
  155231. * Gets the indirect diffuse output component
  155232. */
  155233. get diffuseIndirect(): NodeMaterialConnectionPoint;
  155234. /**
  155235. * Gets the indirect specular output component
  155236. */
  155237. get specularIndirect(): NodeMaterialConnectionPoint;
  155238. /**
  155239. * Gets the indirect clear coat output component
  155240. */
  155241. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  155242. /**
  155243. * Gets the indirect sheen output component
  155244. */
  155245. get sheenIndirect(): NodeMaterialConnectionPoint;
  155246. /**
  155247. * Gets the refraction output component
  155248. */
  155249. get refraction(): NodeMaterialConnectionPoint;
  155250. /**
  155251. * Gets the global lighting output component
  155252. */
  155253. get lighting(): NodeMaterialConnectionPoint;
  155254. /**
  155255. * Gets the shadow output component
  155256. */
  155257. get shadow(): NodeMaterialConnectionPoint;
  155258. /**
  155259. * Gets the alpha output component
  155260. */
  155261. get alpha(): NodeMaterialConnectionPoint;
  155262. autoConfigure(material: NodeMaterial): void;
  155263. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  155264. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  155265. isReady(): boolean;
  155266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  155267. private _injectVertexCode;
  155268. private _getAlbedoOpacityCode;
  155269. private _getAmbientOcclusionCode;
  155270. private _getReflectivityCode;
  155271. protected _buildBlock(state: NodeMaterialBuildState): this;
  155272. protected _dumpPropertiesCode(): string;
  155273. serialize(): any;
  155274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  155275. }
  155276. }
  155277. declare module BABYLON {
  155278. /**
  155279. * Block used to compute value of one parameter modulo another
  155280. */
  155281. export class ModBlock extends NodeMaterialBlock {
  155282. /**
  155283. * Creates a new ModBlock
  155284. * @param name defines the block name
  155285. */
  155286. constructor(name: string);
  155287. /**
  155288. * Gets the current class name
  155289. * @returns the class name
  155290. */
  155291. getClassName(): string;
  155292. /**
  155293. * Gets the left operand input component
  155294. */
  155295. get left(): NodeMaterialConnectionPoint;
  155296. /**
  155297. * Gets the right operand input component
  155298. */
  155299. get right(): NodeMaterialConnectionPoint;
  155300. /**
  155301. * Gets the output component
  155302. */
  155303. get output(): NodeMaterialConnectionPoint;
  155304. protected _buildBlock(state: NodeMaterialBuildState): this;
  155305. }
  155306. }
  155307. declare module BABYLON {
  155308. /**
  155309. * Configuration for Draco compression
  155310. */
  155311. export interface IDracoCompressionConfiguration {
  155312. /**
  155313. * Configuration for the decoder.
  155314. */
  155315. decoder: {
  155316. /**
  155317. * The url to the WebAssembly module.
  155318. */
  155319. wasmUrl?: string;
  155320. /**
  155321. * The url to the WebAssembly binary.
  155322. */
  155323. wasmBinaryUrl?: string;
  155324. /**
  155325. * The url to the fallback JavaScript module.
  155326. */
  155327. fallbackUrl?: string;
  155328. };
  155329. }
  155330. /**
  155331. * Draco compression (https://google.github.io/draco/)
  155332. *
  155333. * This class wraps the Draco module.
  155334. *
  155335. * **Encoder**
  155336. *
  155337. * The encoder is not currently implemented.
  155338. *
  155339. * **Decoder**
  155340. *
  155341. * 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.
  155342. *
  155343. * To update the configuration, use the following code:
  155344. * ```javascript
  155345. * DracoCompression.Configuration = {
  155346. * decoder: {
  155347. * wasmUrl: "<url to the WebAssembly library>",
  155348. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  155349. * fallbackUrl: "<url to the fallback JavaScript library>",
  155350. * }
  155351. * };
  155352. * ```
  155353. *
  155354. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.
  155355. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  155356. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  155357. *
  155358. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  155359. * ```javascript
  155360. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  155361. * ```
  155362. *
  155363. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  155364. */
  155365. export class DracoCompression implements IDisposable {
  155366. private _workerPoolPromise?;
  155367. private _decoderModulePromise?;
  155368. /**
  155369. * The configuration. Defaults to the following urls:
  155370. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  155371. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  155372. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  155373. */
  155374. static Configuration: IDracoCompressionConfiguration;
  155375. /**
  155376. * Returns true if the decoder configuration is available.
  155377. */
  155378. static get DecoderAvailable(): boolean;
  155379. /**
  155380. * Default number of workers to create when creating the draco compression object.
  155381. */
  155382. static DefaultNumWorkers: number;
  155383. private static GetDefaultNumWorkers;
  155384. private static _Default;
  155385. /**
  155386. * Default instance for the draco compression object.
  155387. */
  155388. static get Default(): DracoCompression;
  155389. /**
  155390. * Constructor
  155391. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  155392. */
  155393. constructor(numWorkers?: number);
  155394. /**
  155395. * Stop all async operations and release resources.
  155396. */
  155397. dispose(): void;
  155398. /**
  155399. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  155400. * @returns a promise that resolves when ready
  155401. */
  155402. whenReadyAsync(): Promise<void>;
  155403. /**
  155404. * Decode Draco compressed mesh data to vertex data.
  155405. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  155406. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  155407. * @returns A promise that resolves with the decoded vertex data
  155408. */
  155409. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  155410. [kind: string]: number;
  155411. }): Promise<VertexData>;
  155412. }
  155413. }
  155414. declare module BABYLON {
  155415. /**
  155416. * Class for building Constructive Solid Geometry
  155417. */
  155418. export class CSG {
  155419. private polygons;
  155420. /**
  155421. * The world matrix
  155422. */
  155423. matrix: Matrix;
  155424. /**
  155425. * Stores the position
  155426. */
  155427. position: Vector3;
  155428. /**
  155429. * Stores the rotation
  155430. */
  155431. rotation: Vector3;
  155432. /**
  155433. * Stores the rotation quaternion
  155434. */
  155435. rotationQuaternion: Nullable<Quaternion>;
  155436. /**
  155437. * Stores the scaling vector
  155438. */
  155439. scaling: Vector3;
  155440. /**
  155441. * Convert the Mesh to CSG
  155442. * @param mesh The Mesh to convert to CSG
  155443. * @returns A new CSG from the Mesh
  155444. */
  155445. static FromMesh(mesh: Mesh): CSG;
  155446. /**
  155447. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  155448. * @param polygons Polygons used to construct a CSG solid
  155449. */
  155450. private static FromPolygons;
  155451. /**
  155452. * Clones, or makes a deep copy, of the CSG
  155453. * @returns A new CSG
  155454. */
  155455. clone(): CSG;
  155456. /**
  155457. * Unions this CSG with another CSG
  155458. * @param csg The CSG to union against this CSG
  155459. * @returns The unioned CSG
  155460. */
  155461. union(csg: CSG): CSG;
  155462. /**
  155463. * Unions this CSG with another CSG in place
  155464. * @param csg The CSG to union against this CSG
  155465. */
  155466. unionInPlace(csg: CSG): void;
  155467. /**
  155468. * Subtracts this CSG with another CSG
  155469. * @param csg The CSG to subtract against this CSG
  155470. * @returns A new CSG
  155471. */
  155472. subtract(csg: CSG): CSG;
  155473. /**
  155474. * Subtracts this CSG with another CSG in place
  155475. * @param csg The CSG to subtract against this CSG
  155476. */
  155477. subtractInPlace(csg: CSG): void;
  155478. /**
  155479. * Intersect this CSG with another CSG
  155480. * @param csg The CSG to intersect against this CSG
  155481. * @returns A new CSG
  155482. */
  155483. intersect(csg: CSG): CSG;
  155484. /**
  155485. * Intersects this CSG with another CSG in place
  155486. * @param csg The CSG to intersect against this CSG
  155487. */
  155488. intersectInPlace(csg: CSG): void;
  155489. /**
  155490. * Return a new CSG solid with solid and empty space switched. This solid is
  155491. * not modified.
  155492. * @returns A new CSG solid with solid and empty space switched
  155493. */
  155494. inverse(): CSG;
  155495. /**
  155496. * Inverses the CSG in place
  155497. */
  155498. inverseInPlace(): void;
  155499. /**
  155500. * This is used to keep meshes transformations so they can be restored
  155501. * when we build back a Babylon Mesh
  155502. * NB : All CSG operations are performed in world coordinates
  155503. * @param csg The CSG to copy the transform attributes from
  155504. * @returns This CSG
  155505. */
  155506. copyTransformAttributes(csg: CSG): CSG;
  155507. /**
  155508. * Build Raw mesh from CSG
  155509. * Coordinates here are in world space
  155510. * @param name The name of the mesh geometry
  155511. * @param scene The Scene
  155512. * @param keepSubMeshes Specifies if the submeshes should be kept
  155513. * @returns A new Mesh
  155514. */
  155515. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  155516. /**
  155517. * Build Mesh from CSG taking material and transforms into account
  155518. * @param name The name of the Mesh
  155519. * @param material The material of the Mesh
  155520. * @param scene The Scene
  155521. * @param keepSubMeshes Specifies if submeshes should be kept
  155522. * @returns The new Mesh
  155523. */
  155524. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  155525. }
  155526. }
  155527. declare module BABYLON {
  155528. /**
  155529. * Class used to create a trail following a mesh
  155530. */
  155531. export class TrailMesh extends Mesh {
  155532. private _generator;
  155533. private _autoStart;
  155534. private _running;
  155535. private _diameter;
  155536. private _length;
  155537. private _sectionPolygonPointsCount;
  155538. private _sectionVectors;
  155539. private _sectionNormalVectors;
  155540. private _beforeRenderObserver;
  155541. /**
  155542. * @constructor
  155543. * @param name The value used by scene.getMeshByName() to do a lookup.
  155544. * @param generator The mesh or transform node to generate a trail.
  155545. * @param scene The scene to add this mesh to.
  155546. * @param diameter Diameter of trailing mesh. Default is 1.
  155547. * @param length Length of trailing mesh. Default is 60.
  155548. * @param autoStart Automatically start trailing mesh. Default true.
  155549. */
  155550. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  155551. /**
  155552. * "TrailMesh"
  155553. * @returns "TrailMesh"
  155554. */
  155555. getClassName(): string;
  155556. private _createMesh;
  155557. /**
  155558. * Start trailing mesh.
  155559. */
  155560. start(): void;
  155561. /**
  155562. * Stop trailing mesh.
  155563. */
  155564. stop(): void;
  155565. /**
  155566. * Update trailing mesh geometry.
  155567. */
  155568. update(): void;
  155569. /**
  155570. * Returns a new TrailMesh object.
  155571. * @param name is a string, the name given to the new mesh
  155572. * @param newGenerator use new generator object for cloned trail mesh
  155573. * @returns a new mesh
  155574. */
  155575. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  155576. /**
  155577. * Serializes this trail mesh
  155578. * @param serializationObject object to write serialization to
  155579. */
  155580. serialize(serializationObject: any): void;
  155581. /**
  155582. * Parses a serialized trail mesh
  155583. * @param parsedMesh the serialized mesh
  155584. * @param scene the scene to create the trail mesh in
  155585. * @returns the created trail mesh
  155586. */
  155587. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  155588. }
  155589. }
  155590. declare module BABYLON {
  155591. /**
  155592. * Class containing static functions to help procedurally build meshes
  155593. */
  155594. export class TiledBoxBuilder {
  155595. /**
  155596. * Creates a box mesh
  155597. * 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)
  155598. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  155599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155602. * @param name defines the name of the mesh
  155603. * @param options defines the options used to create the mesh
  155604. * @param scene defines the hosting scene
  155605. * @returns the box mesh
  155606. */
  155607. static CreateTiledBox(name: string, options: {
  155608. pattern?: number;
  155609. width?: number;
  155610. height?: number;
  155611. depth?: number;
  155612. tileSize?: number;
  155613. tileWidth?: number;
  155614. tileHeight?: number;
  155615. alignHorizontal?: number;
  155616. alignVertical?: number;
  155617. faceUV?: Vector4[];
  155618. faceColors?: Color4[];
  155619. sideOrientation?: number;
  155620. updatable?: boolean;
  155621. }, scene?: Nullable<Scene>): Mesh;
  155622. }
  155623. }
  155624. declare module BABYLON {
  155625. /**
  155626. * Class containing static functions to help procedurally build meshes
  155627. */
  155628. export class TorusKnotBuilder {
  155629. /**
  155630. * Creates a torus knot mesh
  155631. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  155632. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  155633. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  155634. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  155635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  155638. * @param name defines the name of the mesh
  155639. * @param options defines the options used to create the mesh
  155640. * @param scene defines the hosting scene
  155641. * @returns the torus knot mesh
  155642. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  155643. */
  155644. static CreateTorusKnot(name: string, options: {
  155645. radius?: number;
  155646. tube?: number;
  155647. radialSegments?: number;
  155648. tubularSegments?: number;
  155649. p?: number;
  155650. q?: number;
  155651. updatable?: boolean;
  155652. sideOrientation?: number;
  155653. frontUVs?: Vector4;
  155654. backUVs?: Vector4;
  155655. }, scene: any): Mesh;
  155656. }
  155657. }
  155658. declare module BABYLON {
  155659. /**
  155660. * Polygon
  155661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  155662. */
  155663. export class Polygon {
  155664. /**
  155665. * Creates a rectangle
  155666. * @param xmin bottom X coord
  155667. * @param ymin bottom Y coord
  155668. * @param xmax top X coord
  155669. * @param ymax top Y coord
  155670. * @returns points that make the resulting rectangle
  155671. */
  155672. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  155673. /**
  155674. * Creates a circle
  155675. * @param radius radius of circle
  155676. * @param cx scale in x
  155677. * @param cy scale in y
  155678. * @param numberOfSides number of sides that make up the circle
  155679. * @returns points that make the resulting circle
  155680. */
  155681. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  155682. /**
  155683. * Creates a polygon from input string
  155684. * @param input Input polygon data
  155685. * @returns the parsed points
  155686. */
  155687. static Parse(input: string): Vector2[];
  155688. /**
  155689. * Starts building a polygon from x and y coordinates
  155690. * @param x x coordinate
  155691. * @param y y coordinate
  155692. * @returns the started path2
  155693. */
  155694. static StartingAt(x: number, y: number): Path2;
  155695. }
  155696. /**
  155697. * Builds a polygon
  155698. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  155699. */
  155700. export class PolygonMeshBuilder {
  155701. private _points;
  155702. private _outlinepoints;
  155703. private _holes;
  155704. private _name;
  155705. private _scene;
  155706. private _epoints;
  155707. private _eholes;
  155708. private _addToepoint;
  155709. /**
  155710. * Babylon reference to the earcut plugin.
  155711. */
  155712. bjsEarcut: any;
  155713. /**
  155714. * Creates a PolygonMeshBuilder
  155715. * @param name name of the builder
  155716. * @param contours Path of the polygon
  155717. * @param scene scene to add to when creating the mesh
  155718. * @param earcutInjection can be used to inject your own earcut reference
  155719. */
  155720. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  155721. /**
  155722. * Adds a hole within the polygon
  155723. * @param hole Array of points defining the hole
  155724. * @returns this
  155725. */
  155726. addHole(hole: Vector2[]): PolygonMeshBuilder;
  155727. /**
  155728. * Creates the polygon
  155729. * @param updatable If the mesh should be updatable
  155730. * @param depth The depth of the mesh created
  155731. * @param smoothingThreshold Dot product threshold for smoothed normals
  155732. * @returns the created mesh
  155733. */
  155734. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  155735. /**
  155736. * Creates the polygon
  155737. * @param depth The depth of the mesh created
  155738. * @param smoothingThreshold Dot product threshold for smoothed normals
  155739. * @returns the created VertexData
  155740. */
  155741. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  155742. /**
  155743. * Adds a side to the polygon
  155744. * @param positions points that make the polygon
  155745. * @param normals normals of the polygon
  155746. * @param uvs uvs of the polygon
  155747. * @param indices indices of the polygon
  155748. * @param bounds bounds of the polygon
  155749. * @param points points of the polygon
  155750. * @param depth depth of the polygon
  155751. * @param flip flip of the polygon
  155752. */
  155753. private addSide;
  155754. }
  155755. }
  155756. declare module BABYLON {
  155757. /**
  155758. * Class containing static functions to help procedurally build meshes
  155759. */
  155760. export class PolygonBuilder {
  155761. /**
  155762. * Creates a polygon mesh
  155763. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  155764. * * 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
  155765. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  155766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  155768. * * Remember you can only change the shape positions, not their number when updating a polygon
  155769. * @param name defines the name of the mesh
  155770. * @param options defines the options used to create the mesh
  155771. * @param scene defines the hosting scene
  155772. * @param earcutInjection can be used to inject your own earcut reference
  155773. * @returns the polygon mesh
  155774. */
  155775. static CreatePolygon(name: string, options: {
  155776. shape: Vector3[];
  155777. holes?: Vector3[][];
  155778. depth?: number;
  155779. smoothingThreshold?: number;
  155780. faceUV?: Vector4[];
  155781. faceColors?: Color4[];
  155782. updatable?: boolean;
  155783. sideOrientation?: number;
  155784. frontUVs?: Vector4;
  155785. backUVs?: Vector4;
  155786. wrap?: boolean;
  155787. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  155788. /**
  155789. * Creates an extruded polygon mesh, with depth in the Y direction.
  155790. * * 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)
  155791. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  155792. * @param name defines the name of the mesh
  155793. * @param options defines the options used to create the mesh
  155794. * @param scene defines the hosting scene
  155795. * @param earcutInjection can be used to inject your own earcut reference
  155796. * @returns the polygon mesh
  155797. */
  155798. static ExtrudePolygon(name: string, options: {
  155799. shape: Vector3[];
  155800. holes?: Vector3[][];
  155801. depth?: number;
  155802. faceUV?: Vector4[];
  155803. faceColors?: Color4[];
  155804. updatable?: boolean;
  155805. sideOrientation?: number;
  155806. frontUVs?: Vector4;
  155807. backUVs?: Vector4;
  155808. wrap?: boolean;
  155809. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  155810. }
  155811. }
  155812. declare module BABYLON {
  155813. /**
  155814. * Class containing static functions to help procedurally build meshes
  155815. */
  155816. export class LatheBuilder {
  155817. /**
  155818. * Creates lathe mesh.
  155819. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  155820. * * 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
  155821. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  155822. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  155823. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  155824. * * 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
  155825. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  155826. * * 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
  155827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155829. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155831. * @param name defines the name of the mesh
  155832. * @param options defines the options used to create the mesh
  155833. * @param scene defines the hosting scene
  155834. * @returns the lathe mesh
  155835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  155836. */
  155837. static CreateLathe(name: string, options: {
  155838. shape: Vector3[];
  155839. radius?: number;
  155840. tessellation?: number;
  155841. clip?: number;
  155842. arc?: number;
  155843. closed?: boolean;
  155844. updatable?: boolean;
  155845. sideOrientation?: number;
  155846. frontUVs?: Vector4;
  155847. backUVs?: Vector4;
  155848. cap?: number;
  155849. invertUV?: boolean;
  155850. }, scene?: Nullable<Scene>): Mesh;
  155851. }
  155852. }
  155853. declare module BABYLON {
  155854. /**
  155855. * Class containing static functions to help procedurally build meshes
  155856. */
  155857. export class TiledPlaneBuilder {
  155858. /**
  155859. * Creates a tiled plane mesh
  155860. * * The parameter `pattern` will, depending on value, do nothing or
  155861. * * * flip (reflect about central vertical) alternate tiles across and up
  155862. * * * flip every tile on alternate rows
  155863. * * * rotate (180 degs) alternate tiles across and up
  155864. * * * rotate every tile on alternate rows
  155865. * * * flip and rotate alternate tiles across and up
  155866. * * * flip and rotate every tile on alternate rows
  155867. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  155868. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  155869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  155871. * * 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)
  155872. * * 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)
  155873. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  155874. * @param name defines the name of the mesh
  155875. * @param options defines the options used to create the mesh
  155876. * @param scene defines the hosting scene
  155877. * @returns the box mesh
  155878. */
  155879. static CreateTiledPlane(name: string, options: {
  155880. pattern?: number;
  155881. tileSize?: number;
  155882. tileWidth?: number;
  155883. tileHeight?: number;
  155884. size?: number;
  155885. width?: number;
  155886. height?: number;
  155887. alignHorizontal?: number;
  155888. alignVertical?: number;
  155889. sideOrientation?: number;
  155890. frontUVs?: Vector4;
  155891. backUVs?: Vector4;
  155892. updatable?: boolean;
  155893. }, scene?: Nullable<Scene>): Mesh;
  155894. }
  155895. }
  155896. declare module BABYLON {
  155897. /**
  155898. * Class containing static functions to help procedurally build meshes
  155899. */
  155900. export class TubeBuilder {
  155901. /**
  155902. * Creates a tube mesh.
  155903. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  155904. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  155905. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  155906. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  155907. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  155908. * * 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)
  155909. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  155910. * * 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
  155911. * * 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
  155912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155914. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  155915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155916. * @param name defines the name of the mesh
  155917. * @param options defines the options used to create the mesh
  155918. * @param scene defines the hosting scene
  155919. * @returns the tube mesh
  155920. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  155921. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  155922. */
  155923. static CreateTube(name: string, options: {
  155924. path: Vector3[];
  155925. radius?: number;
  155926. tessellation?: number;
  155927. radiusFunction?: {
  155928. (i: number, distance: number): number;
  155929. };
  155930. cap?: number;
  155931. arc?: number;
  155932. updatable?: boolean;
  155933. sideOrientation?: number;
  155934. frontUVs?: Vector4;
  155935. backUVs?: Vector4;
  155936. instance?: Mesh;
  155937. invertUV?: boolean;
  155938. }, scene?: Nullable<Scene>): Mesh;
  155939. }
  155940. }
  155941. declare module BABYLON {
  155942. /**
  155943. * Class containing static functions to help procedurally build meshes
  155944. */
  155945. export class IcoSphereBuilder {
  155946. /**
  155947. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  155948. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  155949. * * 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`)
  155950. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  155951. * * 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
  155952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  155953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  155954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  155955. * @param name defines the name of the mesh
  155956. * @param options defines the options used to create the mesh
  155957. * @param scene defines the hosting scene
  155958. * @returns the icosahedron mesh
  155959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  155960. */
  155961. static CreateIcoSphere(name: string, options: {
  155962. radius?: number;
  155963. radiusX?: number;
  155964. radiusY?: number;
  155965. radiusZ?: number;
  155966. flat?: boolean;
  155967. subdivisions?: number;
  155968. sideOrientation?: number;
  155969. frontUVs?: Vector4;
  155970. backUVs?: Vector4;
  155971. updatable?: boolean;
  155972. }, scene?: Nullable<Scene>): Mesh;
  155973. }
  155974. }
  155975. declare module BABYLON {
  155976. /**
  155977. * Class containing static functions to help procedurally build meshes
  155978. */
  155979. export class DecalBuilder {
  155980. /**
  155981. * Creates a decal mesh.
  155982. * 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
  155983. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  155984. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  155985. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  155986. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  155987. * @param name defines the name of the mesh
  155988. * @param sourceMesh defines the mesh where the decal must be applied
  155989. * @param options defines the options used to create the mesh
  155990. * @param scene defines the hosting scene
  155991. * @returns the decal mesh
  155992. * @see https://doc.babylonjs.com/how_to/decals
  155993. */
  155994. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  155995. position?: Vector3;
  155996. normal?: Vector3;
  155997. size?: Vector3;
  155998. angle?: number;
  155999. }): Mesh;
  156000. }
  156001. }
  156002. declare module BABYLON {
  156003. /**
  156004. * Class containing static functions to help procedurally build meshes
  156005. */
  156006. export class MeshBuilder {
  156007. /**
  156008. * Creates a box mesh
  156009. * * The parameter `size` sets the size (float) of each box side (default 1)
  156010. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  156011. * * 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)
  156012. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  156013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156016. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  156017. * @param name defines the name of the mesh
  156018. * @param options defines the options used to create the mesh
  156019. * @param scene defines the hosting scene
  156020. * @returns the box mesh
  156021. */
  156022. static CreateBox(name: string, options: {
  156023. size?: number;
  156024. width?: number;
  156025. height?: number;
  156026. depth?: number;
  156027. faceUV?: Vector4[];
  156028. faceColors?: Color4[];
  156029. sideOrientation?: number;
  156030. frontUVs?: Vector4;
  156031. backUVs?: Vector4;
  156032. wrap?: boolean;
  156033. topBaseAt?: number;
  156034. bottomBaseAt?: number;
  156035. updatable?: boolean;
  156036. }, scene?: Nullable<Scene>): Mesh;
  156037. /**
  156038. * Creates a tiled box mesh
  156039. * * faceTiles sets the pattern, tile size and number of tiles for a face
  156040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156041. * @param name defines the name of the mesh
  156042. * @param options defines the options used to create the mesh
  156043. * @param scene defines the hosting scene
  156044. * @returns the tiled box mesh
  156045. */
  156046. static CreateTiledBox(name: string, options: {
  156047. pattern?: number;
  156048. size?: number;
  156049. width?: number;
  156050. height?: number;
  156051. depth: number;
  156052. tileSize?: number;
  156053. tileWidth?: number;
  156054. tileHeight?: number;
  156055. faceUV?: Vector4[];
  156056. faceColors?: Color4[];
  156057. alignHorizontal?: number;
  156058. alignVertical?: number;
  156059. sideOrientation?: number;
  156060. updatable?: boolean;
  156061. }, scene?: Nullable<Scene>): Mesh;
  156062. /**
  156063. * Creates a sphere mesh
  156064. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  156065. * * 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`)
  156066. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  156067. * * 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
  156068. * * 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)
  156069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156072. * @param name defines the name of the mesh
  156073. * @param options defines the options used to create the mesh
  156074. * @param scene defines the hosting scene
  156075. * @returns the sphere mesh
  156076. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  156077. */
  156078. static CreateSphere(name: string, options: {
  156079. segments?: number;
  156080. diameter?: number;
  156081. diameterX?: number;
  156082. diameterY?: number;
  156083. diameterZ?: number;
  156084. arc?: number;
  156085. slice?: number;
  156086. sideOrientation?: number;
  156087. frontUVs?: Vector4;
  156088. backUVs?: Vector4;
  156089. updatable?: boolean;
  156090. }, scene?: Nullable<Scene>): Mesh;
  156091. /**
  156092. * Creates a plane polygonal mesh. By default, this is a disc
  156093. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  156094. * * 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
  156095. * * 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
  156096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156099. * @param name defines the name of the mesh
  156100. * @param options defines the options used to create the mesh
  156101. * @param scene defines the hosting scene
  156102. * @returns the plane polygonal mesh
  156103. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  156104. */
  156105. static CreateDisc(name: string, options: {
  156106. radius?: number;
  156107. tessellation?: number;
  156108. arc?: number;
  156109. updatable?: boolean;
  156110. sideOrientation?: number;
  156111. frontUVs?: Vector4;
  156112. backUVs?: Vector4;
  156113. }, scene?: Nullable<Scene>): Mesh;
  156114. /**
  156115. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  156116. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  156117. * * 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`)
  156118. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  156119. * * 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
  156120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156123. * @param name defines the name of the mesh
  156124. * @param options defines the options used to create the mesh
  156125. * @param scene defines the hosting scene
  156126. * @returns the icosahedron mesh
  156127. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  156128. */
  156129. static CreateIcoSphere(name: string, options: {
  156130. radius?: number;
  156131. radiusX?: number;
  156132. radiusY?: number;
  156133. radiusZ?: number;
  156134. flat?: boolean;
  156135. subdivisions?: number;
  156136. sideOrientation?: number;
  156137. frontUVs?: Vector4;
  156138. backUVs?: Vector4;
  156139. updatable?: boolean;
  156140. }, scene?: Nullable<Scene>): Mesh;
  156141. /**
  156142. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  156143. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  156144. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  156145. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  156146. * * 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
  156147. * * 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
  156148. * * 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
  156149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  156152. * * 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
  156153. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  156154. * * 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
  156155. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  156156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156157. * @param name defines the name of the mesh
  156158. * @param options defines the options used to create the mesh
  156159. * @param scene defines the hosting scene
  156160. * @returns the ribbon mesh
  156161. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  156162. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  156163. */
  156164. static CreateRibbon(name: string, options: {
  156165. pathArray: Vector3[][];
  156166. closeArray?: boolean;
  156167. closePath?: boolean;
  156168. offset?: number;
  156169. updatable?: boolean;
  156170. sideOrientation?: number;
  156171. frontUVs?: Vector4;
  156172. backUVs?: Vector4;
  156173. instance?: Mesh;
  156174. invertUV?: boolean;
  156175. uvs?: Vector2[];
  156176. colors?: Color4[];
  156177. }, scene?: Nullable<Scene>): Mesh;
  156178. /**
  156179. * Creates a cylinder or a cone mesh
  156180. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  156181. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  156182. * * 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.
  156183. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  156184. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  156185. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  156186. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  156187. * * 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).
  156188. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  156189. * * 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).
  156190. * * 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
  156191. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  156192. * * 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
  156193. * * 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.
  156194. * * If `enclose` is false, a ring surface is one element.
  156195. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  156196. * * 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
  156197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  156200. * @param name defines the name of the mesh
  156201. * @param options defines the options used to create the mesh
  156202. * @param scene defines the hosting scene
  156203. * @returns the cylinder mesh
  156204. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  156205. */
  156206. static CreateCylinder(name: string, options: {
  156207. height?: number;
  156208. diameterTop?: number;
  156209. diameterBottom?: number;
  156210. diameter?: number;
  156211. tessellation?: number;
  156212. subdivisions?: number;
  156213. arc?: number;
  156214. faceColors?: Color4[];
  156215. faceUV?: Vector4[];
  156216. updatable?: boolean;
  156217. hasRings?: boolean;
  156218. enclose?: boolean;
  156219. cap?: number;
  156220. sideOrientation?: number;
  156221. frontUVs?: Vector4;
  156222. backUVs?: Vector4;
  156223. }, scene?: Nullable<Scene>): Mesh;
  156224. /**
  156225. * Creates a torus mesh
  156226. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  156227. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  156228. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  156229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  156232. * @param name defines the name of the mesh
  156233. * @param options defines the options used to create the mesh
  156234. * @param scene defines the hosting scene
  156235. * @returns the torus mesh
  156236. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  156237. */
  156238. static CreateTorus(name: string, options: {
  156239. diameter?: number;
  156240. thickness?: number;
  156241. tessellation?: number;
  156242. updatable?: boolean;
  156243. sideOrientation?: number;
  156244. frontUVs?: Vector4;
  156245. backUVs?: Vector4;
  156246. }, scene?: Nullable<Scene>): Mesh;
  156247. /**
  156248. * Creates a torus knot mesh
  156249. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  156250. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  156251. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  156252. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  156253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  156256. * @param name defines the name of the mesh
  156257. * @param options defines the options used to create the mesh
  156258. * @param scene defines the hosting scene
  156259. * @returns the torus knot mesh
  156260. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  156261. */
  156262. static CreateTorusKnot(name: string, options: {
  156263. radius?: number;
  156264. tube?: number;
  156265. radialSegments?: number;
  156266. tubularSegments?: number;
  156267. p?: number;
  156268. q?: number;
  156269. updatable?: boolean;
  156270. sideOrientation?: number;
  156271. frontUVs?: Vector4;
  156272. backUVs?: Vector4;
  156273. }, scene?: Nullable<Scene>): Mesh;
  156274. /**
  156275. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  156276. * * 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
  156277. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  156278. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  156279. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  156280. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  156281. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  156282. * * 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
  156283. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  156284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  156286. * @param name defines the name of the new line system
  156287. * @param options defines the options used to create the line system
  156288. * @param scene defines the hosting scene
  156289. * @returns a new line system mesh
  156290. */
  156291. static CreateLineSystem(name: string, options: {
  156292. lines: Vector3[][];
  156293. updatable?: boolean;
  156294. instance?: Nullable<LinesMesh>;
  156295. colors?: Nullable<Color4[][]>;
  156296. useVertexAlpha?: boolean;
  156297. }, scene: Nullable<Scene>): LinesMesh;
  156298. /**
  156299. * Creates a line mesh
  156300. * 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
  156301. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  156302. * * The parameter `points` is an array successive Vector3
  156303. * * 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
  156304. * * The optional parameter `colors` is an array of successive Color4, one per line point
  156305. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  156306. * * When updating an instance, remember that only point positions can change, not the number of points
  156307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  156309. * @param name defines the name of the new line system
  156310. * @param options defines the options used to create the line system
  156311. * @param scene defines the hosting scene
  156312. * @returns a new line mesh
  156313. */
  156314. static CreateLines(name: string, options: {
  156315. points: Vector3[];
  156316. updatable?: boolean;
  156317. instance?: Nullable<LinesMesh>;
  156318. colors?: Color4[];
  156319. useVertexAlpha?: boolean;
  156320. }, scene?: Nullable<Scene>): LinesMesh;
  156321. /**
  156322. * Creates a dashed line mesh
  156323. * * 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
  156324. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  156325. * * The parameter `points` is an array successive Vector3
  156326. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  156327. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  156328. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  156329. * * 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
  156330. * * When updating an instance, remember that only point positions can change, not the number of points
  156331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156332. * @param name defines the name of the mesh
  156333. * @param options defines the options used to create the mesh
  156334. * @param scene defines the hosting scene
  156335. * @returns the dashed line mesh
  156336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  156337. */
  156338. static CreateDashedLines(name: string, options: {
  156339. points: Vector3[];
  156340. dashSize?: number;
  156341. gapSize?: number;
  156342. dashNb?: number;
  156343. updatable?: boolean;
  156344. instance?: LinesMesh;
  156345. }, scene?: Nullable<Scene>): LinesMesh;
  156346. /**
  156347. * 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.
  156348. * * 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.
  156349. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  156350. * * 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.
  156351. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  156352. * * 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
  156353. * * 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
  156354. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  156355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  156358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  156359. * @param name defines the name of the mesh
  156360. * @param options defines the options used to create the mesh
  156361. * @param scene defines the hosting scene
  156362. * @returns the extruded shape mesh
  156363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  156364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  156365. */
  156366. static ExtrudeShape(name: string, options: {
  156367. shape: Vector3[];
  156368. path: Vector3[];
  156369. scale?: number;
  156370. rotation?: number;
  156371. cap?: number;
  156372. updatable?: boolean;
  156373. sideOrientation?: number;
  156374. frontUVs?: Vector4;
  156375. backUVs?: Vector4;
  156376. instance?: Mesh;
  156377. invertUV?: boolean;
  156378. }, scene?: Nullable<Scene>): Mesh;
  156379. /**
  156380. * Creates an custom extruded shape mesh.
  156381. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  156382. * * 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.
  156383. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  156384. * * 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 beginning of the path
  156385. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  156386. * * 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
  156387. * * It must returns a float value that will be the scale value applied to the shape on each path point
  156388. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  156389. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  156390. * * 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
  156391. * * 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
  156392. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  156393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156395. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  156396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156397. * @param name defines the name of the mesh
  156398. * @param options defines the options used to create the mesh
  156399. * @param scene defines the hosting scene
  156400. * @returns the custom extruded shape mesh
  156401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  156402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  156403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  156404. */
  156405. static ExtrudeShapeCustom(name: string, options: {
  156406. shape: Vector3[];
  156407. path: Vector3[];
  156408. scaleFunction?: any;
  156409. rotationFunction?: any;
  156410. ribbonCloseArray?: boolean;
  156411. ribbonClosePath?: boolean;
  156412. cap?: number;
  156413. updatable?: boolean;
  156414. sideOrientation?: number;
  156415. frontUVs?: Vector4;
  156416. backUVs?: Vector4;
  156417. instance?: Mesh;
  156418. invertUV?: boolean;
  156419. }, scene?: Nullable<Scene>): Mesh;
  156420. /**
  156421. * Creates lathe mesh.
  156422. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  156423. * * 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
  156424. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  156425. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  156426. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  156427. * * 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
  156428. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  156429. * * 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
  156430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156432. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  156433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156434. * @param name defines the name of the mesh
  156435. * @param options defines the options used to create the mesh
  156436. * @param scene defines the hosting scene
  156437. * @returns the lathe mesh
  156438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  156439. */
  156440. static CreateLathe(name: string, options: {
  156441. shape: Vector3[];
  156442. radius?: number;
  156443. tessellation?: number;
  156444. clip?: number;
  156445. arc?: number;
  156446. closed?: boolean;
  156447. updatable?: boolean;
  156448. sideOrientation?: number;
  156449. frontUVs?: Vector4;
  156450. backUVs?: Vector4;
  156451. cap?: number;
  156452. invertUV?: boolean;
  156453. }, scene?: Nullable<Scene>): Mesh;
  156454. /**
  156455. * Creates a tiled plane mesh
  156456. * * You can set a limited pattern arrangement with the tiles
  156457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156460. * @param name defines the name of the mesh
  156461. * @param options defines the options used to create the mesh
  156462. * @param scene defines the hosting scene
  156463. * @returns the plane mesh
  156464. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  156465. */
  156466. static CreateTiledPlane(name: string, options: {
  156467. pattern?: number;
  156468. tileSize?: number;
  156469. tileWidth?: number;
  156470. tileHeight?: number;
  156471. size?: number;
  156472. width?: number;
  156473. height?: number;
  156474. alignHorizontal?: number;
  156475. alignVertical?: number;
  156476. sideOrientation?: number;
  156477. frontUVs?: Vector4;
  156478. backUVs?: Vector4;
  156479. updatable?: boolean;
  156480. }, scene?: Nullable<Scene>): Mesh;
  156481. /**
  156482. * Creates a plane mesh
  156483. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  156484. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  156485. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  156486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156489. * @param name defines the name of the mesh
  156490. * @param options defines the options used to create the mesh
  156491. * @param scene defines the hosting scene
  156492. * @returns the plane mesh
  156493. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  156494. */
  156495. static CreatePlane(name: string, options: {
  156496. size?: number;
  156497. width?: number;
  156498. height?: number;
  156499. sideOrientation?: number;
  156500. frontUVs?: Vector4;
  156501. backUVs?: Vector4;
  156502. updatable?: boolean;
  156503. sourcePlane?: Plane;
  156504. }, scene?: Nullable<Scene>): Mesh;
  156505. /**
  156506. * Creates a ground mesh
  156507. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  156508. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  156509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156510. * @param name defines the name of the mesh
  156511. * @param options defines the options used to create the mesh
  156512. * @param scene defines the hosting scene
  156513. * @returns the ground mesh
  156514. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  156515. */
  156516. static CreateGround(name: string, options: {
  156517. width?: number;
  156518. height?: number;
  156519. subdivisions?: number;
  156520. subdivisionsX?: number;
  156521. subdivisionsY?: number;
  156522. updatable?: boolean;
  156523. }, scene?: Nullable<Scene>): Mesh;
  156524. /**
  156525. * Creates a tiled ground mesh
  156526. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  156527. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  156528. * * 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
  156529. * * 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
  156530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  156531. * @param name defines the name of the mesh
  156532. * @param options defines the options used to create the mesh
  156533. * @param scene defines the hosting scene
  156534. * @returns the tiled ground mesh
  156535. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  156536. */
  156537. static CreateTiledGround(name: string, options: {
  156538. xmin: number;
  156539. zmin: number;
  156540. xmax: number;
  156541. zmax: number;
  156542. subdivisions?: {
  156543. w: number;
  156544. h: number;
  156545. };
  156546. precision?: {
  156547. w: number;
  156548. h: number;
  156549. };
  156550. updatable?: boolean;
  156551. }, scene?: Nullable<Scene>): Mesh;
  156552. /**
  156553. * Creates a ground mesh from a height map
  156554. * * The parameter `url` sets the URL of the height map image resource.
  156555. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  156556. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  156557. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  156558. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  156559. * * 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.
  156560. * * 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).
  156561. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  156562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  156563. * @param name defines the name of the mesh
  156564. * @param url defines the url to the height map
  156565. * @param options defines the options used to create the mesh
  156566. * @param scene defines the hosting scene
  156567. * @returns the ground mesh
  156568. * @see https://doc.babylonjs.com/babylon101/height_map
  156569. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  156570. */
  156571. static CreateGroundFromHeightMap(name: string, url: string, options: {
  156572. width?: number;
  156573. height?: number;
  156574. subdivisions?: number;
  156575. minHeight?: number;
  156576. maxHeight?: number;
  156577. colorFilter?: Color3;
  156578. alphaFilter?: number;
  156579. updatable?: boolean;
  156580. onReady?: (mesh: GroundMesh) => void;
  156581. }, scene?: Nullable<Scene>): GroundMesh;
  156582. /**
  156583. * Creates a polygon mesh
  156584. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  156585. * * 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
  156586. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  156587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  156589. * * Remember you can only change the shape positions, not their number when updating a polygon
  156590. * @param name defines the name of the mesh
  156591. * @param options defines the options used to create the mesh
  156592. * @param scene defines the hosting scene
  156593. * @param earcutInjection can be used to inject your own earcut reference
  156594. * @returns the polygon mesh
  156595. */
  156596. static CreatePolygon(name: string, options: {
  156597. shape: Vector3[];
  156598. holes?: Vector3[][];
  156599. depth?: number;
  156600. faceUV?: Vector4[];
  156601. faceColors?: Color4[];
  156602. updatable?: boolean;
  156603. sideOrientation?: number;
  156604. frontUVs?: Vector4;
  156605. backUVs?: Vector4;
  156606. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  156607. /**
  156608. * Creates an extruded polygon mesh, with depth in the Y direction.
  156609. * * 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)
  156610. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  156611. * @param name defines the name of the mesh
  156612. * @param options defines the options used to create the mesh
  156613. * @param scene defines the hosting scene
  156614. * @param earcutInjection can be used to inject your own earcut reference
  156615. * @returns the polygon mesh
  156616. */
  156617. static ExtrudePolygon(name: string, options: {
  156618. shape: Vector3[];
  156619. holes?: Vector3[][];
  156620. depth?: number;
  156621. faceUV?: Vector4[];
  156622. faceColors?: Color4[];
  156623. updatable?: boolean;
  156624. sideOrientation?: number;
  156625. frontUVs?: Vector4;
  156626. backUVs?: Vector4;
  156627. wrap?: boolean;
  156628. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  156629. /**
  156630. * Creates a tube mesh.
  156631. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  156632. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  156633. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  156634. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  156635. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  156636. * * 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)
  156637. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  156638. * * 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
  156639. * * 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
  156640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156642. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  156643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156644. * @param name defines the name of the mesh
  156645. * @param options defines the options used to create the mesh
  156646. * @param scene defines the hosting scene
  156647. * @returns the tube mesh
  156648. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  156649. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  156650. */
  156651. static CreateTube(name: string, options: {
  156652. path: Vector3[];
  156653. radius?: number;
  156654. tessellation?: number;
  156655. radiusFunction?: {
  156656. (i: number, distance: number): number;
  156657. };
  156658. cap?: number;
  156659. arc?: number;
  156660. updatable?: boolean;
  156661. sideOrientation?: number;
  156662. frontUVs?: Vector4;
  156663. backUVs?: Vector4;
  156664. instance?: Mesh;
  156665. invertUV?: boolean;
  156666. }, scene?: Nullable<Scene>): Mesh;
  156667. /**
  156668. * Creates a polyhedron mesh
  156669. * * 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
  156670. * * The parameter `size` (positive float, default 1) sets the polygon size
  156671. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  156672. * * 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`
  156673. * * 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
  156674. * * 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)`)
  156675. * * 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
  156676. * * 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
  156677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  156678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  156679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  156680. * @param name defines the name of the mesh
  156681. * @param options defines the options used to create the mesh
  156682. * @param scene defines the hosting scene
  156683. * @returns the polyhedron mesh
  156684. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  156685. */
  156686. static CreatePolyhedron(name: string, options: {
  156687. type?: number;
  156688. size?: number;
  156689. sizeX?: number;
  156690. sizeY?: number;
  156691. sizeZ?: number;
  156692. custom?: any;
  156693. faceUV?: Vector4[];
  156694. faceColors?: Color4[];
  156695. flat?: boolean;
  156696. updatable?: boolean;
  156697. sideOrientation?: number;
  156698. frontUVs?: Vector4;
  156699. backUVs?: Vector4;
  156700. }, scene?: Nullable<Scene>): Mesh;
  156701. /**
  156702. * Creates a decal mesh.
  156703. * 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
  156704. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  156705. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  156706. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  156707. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  156708. * @param name defines the name of the mesh
  156709. * @param sourceMesh defines the mesh where the decal must be applied
  156710. * @param options defines the options used to create the mesh
  156711. * @param scene defines the hosting scene
  156712. * @returns the decal mesh
  156713. * @see https://doc.babylonjs.com/how_to/decals
  156714. */
  156715. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  156716. position?: Vector3;
  156717. normal?: Vector3;
  156718. size?: Vector3;
  156719. angle?: number;
  156720. }): Mesh;
  156721. /**
  156722. * Creates a Capsule Mesh
  156723. * @param name defines the name of the mesh.
  156724. * @param options the constructors options used to shape the mesh.
  156725. * @param scene defines the scene the mesh is scoped to.
  156726. * @returns the capsule mesh
  156727. * @see https://doc.babylonjs.com/how_to/capsule_shape
  156728. */
  156729. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  156730. }
  156731. }
  156732. declare module BABYLON {
  156733. /**
  156734. * A simplifier interface for future simplification implementations
  156735. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156736. */
  156737. export interface ISimplifier {
  156738. /**
  156739. * Simplification of a given mesh according to the given settings.
  156740. * Since this requires computation, it is assumed that the function runs async.
  156741. * @param settings The settings of the simplification, including quality and distance
  156742. * @param successCallback A callback that will be called after the mesh was simplified.
  156743. * @param errorCallback in case of an error, this callback will be called. optional.
  156744. */
  156745. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  156746. }
  156747. /**
  156748. * Expected simplification settings.
  156749. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  156750. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156751. */
  156752. export interface ISimplificationSettings {
  156753. /**
  156754. * Gets or sets the expected quality
  156755. */
  156756. quality: number;
  156757. /**
  156758. * Gets or sets the distance when this optimized version should be used
  156759. */
  156760. distance: number;
  156761. /**
  156762. * Gets an already optimized mesh
  156763. */
  156764. optimizeMesh?: boolean;
  156765. }
  156766. /**
  156767. * Class used to specify simplification options
  156768. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156769. */
  156770. export class SimplificationSettings implements ISimplificationSettings {
  156771. /** expected quality */
  156772. quality: number;
  156773. /** distance when this optimized version should be used */
  156774. distance: number;
  156775. /** already optimized mesh */
  156776. optimizeMesh?: boolean | undefined;
  156777. /**
  156778. * Creates a SimplificationSettings
  156779. * @param quality expected quality
  156780. * @param distance distance when this optimized version should be used
  156781. * @param optimizeMesh already optimized mesh
  156782. */
  156783. constructor(
  156784. /** expected quality */
  156785. quality: number,
  156786. /** distance when this optimized version should be used */
  156787. distance: number,
  156788. /** already optimized mesh */
  156789. optimizeMesh?: boolean | undefined);
  156790. }
  156791. /**
  156792. * Interface used to define a simplification task
  156793. */
  156794. export interface ISimplificationTask {
  156795. /**
  156796. * Array of settings
  156797. */
  156798. settings: Array<ISimplificationSettings>;
  156799. /**
  156800. * Simplification type
  156801. */
  156802. simplificationType: SimplificationType;
  156803. /**
  156804. * Mesh to simplify
  156805. */
  156806. mesh: Mesh;
  156807. /**
  156808. * Callback called on success
  156809. */
  156810. successCallback?: () => void;
  156811. /**
  156812. * Defines if parallel processing can be used
  156813. */
  156814. parallelProcessing: boolean;
  156815. }
  156816. /**
  156817. * Queue used to order the simplification tasks
  156818. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156819. */
  156820. export class SimplificationQueue {
  156821. private _simplificationArray;
  156822. /**
  156823. * Gets a boolean indicating that the process is still running
  156824. */
  156825. running: boolean;
  156826. /**
  156827. * Creates a new queue
  156828. */
  156829. constructor();
  156830. /**
  156831. * Adds a new simplification task
  156832. * @param task defines a task to add
  156833. */
  156834. addTask(task: ISimplificationTask): void;
  156835. /**
  156836. * Execute next task
  156837. */
  156838. executeNext(): void;
  156839. /**
  156840. * Execute a simplification task
  156841. * @param task defines the task to run
  156842. */
  156843. runSimplification(task: ISimplificationTask): void;
  156844. private getSimplifier;
  156845. }
  156846. /**
  156847. * The implemented types of simplification
  156848. * At the moment only Quadratic Error Decimation is implemented
  156849. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156850. */
  156851. export enum SimplificationType {
  156852. /** Quadratic error decimation */
  156853. QUADRATIC = 0
  156854. }
  156855. /**
  156856. * An implementation of the Quadratic Error simplification algorithm.
  156857. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  156858. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  156859. * @author RaananW
  156860. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156861. */
  156862. export class QuadraticErrorSimplification implements ISimplifier {
  156863. private _mesh;
  156864. private triangles;
  156865. private vertices;
  156866. private references;
  156867. private _reconstructedMesh;
  156868. /** Gets or sets the number pf sync iterations */
  156869. syncIterations: number;
  156870. /** Gets or sets the aggressiveness of the simplifier */
  156871. aggressiveness: number;
  156872. /** Gets or sets the number of allowed iterations for decimation */
  156873. decimationIterations: number;
  156874. /** Gets or sets the espilon to use for bounding box computation */
  156875. boundingBoxEpsilon: number;
  156876. /**
  156877. * Creates a new QuadraticErrorSimplification
  156878. * @param _mesh defines the target mesh
  156879. */
  156880. constructor(_mesh: Mesh);
  156881. /**
  156882. * Simplification of a given mesh according to the given settings.
  156883. * Since this requires computation, it is assumed that the function runs async.
  156884. * @param settings The settings of the simplification, including quality and distance
  156885. * @param successCallback A callback that will be called after the mesh was simplified.
  156886. */
  156887. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  156888. private runDecimation;
  156889. private initWithMesh;
  156890. private init;
  156891. private reconstructMesh;
  156892. private initDecimatedMesh;
  156893. private isFlipped;
  156894. private updateTriangles;
  156895. private identifyBorder;
  156896. private updateMesh;
  156897. private vertexError;
  156898. private calculateError;
  156899. }
  156900. }
  156901. declare module BABYLON {
  156902. interface Scene {
  156903. /** @hidden (Backing field) */
  156904. _simplificationQueue: SimplificationQueue;
  156905. /**
  156906. * Gets or sets the simplification queue attached to the scene
  156907. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  156908. */
  156909. simplificationQueue: SimplificationQueue;
  156910. }
  156911. interface Mesh {
  156912. /**
  156913. * Simplify the mesh according to the given array of settings.
  156914. * Function will return immediately and will simplify async
  156915. * @param settings a collection of simplification settings
  156916. * @param parallelProcessing should all levels calculate parallel or one after the other
  156917. * @param simplificationType the type of simplification to run
  156918. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  156919. * @returns the current mesh
  156920. */
  156921. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  156922. }
  156923. /**
  156924. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  156925. * created in a scene
  156926. */
  156927. export class SimplicationQueueSceneComponent implements ISceneComponent {
  156928. /**
  156929. * The component name helpfull to identify the component in the list of scene components.
  156930. */
  156931. readonly name: string;
  156932. /**
  156933. * The scene the component belongs to.
  156934. */
  156935. scene: Scene;
  156936. /**
  156937. * Creates a new instance of the component for the given scene
  156938. * @param scene Defines the scene to register the component in
  156939. */
  156940. constructor(scene: Scene);
  156941. /**
  156942. * Registers the component in a given scene
  156943. */
  156944. register(): void;
  156945. /**
  156946. * Rebuilds the elements related to this component in case of
  156947. * context lost for instance.
  156948. */
  156949. rebuild(): void;
  156950. /**
  156951. * Disposes the component and the associated resources
  156952. */
  156953. dispose(): void;
  156954. private _beforeCameraUpdate;
  156955. }
  156956. }
  156957. declare module BABYLON {
  156958. interface Mesh {
  156959. /**
  156960. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  156961. */
  156962. thinInstanceEnablePicking: boolean;
  156963. /**
  156964. * Creates a new thin instance
  156965. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  156966. * @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
  156967. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  156968. */
  156969. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  156970. /**
  156971. * Adds the transformation (matrix) of the current mesh as a thin instance
  156972. * @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
  156973. * @returns the thin instance index number
  156974. */
  156975. thinInstanceAddSelf(refresh: boolean): number;
  156976. /**
  156977. * Registers a custom attribute to be used with thin instances
  156978. * @param kind name of the attribute
  156979. * @param stride size in floats of the attribute
  156980. */
  156981. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  156982. /**
  156983. * Sets the matrix of a thin instance
  156984. * @param index index of the thin instance
  156985. * @param matrix matrix to set
  156986. * @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
  156987. */
  156988. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  156989. /**
  156990. * Sets the value of a custom attribute for a thin instance
  156991. * @param kind name of the attribute
  156992. * @param index index of the thin instance
  156993. * @param value value to set
  156994. * @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
  156995. */
  156996. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  156997. /**
  156998. * 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.
  156999. */
  157000. thinInstanceCount: number;
  157001. /**
  157002. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  157003. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  157004. * @param buffer buffer to set
  157005. * @param stride size in floats of each value of the buffer
  157006. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  157007. */
  157008. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  157009. /**
  157010. * Gets the list of world matrices
  157011. * @return an array containing all the world matrices from the thin instances
  157012. */
  157013. thinInstanceGetWorldMatrices(): Matrix[];
  157014. /**
  157015. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  157016. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  157017. */
  157018. thinInstanceBufferUpdated(kind: string): void;
  157019. /**
  157020. * Applies a partial update to a buffer directly on the GPU
  157021. * 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
  157022. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  157023. * @param data the data to set in the GPU buffer
  157024. * @param offset the offset in the GPU buffer where to update the data
  157025. */
  157026. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  157027. /**
  157028. * Refreshes the bounding info, taking into account all the thin instances defined
  157029. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  157030. */
  157031. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  157032. /** @hidden */
  157033. _thinInstanceInitializeUserStorage(): void;
  157034. /** @hidden */
  157035. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  157036. /** @hidden */
  157037. _userThinInstanceBuffersStorage: {
  157038. data: {
  157039. [key: string]: Float32Array;
  157040. };
  157041. sizes: {
  157042. [key: string]: number;
  157043. };
  157044. vertexBuffers: {
  157045. [key: string]: Nullable<VertexBuffer>;
  157046. };
  157047. strides: {
  157048. [key: string]: number;
  157049. };
  157050. };
  157051. }
  157052. }
  157053. declare module BABYLON {
  157054. /**
  157055. * Navigation plugin interface to add navigation constrained by a navigation mesh
  157056. */
  157057. export interface INavigationEnginePlugin {
  157058. /**
  157059. * plugin name
  157060. */
  157061. name: string;
  157062. /**
  157063. * Creates a navigation mesh
  157064. * @param meshes array of all the geometry used to compute the navigation mesh
  157065. * @param parameters bunch of parameters used to filter geometry
  157066. */
  157067. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  157068. /**
  157069. * Create a navigation mesh debug mesh
  157070. * @param scene is where the mesh will be added
  157071. * @returns debug display mesh
  157072. */
  157073. createDebugNavMesh(scene: Scene): Mesh;
  157074. /**
  157075. * Get a navigation mesh constrained position, closest to the parameter position
  157076. * @param position world position
  157077. * @returns the closest point to position constrained by the navigation mesh
  157078. */
  157079. getClosestPoint(position: Vector3): Vector3;
  157080. /**
  157081. * Get a navigation mesh constrained position, closest to the parameter position
  157082. * @param position world position
  157083. * @param result output the closest point to position constrained by the navigation mesh
  157084. */
  157085. getClosestPointToRef(position: Vector3, result: Vector3): void;
  157086. /**
  157087. * Get a navigation mesh constrained position, within a particular radius
  157088. * @param position world position
  157089. * @param maxRadius the maximum distance to the constrained world position
  157090. * @returns the closest point to position constrained by the navigation mesh
  157091. */
  157092. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  157093. /**
  157094. * Get a navigation mesh constrained position, within a particular radius
  157095. * @param position world position
  157096. * @param maxRadius the maximum distance to the constrained world position
  157097. * @param result output the closest point to position constrained by the navigation mesh
  157098. */
  157099. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  157100. /**
  157101. * Compute the final position from a segment made of destination-position
  157102. * @param position world position
  157103. * @param destination world position
  157104. * @returns the resulting point along the navmesh
  157105. */
  157106. moveAlong(position: Vector3, destination: Vector3): Vector3;
  157107. /**
  157108. * Compute the final position from a segment made of destination-position
  157109. * @param position world position
  157110. * @param destination world position
  157111. * @param result output the resulting point along the navmesh
  157112. */
  157113. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  157114. /**
  157115. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  157116. * @param start world position
  157117. * @param end world position
  157118. * @returns array containing world position composing the path
  157119. */
  157120. computePath(start: Vector3, end: Vector3): Vector3[];
  157121. /**
  157122. * If this plugin is supported
  157123. * @returns true if plugin is supported
  157124. */
  157125. isSupported(): boolean;
  157126. /**
  157127. * Create a new Crowd so you can add agents
  157128. * @param maxAgents the maximum agent count in the crowd
  157129. * @param maxAgentRadius the maximum radius an agent can have
  157130. * @param scene to attach the crowd to
  157131. * @returns the crowd you can add agents to
  157132. */
  157133. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  157134. /**
  157135. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  157136. * The queries will try to find a solution within those bounds
  157137. * default is (1,1,1)
  157138. * @param extent x,y,z value that define the extent around the queries point of reference
  157139. */
  157140. setDefaultQueryExtent(extent: Vector3): void;
  157141. /**
  157142. * Get the Bounding box extent specified by setDefaultQueryExtent
  157143. * @returns the box extent values
  157144. */
  157145. getDefaultQueryExtent(): Vector3;
  157146. /**
  157147. * build the navmesh from a previously saved state using getNavmeshData
  157148. * @param data the Uint8Array returned by getNavmeshData
  157149. */
  157150. buildFromNavmeshData(data: Uint8Array): void;
  157151. /**
  157152. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  157153. * @returns data the Uint8Array that can be saved and reused
  157154. */
  157155. getNavmeshData(): Uint8Array;
  157156. /**
  157157. * Get the Bounding box extent result specified by setDefaultQueryExtent
  157158. * @param result output the box extent values
  157159. */
  157160. getDefaultQueryExtentToRef(result: Vector3): void;
  157161. /**
  157162. * Set the time step of the navigation tick update.
  157163. * Default is 1/60.
  157164. * A value of 0 will disable fixed time update
  157165. * @param newTimeStep the new timestep to apply to this world.
  157166. */
  157167. setTimeStep(newTimeStep: number): void;
  157168. /**
  157169. * Get the time step of the navigation tick update.
  157170. * @returns the current time step
  157171. */
  157172. getTimeStep(): number;
  157173. /**
  157174. * If delta time in navigation tick update is greater than the time step
  157175. * a number of sub iterations are done. If more iterations are need to reach deltatime
  157176. * they will be discarded.
  157177. * A value of 0 will set to no maximum and update will use as many substeps as needed
  157178. * @param newStepCount the maximum number of iterations
  157179. */
  157180. setMaximumSubStepCount(newStepCount: number): void;
  157181. /**
  157182. * Get the maximum number of iterations per navigation tick update
  157183. * @returns the maximum number of iterations
  157184. */
  157185. getMaximumSubStepCount(): number;
  157186. /**
  157187. * Release all resources
  157188. */
  157189. dispose(): void;
  157190. }
  157191. /**
  157192. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  157193. */
  157194. export interface ICrowd {
  157195. /**
  157196. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  157197. * You can attach anything to that node. The node position is updated in the scene update tick.
  157198. * @param pos world position that will be constrained by the navigation mesh
  157199. * @param parameters agent parameters
  157200. * @param transform hooked to the agent that will be update by the scene
  157201. * @returns agent index
  157202. */
  157203. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  157204. /**
  157205. * Returns the agent position in world space
  157206. * @param index agent index returned by addAgent
  157207. * @returns world space position
  157208. */
  157209. getAgentPosition(index: number): Vector3;
  157210. /**
  157211. * Gets the agent position result in world space
  157212. * @param index agent index returned by addAgent
  157213. * @param result output world space position
  157214. */
  157215. getAgentPositionToRef(index: number, result: Vector3): void;
  157216. /**
  157217. * Gets the agent velocity in world space
  157218. * @param index agent index returned by addAgent
  157219. * @returns world space velocity
  157220. */
  157221. getAgentVelocity(index: number): Vector3;
  157222. /**
  157223. * Gets the agent velocity result in world space
  157224. * @param index agent index returned by addAgent
  157225. * @param result output world space velocity
  157226. */
  157227. getAgentVelocityToRef(index: number, result: Vector3): void;
  157228. /**
  157229. * Gets the agent next target point on the path
  157230. * @param index agent index returned by addAgent
  157231. * @returns world space position
  157232. */
  157233. getAgentNextTargetPath(index: number): Vector3;
  157234. /**
  157235. * Gets the agent state
  157236. * @param index agent index returned by addAgent
  157237. * @returns agent state
  157238. */
  157239. getAgentState(index: number): number;
  157240. /**
  157241. * returns true if the agent in over an off mesh link connection
  157242. * @param index agent index returned by addAgent
  157243. * @returns true if over an off mesh link connection
  157244. */
  157245. overOffmeshConnection(index: number): boolean;
  157246. /**
  157247. * Gets the agent next target point on the path
  157248. * @param index agent index returned by addAgent
  157249. * @param result output world space position
  157250. */
  157251. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  157252. /**
  157253. * remove a particular agent previously created
  157254. * @param index agent index returned by addAgent
  157255. */
  157256. removeAgent(index: number): void;
  157257. /**
  157258. * get the list of all agents attached to this crowd
  157259. * @returns list of agent indices
  157260. */
  157261. getAgents(): number[];
  157262. /**
  157263. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  157264. * @param deltaTime in seconds
  157265. */
  157266. update(deltaTime: number): void;
  157267. /**
  157268. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  157269. * @param index agent index returned by addAgent
  157270. * @param destination targeted world position
  157271. */
  157272. agentGoto(index: number, destination: Vector3): void;
  157273. /**
  157274. * Teleport the agent to a new position
  157275. * @param index agent index returned by addAgent
  157276. * @param destination targeted world position
  157277. */
  157278. agentTeleport(index: number, destination: Vector3): void;
  157279. /**
  157280. * Update agent parameters
  157281. * @param index agent index returned by addAgent
  157282. * @param parameters agent parameters
  157283. */
  157284. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  157285. /**
  157286. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  157287. * The queries will try to find a solution within those bounds
  157288. * default is (1,1,1)
  157289. * @param extent x,y,z value that define the extent around the queries point of reference
  157290. */
  157291. setDefaultQueryExtent(extent: Vector3): void;
  157292. /**
  157293. * Get the Bounding box extent specified by setDefaultQueryExtent
  157294. * @returns the box extent values
  157295. */
  157296. getDefaultQueryExtent(): Vector3;
  157297. /**
  157298. * Get the Bounding box extent result specified by setDefaultQueryExtent
  157299. * @param result output the box extent values
  157300. */
  157301. getDefaultQueryExtentToRef(result: Vector3): void;
  157302. /**
  157303. * Release all resources
  157304. */
  157305. dispose(): void;
  157306. }
  157307. /**
  157308. * Configures an agent
  157309. */
  157310. export interface IAgentParameters {
  157311. /**
  157312. * Agent radius. [Limit: >= 0]
  157313. */
  157314. radius: number;
  157315. /**
  157316. * Agent height. [Limit: > 0]
  157317. */
  157318. height: number;
  157319. /**
  157320. * Maximum allowed acceleration. [Limit: >= 0]
  157321. */
  157322. maxAcceleration: number;
  157323. /**
  157324. * Maximum allowed speed. [Limit: >= 0]
  157325. */
  157326. maxSpeed: number;
  157327. /**
  157328. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  157329. */
  157330. collisionQueryRange: number;
  157331. /**
  157332. * The path visibility optimization range. [Limit: > 0]
  157333. */
  157334. pathOptimizationRange: number;
  157335. /**
  157336. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  157337. */
  157338. separationWeight: number;
  157339. }
  157340. /**
  157341. * Configures the navigation mesh creation
  157342. */
  157343. export interface INavMeshParameters {
  157344. /**
  157345. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  157346. */
  157347. cs: number;
  157348. /**
  157349. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  157350. */
  157351. ch: number;
  157352. /**
  157353. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  157354. */
  157355. walkableSlopeAngle: number;
  157356. /**
  157357. * Minimum floor to 'ceiling' height that will still allow the floor area to
  157358. * be considered walkable. [Limit: >= 3] [Units: vx]
  157359. */
  157360. walkableHeight: number;
  157361. /**
  157362. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  157363. */
  157364. walkableClimb: number;
  157365. /**
  157366. * The distance to erode/shrink the walkable area of the heightfield away from
  157367. * obstructions. [Limit: >=0] [Units: vx]
  157368. */
  157369. walkableRadius: number;
  157370. /**
  157371. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  157372. */
  157373. maxEdgeLen: number;
  157374. /**
  157375. * The maximum distance a simplified contour's border edges should deviate
  157376. * the original raw contour. [Limit: >=0] [Units: vx]
  157377. */
  157378. maxSimplificationError: number;
  157379. /**
  157380. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  157381. */
  157382. minRegionArea: number;
  157383. /**
  157384. * Any regions with a span count smaller than this value will, if possible,
  157385. * be merged with larger regions. [Limit: >=0] [Units: vx]
  157386. */
  157387. mergeRegionArea: number;
  157388. /**
  157389. * The maximum number of vertices allowed for polygons generated during the
  157390. * contour to polygon conversion process. [Limit: >= 3]
  157391. */
  157392. maxVertsPerPoly: number;
  157393. /**
  157394. * Sets the sampling distance to use when generating the detail mesh.
  157395. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  157396. */
  157397. detailSampleDist: number;
  157398. /**
  157399. * The maximum distance the detail mesh surface should deviate from heightfield
  157400. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  157401. */
  157402. detailSampleMaxError: number;
  157403. }
  157404. }
  157405. declare module BABYLON {
  157406. /**
  157407. * RecastJS navigation plugin
  157408. */
  157409. export class RecastJSPlugin implements INavigationEnginePlugin {
  157410. /**
  157411. * Reference to the Recast library
  157412. */
  157413. bjsRECAST: any;
  157414. /**
  157415. * plugin name
  157416. */
  157417. name: string;
  157418. /**
  157419. * the first navmesh created. We might extend this to support multiple navmeshes
  157420. */
  157421. navMesh: any;
  157422. private _maximumSubStepCount;
  157423. private _timeStep;
  157424. /**
  157425. * Initializes the recastJS plugin
  157426. * @param recastInjection can be used to inject your own recast reference
  157427. */
  157428. constructor(recastInjection?: any);
  157429. /**
  157430. * Set the time step of the navigation tick update.
  157431. * Default is 1/60.
  157432. * A value of 0 will disable fixed time update
  157433. * @param newTimeStep the new timestep to apply to this world.
  157434. */
  157435. setTimeStep(newTimeStep?: number): void;
  157436. /**
  157437. * Get the time step of the navigation tick update.
  157438. * @returns the current time step
  157439. */
  157440. getTimeStep(): number;
  157441. /**
  157442. * If delta time in navigation tick update is greater than the time step
  157443. * a number of sub iterations are done. If more iterations are need to reach deltatime
  157444. * they will be discarded.
  157445. * A value of 0 will set to no maximum and update will use as many substeps as needed
  157446. * @param newStepCount the maximum number of iterations
  157447. */
  157448. setMaximumSubStepCount(newStepCount?: number): void;
  157449. /**
  157450. * Get the maximum number of iterations per navigation tick update
  157451. * @returns the maximum number of iterations
  157452. */
  157453. getMaximumSubStepCount(): number;
  157454. /**
  157455. * Creates a navigation mesh
  157456. * @param meshes array of all the geometry used to compute the navigation mesh
  157457. * @param parameters bunch of parameters used to filter geometry
  157458. */
  157459. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  157460. /**
  157461. * Create a navigation mesh debug mesh
  157462. * @param scene is where the mesh will be added
  157463. * @returns debug display mesh
  157464. */
  157465. createDebugNavMesh(scene: Scene): Mesh;
  157466. /**
  157467. * Get a navigation mesh constrained position, closest to the parameter position
  157468. * @param position world position
  157469. * @returns the closest point to position constrained by the navigation mesh
  157470. */
  157471. getClosestPoint(position: Vector3): Vector3;
  157472. /**
  157473. * Get a navigation mesh constrained position, closest to the parameter position
  157474. * @param position world position
  157475. * @param result output the closest point to position constrained by the navigation mesh
  157476. */
  157477. getClosestPointToRef(position: Vector3, result: Vector3): void;
  157478. /**
  157479. * Get a navigation mesh constrained position, within a particular radius
  157480. * @param position world position
  157481. * @param maxRadius the maximum distance to the constrained world position
  157482. * @returns the closest point to position constrained by the navigation mesh
  157483. */
  157484. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  157485. /**
  157486. * Get a navigation mesh constrained position, within a particular radius
  157487. * @param position world position
  157488. * @param maxRadius the maximum distance to the constrained world position
  157489. * @param result output the closest point to position constrained by the navigation mesh
  157490. */
  157491. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  157492. /**
  157493. * Compute the final position from a segment made of destination-position
  157494. * @param position world position
  157495. * @param destination world position
  157496. * @returns the resulting point along the navmesh
  157497. */
  157498. moveAlong(position: Vector3, destination: Vector3): Vector3;
  157499. /**
  157500. * Compute the final position from a segment made of destination-position
  157501. * @param position world position
  157502. * @param destination world position
  157503. * @param result output the resulting point along the navmesh
  157504. */
  157505. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  157506. /**
  157507. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  157508. * @param start world position
  157509. * @param end world position
  157510. * @returns array containing world position composing the path
  157511. */
  157512. computePath(start: Vector3, end: Vector3): Vector3[];
  157513. /**
  157514. * Create a new Crowd so you can add agents
  157515. * @param maxAgents the maximum agent count in the crowd
  157516. * @param maxAgentRadius the maximum radius an agent can have
  157517. * @param scene to attach the crowd to
  157518. * @returns the crowd you can add agents to
  157519. */
  157520. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  157521. /**
  157522. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  157523. * The queries will try to find a solution within those bounds
  157524. * default is (1,1,1)
  157525. * @param extent x,y,z value that define the extent around the queries point of reference
  157526. */
  157527. setDefaultQueryExtent(extent: Vector3): void;
  157528. /**
  157529. * Get the Bounding box extent specified by setDefaultQueryExtent
  157530. * @returns the box extent values
  157531. */
  157532. getDefaultQueryExtent(): Vector3;
  157533. /**
  157534. * build the navmesh from a previously saved state using getNavmeshData
  157535. * @param data the Uint8Array returned by getNavmeshData
  157536. */
  157537. buildFromNavmeshData(data: Uint8Array): void;
  157538. /**
  157539. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  157540. * @returns data the Uint8Array that can be saved and reused
  157541. */
  157542. getNavmeshData(): Uint8Array;
  157543. /**
  157544. * Get the Bounding box extent result specified by setDefaultQueryExtent
  157545. * @param result output the box extent values
  157546. */
  157547. getDefaultQueryExtentToRef(result: Vector3): void;
  157548. /**
  157549. * Disposes
  157550. */
  157551. dispose(): void;
  157552. /**
  157553. * If this plugin is supported
  157554. * @returns true if plugin is supported
  157555. */
  157556. isSupported(): boolean;
  157557. }
  157558. /**
  157559. * Recast detour crowd implementation
  157560. */
  157561. export class RecastJSCrowd implements ICrowd {
  157562. /**
  157563. * Recast/detour plugin
  157564. */
  157565. bjsRECASTPlugin: RecastJSPlugin;
  157566. /**
  157567. * Link to the detour crowd
  157568. */
  157569. recastCrowd: any;
  157570. /**
  157571. * One transform per agent
  157572. */
  157573. transforms: TransformNode[];
  157574. /**
  157575. * All agents created
  157576. */
  157577. agents: number[];
  157578. /**
  157579. * Link to the scene is kept to unregister the crowd from the scene
  157580. */
  157581. private _scene;
  157582. /**
  157583. * Observer for crowd updates
  157584. */
  157585. private _onBeforeAnimationsObserver;
  157586. /**
  157587. * Constructor
  157588. * @param plugin recastJS plugin
  157589. * @param maxAgents the maximum agent count in the crowd
  157590. * @param maxAgentRadius the maximum radius an agent can have
  157591. * @param scene to attach the crowd to
  157592. * @returns the crowd you can add agents to
  157593. */
  157594. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  157595. /**
  157596. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  157597. * You can attach anything to that node. The node position is updated in the scene update tick.
  157598. * @param pos world position that will be constrained by the navigation mesh
  157599. * @param parameters agent parameters
  157600. * @param transform hooked to the agent that will be update by the scene
  157601. * @returns agent index
  157602. */
  157603. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  157604. /**
  157605. * Returns the agent position in world space
  157606. * @param index agent index returned by addAgent
  157607. * @returns world space position
  157608. */
  157609. getAgentPosition(index: number): Vector3;
  157610. /**
  157611. * Returns the agent position result in world space
  157612. * @param index agent index returned by addAgent
  157613. * @param result output world space position
  157614. */
  157615. getAgentPositionToRef(index: number, result: Vector3): void;
  157616. /**
  157617. * Returns the agent velocity in world space
  157618. * @param index agent index returned by addAgent
  157619. * @returns world space velocity
  157620. */
  157621. getAgentVelocity(index: number): Vector3;
  157622. /**
  157623. * Returns the agent velocity result in world space
  157624. * @param index agent index returned by addAgent
  157625. * @param result output world space velocity
  157626. */
  157627. getAgentVelocityToRef(index: number, result: Vector3): void;
  157628. /**
  157629. * Returns the agent next target point on the path
  157630. * @param index agent index returned by addAgent
  157631. * @returns world space position
  157632. */
  157633. getAgentNextTargetPath(index: number): Vector3;
  157634. /**
  157635. * Returns the agent next target point on the path
  157636. * @param index agent index returned by addAgent
  157637. * @param result output world space position
  157638. */
  157639. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  157640. /**
  157641. * Gets the agent state
  157642. * @param index agent index returned by addAgent
  157643. * @returns agent state
  157644. */
  157645. getAgentState(index: number): number;
  157646. /**
  157647. * returns true if the agent in over an off mesh link connection
  157648. * @param index agent index returned by addAgent
  157649. * @returns true if over an off mesh link connection
  157650. */
  157651. overOffmeshConnection(index: number): boolean;
  157652. /**
  157653. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  157654. * @param index agent index returned by addAgent
  157655. * @param destination targeted world position
  157656. */
  157657. agentGoto(index: number, destination: Vector3): void;
  157658. /**
  157659. * Teleport the agent to a new position
  157660. * @param index agent index returned by addAgent
  157661. * @param destination targeted world position
  157662. */
  157663. agentTeleport(index: number, destination: Vector3): void;
  157664. /**
  157665. * Update agent parameters
  157666. * @param index agent index returned by addAgent
  157667. * @param parameters agent parameters
  157668. */
  157669. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  157670. /**
  157671. * remove a particular agent previously created
  157672. * @param index agent index returned by addAgent
  157673. */
  157674. removeAgent(index: number): void;
  157675. /**
  157676. * get the list of all agents attached to this crowd
  157677. * @returns list of agent indices
  157678. */
  157679. getAgents(): number[];
  157680. /**
  157681. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  157682. * @param deltaTime in seconds
  157683. */
  157684. update(deltaTime: number): void;
  157685. /**
  157686. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  157687. * The queries will try to find a solution within those bounds
  157688. * default is (1,1,1)
  157689. * @param extent x,y,z value that define the extent around the queries point of reference
  157690. */
  157691. setDefaultQueryExtent(extent: Vector3): void;
  157692. /**
  157693. * Get the Bounding box extent specified by setDefaultQueryExtent
  157694. * @returns the box extent values
  157695. */
  157696. getDefaultQueryExtent(): Vector3;
  157697. /**
  157698. * Get the Bounding box extent result specified by setDefaultQueryExtent
  157699. * @param result output the box extent values
  157700. */
  157701. getDefaultQueryExtentToRef(result: Vector3): void;
  157702. /**
  157703. * Release all resources
  157704. */
  157705. dispose(): void;
  157706. }
  157707. }
  157708. declare module BABYLON {
  157709. /**
  157710. * Class used to enable access to IndexedDB
  157711. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  157712. */
  157713. export class Database implements IOfflineProvider {
  157714. private _callbackManifestChecked;
  157715. private _currentSceneUrl;
  157716. private _db;
  157717. private _enableSceneOffline;
  157718. private _enableTexturesOffline;
  157719. private _manifestVersionFound;
  157720. private _mustUpdateRessources;
  157721. private _hasReachedQuota;
  157722. private _isSupported;
  157723. private _idbFactory;
  157724. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  157725. private static IsUASupportingBlobStorage;
  157726. /**
  157727. * Gets a boolean indicating if Database storage is enabled (off by default)
  157728. */
  157729. static IDBStorageEnabled: boolean;
  157730. /**
  157731. * Gets a boolean indicating if scene must be saved in the database
  157732. */
  157733. get enableSceneOffline(): boolean;
  157734. /**
  157735. * Gets a boolean indicating if textures must be saved in the database
  157736. */
  157737. get enableTexturesOffline(): boolean;
  157738. /**
  157739. * Creates a new Database
  157740. * @param urlToScene defines the url to load the scene
  157741. * @param callbackManifestChecked defines the callback to use when manifest is checked
  157742. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  157743. */
  157744. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  157745. private static _ParseURL;
  157746. private static _ReturnFullUrlLocation;
  157747. private _checkManifestFile;
  157748. /**
  157749. * Open the database and make it available
  157750. * @param successCallback defines the callback to call on success
  157751. * @param errorCallback defines the callback to call on error
  157752. */
  157753. open(successCallback: () => void, errorCallback: () => void): void;
  157754. /**
  157755. * Loads an image from the database
  157756. * @param url defines the url to load from
  157757. * @param image defines the target DOM image
  157758. */
  157759. loadImage(url: string, image: HTMLImageElement): void;
  157760. private _loadImageFromDBAsync;
  157761. private _saveImageIntoDBAsync;
  157762. private _checkVersionFromDB;
  157763. private _loadVersionFromDBAsync;
  157764. private _saveVersionIntoDBAsync;
  157765. /**
  157766. * Loads a file from database
  157767. * @param url defines the URL to load from
  157768. * @param sceneLoaded defines a callback to call on success
  157769. * @param progressCallBack defines a callback to call when progress changed
  157770. * @param errorCallback defines a callback to call on error
  157771. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  157772. */
  157773. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  157774. private _loadFileAsync;
  157775. private _saveFileAsync;
  157776. /**
  157777. * Validates if xhr data is correct
  157778. * @param xhr defines the request to validate
  157779. * @param dataType defines the expected data type
  157780. * @returns true if data is correct
  157781. */
  157782. private static _ValidateXHRData;
  157783. }
  157784. }
  157785. declare module BABYLON {
  157786. /** @hidden */
  157787. export var gpuUpdateParticlesPixelShader: {
  157788. name: string;
  157789. shader: string;
  157790. };
  157791. }
  157792. declare module BABYLON {
  157793. /** @hidden */
  157794. export var gpuUpdateParticlesVertexShader: {
  157795. name: string;
  157796. shader: string;
  157797. };
  157798. }
  157799. declare module BABYLON {
  157800. /** @hidden */
  157801. export var clipPlaneFragmentDeclaration2: {
  157802. name: string;
  157803. shader: string;
  157804. };
  157805. }
  157806. declare module BABYLON {
  157807. /** @hidden */
  157808. export var gpuRenderParticlesPixelShader: {
  157809. name: string;
  157810. shader: string;
  157811. };
  157812. }
  157813. declare module BABYLON {
  157814. /** @hidden */
  157815. export var clipPlaneVertexDeclaration2: {
  157816. name: string;
  157817. shader: string;
  157818. };
  157819. }
  157820. declare module BABYLON {
  157821. /** @hidden */
  157822. export var gpuRenderParticlesVertexShader: {
  157823. name: string;
  157824. shader: string;
  157825. };
  157826. }
  157827. declare module BABYLON {
  157828. /**
  157829. * This represents a GPU particle system in Babylon
  157830. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  157831. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  157832. */
  157833. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  157834. /**
  157835. * The layer mask we are rendering the particles through.
  157836. */
  157837. layerMask: number;
  157838. private _capacity;
  157839. private _activeCount;
  157840. private _currentActiveCount;
  157841. private _accumulatedCount;
  157842. private _renderEffect;
  157843. private _updateEffect;
  157844. private _buffer0;
  157845. private _buffer1;
  157846. private _spriteBuffer;
  157847. private _updateVAO;
  157848. private _renderVAO;
  157849. private _targetIndex;
  157850. private _sourceBuffer;
  157851. private _targetBuffer;
  157852. private _currentRenderId;
  157853. private _started;
  157854. private _stopped;
  157855. private _timeDelta;
  157856. private _randomTexture;
  157857. private _randomTexture2;
  157858. private _attributesStrideSize;
  157859. private _updateEffectOptions;
  157860. private _randomTextureSize;
  157861. private _actualFrame;
  157862. private _customEffect;
  157863. private readonly _rawTextureWidth;
  157864. /**
  157865. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  157866. */
  157867. static get IsSupported(): boolean;
  157868. /**
  157869. * An event triggered when the system is disposed.
  157870. */
  157871. onDisposeObservable: Observable<IParticleSystem>;
  157872. /**
  157873. * An event triggered when the system is stopped
  157874. */
  157875. onStoppedObservable: Observable<IParticleSystem>;
  157876. /**
  157877. * Gets the maximum number of particles active at the same time.
  157878. * @returns The max number of active particles.
  157879. */
  157880. getCapacity(): number;
  157881. /**
  157882. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  157883. * to override the particles.
  157884. */
  157885. forceDepthWrite: boolean;
  157886. /**
  157887. * Gets or set the number of active particles
  157888. */
  157889. get activeParticleCount(): number;
  157890. set activeParticleCount(value: number);
  157891. private _preWarmDone;
  157892. /**
  157893. * Specifies if the particles are updated in emitter local space or world space.
  157894. */
  157895. isLocal: boolean;
  157896. /** Gets or sets a matrix to use to compute projection */
  157897. defaultProjectionMatrix: Matrix;
  157898. /**
  157899. * Is this system ready to be used/rendered
  157900. * @return true if the system is ready
  157901. */
  157902. isReady(): boolean;
  157903. /**
  157904. * Gets if the system has been started. (Note: this will still be true after stop is called)
  157905. * @returns True if it has been started, otherwise false.
  157906. */
  157907. isStarted(): boolean;
  157908. /**
  157909. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  157910. * @returns True if it has been stopped, otherwise false.
  157911. */
  157912. isStopped(): boolean;
  157913. /**
  157914. * Gets a boolean indicating that the system is stopping
  157915. * @returns true if the system is currently stopping
  157916. */
  157917. isStopping(): boolean;
  157918. /**
  157919. * Gets the number of particles active at the same time.
  157920. * @returns The number of active particles.
  157921. */
  157922. getActiveCount(): number;
  157923. /**
  157924. * Starts the particle system and begins to emit
  157925. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  157926. */
  157927. start(delay?: number): void;
  157928. /**
  157929. * Stops the particle system.
  157930. */
  157931. stop(): void;
  157932. /**
  157933. * Remove all active particles
  157934. */
  157935. reset(): void;
  157936. /**
  157937. * Returns the string "GPUParticleSystem"
  157938. * @returns a string containing the class name
  157939. */
  157940. getClassName(): string;
  157941. /**
  157942. * Gets the custom effect used to render the particles
  157943. * @param blendMode Blend mode for which the effect should be retrieved
  157944. * @returns The effect
  157945. */
  157946. getCustomEffect(blendMode?: number): Nullable<Effect>;
  157947. /**
  157948. * Sets the custom effect used to render the particles
  157949. * @param effect The effect to set
  157950. * @param blendMode Blend mode for which the effect should be set
  157951. */
  157952. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  157953. /** @hidden */
  157954. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  157955. /**
  157956. * Observable that will be called just before the particles are drawn
  157957. */
  157958. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  157959. /**
  157960. * Gets the name of the particle vertex shader
  157961. */
  157962. get vertexShaderName(): string;
  157963. private _colorGradientsTexture;
  157964. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  157965. /**
  157966. * Adds a new color gradient
  157967. * @param gradient defines the gradient to use (between 0 and 1)
  157968. * @param color1 defines the color to affect to the specified gradient
  157969. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  157970. * @returns the current particle system
  157971. */
  157972. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  157973. private _refreshColorGradient;
  157974. /** Force the system to rebuild all gradients that need to be resync */
  157975. forceRefreshGradients(): void;
  157976. /**
  157977. * Remove a specific color gradient
  157978. * @param gradient defines the gradient to remove
  157979. * @returns the current particle system
  157980. */
  157981. removeColorGradient(gradient: number): GPUParticleSystem;
  157982. private _angularSpeedGradientsTexture;
  157983. private _sizeGradientsTexture;
  157984. private _velocityGradientsTexture;
  157985. private _limitVelocityGradientsTexture;
  157986. private _dragGradientsTexture;
  157987. private _addFactorGradient;
  157988. /**
  157989. * Adds a new size gradient
  157990. * @param gradient defines the gradient to use (between 0 and 1)
  157991. * @param factor defines the size factor to affect to the specified gradient
  157992. * @returns the current particle system
  157993. */
  157994. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  157995. /**
  157996. * Remove a specific size gradient
  157997. * @param gradient defines the gradient to remove
  157998. * @returns the current particle system
  157999. */
  158000. removeSizeGradient(gradient: number): GPUParticleSystem;
  158001. private _refreshFactorGradient;
  158002. /**
  158003. * Adds a new angular speed gradient
  158004. * @param gradient defines the gradient to use (between 0 and 1)
  158005. * @param factor defines the angular speed to affect to the specified gradient
  158006. * @returns the current particle system
  158007. */
  158008. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  158009. /**
  158010. * Remove a specific angular speed gradient
  158011. * @param gradient defines the gradient to remove
  158012. * @returns the current particle system
  158013. */
  158014. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  158015. /**
  158016. * Adds a new velocity gradient
  158017. * @param gradient defines the gradient to use (between 0 and 1)
  158018. * @param factor defines the velocity to affect to the specified gradient
  158019. * @returns the current particle system
  158020. */
  158021. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  158022. /**
  158023. * Remove a specific velocity gradient
  158024. * @param gradient defines the gradient to remove
  158025. * @returns the current particle system
  158026. */
  158027. removeVelocityGradient(gradient: number): GPUParticleSystem;
  158028. /**
  158029. * Adds a new limit velocity gradient
  158030. * @param gradient defines the gradient to use (between 0 and 1)
  158031. * @param factor defines the limit velocity value to affect to the specified gradient
  158032. * @returns the current particle system
  158033. */
  158034. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  158035. /**
  158036. * Remove a specific limit velocity gradient
  158037. * @param gradient defines the gradient to remove
  158038. * @returns the current particle system
  158039. */
  158040. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  158041. /**
  158042. * Adds a new drag gradient
  158043. * @param gradient defines the gradient to use (between 0 and 1)
  158044. * @param factor defines the drag value to affect to the specified gradient
  158045. * @returns the current particle system
  158046. */
  158047. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  158048. /**
  158049. * Remove a specific drag gradient
  158050. * @param gradient defines the gradient to remove
  158051. * @returns the current particle system
  158052. */
  158053. removeDragGradient(gradient: number): GPUParticleSystem;
  158054. /**
  158055. * Not supported by GPUParticleSystem
  158056. * @param gradient defines the gradient to use (between 0 and 1)
  158057. * @param factor defines the emit rate value to affect to the specified gradient
  158058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  158059. * @returns the current particle system
  158060. */
  158061. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  158062. /**
  158063. * Not supported by GPUParticleSystem
  158064. * @param gradient defines the gradient to remove
  158065. * @returns the current particle system
  158066. */
  158067. removeEmitRateGradient(gradient: number): IParticleSystem;
  158068. /**
  158069. * Not supported by GPUParticleSystem
  158070. * @param gradient defines the gradient to use (between 0 and 1)
  158071. * @param factor defines the start size value to affect to the specified gradient
  158072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  158073. * @returns the current particle system
  158074. */
  158075. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  158076. /**
  158077. * Not supported by GPUParticleSystem
  158078. * @param gradient defines the gradient to remove
  158079. * @returns the current particle system
  158080. */
  158081. removeStartSizeGradient(gradient: number): IParticleSystem;
  158082. /**
  158083. * Not supported by GPUParticleSystem
  158084. * @param gradient defines the gradient to use (between 0 and 1)
  158085. * @param min defines the color remap minimal range
  158086. * @param max defines the color remap maximal range
  158087. * @returns the current particle system
  158088. */
  158089. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  158090. /**
  158091. * Not supported by GPUParticleSystem
  158092. * @param gradient defines the gradient to remove
  158093. * @returns the current particle system
  158094. */
  158095. removeColorRemapGradient(): IParticleSystem;
  158096. /**
  158097. * Not supported by GPUParticleSystem
  158098. * @param gradient defines the gradient to use (between 0 and 1)
  158099. * @param min defines the alpha remap minimal range
  158100. * @param max defines the alpha remap maximal range
  158101. * @returns the current particle system
  158102. */
  158103. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  158104. /**
  158105. * Not supported by GPUParticleSystem
  158106. * @param gradient defines the gradient to remove
  158107. * @returns the current particle system
  158108. */
  158109. removeAlphaRemapGradient(): IParticleSystem;
  158110. /**
  158111. * Not supported by GPUParticleSystem
  158112. * @param gradient defines the gradient to use (between 0 and 1)
  158113. * @param color defines the color to affect to the specified gradient
  158114. * @returns the current particle system
  158115. */
  158116. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  158117. /**
  158118. * Not supported by GPUParticleSystem
  158119. * @param gradient defines the gradient to remove
  158120. * @returns the current particle system
  158121. */
  158122. removeRampGradient(): IParticleSystem;
  158123. /**
  158124. * Not supported by GPUParticleSystem
  158125. * @returns the list of ramp gradients
  158126. */
  158127. getRampGradients(): Nullable<Array<Color3Gradient>>;
  158128. /**
  158129. * Not supported by GPUParticleSystem
  158130. * Gets or sets a boolean indicating that ramp gradients must be used
  158131. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  158132. */
  158133. get useRampGradients(): boolean;
  158134. set useRampGradients(value: boolean);
  158135. /**
  158136. * Not supported by GPUParticleSystem
  158137. * @param gradient defines the gradient to use (between 0 and 1)
  158138. * @param factor defines the life time factor to affect to the specified gradient
  158139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  158140. * @returns the current particle system
  158141. */
  158142. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  158143. /**
  158144. * Not supported by GPUParticleSystem
  158145. * @param gradient defines the gradient to remove
  158146. * @returns the current particle system
  158147. */
  158148. removeLifeTimeGradient(gradient: number): IParticleSystem;
  158149. /**
  158150. * Instantiates a GPU particle system.
  158151. * 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.
  158152. * @param name The name of the particle system
  158153. * @param options The options used to create the system
  158154. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  158155. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  158156. * @param customEffect a custom effect used to change the way particles are rendered by default
  158157. */
  158158. constructor(name: string, options: Partial<{
  158159. capacity: number;
  158160. randomTextureSize: number;
  158161. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  158162. protected _reset(): void;
  158163. private _createUpdateVAO;
  158164. private _createRenderVAO;
  158165. private _initialize;
  158166. /** @hidden */
  158167. _recreateUpdateEffect(): void;
  158168. private _getEffect;
  158169. /**
  158170. * Fill the defines array according to the current settings of the particle system
  158171. * @param defines Array to be updated
  158172. * @param blendMode blend mode to take into account when updating the array
  158173. */
  158174. fillDefines(defines: Array<string>, blendMode?: number): void;
  158175. /**
  158176. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  158177. * @param uniforms Uniforms array to fill
  158178. * @param attributes Attributes array to fill
  158179. * @param samplers Samplers array to fill
  158180. */
  158181. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  158182. /** @hidden */
  158183. _recreateRenderEffect(): Effect;
  158184. /**
  158185. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  158186. * @param preWarm defines if we are in the pre-warmimg phase
  158187. */
  158188. animate(preWarm?: boolean): void;
  158189. private _createFactorGradientTexture;
  158190. private _createSizeGradientTexture;
  158191. private _createAngularSpeedGradientTexture;
  158192. private _createVelocityGradientTexture;
  158193. private _createLimitVelocityGradientTexture;
  158194. private _createDragGradientTexture;
  158195. private _createColorGradientTexture;
  158196. /**
  158197. * Renders the particle system in its current state
  158198. * @param preWarm defines if the system should only update the particles but not render them
  158199. * @returns the current number of particles
  158200. */
  158201. render(preWarm?: boolean): number;
  158202. /**
  158203. * Rebuilds the particle system
  158204. */
  158205. rebuild(): void;
  158206. private _releaseBuffers;
  158207. private _releaseVAOs;
  158208. /**
  158209. * Disposes the particle system and free the associated resources
  158210. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  158211. */
  158212. dispose(disposeTexture?: boolean): void;
  158213. /**
  158214. * Clones the particle system.
  158215. * @param name The name of the cloned object
  158216. * @param newEmitter The new emitter to use
  158217. * @returns the cloned particle system
  158218. */
  158219. clone(name: string, newEmitter: any): GPUParticleSystem;
  158220. /**
  158221. * Serializes the particle system to a JSON object
  158222. * @param serializeTexture defines if the texture must be serialized as well
  158223. * @returns the JSON object
  158224. */
  158225. serialize(serializeTexture?: boolean): any;
  158226. /**
  158227. * Parses a JSON object to create a GPU particle system.
  158228. * @param parsedParticleSystem The JSON object to parse
  158229. * @param sceneOrEngine The scene or the engine to create the particle system in
  158230. * @param rootUrl The root url to use to load external dependencies like texture
  158231. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  158232. * @returns the parsed GPU particle system
  158233. */
  158234. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  158235. }
  158236. }
  158237. declare module BABYLON {
  158238. /**
  158239. * Represents a set of particle systems working together to create a specific effect
  158240. */
  158241. export class ParticleSystemSet implements IDisposable {
  158242. /**
  158243. * Gets or sets base Assets URL
  158244. */
  158245. static BaseAssetsUrl: string;
  158246. private _emitterCreationOptions;
  158247. private _emitterNode;
  158248. /**
  158249. * Gets the particle system list
  158250. */
  158251. systems: IParticleSystem[];
  158252. /**
  158253. * Gets the emitter node used with this set
  158254. */
  158255. get emitterNode(): Nullable<TransformNode>;
  158256. /**
  158257. * Creates a new emitter mesh as a sphere
  158258. * @param options defines the options used to create the sphere
  158259. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  158260. * @param scene defines the hosting scene
  158261. */
  158262. setEmitterAsSphere(options: {
  158263. diameter: number;
  158264. segments: number;
  158265. color: Color3;
  158266. }, renderingGroupId: number, scene: Scene): void;
  158267. /**
  158268. * Starts all particle systems of the set
  158269. * @param emitter defines an optional mesh to use as emitter for the particle systems
  158270. */
  158271. start(emitter?: AbstractMesh): void;
  158272. /**
  158273. * Release all associated resources
  158274. */
  158275. dispose(): void;
  158276. /**
  158277. * Serialize the set into a JSON compatible object
  158278. * @param serializeTexture defines if the texture must be serialized as well
  158279. * @returns a JSON compatible representation of the set
  158280. */
  158281. serialize(serializeTexture?: boolean): any;
  158282. /**
  158283. * Parse a new ParticleSystemSet from a serialized source
  158284. * @param data defines a JSON compatible representation of the set
  158285. * @param scene defines the hosting scene
  158286. * @param gpu defines if we want GPU particles or CPU particles
  158287. * @returns a new ParticleSystemSet
  158288. */
  158289. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  158290. }
  158291. }
  158292. declare module BABYLON {
  158293. /**
  158294. * This class is made for on one-liner static method to help creating particle system set.
  158295. */
  158296. export class ParticleHelper {
  158297. /**
  158298. * Gets or sets base Assets URL
  158299. */
  158300. static BaseAssetsUrl: string;
  158301. /** Define the Url to load snippets */
  158302. static SnippetUrl: string;
  158303. /**
  158304. * Create a default particle system that you can tweak
  158305. * @param emitter defines the emitter to use
  158306. * @param capacity defines the system capacity (default is 500 particles)
  158307. * @param scene defines the hosting scene
  158308. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  158309. * @returns the new Particle system
  158310. */
  158311. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  158312. /**
  158313. * This is the main static method (one-liner) of this helper to create different particle systems
  158314. * @param type This string represents the type to the particle system to create
  158315. * @param scene The scene where the particle system should live
  158316. * @param gpu If the system will use gpu
  158317. * @returns the ParticleSystemSet created
  158318. */
  158319. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  158320. /**
  158321. * Static function used to export a particle system to a ParticleSystemSet variable.
  158322. * Please note that the emitter shape is not exported
  158323. * @param systems defines the particle systems to export
  158324. * @returns the created particle system set
  158325. */
  158326. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  158327. /**
  158328. * Creates a particle system from a snippet saved in a remote file
  158329. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  158330. * @param url defines the url to load from
  158331. * @param scene defines the hosting scene
  158332. * @param gpu If the system will use gpu
  158333. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  158334. * @returns a promise that will resolve to the new particle system
  158335. */
  158336. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  158337. /**
  158338. * Creates a particle system from a snippet saved by the particle system editor
  158339. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  158340. * @param scene defines the hosting scene
  158341. * @param gpu If the system will use gpu
  158342. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  158343. * @returns a promise that will resolve to the new particle system
  158344. */
  158345. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  158346. }
  158347. }
  158348. declare module BABYLON {
  158349. interface Engine {
  158350. /**
  158351. * Create an effect to use with particle systems.
  158352. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  158353. * the particle system for which you want to create a custom effect in the last parameter
  158354. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  158355. * @param uniformsNames defines a list of attribute names
  158356. * @param samplers defines an array of string used to represent textures
  158357. * @param defines defines the string containing the defines to use to compile the shaders
  158358. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  158359. * @param onCompiled defines a function to call when the effect creation is successful
  158360. * @param onError defines a function to call when the effect creation has failed
  158361. * @param particleSystem the particle system you want to create the effect for
  158362. * @returns the new Effect
  158363. */
  158364. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  158365. }
  158366. interface Mesh {
  158367. /**
  158368. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  158369. * @returns an array of IParticleSystem
  158370. */
  158371. getEmittedParticleSystems(): IParticleSystem[];
  158372. /**
  158373. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  158374. * @returns an array of IParticleSystem
  158375. */
  158376. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  158377. }
  158378. }
  158379. declare module BABYLON {
  158380. /** Defines the 4 color options */
  158381. export enum PointColor {
  158382. /** color value */
  158383. Color = 2,
  158384. /** uv value */
  158385. UV = 1,
  158386. /** random value */
  158387. Random = 0,
  158388. /** stated value */
  158389. Stated = 3
  158390. }
  158391. /**
  158392. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  158393. * 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.
  158394. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  158395. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  158396. *
  158397. * Full documentation here : TO BE ENTERED
  158398. */
  158399. export class PointsCloudSystem implements IDisposable {
  158400. /**
  158401. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  158402. * Example : var p = SPS.particles[i];
  158403. */
  158404. particles: CloudPoint[];
  158405. /**
  158406. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  158407. */
  158408. nbParticles: number;
  158409. /**
  158410. * This a counter for your own usage. It's not set by any SPS functions.
  158411. */
  158412. counter: number;
  158413. /**
  158414. * The PCS name. This name is also given to the underlying mesh.
  158415. */
  158416. name: string;
  158417. /**
  158418. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  158419. */
  158420. mesh: Mesh;
  158421. /**
  158422. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  158423. * Please read :
  158424. */
  158425. vars: any;
  158426. /**
  158427. * @hidden
  158428. */
  158429. _size: number;
  158430. private _scene;
  158431. private _promises;
  158432. private _positions;
  158433. private _indices;
  158434. private _normals;
  158435. private _colors;
  158436. private _uvs;
  158437. private _indices32;
  158438. private _positions32;
  158439. private _colors32;
  158440. private _uvs32;
  158441. private _updatable;
  158442. private _isVisibilityBoxLocked;
  158443. private _alwaysVisible;
  158444. private _groups;
  158445. private _groupCounter;
  158446. private _computeParticleColor;
  158447. private _computeParticleTexture;
  158448. private _computeParticleRotation;
  158449. private _computeBoundingBox;
  158450. private _isReady;
  158451. /**
  158452. * Creates a PCS (Points Cloud System) object
  158453. * @param name (String) is the PCS name, this will be the underlying mesh name
  158454. * @param pointSize (number) is the size for each point
  158455. * @param scene (Scene) is the scene in which the PCS is added
  158456. * @param options defines the options of the PCS e.g.
  158457. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  158458. */
  158459. constructor(name: string, pointSize: number, scene: Scene, options?: {
  158460. updatable?: boolean;
  158461. });
  158462. /**
  158463. * Builds the PCS underlying mesh. Returns a standard Mesh.
  158464. * If no points were added to the PCS, the returned mesh is just a single point.
  158465. * @returns a promise for the created mesh
  158466. */
  158467. buildMeshAsync(): Promise<Mesh>;
  158468. /**
  158469. * @hidden
  158470. */
  158471. private _buildMesh;
  158472. private _addParticle;
  158473. private _randomUnitVector;
  158474. private _getColorIndicesForCoord;
  158475. private _setPointsColorOrUV;
  158476. private _colorFromTexture;
  158477. private _calculateDensity;
  158478. /**
  158479. * Adds points to the PCS in random positions within a unit sphere
  158480. * @param nb (positive integer) the number of particles to be created from this model
  158481. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  158482. * @returns the number of groups in the system
  158483. */
  158484. addPoints(nb: number, pointFunction?: any): number;
  158485. /**
  158486. * Adds points to the PCS from the surface of the model shape
  158487. * @param mesh is any Mesh object that will be used as a surface model for the points
  158488. * @param nb (positive integer) the number of particles to be created from this model
  158489. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  158490. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  158491. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  158492. * @returns the number of groups in the system
  158493. */
  158494. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  158495. /**
  158496. * Adds points to the PCS inside the model shape
  158497. * @param mesh is any Mesh object that will be used as a surface model for the points
  158498. * @param nb (positive integer) the number of particles to be created from this model
  158499. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  158500. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  158501. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  158502. * @returns the number of groups in the system
  158503. */
  158504. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  158505. /**
  158506. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  158507. * This method calls `updateParticle()` for each particle of the SPS.
  158508. * For an animated SPS, it is usually called within the render loop.
  158509. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  158510. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  158511. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  158512. * @returns the PCS.
  158513. */
  158514. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  158515. /**
  158516. * Disposes the PCS.
  158517. */
  158518. dispose(): void;
  158519. /**
  158520. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  158521. * doc :
  158522. * @returns the PCS.
  158523. */
  158524. refreshVisibleSize(): PointsCloudSystem;
  158525. /**
  158526. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  158527. * @param size the size (float) of the visibility box
  158528. * note : this doesn't lock the PCS mesh bounding box.
  158529. * doc :
  158530. */
  158531. setVisibilityBox(size: number): void;
  158532. /**
  158533. * Gets whether the PCS is always visible or not
  158534. * doc :
  158535. */
  158536. get isAlwaysVisible(): boolean;
  158537. /**
  158538. * Sets the PCS as always visible or not
  158539. * doc :
  158540. */
  158541. set isAlwaysVisible(val: boolean);
  158542. /**
  158543. * Tells to `setParticles()` to compute the particle rotations or not
  158544. * Default value : false. The PCS is faster when it's set to false
  158545. * Note : particle rotations are only applied to parent particles
  158546. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  158547. */
  158548. set computeParticleRotation(val: boolean);
  158549. /**
  158550. * Tells to `setParticles()` to compute the particle colors or not.
  158551. * Default value : true. The PCS is faster when it's set to false.
  158552. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  158553. */
  158554. set computeParticleColor(val: boolean);
  158555. set computeParticleTexture(val: boolean);
  158556. /**
  158557. * Gets if `setParticles()` computes the particle colors or not.
  158558. * Default value : false. The PCS is faster when it's set to false.
  158559. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  158560. */
  158561. get computeParticleColor(): boolean;
  158562. /**
  158563. * Gets if `setParticles()` computes the particle textures or not.
  158564. * Default value : false. The PCS is faster when it's set to false.
  158565. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  158566. */
  158567. get computeParticleTexture(): boolean;
  158568. /**
  158569. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  158570. */
  158571. set computeBoundingBox(val: boolean);
  158572. /**
  158573. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  158574. */
  158575. get computeBoundingBox(): boolean;
  158576. /**
  158577. * This function does nothing. It may be overwritten to set all the particle first values.
  158578. * The PCS doesn't call this function, you may have to call it by your own.
  158579. * doc :
  158580. */
  158581. initParticles(): void;
  158582. /**
  158583. * This function does nothing. It may be overwritten to recycle a particle
  158584. * The PCS doesn't call this function, you can to call it
  158585. * doc :
  158586. * @param particle The particle to recycle
  158587. * @returns the recycled particle
  158588. */
  158589. recycleParticle(particle: CloudPoint): CloudPoint;
  158590. /**
  158591. * Updates a particle : this function should be overwritten by the user.
  158592. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  158593. * doc :
  158594. * @example : just set a particle position or velocity and recycle conditions
  158595. * @param particle The particle to update
  158596. * @returns the updated particle
  158597. */
  158598. updateParticle(particle: CloudPoint): CloudPoint;
  158599. /**
  158600. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  158601. * This does nothing and may be overwritten by the user.
  158602. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  158603. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  158604. * @param update the boolean update value actually passed to setParticles()
  158605. */
  158606. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  158607. /**
  158608. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  158609. * This will be passed three parameters.
  158610. * This does nothing and may be overwritten by the user.
  158611. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  158612. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  158613. * @param update the boolean update value actually passed to setParticles()
  158614. */
  158615. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  158616. }
  158617. }
  158618. declare module BABYLON {
  158619. /**
  158620. * Represents one particle of a points cloud system.
  158621. */
  158622. export class CloudPoint {
  158623. /**
  158624. * particle global index
  158625. */
  158626. idx: number;
  158627. /**
  158628. * The color of the particle
  158629. */
  158630. color: Nullable<Color4>;
  158631. /**
  158632. * The world space position of the particle.
  158633. */
  158634. position: Vector3;
  158635. /**
  158636. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  158637. */
  158638. rotation: Vector3;
  158639. /**
  158640. * The world space rotation quaternion of the particle.
  158641. */
  158642. rotationQuaternion: Nullable<Quaternion>;
  158643. /**
  158644. * The uv of the particle.
  158645. */
  158646. uv: Nullable<Vector2>;
  158647. /**
  158648. * The current speed of the particle.
  158649. */
  158650. velocity: Vector3;
  158651. /**
  158652. * The pivot point in the particle local space.
  158653. */
  158654. pivot: Vector3;
  158655. /**
  158656. * Must the particle be translated from its pivot point in its local space ?
  158657. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  158658. * Default : false
  158659. */
  158660. translateFromPivot: boolean;
  158661. /**
  158662. * Index of this particle in the global "positions" array (Internal use)
  158663. * @hidden
  158664. */
  158665. _pos: number;
  158666. /**
  158667. * @hidden Index of this particle in the global "indices" array (Internal use)
  158668. */
  158669. _ind: number;
  158670. /**
  158671. * Group this particle belongs to
  158672. */
  158673. _group: PointsGroup;
  158674. /**
  158675. * Group id of this particle
  158676. */
  158677. groupId: number;
  158678. /**
  158679. * Index of the particle in its group id (Internal use)
  158680. */
  158681. idxInGroup: number;
  158682. /**
  158683. * @hidden Particle BoundingInfo object (Internal use)
  158684. */
  158685. _boundingInfo: BoundingInfo;
  158686. /**
  158687. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  158688. */
  158689. _pcs: PointsCloudSystem;
  158690. /**
  158691. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  158692. */
  158693. _stillInvisible: boolean;
  158694. /**
  158695. * @hidden Last computed particle rotation matrix
  158696. */
  158697. _rotationMatrix: number[];
  158698. /**
  158699. * Parent particle Id, if any.
  158700. * Default null.
  158701. */
  158702. parentId: Nullable<number>;
  158703. /**
  158704. * @hidden Internal global position in the PCS.
  158705. */
  158706. _globalPosition: Vector3;
  158707. /**
  158708. * Creates a Point Cloud object.
  158709. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  158710. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  158711. * @param group (PointsGroup) is the group the particle belongs to
  158712. * @param groupId (integer) is the group identifier in the PCS.
  158713. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  158714. * @param pcs defines the PCS it is associated to
  158715. */
  158716. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  158717. /**
  158718. * get point size
  158719. */
  158720. get size(): Vector3;
  158721. /**
  158722. * Set point size
  158723. */
  158724. set size(scale: Vector3);
  158725. /**
  158726. * Legacy support, changed quaternion to rotationQuaternion
  158727. */
  158728. get quaternion(): Nullable<Quaternion>;
  158729. /**
  158730. * Legacy support, changed quaternion to rotationQuaternion
  158731. */
  158732. set quaternion(q: Nullable<Quaternion>);
  158733. /**
  158734. * Returns a boolean. True if the particle intersects a mesh, else false
  158735. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  158736. * @param target is the object (point or mesh) what the intersection is computed against
  158737. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  158738. * @returns true if it intersects
  158739. */
  158740. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  158741. /**
  158742. * get the rotation matrix of the particle
  158743. * @hidden
  158744. */
  158745. getRotationMatrix(m: Matrix): void;
  158746. }
  158747. /**
  158748. * Represents a group of points in a points cloud system
  158749. * * PCS internal tool, don't use it manually.
  158750. */
  158751. export class PointsGroup {
  158752. /**
  158753. * The group id
  158754. * @hidden
  158755. */
  158756. groupID: number;
  158757. /**
  158758. * image data for group (internal use)
  158759. * @hidden
  158760. */
  158761. _groupImageData: Nullable<ArrayBufferView>;
  158762. /**
  158763. * Image Width (internal use)
  158764. * @hidden
  158765. */
  158766. _groupImgWidth: number;
  158767. /**
  158768. * Image Height (internal use)
  158769. * @hidden
  158770. */
  158771. _groupImgHeight: number;
  158772. /**
  158773. * Custom position function (internal use)
  158774. * @hidden
  158775. */
  158776. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  158777. /**
  158778. * density per facet for surface points
  158779. * @hidden
  158780. */
  158781. _groupDensity: number[];
  158782. /**
  158783. * Only when points are colored by texture carries pointer to texture list array
  158784. * @hidden
  158785. */
  158786. _textureNb: number;
  158787. /**
  158788. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  158789. * PCS internal tool, don't use it manually.
  158790. * @hidden
  158791. */
  158792. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  158793. }
  158794. }
  158795. declare module BABYLON {
  158796. interface Scene {
  158797. /** @hidden (Backing field) */
  158798. _physicsEngine: Nullable<IPhysicsEngine>;
  158799. /** @hidden */
  158800. _physicsTimeAccumulator: number;
  158801. /**
  158802. * Gets the current physics engine
  158803. * @returns a IPhysicsEngine or null if none attached
  158804. */
  158805. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  158806. /**
  158807. * Enables physics to the current scene
  158808. * @param gravity defines the scene's gravity for the physics engine
  158809. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  158810. * @return a boolean indicating if the physics engine was initialized
  158811. */
  158812. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  158813. /**
  158814. * Disables and disposes the physics engine associated with the scene
  158815. */
  158816. disablePhysicsEngine(): void;
  158817. /**
  158818. * Gets a boolean indicating if there is an active physics engine
  158819. * @returns a boolean indicating if there is an active physics engine
  158820. */
  158821. isPhysicsEnabled(): boolean;
  158822. /**
  158823. * Deletes a physics compound impostor
  158824. * @param compound defines the compound to delete
  158825. */
  158826. deleteCompoundImpostor(compound: any): void;
  158827. /**
  158828. * An event triggered when physic simulation is about to be run
  158829. */
  158830. onBeforePhysicsObservable: Observable<Scene>;
  158831. /**
  158832. * An event triggered when physic simulation has been done
  158833. */
  158834. onAfterPhysicsObservable: Observable<Scene>;
  158835. }
  158836. interface AbstractMesh {
  158837. /** @hidden */
  158838. _physicsImpostor: Nullable<PhysicsImpostor>;
  158839. /**
  158840. * Gets or sets impostor used for physic simulation
  158841. * @see https://doc.babylonjs.com/features/physics_engine
  158842. */
  158843. physicsImpostor: Nullable<PhysicsImpostor>;
  158844. /**
  158845. * Gets the current physics impostor
  158846. * @see https://doc.babylonjs.com/features/physics_engine
  158847. * @returns a physics impostor or null
  158848. */
  158849. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  158850. /** Apply a physic impulse to the mesh
  158851. * @param force defines the force to apply
  158852. * @param contactPoint defines where to apply the force
  158853. * @returns the current mesh
  158854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  158855. */
  158856. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  158857. /**
  158858. * Creates a physic joint between two meshes
  158859. * @param otherMesh defines the other mesh to use
  158860. * @param pivot1 defines the pivot to use on this mesh
  158861. * @param pivot2 defines the pivot to use on the other mesh
  158862. * @param options defines additional options (can be plugin dependent)
  158863. * @returns the current mesh
  158864. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  158865. */
  158866. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  158867. /** @hidden */
  158868. _disposePhysicsObserver: Nullable<Observer<Node>>;
  158869. }
  158870. /**
  158871. * Defines the physics engine scene component responsible to manage a physics engine
  158872. */
  158873. export class PhysicsEngineSceneComponent implements ISceneComponent {
  158874. /**
  158875. * The component name helpful to identify the component in the list of scene components.
  158876. */
  158877. readonly name: string;
  158878. /**
  158879. * The scene the component belongs to.
  158880. */
  158881. scene: Scene;
  158882. /**
  158883. * Creates a new instance of the component for the given scene
  158884. * @param scene Defines the scene to register the component in
  158885. */
  158886. constructor(scene: Scene);
  158887. /**
  158888. * Registers the component in a given scene
  158889. */
  158890. register(): void;
  158891. /**
  158892. * Rebuilds the elements related to this component in case of
  158893. * context lost for instance.
  158894. */
  158895. rebuild(): void;
  158896. /**
  158897. * Disposes the component and the associated resources
  158898. */
  158899. dispose(): void;
  158900. }
  158901. }
  158902. declare module BABYLON {
  158903. /**
  158904. * A helper for physics simulations
  158905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  158906. */
  158907. export class PhysicsHelper {
  158908. private _scene;
  158909. private _physicsEngine;
  158910. /**
  158911. * Initializes the Physics helper
  158912. * @param scene Babylon.js scene
  158913. */
  158914. constructor(scene: Scene);
  158915. /**
  158916. * Applies a radial explosion impulse
  158917. * @param origin the origin of the explosion
  158918. * @param radiusOrEventOptions the radius or the options of radial explosion
  158919. * @param strength the explosion strength
  158920. * @param falloff possible options: Constant & Linear. Defaults to Constant
  158921. * @returns A physics radial explosion event, or null
  158922. */
  158923. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  158924. /**
  158925. * Applies a radial explosion force
  158926. * @param origin the origin of the explosion
  158927. * @param radiusOrEventOptions the radius or the options of radial explosion
  158928. * @param strength the explosion strength
  158929. * @param falloff possible options: Constant & Linear. Defaults to Constant
  158930. * @returns A physics radial explosion event, or null
  158931. */
  158932. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  158933. /**
  158934. * Creates a gravitational field
  158935. * @param origin the origin of the explosion
  158936. * @param radiusOrEventOptions the radius or the options of radial explosion
  158937. * @param strength the explosion strength
  158938. * @param falloff possible options: Constant & Linear. Defaults to Constant
  158939. * @returns A physics gravitational field event, or null
  158940. */
  158941. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  158942. /**
  158943. * Creates a physics updraft event
  158944. * @param origin the origin of the updraft
  158945. * @param radiusOrEventOptions the radius or the options of the updraft
  158946. * @param strength the strength of the updraft
  158947. * @param height the height of the updraft
  158948. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  158949. * @returns A physics updraft event, or null
  158950. */
  158951. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  158952. /**
  158953. * Creates a physics vortex event
  158954. * @param origin the of the vortex
  158955. * @param radiusOrEventOptions the radius or the options of the vortex
  158956. * @param strength the strength of the vortex
  158957. * @param height the height of the vortex
  158958. * @returns a Physics vortex event, or null
  158959. * A physics vortex event or null
  158960. */
  158961. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  158962. }
  158963. /**
  158964. * Represents a physics radial explosion event
  158965. */
  158966. class PhysicsRadialExplosionEvent {
  158967. private _scene;
  158968. private _options;
  158969. private _sphere;
  158970. private _dataFetched;
  158971. /**
  158972. * Initializes a radial explosion event
  158973. * @param _scene BabylonJS scene
  158974. * @param _options The options for the vortex event
  158975. */
  158976. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  158977. /**
  158978. * Returns the data related to the radial explosion event (sphere).
  158979. * @returns The radial explosion event data
  158980. */
  158981. getData(): PhysicsRadialExplosionEventData;
  158982. /**
  158983. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  158984. * @param impostor A physics imposter
  158985. * @param origin the origin of the explosion
  158986. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  158987. */
  158988. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  158989. /**
  158990. * Triggers affected impostors callbacks
  158991. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  158992. */
  158993. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  158994. /**
  158995. * Disposes the sphere.
  158996. * @param force Specifies if the sphere should be disposed by force
  158997. */
  158998. dispose(force?: boolean): void;
  158999. /*** Helpers ***/
  159000. private _prepareSphere;
  159001. private _intersectsWithSphere;
  159002. }
  159003. /**
  159004. * Represents a gravitational field event
  159005. */
  159006. class PhysicsGravitationalFieldEvent {
  159007. private _physicsHelper;
  159008. private _scene;
  159009. private _origin;
  159010. private _options;
  159011. private _tickCallback;
  159012. private _sphere;
  159013. private _dataFetched;
  159014. /**
  159015. * Initializes the physics gravitational field event
  159016. * @param _physicsHelper A physics helper
  159017. * @param _scene BabylonJS scene
  159018. * @param _origin The origin position of the gravitational field event
  159019. * @param _options The options for the vortex event
  159020. */
  159021. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  159022. /**
  159023. * Returns the data related to the gravitational field event (sphere).
  159024. * @returns A gravitational field event
  159025. */
  159026. getData(): PhysicsGravitationalFieldEventData;
  159027. /**
  159028. * Enables the gravitational field.
  159029. */
  159030. enable(): void;
  159031. /**
  159032. * Disables the gravitational field.
  159033. */
  159034. disable(): void;
  159035. /**
  159036. * Disposes the sphere.
  159037. * @param force The force to dispose from the gravitational field event
  159038. */
  159039. dispose(force?: boolean): void;
  159040. private _tick;
  159041. }
  159042. /**
  159043. * Represents a physics updraft event
  159044. */
  159045. class PhysicsUpdraftEvent {
  159046. private _scene;
  159047. private _origin;
  159048. private _options;
  159049. private _physicsEngine;
  159050. private _originTop;
  159051. private _originDirection;
  159052. private _tickCallback;
  159053. private _cylinder;
  159054. private _cylinderPosition;
  159055. private _dataFetched;
  159056. /**
  159057. * Initializes the physics updraft event
  159058. * @param _scene BabylonJS scene
  159059. * @param _origin The origin position of the updraft
  159060. * @param _options The options for the updraft event
  159061. */
  159062. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  159063. /**
  159064. * Returns the data related to the updraft event (cylinder).
  159065. * @returns A physics updraft event
  159066. */
  159067. getData(): PhysicsUpdraftEventData;
  159068. /**
  159069. * Enables the updraft.
  159070. */
  159071. enable(): void;
  159072. /**
  159073. * Disables the updraft.
  159074. */
  159075. disable(): void;
  159076. /**
  159077. * Disposes the cylinder.
  159078. * @param force Specifies if the updraft should be disposed by force
  159079. */
  159080. dispose(force?: boolean): void;
  159081. private getImpostorHitData;
  159082. private _tick;
  159083. /*** Helpers ***/
  159084. private _prepareCylinder;
  159085. private _intersectsWithCylinder;
  159086. }
  159087. /**
  159088. * Represents a physics vortex event
  159089. */
  159090. class PhysicsVortexEvent {
  159091. private _scene;
  159092. private _origin;
  159093. private _options;
  159094. private _physicsEngine;
  159095. private _originTop;
  159096. private _tickCallback;
  159097. private _cylinder;
  159098. private _cylinderPosition;
  159099. private _dataFetched;
  159100. /**
  159101. * Initializes the physics vortex event
  159102. * @param _scene The BabylonJS scene
  159103. * @param _origin The origin position of the vortex
  159104. * @param _options The options for the vortex event
  159105. */
  159106. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  159107. /**
  159108. * Returns the data related to the vortex event (cylinder).
  159109. * @returns The physics vortex event data
  159110. */
  159111. getData(): PhysicsVortexEventData;
  159112. /**
  159113. * Enables the vortex.
  159114. */
  159115. enable(): void;
  159116. /**
  159117. * Disables the cortex.
  159118. */
  159119. disable(): void;
  159120. /**
  159121. * Disposes the sphere.
  159122. * @param force
  159123. */
  159124. dispose(force?: boolean): void;
  159125. private getImpostorHitData;
  159126. private _tick;
  159127. /*** Helpers ***/
  159128. private _prepareCylinder;
  159129. private _intersectsWithCylinder;
  159130. }
  159131. /**
  159132. * Options fot the radial explosion event
  159133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159134. */
  159135. export class PhysicsRadialExplosionEventOptions {
  159136. /**
  159137. * The radius of the sphere for the radial explosion.
  159138. */
  159139. radius: number;
  159140. /**
  159141. * The strength of the explosion.
  159142. */
  159143. strength: number;
  159144. /**
  159145. * The strength of the force in correspondence to the distance of the affected object
  159146. */
  159147. falloff: PhysicsRadialImpulseFalloff;
  159148. /**
  159149. * Sphere options for the radial explosion.
  159150. */
  159151. sphere: {
  159152. segments: number;
  159153. diameter: number;
  159154. };
  159155. /**
  159156. * Sphere options for the radial explosion.
  159157. */
  159158. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  159159. }
  159160. /**
  159161. * Options fot the updraft event
  159162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159163. */
  159164. export class PhysicsUpdraftEventOptions {
  159165. /**
  159166. * The radius of the cylinder for the vortex
  159167. */
  159168. radius: number;
  159169. /**
  159170. * The strength of the updraft.
  159171. */
  159172. strength: number;
  159173. /**
  159174. * The height of the cylinder for the updraft.
  159175. */
  159176. height: number;
  159177. /**
  159178. * The mode for the the updraft.
  159179. */
  159180. updraftMode: PhysicsUpdraftMode;
  159181. }
  159182. /**
  159183. * Options fot the vortex event
  159184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159185. */
  159186. export class PhysicsVortexEventOptions {
  159187. /**
  159188. * The radius of the cylinder for the vortex
  159189. */
  159190. radius: number;
  159191. /**
  159192. * The strength of the vortex.
  159193. */
  159194. strength: number;
  159195. /**
  159196. * The height of the cylinder for the vortex.
  159197. */
  159198. height: number;
  159199. /**
  159200. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  159201. */
  159202. centripetalForceThreshold: number;
  159203. /**
  159204. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  159205. */
  159206. centripetalForceMultiplier: number;
  159207. /**
  159208. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  159209. */
  159210. centrifugalForceMultiplier: number;
  159211. /**
  159212. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  159213. */
  159214. updraftForceMultiplier: number;
  159215. }
  159216. /**
  159217. * The strength of the force in correspondence to the distance of the affected object
  159218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159219. */
  159220. export enum PhysicsRadialImpulseFalloff {
  159221. /** Defines that impulse is constant in strength across it's whole radius */
  159222. Constant = 0,
  159223. /** Defines that impulse gets weaker if it's further from the origin */
  159224. Linear = 1
  159225. }
  159226. /**
  159227. * The strength of the force in correspondence to the distance of the affected object
  159228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159229. */
  159230. export enum PhysicsUpdraftMode {
  159231. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  159232. Center = 0,
  159233. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  159234. Perpendicular = 1
  159235. }
  159236. /**
  159237. * Interface for a physics hit data
  159238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159239. */
  159240. export interface PhysicsHitData {
  159241. /**
  159242. * The force applied at the contact point
  159243. */
  159244. force: Vector3;
  159245. /**
  159246. * The contact point
  159247. */
  159248. contactPoint: Vector3;
  159249. /**
  159250. * The distance from the origin to the contact point
  159251. */
  159252. distanceFromOrigin: number;
  159253. }
  159254. /**
  159255. * Interface for radial explosion event data
  159256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159257. */
  159258. export interface PhysicsRadialExplosionEventData {
  159259. /**
  159260. * A sphere used for the radial explosion event
  159261. */
  159262. sphere: Mesh;
  159263. }
  159264. /**
  159265. * Interface for gravitational field event data
  159266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159267. */
  159268. export interface PhysicsGravitationalFieldEventData {
  159269. /**
  159270. * A sphere mesh used for the gravitational field event
  159271. */
  159272. sphere: Mesh;
  159273. }
  159274. /**
  159275. * Interface for updraft event data
  159276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159277. */
  159278. export interface PhysicsUpdraftEventData {
  159279. /**
  159280. * A cylinder used for the updraft event
  159281. */
  159282. cylinder: Mesh;
  159283. }
  159284. /**
  159285. * Interface for vortex event data
  159286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159287. */
  159288. export interface PhysicsVortexEventData {
  159289. /**
  159290. * A cylinder used for the vortex event
  159291. */
  159292. cylinder: Mesh;
  159293. }
  159294. /**
  159295. * Interface for an affected physics impostor
  159296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  159297. */
  159298. export interface PhysicsAffectedImpostorWithData {
  159299. /**
  159300. * The impostor affected by the effect
  159301. */
  159302. impostor: PhysicsImpostor;
  159303. /**
  159304. * The data about the hit/force from the explosion
  159305. */
  159306. hitData: PhysicsHitData;
  159307. }
  159308. }
  159309. declare module BABYLON {
  159310. /** @hidden */
  159311. export var blackAndWhitePixelShader: {
  159312. name: string;
  159313. shader: string;
  159314. };
  159315. }
  159316. declare module BABYLON {
  159317. /**
  159318. * Post process used to render in black and white
  159319. */
  159320. export class BlackAndWhitePostProcess extends PostProcess {
  159321. /**
  159322. * Linear about to convert he result to black and white (default: 1)
  159323. */
  159324. degree: number;
  159325. /**
  159326. * Gets a string identifying the name of the class
  159327. * @returns "BlackAndWhitePostProcess" string
  159328. */
  159329. getClassName(): string;
  159330. /**
  159331. * Creates a black and white post process
  159332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  159333. * @param name The name of the effect.
  159334. * @param options The required width/height ratio to downsize to before computing the render pass.
  159335. * @param camera The camera to apply the render pass to.
  159336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159337. * @param engine The engine which the post process will be applied. (default: current engine)
  159338. * @param reusable If the post process can be reused on the same frame. (default: false)
  159339. */
  159340. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  159341. /** @hidden */
  159342. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  159343. }
  159344. }
  159345. declare module BABYLON {
  159346. /**
  159347. * This represents a set of one or more post processes in Babylon.
  159348. * A post process can be used to apply a shader to a texture after it is rendered.
  159349. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  159350. */
  159351. export class PostProcessRenderEffect {
  159352. private _postProcesses;
  159353. private _getPostProcesses;
  159354. private _singleInstance;
  159355. private _cameras;
  159356. private _indicesForCamera;
  159357. /**
  159358. * Name of the effect
  159359. * @hidden
  159360. */
  159361. _name: string;
  159362. /**
  159363. * Instantiates a post process render effect.
  159364. * A post process can be used to apply a shader to a texture after it is rendered.
  159365. * @param engine The engine the effect is tied to
  159366. * @param name The name of the effect
  159367. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  159368. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  159369. */
  159370. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  159371. /**
  159372. * Checks if all the post processes in the effect are supported.
  159373. */
  159374. get isSupported(): boolean;
  159375. /**
  159376. * Updates the current state of the effect
  159377. * @hidden
  159378. */
  159379. _update(): void;
  159380. /**
  159381. * Attaches the effect on cameras
  159382. * @param cameras The camera to attach to.
  159383. * @hidden
  159384. */
  159385. _attachCameras(cameras: Camera): void;
  159386. /**
  159387. * Attaches the effect on cameras
  159388. * @param cameras The camera to attach to.
  159389. * @hidden
  159390. */
  159391. _attachCameras(cameras: Camera[]): void;
  159392. /**
  159393. * Detaches the effect on cameras
  159394. * @param cameras The camera to detach from.
  159395. * @hidden
  159396. */
  159397. _detachCameras(cameras: Camera): void;
  159398. /**
  159399. * Detaches the effect on cameras
  159400. * @param cameras The camera to detach from.
  159401. * @hidden
  159402. */
  159403. _detachCameras(cameras: Camera[]): void;
  159404. /**
  159405. * Enables the effect on given cameras
  159406. * @param cameras The camera to enable.
  159407. * @hidden
  159408. */
  159409. _enable(cameras: Camera): void;
  159410. /**
  159411. * Enables the effect on given cameras
  159412. * @param cameras The camera to enable.
  159413. * @hidden
  159414. */
  159415. _enable(cameras: Nullable<Camera[]>): void;
  159416. /**
  159417. * Disables the effect on the given cameras
  159418. * @param cameras The camera to disable.
  159419. * @hidden
  159420. */
  159421. _disable(cameras: Camera): void;
  159422. /**
  159423. * Disables the effect on the given cameras
  159424. * @param cameras The camera to disable.
  159425. * @hidden
  159426. */
  159427. _disable(cameras: Nullable<Camera[]>): void;
  159428. /**
  159429. * Gets a list of the post processes contained in the effect.
  159430. * @param camera The camera to get the post processes on.
  159431. * @returns The list of the post processes in the effect.
  159432. */
  159433. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  159434. }
  159435. }
  159436. declare module BABYLON {
  159437. /** @hidden */
  159438. export var extractHighlightsPixelShader: {
  159439. name: string;
  159440. shader: string;
  159441. };
  159442. }
  159443. declare module BABYLON {
  159444. /**
  159445. * 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.
  159446. */
  159447. export class ExtractHighlightsPostProcess extends PostProcess {
  159448. /**
  159449. * The luminance threshold, pixels below this value will be set to black.
  159450. */
  159451. threshold: number;
  159452. /** @hidden */
  159453. _exposure: number;
  159454. /**
  159455. * Post process which has the input texture to be used when performing highlight extraction
  159456. * @hidden
  159457. */
  159458. _inputPostProcess: Nullable<PostProcess>;
  159459. /**
  159460. * Gets a string identifying the name of the class
  159461. * @returns "ExtractHighlightsPostProcess" string
  159462. */
  159463. getClassName(): string;
  159464. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159465. }
  159466. }
  159467. declare module BABYLON {
  159468. /** @hidden */
  159469. export var bloomMergePixelShader: {
  159470. name: string;
  159471. shader: string;
  159472. };
  159473. }
  159474. declare module BABYLON {
  159475. /**
  159476. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  159477. */
  159478. export class BloomMergePostProcess extends PostProcess {
  159479. /** Weight of the bloom to be added to the original input. */
  159480. weight: number;
  159481. /**
  159482. * Gets a string identifying the name of the class
  159483. * @returns "BloomMergePostProcess" string
  159484. */
  159485. getClassName(): string;
  159486. /**
  159487. * Creates a new instance of @see BloomMergePostProcess
  159488. * @param name The name of the effect.
  159489. * @param originalFromInput Post process which's input will be used for the merge.
  159490. * @param blurred Blurred highlights post process which's output will be used.
  159491. * @param weight Weight of the bloom to be added to the original input.
  159492. * @param options The required width/height ratio to downsize to before computing the render pass.
  159493. * @param camera The camera to apply the render pass to.
  159494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159495. * @param engine The engine which the post process will be applied. (default: current engine)
  159496. * @param reusable If the post process can be reused on the same frame. (default: false)
  159497. * @param textureType Type of textures used when performing the post process. (default: 0)
  159498. * @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)
  159499. */
  159500. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  159501. /** Weight of the bloom to be added to the original input. */
  159502. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159503. }
  159504. }
  159505. declare module BABYLON {
  159506. /**
  159507. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  159508. */
  159509. export class BloomEffect extends PostProcessRenderEffect {
  159510. private bloomScale;
  159511. /**
  159512. * @hidden Internal
  159513. */
  159514. _effects: Array<PostProcess>;
  159515. /**
  159516. * @hidden Internal
  159517. */
  159518. _downscale: ExtractHighlightsPostProcess;
  159519. private _blurX;
  159520. private _blurY;
  159521. private _merge;
  159522. /**
  159523. * The luminance threshold to find bright areas of the image to bloom.
  159524. */
  159525. get threshold(): number;
  159526. set threshold(value: number);
  159527. /**
  159528. * The strength of the bloom.
  159529. */
  159530. get weight(): number;
  159531. set weight(value: number);
  159532. /**
  159533. * Specifies the size of the bloom blur kernel, relative to the final output size
  159534. */
  159535. get kernel(): number;
  159536. set kernel(value: number);
  159537. /**
  159538. * Creates a new instance of @see BloomEffect
  159539. * @param scene The scene the effect belongs to.
  159540. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  159541. * @param bloomKernel The size of the kernel to be used when applying the blur.
  159542. * @param bloomWeight The the strength of bloom.
  159543. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  159544. * @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)
  159545. */
  159546. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  159547. /**
  159548. * Disposes each of the internal effects for a given camera.
  159549. * @param camera The camera to dispose the effect on.
  159550. */
  159551. disposeEffects(camera: Camera): void;
  159552. /**
  159553. * @hidden Internal
  159554. */
  159555. _updateEffects(): void;
  159556. /**
  159557. * Internal
  159558. * @returns if all the contained post processes are ready.
  159559. * @hidden
  159560. */
  159561. _isReady(): boolean;
  159562. }
  159563. }
  159564. declare module BABYLON {
  159565. /** @hidden */
  159566. export var chromaticAberrationPixelShader: {
  159567. name: string;
  159568. shader: string;
  159569. };
  159570. }
  159571. declare module BABYLON {
  159572. /**
  159573. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  159574. */
  159575. export class ChromaticAberrationPostProcess extends PostProcess {
  159576. /**
  159577. * The amount of separation of rgb channels (default: 30)
  159578. */
  159579. aberrationAmount: number;
  159580. /**
  159581. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  159582. */
  159583. radialIntensity: number;
  159584. /**
  159585. * The normalized direction in which the rgb channels should be separated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  159586. */
  159587. direction: Vector2;
  159588. /**
  159589. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corner] (default: Vector2(0.5 ,0.5))
  159590. */
  159591. centerPosition: Vector2;
  159592. /** The width of the screen to apply the effect on */
  159593. screenWidth: number;
  159594. /** The height of the screen to apply the effect on */
  159595. screenHeight: number;
  159596. /**
  159597. * Gets a string identifying the name of the class
  159598. * @returns "ChromaticAberrationPostProcess" string
  159599. */
  159600. getClassName(): string;
  159601. /**
  159602. * Creates a new instance ChromaticAberrationPostProcess
  159603. * @param name The name of the effect.
  159604. * @param screenWidth The width of the screen to apply the effect on.
  159605. * @param screenHeight The height of the screen to apply the effect on.
  159606. * @param options The required width/height ratio to downsize to before computing the render pass.
  159607. * @param camera The camera to apply the render pass to.
  159608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159609. * @param engine The engine which the post process will be applied. (default: current engine)
  159610. * @param reusable If the post process can be reused on the same frame. (default: false)
  159611. * @param textureType Type of textures used when performing the post process. (default: 0)
  159612. * @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)
  159613. */
  159614. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159615. /** @hidden */
  159616. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  159617. }
  159618. }
  159619. declare module BABYLON {
  159620. /** @hidden */
  159621. export var circleOfConfusionPixelShader: {
  159622. name: string;
  159623. shader: string;
  159624. };
  159625. }
  159626. declare module BABYLON {
  159627. /**
  159628. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  159629. */
  159630. export class CircleOfConfusionPostProcess extends PostProcess {
  159631. /**
  159632. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
  159633. */
  159634. lensSize: number;
  159635. /**
  159636. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  159637. */
  159638. fStop: number;
  159639. /**
  159640. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  159641. */
  159642. focusDistance: number;
  159643. /**
  159644. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  159645. */
  159646. focalLength: number;
  159647. /**
  159648. * Gets a string identifying the name of the class
  159649. * @returns "CircleOfConfusionPostProcess" string
  159650. */
  159651. getClassName(): string;
  159652. private _depthTexture;
  159653. /**
  159654. * Creates a new instance CircleOfConfusionPostProcess
  159655. * @param name The name of the effect.
  159656. * @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.
  159657. * @param options The required width/height ratio to downsize to before computing the render pass.
  159658. * @param camera The camera to apply the render pass to.
  159659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159660. * @param engine The engine which the post process will be applied. (default: current engine)
  159661. * @param reusable If the post process can be reused on the same frame. (default: false)
  159662. * @param textureType Type of textures used when performing the post process. (default: 0)
  159663. * @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)
  159664. */
  159665. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  159666. /**
  159667. * 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.
  159668. */
  159669. set depthTexture(value: RenderTargetTexture);
  159670. }
  159671. }
  159672. declare module BABYLON {
  159673. /** @hidden */
  159674. export var colorCorrectionPixelShader: {
  159675. name: string;
  159676. shader: string;
  159677. };
  159678. }
  159679. declare module BABYLON {
  159680. /**
  159681. *
  159682. * This post-process allows the modification of rendered colors by using
  159683. * a 'look-up table' (LUT). This effect is also called Color Grading.
  159684. *
  159685. * The object needs to be provided an url to a texture containing the color
  159686. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  159687. * Use an image editing software to tweak the LUT to match your needs.
  159688. *
  159689. * For an example of a color LUT, see here:
  159690. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  159691. * For explanations on color grading, see here:
  159692. * @see http://udn.epicgames.com/Three/ColorGrading.html
  159693. *
  159694. */
  159695. export class ColorCorrectionPostProcess extends PostProcess {
  159696. private _colorTableTexture;
  159697. /**
  159698. * Gets the color table url used to create the LUT texture
  159699. */
  159700. colorTableUrl: string;
  159701. /**
  159702. * Gets a string identifying the name of the class
  159703. * @returns "ColorCorrectionPostProcess" string
  159704. */
  159705. getClassName(): string;
  159706. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  159707. /** @hidden */
  159708. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  159709. }
  159710. }
  159711. declare module BABYLON {
  159712. /** @hidden */
  159713. export var convolutionPixelShader: {
  159714. name: string;
  159715. shader: string;
  159716. };
  159717. }
  159718. declare module BABYLON {
  159719. /**
  159720. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  159721. * input texture to perform effects such as edge detection or sharpening
  159722. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  159723. */
  159724. export class ConvolutionPostProcess extends PostProcess {
  159725. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  159726. kernel: number[];
  159727. /**
  159728. * Gets a string identifying the name of the class
  159729. * @returns "ConvolutionPostProcess" string
  159730. */
  159731. getClassName(): string;
  159732. /**
  159733. * Creates a new instance ConvolutionPostProcess
  159734. * @param name The name of the effect.
  159735. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  159736. * @param options The required width/height ratio to downsize to before computing the render pass.
  159737. * @param camera The camera to apply the render pass to.
  159738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159739. * @param engine The engine which the post process will be applied. (default: current engine)
  159740. * @param reusable If the post process can be reused on the same frame. (default: false)
  159741. * @param textureType Type of textures used when performing the post process. (default: 0)
  159742. */
  159743. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  159744. /** @hidden */
  159745. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  159746. /**
  159747. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  159748. */
  159749. static EdgeDetect0Kernel: number[];
  159750. /**
  159751. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  159752. */
  159753. static EdgeDetect1Kernel: number[];
  159754. /**
  159755. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  159756. */
  159757. static EdgeDetect2Kernel: number[];
  159758. /**
  159759. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  159760. */
  159761. static SharpenKernel: number[];
  159762. /**
  159763. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  159764. */
  159765. static EmbossKernel: number[];
  159766. /**
  159767. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  159768. */
  159769. static GaussianKernel: number[];
  159770. }
  159771. }
  159772. declare module BABYLON {
  159773. /**
  159774. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  159775. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  159776. * based on samples that have a large difference in distance than the center pixel.
  159777. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  159778. */
  159779. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  159780. /**
  159781. * The direction the blur should be applied
  159782. */
  159783. direction: Vector2;
  159784. /**
  159785. * Gets a string identifying the name of the class
  159786. * @returns "DepthOfFieldBlurPostProcess" string
  159787. */
  159788. getClassName(): string;
  159789. /**
  159790. * Creates a new instance CircleOfConfusionPostProcess
  159791. * @param name The name of the effect.
  159792. * @param scene The scene the effect belongs to.
  159793. * @param direction The direction the blur should be applied.
  159794. * @param kernel The size of the kernel used to blur.
  159795. * @param options The required width/height ratio to downsize to before computing the render pass.
  159796. * @param camera The camera to apply the render pass to.
  159797. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  159798. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  159799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159800. * @param engine The engine which the post process will be applied. (default: current engine)
  159801. * @param reusable If the post process can be reused on the same frame. (default: false)
  159802. * @param textureType Type of textures used when performing the post process. (default: 0)
  159803. * @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)
  159804. */
  159805. 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);
  159806. }
  159807. }
  159808. declare module BABYLON {
  159809. /** @hidden */
  159810. export var depthOfFieldMergePixelShader: {
  159811. name: string;
  159812. shader: string;
  159813. };
  159814. }
  159815. declare module BABYLON {
  159816. /**
  159817. * Options to be set when merging outputs from the default pipeline.
  159818. */
  159819. export class DepthOfFieldMergePostProcessOptions {
  159820. /**
  159821. * The original image to merge on top of
  159822. */
  159823. originalFromInput: PostProcess;
  159824. /**
  159825. * Parameters to perform the merge of the depth of field effect
  159826. */
  159827. depthOfField?: {
  159828. circleOfConfusion: PostProcess;
  159829. blurSteps: Array<PostProcess>;
  159830. };
  159831. /**
  159832. * Parameters to perform the merge of bloom effect
  159833. */
  159834. bloom?: {
  159835. blurred: PostProcess;
  159836. weight: number;
  159837. };
  159838. }
  159839. /**
  159840. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  159841. */
  159842. export class DepthOfFieldMergePostProcess extends PostProcess {
  159843. private blurSteps;
  159844. /**
  159845. * Gets a string identifying the name of the class
  159846. * @returns "DepthOfFieldMergePostProcess" string
  159847. */
  159848. getClassName(): string;
  159849. /**
  159850. * Creates a new instance of DepthOfFieldMergePostProcess
  159851. * @param name The name of the effect.
  159852. * @param originalFromInput Post process which's input will be used for the merge.
  159853. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  159854. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  159855. * @param options The required width/height ratio to downsize to before computing the render pass.
  159856. * @param camera The camera to apply the render pass to.
  159857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159858. * @param engine The engine which the post process will be applied. (default: current engine)
  159859. * @param reusable If the post process can be reused on the same frame. (default: false)
  159860. * @param textureType Type of textures used when performing the post process. (default: 0)
  159861. * @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)
  159862. */
  159863. 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);
  159864. /**
  159865. * Updates the effect with the current post process compile time values and recompiles the shader.
  159866. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  159867. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  159868. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  159869. * @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
  159870. * @param onCompiled Called when the shader has been compiled.
  159871. * @param onError Called if there is an error when compiling a shader.
  159872. */
  159873. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  159874. }
  159875. }
  159876. declare module BABYLON {
  159877. /**
  159878. * Specifies the level of max blur that should be applied when using the depth of field effect
  159879. */
  159880. export enum DepthOfFieldEffectBlurLevel {
  159881. /**
  159882. * Subtle blur
  159883. */
  159884. Low = 0,
  159885. /**
  159886. * Medium blur
  159887. */
  159888. Medium = 1,
  159889. /**
  159890. * Large blur
  159891. */
  159892. High = 2
  159893. }
  159894. /**
  159895. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  159896. */
  159897. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  159898. private _circleOfConfusion;
  159899. /**
  159900. * @hidden Internal, blurs from high to low
  159901. */
  159902. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  159903. private _depthOfFieldBlurY;
  159904. private _dofMerge;
  159905. /**
  159906. * @hidden Internal post processes in depth of field effect
  159907. */
  159908. _effects: Array<PostProcess>;
  159909. /**
  159910. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  159911. */
  159912. set focalLength(value: number);
  159913. get focalLength(): number;
  159914. /**
  159915. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  159916. */
  159917. set fStop(value: number);
  159918. get fStop(): number;
  159919. /**
  159920. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  159921. */
  159922. set focusDistance(value: number);
  159923. get focusDistance(): number;
  159924. /**
  159925. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
  159926. */
  159927. set lensSize(value: number);
  159928. get lensSize(): number;
  159929. /**
  159930. * Creates a new instance DepthOfFieldEffect
  159931. * @param scene The scene the effect belongs to.
  159932. * @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.
  159933. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  159934. * @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)
  159935. */
  159936. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  159937. /**
  159938. * Get the current class name of the current effect
  159939. * @returns "DepthOfFieldEffect"
  159940. */
  159941. getClassName(): string;
  159942. /**
  159943. * 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.
  159944. */
  159945. set depthTexture(value: RenderTargetTexture);
  159946. /**
  159947. * Disposes each of the internal effects for a given camera.
  159948. * @param camera The camera to dispose the effect on.
  159949. */
  159950. disposeEffects(camera: Camera): void;
  159951. /**
  159952. * @hidden Internal
  159953. */
  159954. _updateEffects(): void;
  159955. /**
  159956. * Internal
  159957. * @returns if all the contained post processes are ready.
  159958. * @hidden
  159959. */
  159960. _isReady(): boolean;
  159961. }
  159962. }
  159963. declare module BABYLON {
  159964. /** @hidden */
  159965. export var displayPassPixelShader: {
  159966. name: string;
  159967. shader: string;
  159968. };
  159969. }
  159970. declare module BABYLON {
  159971. /**
  159972. * DisplayPassPostProcess which produces an output the same as it's input
  159973. */
  159974. export class DisplayPassPostProcess extends PostProcess {
  159975. /**
  159976. * Gets a string identifying the name of the class
  159977. * @returns "DisplayPassPostProcess" string
  159978. */
  159979. getClassName(): string;
  159980. /**
  159981. * Creates the DisplayPassPostProcess
  159982. * @param name The name of the effect.
  159983. * @param options The required width/height ratio to downsize to before computing the render pass.
  159984. * @param camera The camera to apply the render pass to.
  159985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159986. * @param engine The engine which the post process will be applied. (default: current engine)
  159987. * @param reusable If the post process can be reused on the same frame. (default: false)
  159988. */
  159989. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  159990. /** @hidden */
  159991. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  159992. }
  159993. }
  159994. declare module BABYLON {
  159995. /** @hidden */
  159996. export var filterPixelShader: {
  159997. name: string;
  159998. shader: string;
  159999. };
  160000. }
  160001. declare module BABYLON {
  160002. /**
  160003. * Applies a kernel filter to the image
  160004. */
  160005. export class FilterPostProcess extends PostProcess {
  160006. /** The matrix to be applied to the image */
  160007. kernelMatrix: Matrix;
  160008. /**
  160009. * Gets a string identifying the name of the class
  160010. * @returns "FilterPostProcess" string
  160011. */
  160012. getClassName(): string;
  160013. /**
  160014. *
  160015. * @param name The name of the effect.
  160016. * @param kernelMatrix The matrix to be applied to the image
  160017. * @param options The required width/height ratio to downsize to before computing the render pass.
  160018. * @param camera The camera to apply the render pass to.
  160019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160020. * @param engine The engine which the post process will be applied. (default: current engine)
  160021. * @param reusable If the post process can be reused on the same frame. (default: false)
  160022. */
  160023. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  160024. /** @hidden */
  160025. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  160026. }
  160027. }
  160028. declare module BABYLON {
  160029. /** @hidden */
  160030. export var fxaaPixelShader: {
  160031. name: string;
  160032. shader: string;
  160033. };
  160034. }
  160035. declare module BABYLON {
  160036. /** @hidden */
  160037. export var fxaaVertexShader: {
  160038. name: string;
  160039. shader: string;
  160040. };
  160041. }
  160042. declare module BABYLON {
  160043. /**
  160044. * Fxaa post process
  160045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  160046. */
  160047. export class FxaaPostProcess extends PostProcess {
  160048. /**
  160049. * Gets a string identifying the name of the class
  160050. * @returns "FxaaPostProcess" string
  160051. */
  160052. getClassName(): string;
  160053. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  160054. private _getDefines;
  160055. /** @hidden */
  160056. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  160057. }
  160058. }
  160059. declare module BABYLON {
  160060. /** @hidden */
  160061. export var grainPixelShader: {
  160062. name: string;
  160063. shader: string;
  160064. };
  160065. }
  160066. declare module BABYLON {
  160067. /**
  160068. * The GrainPostProcess adds noise to the image at mid luminance levels
  160069. */
  160070. export class GrainPostProcess extends PostProcess {
  160071. /**
  160072. * The intensity of the grain added (default: 30)
  160073. */
  160074. intensity: number;
  160075. /**
  160076. * If the grain should be randomized on every frame
  160077. */
  160078. animated: boolean;
  160079. /**
  160080. * Gets a string identifying the name of the class
  160081. * @returns "GrainPostProcess" string
  160082. */
  160083. getClassName(): string;
  160084. /**
  160085. * Creates a new instance of @see GrainPostProcess
  160086. * @param name The name of the effect.
  160087. * @param options The required width/height ratio to downsize to before computing the render pass.
  160088. * @param camera The camera to apply the render pass to.
  160089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160090. * @param engine The engine which the post process will be applied. (default: current engine)
  160091. * @param reusable If the post process can be reused on the same frame. (default: false)
  160092. * @param textureType Type of textures used when performing the post process. (default: 0)
  160093. * @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)
  160094. */
  160095. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  160096. /** @hidden */
  160097. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  160098. }
  160099. }
  160100. declare module BABYLON {
  160101. /** @hidden */
  160102. export var highlightsPixelShader: {
  160103. name: string;
  160104. shader: string;
  160105. };
  160106. }
  160107. declare module BABYLON {
  160108. /**
  160109. * Extracts highlights from the image
  160110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  160111. */
  160112. export class HighlightsPostProcess extends PostProcess {
  160113. /**
  160114. * Gets a string identifying the name of the class
  160115. * @returns "HighlightsPostProcess" string
  160116. */
  160117. getClassName(): string;
  160118. /**
  160119. * Extracts highlights from the image
  160120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  160121. * @param name The name of the effect.
  160122. * @param options The required width/height ratio to downsize to before computing the render pass.
  160123. * @param camera The camera to apply the render pass to.
  160124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160125. * @param engine The engine which the post process will be applied. (default: current engine)
  160126. * @param reusable If the post process can be reused on the same frame. (default: false)
  160127. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  160128. */
  160129. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  160130. }
  160131. }
  160132. declare module BABYLON {
  160133. /**
  160134. * Contains all parameters needed for the prepass to perform
  160135. * motion blur
  160136. */
  160137. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  160138. /**
  160139. * Is motion blur enabled
  160140. */
  160141. enabled: boolean;
  160142. /**
  160143. * Name of the configuration
  160144. */
  160145. name: string;
  160146. /**
  160147. * Textures that should be present in the MRT for this effect to work
  160148. */
  160149. readonly texturesRequired: number[];
  160150. }
  160151. }
  160152. declare module BABYLON {
  160153. interface Scene {
  160154. /** @hidden (Backing field) */
  160155. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  160156. /**
  160157. * Gets or Sets the current geometry buffer associated to the scene.
  160158. */
  160159. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  160160. /**
  160161. * Enables a GeometryBufferRender and associates it with the scene
  160162. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  160163. * @returns the GeometryBufferRenderer
  160164. */
  160165. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  160166. /**
  160167. * Disables the GeometryBufferRender associated with the scene
  160168. */
  160169. disableGeometryBufferRenderer(): void;
  160170. }
  160171. /**
  160172. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  160173. * in several rendering techniques.
  160174. */
  160175. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  160176. /**
  160177. * The component name helpful to identify the component in the list of scene components.
  160178. */
  160179. readonly name: string;
  160180. /**
  160181. * The scene the component belongs to.
  160182. */
  160183. scene: Scene;
  160184. /**
  160185. * Creates a new instance of the component for the given scene
  160186. * @param scene Defines the scene to register the component in
  160187. */
  160188. constructor(scene: Scene);
  160189. /**
  160190. * Registers the component in a given scene
  160191. */
  160192. register(): void;
  160193. /**
  160194. * Rebuilds the elements related to this component in case of
  160195. * context lost for instance.
  160196. */
  160197. rebuild(): void;
  160198. /**
  160199. * Disposes the component and the associated resources
  160200. */
  160201. dispose(): void;
  160202. private _gatherRenderTargets;
  160203. }
  160204. }
  160205. declare module BABYLON {
  160206. /** @hidden */
  160207. export var motionBlurPixelShader: {
  160208. name: string;
  160209. shader: string;
  160210. };
  160211. }
  160212. declare module BABYLON {
  160213. /**
  160214. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  160215. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  160216. * As an example, all you have to do is to create the post-process:
  160217. * var mb = new BABYLON.MotionBlurPostProcess(
  160218. * 'mb', // The name of the effect.
  160219. * scene, // The scene containing the objects to blur according to their velocity.
  160220. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  160221. * camera // The camera to apply the render pass to.
  160222. * );
  160223. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  160224. */
  160225. export class MotionBlurPostProcess extends PostProcess {
  160226. /**
  160227. * Defines how much the image is blurred by the movement. Default value is equal to 1
  160228. */
  160229. motionStrength: number;
  160230. /**
  160231. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  160232. */
  160233. get motionBlurSamples(): number;
  160234. /**
  160235. * Sets the number of iterations to be used for motion blur quality
  160236. */
  160237. set motionBlurSamples(samples: number);
  160238. private _motionBlurSamples;
  160239. /**
  160240. * Gets whether or not the motion blur post-process is in object based mode.
  160241. */
  160242. get isObjectBased(): boolean;
  160243. /**
  160244. * Sets whether or not the motion blur post-process is in object based mode.
  160245. */
  160246. set isObjectBased(value: boolean);
  160247. private _isObjectBased;
  160248. private _forceGeometryBuffer;
  160249. private _geometryBufferRenderer;
  160250. private _prePassRenderer;
  160251. private _invViewProjection;
  160252. private _previousViewProjection;
  160253. /**
  160254. * Gets a string identifying the name of the class
  160255. * @returns "MotionBlurPostProcess" string
  160256. */
  160257. getClassName(): string;
  160258. /**
  160259. * Creates a new instance MotionBlurPostProcess
  160260. * @param name The name of the effect.
  160261. * @param scene The scene containing the objects to blur according to their velocity.
  160262. * @param options The required width/height ratio to downsize to before computing the render pass.
  160263. * @param camera The camera to apply the render pass to.
  160264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160265. * @param engine The engine which the post process will be applied. (default: current engine)
  160266. * @param reusable If the post process can be reused on the same frame. (default: false)
  160267. * @param textureType Type of textures used when performing the post process. (default: 0)
  160268. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  160269. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  160270. */
  160271. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  160272. /**
  160273. * Excludes the given skinned mesh from computing bones velocities.
  160274. * 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.
  160275. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  160276. */
  160277. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  160278. /**
  160279. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  160280. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  160281. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  160282. */
  160283. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  160284. /**
  160285. * Disposes the post process.
  160286. * @param camera The camera to dispose the post process on.
  160287. */
  160288. dispose(camera?: Camera): void;
  160289. /**
  160290. * Called on the mode changed (object based or screen based).
  160291. */
  160292. private _applyMode;
  160293. /**
  160294. * Called on the effect is applied when the motion blur post-process is in object based mode.
  160295. */
  160296. private _onApplyObjectBased;
  160297. /**
  160298. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  160299. */
  160300. private _onApplyScreenBased;
  160301. /**
  160302. * Called on the effect must be updated (changed mode, samples count, etc.).
  160303. */
  160304. private _updateEffect;
  160305. /** @hidden */
  160306. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  160307. }
  160308. }
  160309. declare module BABYLON {
  160310. /** @hidden */
  160311. export var refractionPixelShader: {
  160312. name: string;
  160313. shader: string;
  160314. };
  160315. }
  160316. declare module BABYLON {
  160317. /**
  160318. * Post process which applies a refraction texture
  160319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  160320. */
  160321. export class RefractionPostProcess extends PostProcess {
  160322. private _refTexture;
  160323. private _ownRefractionTexture;
  160324. /** the base color of the refraction (used to taint the rendering) */
  160325. color: Color3;
  160326. /** simulated refraction depth */
  160327. depth: number;
  160328. /** the coefficient of the base color (0 to remove base color tainting) */
  160329. colorLevel: number;
  160330. /** Gets the url used to load the refraction texture */
  160331. refractionTextureUrl: string;
  160332. /**
  160333. * Gets or sets the refraction texture
  160334. * Please note that you are responsible for disposing the texture if you set it manually
  160335. */
  160336. get refractionTexture(): Texture;
  160337. set refractionTexture(value: Texture);
  160338. /**
  160339. * Gets a string identifying the name of the class
  160340. * @returns "RefractionPostProcess" string
  160341. */
  160342. getClassName(): string;
  160343. /**
  160344. * Initializes the RefractionPostProcess
  160345. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  160346. * @param name The name of the effect.
  160347. * @param refractionTextureUrl Url of the refraction texture to use
  160348. * @param color the base color of the refraction (used to taint the rendering)
  160349. * @param depth simulated refraction depth
  160350. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  160351. * @param camera The camera to apply the render pass to.
  160352. * @param options The required width/height ratio to downsize to before computing the render pass.
  160353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160354. * @param engine The engine which the post process will be applied. (default: current engine)
  160355. * @param reusable If the post process can be reused on the same frame. (default: false)
  160356. */
  160357. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  160358. /**
  160359. * Disposes of the post process
  160360. * @param camera Camera to dispose post process on
  160361. */
  160362. dispose(camera: Camera): void;
  160363. /** @hidden */
  160364. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  160365. }
  160366. }
  160367. declare module BABYLON {
  160368. /** @hidden */
  160369. export var sharpenPixelShader: {
  160370. name: string;
  160371. shader: string;
  160372. };
  160373. }
  160374. declare module BABYLON {
  160375. /**
  160376. * The SharpenPostProcess applies a sharpen kernel to every pixel
  160377. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  160378. */
  160379. export class SharpenPostProcess extends PostProcess {
  160380. /**
  160381. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  160382. */
  160383. colorAmount: number;
  160384. /**
  160385. * How much sharpness should be applied (default: 0.3)
  160386. */
  160387. edgeAmount: number;
  160388. /**
  160389. * Gets a string identifying the name of the class
  160390. * @returns "SharpenPostProcess" string
  160391. */
  160392. getClassName(): string;
  160393. /**
  160394. * Creates a new instance ConvolutionPostProcess
  160395. * @param name The name of the effect.
  160396. * @param options The required width/height ratio to downsize to before computing the render pass.
  160397. * @param camera The camera to apply the render pass to.
  160398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160399. * @param engine The engine which the post process will be applied. (default: current engine)
  160400. * @param reusable If the post process can be reused on the same frame. (default: false)
  160401. * @param textureType Type of textures used when performing the post process. (default: 0)
  160402. * @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)
  160403. */
  160404. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  160405. /** @hidden */
  160406. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  160407. }
  160408. }
  160409. declare module BABYLON {
  160410. /**
  160411. * PostProcessRenderPipeline
  160412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  160413. */
  160414. export class PostProcessRenderPipeline {
  160415. private engine;
  160416. private _renderEffects;
  160417. private _renderEffectsForIsolatedPass;
  160418. /**
  160419. * List of inspectable custom properties (used by the Inspector)
  160420. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  160421. */
  160422. inspectableCustomProperties: IInspectable[];
  160423. /**
  160424. * @hidden
  160425. */
  160426. protected _cameras: Camera[];
  160427. /** @hidden */
  160428. _name: string;
  160429. /**
  160430. * Gets pipeline name
  160431. */
  160432. get name(): string;
  160433. /** Gets the list of attached cameras */
  160434. get cameras(): Camera[];
  160435. /**
  160436. * Initializes a PostProcessRenderPipeline
  160437. * @param engine engine to add the pipeline to
  160438. * @param name name of the pipeline
  160439. */
  160440. constructor(engine: Engine, name: string);
  160441. /**
  160442. * Gets the class name
  160443. * @returns "PostProcessRenderPipeline"
  160444. */
  160445. getClassName(): string;
  160446. /**
  160447. * If all the render effects in the pipeline are supported
  160448. */
  160449. get isSupported(): boolean;
  160450. /**
  160451. * Adds an effect to the pipeline
  160452. * @param renderEffect the effect to add
  160453. */
  160454. addEffect(renderEffect: PostProcessRenderEffect): void;
  160455. /** @hidden */
  160456. _rebuild(): void;
  160457. /** @hidden */
  160458. _enableEffect(renderEffectName: string, cameras: Camera): void;
  160459. /** @hidden */
  160460. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  160461. /** @hidden */
  160462. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  160463. /** @hidden */
  160464. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  160465. /** @hidden */
  160466. _attachCameras(cameras: Camera, unique: boolean): void;
  160467. /** @hidden */
  160468. _attachCameras(cameras: Camera[], unique: boolean): void;
  160469. /** @hidden */
  160470. _detachCameras(cameras: Camera): void;
  160471. /** @hidden */
  160472. _detachCameras(cameras: Nullable<Camera[]>): void;
  160473. /** @hidden */
  160474. _update(): void;
  160475. /** @hidden */
  160476. _reset(): void;
  160477. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  160478. /**
  160479. * Sets the required values to the prepass renderer.
  160480. * @param prePassRenderer defines the prepass renderer to setup.
  160481. * @returns true if the pre pass is needed.
  160482. */
  160483. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  160484. /**
  160485. * Disposes of the pipeline
  160486. */
  160487. dispose(): void;
  160488. }
  160489. }
  160490. declare module BABYLON {
  160491. /**
  160492. * PostProcessRenderPipelineManager class
  160493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  160494. */
  160495. export class PostProcessRenderPipelineManager {
  160496. private _renderPipelines;
  160497. /**
  160498. * Initializes a PostProcessRenderPipelineManager
  160499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  160500. */
  160501. constructor();
  160502. /**
  160503. * Gets the list of supported render pipelines
  160504. */
  160505. get supportedPipelines(): PostProcessRenderPipeline[];
  160506. /**
  160507. * Adds a pipeline to the manager
  160508. * @param renderPipeline The pipeline to add
  160509. */
  160510. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  160511. /**
  160512. * Attaches a camera to the pipeline
  160513. * @param renderPipelineName The name of the pipeline to attach to
  160514. * @param cameras the camera to attach
  160515. * @param unique if the camera can be attached multiple times to the pipeline
  160516. */
  160517. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  160518. /**
  160519. * Detaches a camera from the pipeline
  160520. * @param renderPipelineName The name of the pipeline to detach from
  160521. * @param cameras the camera to detach
  160522. */
  160523. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  160524. /**
  160525. * Enables an effect by name on a pipeline
  160526. * @param renderPipelineName the name of the pipeline to enable the effect in
  160527. * @param renderEffectName the name of the effect to enable
  160528. * @param cameras the cameras that the effect should be enabled on
  160529. */
  160530. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  160531. /**
  160532. * Disables an effect by name on a pipeline
  160533. * @param renderPipelineName the name of the pipeline to disable the effect in
  160534. * @param renderEffectName the name of the effect to disable
  160535. * @param cameras the cameras that the effect should be disabled on
  160536. */
  160537. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  160538. /**
  160539. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  160540. */
  160541. update(): void;
  160542. /** @hidden */
  160543. _rebuild(): void;
  160544. /**
  160545. * Disposes of the manager and pipelines
  160546. */
  160547. dispose(): void;
  160548. }
  160549. }
  160550. declare module BABYLON {
  160551. interface Scene {
  160552. /** @hidden (Backing field) */
  160553. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  160554. /**
  160555. * Gets the postprocess render pipeline manager
  160556. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  160557. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  160558. */
  160559. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  160560. }
  160561. /**
  160562. * Defines the Render Pipeline scene component responsible to rendering pipelines
  160563. */
  160564. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  160565. /**
  160566. * The component name helpful to identify the component in the list of scene components.
  160567. */
  160568. readonly name: string;
  160569. /**
  160570. * The scene the component belongs to.
  160571. */
  160572. scene: Scene;
  160573. /**
  160574. * Creates a new instance of the component for the given scene
  160575. * @param scene Defines the scene to register the component in
  160576. */
  160577. constructor(scene: Scene);
  160578. /**
  160579. * Registers the component in a given scene
  160580. */
  160581. register(): void;
  160582. /**
  160583. * Rebuilds the elements related to this component in case of
  160584. * context lost for instance.
  160585. */
  160586. rebuild(): void;
  160587. /**
  160588. * Disposes the component and the associated resources
  160589. */
  160590. dispose(): void;
  160591. private _gatherRenderTargets;
  160592. }
  160593. }
  160594. declare module BABYLON {
  160595. /**
  160596. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  160597. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  160598. */
  160599. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  160600. private _scene;
  160601. private _camerasToBeAttached;
  160602. /**
  160603. * ID of the sharpen post process,
  160604. */
  160605. private readonly SharpenPostProcessId;
  160606. /**
  160607. * @ignore
  160608. * ID of the image processing post process;
  160609. */
  160610. readonly ImageProcessingPostProcessId: string;
  160611. /**
  160612. * @ignore
  160613. * ID of the Fast Approximate Anti-Aliasing post process;
  160614. */
  160615. readonly FxaaPostProcessId: string;
  160616. /**
  160617. * ID of the chromatic aberration post process,
  160618. */
  160619. private readonly ChromaticAberrationPostProcessId;
  160620. /**
  160621. * ID of the grain post process
  160622. */
  160623. private readonly GrainPostProcessId;
  160624. /**
  160625. * Sharpen post process which will apply a sharpen convolution to enhance edges
  160626. */
  160627. sharpen: SharpenPostProcess;
  160628. private _sharpenEffect;
  160629. private bloom;
  160630. /**
  160631. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  160632. */
  160633. depthOfField: DepthOfFieldEffect;
  160634. /**
  160635. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  160636. */
  160637. fxaa: FxaaPostProcess;
  160638. /**
  160639. * Image post processing pass used to perform operations such as tone mapping or color grading.
  160640. */
  160641. imageProcessing: ImageProcessingPostProcess;
  160642. /**
  160643. * Chromatic aberration post process which will shift rgb colors in the image
  160644. */
  160645. chromaticAberration: ChromaticAberrationPostProcess;
  160646. private _chromaticAberrationEffect;
  160647. /**
  160648. * Grain post process which add noise to the image
  160649. */
  160650. grain: GrainPostProcess;
  160651. private _grainEffect;
  160652. /**
  160653. * Glow post process which adds a glow to emissive areas of the image
  160654. */
  160655. private _glowLayer;
  160656. /**
  160657. * Animations which can be used to tweak settings over a period of time
  160658. */
  160659. animations: Animation[];
  160660. private _imageProcessingConfigurationObserver;
  160661. private _sharpenEnabled;
  160662. private _bloomEnabled;
  160663. private _depthOfFieldEnabled;
  160664. private _depthOfFieldBlurLevel;
  160665. private _fxaaEnabled;
  160666. private _imageProcessingEnabled;
  160667. private _defaultPipelineTextureType;
  160668. private _bloomScale;
  160669. private _chromaticAberrationEnabled;
  160670. private _grainEnabled;
  160671. private _buildAllowed;
  160672. /**
  160673. * This is triggered each time the pipeline has been built.
  160674. */
  160675. onBuildObservable: Observable<DefaultRenderingPipeline>;
  160676. /**
  160677. * Gets active scene
  160678. */
  160679. get scene(): Scene;
  160680. /**
  160681. * Enable or disable the sharpen process from the pipeline
  160682. */
  160683. set sharpenEnabled(enabled: boolean);
  160684. get sharpenEnabled(): boolean;
  160685. private _resizeObserver;
  160686. private _hardwareScaleLevel;
  160687. private _bloomKernel;
  160688. /**
  160689. * Specifies the size of the bloom blur kernel, relative to the final output size
  160690. */
  160691. get bloomKernel(): number;
  160692. set bloomKernel(value: number);
  160693. /**
  160694. * Specifies the weight of the bloom in the final rendering
  160695. */
  160696. private _bloomWeight;
  160697. /**
  160698. * Specifies the luma threshold for the area that will be blurred by the bloom
  160699. */
  160700. private _bloomThreshold;
  160701. private _hdr;
  160702. /**
  160703. * The strength of the bloom.
  160704. */
  160705. set bloomWeight(value: number);
  160706. get bloomWeight(): number;
  160707. /**
  160708. * The strength of the bloom.
  160709. */
  160710. set bloomThreshold(value: number);
  160711. get bloomThreshold(): number;
  160712. /**
  160713. * The scale of the bloom, lower value will provide better performance.
  160714. */
  160715. set bloomScale(value: number);
  160716. get bloomScale(): number;
  160717. /**
  160718. * Enable or disable the bloom from the pipeline
  160719. */
  160720. set bloomEnabled(enabled: boolean);
  160721. get bloomEnabled(): boolean;
  160722. private _rebuildBloom;
  160723. /**
  160724. * If the depth of field is enabled.
  160725. */
  160726. get depthOfFieldEnabled(): boolean;
  160727. set depthOfFieldEnabled(enabled: boolean);
  160728. /**
  160729. * Blur level of the depth of field effect. (Higher blur will effect performance)
  160730. */
  160731. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  160732. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  160733. /**
  160734. * If the anti aliasing is enabled.
  160735. */
  160736. set fxaaEnabled(enabled: boolean);
  160737. get fxaaEnabled(): boolean;
  160738. private _samples;
  160739. /**
  160740. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  160741. */
  160742. set samples(sampleCount: number);
  160743. get samples(): number;
  160744. /**
  160745. * If image processing is enabled.
  160746. */
  160747. set imageProcessingEnabled(enabled: boolean);
  160748. get imageProcessingEnabled(): boolean;
  160749. /**
  160750. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  160751. */
  160752. set glowLayerEnabled(enabled: boolean);
  160753. get glowLayerEnabled(): boolean;
  160754. /**
  160755. * Gets the glow layer (or null if not defined)
  160756. */
  160757. get glowLayer(): Nullable<GlowLayer>;
  160758. /**
  160759. * Enable or disable the chromaticAberration process from the pipeline
  160760. */
  160761. set chromaticAberrationEnabled(enabled: boolean);
  160762. get chromaticAberrationEnabled(): boolean;
  160763. /**
  160764. * Enable or disable the grain process from the pipeline
  160765. */
  160766. set grainEnabled(enabled: boolean);
  160767. get grainEnabled(): boolean;
  160768. /**
  160769. * @constructor
  160770. * @param name - The rendering pipeline name (default: "")
  160771. * @param hdr - If high dynamic range textures should be used (default: true)
  160772. * @param scene - The scene linked to this pipeline (default: the last created scene)
  160773. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  160774. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  160775. */
  160776. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  160777. /**
  160778. * Get the class name
  160779. * @returns "DefaultRenderingPipeline"
  160780. */
  160781. getClassName(): string;
  160782. /**
  160783. * Force the compilation of the entire pipeline.
  160784. */
  160785. prepare(): void;
  160786. private _hasCleared;
  160787. private _prevPostProcess;
  160788. private _prevPrevPostProcess;
  160789. private _setAutoClearAndTextureSharing;
  160790. private _depthOfFieldSceneObserver;
  160791. private _buildPipeline;
  160792. private _disposePostProcesses;
  160793. /**
  160794. * Adds a camera to the pipeline
  160795. * @param camera the camera to be added
  160796. */
  160797. addCamera(camera: Camera): void;
  160798. /**
  160799. * Removes a camera from the pipeline
  160800. * @param camera the camera to remove
  160801. */
  160802. removeCamera(camera: Camera): void;
  160803. /**
  160804. * Dispose of the pipeline and stop all post processes
  160805. */
  160806. dispose(): void;
  160807. /**
  160808. * Serialize the rendering pipeline (Used when exporting)
  160809. * @returns the serialized object
  160810. */
  160811. serialize(): any;
  160812. /**
  160813. * Parse the serialized pipeline
  160814. * @param source Source pipeline.
  160815. * @param scene The scene to load the pipeline to.
  160816. * @param rootUrl The URL of the serialized pipeline.
  160817. * @returns An instantiated pipeline from the serialized object.
  160818. */
  160819. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  160820. }
  160821. }
  160822. declare module BABYLON {
  160823. /** @hidden */
  160824. export var lensHighlightsPixelShader: {
  160825. name: string;
  160826. shader: string;
  160827. };
  160828. }
  160829. declare module BABYLON {
  160830. /** @hidden */
  160831. export var depthOfFieldPixelShader: {
  160832. name: string;
  160833. shader: string;
  160834. };
  160835. }
  160836. declare module BABYLON {
  160837. /**
  160838. * BABYLON.JS Chromatic Aberration GLSL Shader
  160839. * Author: Olivier Guyot
  160840. * Separates very slightly R, G and B colors on the edges of the screen
  160841. * Inspired by Francois Tarlier & Martins Upitis
  160842. */
  160843. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  160844. /**
  160845. * @ignore
  160846. * The chromatic aberration PostProcess id in the pipeline
  160847. */
  160848. LensChromaticAberrationEffect: string;
  160849. /**
  160850. * @ignore
  160851. * The highlights enhancing PostProcess id in the pipeline
  160852. */
  160853. HighlightsEnhancingEffect: string;
  160854. /**
  160855. * @ignore
  160856. * The depth-of-field PostProcess id in the pipeline
  160857. */
  160858. LensDepthOfFieldEffect: string;
  160859. private _scene;
  160860. private _depthTexture;
  160861. private _grainTexture;
  160862. private _chromaticAberrationPostProcess;
  160863. private _highlightsPostProcess;
  160864. private _depthOfFieldPostProcess;
  160865. private _edgeBlur;
  160866. private _grainAmount;
  160867. private _chromaticAberration;
  160868. private _distortion;
  160869. private _highlightsGain;
  160870. private _highlightsThreshold;
  160871. private _dofDistance;
  160872. private _dofAperture;
  160873. private _dofDarken;
  160874. private _dofPentagon;
  160875. private _blurNoise;
  160876. /**
  160877. * @constructor
  160878. *
  160879. * Effect parameters are as follow:
  160880. * {
  160881. * chromatic_aberration: number; // from 0 to x (1 for realism)
  160882. * edge_blur: number; // from 0 to x (1 for realism)
  160883. * distortion: number; // from 0 to x (1 for realism)
  160884. * grain_amount: number; // from 0 to 1
  160885. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  160886. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  160887. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  160888. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  160889. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  160890. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  160891. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  160892. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  160893. * }
  160894. * Note: if an effect parameter is unset, effect is disabled
  160895. *
  160896. * @param name The rendering pipeline name
  160897. * @param parameters - An object containing all parameters (see above)
  160898. * @param scene The scene linked to this pipeline
  160899. * @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)
  160900. * @param cameras The array of cameras that the rendering pipeline will be attached to
  160901. */
  160902. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  160903. /**
  160904. * Get the class name
  160905. * @returns "LensRenderingPipeline"
  160906. */
  160907. getClassName(): string;
  160908. /**
  160909. * Gets associated scene
  160910. */
  160911. get scene(): Scene;
  160912. /**
  160913. * Gets or sets the edge blur
  160914. */
  160915. get edgeBlur(): number;
  160916. set edgeBlur(value: number);
  160917. /**
  160918. * Gets or sets the grain amount
  160919. */
  160920. get grainAmount(): number;
  160921. set grainAmount(value: number);
  160922. /**
  160923. * Gets or sets the chromatic aberration amount
  160924. */
  160925. get chromaticAberration(): number;
  160926. set chromaticAberration(value: number);
  160927. /**
  160928. * Gets or sets the depth of field aperture
  160929. */
  160930. get dofAperture(): number;
  160931. set dofAperture(value: number);
  160932. /**
  160933. * Gets or sets the edge distortion
  160934. */
  160935. get edgeDistortion(): number;
  160936. set edgeDistortion(value: number);
  160937. /**
  160938. * Gets or sets the depth of field distortion
  160939. */
  160940. get dofDistortion(): number;
  160941. set dofDistortion(value: number);
  160942. /**
  160943. * Gets or sets the darken out of focus amount
  160944. */
  160945. get darkenOutOfFocus(): number;
  160946. set darkenOutOfFocus(value: number);
  160947. /**
  160948. * Gets or sets a boolean indicating if blur noise is enabled
  160949. */
  160950. get blurNoise(): boolean;
  160951. set blurNoise(value: boolean);
  160952. /**
  160953. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  160954. */
  160955. get pentagonBokeh(): boolean;
  160956. set pentagonBokeh(value: boolean);
  160957. /**
  160958. * Gets or sets the highlight grain amount
  160959. */
  160960. get highlightsGain(): number;
  160961. set highlightsGain(value: number);
  160962. /**
  160963. * Gets or sets the highlight threshold
  160964. */
  160965. get highlightsThreshold(): number;
  160966. set highlightsThreshold(value: number);
  160967. /**
  160968. * Sets the amount of blur at the edges
  160969. * @param amount blur amount
  160970. */
  160971. setEdgeBlur(amount: number): void;
  160972. /**
  160973. * Sets edge blur to 0
  160974. */
  160975. disableEdgeBlur(): void;
  160976. /**
  160977. * Sets the amount of grain
  160978. * @param amount Amount of grain
  160979. */
  160980. setGrainAmount(amount: number): void;
  160981. /**
  160982. * Set grain amount to 0
  160983. */
  160984. disableGrain(): void;
  160985. /**
  160986. * Sets the chromatic aberration amount
  160987. * @param amount amount of chromatic aberration
  160988. */
  160989. setChromaticAberration(amount: number): void;
  160990. /**
  160991. * Sets chromatic aberration amount to 0
  160992. */
  160993. disableChromaticAberration(): void;
  160994. /**
  160995. * Sets the EdgeDistortion amount
  160996. * @param amount amount of EdgeDistortion
  160997. */
  160998. setEdgeDistortion(amount: number): void;
  160999. /**
  161000. * Sets edge distortion to 0
  161001. */
  161002. disableEdgeDistortion(): void;
  161003. /**
  161004. * Sets the FocusDistance amount
  161005. * @param amount amount of FocusDistance
  161006. */
  161007. setFocusDistance(amount: number): void;
  161008. /**
  161009. * Disables depth of field
  161010. */
  161011. disableDepthOfField(): void;
  161012. /**
  161013. * Sets the Aperture amount
  161014. * @param amount amount of Aperture
  161015. */
  161016. setAperture(amount: number): void;
  161017. /**
  161018. * Sets the DarkenOutOfFocus amount
  161019. * @param amount amount of DarkenOutOfFocus
  161020. */
  161021. setDarkenOutOfFocus(amount: number): void;
  161022. private _pentagonBokehIsEnabled;
  161023. /**
  161024. * Creates a pentagon bokeh effect
  161025. */
  161026. enablePentagonBokeh(): void;
  161027. /**
  161028. * Disables the pentagon bokeh effect
  161029. */
  161030. disablePentagonBokeh(): void;
  161031. /**
  161032. * Enables noise blur
  161033. */
  161034. enableNoiseBlur(): void;
  161035. /**
  161036. * Disables noise blur
  161037. */
  161038. disableNoiseBlur(): void;
  161039. /**
  161040. * Sets the HighlightsGain amount
  161041. * @param amount amount of HighlightsGain
  161042. */
  161043. setHighlightsGain(amount: number): void;
  161044. /**
  161045. * Sets the HighlightsThreshold amount
  161046. * @param amount amount of HighlightsThreshold
  161047. */
  161048. setHighlightsThreshold(amount: number): void;
  161049. /**
  161050. * Disables highlights
  161051. */
  161052. disableHighlights(): void;
  161053. /**
  161054. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  161055. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  161056. */
  161057. dispose(disableDepthRender?: boolean): void;
  161058. private _createChromaticAberrationPostProcess;
  161059. private _createHighlightsPostProcess;
  161060. private _createDepthOfFieldPostProcess;
  161061. private _createGrainTexture;
  161062. }
  161063. }
  161064. declare module BABYLON {
  161065. /**
  161066. * Contains all parameters needed for the prepass to perform
  161067. * screen space subsurface scattering
  161068. */
  161069. export class SSAO2Configuration implements PrePassEffectConfiguration {
  161070. /**
  161071. * Is subsurface enabled
  161072. */
  161073. enabled: boolean;
  161074. /**
  161075. * Name of the configuration
  161076. */
  161077. name: string;
  161078. /**
  161079. * Textures that should be present in the MRT for this effect to work
  161080. */
  161081. readonly texturesRequired: number[];
  161082. }
  161083. }
  161084. declare module BABYLON {
  161085. /** @hidden */
  161086. export var ssao2PixelShader: {
  161087. name: string;
  161088. shader: string;
  161089. };
  161090. }
  161091. declare module BABYLON {
  161092. /** @hidden */
  161093. export var ssaoCombinePixelShader: {
  161094. name: string;
  161095. shader: string;
  161096. };
  161097. }
  161098. declare module BABYLON {
  161099. /**
  161100. * Render pipeline to produce ssao effect
  161101. */
  161102. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  161103. /**
  161104. * @ignore
  161105. * The PassPostProcess id in the pipeline that contains the original scene color
  161106. */
  161107. SSAOOriginalSceneColorEffect: string;
  161108. /**
  161109. * @ignore
  161110. * The SSAO PostProcess id in the pipeline
  161111. */
  161112. SSAORenderEffect: string;
  161113. /**
  161114. * @ignore
  161115. * The horizontal blur PostProcess id in the pipeline
  161116. */
  161117. SSAOBlurHRenderEffect: string;
  161118. /**
  161119. * @ignore
  161120. * The vertical blur PostProcess id in the pipeline
  161121. */
  161122. SSAOBlurVRenderEffect: string;
  161123. /**
  161124. * @ignore
  161125. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  161126. */
  161127. SSAOCombineRenderEffect: string;
  161128. /**
  161129. * The output strength of the SSAO post-process. Default value is 1.0.
  161130. */
  161131. totalStrength: number;
  161132. /**
  161133. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  161134. */
  161135. maxZ: number;
  161136. /**
  161137. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  161138. */
  161139. minZAspect: number;
  161140. private _samples;
  161141. /**
  161142. * Number of samples used for the SSAO calculations. Default value is 8
  161143. */
  161144. set samples(n: number);
  161145. get samples(): number;
  161146. private _textureSamples;
  161147. /**
  161148. * Number of samples to use for antialiasing
  161149. */
  161150. set textureSamples(n: number);
  161151. get textureSamples(): number;
  161152. /**
  161153. * Force rendering the geometry through geometry buffer
  161154. */
  161155. private _forceGeometryBuffer;
  161156. /**
  161157. * Ratio object used for SSAO ratio and blur ratio
  161158. */
  161159. private _ratio;
  161160. /**
  161161. * Dynamically generated sphere sampler.
  161162. */
  161163. private _sampleSphere;
  161164. /**
  161165. * Blur filter offsets
  161166. */
  161167. private _samplerOffsets;
  161168. private _expensiveBlur;
  161169. /**
  161170. * If bilateral blur should be used
  161171. */
  161172. set expensiveBlur(b: boolean);
  161173. get expensiveBlur(): boolean;
  161174. /**
  161175. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  161176. */
  161177. radius: number;
  161178. /**
  161179. * The base color of the SSAO post-process
  161180. * The final result is "base + ssao" between [0, 1]
  161181. */
  161182. base: number;
  161183. /**
  161184. * Support test.
  161185. */
  161186. static get IsSupported(): boolean;
  161187. private _scene;
  161188. private _randomTexture;
  161189. private _originalColorPostProcess;
  161190. private _ssaoPostProcess;
  161191. private _blurHPostProcess;
  161192. private _blurVPostProcess;
  161193. private _ssaoCombinePostProcess;
  161194. private _prePassRenderer;
  161195. /**
  161196. * Gets active scene
  161197. */
  161198. get scene(): Scene;
  161199. /**
  161200. * @constructor
  161201. * @param name The rendering pipeline name
  161202. * @param scene The scene linked to this pipeline
  161203. * @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 }
  161204. * @param cameras The array of cameras that the rendering pipeline will be attached to
  161205. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  161206. */
  161207. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  161208. /**
  161209. * Get the class name
  161210. * @returns "SSAO2RenderingPipeline"
  161211. */
  161212. getClassName(): string;
  161213. /**
  161214. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  161215. */
  161216. dispose(disableGeometryBufferRenderer?: boolean): void;
  161217. private _createBlurPostProcess;
  161218. /** @hidden */
  161219. _rebuild(): void;
  161220. private _bits;
  161221. private _radicalInverse_VdC;
  161222. private _hammersley;
  161223. private _hemisphereSample_uniform;
  161224. private _generateHemisphere;
  161225. private _getDefinesForSSAO;
  161226. private static readonly ORTHO_DEPTH_PROJECTION;
  161227. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  161228. private _createSSAOPostProcess;
  161229. private _createSSAOCombinePostProcess;
  161230. private _createRandomTexture;
  161231. /**
  161232. * Serialize the rendering pipeline (Used when exporting)
  161233. * @returns the serialized object
  161234. */
  161235. serialize(): any;
  161236. /**
  161237. * Parse the serialized pipeline
  161238. * @param source Source pipeline.
  161239. * @param scene The scene to load the pipeline to.
  161240. * @param rootUrl The URL of the serialized pipeline.
  161241. * @returns An instantiated pipeline from the serialized object.
  161242. */
  161243. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  161244. }
  161245. }
  161246. declare module BABYLON {
  161247. /** @hidden */
  161248. export var ssaoPixelShader: {
  161249. name: string;
  161250. shader: string;
  161251. };
  161252. }
  161253. declare module BABYLON {
  161254. /**
  161255. * Render pipeline to produce ssao effect
  161256. */
  161257. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  161258. /**
  161259. * @ignore
  161260. * The PassPostProcess id in the pipeline that contains the original scene color
  161261. */
  161262. SSAOOriginalSceneColorEffect: string;
  161263. /**
  161264. * @ignore
  161265. * The SSAO PostProcess id in the pipeline
  161266. */
  161267. SSAORenderEffect: string;
  161268. /**
  161269. * @ignore
  161270. * The horizontal blur PostProcess id in the pipeline
  161271. */
  161272. SSAOBlurHRenderEffect: string;
  161273. /**
  161274. * @ignore
  161275. * The vertical blur PostProcess id in the pipeline
  161276. */
  161277. SSAOBlurVRenderEffect: string;
  161278. /**
  161279. * @ignore
  161280. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  161281. */
  161282. SSAOCombineRenderEffect: string;
  161283. /**
  161284. * The output strength of the SSAO post-process. Default value is 1.0.
  161285. */
  161286. totalStrength: number;
  161287. /**
  161288. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  161289. */
  161290. radius: number;
  161291. /**
  161292. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  161293. * Must not be equal to fallOff and superior to fallOff.
  161294. * Default value is 0.0075
  161295. */
  161296. area: number;
  161297. /**
  161298. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  161299. * Must not be equal to area and inferior to area.
  161300. * Default value is 0.000001
  161301. */
  161302. fallOff: number;
  161303. /**
  161304. * The base color of the SSAO post-process
  161305. * The final result is "base + ssao" between [0, 1]
  161306. */
  161307. base: number;
  161308. private _scene;
  161309. private _depthTexture;
  161310. private _randomTexture;
  161311. private _originalColorPostProcess;
  161312. private _ssaoPostProcess;
  161313. private _blurHPostProcess;
  161314. private _blurVPostProcess;
  161315. private _ssaoCombinePostProcess;
  161316. private _firstUpdate;
  161317. /**
  161318. * Gets active scene
  161319. */
  161320. get scene(): Scene;
  161321. /**
  161322. * @constructor
  161323. * @param name - The rendering pipeline name
  161324. * @param scene - The scene linked to this pipeline
  161325. * @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 }
  161326. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  161327. */
  161328. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  161329. /**
  161330. * Get the class name
  161331. * @returns "SSAORenderingPipeline"
  161332. */
  161333. getClassName(): string;
  161334. /**
  161335. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  161336. */
  161337. dispose(disableDepthRender?: boolean): void;
  161338. private _createBlurPostProcess;
  161339. /** @hidden */
  161340. _rebuild(): void;
  161341. private _createSSAOPostProcess;
  161342. private _createSSAOCombinePostProcess;
  161343. private _createRandomTexture;
  161344. }
  161345. }
  161346. declare module BABYLON {
  161347. /**
  161348. * Contains all parameters needed for the prepass to perform
  161349. * screen space reflections
  161350. */
  161351. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  161352. /**
  161353. * Is ssr enabled
  161354. */
  161355. enabled: boolean;
  161356. /**
  161357. * Name of the configuration
  161358. */
  161359. name: string;
  161360. /**
  161361. * Textures that should be present in the MRT for this effect to work
  161362. */
  161363. readonly texturesRequired: number[];
  161364. }
  161365. }
  161366. declare module BABYLON {
  161367. /** @hidden */
  161368. export var screenSpaceReflectionPixelShader: {
  161369. name: string;
  161370. shader: string;
  161371. };
  161372. }
  161373. declare module BABYLON {
  161374. /**
  161375. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  161376. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  161377. */
  161378. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  161379. /**
  161380. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  161381. */
  161382. threshold: number;
  161383. /**
  161384. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  161385. */
  161386. strength: number;
  161387. /**
  161388. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  161389. */
  161390. reflectionSpecularFalloffExponent: number;
  161391. /**
  161392. * 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]
  161393. */
  161394. step: number;
  161395. /**
  161396. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  161397. */
  161398. roughnessFactor: number;
  161399. private _forceGeometryBuffer;
  161400. private _geometryBufferRenderer;
  161401. private _prePassRenderer;
  161402. private _enableSmoothReflections;
  161403. private _reflectionSamples;
  161404. private _smoothSteps;
  161405. /**
  161406. * Gets a string identifying the name of the class
  161407. * @returns "ScreenSpaceReflectionPostProcess" string
  161408. */
  161409. getClassName(): string;
  161410. /**
  161411. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  161412. * @param name The name of the effect.
  161413. * @param scene The scene containing the objects to calculate reflections.
  161414. * @param options The required width/height ratio to downsize to before computing the render pass.
  161415. * @param camera The camera to apply the render pass to.
  161416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  161417. * @param engine The engine which the post process will be applied. (default: current engine)
  161418. * @param reusable If the post process can be reused on the same frame. (default: false)
  161419. * @param textureType Type of textures used when performing the post process. (default: 0)
  161420. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  161421. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  161422. */
  161423. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  161424. /**
  161425. * Gets whether or not smoothing reflections is enabled.
  161426. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  161427. */
  161428. get enableSmoothReflections(): boolean;
  161429. /**
  161430. * Sets whether or not smoothing reflections is enabled.
  161431. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  161432. */
  161433. set enableSmoothReflections(enabled: boolean);
  161434. /**
  161435. * Gets the number of samples taken while computing reflections. More samples count is high,
  161436. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  161437. */
  161438. get reflectionSamples(): number;
  161439. /**
  161440. * Sets the number of samples taken while computing reflections. More samples count is high,
  161441. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  161442. */
  161443. set reflectionSamples(samples: number);
  161444. /**
  161445. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  161446. * more the post-process will require GPU power and can generate a drop in FPS.
  161447. * Default value (5.0) work pretty well in all cases but can be adjusted.
  161448. */
  161449. get smoothSteps(): number;
  161450. set smoothSteps(steps: number);
  161451. private _updateEffectDefines;
  161452. /** @hidden */
  161453. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  161454. }
  161455. }
  161456. declare module BABYLON {
  161457. /** @hidden */
  161458. export var standardPixelShader: {
  161459. name: string;
  161460. shader: string;
  161461. };
  161462. }
  161463. declare module BABYLON {
  161464. /**
  161465. * Standard rendering pipeline
  161466. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  161467. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  161468. */
  161469. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  161470. /**
  161471. * Public members
  161472. */
  161473. /**
  161474. * Post-process which contains the original scene color before the pipeline applies all the effects
  161475. */
  161476. originalPostProcess: Nullable<PostProcess>;
  161477. /**
  161478. * Post-process used to down scale an image x4
  161479. */
  161480. downSampleX4PostProcess: Nullable<PostProcess>;
  161481. /**
  161482. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  161483. */
  161484. brightPassPostProcess: Nullable<PostProcess>;
  161485. /**
  161486. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  161487. */
  161488. blurHPostProcesses: PostProcess[];
  161489. /**
  161490. * Post-process array storing all the vertical blur post-processes used by the pipeline
  161491. */
  161492. blurVPostProcesses: PostProcess[];
  161493. /**
  161494. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  161495. */
  161496. textureAdderPostProcess: Nullable<PostProcess>;
  161497. /**
  161498. * Post-process used to create volumetric lighting effect
  161499. */
  161500. volumetricLightPostProcess: Nullable<PostProcess>;
  161501. /**
  161502. * Post-process used to smooth the previous volumetric light post-process on the X axis
  161503. */
  161504. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  161505. /**
  161506. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  161507. */
  161508. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  161509. /**
  161510. * Post-process used to merge the volumetric light effect and the real scene color
  161511. */
  161512. volumetricLightMergePostProces: Nullable<PostProcess>;
  161513. /**
  161514. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  161515. */
  161516. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  161517. /**
  161518. * Base post-process used to calculate the average luminance of the final image for HDR
  161519. */
  161520. luminancePostProcess: Nullable<PostProcess>;
  161521. /**
  161522. * Post-processes used to create down sample post-processes in order to get
  161523. * the average luminance of the final image for HDR
  161524. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  161525. */
  161526. luminanceDownSamplePostProcesses: PostProcess[];
  161527. /**
  161528. * Post-process used to create a HDR effect (light adaptation)
  161529. */
  161530. hdrPostProcess: Nullable<PostProcess>;
  161531. /**
  161532. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  161533. */
  161534. textureAdderFinalPostProcess: Nullable<PostProcess>;
  161535. /**
  161536. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  161537. */
  161538. lensFlareFinalPostProcess: Nullable<PostProcess>;
  161539. /**
  161540. * Post-process used to merge the final HDR post-process and the real scene color
  161541. */
  161542. hdrFinalPostProcess: Nullable<PostProcess>;
  161543. /**
  161544. * Post-process used to create a lens flare effect
  161545. */
  161546. lensFlarePostProcess: Nullable<PostProcess>;
  161547. /**
  161548. * Post-process that merges the result of the lens flare post-process and the real scene color
  161549. */
  161550. lensFlareComposePostProcess: Nullable<PostProcess>;
  161551. /**
  161552. * Post-process used to create a motion blur effect
  161553. */
  161554. motionBlurPostProcess: Nullable<PostProcess>;
  161555. /**
  161556. * Post-process used to create a depth of field effect
  161557. */
  161558. depthOfFieldPostProcess: Nullable<PostProcess>;
  161559. /**
  161560. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  161561. */
  161562. fxaaPostProcess: Nullable<FxaaPostProcess>;
  161563. /**
  161564. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  161565. */
  161566. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  161567. /**
  161568. * Represents the brightness threshold in order to configure the illuminated surfaces
  161569. */
  161570. brightThreshold: number;
  161571. /**
  161572. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  161573. */
  161574. blurWidth: number;
  161575. /**
  161576. * Sets if the blur for highlighted surfaces must be only horizontal
  161577. */
  161578. horizontalBlur: boolean;
  161579. /**
  161580. * Gets the overall exposure used by the pipeline
  161581. */
  161582. get exposure(): number;
  161583. /**
  161584. * Sets the overall exposure used by the pipeline
  161585. */
  161586. set exposure(value: number);
  161587. /**
  161588. * Texture used typically to simulate "dirty" on camera lens
  161589. */
  161590. lensTexture: Nullable<Texture>;
  161591. /**
  161592. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  161593. */
  161594. volumetricLightCoefficient: number;
  161595. /**
  161596. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  161597. */
  161598. volumetricLightPower: number;
  161599. /**
  161600. * Used the set the blur intensity to smooth the volumetric lights
  161601. */
  161602. volumetricLightBlurScale: number;
  161603. /**
  161604. * Light (spot or directional) used to generate the volumetric lights rays
  161605. * The source light must have a shadow generate so the pipeline can get its
  161606. * depth map
  161607. */
  161608. sourceLight: Nullable<SpotLight | DirectionalLight>;
  161609. /**
  161610. * For eye adaptation, represents the minimum luminance the eye can see
  161611. */
  161612. hdrMinimumLuminance: number;
  161613. /**
  161614. * For eye adaptation, represents the decrease luminance speed
  161615. */
  161616. hdrDecreaseRate: number;
  161617. /**
  161618. * For eye adaptation, represents the increase luminance speed
  161619. */
  161620. hdrIncreaseRate: number;
  161621. /**
  161622. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  161623. */
  161624. get hdrAutoExposure(): boolean;
  161625. /**
  161626. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  161627. */
  161628. set hdrAutoExposure(value: boolean);
  161629. /**
  161630. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  161631. */
  161632. lensColorTexture: Nullable<Texture>;
  161633. /**
  161634. * The overall strengh for the lens flare effect
  161635. */
  161636. lensFlareStrength: number;
  161637. /**
  161638. * Dispersion coefficient for lens flare ghosts
  161639. */
  161640. lensFlareGhostDispersal: number;
  161641. /**
  161642. * Main lens flare halo width
  161643. */
  161644. lensFlareHaloWidth: number;
  161645. /**
  161646. * Based on the lens distortion effect, defines how much the lens flare result
  161647. * is distorted
  161648. */
  161649. lensFlareDistortionStrength: number;
  161650. /**
  161651. * Configures the blur intensity used for for lens flare (halo)
  161652. */
  161653. lensFlareBlurWidth: number;
  161654. /**
  161655. * Lens star texture must be used to simulate rays on the flares and is available
  161656. * in the documentation
  161657. */
  161658. lensStarTexture: Nullable<Texture>;
  161659. /**
  161660. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  161661. * flare effect by taking account of the dirt texture
  161662. */
  161663. lensFlareDirtTexture: Nullable<Texture>;
  161664. /**
  161665. * Represents the focal length for the depth of field effect
  161666. */
  161667. depthOfFieldDistance: number;
  161668. /**
  161669. * Represents the blur intensity for the blurred part of the depth of field effect
  161670. */
  161671. depthOfFieldBlurWidth: number;
  161672. /**
  161673. * Gets how much the image is blurred by the movement while using the motion blur post-process
  161674. */
  161675. get motionStrength(): number;
  161676. /**
  161677. * Sets how much the image is blurred by the movement while using the motion blur post-process
  161678. */
  161679. set motionStrength(strength: number);
  161680. /**
  161681. * Gets whether or not the motion blur post-process is object based or screen based.
  161682. */
  161683. get objectBasedMotionBlur(): boolean;
  161684. /**
  161685. * Sets whether or not the motion blur post-process should be object based or screen based
  161686. */
  161687. set objectBasedMotionBlur(value: boolean);
  161688. /**
  161689. * List of animations for the pipeline (IAnimatable implementation)
  161690. */
  161691. animations: Animation[];
  161692. /**
  161693. * Private members
  161694. */
  161695. private _scene;
  161696. private _currentDepthOfFieldSource;
  161697. private _basePostProcess;
  161698. private _fixedExposure;
  161699. private _currentExposure;
  161700. private _hdrAutoExposure;
  161701. private _hdrCurrentLuminance;
  161702. private _motionStrength;
  161703. private _isObjectBasedMotionBlur;
  161704. private _floatTextureType;
  161705. private _camerasToBeAttached;
  161706. private _ratio;
  161707. private _bloomEnabled;
  161708. private _depthOfFieldEnabled;
  161709. private _vlsEnabled;
  161710. private _lensFlareEnabled;
  161711. private _hdrEnabled;
  161712. private _motionBlurEnabled;
  161713. private _fxaaEnabled;
  161714. private _screenSpaceReflectionsEnabled;
  161715. private _motionBlurSamples;
  161716. private _volumetricLightStepsCount;
  161717. private _samples;
  161718. /**
  161719. * @ignore
  161720. * Specifies if the bloom pipeline is enabled
  161721. */
  161722. get BloomEnabled(): boolean;
  161723. set BloomEnabled(enabled: boolean);
  161724. /**
  161725. * @ignore
  161726. * Specifies if the depth of field pipeline is enabled
  161727. */
  161728. get DepthOfFieldEnabled(): boolean;
  161729. set DepthOfFieldEnabled(enabled: boolean);
  161730. /**
  161731. * @ignore
  161732. * Specifies if the lens flare pipeline is enabled
  161733. */
  161734. get LensFlareEnabled(): boolean;
  161735. set LensFlareEnabled(enabled: boolean);
  161736. /**
  161737. * @ignore
  161738. * Specifies if the HDR pipeline is enabled
  161739. */
  161740. get HDREnabled(): boolean;
  161741. set HDREnabled(enabled: boolean);
  161742. /**
  161743. * @ignore
  161744. * Specifies if the volumetric lights scattering effect is enabled
  161745. */
  161746. get VLSEnabled(): boolean;
  161747. set VLSEnabled(enabled: boolean);
  161748. /**
  161749. * @ignore
  161750. * Specifies if the motion blur effect is enabled
  161751. */
  161752. get MotionBlurEnabled(): boolean;
  161753. set MotionBlurEnabled(enabled: boolean);
  161754. /**
  161755. * Specifies if anti-aliasing is enabled
  161756. */
  161757. get fxaaEnabled(): boolean;
  161758. set fxaaEnabled(enabled: boolean);
  161759. /**
  161760. * Specifies if screen space reflections are enabled.
  161761. */
  161762. get screenSpaceReflectionsEnabled(): boolean;
  161763. set screenSpaceReflectionsEnabled(enabled: boolean);
  161764. /**
  161765. * Specifies the number of steps used to calculate the volumetric lights
  161766. * Typically in interval [50, 200]
  161767. */
  161768. get volumetricLightStepsCount(): number;
  161769. set volumetricLightStepsCount(count: number);
  161770. /**
  161771. * Specifies the number of samples used for the motion blur effect
  161772. * Typically in interval [16, 64]
  161773. */
  161774. get motionBlurSamples(): number;
  161775. set motionBlurSamples(samples: number);
  161776. /**
  161777. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  161778. */
  161779. get samples(): number;
  161780. set samples(sampleCount: number);
  161781. /**
  161782. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  161783. * @constructor
  161784. * @param name The rendering pipeline name
  161785. * @param scene The scene linked to this pipeline
  161786. * @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)
  161787. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  161788. * @param cameras The array of cameras that the rendering pipeline will be attached to
  161789. */
  161790. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  161791. private _buildPipeline;
  161792. private _createDownSampleX4PostProcess;
  161793. private _createBrightPassPostProcess;
  161794. private _createBlurPostProcesses;
  161795. private _createTextureAdderPostProcess;
  161796. private _createVolumetricLightPostProcess;
  161797. private _createLuminancePostProcesses;
  161798. private _createHdrPostProcess;
  161799. private _createLensFlarePostProcess;
  161800. private _createDepthOfFieldPostProcess;
  161801. private _createMotionBlurPostProcess;
  161802. private _getDepthTexture;
  161803. private _disposePostProcesses;
  161804. /**
  161805. * Dispose of the pipeline and stop all post processes
  161806. */
  161807. dispose(): void;
  161808. /**
  161809. * Serialize the rendering pipeline (Used when exporting)
  161810. * @returns the serialized object
  161811. */
  161812. serialize(): any;
  161813. /**
  161814. * Parse the serialized pipeline
  161815. * @param source Source pipeline.
  161816. * @param scene The scene to load the pipeline to.
  161817. * @param rootUrl The URL of the serialized pipeline.
  161818. * @returns An instantiated pipeline from the serialized object.
  161819. */
  161820. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  161821. /**
  161822. * Luminance steps
  161823. */
  161824. static LuminanceSteps: number;
  161825. }
  161826. }
  161827. declare module BABYLON {
  161828. /** @hidden */
  161829. export var tonemapPixelShader: {
  161830. name: string;
  161831. shader: string;
  161832. };
  161833. }
  161834. declare module BABYLON {
  161835. /** Defines operator used for tonemapping */
  161836. export enum TonemappingOperator {
  161837. /** Hable */
  161838. Hable = 0,
  161839. /** Reinhard */
  161840. Reinhard = 1,
  161841. /** HejiDawson */
  161842. HejiDawson = 2,
  161843. /** Photographic */
  161844. Photographic = 3
  161845. }
  161846. /**
  161847. * Defines a post process to apply tone mapping
  161848. */
  161849. export class TonemapPostProcess extends PostProcess {
  161850. private _operator;
  161851. /** Defines the required exposure adjustment */
  161852. exposureAdjustment: number;
  161853. /**
  161854. * Gets a string identifying the name of the class
  161855. * @returns "TonemapPostProcess" string
  161856. */
  161857. getClassName(): string;
  161858. /**
  161859. * Creates a new TonemapPostProcess
  161860. * @param name defines the name of the postprocess
  161861. * @param _operator defines the operator to use
  161862. * @param exposureAdjustment defines the required exposure adjustement
  161863. * @param camera defines the camera to use (can be null)
  161864. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  161865. * @param engine defines the hosting engine (can be ignore if camera is set)
  161866. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  161867. */
  161868. constructor(name: string, _operator: TonemappingOperator,
  161869. /** Defines the required exposure adjustment */
  161870. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  161871. }
  161872. }
  161873. declare module BABYLON {
  161874. /** @hidden */
  161875. export var volumetricLightScatteringPixelShader: {
  161876. name: string;
  161877. shader: string;
  161878. };
  161879. }
  161880. declare module BABYLON {
  161881. /** @hidden */
  161882. export var volumetricLightScatteringPassVertexShader: {
  161883. name: string;
  161884. shader: string;
  161885. };
  161886. }
  161887. declare module BABYLON {
  161888. /** @hidden */
  161889. export var volumetricLightScatteringPassPixelShader: {
  161890. name: string;
  161891. shader: string;
  161892. };
  161893. }
  161894. declare module BABYLON {
  161895. /**
  161896. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  161897. */
  161898. export class VolumetricLightScatteringPostProcess extends PostProcess {
  161899. private _volumetricLightScatteringPass;
  161900. private _volumetricLightScatteringRTT;
  161901. private _viewPort;
  161902. private _screenCoordinates;
  161903. private _cachedDefines;
  161904. /**
  161905. * If not undefined, the mesh position is computed from the attached node position
  161906. */
  161907. attachedNode: {
  161908. position: Vector3;
  161909. };
  161910. /**
  161911. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  161912. */
  161913. customMeshPosition: Vector3;
  161914. /**
  161915. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  161916. */
  161917. useCustomMeshPosition: boolean;
  161918. /**
  161919. * If the post-process should inverse the light scattering direction
  161920. */
  161921. invert: boolean;
  161922. /**
  161923. * The internal mesh used by the post-process
  161924. */
  161925. mesh: Mesh;
  161926. /**
  161927. * @hidden
  161928. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  161929. */
  161930. get useDiffuseColor(): boolean;
  161931. set useDiffuseColor(useDiffuseColor: boolean);
  161932. /**
  161933. * Array containing the excluded meshes not rendered in the internal pass
  161934. */
  161935. excludedMeshes: AbstractMesh[];
  161936. /**
  161937. * Controls the overall intensity of the post-process
  161938. */
  161939. exposure: number;
  161940. /**
  161941. * Dissipates each sample's contribution in range [0, 1]
  161942. */
  161943. decay: number;
  161944. /**
  161945. * Controls the overall intensity of each sample
  161946. */
  161947. weight: number;
  161948. /**
  161949. * Controls the density of each sample
  161950. */
  161951. density: number;
  161952. /**
  161953. * @constructor
  161954. * @param name The post-process name
  161955. * @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)
  161956. * @param camera The camera that the post-process will be attached to
  161957. * @param mesh The mesh used to create the light scattering
  161958. * @param samples The post-process quality, default 100
  161959. * @param samplingModeThe post-process filtering mode
  161960. * @param engine The babylon engine
  161961. * @param reusable If the post-process is reusable
  161962. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  161963. */
  161964. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  161965. /**
  161966. * Returns the string "VolumetricLightScatteringPostProcess"
  161967. * @returns "VolumetricLightScatteringPostProcess"
  161968. */
  161969. getClassName(): string;
  161970. private _isReady;
  161971. /**
  161972. * Sets the new light position for light scattering effect
  161973. * @param position The new custom light position
  161974. */
  161975. setCustomMeshPosition(position: Vector3): void;
  161976. /**
  161977. * Returns the light position for light scattering effect
  161978. * @return Vector3 The custom light position
  161979. */
  161980. getCustomMeshPosition(): Vector3;
  161981. /**
  161982. * Disposes the internal assets and detaches the post-process from the camera
  161983. */
  161984. dispose(camera: Camera): void;
  161985. /**
  161986. * Returns the render target texture used by the post-process
  161987. * @return the render target texture used by the post-process
  161988. */
  161989. getPass(): RenderTargetTexture;
  161990. private _meshExcluded;
  161991. private _createPass;
  161992. private _updateMeshScreenCoordinates;
  161993. /**
  161994. * Creates a default mesh for the Volumeric Light Scattering post-process
  161995. * @param name The mesh name
  161996. * @param scene The scene where to create the mesh
  161997. * @return the default mesh
  161998. */
  161999. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  162000. }
  162001. }
  162002. declare module BABYLON {
  162003. /** @hidden */
  162004. export var screenSpaceCurvaturePixelShader: {
  162005. name: string;
  162006. shader: string;
  162007. };
  162008. }
  162009. declare module BABYLON {
  162010. /**
  162011. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  162012. */
  162013. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  162014. /**
  162015. * Defines how much ridge the curvature effect displays.
  162016. */
  162017. ridge: number;
  162018. /**
  162019. * Defines how much valley the curvature effect displays.
  162020. */
  162021. valley: number;
  162022. private _geometryBufferRenderer;
  162023. /**
  162024. * Gets a string identifying the name of the class
  162025. * @returns "ScreenSpaceCurvaturePostProcess" string
  162026. */
  162027. getClassName(): string;
  162028. /**
  162029. * Creates a new instance ScreenSpaceCurvaturePostProcess
  162030. * @param name The name of the effect.
  162031. * @param scene The scene containing the objects to blur according to their velocity.
  162032. * @param options The required width/height ratio to downsize to before computing the render pass.
  162033. * @param camera The camera to apply the render pass to.
  162034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  162035. * @param engine The engine which the post process will be applied. (default: current engine)
  162036. * @param reusable If the post process can be reused on the same frame. (default: false)
  162037. * @param textureType Type of textures used when performing the post process. (default: 0)
  162038. * @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)
  162039. */
  162040. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  162041. /**
  162042. * Support test.
  162043. */
  162044. static get IsSupported(): boolean;
  162045. /** @hidden */
  162046. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  162047. }
  162048. }
  162049. declare module BABYLON {
  162050. interface Scene {
  162051. /** @hidden (Backing field) */
  162052. _boundingBoxRenderer: BoundingBoxRenderer;
  162053. /** @hidden (Backing field) */
  162054. _forceShowBoundingBoxes: boolean;
  162055. /**
  162056. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  162057. */
  162058. forceShowBoundingBoxes: boolean;
  162059. /**
  162060. * Gets the bounding box renderer associated with the scene
  162061. * @returns a BoundingBoxRenderer
  162062. */
  162063. getBoundingBoxRenderer(): BoundingBoxRenderer;
  162064. }
  162065. interface AbstractMesh {
  162066. /** @hidden (Backing field) */
  162067. _showBoundingBox: boolean;
  162068. /**
  162069. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  162070. */
  162071. showBoundingBox: boolean;
  162072. }
  162073. /**
  162074. * Component responsible of rendering the bounding box of the meshes in a scene.
  162075. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  162076. */
  162077. export class BoundingBoxRenderer implements ISceneComponent {
  162078. /**
  162079. * The component name helpful to identify the component in the list of scene components.
  162080. */
  162081. readonly name: string;
  162082. /**
  162083. * The scene the component belongs to.
  162084. */
  162085. scene: Scene;
  162086. /**
  162087. * Color of the bounding box lines placed in front of an object
  162088. */
  162089. frontColor: Color3;
  162090. /**
  162091. * Color of the bounding box lines placed behind an object
  162092. */
  162093. backColor: Color3;
  162094. /**
  162095. * Defines if the renderer should show the back lines or not
  162096. */
  162097. showBackLines: boolean;
  162098. /**
  162099. * Observable raised before rendering a bounding box
  162100. */
  162101. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  162102. /**
  162103. * Observable raised after rendering a bounding box
  162104. */
  162105. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  162106. /**
  162107. * Observable raised after resources are created
  162108. */
  162109. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  162110. /**
  162111. * When false, no bounding boxes will be rendered
  162112. */
  162113. enabled: boolean;
  162114. /**
  162115. * @hidden
  162116. */
  162117. renderList: SmartArray<BoundingBox>;
  162118. private _colorShader;
  162119. private _vertexBuffers;
  162120. private _indexBuffer;
  162121. private _fillIndexBuffer;
  162122. private _fillIndexData;
  162123. /**
  162124. * Instantiates a new bounding box renderer in a scene.
  162125. * @param scene the scene the renderer renders in
  162126. */
  162127. constructor(scene: Scene);
  162128. /**
  162129. * Registers the component in a given scene
  162130. */
  162131. register(): void;
  162132. private _evaluateSubMesh;
  162133. private _preActiveMesh;
  162134. private _prepareResources;
  162135. private _createIndexBuffer;
  162136. /**
  162137. * Rebuilds the elements related to this component in case of
  162138. * context lost for instance.
  162139. */
  162140. rebuild(): void;
  162141. /**
  162142. * @hidden
  162143. */
  162144. reset(): void;
  162145. /**
  162146. * Render the bounding boxes of a specific rendering group
  162147. * @param renderingGroupId defines the rendering group to render
  162148. */
  162149. render(renderingGroupId: number): void;
  162150. /**
  162151. * In case of occlusion queries, we can render the occlusion bounding box through this method
  162152. * @param mesh Define the mesh to render the occlusion bounding box for
  162153. */
  162154. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  162155. /**
  162156. * Dispose and release the resources attached to this renderer.
  162157. */
  162158. dispose(): void;
  162159. }
  162160. }
  162161. declare module BABYLON {
  162162. interface Scene {
  162163. /** @hidden (Backing field) */
  162164. _depthRenderer: {
  162165. [id: string]: DepthRenderer;
  162166. };
  162167. /**
  162168. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  162169. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  162170. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  162171. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  162172. * @returns the created depth renderer
  162173. */
  162174. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  162175. /**
  162176. * Disables a depth renderer for a given camera
  162177. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  162178. */
  162179. disableDepthRenderer(camera?: Nullable<Camera>): void;
  162180. }
  162181. /**
  162182. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  162183. * in several rendering techniques.
  162184. */
  162185. export class DepthRendererSceneComponent implements ISceneComponent {
  162186. /**
  162187. * The component name helpful to identify the component in the list of scene components.
  162188. */
  162189. readonly name: string;
  162190. /**
  162191. * The scene the component belongs to.
  162192. */
  162193. scene: Scene;
  162194. /**
  162195. * Creates a new instance of the component for the given scene
  162196. * @param scene Defines the scene to register the component in
  162197. */
  162198. constructor(scene: Scene);
  162199. /**
  162200. * Registers the component in a given scene
  162201. */
  162202. register(): void;
  162203. /**
  162204. * Rebuilds the elements related to this component in case of
  162205. * context lost for instance.
  162206. */
  162207. rebuild(): void;
  162208. /**
  162209. * Disposes the component and the associated resources
  162210. */
  162211. dispose(): void;
  162212. private _gatherRenderTargets;
  162213. private _gatherActiveCameraRenderTargets;
  162214. }
  162215. }
  162216. declare module BABYLON {
  162217. interface AbstractScene {
  162218. /** @hidden (Backing field) */
  162219. _prePassRenderer: Nullable<PrePassRenderer>;
  162220. /**
  162221. * Gets or Sets the current prepass renderer associated to the scene.
  162222. */
  162223. prePassRenderer: Nullable<PrePassRenderer>;
  162224. /**
  162225. * Enables the prepass and associates it with the scene
  162226. * @returns the PrePassRenderer
  162227. */
  162228. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  162229. /**
  162230. * Disables the prepass associated with the scene
  162231. */
  162232. disablePrePassRenderer(): void;
  162233. }
  162234. interface RenderTargetTexture {
  162235. /** @hidden */
  162236. _prePassRenderTarget: PrePassRenderTarget;
  162237. }
  162238. /**
  162239. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  162240. * in several rendering techniques.
  162241. */
  162242. export class PrePassRendererSceneComponent implements ISceneComponent {
  162243. /**
  162244. * The component name helpful to identify the component in the list of scene components.
  162245. */
  162246. readonly name: string;
  162247. /**
  162248. * The scene the component belongs to.
  162249. */
  162250. scene: Scene;
  162251. /**
  162252. * Creates a new instance of the component for the given scene
  162253. * @param scene Defines the scene to register the component in
  162254. */
  162255. constructor(scene: Scene);
  162256. /**
  162257. * Registers the component in a given scene
  162258. */
  162259. register(): void;
  162260. private _beforeRenderTargetDraw;
  162261. private _afterRenderTargetDraw;
  162262. private _beforeRenderTargetClearStage;
  162263. private _beforeCameraDraw;
  162264. private _afterCameraDraw;
  162265. private _beforeClearStage;
  162266. private _beforeRenderingMeshStage;
  162267. private _afterRenderingMeshStage;
  162268. /**
  162269. * Rebuilds the elements related to this component in case of
  162270. * context lost for instance.
  162271. */
  162272. rebuild(): void;
  162273. /**
  162274. * Disposes the component and the associated resources
  162275. */
  162276. dispose(): void;
  162277. }
  162278. }
  162279. declare module BABYLON {
  162280. /** @hidden */
  162281. export var fibonacci: {
  162282. name: string;
  162283. shader: string;
  162284. };
  162285. }
  162286. declare module BABYLON {
  162287. /** @hidden */
  162288. export var diffusionProfile: {
  162289. name: string;
  162290. shader: string;
  162291. };
  162292. }
  162293. declare module BABYLON {
  162294. /** @hidden */
  162295. export var subSurfaceScatteringPixelShader: {
  162296. name: string;
  162297. shader: string;
  162298. };
  162299. }
  162300. declare module BABYLON {
  162301. /**
  162302. * Sub surface scattering post process
  162303. */
  162304. export class SubSurfaceScatteringPostProcess extends PostProcess {
  162305. /**
  162306. * Gets a string identifying the name of the class
  162307. * @returns "SubSurfaceScatteringPostProcess" string
  162308. */
  162309. getClassName(): string;
  162310. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  162311. }
  162312. }
  162313. declare module BABYLON {
  162314. /**
  162315. * Contains all parameters needed for the prepass to perform
  162316. * screen space subsurface scattering
  162317. */
  162318. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  162319. /** @hidden */
  162320. static _SceneComponentInitialization: (scene: Scene) => void;
  162321. private _ssDiffusionS;
  162322. private _ssFilterRadii;
  162323. private _ssDiffusionD;
  162324. /**
  162325. * Post process to attach for screen space subsurface scattering
  162326. */
  162327. postProcess: SubSurfaceScatteringPostProcess;
  162328. /**
  162329. * Diffusion profile color for subsurface scattering
  162330. */
  162331. get ssDiffusionS(): number[];
  162332. /**
  162333. * Diffusion profile max color channel value for subsurface scattering
  162334. */
  162335. get ssDiffusionD(): number[];
  162336. /**
  162337. * Diffusion profile filter radius for subsurface scattering
  162338. */
  162339. get ssFilterRadii(): number[];
  162340. /**
  162341. * Is subsurface enabled
  162342. */
  162343. enabled: boolean;
  162344. /**
  162345. * Does the output of this prepass need to go through imageprocessing
  162346. */
  162347. needsImageProcessing: boolean;
  162348. /**
  162349. * Name of the configuration
  162350. */
  162351. name: string;
  162352. /**
  162353. * Diffusion profile colors for subsurface scattering
  162354. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  162355. * See ...
  162356. * Note that you can only store up to 5 of them
  162357. */
  162358. ssDiffusionProfileColors: Color3[];
  162359. /**
  162360. * Defines the ratio real world => scene units.
  162361. * Used for subsurface scattering
  162362. */
  162363. metersPerUnit: number;
  162364. /**
  162365. * Textures that should be present in the MRT for this effect to work
  162366. */
  162367. readonly texturesRequired: number[];
  162368. private _scene;
  162369. /**
  162370. * Builds a subsurface configuration object
  162371. * @param scene The scene
  162372. */
  162373. constructor(scene: Scene);
  162374. /**
  162375. * Adds a new diffusion profile.
  162376. * Useful for more realistic subsurface scattering on diverse materials.
  162377. * @param color The color of the diffusion profile. Should be the average color of the material.
  162378. * @return The index of the diffusion profile for the material subsurface configuration
  162379. */
  162380. addDiffusionProfile(color: Color3): number;
  162381. /**
  162382. * Creates the sss post process
  162383. * @return The created post process
  162384. */
  162385. createPostProcess(): SubSurfaceScatteringPostProcess;
  162386. /**
  162387. * Deletes all diffusion profiles.
  162388. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  162389. */
  162390. clearAllDiffusionProfiles(): void;
  162391. /**
  162392. * Disposes this object
  162393. */
  162394. dispose(): void;
  162395. /**
  162396. * @hidden
  162397. * https://zero-radiance.github.io/post/sampling-diffusion/
  162398. *
  162399. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  162400. * ------------------------------------------------------------------------------------
  162401. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  162402. * PDF[r, phi, s] = r * R[r, phi, s]
  162403. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  162404. * ------------------------------------------------------------------------------------
  162405. * We importance sample the color channel with the widest scattering distance.
  162406. */
  162407. getDiffusionProfileParameters(color: Color3): number;
  162408. /**
  162409. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  162410. * 'u' is the random number (the value of the CDF): [0, 1).
  162411. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  162412. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  162413. */
  162414. private _sampleBurleyDiffusionProfile;
  162415. }
  162416. }
  162417. declare module BABYLON {
  162418. interface AbstractScene {
  162419. /** @hidden (Backing field) */
  162420. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  162421. /**
  162422. * Gets or Sets the current prepass renderer associated to the scene.
  162423. */
  162424. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  162425. /**
  162426. * Enables the subsurface effect for prepass
  162427. * @returns the SubSurfaceConfiguration
  162428. */
  162429. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  162430. /**
  162431. * Disables the subsurface effect for prepass
  162432. */
  162433. disableSubSurfaceForPrePass(): void;
  162434. }
  162435. /**
  162436. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  162437. * in several rendering techniques.
  162438. */
  162439. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  162440. /**
  162441. * The component name helpful to identify the component in the list of scene components.
  162442. */
  162443. readonly name: string;
  162444. /**
  162445. * The scene the component belongs to.
  162446. */
  162447. scene: Scene;
  162448. /**
  162449. * Creates a new instance of the component for the given scene
  162450. * @param scene Defines the scene to register the component in
  162451. */
  162452. constructor(scene: Scene);
  162453. /**
  162454. * Registers the component in a given scene
  162455. */
  162456. register(): void;
  162457. /**
  162458. * Serializes the component data to the specified json object
  162459. * @param serializationObject The object to serialize to
  162460. */
  162461. serialize(serializationObject: any): void;
  162462. /**
  162463. * Adds all the elements from the container to the scene
  162464. * @param container the container holding the elements
  162465. */
  162466. addFromContainer(container: AbstractScene): void;
  162467. /**
  162468. * Removes all the elements in the container from the scene
  162469. * @param container contains the elements to remove
  162470. * @param dispose if the removed element should be disposed (default: false)
  162471. */
  162472. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  162473. /**
  162474. * Rebuilds the elements related to this component in case of
  162475. * context lost for instance.
  162476. */
  162477. rebuild(): void;
  162478. /**
  162479. * Disposes the component and the associated resources
  162480. */
  162481. dispose(): void;
  162482. }
  162483. }
  162484. declare module BABYLON {
  162485. /** @hidden */
  162486. export var outlinePixelShader: {
  162487. name: string;
  162488. shader: string;
  162489. };
  162490. }
  162491. declare module BABYLON {
  162492. /** @hidden */
  162493. export var outlineVertexShader: {
  162494. name: string;
  162495. shader: string;
  162496. };
  162497. }
  162498. declare module BABYLON {
  162499. interface Scene {
  162500. /** @hidden */
  162501. _outlineRenderer: OutlineRenderer;
  162502. /**
  162503. * Gets the outline renderer associated with the scene
  162504. * @returns a OutlineRenderer
  162505. */
  162506. getOutlineRenderer(): OutlineRenderer;
  162507. }
  162508. interface AbstractMesh {
  162509. /** @hidden (Backing field) */
  162510. _renderOutline: boolean;
  162511. /**
  162512. * Gets or sets a boolean indicating if the outline must be rendered as well
  162513. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  162514. */
  162515. renderOutline: boolean;
  162516. /** @hidden (Backing field) */
  162517. _renderOverlay: boolean;
  162518. /**
  162519. * Gets or sets a boolean indicating if the overlay must be rendered as well
  162520. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  162521. */
  162522. renderOverlay: boolean;
  162523. }
  162524. /**
  162525. * This class is responsible to draw the outline/overlay of meshes.
  162526. * It should not be used directly but through the available method on mesh.
  162527. */
  162528. export class OutlineRenderer implements ISceneComponent {
  162529. /**
  162530. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  162531. */
  162532. private static _StencilReference;
  162533. /**
  162534. * The name of the component. Each component must have a unique name.
  162535. */
  162536. name: string;
  162537. /**
  162538. * The scene the component belongs to.
  162539. */
  162540. scene: Scene;
  162541. /**
  162542. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  162543. */
  162544. zOffset: number;
  162545. private _engine;
  162546. private _effect;
  162547. private _cachedDefines;
  162548. private _savedDepthWrite;
  162549. /**
  162550. * Instantiates a new outline renderer. (There could be only one per scene).
  162551. * @param scene Defines the scene it belongs to
  162552. */
  162553. constructor(scene: Scene);
  162554. /**
  162555. * Register the component to one instance of a scene.
  162556. */
  162557. register(): void;
  162558. /**
  162559. * Rebuilds the elements related to this component in case of
  162560. * context lost for instance.
  162561. */
  162562. rebuild(): void;
  162563. /**
  162564. * Disposes the component and the associated resources.
  162565. */
  162566. dispose(): void;
  162567. /**
  162568. * Renders the outline in the canvas.
  162569. * @param subMesh Defines the sumesh to render
  162570. * @param batch Defines the batch of meshes in case of instances
  162571. * @param useOverlay Defines if the rendering is for the overlay or the outline
  162572. */
  162573. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  162574. /**
  162575. * Returns whether or not the outline renderer is ready for a given submesh.
  162576. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  162577. * @param subMesh Defines the submesh to check readiness for
  162578. * @param useInstances Defines whether wee are trying to render instances or not
  162579. * @returns true if ready otherwise false
  162580. */
  162581. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  162582. private _beforeRenderingMesh;
  162583. private _afterRenderingMesh;
  162584. }
  162585. }
  162586. declare module BABYLON {
  162587. /**
  162588. * Defines the basic options interface of a Sprite Frame Source Size.
  162589. */
  162590. export interface ISpriteJSONSpriteSourceSize {
  162591. /**
  162592. * number of the original width of the Frame
  162593. */
  162594. w: number;
  162595. /**
  162596. * number of the original height of the Frame
  162597. */
  162598. h: number;
  162599. }
  162600. /**
  162601. * Defines the basic options interface of a Sprite Frame Data.
  162602. */
  162603. export interface ISpriteJSONSpriteFrameData {
  162604. /**
  162605. * number of the x offset of the Frame
  162606. */
  162607. x: number;
  162608. /**
  162609. * number of the y offset of the Frame
  162610. */
  162611. y: number;
  162612. /**
  162613. * number of the width of the Frame
  162614. */
  162615. w: number;
  162616. /**
  162617. * number of the height of the Frame
  162618. */
  162619. h: number;
  162620. }
  162621. /**
  162622. * Defines the basic options interface of a JSON Sprite.
  162623. */
  162624. export interface ISpriteJSONSprite {
  162625. /**
  162626. * string name of the Frame
  162627. */
  162628. filename: string;
  162629. /**
  162630. * ISpriteJSONSpriteFrame basic object of the frame data
  162631. */
  162632. frame: ISpriteJSONSpriteFrameData;
  162633. /**
  162634. * boolean to flag is the frame was rotated.
  162635. */
  162636. rotated: boolean;
  162637. /**
  162638. * boolean to flag is the frame was trimmed.
  162639. */
  162640. trimmed: boolean;
  162641. /**
  162642. * ISpriteJSONSpriteFrame basic object of the source data
  162643. */
  162644. spriteSourceSize: ISpriteJSONSpriteFrameData;
  162645. /**
  162646. * ISpriteJSONSpriteFrame basic object of the source data
  162647. */
  162648. sourceSize: ISpriteJSONSpriteSourceSize;
  162649. }
  162650. /**
  162651. * Defines the basic options interface of a JSON atlas.
  162652. */
  162653. export interface ISpriteJSONAtlas {
  162654. /**
  162655. * Array of objects that contain the frame data.
  162656. */
  162657. frames: Array<ISpriteJSONSprite>;
  162658. /**
  162659. * object basic object containing the sprite meta data.
  162660. */
  162661. meta?: object;
  162662. }
  162663. }
  162664. declare module BABYLON {
  162665. /** @hidden */
  162666. export var spriteMapPixelShader: {
  162667. name: string;
  162668. shader: string;
  162669. };
  162670. }
  162671. declare module BABYLON {
  162672. /** @hidden */
  162673. export var spriteMapVertexShader: {
  162674. name: string;
  162675. shader: string;
  162676. };
  162677. }
  162678. declare module BABYLON {
  162679. /**
  162680. * Defines the basic options interface of a SpriteMap
  162681. */
  162682. export interface ISpriteMapOptions {
  162683. /**
  162684. * Vector2 of the number of cells in the grid.
  162685. */
  162686. stageSize?: Vector2;
  162687. /**
  162688. * Vector2 of the size of the output plane in World Units.
  162689. */
  162690. outputSize?: Vector2;
  162691. /**
  162692. * Vector3 of the position of the output plane in World Units.
  162693. */
  162694. outputPosition?: Vector3;
  162695. /**
  162696. * Vector3 of the rotation of the output plane.
  162697. */
  162698. outputRotation?: Vector3;
  162699. /**
  162700. * number of layers that the system will reserve in resources.
  162701. */
  162702. layerCount?: number;
  162703. /**
  162704. * number of max animation frames a single cell will reserve in resources.
  162705. */
  162706. maxAnimationFrames?: number;
  162707. /**
  162708. * number cell index of the base tile when the system compiles.
  162709. */
  162710. baseTile?: number;
  162711. /**
  162712. * boolean flip the sprite after its been repositioned by the framing data.
  162713. */
  162714. flipU?: boolean;
  162715. /**
  162716. * Vector3 scalar of the global RGB values of the SpriteMap.
  162717. */
  162718. colorMultiply?: Vector3;
  162719. }
  162720. /**
  162721. * Defines the IDisposable interface in order to be cleanable from resources.
  162722. */
  162723. export interface ISpriteMap extends IDisposable {
  162724. /**
  162725. * String name of the SpriteMap.
  162726. */
  162727. name: string;
  162728. /**
  162729. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  162730. */
  162731. atlasJSON: ISpriteJSONAtlas;
  162732. /**
  162733. * Texture of the SpriteMap.
  162734. */
  162735. spriteSheet: Texture;
  162736. /**
  162737. * The parameters to initialize the SpriteMap with.
  162738. */
  162739. options: ISpriteMapOptions;
  162740. }
  162741. /**
  162742. * Class used to manage a grid restricted sprite deployment on an Output plane.
  162743. */
  162744. export class SpriteMap implements ISpriteMap {
  162745. /** The Name of the spriteMap */
  162746. name: string;
  162747. /** The JSON file with the frame and meta data */
  162748. atlasJSON: ISpriteJSONAtlas;
  162749. /** The systems Sprite Sheet Texture */
  162750. spriteSheet: Texture;
  162751. /** Arguments passed with the Constructor */
  162752. options: ISpriteMapOptions;
  162753. /** Public Sprite Storage array, parsed from atlasJSON */
  162754. sprites: Array<ISpriteJSONSprite>;
  162755. /** Returns the Number of Sprites in the System */
  162756. get spriteCount(): number;
  162757. /** Returns the Position of Output Plane*/
  162758. get position(): Vector3;
  162759. /** Returns the Position of Output Plane*/
  162760. set position(v: Vector3);
  162761. /** Returns the Rotation of Output Plane*/
  162762. get rotation(): Vector3;
  162763. /** Returns the Rotation of Output Plane*/
  162764. set rotation(v: Vector3);
  162765. /** Sets the AnimationMap*/
  162766. get animationMap(): RawTexture;
  162767. /** Sets the AnimationMap*/
  162768. set animationMap(v: RawTexture);
  162769. /** Scene that the SpriteMap was created in */
  162770. private _scene;
  162771. /** Texture Buffer of Float32 that holds tile frame data*/
  162772. private _frameMap;
  162773. /** Texture Buffers of Float32 that holds tileMap data*/
  162774. private _tileMaps;
  162775. /** Texture Buffer of Float32 that holds Animation Data*/
  162776. private _animationMap;
  162777. /** Custom ShaderMaterial Central to the System*/
  162778. private _material;
  162779. /** Custom ShaderMaterial Central to the System*/
  162780. private _output;
  162781. /** Systems Time Ticker*/
  162782. private _time;
  162783. /**
  162784. * Creates a new SpriteMap
  162785. * @param name defines the SpriteMaps Name
  162786. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  162787. * @param spriteSheet is the Texture that the Sprites are on.
  162788. * @param options a basic deployment configuration
  162789. * @param scene The Scene that the map is deployed on
  162790. */
  162791. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  162792. /**
  162793. * Returns tileID location
  162794. * @returns Vector2 the cell position ID
  162795. */
  162796. getTileID(): Vector2;
  162797. /**
  162798. * Gets the UV location of the mouse over the SpriteMap.
  162799. * @returns Vector2 the UV position of the mouse interaction
  162800. */
  162801. getMousePosition(): Vector2;
  162802. /**
  162803. * Creates the "frame" texture Buffer
  162804. * -------------------------------------
  162805. * Structure of frames
  162806. * "filename": "Falling-Water-2.png",
  162807. * "frame": {"x":69,"y":103,"w":24,"h":32},
  162808. * "rotated": true,
  162809. * "trimmed": true,
  162810. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  162811. * "sourceSize": {"w":32,"h":32}
  162812. * @returns RawTexture of the frameMap
  162813. */
  162814. private _createFrameBuffer;
  162815. /**
  162816. * Creates the tileMap texture Buffer
  162817. * @param buffer normally and array of numbers, or a false to generate from scratch
  162818. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  162819. * @returns RawTexture of the tileMap
  162820. */
  162821. private _createTileBuffer;
  162822. /**
  162823. * Modifies the data of the tileMaps
  162824. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  162825. * @param pos is the iVector2 Coordinates of the Tile
  162826. * @param tile The SpriteIndex of the new Tile
  162827. */
  162828. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  162829. /**
  162830. * Creates the animationMap texture Buffer
  162831. * @param buffer normally and array of numbers, or a false to generate from scratch
  162832. * @returns RawTexture of the animationMap
  162833. */
  162834. private _createTileAnimationBuffer;
  162835. /**
  162836. * Modifies the data of the animationMap
  162837. * @param cellID is the Index of the Sprite
  162838. * @param _frame is the target Animation frame
  162839. * @param toCell is the Target Index of the next frame of the animation
  162840. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  162841. * @param speed is a global scalar of the time variable on the map.
  162842. */
  162843. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  162844. /**
  162845. * Exports the .tilemaps file
  162846. */
  162847. saveTileMaps(): void;
  162848. /**
  162849. * Imports the .tilemaps file
  162850. * @param url of the .tilemaps file
  162851. */
  162852. loadTileMaps(url: string): void;
  162853. /**
  162854. * Release associated resources
  162855. */
  162856. dispose(): void;
  162857. }
  162858. }
  162859. declare module BABYLON {
  162860. /**
  162861. * Class used to manage multiple sprites of different sizes on the same spritesheet
  162862. * @see https://doc.babylonjs.com/babylon101/sprites
  162863. */
  162864. export class SpritePackedManager extends SpriteManager {
  162865. /** defines the packed manager's name */
  162866. name: string;
  162867. /**
  162868. * Creates a new sprite manager from a packed sprite sheet
  162869. * @param name defines the manager's name
  162870. * @param imgUrl defines the sprite sheet url
  162871. * @param capacity defines the maximum allowed number of sprites
  162872. * @param scene defines the hosting scene
  162873. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  162874. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  162875. * @param samplingMode defines the sampling mode to use with spritesheet
  162876. * @param fromPacked set to true; do not alter
  162877. */
  162878. constructor(
  162879. /** defines the packed manager's name */
  162880. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  162881. }
  162882. }
  162883. declare module BABYLON {
  162884. /**
  162885. * Defines the list of states available for a task inside a AssetsManager
  162886. */
  162887. export enum AssetTaskState {
  162888. /**
  162889. * Initialization
  162890. */
  162891. INIT = 0,
  162892. /**
  162893. * Running
  162894. */
  162895. RUNNING = 1,
  162896. /**
  162897. * Done
  162898. */
  162899. DONE = 2,
  162900. /**
  162901. * Error
  162902. */
  162903. ERROR = 3
  162904. }
  162905. /**
  162906. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  162907. */
  162908. export abstract class AbstractAssetTask {
  162909. /**
  162910. * Task name
  162911. */ name: string;
  162912. /**
  162913. * Callback called when the task is successful
  162914. */
  162915. onSuccess: (task: any) => void;
  162916. /**
  162917. * Callback called when the task is not successful
  162918. */
  162919. onError: (task: any, message?: string, exception?: any) => void;
  162920. /**
  162921. * Creates a new AssetsManager
  162922. * @param name defines the name of the task
  162923. */
  162924. constructor(
  162925. /**
  162926. * Task name
  162927. */ name: string);
  162928. private _isCompleted;
  162929. private _taskState;
  162930. private _errorObject;
  162931. /**
  162932. * Get if the task is completed
  162933. */
  162934. get isCompleted(): boolean;
  162935. /**
  162936. * Gets the current state of the task
  162937. */
  162938. get taskState(): AssetTaskState;
  162939. /**
  162940. * Gets the current error object (if task is in error)
  162941. */
  162942. get errorObject(): {
  162943. message?: string;
  162944. exception?: any;
  162945. };
  162946. /**
  162947. * Internal only
  162948. * @hidden
  162949. */
  162950. _setErrorObject(message?: string, exception?: any): void;
  162951. /**
  162952. * Execute the current task
  162953. * @param scene defines the scene where you want your assets to be loaded
  162954. * @param onSuccess is a callback called when the task is successfully executed
  162955. * @param onError is a callback called if an error occurs
  162956. */
  162957. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162958. /**
  162959. * Execute the current task
  162960. * @param scene defines the scene where you want your assets to be loaded
  162961. * @param onSuccess is a callback called when the task is successfully executed
  162962. * @param onError is a callback called if an error occurs
  162963. */
  162964. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  162965. /**
  162966. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  162967. * This can be used with failed tasks that have the reason for failure fixed.
  162968. */
  162969. reset(): void;
  162970. private onErrorCallback;
  162971. private onDoneCallback;
  162972. }
  162973. /**
  162974. * Define the interface used by progress events raised during assets loading
  162975. */
  162976. export interface IAssetsProgressEvent {
  162977. /**
  162978. * Defines the number of remaining tasks to process
  162979. */
  162980. remainingCount: number;
  162981. /**
  162982. * Defines the total number of tasks
  162983. */
  162984. totalCount: number;
  162985. /**
  162986. * Defines the task that was just processed
  162987. */
  162988. task: AbstractAssetTask;
  162989. }
  162990. /**
  162991. * Class used to share progress information about assets loading
  162992. */
  162993. export class AssetsProgressEvent implements IAssetsProgressEvent {
  162994. /**
  162995. * Defines the number of remaining tasks to process
  162996. */
  162997. remainingCount: number;
  162998. /**
  162999. * Defines the total number of tasks
  163000. */
  163001. totalCount: number;
  163002. /**
  163003. * Defines the task that was just processed
  163004. */
  163005. task: AbstractAssetTask;
  163006. /**
  163007. * Creates a AssetsProgressEvent
  163008. * @param remainingCount defines the number of remaining tasks to process
  163009. * @param totalCount defines the total number of tasks
  163010. * @param task defines the task that was just processed
  163011. */
  163012. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  163013. }
  163014. /**
  163015. * Define a task used by AssetsManager to load assets into a container
  163016. */
  163017. export class ContainerAssetTask extends AbstractAssetTask {
  163018. /**
  163019. * Defines the name of the task
  163020. */
  163021. name: string;
  163022. /**
  163023. * Defines the list of mesh's names you want to load
  163024. */
  163025. meshesNames: any;
  163026. /**
  163027. * Defines the root url to use as a base to load your meshes and associated resources
  163028. */
  163029. rootUrl: string;
  163030. /**
  163031. * Defines the filename or File of the scene to load from
  163032. */
  163033. sceneFilename: string | File;
  163034. /**
  163035. * Get the loaded asset container
  163036. */
  163037. loadedContainer: AssetContainer;
  163038. /**
  163039. * Gets the list of loaded meshes
  163040. */
  163041. loadedMeshes: Array<AbstractMesh>;
  163042. /**
  163043. * Gets the list of loaded particle systems
  163044. */
  163045. loadedParticleSystems: Array<IParticleSystem>;
  163046. /**
  163047. * Gets the list of loaded skeletons
  163048. */
  163049. loadedSkeletons: Array<Skeleton>;
  163050. /**
  163051. * Gets the list of loaded animation groups
  163052. */
  163053. loadedAnimationGroups: Array<AnimationGroup>;
  163054. /**
  163055. * Callback called when the task is successful
  163056. */
  163057. onSuccess: (task: ContainerAssetTask) => void;
  163058. /**
  163059. * Callback called when the task is successful
  163060. */
  163061. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  163062. /**
  163063. * Creates a new ContainerAssetTask
  163064. * @param name defines the name of the task
  163065. * @param meshesNames defines the list of mesh's names you want to load
  163066. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  163067. * @param sceneFilename defines the filename or File of the scene to load from
  163068. */
  163069. constructor(
  163070. /**
  163071. * Defines the name of the task
  163072. */
  163073. name: string,
  163074. /**
  163075. * Defines the list of mesh's names you want to load
  163076. */
  163077. meshesNames: any,
  163078. /**
  163079. * Defines the root url to use as a base to load your meshes and associated resources
  163080. */
  163081. rootUrl: string,
  163082. /**
  163083. * Defines the filename or File of the scene to load from
  163084. */
  163085. sceneFilename: string | File);
  163086. /**
  163087. * Execute the current task
  163088. * @param scene defines the scene where you want your assets to be loaded
  163089. * @param onSuccess is a callback called when the task is successfully executed
  163090. * @param onError is a callback called if an error occurs
  163091. */
  163092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163093. }
  163094. /**
  163095. * Define a task used by AssetsManager to load meshes
  163096. */
  163097. export class MeshAssetTask extends AbstractAssetTask {
  163098. /**
  163099. * Defines the name of the task
  163100. */
  163101. name: string;
  163102. /**
  163103. * Defines the list of mesh's names you want to load
  163104. */
  163105. meshesNames: any;
  163106. /**
  163107. * Defines the root url to use as a base to load your meshes and associated resources
  163108. */
  163109. rootUrl: string;
  163110. /**
  163111. * Defines the filename or File of the scene to load from
  163112. */
  163113. sceneFilename: string | File;
  163114. /**
  163115. * Gets the list of loaded meshes
  163116. */
  163117. loadedMeshes: Array<AbstractMesh>;
  163118. /**
  163119. * Gets the list of loaded particle systems
  163120. */
  163121. loadedParticleSystems: Array<IParticleSystem>;
  163122. /**
  163123. * Gets the list of loaded skeletons
  163124. */
  163125. loadedSkeletons: Array<Skeleton>;
  163126. /**
  163127. * Gets the list of loaded animation groups
  163128. */
  163129. loadedAnimationGroups: Array<AnimationGroup>;
  163130. /**
  163131. * Callback called when the task is successful
  163132. */
  163133. onSuccess: (task: MeshAssetTask) => void;
  163134. /**
  163135. * Callback called when the task is successful
  163136. */
  163137. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  163138. /**
  163139. * Creates a new MeshAssetTask
  163140. * @param name defines the name of the task
  163141. * @param meshesNames defines the list of mesh's names you want to load
  163142. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  163143. * @param sceneFilename defines the filename or File of the scene to load from
  163144. */
  163145. constructor(
  163146. /**
  163147. * Defines the name of the task
  163148. */
  163149. name: string,
  163150. /**
  163151. * Defines the list of mesh's names you want to load
  163152. */
  163153. meshesNames: any,
  163154. /**
  163155. * Defines the root url to use as a base to load your meshes and associated resources
  163156. */
  163157. rootUrl: string,
  163158. /**
  163159. * Defines the filename or File of the scene to load from
  163160. */
  163161. sceneFilename: string | File);
  163162. /**
  163163. * Execute the current task
  163164. * @param scene defines the scene where you want your assets to be loaded
  163165. * @param onSuccess is a callback called when the task is successfully executed
  163166. * @param onError is a callback called if an error occurs
  163167. */
  163168. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163169. }
  163170. /**
  163171. * Define a task used by AssetsManager to load text content
  163172. */
  163173. export class TextFileAssetTask extends AbstractAssetTask {
  163174. /**
  163175. * Defines the name of the task
  163176. */
  163177. name: string;
  163178. /**
  163179. * Defines the location of the file to load
  163180. */
  163181. url: string;
  163182. /**
  163183. * Gets the loaded text string
  163184. */
  163185. text: string;
  163186. /**
  163187. * Callback called when the task is successful
  163188. */
  163189. onSuccess: (task: TextFileAssetTask) => void;
  163190. /**
  163191. * Callback called when the task is successful
  163192. */
  163193. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  163194. /**
  163195. * Creates a new TextFileAssetTask object
  163196. * @param name defines the name of the task
  163197. * @param url defines the location of the file to load
  163198. */
  163199. constructor(
  163200. /**
  163201. * Defines the name of the task
  163202. */
  163203. name: string,
  163204. /**
  163205. * Defines the location of the file to load
  163206. */
  163207. url: string);
  163208. /**
  163209. * Execute the current task
  163210. * @param scene defines the scene where you want your assets to be loaded
  163211. * @param onSuccess is a callback called when the task is successfully executed
  163212. * @param onError is a callback called if an error occurs
  163213. */
  163214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163215. }
  163216. /**
  163217. * Define a task used by AssetsManager to load binary data
  163218. */
  163219. export class BinaryFileAssetTask extends AbstractAssetTask {
  163220. /**
  163221. * Defines the name of the task
  163222. */
  163223. name: string;
  163224. /**
  163225. * Defines the location of the file to load
  163226. */
  163227. url: string;
  163228. /**
  163229. * Gets the lodaded data (as an array buffer)
  163230. */
  163231. data: ArrayBuffer;
  163232. /**
  163233. * Callback called when the task is successful
  163234. */
  163235. onSuccess: (task: BinaryFileAssetTask) => void;
  163236. /**
  163237. * Callback called when the task is successful
  163238. */
  163239. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  163240. /**
  163241. * Creates a new BinaryFileAssetTask object
  163242. * @param name defines the name of the new task
  163243. * @param url defines the location of the file to load
  163244. */
  163245. constructor(
  163246. /**
  163247. * Defines the name of the task
  163248. */
  163249. name: string,
  163250. /**
  163251. * Defines the location of the file to load
  163252. */
  163253. url: string);
  163254. /**
  163255. * Execute the current task
  163256. * @param scene defines the scene where you want your assets to be loaded
  163257. * @param onSuccess is a callback called when the task is successfully executed
  163258. * @param onError is a callback called if an error occurs
  163259. */
  163260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163261. }
  163262. /**
  163263. * Define a task used by AssetsManager to load images
  163264. */
  163265. export class ImageAssetTask extends AbstractAssetTask {
  163266. /**
  163267. * Defines the name of the task
  163268. */
  163269. name: string;
  163270. /**
  163271. * Defines the location of the image to load
  163272. */
  163273. url: string;
  163274. /**
  163275. * Gets the loaded images
  163276. */
  163277. image: HTMLImageElement;
  163278. /**
  163279. * Callback called when the task is successful
  163280. */
  163281. onSuccess: (task: ImageAssetTask) => void;
  163282. /**
  163283. * Callback called when the task is successful
  163284. */
  163285. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  163286. /**
  163287. * Creates a new ImageAssetTask
  163288. * @param name defines the name of the task
  163289. * @param url defines the location of the image to load
  163290. */
  163291. constructor(
  163292. /**
  163293. * Defines the name of the task
  163294. */
  163295. name: string,
  163296. /**
  163297. * Defines the location of the image to load
  163298. */
  163299. url: string);
  163300. /**
  163301. * Execute the current task
  163302. * @param scene defines the scene where you want your assets to be loaded
  163303. * @param onSuccess is a callback called when the task is successfully executed
  163304. * @param onError is a callback called if an error occurs
  163305. */
  163306. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163307. }
  163308. /**
  163309. * Defines the interface used by texture loading tasks
  163310. */
  163311. export interface ITextureAssetTask<TEX extends BaseTexture> {
  163312. /**
  163313. * Gets the loaded texture
  163314. */
  163315. texture: TEX;
  163316. }
  163317. /**
  163318. * Define a task used by AssetsManager to load 2D textures
  163319. */
  163320. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  163321. /**
  163322. * Defines the name of the task
  163323. */
  163324. name: string;
  163325. /**
  163326. * Defines the location of the file to load
  163327. */
  163328. url: string;
  163329. /**
  163330. * Defines if mipmap should not be generated (default is false)
  163331. */
  163332. noMipmap?: boolean | undefined;
  163333. /**
  163334. * Defines if texture must be inverted on Y axis (default is true)
  163335. */
  163336. invertY: boolean;
  163337. /**
  163338. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  163339. */
  163340. samplingMode: number;
  163341. /**
  163342. * Gets the loaded texture
  163343. */
  163344. texture: Texture;
  163345. /**
  163346. * Callback called when the task is successful
  163347. */
  163348. onSuccess: (task: TextureAssetTask) => void;
  163349. /**
  163350. * Callback called when the task is successful
  163351. */
  163352. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  163353. /**
  163354. * Creates a new TextureAssetTask object
  163355. * @param name defines the name of the task
  163356. * @param url defines the location of the file to load
  163357. * @param noMipmap defines if mipmap should not be generated (default is false)
  163358. * @param invertY defines if texture must be inverted on Y axis (default is true)
  163359. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  163360. */
  163361. constructor(
  163362. /**
  163363. * Defines the name of the task
  163364. */
  163365. name: string,
  163366. /**
  163367. * Defines the location of the file to load
  163368. */
  163369. url: string,
  163370. /**
  163371. * Defines if mipmap should not be generated (default is false)
  163372. */
  163373. noMipmap?: boolean | undefined,
  163374. /**
  163375. * Defines if texture must be inverted on Y axis (default is true)
  163376. */
  163377. invertY?: boolean,
  163378. /**
  163379. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  163380. */
  163381. samplingMode?: number);
  163382. /**
  163383. * Execute the current task
  163384. * @param scene defines the scene where you want your assets to be loaded
  163385. * @param onSuccess is a callback called when the task is successfully executed
  163386. * @param onError is a callback called if an error occurs
  163387. */
  163388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163389. }
  163390. /**
  163391. * Define a task used by AssetsManager to load cube textures
  163392. */
  163393. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  163394. /**
  163395. * Defines the name of the task
  163396. */
  163397. name: string;
  163398. /**
  163399. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  163400. */
  163401. url: string;
  163402. /**
  163403. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  163404. */
  163405. extensions?: string[] | undefined;
  163406. /**
  163407. * Defines if mipmaps should not be generated (default is false)
  163408. */
  163409. noMipmap?: boolean | undefined;
  163410. /**
  163411. * Defines the explicit list of files (undefined by default)
  163412. */
  163413. files?: string[] | undefined;
  163414. /**
  163415. * Gets the loaded texture
  163416. */
  163417. texture: CubeTexture;
  163418. /**
  163419. * Callback called when the task is successful
  163420. */
  163421. onSuccess: (task: CubeTextureAssetTask) => void;
  163422. /**
  163423. * Callback called when the task is successful
  163424. */
  163425. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  163426. /**
  163427. * Creates a new CubeTextureAssetTask
  163428. * @param name defines the name of the task
  163429. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  163430. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  163431. * @param noMipmap defines if mipmaps should not be generated (default is false)
  163432. * @param files defines the explicit list of files (undefined by default)
  163433. */
  163434. constructor(
  163435. /**
  163436. * Defines the name of the task
  163437. */
  163438. name: string,
  163439. /**
  163440. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  163441. */
  163442. url: string,
  163443. /**
  163444. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  163445. */
  163446. extensions?: string[] | undefined,
  163447. /**
  163448. * Defines if mipmaps should not be generated (default is false)
  163449. */
  163450. noMipmap?: boolean | undefined,
  163451. /**
  163452. * Defines the explicit list of files (undefined by default)
  163453. */
  163454. files?: string[] | undefined);
  163455. /**
  163456. * Execute the current task
  163457. * @param scene defines the scene where you want your assets to be loaded
  163458. * @param onSuccess is a callback called when the task is successfully executed
  163459. * @param onError is a callback called if an error occurs
  163460. */
  163461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163462. }
  163463. /**
  163464. * Define a task used by AssetsManager to load HDR cube textures
  163465. */
  163466. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  163467. /**
  163468. * Defines the name of the task
  163469. */
  163470. name: string;
  163471. /**
  163472. * Defines the location of the file to load
  163473. */
  163474. url: string;
  163475. /**
  163476. * Defines the desired size (the more it increases the longer the generation will be)
  163477. */
  163478. size: number;
  163479. /**
  163480. * Defines if mipmaps should not be generated (default is false)
  163481. */
  163482. noMipmap: boolean;
  163483. /**
  163484. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  163485. */
  163486. generateHarmonics: boolean;
  163487. /**
  163488. * 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)
  163489. */
  163490. gammaSpace: boolean;
  163491. /**
  163492. * Internal Use Only
  163493. */
  163494. reserved: boolean;
  163495. /**
  163496. * Gets the loaded texture
  163497. */
  163498. texture: HDRCubeTexture;
  163499. /**
  163500. * Callback called when the task is successful
  163501. */
  163502. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  163503. /**
  163504. * Callback called when the task is successful
  163505. */
  163506. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  163507. /**
  163508. * Creates a new HDRCubeTextureAssetTask object
  163509. * @param name defines the name of the task
  163510. * @param url defines the location of the file to load
  163511. * @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.
  163512. * @param noMipmap defines if mipmaps should not be generated (default is false)
  163513. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  163514. * @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)
  163515. * @param reserved Internal use only
  163516. */
  163517. constructor(
  163518. /**
  163519. * Defines the name of the task
  163520. */
  163521. name: string,
  163522. /**
  163523. * Defines the location of the file to load
  163524. */
  163525. url: string,
  163526. /**
  163527. * Defines the desired size (the more it increases the longer the generation will be)
  163528. */
  163529. size: number,
  163530. /**
  163531. * Defines if mipmaps should not be generated (default is false)
  163532. */
  163533. noMipmap?: boolean,
  163534. /**
  163535. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  163536. */
  163537. generateHarmonics?: boolean,
  163538. /**
  163539. * 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)
  163540. */
  163541. gammaSpace?: boolean,
  163542. /**
  163543. * Internal Use Only
  163544. */
  163545. reserved?: boolean);
  163546. /**
  163547. * Execute the current task
  163548. * @param scene defines the scene where you want your assets to be loaded
  163549. * @param onSuccess is a callback called when the task is successfully executed
  163550. * @param onError is a callback called if an error occurs
  163551. */
  163552. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163553. }
  163554. /**
  163555. * Define a task used by AssetsManager to load Equirectangular cube textures
  163556. */
  163557. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  163558. /**
  163559. * Defines the name of the task
  163560. */
  163561. name: string;
  163562. /**
  163563. * Defines the location of the file to load
  163564. */
  163565. url: string;
  163566. /**
  163567. * Defines the desired size (the more it increases the longer the generation will be)
  163568. */
  163569. size: number;
  163570. /**
  163571. * Defines if mipmaps should not be generated (default is false)
  163572. */
  163573. noMipmap: boolean;
  163574. /**
  163575. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  163576. * but the standard material would require them in Gamma space) (default is true)
  163577. */
  163578. gammaSpace: boolean;
  163579. /**
  163580. * Gets the loaded texture
  163581. */
  163582. texture: EquiRectangularCubeTexture;
  163583. /**
  163584. * Callback called when the task is successful
  163585. */
  163586. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  163587. /**
  163588. * Callback called when the task is successful
  163589. */
  163590. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  163591. /**
  163592. * Creates a new EquiRectangularCubeTextureAssetTask object
  163593. * @param name defines the name of the task
  163594. * @param url defines the location of the file to load
  163595. * @param size defines the desired size (the more it increases the longer the generation will be)
  163596. * If the size is omitted this implies you are using a preprocessed cubemap.
  163597. * @param noMipmap defines if mipmaps should not be generated (default is false)
  163598. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  163599. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  163600. * (default is true)
  163601. */
  163602. constructor(
  163603. /**
  163604. * Defines the name of the task
  163605. */
  163606. name: string,
  163607. /**
  163608. * Defines the location of the file to load
  163609. */
  163610. url: string,
  163611. /**
  163612. * Defines the desired size (the more it increases the longer the generation will be)
  163613. */
  163614. size: number,
  163615. /**
  163616. * Defines if mipmaps should not be generated (default is false)
  163617. */
  163618. noMipmap?: boolean,
  163619. /**
  163620. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  163621. * but the standard material would require them in Gamma space) (default is true)
  163622. */
  163623. gammaSpace?: boolean);
  163624. /**
  163625. * Execute the current task
  163626. * @param scene defines the scene where you want your assets to be loaded
  163627. * @param onSuccess is a callback called when the task is successfully executed
  163628. * @param onError is a callback called if an error occurs
  163629. */
  163630. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  163631. }
  163632. /**
  163633. * This class can be used to easily import assets into a scene
  163634. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  163635. */
  163636. export class AssetsManager {
  163637. private _scene;
  163638. private _isLoading;
  163639. protected _tasks: AbstractAssetTask[];
  163640. protected _waitingTasksCount: number;
  163641. protected _totalTasksCount: number;
  163642. /**
  163643. * Callback called when all tasks are processed
  163644. */
  163645. onFinish: (tasks: AbstractAssetTask[]) => void;
  163646. /**
  163647. * Callback called when a task is successful
  163648. */
  163649. onTaskSuccess: (task: AbstractAssetTask) => void;
  163650. /**
  163651. * Callback called when a task had an error
  163652. */
  163653. onTaskError: (task: AbstractAssetTask) => void;
  163654. /**
  163655. * Callback called when a task is done (whatever the result is)
  163656. */
  163657. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  163658. /**
  163659. * Observable called when all tasks are processed
  163660. */
  163661. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  163662. /**
  163663. * Observable called when a task had an error
  163664. */
  163665. onTaskErrorObservable: Observable<AbstractAssetTask>;
  163666. /**
  163667. * Observable called when all tasks were executed
  163668. */
  163669. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  163670. /**
  163671. * Observable called when a task is done (whatever the result is)
  163672. */
  163673. onProgressObservable: Observable<IAssetsProgressEvent>;
  163674. /**
  163675. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  163676. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  163677. */
  163678. useDefaultLoadingScreen: boolean;
  163679. /**
  163680. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  163681. * when all assets have been downloaded.
  163682. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  163683. */
  163684. autoHideLoadingUI: boolean;
  163685. /**
  163686. * Creates a new AssetsManager
  163687. * @param scene defines the scene to work on
  163688. */
  163689. constructor(scene: Scene);
  163690. /**
  163691. * Add a ContainerAssetTask to the list of active tasks
  163692. * @param taskName defines the name of the new task
  163693. * @param meshesNames defines the name of meshes to load
  163694. * @param rootUrl defines the root url to use to locate files
  163695. * @param sceneFilename defines the filename of the scene file
  163696. * @returns a new ContainerAssetTask object
  163697. */
  163698. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  163699. /**
  163700. * Add a MeshAssetTask to the list of active tasks
  163701. * @param taskName defines the name of the new task
  163702. * @param meshesNames defines the name of meshes to load
  163703. * @param rootUrl defines the root url to use to locate files
  163704. * @param sceneFilename defines the filename of the scene file
  163705. * @returns a new MeshAssetTask object
  163706. */
  163707. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  163708. /**
  163709. * Add a TextFileAssetTask to the list of active tasks
  163710. * @param taskName defines the name of the new task
  163711. * @param url defines the url of the file to load
  163712. * @returns a new TextFileAssetTask object
  163713. */
  163714. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  163715. /**
  163716. * Add a BinaryFileAssetTask to the list of active tasks
  163717. * @param taskName defines the name of the new task
  163718. * @param url defines the url of the file to load
  163719. * @returns a new BinaryFileAssetTask object
  163720. */
  163721. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  163722. /**
  163723. * Add a ImageAssetTask to the list of active tasks
  163724. * @param taskName defines the name of the new task
  163725. * @param url defines the url of the file to load
  163726. * @returns a new ImageAssetTask object
  163727. */
  163728. addImageTask(taskName: string, url: string): ImageAssetTask;
  163729. /**
  163730. * Add a TextureAssetTask to the list of active tasks
  163731. * @param taskName defines the name of the new task
  163732. * @param url defines the url of the file to load
  163733. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  163734. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  163735. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  163736. * @returns a new TextureAssetTask object
  163737. */
  163738. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  163739. /**
  163740. * Add a CubeTextureAssetTask to the list of active tasks
  163741. * @param taskName defines the name of the new task
  163742. * @param url defines the url of the file to load
  163743. * @param extensions defines the extension to use to load the cube map (can be null)
  163744. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  163745. * @param files defines the list of files to load (can be null)
  163746. * @returns a new CubeTextureAssetTask object
  163747. */
  163748. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  163749. /**
  163750. *
  163751. * Add a HDRCubeTextureAssetTask to the list of active tasks
  163752. * @param taskName defines the name of the new task
  163753. * @param url defines the url of the file to load
  163754. * @param size defines the size you want for the cubemap (can be null)
  163755. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  163756. * @param generateHarmonics defines if you want to automatically generate (true by default)
  163757. * @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)
  163758. * @param reserved Internal use only
  163759. * @returns a new HDRCubeTextureAssetTask object
  163760. */
  163761. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  163762. /**
  163763. *
  163764. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  163765. * @param taskName defines the name of the new task
  163766. * @param url defines the url of the file to load
  163767. * @param size defines the size you want for the cubemap (can be null)
  163768. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  163769. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  163770. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  163771. * @returns a new EquiRectangularCubeTextureAssetTask object
  163772. */
  163773. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  163774. /**
  163775. * Remove a task from the assets manager.
  163776. * @param task the task to remove
  163777. */
  163778. removeTask(task: AbstractAssetTask): void;
  163779. private _decreaseWaitingTasksCount;
  163780. private _runTask;
  163781. /**
  163782. * Reset the AssetsManager and remove all tasks
  163783. * @return the current instance of the AssetsManager
  163784. */
  163785. reset(): AssetsManager;
  163786. /**
  163787. * Start the loading process
  163788. * @return the current instance of the AssetsManager
  163789. */
  163790. load(): AssetsManager;
  163791. /**
  163792. * Start the loading process as an async operation
  163793. * @return a promise returning the list of failed tasks
  163794. */
  163795. loadAsync(): Promise<void>;
  163796. }
  163797. }
  163798. declare module BABYLON {
  163799. /**
  163800. * Wrapper class for promise with external resolve and reject.
  163801. */
  163802. export class Deferred<T> {
  163803. /**
  163804. * The promise associated with this deferred object.
  163805. */
  163806. readonly promise: Promise<T>;
  163807. private _resolve;
  163808. private _reject;
  163809. /**
  163810. * The resolve method of the promise associated with this deferred object.
  163811. */
  163812. get resolve(): (value: T | PromiseLike<T>) => void;
  163813. /**
  163814. * The reject method of the promise associated with this deferred object.
  163815. */
  163816. get reject(): (reason?: any) => void;
  163817. /**
  163818. * Constructor for this deferred object.
  163819. */
  163820. constructor();
  163821. }
  163822. }
  163823. declare module BABYLON {
  163824. /**
  163825. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  163826. */
  163827. export class MeshExploder {
  163828. private _centerMesh;
  163829. private _meshes;
  163830. private _meshesOrigins;
  163831. private _toCenterVectors;
  163832. private _scaledDirection;
  163833. private _newPosition;
  163834. private _centerPosition;
  163835. /**
  163836. * Explodes meshes from a center mesh.
  163837. * @param meshes The meshes to explode.
  163838. * @param centerMesh The mesh to be center of explosion.
  163839. */
  163840. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  163841. private _setCenterMesh;
  163842. /**
  163843. * Get class name
  163844. * @returns "MeshExploder"
  163845. */
  163846. getClassName(): string;
  163847. /**
  163848. * "Exploded meshes"
  163849. * @returns Array of meshes with the centerMesh at index 0.
  163850. */
  163851. getMeshes(): Array<Mesh>;
  163852. /**
  163853. * Explodes meshes giving a specific direction
  163854. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  163855. */
  163856. explode(direction?: number): void;
  163857. }
  163858. }
  163859. declare module BABYLON {
  163860. /**
  163861. * Class used to help managing file picking and drag'n'drop
  163862. */
  163863. export class FilesInput {
  163864. /**
  163865. * List of files ready to be loaded
  163866. */
  163867. static get FilesToLoad(): {
  163868. [key: string]: File;
  163869. };
  163870. /**
  163871. * Callback called when a file is processed
  163872. */
  163873. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  163874. /**
  163875. * Function used when loading the scene file
  163876. */
  163877. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  163878. private _engine;
  163879. private _currentScene;
  163880. private _sceneLoadedCallback;
  163881. private _progressCallback;
  163882. private _additionalRenderLoopLogicCallback;
  163883. private _textureLoadingCallback;
  163884. private _startingProcessingFilesCallback;
  163885. private _onReloadCallback;
  163886. private _errorCallback;
  163887. private _elementToMonitor;
  163888. private _sceneFileToLoad;
  163889. private _filesToLoad;
  163890. /**
  163891. * Creates a new FilesInput
  163892. * @param engine defines the rendering engine
  163893. * @param scene defines the hosting scene
  163894. * @param sceneLoadedCallback callback called when scene is loaded
  163895. * @param progressCallback callback called to track progress
  163896. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  163897. * @param textureLoadingCallback callback called when a texture is loading
  163898. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  163899. * @param onReloadCallback callback called when a reload is requested
  163900. * @param errorCallback callback call if an error occurs
  163901. */
  163902. 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>);
  163903. private _dragEnterHandler;
  163904. private _dragOverHandler;
  163905. private _dropHandler;
  163906. /**
  163907. * Calls this function to listen to drag'n'drop events on a specific DOM element
  163908. * @param elementToMonitor defines the DOM element to track
  163909. */
  163910. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  163911. /** Gets the current list of files to load */
  163912. get filesToLoad(): File[];
  163913. /**
  163914. * Release all associated resources
  163915. */
  163916. dispose(): void;
  163917. private renderFunction;
  163918. private drag;
  163919. private drop;
  163920. private _traverseFolder;
  163921. private _processFiles;
  163922. /**
  163923. * Load files from a drop event
  163924. * @param event defines the drop event to use as source
  163925. */
  163926. loadFiles(event: any): void;
  163927. private _processReload;
  163928. /**
  163929. * Reload the current scene from the loaded files
  163930. */
  163931. reload(): void;
  163932. }
  163933. }
  163934. declare module BABYLON {
  163935. /**
  163936. * Defines the root class used to create scene optimization to use with SceneOptimizer
  163937. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163938. */
  163939. export class SceneOptimization {
  163940. /**
  163941. * Defines the priority of this optimization (0 by default which means first in the list)
  163942. */
  163943. priority: number;
  163944. /**
  163945. * Gets a string describing the action executed by the current optimization
  163946. * @returns description string
  163947. */
  163948. getDescription(): string;
  163949. /**
  163950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  163951. * @param scene defines the current scene where to apply this optimization
  163952. * @param optimizer defines the current optimizer
  163953. * @returns true if everything that can be done was applied
  163954. */
  163955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  163956. /**
  163957. * Creates the SceneOptimization object
  163958. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  163959. * @param desc defines the description associated with the optimization
  163960. */
  163961. constructor(
  163962. /**
  163963. * Defines the priority of this optimization (0 by default which means first in the list)
  163964. */
  163965. priority?: number);
  163966. }
  163967. /**
  163968. * Defines an optimization used to reduce the size of render target textures
  163969. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  163970. */
  163971. export class TextureOptimization extends SceneOptimization {
  163972. /**
  163973. * Defines the priority of this optimization (0 by default which means first in the list)
  163974. */
  163975. priority: number;
  163976. /**
  163977. * 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
  163978. */
  163979. maximumSize: number;
  163980. /**
  163981. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  163982. */
  163983. step: number;
  163984. /**
  163985. * Gets a string describing the action executed by the current optimization
  163986. * @returns description string
  163987. */
  163988. getDescription(): string;
  163989. /**
  163990. * Creates the TextureOptimization object
  163991. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  163992. * @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
  163993. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  163994. */
  163995. constructor(
  163996. /**
  163997. * Defines the priority of this optimization (0 by default which means first in the list)
  163998. */
  163999. priority?: number,
  164000. /**
  164001. * 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
  164002. */
  164003. maximumSize?: number,
  164004. /**
  164005. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  164006. */
  164007. step?: number);
  164008. /**
  164009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164010. * @param scene defines the current scene where to apply this optimization
  164011. * @param optimizer defines the current optimizer
  164012. * @returns true if everything that can be done was applied
  164013. */
  164014. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  164015. }
  164016. /**
  164017. * Defines an optimization used to increase or decrease the rendering resolution
  164018. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164019. */
  164020. export class HardwareScalingOptimization extends SceneOptimization {
  164021. /**
  164022. * Defines the priority of this optimization (0 by default which means first in the list)
  164023. */
  164024. priority: number;
  164025. /**
  164026. * Defines the maximum scale to use (2 by default)
  164027. */
  164028. maximumScale: number;
  164029. /**
  164030. * Defines the step to use between two passes (0.5 by default)
  164031. */
  164032. step: number;
  164033. private _currentScale;
  164034. private _directionOffset;
  164035. /**
  164036. * Gets a string describing the action executed by the current optimization
  164037. * @return description string
  164038. */
  164039. getDescription(): string;
  164040. /**
  164041. * Creates the HardwareScalingOptimization object
  164042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  164043. * @param maximumScale defines the maximum scale to use (2 by default)
  164044. * @param step defines the step to use between two passes (0.5 by default)
  164045. */
  164046. constructor(
  164047. /**
  164048. * Defines the priority of this optimization (0 by default which means first in the list)
  164049. */
  164050. priority?: number,
  164051. /**
  164052. * Defines the maximum scale to use (2 by default)
  164053. */
  164054. maximumScale?: number,
  164055. /**
  164056. * Defines the step to use between two passes (0.5 by default)
  164057. */
  164058. step?: number);
  164059. /**
  164060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164061. * @param scene defines the current scene where to apply this optimization
  164062. * @param optimizer defines the current optimizer
  164063. * @returns true if everything that can be done was applied
  164064. */
  164065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  164066. }
  164067. /**
  164068. * Defines an optimization used to remove shadows
  164069. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164070. */
  164071. export class ShadowsOptimization extends SceneOptimization {
  164072. /**
  164073. * Gets a string describing the action executed by the current optimization
  164074. * @return description string
  164075. */
  164076. getDescription(): string;
  164077. /**
  164078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164079. * @param scene defines the current scene where to apply this optimization
  164080. * @param optimizer defines the current optimizer
  164081. * @returns true if everything that can be done was applied
  164082. */
  164083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  164084. }
  164085. /**
  164086. * Defines an optimization used to turn post-processes off
  164087. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164088. */
  164089. export class PostProcessesOptimization extends SceneOptimization {
  164090. /**
  164091. * Gets a string describing the action executed by the current optimization
  164092. * @return description string
  164093. */
  164094. getDescription(): string;
  164095. /**
  164096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164097. * @param scene defines the current scene where to apply this optimization
  164098. * @param optimizer defines the current optimizer
  164099. * @returns true if everything that can be done was applied
  164100. */
  164101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  164102. }
  164103. /**
  164104. * Defines an optimization used to turn lens flares off
  164105. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164106. */
  164107. export class LensFlaresOptimization extends SceneOptimization {
  164108. /**
  164109. * Gets a string describing the action executed by the current optimization
  164110. * @return description string
  164111. */
  164112. getDescription(): string;
  164113. /**
  164114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164115. * @param scene defines the current scene where to apply this optimization
  164116. * @param optimizer defines the current optimizer
  164117. * @returns true if everything that can be done was applied
  164118. */
  164119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  164120. }
  164121. /**
  164122. * Defines an optimization based on user defined callback.
  164123. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164124. */
  164125. export class CustomOptimization extends SceneOptimization {
  164126. /**
  164127. * Callback called to apply the custom optimization.
  164128. */
  164129. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  164130. /**
  164131. * Callback called to get custom description
  164132. */
  164133. onGetDescription: () => string;
  164134. /**
  164135. * Gets a string describing the action executed by the current optimization
  164136. * @returns description string
  164137. */
  164138. getDescription(): string;
  164139. /**
  164140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164141. * @param scene defines the current scene where to apply this optimization
  164142. * @param optimizer defines the current optimizer
  164143. * @returns true if everything that can be done was applied
  164144. */
  164145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  164146. }
  164147. /**
  164148. * Defines an optimization used to turn particles off
  164149. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164150. */
  164151. export class ParticlesOptimization extends SceneOptimization {
  164152. /**
  164153. * Gets a string describing the action executed by the current optimization
  164154. * @return description string
  164155. */
  164156. getDescription(): string;
  164157. /**
  164158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164159. * @param scene defines the current scene where to apply this optimization
  164160. * @param optimizer defines the current optimizer
  164161. * @returns true if everything that can be done was applied
  164162. */
  164163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  164164. }
  164165. /**
  164166. * Defines an optimization used to turn render targets off
  164167. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164168. */
  164169. export class RenderTargetsOptimization extends SceneOptimization {
  164170. /**
  164171. * Gets a string describing the action executed by the current optimization
  164172. * @return description string
  164173. */
  164174. getDescription(): string;
  164175. /**
  164176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164177. * @param scene defines the current scene where to apply this optimization
  164178. * @param optimizer defines the current optimizer
  164179. * @returns true if everything that can be done was applied
  164180. */
  164181. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  164182. }
  164183. /**
  164184. * Defines an optimization used to merge meshes with compatible materials
  164185. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164186. */
  164187. export class MergeMeshesOptimization extends SceneOptimization {
  164188. private static _UpdateSelectionTree;
  164189. /**
  164190. * Gets or sets a boolean which defines if optimization octree has to be updated
  164191. */
  164192. static get UpdateSelectionTree(): boolean;
  164193. /**
  164194. * Gets or sets a boolean which defines if optimization octree has to be updated
  164195. */
  164196. static set UpdateSelectionTree(value: boolean);
  164197. /**
  164198. * Gets a string describing the action executed by the current optimization
  164199. * @return description string
  164200. */
  164201. getDescription(): string;
  164202. private _canBeMerged;
  164203. /**
  164204. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  164205. * @param scene defines the current scene where to apply this optimization
  164206. * @param optimizer defines the current optimizer
  164207. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  164208. * @returns true if everything that can be done was applied
  164209. */
  164210. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  164211. }
  164212. /**
  164213. * Defines a list of options used by SceneOptimizer
  164214. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164215. */
  164216. export class SceneOptimizerOptions {
  164217. /**
  164218. * Defines the target frame rate to reach (60 by default)
  164219. */
  164220. targetFrameRate: number;
  164221. /**
  164222. * Defines the interval between two checks (2000ms by default)
  164223. */
  164224. trackerDuration: number;
  164225. /**
  164226. * Gets the list of optimizations to apply
  164227. */
  164228. optimizations: SceneOptimization[];
  164229. /**
  164230. * Creates a new list of options used by SceneOptimizer
  164231. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  164232. * @param trackerDuration defines the interval between two checks (2000ms by default)
  164233. */
  164234. constructor(
  164235. /**
  164236. * Defines the target frame rate to reach (60 by default)
  164237. */
  164238. targetFrameRate?: number,
  164239. /**
  164240. * Defines the interval between two checks (2000ms by default)
  164241. */
  164242. trackerDuration?: number);
  164243. /**
  164244. * Add a new optimization
  164245. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  164246. * @returns the current SceneOptimizerOptions
  164247. */
  164248. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  164249. /**
  164250. * Add a new custom optimization
  164251. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  164252. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  164253. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  164254. * @returns the current SceneOptimizerOptions
  164255. */
  164256. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  164257. /**
  164258. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  164259. * @param targetFrameRate defines the target frame rate (60 by default)
  164260. * @returns a SceneOptimizerOptions object
  164261. */
  164262. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  164263. /**
  164264. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  164265. * @param targetFrameRate defines the target frame rate (60 by default)
  164266. * @returns a SceneOptimizerOptions object
  164267. */
  164268. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  164269. /**
  164270. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  164271. * @param targetFrameRate defines the target frame rate (60 by default)
  164272. * @returns a SceneOptimizerOptions object
  164273. */
  164274. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  164275. }
  164276. /**
  164277. * Class used to run optimizations in order to reach a target frame rate
  164278. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  164279. */
  164280. export class SceneOptimizer implements IDisposable {
  164281. private _isRunning;
  164282. private _options;
  164283. private _scene;
  164284. private _currentPriorityLevel;
  164285. private _targetFrameRate;
  164286. private _trackerDuration;
  164287. private _currentFrameRate;
  164288. private _sceneDisposeObserver;
  164289. private _improvementMode;
  164290. /**
  164291. * Defines an observable called when the optimizer reaches the target frame rate
  164292. */
  164293. onSuccessObservable: Observable<SceneOptimizer>;
  164294. /**
  164295. * Defines an observable called when the optimizer enables an optimization
  164296. */
  164297. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  164298. /**
  164299. * Defines an observable called when the optimizer is not able to reach the target frame rate
  164300. */
  164301. onFailureObservable: Observable<SceneOptimizer>;
  164302. /**
  164303. * Gets a boolean indicating if the optimizer is in improvement mode
  164304. */
  164305. get isInImprovementMode(): boolean;
  164306. /**
  164307. * Gets the current priority level (0 at start)
  164308. */
  164309. get currentPriorityLevel(): number;
  164310. /**
  164311. * Gets the current frame rate checked by the SceneOptimizer
  164312. */
  164313. get currentFrameRate(): number;
  164314. /**
  164315. * Gets or sets the current target frame rate (60 by default)
  164316. */
  164317. get targetFrameRate(): number;
  164318. /**
  164319. * Gets or sets the current target frame rate (60 by default)
  164320. */
  164321. set targetFrameRate(value: number);
  164322. /**
  164323. * Gets or sets the current interval between two checks (every 2000ms by default)
  164324. */
  164325. get trackerDuration(): number;
  164326. /**
  164327. * Gets or sets the current interval between two checks (every 2000ms by default)
  164328. */
  164329. set trackerDuration(value: number);
  164330. /**
  164331. * Gets the list of active optimizations
  164332. */
  164333. get optimizations(): SceneOptimization[];
  164334. /**
  164335. * Creates a new SceneOptimizer
  164336. * @param scene defines the scene to work on
  164337. * @param options defines the options to use with the SceneOptimizer
  164338. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  164339. * @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)
  164340. */
  164341. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  164342. /**
  164343. * Stops the current optimizer
  164344. */
  164345. stop(): void;
  164346. /**
  164347. * Reset the optimizer to initial step (current priority level = 0)
  164348. */
  164349. reset(): void;
  164350. /**
  164351. * Start the optimizer. By default it will try to reach a specific framerate
  164352. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  164353. */
  164354. start(): void;
  164355. private _checkCurrentState;
  164356. /**
  164357. * Release all resources
  164358. */
  164359. dispose(): void;
  164360. /**
  164361. * Helper function to create a SceneOptimizer with one single line of code
  164362. * @param scene defines the scene to work on
  164363. * @param options defines the options to use with the SceneOptimizer
  164364. * @param onSuccess defines a callback to call on success
  164365. * @param onFailure defines a callback to call on failure
  164366. * @returns the new SceneOptimizer object
  164367. */
  164368. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  164369. }
  164370. }
  164371. declare module BABYLON {
  164372. /**
  164373. * Class used to serialize a scene into a string
  164374. */
  164375. export class SceneSerializer {
  164376. /**
  164377. * Clear cache used by a previous serialization
  164378. */
  164379. static ClearCache(): void;
  164380. /**
  164381. * Serialize a scene into a JSON compatible object
  164382. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  164383. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  164384. * @param scene defines the scene to serialize
  164385. * @returns a JSON compatible object
  164386. */
  164387. static Serialize(scene: Scene): any;
  164388. private static _Serialize;
  164389. /**
  164390. * Serialize a scene into a JSON compatible object
  164391. * @param scene defines the scene to serialize
  164392. * @returns a JSON promise compatible object
  164393. */
  164394. static SerializeAsync(scene: Scene): Promise<any>;
  164395. private static _CollectPromises;
  164396. /**
  164397. * Serialize a mesh into a JSON compatible object
  164398. * @param toSerialize defines the mesh to serialize
  164399. * @param withParents defines if parents must be serialized as well
  164400. * @param withChildren defines if children must be serialized as well
  164401. * @returns a JSON compatible object
  164402. */
  164403. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  164404. }
  164405. }
  164406. declare module BABYLON {
  164407. /**
  164408. * This represents the different options available for the video capture.
  164409. */
  164410. export interface VideoRecorderOptions {
  164411. /** Defines the mime type of the video. */
  164412. mimeType: string;
  164413. /** Defines the FPS the video should be recorded at. */
  164414. fps: number;
  164415. /** Defines the chunk size for the recording data. */
  164416. recordChunckSize: number;
  164417. /** The audio tracks to attach to the recording. */
  164418. audioTracks?: MediaStreamTrack[];
  164419. }
  164420. /**
  164421. * This can help with recording videos from BabylonJS.
  164422. * This is based on the available WebRTC functionalities of the browser.
  164423. *
  164424. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  164425. */
  164426. export class VideoRecorder {
  164427. private static readonly _defaultOptions;
  164428. /**
  164429. * Returns whether or not the VideoRecorder is available in your browser.
  164430. * @param engine Defines the Babylon Engine.
  164431. * @returns true if supported otherwise false.
  164432. */
  164433. static IsSupported(engine: Engine): boolean;
  164434. private readonly _options;
  164435. private _canvas;
  164436. private _mediaRecorder;
  164437. private _recordedChunks;
  164438. private _fileName;
  164439. private _resolve;
  164440. private _reject;
  164441. /**
  164442. * True when a recording is already in progress.
  164443. */
  164444. get isRecording(): boolean;
  164445. /**
  164446. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  164447. * @param engine Defines the BabylonJS Engine you wish to record.
  164448. * @param options Defines options that can be used to customize the capture.
  164449. */
  164450. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  164451. /**
  164452. * Stops the current recording before the default capture timeout passed in the startRecording function.
  164453. */
  164454. stopRecording(): void;
  164455. /**
  164456. * Starts recording the canvas for a max duration specified in parameters.
  164457. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  164458. * If null no automatic download will start and you can rely on the promise to get the data back.
  164459. * @param maxDuration Defines the maximum recording time in seconds.
  164460. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  164461. * @return A promise callback at the end of the recording with the video data in Blob.
  164462. */
  164463. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  164464. /**
  164465. * Releases internal resources used during the recording.
  164466. */
  164467. dispose(): void;
  164468. private _handleDataAvailable;
  164469. private _handleError;
  164470. private _handleStop;
  164471. }
  164472. }
  164473. declare module BABYLON {
  164474. /**
  164475. * Class containing a set of static utilities functions for screenshots
  164476. */
  164477. export class ScreenshotTools {
  164478. /**
  164479. * Captures a screenshot of the current rendering
  164480. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  164481. * @param engine defines the rendering engine
  164482. * @param camera defines the source camera
  164483. * @param size This parameter can be set to a single number or to an object with the
  164484. * following (optional) properties: precision, width, height. If a single number is passed,
  164485. * it will be used for both width and height. If an object is passed, the screenshot size
  164486. * will be derived from the parameters. The precision property is a multiplier allowing
  164487. * rendering at a higher or lower resolution
  164488. * @param successCallback defines the callback receives a single parameter which contains the
  164489. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  164490. * src parameter of an <img> to display it
  164491. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  164492. * Check your browser for supported MIME types
  164493. * @param forceDownload force the system to download the image even if a successCallback is provided
  164494. */
  164495. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  164496. /**
  164497. * Captures a screenshot of the current rendering
  164498. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  164499. * @param engine defines the rendering engine
  164500. * @param camera defines the source camera
  164501. * @param size This parameter can be set to a single number or to an object with the
  164502. * following (optional) properties: precision, width, height. If a single number is passed,
  164503. * it will be used for both width and height. If an object is passed, the screenshot size
  164504. * will be derived from the parameters. The precision property is a multiplier allowing
  164505. * rendering at a higher or lower resolution
  164506. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  164507. * Check your browser for supported MIME types
  164508. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  164509. * to the src parameter of an <img> to display it
  164510. */
  164511. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  164512. /**
  164513. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  164514. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  164515. * @param engine defines the rendering engine
  164516. * @param camera defines the source camera
  164517. * @param width defines the expected width
  164518. * @param height defines the expected height
  164519. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  164520. * Check your browser for supported MIME types
  164521. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  164522. * to the src parameter of an <img> to display it
  164523. */
  164524. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  164525. /**
  164526. * Generates an image screenshot from the specified camera.
  164527. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  164528. * @param engine The engine to use for rendering
  164529. * @param camera The camera to use for rendering
  164530. * @param size This parameter can be set to a single number or to an object with the
  164531. * following (optional) properties: precision, width, height. If a single number is passed,
  164532. * it will be used for both width and height. If an object is passed, the screenshot size
  164533. * will be derived from the parameters. The precision property is a multiplier allowing
  164534. * rendering at a higher or lower resolution
  164535. * @param successCallback The callback receives a single parameter which contains the
  164536. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  164537. * src parameter of an <img> to display it
  164538. * @param mimeType The MIME type of the screenshot image (default: image/png).
  164539. * Check your browser for supported MIME types
  164540. * @param samples Texture samples (default: 1)
  164541. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  164542. * @param fileName A name for for the downloaded file.
  164543. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  164544. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  164545. */
  164546. 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;
  164547. /**
  164548. * Generates an image screenshot from the specified camera.
  164549. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  164550. * @param engine The engine to use for rendering
  164551. * @param camera The camera to use for rendering
  164552. * @param size This parameter can be set to a single number or to an object with the
  164553. * following (optional) properties: precision, width, height. If a single number is passed,
  164554. * it will be used for both width and height. If an object is passed, the screenshot size
  164555. * will be derived from the parameters. The precision property is a multiplier allowing
  164556. * rendering at a higher or lower resolution
  164557. * @param mimeType The MIME type of the screenshot image (default: image/png).
  164558. * Check your browser for supported MIME types
  164559. * @param samples Texture samples (default: 1)
  164560. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  164561. * @param fileName A name for for the downloaded file.
  164562. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  164563. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  164564. * to the src parameter of an <img> to display it
  164565. */
  164566. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  164567. /**
  164568. * Gets height and width for screenshot size
  164569. * @private
  164570. */
  164571. private static _getScreenshotSize;
  164572. }
  164573. }
  164574. declare module BABYLON {
  164575. /**
  164576. * Interface for a data buffer
  164577. */
  164578. export interface IDataBuffer {
  164579. /**
  164580. * Reads bytes from the data buffer.
  164581. * @param byteOffset The byte offset to read
  164582. * @param byteLength The byte length to read
  164583. * @returns A promise that resolves when the bytes are read
  164584. */
  164585. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  164586. /**
  164587. * The byte length of the buffer.
  164588. */
  164589. readonly byteLength: number;
  164590. }
  164591. /**
  164592. * Utility class for reading from a data buffer
  164593. */
  164594. export class DataReader {
  164595. /**
  164596. * The data buffer associated with this data reader.
  164597. */
  164598. readonly buffer: IDataBuffer;
  164599. /**
  164600. * The current byte offset from the beginning of the data buffer.
  164601. */
  164602. byteOffset: number;
  164603. private _dataView;
  164604. private _dataByteOffset;
  164605. /**
  164606. * Constructor
  164607. * @param buffer The buffer to read
  164608. */
  164609. constructor(buffer: IDataBuffer);
  164610. /**
  164611. * Loads the given byte length.
  164612. * @param byteLength The byte length to load
  164613. * @returns A promise that resolves when the load is complete
  164614. */
  164615. loadAsync(byteLength: number): Promise<void>;
  164616. /**
  164617. * Read a unsigned 32-bit integer from the currently loaded data range.
  164618. * @returns The 32-bit integer read
  164619. */
  164620. readUint32(): number;
  164621. /**
  164622. * Read a byte array from the currently loaded data range.
  164623. * @param byteLength The byte length to read
  164624. * @returns The byte array read
  164625. */
  164626. readUint8Array(byteLength: number): Uint8Array;
  164627. /**
  164628. * Read a string from the currently loaded data range.
  164629. * @param byteLength The byte length to read
  164630. * @returns The string read
  164631. */
  164632. readString(byteLength: number): string;
  164633. /**
  164634. * Skips the given byte length the currently loaded data range.
  164635. * @param byteLength The byte length to skip
  164636. */
  164637. skipBytes(byteLength: number): void;
  164638. }
  164639. }
  164640. declare module BABYLON {
  164641. /**
  164642. * Class for storing data to local storage if available or in-memory storage otherwise
  164643. */
  164644. export class DataStorage {
  164645. private static _Storage;
  164646. private static _GetStorage;
  164647. /**
  164648. * Reads a string from the data storage
  164649. * @param key The key to read
  164650. * @param defaultValue The value if the key doesn't exist
  164651. * @returns The string value
  164652. */
  164653. static ReadString(key: string, defaultValue: string): string;
  164654. /**
  164655. * Writes a string to the data storage
  164656. * @param key The key to write
  164657. * @param value The value to write
  164658. */
  164659. static WriteString(key: string, value: string): void;
  164660. /**
  164661. * Reads a boolean from the data storage
  164662. * @param key The key to read
  164663. * @param defaultValue The value if the key doesn't exist
  164664. * @returns The boolean value
  164665. */
  164666. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  164667. /**
  164668. * Writes a boolean to the data storage
  164669. * @param key The key to write
  164670. * @param value The value to write
  164671. */
  164672. static WriteBoolean(key: string, value: boolean): void;
  164673. /**
  164674. * Reads a number from the data storage
  164675. * @param key The key to read
  164676. * @param defaultValue The value if the key doesn't exist
  164677. * @returns The number value
  164678. */
  164679. static ReadNumber(key: string, defaultValue: number): number;
  164680. /**
  164681. * Writes a number to the data storage
  164682. * @param key The key to write
  164683. * @param value The value to write
  164684. */
  164685. static WriteNumber(key: string, value: number): void;
  164686. }
  164687. }
  164688. declare module BABYLON {
  164689. /**
  164690. * Class used to record delta files between 2 scene states
  164691. */
  164692. export class SceneRecorder {
  164693. private _trackedScene;
  164694. private _savedJSON;
  164695. /**
  164696. * Track a given scene. This means the current scene state will be considered the original state
  164697. * @param scene defines the scene to track
  164698. */
  164699. track(scene: Scene): void;
  164700. /**
  164701. * Get the delta between current state and original state
  164702. * @returns a any containing the delta
  164703. */
  164704. getDelta(): any;
  164705. private _compareArray;
  164706. private _compareObjects;
  164707. private _compareCollections;
  164708. private static GetShadowGeneratorById;
  164709. /**
  164710. * Apply a given delta to a given scene
  164711. * @param deltaJSON defines the JSON containing the delta
  164712. * @param scene defines the scene to apply the delta to
  164713. */
  164714. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  164715. private static _ApplyPropertiesToEntity;
  164716. private static _ApplyDeltaForEntity;
  164717. }
  164718. }
  164719. declare module BABYLON {
  164720. /**
  164721. * A 3D trajectory consisting of an order list of vectors describing a
  164722. * path of motion through 3D space.
  164723. */
  164724. export class Trajectory {
  164725. private _points;
  164726. private readonly _segmentLength;
  164727. /**
  164728. * Serialize to JSON.
  164729. * @returns serialized JSON string
  164730. */
  164731. serialize(): string;
  164732. /**
  164733. * Deserialize from JSON.
  164734. * @param json serialized JSON string
  164735. * @returns deserialized Trajectory
  164736. */
  164737. static Deserialize(json: string): Trajectory;
  164738. /**
  164739. * Create a new empty Trajectory.
  164740. * @param segmentLength radius of discretization for Trajectory points
  164741. */
  164742. constructor(segmentLength?: number);
  164743. /**
  164744. * Get the length of the Trajectory.
  164745. * @returns length of the Trajectory
  164746. */
  164747. getLength(): number;
  164748. /**
  164749. * Append a new point to the Trajectory.
  164750. * NOTE: This implementation has many allocations.
  164751. * @param point point to append to the Trajectory
  164752. */
  164753. add(point: DeepImmutable<Vector3>): void;
  164754. /**
  164755. * Create a new Trajectory with a segment length chosen to make it
  164756. * probable that the new Trajectory will have a specified number of
  164757. * segments. This operation is imprecise.
  164758. * @param targetResolution number of segments desired
  164759. * @returns new Trajectory with approximately the requested number of segments
  164760. */
  164761. resampleAtTargetResolution(targetResolution: number): Trajectory;
  164762. /**
  164763. * Convert Trajectory segments into tokenized representation. This
  164764. * representation is an array of numbers where each nth number is the
  164765. * index of the token which is most similar to the nth segment of the
  164766. * Trajectory.
  164767. * @param tokens list of vectors which serve as discrete tokens
  164768. * @returns list of indices of most similar token per segment
  164769. */
  164770. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  164771. private static _forwardDir;
  164772. private static _inverseFromVec;
  164773. private static _upDir;
  164774. private static _fromToVec;
  164775. private static _lookMatrix;
  164776. /**
  164777. * Transform the rotation (i.e., direction) of a segment to isolate
  164778. * the relative transformation represented by the segment. This operation
  164779. * may or may not succeed due to singularities in the equations that define
  164780. * motion relativity in this context.
  164781. * @param priorVec the origin of the prior segment
  164782. * @param fromVec the origin of the current segment
  164783. * @param toVec the destination of the current segment
  164784. * @param result reference to output variable
  164785. * @returns whether or not transformation was successful
  164786. */
  164787. private static _transformSegmentDirToRef;
  164788. private static _bestMatch;
  164789. private static _score;
  164790. private static _bestScore;
  164791. /**
  164792. * Determine which token vector is most similar to the
  164793. * segment vector.
  164794. * @param segment segment vector
  164795. * @param tokens token vector list
  164796. * @returns index of the most similar token to the segment
  164797. */
  164798. private static _tokenizeSegment;
  164799. }
  164800. /**
  164801. * Class representing a set of known, named trajectories to which Trajectories can be
  164802. * added and using which Trajectories can be recognized.
  164803. */
  164804. export class TrajectoryClassifier {
  164805. private _maximumAllowableMatchCost;
  164806. private _vector3Alphabet;
  164807. private _levenshteinAlphabet;
  164808. private _nameToDescribedTrajectory;
  164809. /**
  164810. * Serialize to JSON.
  164811. * @returns JSON serialization
  164812. */
  164813. serialize(): string;
  164814. /**
  164815. * Deserialize from JSON.
  164816. * @param json JSON serialization
  164817. * @returns deserialized TrajectorySet
  164818. */
  164819. static Deserialize(json: string): TrajectoryClassifier;
  164820. /**
  164821. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  164822. * VERY naive, need to be generating these things from known
  164823. * sets. Better version later, probably eliminating this one.
  164824. * @returns auto-generated TrajectorySet
  164825. */
  164826. static Generate(): TrajectoryClassifier;
  164827. private constructor();
  164828. /**
  164829. * Add a new Trajectory to the set with a given name.
  164830. * @param trajectory new Trajectory to be added
  164831. * @param classification name to which to add the Trajectory
  164832. */
  164833. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  164834. /**
  164835. * Remove a known named trajectory and all Trajectories associated with it.
  164836. * @param classification name to remove
  164837. * @returns whether anything was removed
  164838. */
  164839. deleteClassification(classification: string): boolean;
  164840. /**
  164841. * Attempt to recognize a Trajectory from among all the classifications
  164842. * already known to the classifier.
  164843. * @param trajectory Trajectory to be recognized
  164844. * @returns classification of Trajectory if recognized, null otherwise
  164845. */
  164846. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  164847. }
  164848. }
  164849. declare module BABYLON {
  164850. /**
  164851. * An interface for all Hit test features
  164852. */
  164853. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  164854. /**
  164855. * Triggered when new babylon (transformed) hit test results are available
  164856. */
  164857. onHitTestResultObservable: Observable<T[]>;
  164858. }
  164859. /**
  164860. * Options used for hit testing
  164861. */
  164862. export interface IWebXRLegacyHitTestOptions {
  164863. /**
  164864. * Only test when user interacted with the scene. Default - hit test every frame
  164865. */
  164866. testOnPointerDownOnly?: boolean;
  164867. /**
  164868. * The node to use to transform the local results to world coordinates
  164869. */
  164870. worldParentNode?: TransformNode;
  164871. }
  164872. /**
  164873. * Interface defining the babylon result of raycasting/hit-test
  164874. */
  164875. export interface IWebXRLegacyHitResult {
  164876. /**
  164877. * Transformation matrix that can be applied to a node that will put it in the hit point location
  164878. */
  164879. transformationMatrix: Matrix;
  164880. /**
  164881. * The native hit test result
  164882. */
  164883. xrHitResult: XRHitResult | XRHitTestResult;
  164884. }
  164885. /**
  164886. * The currently-working hit-test module.
  164887. * Hit test (or Ray-casting) is used to interact with the real world.
  164888. * For further information read here - https://github.com/immersive-web/hit-test
  164889. */
  164890. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  164891. /**
  164892. * options to use when constructing this feature
  164893. */
  164894. readonly options: IWebXRLegacyHitTestOptions;
  164895. private _direction;
  164896. private _mat;
  164897. private _onSelectEnabled;
  164898. private _origin;
  164899. /**
  164900. * The module's name
  164901. */
  164902. static readonly Name: string;
  164903. /**
  164904. * The (Babylon) version of this module.
  164905. * This is an integer representing the implementation version.
  164906. * This number does not correspond to the WebXR specs version
  164907. */
  164908. static readonly Version: number;
  164909. /**
  164910. * Populated with the last native XR Hit Results
  164911. */
  164912. lastNativeXRHitResults: XRHitResult[];
  164913. /**
  164914. * Triggered when new babylon (transformed) hit test results are available
  164915. */
  164916. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  164917. /**
  164918. * Creates a new instance of the (legacy version) hit test feature
  164919. * @param _xrSessionManager an instance of WebXRSessionManager
  164920. * @param options options to use when constructing this feature
  164921. */
  164922. constructor(_xrSessionManager: WebXRSessionManager,
  164923. /**
  164924. * options to use when constructing this feature
  164925. */
  164926. options?: IWebXRLegacyHitTestOptions);
  164927. /**
  164928. * execute a hit test with an XR Ray
  164929. *
  164930. * @param xrSession a native xrSession that will execute this hit test
  164931. * @param xrRay the ray (position and direction) to use for ray-casting
  164932. * @param referenceSpace native XR reference space to use for the hit-test
  164933. * @param filter filter function that will filter the results
  164934. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  164935. */
  164936. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  164937. /**
  164938. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  164939. * @param event the (select) event to use to select with
  164940. * @param referenceSpace the reference space to use for this hit test
  164941. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  164942. */
  164943. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  164944. /**
  164945. * attach this feature
  164946. * Will usually be called by the features manager
  164947. *
  164948. * @returns true if successful.
  164949. */
  164950. attach(): boolean;
  164951. /**
  164952. * detach this feature.
  164953. * Will usually be called by the features manager
  164954. *
  164955. * @returns true if successful.
  164956. */
  164957. detach(): boolean;
  164958. /**
  164959. * Dispose this feature and all of the resources attached
  164960. */
  164961. dispose(): void;
  164962. protected _onXRFrame(frame: XRFrame): void;
  164963. private _onHitTestResults;
  164964. private _onSelect;
  164965. }
  164966. }
  164967. declare module BABYLON {
  164968. /**
  164969. * Options used for hit testing (version 2)
  164970. */
  164971. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  164972. /**
  164973. * Do not create a permanent hit test. Will usually be used when only
  164974. * transient inputs are needed.
  164975. */
  164976. disablePermanentHitTest?: boolean;
  164977. /**
  164978. * Enable transient (for example touch-based) hit test inspections
  164979. */
  164980. enableTransientHitTest?: boolean;
  164981. /**
  164982. * Offset ray for the permanent hit test
  164983. */
  164984. offsetRay?: Vector3;
  164985. /**
  164986. * Offset ray for the transient hit test
  164987. */
  164988. transientOffsetRay?: Vector3;
  164989. /**
  164990. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  164991. */
  164992. useReferenceSpace?: boolean;
  164993. /**
  164994. * Override the default entity type(s) of the hit-test result
  164995. */
  164996. entityTypes?: XRHitTestTrackableType[];
  164997. }
  164998. /**
  164999. * Interface defining the babylon result of hit-test
  165000. */
  165001. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  165002. /**
  165003. * The input source that generated this hit test (if transient)
  165004. */
  165005. inputSource?: XRInputSource;
  165006. /**
  165007. * Is this a transient hit test
  165008. */
  165009. isTransient?: boolean;
  165010. /**
  165011. * Position of the hit test result
  165012. */
  165013. position: Vector3;
  165014. /**
  165015. * Rotation of the hit test result
  165016. */
  165017. rotationQuaternion: Quaternion;
  165018. /**
  165019. * The native hit test result
  165020. */
  165021. xrHitResult: XRHitTestResult;
  165022. }
  165023. /**
  165024. * The currently-working hit-test module.
  165025. * Hit test (or Ray-casting) is used to interact with the real world.
  165026. * For further information read here - https://github.com/immersive-web/hit-test
  165027. *
  165028. * Tested on chrome (mobile) 80.
  165029. */
  165030. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  165031. /**
  165032. * options to use when constructing this feature
  165033. */
  165034. readonly options: IWebXRHitTestOptions;
  165035. private _tmpMat;
  165036. private _tmpPos;
  165037. private _tmpQuat;
  165038. private _transientXrHitTestSource;
  165039. private _xrHitTestSource;
  165040. private initHitTestSource;
  165041. /**
  165042. * The module's name
  165043. */
  165044. static readonly Name: string;
  165045. /**
  165046. * The (Babylon) version of this module.
  165047. * This is an integer representing the implementation version.
  165048. * This number does not correspond to the WebXR specs version
  165049. */
  165050. static readonly Version: number;
  165051. /**
  165052. * When set to true, each hit test will have its own position/rotation objects
  165053. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  165054. * the developers will clone them or copy them as they see fit.
  165055. */
  165056. autoCloneTransformation: boolean;
  165057. /**
  165058. * Triggered when new babylon (transformed) hit test results are available
  165059. * Note - this will be called when results come back from the device. It can be an empty array!!
  165060. */
  165061. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  165062. /**
  165063. * Use this to temporarily pause hit test checks.
  165064. */
  165065. paused: boolean;
  165066. /**
  165067. * Creates a new instance of the hit test feature
  165068. * @param _xrSessionManager an instance of WebXRSessionManager
  165069. * @param options options to use when constructing this feature
  165070. */
  165071. constructor(_xrSessionManager: WebXRSessionManager,
  165072. /**
  165073. * options to use when constructing this feature
  165074. */
  165075. options?: IWebXRHitTestOptions);
  165076. /**
  165077. * attach this feature
  165078. * Will usually be called by the features manager
  165079. *
  165080. * @returns true if successful.
  165081. */
  165082. attach(): boolean;
  165083. /**
  165084. * detach this feature.
  165085. * Will usually be called by the features manager
  165086. *
  165087. * @returns true if successful.
  165088. */
  165089. detach(): boolean;
  165090. /**
  165091. * Dispose this feature and all of the resources attached
  165092. */
  165093. dispose(): void;
  165094. protected _onXRFrame(frame: XRFrame): void;
  165095. private _processWebXRHitTestResult;
  165096. }
  165097. }
  165098. declare module BABYLON {
  165099. /**
  165100. * Configuration options of the anchor system
  165101. */
  165102. export interface IWebXRAnchorSystemOptions {
  165103. /**
  165104. * a node that will be used to convert local to world coordinates
  165105. */
  165106. worldParentNode?: TransformNode;
  165107. /**
  165108. * If set to true a reference of the created anchors will be kept until the next session starts
  165109. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  165110. */
  165111. doNotRemoveAnchorsOnSessionEnded?: boolean;
  165112. }
  165113. /**
  165114. * A babylon container for an XR Anchor
  165115. */
  165116. export interface IWebXRAnchor {
  165117. /**
  165118. * A babylon-assigned ID for this anchor
  165119. */
  165120. id: number;
  165121. /**
  165122. * Transformation matrix to apply to an object attached to this anchor
  165123. */
  165124. transformationMatrix: Matrix;
  165125. /**
  165126. * The native anchor object
  165127. */
  165128. xrAnchor: XRAnchor;
  165129. /**
  165130. * if defined, this object will be constantly updated by the anchor's position and rotation
  165131. */
  165132. attachedNode?: TransformNode;
  165133. /**
  165134. * Remove this anchor from the scene
  165135. */
  165136. remove(): void;
  165137. }
  165138. /**
  165139. * An implementation of the anchor system for WebXR.
  165140. * For further information see https://github.com/immersive-web/anchors/
  165141. */
  165142. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  165143. private _options;
  165144. private _lastFrameDetected;
  165145. private _trackedAnchors;
  165146. private _referenceSpaceForFrameAnchors;
  165147. private _futureAnchors;
  165148. /**
  165149. * The module's name
  165150. */
  165151. static readonly Name: string;
  165152. /**
  165153. * The (Babylon) version of this module.
  165154. * This is an integer representing the implementation version.
  165155. * This number does not correspond to the WebXR specs version
  165156. */
  165157. static readonly Version: number;
  165158. /**
  165159. * Observers registered here will be executed when a new anchor was added to the session
  165160. */
  165161. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  165162. /**
  165163. * Observers registered here will be executed when an anchor was removed from the session
  165164. */
  165165. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  165166. /**
  165167. * Observers registered here will be executed when an existing anchor updates
  165168. * This can execute N times every frame
  165169. */
  165170. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  165171. /**
  165172. * Set the reference space to use for anchor creation, when not using a hit test.
  165173. * Will default to the session's reference space if not defined
  165174. */
  165175. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  165176. /**
  165177. * constructs a new anchor system
  165178. * @param _xrSessionManager an instance of WebXRSessionManager
  165179. * @param _options configuration object for this feature
  165180. */
  165181. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  165182. private _tmpVector;
  165183. private _tmpQuaternion;
  165184. private _populateTmpTransformation;
  165185. /**
  165186. * Create a new anchor point using a hit test result at a specific point in the scene
  165187. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  165188. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  165189. *
  165190. * @param hitTestResult The hit test result to use for this anchor creation
  165191. * @param position an optional position offset for this anchor
  165192. * @param rotationQuaternion an optional rotation offset for this anchor
  165193. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  165194. */
  165195. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  165196. /**
  165197. * Add a new anchor at a specific position and rotation
  165198. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  165199. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  165200. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  165201. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  165202. *
  165203. * @param position the position in which to add an anchor
  165204. * @param rotationQuaternion an optional rotation for the anchor transformation
  165205. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  165206. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  165207. */
  165208. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  165209. /**
  165210. * Get the list of anchors currently being tracked by the system
  165211. */
  165212. get anchors(): IWebXRAnchor[];
  165213. /**
  165214. * detach this feature.
  165215. * Will usually be called by the features manager
  165216. *
  165217. * @returns true if successful.
  165218. */
  165219. detach(): boolean;
  165220. /**
  165221. * Dispose this feature and all of the resources attached
  165222. */
  165223. dispose(): void;
  165224. protected _onXRFrame(frame: XRFrame): void;
  165225. /**
  165226. * avoiding using Array.find for global support.
  165227. * @param xrAnchor the plane to find in the array
  165228. */
  165229. private _findIndexInAnchorArray;
  165230. private _updateAnchorWithXRFrame;
  165231. private _createAnchorAtTransformation;
  165232. }
  165233. }
  165234. declare module BABYLON {
  165235. /**
  165236. * Options used in the plane detector module
  165237. */
  165238. export interface IWebXRPlaneDetectorOptions {
  165239. /**
  165240. * The node to use to transform the local results to world coordinates
  165241. */
  165242. worldParentNode?: TransformNode;
  165243. /**
  165244. * If set to true a reference of the created planes will be kept until the next session starts
  165245. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  165246. */
  165247. doNotRemovePlanesOnSessionEnded?: boolean;
  165248. /**
  165249. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  165250. */
  165251. preferredDetectorOptions?: XRGeometryDetectorOptions;
  165252. }
  165253. /**
  165254. * A babylon interface for a WebXR plane.
  165255. * A Plane is actually a polygon, built from N points in space
  165256. *
  165257. * Supported in chrome 79, not supported in canary 81 ATM
  165258. */
  165259. export interface IWebXRPlane {
  165260. /**
  165261. * a babylon-assigned ID for this polygon
  165262. */
  165263. id: number;
  165264. /**
  165265. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  165266. */
  165267. polygonDefinition: Array<Vector3>;
  165268. /**
  165269. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  165270. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  165271. */
  165272. transformationMatrix: Matrix;
  165273. /**
  165274. * the native xr-plane object
  165275. */
  165276. xrPlane: XRPlane;
  165277. }
  165278. /**
  165279. * The plane detector is used to detect planes in the real world when in AR
  165280. * For more information see https://github.com/immersive-web/real-world-geometry/
  165281. */
  165282. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  165283. private _options;
  165284. private _detectedPlanes;
  165285. private _enabled;
  165286. private _lastFrameDetected;
  165287. /**
  165288. * The module's name
  165289. */
  165290. static readonly Name: string;
  165291. /**
  165292. * The (Babylon) version of this module.
  165293. * This is an integer representing the implementation version.
  165294. * This number does not correspond to the WebXR specs version
  165295. */
  165296. static readonly Version: number;
  165297. /**
  165298. * Observers registered here will be executed when a new plane was added to the session
  165299. */
  165300. onPlaneAddedObservable: Observable<IWebXRPlane>;
  165301. /**
  165302. * Observers registered here will be executed when a plane is no longer detected in the session
  165303. */
  165304. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  165305. /**
  165306. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  165307. * This can execute N times every frame
  165308. */
  165309. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  165310. /**
  165311. * construct a new Plane Detector
  165312. * @param _xrSessionManager an instance of xr Session manager
  165313. * @param _options configuration to use when constructing this feature
  165314. */
  165315. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  165316. /**
  165317. * detach this feature.
  165318. * Will usually be called by the features manager
  165319. *
  165320. * @returns true if successful.
  165321. */
  165322. detach(): boolean;
  165323. /**
  165324. * Dispose this feature and all of the resources attached
  165325. */
  165326. dispose(): void;
  165327. /**
  165328. * Check if the needed objects are defined.
  165329. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  165330. */
  165331. isCompatible(): boolean;
  165332. protected _onXRFrame(frame: XRFrame): void;
  165333. private _init;
  165334. private _updatePlaneWithXRPlane;
  165335. /**
  165336. * avoiding using Array.find for global support.
  165337. * @param xrPlane the plane to find in the array
  165338. */
  165339. private _findIndexInPlaneArray;
  165340. }
  165341. }
  165342. declare module BABYLON {
  165343. /**
  165344. * Options interface for the background remover plugin
  165345. */
  165346. export interface IWebXRBackgroundRemoverOptions {
  165347. /**
  165348. * Further background meshes to disable when entering AR
  165349. */
  165350. backgroundMeshes?: AbstractMesh[];
  165351. /**
  165352. * flags to configure the removal of the environment helper.
  165353. * If not set, the entire background will be removed. If set, flags should be set as well.
  165354. */
  165355. environmentHelperRemovalFlags?: {
  165356. /**
  165357. * Should the skybox be removed (default false)
  165358. */
  165359. skyBox?: boolean;
  165360. /**
  165361. * Should the ground be removed (default false)
  165362. */
  165363. ground?: boolean;
  165364. };
  165365. /**
  165366. * don't disable the environment helper
  165367. */
  165368. ignoreEnvironmentHelper?: boolean;
  165369. }
  165370. /**
  165371. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  165372. */
  165373. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  165374. /**
  165375. * read-only options to be used in this module
  165376. */
  165377. readonly options: IWebXRBackgroundRemoverOptions;
  165378. /**
  165379. * The module's name
  165380. */
  165381. static readonly Name: string;
  165382. /**
  165383. * The (Babylon) version of this module.
  165384. * This is an integer representing the implementation version.
  165385. * This number does not correspond to the WebXR specs version
  165386. */
  165387. static readonly Version: number;
  165388. /**
  165389. * registered observers will be triggered when the background state changes
  165390. */
  165391. onBackgroundStateChangedObservable: Observable<boolean>;
  165392. /**
  165393. * constructs a new background remover module
  165394. * @param _xrSessionManager the session manager for this module
  165395. * @param options read-only options to be used in this module
  165396. */
  165397. constructor(_xrSessionManager: WebXRSessionManager,
  165398. /**
  165399. * read-only options to be used in this module
  165400. */
  165401. options?: IWebXRBackgroundRemoverOptions);
  165402. /**
  165403. * attach this feature
  165404. * Will usually be called by the features manager
  165405. *
  165406. * @returns true if successful.
  165407. */
  165408. attach(): boolean;
  165409. /**
  165410. * detach this feature.
  165411. * Will usually be called by the features manager
  165412. *
  165413. * @returns true if successful.
  165414. */
  165415. detach(): boolean;
  165416. /**
  165417. * Dispose this feature and all of the resources attached
  165418. */
  165419. dispose(): void;
  165420. protected _onXRFrame(_xrFrame: XRFrame): void;
  165421. private _setBackgroundState;
  165422. }
  165423. }
  165424. declare module BABYLON {
  165425. /**
  165426. * Options for the controller physics feature
  165427. */
  165428. export class IWebXRControllerPhysicsOptions {
  165429. /**
  165430. * Should the headset get its own impostor
  165431. */
  165432. enableHeadsetImpostor?: boolean;
  165433. /**
  165434. * Optional parameters for the headset impostor
  165435. */
  165436. headsetImpostorParams?: {
  165437. /**
  165438. * The type of impostor to create. Default is sphere
  165439. */
  165440. impostorType: number;
  165441. /**
  165442. * the size of the impostor. Defaults to 10cm
  165443. */
  165444. impostorSize?: number | {
  165445. width: number;
  165446. height: number;
  165447. depth: number;
  165448. };
  165449. /**
  165450. * Friction definitions
  165451. */
  165452. friction?: number;
  165453. /**
  165454. * Restitution
  165455. */
  165456. restitution?: number;
  165457. };
  165458. /**
  165459. * The physics properties of the future impostors
  165460. */
  165461. physicsProperties?: {
  165462. /**
  165463. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  165464. * Note that this requires a physics engine that supports mesh impostors!
  165465. */
  165466. useControllerMesh?: boolean;
  165467. /**
  165468. * The type of impostor to create. Default is sphere
  165469. */
  165470. impostorType?: number;
  165471. /**
  165472. * the size of the impostor. Defaults to 10cm
  165473. */
  165474. impostorSize?: number | {
  165475. width: number;
  165476. height: number;
  165477. depth: number;
  165478. };
  165479. /**
  165480. * Friction definitions
  165481. */
  165482. friction?: number;
  165483. /**
  165484. * Restitution
  165485. */
  165486. restitution?: number;
  165487. };
  165488. /**
  165489. * the xr input to use with this pointer selection
  165490. */
  165491. xrInput: WebXRInput;
  165492. }
  165493. /**
  165494. * Add physics impostor to your webxr controllers,
  165495. * including naive calculation of their linear and angular velocity
  165496. */
  165497. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  165498. private readonly _options;
  165499. private _attachController;
  165500. private _controllers;
  165501. private _debugMode;
  165502. private _delta;
  165503. private _headsetImpostor?;
  165504. private _headsetMesh?;
  165505. private _lastTimestamp;
  165506. private _tmpQuaternion;
  165507. private _tmpVector;
  165508. /**
  165509. * The module's name
  165510. */
  165511. static readonly Name: string;
  165512. /**
  165513. * The (Babylon) version of this module.
  165514. * This is an integer representing the implementation version.
  165515. * This number does not correspond to the webxr specs version
  165516. */
  165517. static readonly Version: number;
  165518. /**
  165519. * Construct a new Controller Physics Feature
  165520. * @param _xrSessionManager the corresponding xr session manager
  165521. * @param _options options to create this feature with
  165522. */
  165523. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  165524. /**
  165525. * @hidden
  165526. * enable debugging - will show console outputs and the impostor mesh
  165527. */
  165528. _enablePhysicsDebug(): void;
  165529. /**
  165530. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  165531. * @param xrController the controller to add
  165532. */
  165533. addController(xrController: WebXRInputSource): void;
  165534. /**
  165535. * attach this feature
  165536. * Will usually be called by the features manager
  165537. *
  165538. * @returns true if successful.
  165539. */
  165540. attach(): boolean;
  165541. /**
  165542. * detach this feature.
  165543. * Will usually be called by the features manager
  165544. *
  165545. * @returns true if successful.
  165546. */
  165547. detach(): boolean;
  165548. /**
  165549. * Get the headset impostor, if enabled
  165550. * @returns the impostor
  165551. */
  165552. getHeadsetImpostor(): PhysicsImpostor | undefined;
  165553. /**
  165554. * Get the physics impostor of a specific controller.
  165555. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  165556. * @param controller the controller or the controller id of which to get the impostor
  165557. * @returns the impostor or null
  165558. */
  165559. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  165560. /**
  165561. * Update the physics properties provided in the constructor
  165562. * @param newProperties the new properties object
  165563. */
  165564. setPhysicsProperties(newProperties: {
  165565. impostorType?: number;
  165566. impostorSize?: number | {
  165567. width: number;
  165568. height: number;
  165569. depth: number;
  165570. };
  165571. friction?: number;
  165572. restitution?: number;
  165573. }): void;
  165574. protected _onXRFrame(_xrFrame: any): void;
  165575. private _detachController;
  165576. }
  165577. }
  165578. declare module BABYLON {
  165579. /**
  165580. * A babylon interface for a "WebXR" feature point.
  165581. * Represents the position and confidence value of a given feature point.
  165582. */
  165583. export interface IWebXRFeaturePoint {
  165584. /**
  165585. * Represents the position of the feature point in world space.
  165586. */
  165587. position: Vector3;
  165588. /**
  165589. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  165590. */
  165591. confidenceValue: number;
  165592. }
  165593. /**
  165594. * The feature point system is used to detect feature points from real world geometry.
  165595. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  165596. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  165597. */
  165598. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  165599. private _enabled;
  165600. private _featurePointCloud;
  165601. /**
  165602. * The module's name
  165603. */
  165604. static readonly Name: string;
  165605. /**
  165606. * The (Babylon) version of this module.
  165607. * This is an integer representing the implementation version.
  165608. * This number does not correspond to the WebXR specs version
  165609. */
  165610. static readonly Version: number;
  165611. /**
  165612. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  165613. * Will notify the observers about which feature points have been added.
  165614. */
  165615. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  165616. /**
  165617. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  165618. * Will notify the observers about which feature points have been updated.
  165619. */
  165620. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  165621. /**
  165622. * The current feature point cloud maintained across frames.
  165623. */
  165624. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  165625. /**
  165626. * construct the feature point system
  165627. * @param _xrSessionManager an instance of xr Session manager
  165628. */
  165629. constructor(_xrSessionManager: WebXRSessionManager);
  165630. /**
  165631. * Detach this feature.
  165632. * Will usually be called by the features manager
  165633. *
  165634. * @returns true if successful.
  165635. */
  165636. detach(): boolean;
  165637. /**
  165638. * Dispose this feature and all of the resources attached
  165639. */
  165640. dispose(): void;
  165641. /**
  165642. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  165643. */
  165644. protected _onXRFrame(frame: XRFrame): void;
  165645. /**
  165646. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  165647. */
  165648. private _init;
  165649. }
  165650. }
  165651. declare module BABYLON {
  165652. /**
  165653. * Configuration interface for the hand tracking feature
  165654. */
  165655. export interface IWebXRHandTrackingOptions {
  165656. /**
  165657. * The xrInput that will be used as source for new hands
  165658. */
  165659. xrInput: WebXRInput;
  165660. /**
  165661. * Configuration object for the joint meshes
  165662. */
  165663. jointMeshes?: {
  165664. /**
  165665. * Should the meshes created be invisible (defaults to false)
  165666. */
  165667. invisible?: boolean;
  165668. /**
  165669. * A source mesh to be used to create instances. Defaults to a sphere.
  165670. * This mesh will be the source for all other (25) meshes.
  165671. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  165672. */
  165673. sourceMesh?: Mesh;
  165674. /**
  165675. * This function will be called after a mesh was created for a specific joint.
  165676. * Using this function you can either manipulate the instance or return a new mesh.
  165677. * When returning a new mesh the instance created before will be disposed
  165678. */
  165679. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  165680. /**
  165681. * Should the source mesh stay visible. Defaults to false
  165682. */
  165683. keepOriginalVisible?: boolean;
  165684. /**
  165685. * Scale factor for all instances (defaults to 2)
  165686. */
  165687. scaleFactor?: number;
  165688. /**
  165689. * Should each instance have its own physics impostor
  165690. */
  165691. enablePhysics?: boolean;
  165692. /**
  165693. * If enabled, override default physics properties
  165694. */
  165695. physicsProps?: {
  165696. friction?: number;
  165697. restitution?: number;
  165698. impostorType?: number;
  165699. };
  165700. /**
  165701. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  165702. */
  165703. disableDefaultHandMesh?: boolean;
  165704. /**
  165705. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  165706. */
  165707. handMeshes?: {
  165708. right: AbstractMesh;
  165709. left: AbstractMesh;
  165710. };
  165711. /**
  165712. * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.
  165713. */
  165714. leftHandedSystemMeshes?: boolean;
  165715. /**
  165716. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  165717. */
  165718. rigMapping?: {
  165719. right: string[];
  165720. left: string[];
  165721. };
  165722. };
  165723. }
  165724. /**
  165725. * Parts of the hands divided to writs and finger names
  165726. */
  165727. export const enum HandPart {
  165728. /**
  165729. * HandPart - Wrist
  165730. */
  165731. WRIST = "wrist",
  165732. /**
  165733. * HandPart - The Thumb
  165734. */
  165735. THUMB = "thumb",
  165736. /**
  165737. * HandPart - Index finger
  165738. */
  165739. INDEX = "index",
  165740. /**
  165741. * HandPart - Middle finger
  165742. */
  165743. MIDDLE = "middle",
  165744. /**
  165745. * HandPart - Ring finger
  165746. */
  165747. RING = "ring",
  165748. /**
  165749. * HandPart - Little finger
  165750. */
  165751. LITTLE = "little"
  165752. }
  165753. /**
  165754. * Representing a single hand (with its corresponding native XRHand object)
  165755. */
  165756. export class WebXRHand implements IDisposable {
  165757. /** the controller to which the hand correlates */
  165758. readonly xrController: WebXRInputSource;
  165759. /** the meshes to be used to track the hand joints */
  165760. readonly trackedMeshes: AbstractMesh[];
  165761. private _handMesh?;
  165762. private _rigMapping?;
  165763. private _leftHandedMeshes?;
  165764. private _scene;
  165765. private _defaultHandMesh;
  165766. private _transformNodeMapping;
  165767. private _boneMapping;
  165768. private _useBones;
  165769. /**
  165770. * Hand-parts definition (key is HandPart)
  165771. */
  165772. handPartsDefinition: {
  165773. [key: string]: number[];
  165774. };
  165775. /**
  165776. * Observers will be triggered when the mesh for this hand was initialized.
  165777. */
  165778. onHandMeshReadyObservable: Observable<WebXRHand>;
  165779. /**
  165780. * Populate the HandPartsDefinition object.
  165781. * This is called as a side effect since certain browsers don't have XRHand defined.
  165782. */
  165783. private generateHandPartsDefinition;
  165784. /**
  165785. * Construct a new hand object
  165786. * @param xrController the controller to which the hand correlates
  165787. * @param trackedMeshes the meshes to be used to track the hand joints
  165788. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  165789. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  165790. * @param disableDefaultHandMesh should the default mesh creation be disabled
  165791. * @param _leftHandedMeshes are the hand meshes left-handed-system meshes
  165792. */
  165793. constructor(
  165794. /** the controller to which the hand correlates */
  165795. xrController: WebXRInputSource,
  165796. /** the meshes to be used to track the hand joints */
  165797. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean, _leftHandedMeshes?: boolean | undefined);
  165798. /**
  165799. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  165800. */
  165801. get handMesh(): AbstractMesh | undefined;
  165802. /**
  165803. * Update this hand from the latest xr frame
  165804. * @param xrFrame xrFrame to update from
  165805. * @param referenceSpace The current viewer reference space
  165806. * @param scaleFactor optional scale factor for the meshes
  165807. */
  165808. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  165809. /**
  165810. * Get meshes of part of the hand
  165811. * @param part the part of hand to get
  165812. * @returns An array of meshes that correlate to the hand part requested
  165813. */
  165814. getHandPartMeshes(part: HandPart): AbstractMesh[];
  165815. /**
  165816. * Dispose this Hand object
  165817. */
  165818. dispose(): void;
  165819. private _generateDefaultHandMesh;
  165820. }
  165821. /**
  165822. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  165823. */
  165824. export class WebXRHandTracking extends WebXRAbstractFeature {
  165825. /**
  165826. * options to use when constructing this feature
  165827. */
  165828. readonly options: IWebXRHandTrackingOptions;
  165829. private static _idCounter;
  165830. /**
  165831. * The module's name
  165832. */
  165833. static readonly Name: string;
  165834. /**
  165835. * The (Babylon) version of this module.
  165836. * This is an integer representing the implementation version.
  165837. * This number does not correspond to the WebXR specs version
  165838. */
  165839. static readonly Version: number;
  165840. /**
  165841. * This observable will notify registered observers when a new hand object was added and initialized
  165842. */
  165843. onHandAddedObservable: Observable<WebXRHand>;
  165844. /**
  165845. * This observable will notify its observers right before the hand object is disposed
  165846. */
  165847. onHandRemovedObservable: Observable<WebXRHand>;
  165848. private _hands;
  165849. /**
  165850. * Creates a new instance of the hit test feature
  165851. * @param _xrSessionManager an instance of WebXRSessionManager
  165852. * @param options options to use when constructing this feature
  165853. */
  165854. constructor(_xrSessionManager: WebXRSessionManager,
  165855. /**
  165856. * options to use when constructing this feature
  165857. */
  165858. options: IWebXRHandTrackingOptions);
  165859. /**
  165860. * Check if the needed objects are defined.
  165861. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  165862. */
  165863. isCompatible(): boolean;
  165864. /**
  165865. * attach this feature
  165866. * Will usually be called by the features manager
  165867. *
  165868. * @returns true if successful.
  165869. */
  165870. attach(): boolean;
  165871. /**
  165872. * detach this feature.
  165873. * Will usually be called by the features manager
  165874. *
  165875. * @returns true if successful.
  165876. */
  165877. detach(): boolean;
  165878. /**
  165879. * Dispose this feature and all of the resources attached
  165880. */
  165881. dispose(): void;
  165882. /**
  165883. * Get the hand object according to the controller id
  165884. * @param controllerId the controller id to which we want to get the hand
  165885. * @returns null if not found or the WebXRHand object if found
  165886. */
  165887. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  165888. /**
  165889. * Get a hand object according to the requested handedness
  165890. * @param handedness the handedness to request
  165891. * @returns null if not found or the WebXRHand object if found
  165892. */
  165893. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  165894. protected _onXRFrame(_xrFrame: XRFrame): void;
  165895. private _attachHand;
  165896. private _detachHand;
  165897. }
  165898. }
  165899. declare module BABYLON {
  165900. /**
  165901. * Options used in the mesh detector module
  165902. */
  165903. export interface IWebXRMeshDetectorOptions {
  165904. /**
  165905. * The node to use to transform the local results to world coordinates
  165906. */
  165907. worldParentNode?: TransformNode;
  165908. /**
  165909. * If set to true a reference of the created meshes will be kept until the next session starts
  165910. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  165911. */
  165912. doNotRemoveMeshesOnSessionEnded?: boolean;
  165913. /**
  165914. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  165915. */
  165916. preferredDetectorOptions?: XRGeometryDetectorOptions;
  165917. /**
  165918. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  165919. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  165920. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  165921. */
  165922. convertCoordinateSystems?: boolean;
  165923. }
  165924. /**
  165925. * A babylon interface for a XR mesh's vertex data.
  165926. *
  165927. * Currently not supported by WebXR, available only with BabylonNative
  165928. */
  165929. export interface IWebXRVertexData {
  165930. /**
  165931. * A babylon-assigned ID for this mesh
  165932. */
  165933. id: number;
  165934. /**
  165935. * Data required for constructing a mesh in Babylon.js.
  165936. */
  165937. xrMesh: XRMesh;
  165938. /**
  165939. * The node to use to transform the local results to world coordinates.
  165940. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  165941. */
  165942. worldParentNode?: TransformNode;
  165943. /**
  165944. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  165945. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  165946. */
  165947. positions?: Float32Array;
  165948. /**
  165949. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  165950. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  165951. */
  165952. indices?: Uint32Array;
  165953. /**
  165954. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  165955. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  165956. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  165957. */
  165958. normals?: Float32Array;
  165959. /**
  165960. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  165961. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  165962. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  165963. */
  165964. transformationMatrix?: Matrix;
  165965. }
  165966. /**
  165967. * The mesh detector is used to detect meshes in the real world when in AR
  165968. */
  165969. export class WebXRMeshDetector extends WebXRAbstractFeature {
  165970. private _options;
  165971. private _detectedMeshes;
  165972. /**
  165973. * The module's name
  165974. */
  165975. static readonly Name: string;
  165976. /**
  165977. * The (Babylon) version of this module.
  165978. * This is an integer representing the implementation version.
  165979. * This number does not correspond to the WebXR specs version
  165980. */
  165981. static readonly Version: number;
  165982. /**
  165983. * Observers registered here will be executed when a new mesh was added to the session
  165984. */
  165985. onMeshAddedObservable: Observable<IWebXRVertexData>;
  165986. /**
  165987. * Observers registered here will be executed when a mesh is no longer detected in the session
  165988. */
  165989. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  165990. /**
  165991. * Observers registered here will be executed when an existing mesh updates
  165992. */
  165993. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  165994. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  165995. detach(): boolean;
  165996. dispose(): void;
  165997. protected _onXRFrame(frame: XRFrame): void;
  165998. private _init;
  165999. private _updateVertexDataWithXRMesh;
  166000. }
  166001. }
  166002. declare module BABYLON {
  166003. /**
  166004. * Options interface for the background remover plugin
  166005. */
  166006. export interface IWebXRImageTrackingOptions {
  166007. /**
  166008. * A required array with images to track
  166009. */
  166010. images: {
  166011. /**
  166012. * The source of the image. can be a URL or an image bitmap
  166013. */
  166014. src: string | ImageBitmap;
  166015. /**
  166016. * The estimated width in the real world (in meters)
  166017. */
  166018. estimatedRealWorldWidth: number;
  166019. }[];
  166020. }
  166021. /**
  166022. * An object representing an image tracked by the system
  166023. */
  166024. export interface IWebXRTrackedImage {
  166025. /**
  166026. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  166027. */
  166028. id: number;
  166029. /**
  166030. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  166031. */
  166032. emulated?: boolean;
  166033. /**
  166034. * Just in case it is needed - the image bitmap that is being tracked
  166035. */
  166036. originalBitmap: ImageBitmap;
  166037. /**
  166038. * The native XR result image tracking result, untouched
  166039. */
  166040. xrTrackingResult?: XRImageTrackingResult;
  166041. /**
  166042. * Width in real world (meters)
  166043. */
  166044. realWorldWidth?: number;
  166045. /**
  166046. * A transformation matrix of this current image in the current reference space.
  166047. */
  166048. transformationMatrix: Matrix;
  166049. /**
  166050. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  166051. */
  166052. ratio?: number;
  166053. }
  166054. /**
  166055. * Image tracking for immersive AR sessions.
  166056. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  166057. */
  166058. export class WebXRImageTracking extends WebXRAbstractFeature {
  166059. /**
  166060. * read-only options to be used in this module
  166061. */
  166062. readonly options: IWebXRImageTrackingOptions;
  166063. /**
  166064. * The module's name
  166065. */
  166066. static readonly Name: string;
  166067. /**
  166068. * The (Babylon) version of this module.
  166069. * This is an integer representing the implementation version.
  166070. * This number does not correspond to the WebXR specs version
  166071. */
  166072. static readonly Version: number;
  166073. /**
  166074. * This will be triggered if the underlying system deems an image untrackable.
  166075. * The index is the index of the image from the array used to initialize the feature.
  166076. */
  166077. onUntrackableImageFoundObservable: Observable<number>;
  166078. /**
  166079. * An image was deemed trackable, and the system will start tracking it.
  166080. */
  166081. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  166082. /**
  166083. * The image was found and its state was updated.
  166084. */
  166085. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  166086. private _trackedImages;
  166087. private _originalTrackingRequest;
  166088. /**
  166089. * constructs the image tracking feature
  166090. * @param _xrSessionManager the session manager for this module
  166091. * @param options read-only options to be used in this module
  166092. */
  166093. constructor(_xrSessionManager: WebXRSessionManager,
  166094. /**
  166095. * read-only options to be used in this module
  166096. */
  166097. options: IWebXRImageTrackingOptions);
  166098. /**
  166099. * attach this feature
  166100. * Will usually be called by the features manager
  166101. *
  166102. * @returns true if successful.
  166103. */
  166104. attach(): boolean;
  166105. /**
  166106. * detach this feature.
  166107. * Will usually be called by the features manager
  166108. *
  166109. * @returns true if successful.
  166110. */
  166111. detach(): boolean;
  166112. /**
  166113. * Check if the needed objects are defined.
  166114. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  166115. */
  166116. isCompatible(): boolean;
  166117. /**
  166118. * Get a tracked image by its ID.
  166119. *
  166120. * @param id the id of the image to load (position in the init array)
  166121. * @returns a trackable image, if exists in this location
  166122. */
  166123. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  166124. /**
  166125. * Dispose this feature and all of the resources attached
  166126. */
  166127. dispose(): void;
  166128. /**
  166129. * Extends the session init object if needed
  166130. * @returns augmentation object fo the xr session init object.
  166131. */
  166132. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  166133. protected _onXRFrame(_xrFrame: XRFrame): void;
  166134. private _init;
  166135. }
  166136. }
  166137. declare module BABYLON {
  166138. /**
  166139. * The motion controller class for all microsoft mixed reality controllers
  166140. */
  166141. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  166142. protected readonly _mapping: {
  166143. defaultButton: {
  166144. valueNodeName: string;
  166145. unpressedNodeName: string;
  166146. pressedNodeName: string;
  166147. };
  166148. defaultAxis: {
  166149. valueNodeName: string;
  166150. minNodeName: string;
  166151. maxNodeName: string;
  166152. };
  166153. buttons: {
  166154. "xr-standard-trigger": {
  166155. rootNodeName: string;
  166156. componentProperty: string;
  166157. states: string[];
  166158. };
  166159. "xr-standard-squeeze": {
  166160. rootNodeName: string;
  166161. componentProperty: string;
  166162. states: string[];
  166163. };
  166164. "xr-standard-touchpad": {
  166165. rootNodeName: string;
  166166. labelAnchorNodeName: string;
  166167. touchPointNodeName: string;
  166168. };
  166169. "xr-standard-thumbstick": {
  166170. rootNodeName: string;
  166171. componentProperty: string;
  166172. states: string[];
  166173. };
  166174. };
  166175. axes: {
  166176. "xr-standard-touchpad": {
  166177. "x-axis": {
  166178. rootNodeName: string;
  166179. };
  166180. "y-axis": {
  166181. rootNodeName: string;
  166182. };
  166183. };
  166184. "xr-standard-thumbstick": {
  166185. "x-axis": {
  166186. rootNodeName: string;
  166187. };
  166188. "y-axis": {
  166189. rootNodeName: string;
  166190. };
  166191. };
  166192. };
  166193. };
  166194. /**
  166195. * The base url used to load the left and right controller models
  166196. */
  166197. static MODEL_BASE_URL: string;
  166198. /**
  166199. * The name of the left controller model file
  166200. */
  166201. static MODEL_LEFT_FILENAME: string;
  166202. /**
  166203. * The name of the right controller model file
  166204. */
  166205. static MODEL_RIGHT_FILENAME: string;
  166206. profileId: string;
  166207. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  166208. protected _getFilenameAndPath(): {
  166209. filename: string;
  166210. path: string;
  166211. };
  166212. protected _getModelLoadingConstraints(): boolean;
  166213. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  166214. protected _setRootMesh(meshes: AbstractMesh[]): void;
  166215. protected _updateModel(): void;
  166216. }
  166217. }
  166218. declare module BABYLON {
  166219. /**
  166220. * The motion controller class for oculus touch (quest, rift).
  166221. * This class supports legacy mapping as well the standard xr mapping
  166222. */
  166223. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  166224. private _forceLegacyControllers;
  166225. private _modelRootNode;
  166226. /**
  166227. * The base url used to load the left and right controller models
  166228. */
  166229. static MODEL_BASE_URL: string;
  166230. /**
  166231. * The name of the left controller model file
  166232. */
  166233. static MODEL_LEFT_FILENAME: string;
  166234. /**
  166235. * The name of the right controller model file
  166236. */
  166237. static MODEL_RIGHT_FILENAME: string;
  166238. /**
  166239. * Base Url for the Quest controller model.
  166240. */
  166241. static QUEST_MODEL_BASE_URL: string;
  166242. profileId: string;
  166243. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  166244. protected _getFilenameAndPath(): {
  166245. filename: string;
  166246. path: string;
  166247. };
  166248. protected _getModelLoadingConstraints(): boolean;
  166249. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  166250. protected _setRootMesh(meshes: AbstractMesh[]): void;
  166251. protected _updateModel(): void;
  166252. /**
  166253. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  166254. * between the touch and touch 2.
  166255. */
  166256. private _isQuest;
  166257. }
  166258. }
  166259. declare module BABYLON {
  166260. /**
  166261. * The motion controller class for the standard HTC-Vive controllers
  166262. */
  166263. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  166264. private _modelRootNode;
  166265. /**
  166266. * The base url used to load the left and right controller models
  166267. */
  166268. static MODEL_BASE_URL: string;
  166269. /**
  166270. * File name for the controller model.
  166271. */
  166272. static MODEL_FILENAME: string;
  166273. profileId: string;
  166274. /**
  166275. * Create a new Vive motion controller object
  166276. * @param scene the scene to use to create this controller
  166277. * @param gamepadObject the corresponding gamepad object
  166278. * @param handedness the handedness of the controller
  166279. */
  166280. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  166281. protected _getFilenameAndPath(): {
  166282. filename: string;
  166283. path: string;
  166284. };
  166285. protected _getModelLoadingConstraints(): boolean;
  166286. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  166287. protected _setRootMesh(meshes: AbstractMesh[]): void;
  166288. protected _updateModel(): void;
  166289. }
  166290. }
  166291. declare module BABYLON {
  166292. /** @hidden */
  166293. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  166294. private static _Cache;
  166295. protected _getRenderPipeline(param: {
  166296. token: any;
  166297. pipeline: Nullable<GPURenderPipeline>;
  166298. }): void;
  166299. protected _setRenderPipeline(param: {
  166300. token: any;
  166301. pipeline: Nullable<GPURenderPipeline>;
  166302. }): void;
  166303. }
  166304. }
  166305. declare module BABYLON {
  166306. /** @hidden */
  166307. export var blurPixelShader: {
  166308. name: string;
  166309. shader: string;
  166310. };
  166311. }
  166312. declare module BABYLON {
  166313. /** @hidden */
  166314. export var pointCloudVertexDeclaration: {
  166315. name: string;
  166316. shader: string;
  166317. };
  166318. }
  166319. // Mixins
  166320. interface Window {
  166321. mozIndexedDB: IDBFactory;
  166322. webkitIndexedDB: IDBFactory;
  166323. msIndexedDB: IDBFactory;
  166324. webkitURL: typeof URL;
  166325. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  166326. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  166327. WebGLRenderingContext: WebGLRenderingContext;
  166328. MSGesture: MSGesture;
  166329. CANNON: any;
  166330. AudioContext: AudioContext;
  166331. webkitAudioContext: AudioContext;
  166332. PointerEvent: any;
  166333. Math: Math;
  166334. Uint8Array: Uint8ArrayConstructor;
  166335. Float32Array: Float32ArrayConstructor;
  166336. mozURL: typeof URL;
  166337. msURL: typeof URL;
  166338. VRFrameData: any; // WebVR, from specs 1.1
  166339. DracoDecoderModule: any;
  166340. setImmediate(handler: (...args: any[]) => void): number;
  166341. }
  166342. interface HTMLCanvasElement {
  166343. requestPointerLock(): void;
  166344. msRequestPointerLock?(): void;
  166345. mozRequestPointerLock?(): void;
  166346. webkitRequestPointerLock?(): void;
  166347. /** Track whether a record is in progress */
  166348. isRecording: boolean;
  166349. /** Capture Stream method defined by some browsers */
  166350. captureStream(fps?: number): MediaStream;
  166351. }
  166352. interface CanvasRenderingContext2D {
  166353. msImageSmoothingEnabled: boolean;
  166354. }
  166355. interface MouseEvent {
  166356. mozMovementX: number;
  166357. mozMovementY: number;
  166358. webkitMovementX: number;
  166359. webkitMovementY: number;
  166360. msMovementX: number;
  166361. msMovementY: number;
  166362. }
  166363. interface Navigator {
  166364. mozGetVRDevices: (any: any) => any;
  166365. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  166366. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  166367. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  166368. webkitGetGamepads(): Gamepad[];
  166369. msGetGamepads(): Gamepad[];
  166370. webkitGamepads(): Gamepad[];
  166371. }
  166372. interface HTMLVideoElement {
  166373. mozSrcObject: any;
  166374. }
  166375. interface Math {
  166376. fround(x: number): number;
  166377. imul(a: number, b: number): number;
  166378. log2(x: number): number;
  166379. }
  166380. interface WebGLRenderingContext {
  166381. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  166382. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  166383. vertexAttribDivisor(index: number, divisor: number): void;
  166384. createVertexArray(): any;
  166385. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  166386. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  166387. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  166388. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  166389. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  166390. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  166391. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  166392. // Queries
  166393. createQuery(): WebGLQuery;
  166394. deleteQuery(query: WebGLQuery): void;
  166395. beginQuery(target: number, query: WebGLQuery): void;
  166396. endQuery(target: number): void;
  166397. getQueryParameter(query: WebGLQuery, pname: number): any;
  166398. getQuery(target: number, pname: number): any;
  166399. MAX_SAMPLES: number;
  166400. RGBA8: number;
  166401. READ_FRAMEBUFFER: number;
  166402. DRAW_FRAMEBUFFER: number;
  166403. UNIFORM_BUFFER: number;
  166404. HALF_FLOAT_OES: number;
  166405. RGBA16F: number;
  166406. RGBA32F: number;
  166407. R32F: number;
  166408. RG32F: number;
  166409. RGB32F: number;
  166410. R16F: number;
  166411. RG16F: number;
  166412. RGB16F: number;
  166413. RED: number;
  166414. RG: number;
  166415. R8: number;
  166416. RG8: number;
  166417. UNSIGNED_INT_24_8: number;
  166418. DEPTH24_STENCIL8: number;
  166419. MIN: number;
  166420. MAX: number;
  166421. /* Multiple Render Targets */
  166422. drawBuffers(buffers: number[]): void;
  166423. readBuffer(src: number): void;
  166424. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  166425. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  166426. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  166427. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  166428. // Occlusion Query
  166429. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  166430. ANY_SAMPLES_PASSED: number;
  166431. QUERY_RESULT_AVAILABLE: number;
  166432. QUERY_RESULT: number;
  166433. }
  166434. interface WebGLProgram {
  166435. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  166436. }
  166437. interface EXT_disjoint_timer_query {
  166438. QUERY_COUNTER_BITS_EXT: number;
  166439. TIME_ELAPSED_EXT: number;
  166440. TIMESTAMP_EXT: number;
  166441. GPU_DISJOINT_EXT: number;
  166442. QUERY_RESULT_EXT: number;
  166443. QUERY_RESULT_AVAILABLE_EXT: number;
  166444. queryCounterEXT(query: WebGLQuery, target: number): void;
  166445. createQueryEXT(): WebGLQuery;
  166446. beginQueryEXT(target: number, query: WebGLQuery): void;
  166447. endQueryEXT(target: number): void;
  166448. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  166449. deleteQueryEXT(query: WebGLQuery): void;
  166450. }
  166451. interface WebGLUniformLocation {
  166452. _currentState: any;
  166453. }
  166454. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  166455. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  166456. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  166457. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  166458. interface WebGLRenderingContext {
  166459. readonly RASTERIZER_DISCARD: number;
  166460. readonly DEPTH_COMPONENT24: number;
  166461. readonly TEXTURE_3D: number;
  166462. readonly TEXTURE_2D_ARRAY: number;
  166463. readonly TEXTURE_COMPARE_FUNC: number;
  166464. readonly TEXTURE_COMPARE_MODE: number;
  166465. readonly COMPARE_REF_TO_TEXTURE: number;
  166466. readonly TEXTURE_WRAP_R: number;
  166467. readonly HALF_FLOAT: number;
  166468. readonly RGB8: number;
  166469. readonly RED_INTEGER: number;
  166470. readonly RG_INTEGER: number;
  166471. readonly RGB_INTEGER: number;
  166472. readonly RGBA_INTEGER: number;
  166473. readonly R8_SNORM: number;
  166474. readonly RG8_SNORM: number;
  166475. readonly RGB8_SNORM: number;
  166476. readonly RGBA8_SNORM: number;
  166477. readonly R8I: number;
  166478. readonly RG8I: number;
  166479. readonly RGB8I: number;
  166480. readonly RGBA8I: number;
  166481. readonly R8UI: number;
  166482. readonly RG8UI: number;
  166483. readonly RGB8UI: number;
  166484. readonly RGBA8UI: number;
  166485. readonly R16I: number;
  166486. readonly RG16I: number;
  166487. readonly RGB16I: number;
  166488. readonly RGBA16I: number;
  166489. readonly R16UI: number;
  166490. readonly RG16UI: number;
  166491. readonly RGB16UI: number;
  166492. readonly RGBA16UI: number;
  166493. readonly R32I: number;
  166494. readonly RG32I: number;
  166495. readonly RGB32I: number;
  166496. readonly RGBA32I: number;
  166497. readonly R32UI: number;
  166498. readonly RG32UI: number;
  166499. readonly RGB32UI: number;
  166500. readonly RGBA32UI: number;
  166501. readonly RGB10_A2UI: number;
  166502. readonly R11F_G11F_B10F: number;
  166503. readonly RGB9_E5: number;
  166504. readonly RGB10_A2: number;
  166505. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  166506. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  166507. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  166508. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  166509. readonly DEPTH_COMPONENT32F: number;
  166510. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  166511. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  166512. 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;
  166513. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  166514. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  166515. readonly TRANSFORM_FEEDBACK: number;
  166516. readonly INTERLEAVED_ATTRIBS: number;
  166517. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  166518. createTransformFeedback(): WebGLTransformFeedback;
  166519. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  166520. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  166521. beginTransformFeedback(primitiveMode: number): void;
  166522. endTransformFeedback(): void;
  166523. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  166524. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  166525. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  166526. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  166527. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  166528. }
  166529. interface ImageBitmap {
  166530. readonly width: number;
  166531. readonly height: number;
  166532. close(): void;
  166533. }
  166534. interface WebGLQuery extends WebGLObject {
  166535. }
  166536. declare var WebGLQuery: {
  166537. prototype: WebGLQuery;
  166538. new(): WebGLQuery;
  166539. };
  166540. interface WebGLSampler extends WebGLObject {
  166541. }
  166542. declare var WebGLSampler: {
  166543. prototype: WebGLSampler;
  166544. new(): WebGLSampler;
  166545. };
  166546. interface WebGLSync extends WebGLObject {
  166547. }
  166548. declare var WebGLSync: {
  166549. prototype: WebGLSync;
  166550. new(): WebGLSync;
  166551. };
  166552. interface WebGLTransformFeedback extends WebGLObject {
  166553. }
  166554. declare var WebGLTransformFeedback: {
  166555. prototype: WebGLTransformFeedback;
  166556. new(): WebGLTransformFeedback;
  166557. };
  166558. interface WebGLVertexArrayObject extends WebGLObject {
  166559. }
  166560. declare var WebGLVertexArrayObject: {
  166561. prototype: WebGLVertexArrayObject;
  166562. new(): WebGLVertexArrayObject;
  166563. };
  166564. interface Navigator {
  166565. readonly gpu: GPU | undefined;
  166566. }
  166567. interface GPUColorDict {
  166568. a: number;
  166569. b: number;
  166570. g: number;
  166571. r: number;
  166572. }
  166573. type GPUColor = [number, number, number, number] | GPUColorDict;
  166574. interface GPUOrigin2DDict {
  166575. x?: number;
  166576. y?: number;
  166577. }
  166578. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  166579. interface GPUOrigin3DDict {
  166580. x?: number;
  166581. y?: number;
  166582. z?: number;
  166583. }
  166584. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  166585. interface GPUExtent3DDict {
  166586. width: number;
  166587. height: number;
  166588. depth: number;
  166589. }
  166590. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  166591. type GPUBindingResource =
  166592. | GPUSampler
  166593. | GPUTextureView
  166594. | GPUBufferBinding;
  166595. type GPUExtensionName =
  166596. | "texture-compression-bc"
  166597. | "timestamp-query"
  166598. | "pipeline-statistics-query"
  166599. | "depth-clamping"
  166600. | "depth24unorm-stencil8"
  166601. | "depth32float-stencil8";
  166602. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  166603. type GPUBindingType =
  166604. | "uniform-buffer"
  166605. | "storage-buffer"
  166606. | "readonly-storage-buffer"
  166607. | "sampler"
  166608. | "comparison-sampler"
  166609. | "sampled-texture"
  166610. | "readonly-storage-texture"
  166611. | "writeonly-storage-texture";
  166612. type GPUBlendFactor =
  166613. | "zero"
  166614. | "one"
  166615. | "src-color"
  166616. | "one-minus-src-color"
  166617. | "src-alpha"
  166618. | "one-minus-src-alpha"
  166619. | "dst-color"
  166620. | "one-minus-dst-color"
  166621. | "dst-alpha"
  166622. | "one-minus-dst-alpha"
  166623. | "src-alpha-saturated"
  166624. | "blend-color"
  166625. | "one-minus-blend-color";
  166626. type GPUBlendOperation =
  166627. | "add"
  166628. | "subtract"
  166629. | "reverse-subtract"
  166630. | "min"
  166631. | "max";
  166632. type GPUCompareFunction =
  166633. | "never"
  166634. | "less"
  166635. | "equal"
  166636. | "less-equal"
  166637. | "greater"
  166638. | "not-equal"
  166639. | "greater-equal"
  166640. | "always";
  166641. type GPUCullMode = "none" | "front" | "back";
  166642. type GPUFilterMode = "nearest" | "linear";
  166643. type GPUFrontFace = "ccw" | "cw";
  166644. type GPUIndexFormat = "uint16" | "uint32";
  166645. type GPUInputStepMode = "vertex" | "instance";
  166646. type GPULoadOp = "load";
  166647. type GPUPrimitiveTopology =
  166648. | "point-list"
  166649. | "line-list"
  166650. | "line-strip"
  166651. | "triangle-list"
  166652. | "triangle-strip";
  166653. type GPUStencilOperation =
  166654. | "keep"
  166655. | "zero"
  166656. | "replace"
  166657. | "invert"
  166658. | "increment-clamp"
  166659. | "decrement-clamp"
  166660. | "increment-wrap"
  166661. | "decrement-wrap";
  166662. type GPUStoreOp = "store" | "clear";
  166663. type GPUTextureDimension = "1d" | "2d" | "3d";
  166664. type GPUTextureFormat =
  166665. | "r8unorm"
  166666. | "r8snorm"
  166667. | "r8uint"
  166668. | "r8sint"
  166669. | "r16uint"
  166670. | "r16sint"
  166671. | "r16float"
  166672. | "rg8unorm"
  166673. | "rg8snorm"
  166674. | "rg8uint"
  166675. | "rg8sint"
  166676. | "r32uint"
  166677. | "r32sint"
  166678. | "r32float"
  166679. | "rg16uint"
  166680. | "rg16sint"
  166681. | "rg16float"
  166682. | "rgba8unorm"
  166683. | "rgba8unorm-srgb"
  166684. | "rgba8snorm"
  166685. | "rgba8uint"
  166686. | "rgba8sint"
  166687. | "bgra8unorm"
  166688. | "bgra8unorm-srgb"
  166689. | "rgb9e5ufloat"
  166690. | "rgb10a2unorm"
  166691. | "rg11b10ufloat"
  166692. | "rg32uint"
  166693. | "rg32sint"
  166694. | "rg32float"
  166695. | "rgba16uint"
  166696. | "rgba16sint"
  166697. | "rgba16float"
  166698. | "rgba32uint"
  166699. | "rgba32sint"
  166700. | "rgba32float"
  166701. | "stencil8"
  166702. | "depth16unorm"
  166703. | "depth24plus"
  166704. | "depth24plus-stencil8"
  166705. | "depth32float"
  166706. | "bc1-rgba-unorm"
  166707. | "bc1-rgba-unorm-srgb"
  166708. | "bc2-rgba-unorm"
  166709. | "bc2-rgba-unorm-srgb"
  166710. | "bc3-rgba-unorm"
  166711. | "bc3-rgba-unorm-srgb"
  166712. | "bc4-r-unorm"
  166713. | "bc4-r-snorm"
  166714. | "bc5-rg-unorm"
  166715. | "bc5-rg-snorm"
  166716. | "bc6h-rgb-ufloat"
  166717. | "bc6h-rgb-float"
  166718. | "bc7-rgba-unorm"
  166719. | "bc7-rgba-unorm-srgb"
  166720. | "depth24unorm-stencil8"
  166721. | "depth32float-stencil8";
  166722. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  166723. type GPUTextureViewDimension =
  166724. | "1d"
  166725. | "2d"
  166726. | "2d-array"
  166727. | "cube"
  166728. | "cube-array"
  166729. | "3d";
  166730. type GPUVertexFormat =
  166731. | "uchar2"
  166732. | "uchar4"
  166733. | "char2"
  166734. | "char4"
  166735. | "uchar2norm"
  166736. | "uchar4norm"
  166737. | "char2norm"
  166738. | "char4norm"
  166739. | "ushort2"
  166740. | "ushort4"
  166741. | "short2"
  166742. | "short4"
  166743. | "ushort2norm"
  166744. | "ushort4norm"
  166745. | "short2norm"
  166746. | "short4norm"
  166747. | "half2"
  166748. | "half4"
  166749. | "float"
  166750. | "float2"
  166751. | "float3"
  166752. | "float4"
  166753. | "uint"
  166754. | "uint2"
  166755. | "uint3"
  166756. | "uint4"
  166757. | "int"
  166758. | "int2"
  166759. | "int3"
  166760. | "int4";
  166761. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  166762. type GPUBufferUsageFlags = number;
  166763. type GPUColorWriteFlags = number;
  166764. type GPUShaderStageFlags = number;
  166765. type GPUTextureUsageFlags = number;
  166766. type GPUMapModeFlags = number;
  166767. interface GPUBindGroupEntry {
  166768. binding: number;
  166769. resource: GPUBindingResource;
  166770. }
  166771. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  166772. layout: GPUBindGroupLayout;
  166773. entries: Iterable<GPUBindGroupEntry>;
  166774. }
  166775. interface GPUBindGroupLayoutEntry {
  166776. binding: number;
  166777. visibility: GPUShaderStageFlags;
  166778. type: GPUBindingType;
  166779. hasDynamicOffset?: boolean;
  166780. minBufferBindingSize?: number;
  166781. viewDimension?: GPUTextureViewDimension;
  166782. textureComponentType?: GPUTextureComponentType;
  166783. storageTextureFormat?: GPUTextureFormat;
  166784. }
  166785. interface GPUBindGroupLayoutDescriptor
  166786. extends GPUObjectDescriptorBase {
  166787. entries: Iterable<GPUBindGroupLayoutEntry>;
  166788. }
  166789. interface GPUBlendDescriptor {
  166790. dstFactor?: GPUBlendFactor;
  166791. operation?: GPUBlendOperation;
  166792. srcFactor?: GPUBlendFactor;
  166793. }
  166794. interface GPUColorStateDescriptor {
  166795. format: GPUTextureFormat;
  166796. alphaBlend?: GPUBlendDescriptor;
  166797. colorBlend?: GPUBlendDescriptor;
  166798. writeMask?: GPUColorWriteFlags;
  166799. }
  166800. interface GPUBufferBinding {
  166801. buffer: GPUBuffer;
  166802. offset?: number;
  166803. size?: number;
  166804. }
  166805. interface GPUTextureDataLayout {
  166806. offset?: number;
  166807. bytesPerRow: number;
  166808. rowsPerImage?: number;
  166809. }
  166810. interface GPUBufferCopyView extends GPUTextureDataLayout {
  166811. buffer: GPUBuffer;
  166812. }
  166813. interface GPUTextureCopyView {
  166814. texture: GPUTexture;
  166815. mipLevel?: number;
  166816. origin?: GPUOrigin3D;
  166817. }
  166818. interface GPUImageBitmapCopyView {
  166819. imageBitmap: ImageBitmap;
  166820. origin?: GPUOrigin2D;
  166821. }
  166822. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  166823. size: number;
  166824. usage: GPUBufferUsageFlags;
  166825. mappedAtCreation?: boolean;
  166826. }
  166827. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  166828. label?: string;
  166829. measureExecutionTime?: boolean;
  166830. }
  166831. interface GPUComputePipelineDescriptor
  166832. extends GPUPipelineDescriptorBase {
  166833. computeStage: GPUProgrammableStageDescriptor;
  166834. }
  166835. interface GPUDepthStencilStateDescriptor {
  166836. format: GPUTextureFormat;
  166837. depthWriteEnabled?: boolean;
  166838. depthCompare?: GPUCompareFunction;
  166839. stencilFront?: GPUStencilStateFaceDescriptor;
  166840. stencilBack?: GPUStencilStateFaceDescriptor;
  166841. stencilReadMask?: number;
  166842. stencilWriteMask?: number;
  166843. }
  166844. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  166845. extensions?: Iterable<GPUExtensionName>;
  166846. limits?: GPULimits;
  166847. }
  166848. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  166849. initialValue?: number;
  166850. label?: string;
  166851. signalQueue?: GPUQueue;
  166852. }
  166853. interface GPUVertexAttributeDescriptor {
  166854. format: GPUVertexFormat;
  166855. offset: number;
  166856. shaderLocation: number;
  166857. }
  166858. interface GPUVertexBufferLayoutDescriptor {
  166859. arrayStride: number;
  166860. stepMode?: GPUInputStepMode;
  166861. attributes: Iterable<GPUVertexAttributeDescriptor>;
  166862. }
  166863. interface GPUVertexStateDescriptor {
  166864. indexFormat?: GPUIndexFormat;
  166865. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  166866. }
  166867. interface GPULimits {
  166868. maxBindGroups?: number;
  166869. maxDynamicUniformBuffersPerPipelineLayout?: number;
  166870. maxDynamicStorageBuffersPerPipelineLayout?: number;
  166871. maxSampledTexturesPerShaderStage?: number;
  166872. maxSamplersPerShaderStage?: number;
  166873. maxStorageBuffersPerShaderStage?: number;
  166874. maxStorageTexturesPerShaderStage?: number;
  166875. maxUniformBuffersPerShaderStage?: number;
  166876. maxUniformBufferBindingSize?: number;
  166877. }
  166878. interface GPUPipelineDescriptorBase {
  166879. label?: string;
  166880. layout?: GPUPipelineLayout;
  166881. }
  166882. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  166883. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  166884. }
  166885. interface GPUProgrammableStageDescriptor {
  166886. module: GPUShaderModule;
  166887. entryPoint: string;
  166888. }
  166889. interface GPURasterizationStateDescriptor {
  166890. frontFace?: GPUFrontFace;
  166891. cullMode?: GPUCullMode;
  166892. clampDepth?: boolean;
  166893. depthBias?: number;
  166894. depthBiasSlopeScale?: number;
  166895. depthBiasClamp?: number;
  166896. }
  166897. interface GPURenderPassColorAttachmentDescriptor {
  166898. attachment: GPUTextureView;
  166899. resolveTarget?: GPUTextureView;
  166900. loadValue: GPULoadOp | GPUColor;
  166901. storeOp?: GPUStoreOp;
  166902. }
  166903. interface GPURenderPassDepthStencilAttachmentDescriptor {
  166904. attachment: GPUTextureView;
  166905. depthLoadValue: GPULoadOp | number;
  166906. depthStoreOp: GPUStoreOp;
  166907. depthReadOnly?: boolean;
  166908. stencilLoadValue: GPULoadOp | number;
  166909. stencilStoreOp: GPUStoreOp;
  166910. stencilReadOnly?: boolean;
  166911. }
  166912. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  166913. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  166914. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  166915. }
  166916. interface GPURenderPipelineDescriptor
  166917. extends GPUPipelineDescriptorBase {
  166918. vertexStage: GPUProgrammableStageDescriptor;
  166919. fragmentStage?: GPUProgrammableStageDescriptor;
  166920. primitiveTopology: GPUPrimitiveTopology;
  166921. rasterizationState?: GPURasterizationStateDescriptor;
  166922. colorStates: Iterable<GPUColorStateDescriptor>;
  166923. depthStencilState?: GPUDepthStencilStateDescriptor;
  166924. vertexState?: GPUVertexStateDescriptor;
  166925. sampleCount?: number;
  166926. sampleMask?: number;
  166927. alphaToCoverageEnabled?: boolean;
  166928. }
  166929. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  166930. addressModeU?: GPUAddressMode;
  166931. addressModeV?: GPUAddressMode;
  166932. addressModeW?: GPUAddressMode;
  166933. magFilter?: GPUFilterMode;
  166934. minFilter?: GPUFilterMode;
  166935. mipmapFilter?: GPUFilterMode;
  166936. lodMinClamp?: number;
  166937. lodMaxClamp?: number;
  166938. compare?: GPUCompareFunction;
  166939. maxAnisotropy?: number;
  166940. }
  166941. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  166942. code: Uint32Array | string;
  166943. label?: string;
  166944. sourceMap?: object;
  166945. }
  166946. interface GPUStencilStateFaceDescriptor {
  166947. compare?: GPUCompareFunction;
  166948. depthFailOp?: GPUStencilOperation;
  166949. passOp?: GPUStencilOperation;
  166950. failOp?: GPUStencilOperation;
  166951. }
  166952. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  166953. device: GPUDevice;
  166954. format: GPUTextureFormat;
  166955. usage?: GPUTextureUsageFlags;
  166956. }
  166957. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  166958. size: GPUExtent3D;
  166959. mipLevelCount?: number;
  166960. sampleCount?: number;
  166961. dimension?: GPUTextureDimension;
  166962. format: GPUTextureFormat;
  166963. usage: GPUTextureUsageFlags;
  166964. }
  166965. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  166966. format?: GPUTextureFormat;
  166967. dimension?: GPUTextureViewDimension;
  166968. aspect?: GPUTextureAspect;
  166969. baseArrayLayer?: number;
  166970. baseMipLevel?: number;
  166971. arrayLayerCount?: number;
  166972. mipLevelCount?: number;
  166973. }
  166974. declare class GPUAdapter {
  166975. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  166976. private __brand: void;
  166977. readonly name: string;
  166978. readonly extensions: GPUExtensionName[];
  166979. readonly limits: Required<GPULimits>;
  166980. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  166981. }
  166982. declare class GPUBindGroup implements GPUObjectBase {
  166983. private __brand: void;
  166984. label: string | undefined;
  166985. }
  166986. declare class GPUBindGroupLayout implements GPUObjectBase {
  166987. private __brand: void;
  166988. label: string | undefined;
  166989. }
  166990. declare class GPUBuffer implements GPUObjectBase {
  166991. private __brand: void;
  166992. label: string | undefined;
  166993. destroy(): void;
  166994. unmap(): void;
  166995. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  166996. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  166997. }
  166998. declare class GPUCommandBuffer implements GPUObjectBase {
  166999. private __brand: void;
  167000. label: string | undefined;
  167001. readonly executionTime: Promise<number>;
  167002. }
  167003. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  167004. declare class GPUCommandEncoder implements GPUObjectBase {
  167005. private __brand: void;
  167006. label: string | undefined;
  167007. beginComputePass(
  167008. descriptor?: GPUComputePassDescriptor
  167009. ): GPUComputePassEncoder;
  167010. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  167011. copyBufferToBuffer(
  167012. source: GPUBuffer,
  167013. sourceOffset: number,
  167014. destination: GPUBuffer,
  167015. destinationOffset: number,
  167016. size: number
  167017. ): void;
  167018. copyBufferToTexture(
  167019. source: GPUBufferCopyView,
  167020. destination: GPUTextureCopyView,
  167021. copySize: GPUExtent3D
  167022. ): void;
  167023. copyTextureToBuffer(
  167024. source: GPUTextureCopyView,
  167025. destination: GPUBufferCopyView,
  167026. copySize: GPUExtent3D
  167027. ): void;
  167028. copyTextureToTexture(
  167029. source: GPUTextureCopyView,
  167030. destination: GPUTextureCopyView,
  167031. copySize: GPUExtent3D
  167032. ): void;
  167033. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  167034. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  167035. popDebugGroup(): void;
  167036. pushDebugGroup(groupLabel: string): void;
  167037. insertDebugMarker(markerLabel: string): void;
  167038. }
  167039. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  167040. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  167041. private __brand: void;
  167042. label: string | undefined;
  167043. setBindGroup(
  167044. index: number,
  167045. bindGroup: GPUBindGroup,
  167046. dynamicOffsets?: Iterable<number>
  167047. ): void;
  167048. popDebugGroup(): void;
  167049. pushDebugGroup(groupLabel: string): void;
  167050. insertDebugMarker(markerLabel: string): void;
  167051. setPipeline(pipeline: GPUComputePipeline): void;
  167052. dispatch(x: number, y?: number, z?: number): void;
  167053. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  167054. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  167055. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  167056. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  167057. endPass(): void;
  167058. }
  167059. declare class GPUComputePipeline implements GPUPipelineBase {
  167060. private __brand: void;
  167061. label: string | undefined;
  167062. getBindGroupLayout(index: number): GPUBindGroupLayout;
  167063. }
  167064. interface GPUObjectBase {
  167065. label: string | undefined;
  167066. }
  167067. interface GPUObjectDescriptorBase {
  167068. label?: string;
  167069. }
  167070. // SwapChain / CanvasContext
  167071. declare class GPUCanvasContext {
  167072. private __brand: void;
  167073. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  167074. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  167075. }
  167076. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  167077. private __brand: void;
  167078. label: string | undefined;
  167079. readonly adapter: GPUAdapter;
  167080. readonly extensions: GPUExtensionName[];
  167081. readonly limits: Required<GPULimits>;
  167082. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  167083. createBindGroupLayout(
  167084. descriptor: GPUBindGroupLayoutDescriptor
  167085. ): GPUBindGroupLayout;
  167086. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  167087. createPipelineLayout(
  167088. descriptor: GPUPipelineLayoutDescriptor
  167089. ): GPUPipelineLayout;
  167090. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  167091. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  167092. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  167093. createComputePipeline(
  167094. descriptor: GPUComputePipelineDescriptor
  167095. ): GPUComputePipeline;
  167096. createRenderPipeline(
  167097. descriptor: GPURenderPipelineDescriptor
  167098. ): GPURenderPipeline;
  167099. createReadyComputePipeline(
  167100. descriptor: GPUComputePipelineDescriptor
  167101. ): Promise<GPUComputePipeline>;
  167102. createReadyRenderPipeline(
  167103. descriptor: GPURenderPipelineDescriptor
  167104. ): Promise<GPURenderPipeline>;
  167105. createCommandEncoder(
  167106. descriptor?: GPUCommandEncoderDescriptor
  167107. ): GPUCommandEncoder;
  167108. createRenderBundleEncoder(
  167109. descriptor: GPURenderBundleEncoderDescriptor
  167110. ): GPURenderBundleEncoder;
  167111. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  167112. defaultQueue: GPUQueue;
  167113. pushErrorScope(filter: GPUErrorFilter): void;
  167114. popErrorScope(): Promise<GPUError | null>;
  167115. onuncapturederror: Event | undefined;
  167116. readonly lost: Promise<GPUDeviceLostInfo>;
  167117. }
  167118. declare class GPUFence implements GPUObjectBase {
  167119. private __brand: void;
  167120. label: string | undefined;
  167121. getCompletedValue(): number;
  167122. onCompletion(completionValue: number): Promise<void>;
  167123. }
  167124. interface GPUPipelineBase extends GPUObjectBase {
  167125. getBindGroupLayout(index: number): GPUBindGroupLayout;
  167126. }
  167127. declare class GPUPipelineLayout implements GPUObjectBase {
  167128. private __brand: void;
  167129. label: string | undefined;
  167130. }
  167131. interface GPUProgrammablePassEncoder {
  167132. setBindGroup(
  167133. index: number,
  167134. bindGroup: GPUBindGroup,
  167135. dynamicOffsets?: Iterable<number>
  167136. ): void;
  167137. popDebugGroup(): void;
  167138. pushDebugGroup(groupLabel: string): void;
  167139. insertDebugMarker(markerLabel: string): void;
  167140. }
  167141. declare class GPUQueue implements GPUObjectBase {
  167142. private __brand: void;
  167143. label: string | undefined;
  167144. signal(fence: GPUFence, signalValue: number): void;
  167145. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  167146. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  167147. writeBuffer(buffer: GPUBuffer,
  167148. bufferOffset: number,
  167149. data: BufferSource | ArrayBuffer,
  167150. dataOffset?: number,
  167151. size?: number): void;
  167152. writeTexture(destination: GPUTextureCopyView,
  167153. data: BufferSource | ArrayBuffer,
  167154. dataLayout: GPUTextureDataLayout,
  167155. size: GPUExtent3D): void;
  167156. copyImageBitmapToTexture(
  167157. source: GPUImageBitmapCopyView,
  167158. destination: GPUTextureCopyView,
  167159. copySize: GPUExtent3D
  167160. ): void;
  167161. }
  167162. type GPUQueryType =
  167163. | "occlusion"
  167164. | "timestamp"
  167165. | "pipeline-statistics";
  167166. type GPUPipelineStatisticName =
  167167. | "vertex-shader-invocations"
  167168. | "clipper-invocations"
  167169. | "clipper-primitives-out"
  167170. | "fragment-shader-invocations"
  167171. | "compute-shader-invocations";
  167172. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  167173. type: GPUQueryType;
  167174. count: number;
  167175. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  167176. }
  167177. declare class GPUQuerySet implements GPUObjectBase {
  167178. private __brand: void;
  167179. label: string | undefined;
  167180. destroy(): void;
  167181. }
  167182. interface GPURenderEncoderBase {
  167183. setPipeline(pipeline: GPURenderPipeline): void;
  167184. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  167185. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  167186. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  167187. draw(
  167188. vertexCount: number,
  167189. instanceCount?: number,
  167190. firstVertex?: number,
  167191. firstInstance?: number
  167192. ): void;
  167193. drawIndexed(
  167194. indexCount: number,
  167195. instanceCount?: number,
  167196. firstIndex?: number,
  167197. baseVertex?: number,
  167198. firstInstance?: number
  167199. ): void;
  167200. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  167201. drawIndexedIndirect(
  167202. indirectBuffer: GPUBuffer,
  167203. indirectOffset: number
  167204. ): void;
  167205. }
  167206. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  167207. private __brand: void;
  167208. label: string | undefined;
  167209. setBindGroup(
  167210. index: number,
  167211. bindGroup: GPUBindGroup,
  167212. dynamicOffsets?: Iterable<number>
  167213. ): void;
  167214. popDebugGroup(): void;
  167215. pushDebugGroup(groupLabel: string): void;
  167216. insertDebugMarker(markerLabel: string): void;
  167217. setPipeline(pipeline: GPURenderPipeline): void;
  167218. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  167219. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  167220. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  167221. draw(
  167222. vertexCount: number,
  167223. instanceCount?: number,
  167224. firstVertex?: number,
  167225. firstInstance?: number
  167226. ): void;
  167227. drawIndexed(
  167228. indexCount: number,
  167229. instanceCount?: number,
  167230. firstIndex?: number,
  167231. baseVertex?: number,
  167232. firstInstance?: number
  167233. ): void;
  167234. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  167235. drawIndexedIndirect(
  167236. indirectBuffer: GPUBuffer,
  167237. indirectOffset: number
  167238. ): void;
  167239. setViewport(
  167240. x: number,
  167241. y: number,
  167242. width: number,
  167243. height: number,
  167244. minDepth: number,
  167245. maxDepth: number
  167246. ): void;
  167247. setScissorRect(x: number, y: number, width: number, height: number): void;
  167248. setBlendColor(color: GPUColor): void;
  167249. setStencilReference(reference: number): void;
  167250. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  167251. beginOcclusionQuery(queryIndex: number): void;
  167252. endOcclusionQuery(): void;
  167253. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  167254. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  167255. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  167256. endPass(): void;
  167257. }
  167258. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  167259. declare class GPURenderBundle implements GPUObjectBase {
  167260. private __brand: void;
  167261. label: string | undefined;
  167262. }
  167263. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  167264. private __brand: void;
  167265. label: string | undefined;
  167266. setBindGroup(
  167267. index: number,
  167268. bindGroup: GPUBindGroup,
  167269. dynamicOffsets?: Iterable<number>
  167270. ): void;
  167271. popDebugGroup(): void;
  167272. pushDebugGroup(groupLabel: string): void;
  167273. insertDebugMarker(markerLabel: string): void;
  167274. setPipeline(pipeline: GPURenderPipeline): void;
  167275. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  167276. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  167277. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  167278. draw(
  167279. vertexCount: number,
  167280. instanceCount?: number,
  167281. firstVertex?: number,
  167282. firstInstance?: number
  167283. ): void;
  167284. drawIndexed(
  167285. indexCount: number,
  167286. instanceCount?: number,
  167287. firstIndex?: number,
  167288. baseVertex?: number,
  167289. firstInstance?: number
  167290. ): void;
  167291. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  167292. drawIndexedIndirect(
  167293. indirectBuffer: GPUBuffer,
  167294. indirectOffset: number
  167295. ): void;
  167296. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  167297. }
  167298. interface GPURenderBundleEncoderDescriptor
  167299. extends GPUObjectDescriptorBase {
  167300. colorFormats: Iterable<GPUTextureFormat>;
  167301. depthStencilFormat?: GPUTextureFormat;
  167302. sampleCount?: number;
  167303. }
  167304. declare class GPURenderPipeline implements GPUPipelineBase {
  167305. private __brand: void;
  167306. label: string | undefined;
  167307. getBindGroupLayout(index: number): GPUBindGroupLayout;
  167308. }
  167309. declare class GPUSampler implements GPUObjectBase {
  167310. private __brand: void;
  167311. label: string | undefined;
  167312. }
  167313. type GPUCompilationMessageType =
  167314. | "error"
  167315. | "warning"
  167316. | "info";
  167317. interface GPUCompilationMessage {
  167318. readonly message: string;
  167319. readonly type: GPUCompilationMessageType;
  167320. readonly lineNum: number;
  167321. readonly linePos: number;
  167322. }
  167323. interface GPUCompilationInfo {
  167324. readonly messages: readonly GPUCompilationMessage[];
  167325. }
  167326. declare class GPUShaderModule implements GPUObjectBase {
  167327. private __brand: void;
  167328. label: string | undefined;
  167329. compilationInfo(): Promise<GPUCompilationInfo>;
  167330. }
  167331. declare class GPUSwapChain implements GPUObjectBase {
  167332. private __brand: void;
  167333. label: string | undefined;
  167334. getCurrentTexture(): GPUTexture;
  167335. }
  167336. declare class GPUTexture implements GPUObjectBase {
  167337. private __brand: void;
  167338. label: string | undefined;
  167339. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  167340. destroy(): void;
  167341. }
  167342. declare class GPUTextureView implements GPUObjectBase {
  167343. private __brand: void;
  167344. label: string | undefined;
  167345. }
  167346. type GPUPowerPreference = "low-power" | "high-performance";
  167347. interface GPURequestAdapterOptions {
  167348. powerPreference?: GPUPowerPreference;
  167349. }
  167350. declare class GPU {
  167351. private __brand: void;
  167352. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  167353. }
  167354. // ****************************************************************************
  167355. // ERROR SCOPES
  167356. // ****************************************************************************
  167357. type GPUErrorFilter = "out-of-memory" | "validation";
  167358. declare class GPUOutOfMemoryError {
  167359. private __brand: void;
  167360. constructor();
  167361. }
  167362. declare class GPUValidationError {
  167363. private __brand: void;
  167364. constructor(message: string);
  167365. readonly message: string;
  167366. }
  167367. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  167368. // ****************************************************************************
  167369. // TELEMETRY
  167370. // ****************************************************************************
  167371. declare class GPUUncapturedErrorEvent extends Event {
  167372. private __brand: void;
  167373. constructor(
  167374. type: string,
  167375. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  167376. );
  167377. readonly error: GPUError;
  167378. }
  167379. interface GPUUncapturedErrorEventInit extends EventInit {
  167380. error: GPUError;
  167381. }
  167382. declare class GPUDeviceLostInfo {
  167383. private __brand: void;
  167384. readonly message: string;
  167385. }
  167386. // Type definitions for WebVR API
  167387. // Project: https://w3c.github.io/webvr/
  167388. // Definitions by: six a <https://github.com/lostfictions>
  167389. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  167390. interface VRDisplay extends EventTarget {
  167391. /**
  167392. * Dictionary of capabilities describing the VRDisplay.
  167393. */
  167394. readonly capabilities: VRDisplayCapabilities;
  167395. /**
  167396. * z-depth defining the far plane of the eye view frustum
  167397. * enables mapping of values in the render target depth
  167398. * attachment to scene coordinates. Initially set to 10000.0.
  167399. */
  167400. depthFar: number;
  167401. /**
  167402. * z-depth defining the near plane of the eye view frustum
  167403. * enables mapping of values in the render target depth
  167404. * attachment to scene coordinates. Initially set to 0.01.
  167405. */
  167406. depthNear: number;
  167407. /**
  167408. * An identifier for this distinct VRDisplay. Used as an
  167409. * association point in the Gamepad API.
  167410. */
  167411. readonly displayId: number;
  167412. /**
  167413. * A display name, a user-readable name identifying it.
  167414. */
  167415. readonly displayName: string;
  167416. readonly isConnected: boolean;
  167417. readonly isPresenting: boolean;
  167418. /**
  167419. * If this VRDisplay supports room-scale experiences, the optional
  167420. * stage attribute contains details on the room-scale parameters.
  167421. */
  167422. readonly stageParameters: VRStageParameters | null;
  167423. /**
  167424. * Passing the value returned by `requestAnimationFrame` to
  167425. * `cancelAnimationFrame` will unregister the callback.
  167426. * @param handle Define the hanle of the request to cancel
  167427. */
  167428. cancelAnimationFrame(handle: number): void;
  167429. /**
  167430. * Stops presenting to the VRDisplay.
  167431. * @returns a promise to know when it stopped
  167432. */
  167433. exitPresent(): Promise<void>;
  167434. /**
  167435. * Return the current VREyeParameters for the given eye.
  167436. * @param whichEye Define the eye we want the parameter for
  167437. * @returns the eye parameters
  167438. */
  167439. getEyeParameters(whichEye: string): VREyeParameters;
  167440. /**
  167441. * Populates the passed VRFrameData with the information required to render
  167442. * the current frame.
  167443. * @param frameData Define the data structure to populate
  167444. * @returns true if ok otherwise false
  167445. */
  167446. getFrameData(frameData: VRFrameData): boolean;
  167447. /**
  167448. * Get the layers currently being presented.
  167449. * @returns the list of VR layers
  167450. */
  167451. getLayers(): VRLayer[];
  167452. /**
  167453. * Return a VRPose containing the future predicted pose of the VRDisplay
  167454. * when the current frame will be presented. The value returned will not
  167455. * change until JavaScript has returned control to the browser.
  167456. *
  167457. * The VRPose will contain the position, orientation, velocity,
  167458. * and acceleration of each of these properties.
  167459. * @returns the pose object
  167460. */
  167461. getPose(): VRPose;
  167462. /**
  167463. * Return the current instantaneous pose of the VRDisplay, with no
  167464. * prediction applied.
  167465. * @returns the current instantaneous pose
  167466. */
  167467. getImmediatePose(): VRPose;
  167468. /**
  167469. * The callback passed to `requestAnimationFrame` will be called
  167470. * any time a new frame should be rendered. When the VRDisplay is
  167471. * presenting the callback will be called at the native refresh
  167472. * rate of the HMD. When not presenting this function acts
  167473. * identically to how window.requestAnimationFrame acts. Content should
  167474. * make no assumptions of frame rate or vsync behavior as the HMD runs
  167475. * asynchronously from other displays and at differing refresh rates.
  167476. * @param callback Define the action to run next frame
  167477. * @returns the request handle it
  167478. */
  167479. requestAnimationFrame(callback: FrameRequestCallback): number;
  167480. /**
  167481. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  167482. * Repeat calls while already presenting will update the VRLayers being displayed.
  167483. * @param layers Define the list of layer to present
  167484. * @returns a promise to know when the request has been fulfilled
  167485. */
  167486. requestPresent(layers: VRLayer[]): Promise<void>;
  167487. /**
  167488. * Reset the pose for this display, treating its current position and
  167489. * orientation as the "origin/zero" values. VRPose.position,
  167490. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  167491. * updated when calling resetPose(). This should be called in only
  167492. * sitting-space experiences.
  167493. */
  167494. resetPose(): void;
  167495. /**
  167496. * The VRLayer provided to the VRDisplay will be captured and presented
  167497. * in the HMD. Calling this function has the same effect on the source
  167498. * canvas as any other operation that uses its source image, and canvases
  167499. * created without preserveDrawingBuffer set to true will be cleared.
  167500. * @param pose Define the pose to submit
  167501. */
  167502. submitFrame(pose?: VRPose): void;
  167503. }
  167504. declare var VRDisplay: {
  167505. prototype: VRDisplay;
  167506. new(): VRDisplay;
  167507. };
  167508. interface VRLayer {
  167509. leftBounds?: number[] | Float32Array | null;
  167510. rightBounds?: number[] | Float32Array | null;
  167511. source?: HTMLCanvasElement | null;
  167512. }
  167513. interface VRDisplayCapabilities {
  167514. readonly canPresent: boolean;
  167515. readonly hasExternalDisplay: boolean;
  167516. readonly hasOrientation: boolean;
  167517. readonly hasPosition: boolean;
  167518. readonly maxLayers: number;
  167519. }
  167520. interface VREyeParameters {
  167521. /** @deprecated */
  167522. readonly fieldOfView: VRFieldOfView;
  167523. readonly offset: Float32Array;
  167524. readonly renderHeight: number;
  167525. readonly renderWidth: number;
  167526. }
  167527. interface VRFieldOfView {
  167528. readonly downDegrees: number;
  167529. readonly leftDegrees: number;
  167530. readonly rightDegrees: number;
  167531. readonly upDegrees: number;
  167532. }
  167533. interface VRFrameData {
  167534. readonly leftProjectionMatrix: Float32Array;
  167535. readonly leftViewMatrix: Float32Array;
  167536. readonly pose: VRPose;
  167537. readonly rightProjectionMatrix: Float32Array;
  167538. readonly rightViewMatrix: Float32Array;
  167539. readonly timestamp: number;
  167540. }
  167541. interface VRPose {
  167542. readonly angularAcceleration: Float32Array | null;
  167543. readonly angularVelocity: Float32Array | null;
  167544. readonly linearAcceleration: Float32Array | null;
  167545. readonly linearVelocity: Float32Array | null;
  167546. readonly orientation: Float32Array | null;
  167547. readonly position: Float32Array | null;
  167548. readonly timestamp: number;
  167549. }
  167550. interface VRStageParameters {
  167551. sittingToStandingTransform?: Float32Array;
  167552. sizeX?: number;
  167553. sizeY?: number;
  167554. }
  167555. interface Navigator {
  167556. getVRDisplays(): Promise<VRDisplay[]>;
  167557. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  167558. }
  167559. interface Window {
  167560. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  167561. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  167562. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  167563. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  167564. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  167565. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  167566. }
  167567. interface Gamepad {
  167568. readonly displayId: number;
  167569. }
  167570. /**
  167571. * Available session modes
  167572. */
  167573. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  167574. /**
  167575. * Reference space types
  167576. */
  167577. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  167578. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  167579. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  167580. /**
  167581. * Handedness types
  167582. */
  167583. type XRHandedness = "none" | "left" | "right";
  167584. /**
  167585. * InputSource target ray modes
  167586. */
  167587. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  167588. /**
  167589. * Eye types
  167590. */
  167591. type XREye = "none" | "left" | "right";
  167592. /**
  167593. * Type of XR events available
  167594. */
  167595. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  167596. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  167597. type XRPlaneSet = Set<XRPlane>;
  167598. type XRAnchorSet = Set<XRAnchor>;
  167599. type XREventHandler = (callback: any) => void;
  167600. interface XRLayer extends EventTarget {}
  167601. interface XRSessionInit {
  167602. optionalFeatures?: string[];
  167603. requiredFeatures?: string[];
  167604. trackedImages?: XRTrackedImageInit[];
  167605. }
  167606. interface XRSessionEvent extends Event {
  167607. readonly session: XRSession;
  167608. }
  167609. interface XRSystem {
  167610. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  167611. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  167612. }
  167613. interface XRViewport {
  167614. readonly x: number;
  167615. readonly y: number;
  167616. readonly width: number;
  167617. readonly height: number;
  167618. }
  167619. interface XRWebGLLayerInit {
  167620. antialias?: boolean;
  167621. depth?: boolean;
  167622. stencil?: boolean;
  167623. alpha?: boolean;
  167624. multiview?: boolean;
  167625. framebufferScaleFactor?: number;
  167626. }
  167627. declare class XRWebGLLayer {
  167628. static getNativeFramebufferScaleFactor(session: XRSession): number;
  167629. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  167630. readonly antialias: boolean;
  167631. readonly framebuffer: WebGLFramebuffer;
  167632. readonly framebufferWidth: number;
  167633. readonly framebufferHeight: number;
  167634. readonly ignoreDepthValues: boolean;
  167635. getViewport: (view: XRView) => XRViewport;
  167636. }
  167637. // tslint:disable-next-line no-empty-interface
  167638. interface XRSpace extends EventTarget {}
  167639. interface XRRenderState {
  167640. readonly baseLayer?: XRWebGLLayer;
  167641. readonly depthFar: number;
  167642. readonly depthNear: number;
  167643. readonly inlineVerticalFieldOfView?: number;
  167644. }
  167645. interface XRRenderStateInit extends XRRenderState {
  167646. baseLayer: XRWebGLLayer;
  167647. depthFar: number;
  167648. depthNear: number;
  167649. inlineVerticalFieldOfView?: number;
  167650. layers?: XRLayer[];
  167651. }
  167652. interface XRReferenceSpace extends XRSpace {
  167653. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  167654. onreset: XREventHandler;
  167655. }
  167656. interface XRBoundedReferenceSpace extends XRSpace {
  167657. readonly boundsGeometry: DOMPointReadOnly[];
  167658. }
  167659. interface XRInputSource {
  167660. readonly handedness: XRHandedness;
  167661. readonly targetRayMode: XRTargetRayMode;
  167662. readonly targetRaySpace: XRSpace;
  167663. readonly gripSpace?: XRSpace;
  167664. readonly gamepad?: Gamepad;
  167665. readonly profiles: Array<string>;
  167666. readonly hand?: XRHand;
  167667. }
  167668. interface XRPose {
  167669. readonly transform: XRRigidTransform;
  167670. readonly emulatedPosition: boolean;
  167671. }
  167672. interface XRWorldInformation {
  167673. detectedPlanes?: XRPlaneSet;
  167674. }
  167675. interface XRFrame {
  167676. readonly session: XRSession;
  167677. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  167678. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  167679. // AR
  167680. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  167681. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  167682. // Anchors
  167683. trackedAnchors?: XRAnchorSet;
  167684. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  167685. // World geometries
  167686. worldInformation?: XRWorldInformation;
  167687. // Hand tracking
  167688. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  167689. // Image tracking
  167690. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  167691. }
  167692. interface XRInputSourceEvent extends Event {
  167693. readonly frame: XRFrame;
  167694. readonly inputSource: XRInputSource;
  167695. }
  167696. type XRInputSourceArray = XRInputSource[];
  167697. interface XRSession {
  167698. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  167699. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  167700. /**
  167701. * Returns a list of this session's XRInputSources, each representing an input device
  167702. * used to control the camera and/or scene.
  167703. */
  167704. readonly inputSources: Array<XRInputSource>;
  167705. /**
  167706. * object which contains options affecting how the imagery is rendered.
  167707. * This includes things such as the near and far clipping planes
  167708. */
  167709. readonly renderState: XRRenderState;
  167710. readonly visibilityState: XRVisibilityState;
  167711. /**
  167712. * Removes a callback from the animation frame painting callback from
  167713. * XRSession's set of animation frame rendering callbacks, given the
  167714. * identifying handle returned by a previous call to requestAnimationFrame().
  167715. */
  167716. cancelAnimationFrame: (handle: number) => void;
  167717. /**
  167718. * Ends the WebXR session. Returns a promise which resolves when the
  167719. * session has been shut down.
  167720. */
  167721. end(): Promise<void>;
  167722. /**
  167723. * Schedules the specified method to be called the next time the user agent
  167724. * is working on rendering an animation frame for the WebXR device. Returns an
  167725. * integer value which can be used to identify the request for the purposes of
  167726. * canceling the callback using cancelAnimationFrame(). This method is comparable
  167727. * to the Window.requestAnimationFrame() method.
  167728. */
  167729. requestAnimationFrame: XRFrameRequestCallback;
  167730. /**
  167731. * Requests that a new XRReferenceSpace of the specified type be created.
  167732. * Returns a promise which resolves with the XRReferenceSpace or
  167733. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  167734. * the requested space type isn't supported by the device.
  167735. */
  167736. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  167737. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  167738. onend: XREventHandler;
  167739. oninputsourceschange: XREventHandler;
  167740. onselect: XREventHandler;
  167741. onselectstart: XREventHandler;
  167742. onselectend: XREventHandler;
  167743. onsqueeze: XREventHandler;
  167744. onsqueezestart: XREventHandler;
  167745. onsqueezeend: XREventHandler;
  167746. onvisibilitychange: XREventHandler;
  167747. // hit test
  167748. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  167749. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  167750. // legacy AR hit test
  167751. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  167752. // legacy plane detection
  167753. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  167754. // image tracking
  167755. getTrackedImageScores?(): XRImageTrackingScore[];
  167756. }
  167757. interface XRViewerPose extends XRPose {
  167758. readonly views: Array<XRView>;
  167759. }
  167760. declare class XRRigidTransform {
  167761. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  167762. position: DOMPointReadOnly;
  167763. orientation: DOMPointReadOnly;
  167764. matrix: Float32Array;
  167765. inverse: XRRigidTransform;
  167766. }
  167767. interface XRView {
  167768. readonly eye: XREye;
  167769. readonly projectionMatrix: Float32Array;
  167770. readonly transform: XRRigidTransform;
  167771. readonly recommendedViewportScale?: number;
  167772. requestViewportScale(scale: number): void;
  167773. }
  167774. interface XRInputSourceChangeEvent extends Event {
  167775. session: XRSession;
  167776. removed: Array<XRInputSource>;
  167777. added: Array<XRInputSource>;
  167778. }
  167779. // Experimental/Draft features
  167780. declare class XRRay {
  167781. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  167782. origin: DOMPointReadOnly;
  167783. direction: DOMPointReadOnly;
  167784. matrix: Float32Array;
  167785. }
  167786. declare enum XRHitTestTrackableType {
  167787. "point",
  167788. "plane",
  167789. "mesh",
  167790. }
  167791. interface XRHitResult {
  167792. hitMatrix: Float32Array;
  167793. }
  167794. interface XRTransientInputHitTestResult {
  167795. readonly inputSource: XRInputSource;
  167796. readonly results: Array<XRHitTestResult>;
  167797. }
  167798. interface XRHitTestResult {
  167799. getPose(baseSpace: XRSpace): XRPose | undefined;
  167800. // When anchor system is enabled
  167801. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  167802. }
  167803. interface XRHitTestSource {
  167804. cancel(): void;
  167805. }
  167806. interface XRTransientInputHitTestSource {
  167807. cancel(): void;
  167808. }
  167809. interface XRHitTestOptionsInit {
  167810. space: XRSpace;
  167811. entityTypes?: Array<XRHitTestTrackableType>;
  167812. offsetRay?: XRRay;
  167813. }
  167814. interface XRTransientInputHitTestOptionsInit {
  167815. profile: string;
  167816. entityTypes?: Array<XRHitTestTrackableType>;
  167817. offsetRay?: XRRay;
  167818. }
  167819. interface XRAnchor {
  167820. anchorSpace: XRSpace;
  167821. delete(): void;
  167822. }
  167823. interface XRPlane {
  167824. orientation: "Horizontal" | "Vertical";
  167825. planeSpace: XRSpace;
  167826. polygon: Array<DOMPointReadOnly>;
  167827. lastChangedTime: number;
  167828. }
  167829. interface XRJointSpace extends XRSpace {}
  167830. interface XRJointPose extends XRPose {
  167831. radius: number | undefined;
  167832. }
  167833. interface XRHand extends Iterable<XRJointSpace> {
  167834. readonly length: number;
  167835. [index: number]: XRJointSpace;
  167836. readonly WRIST: number;
  167837. readonly THUMB_METACARPAL: number;
  167838. readonly THUMB_PHALANX_PROXIMAL: number;
  167839. readonly THUMB_PHALANX_DISTAL: number;
  167840. readonly THUMB_PHALANX_TIP: number;
  167841. readonly INDEX_METACARPAL: number;
  167842. readonly INDEX_PHALANX_PROXIMAL: number;
  167843. readonly INDEX_PHALANX_INTERMEDIATE: number;
  167844. readonly INDEX_PHALANX_DISTAL: number;
  167845. readonly INDEX_PHALANX_TIP: number;
  167846. readonly MIDDLE_METACARPAL: number;
  167847. readonly MIDDLE_PHALANX_PROXIMAL: number;
  167848. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  167849. readonly MIDDLE_PHALANX_DISTAL: number;
  167850. readonly MIDDLE_PHALANX_TIP: number;
  167851. readonly RING_METACARPAL: number;
  167852. readonly RING_PHALANX_PROXIMAL: number;
  167853. readonly RING_PHALANX_INTERMEDIATE: number;
  167854. readonly RING_PHALANX_DISTAL: number;
  167855. readonly RING_PHALANX_TIP: number;
  167856. readonly LITTLE_METACARPAL: number;
  167857. readonly LITTLE_PHALANX_PROXIMAL: number;
  167858. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  167859. readonly LITTLE_PHALANX_DISTAL: number;
  167860. readonly LITTLE_PHALANX_TIP: number;
  167861. }
  167862. type XRImageTrackingState = "tracked" | "emulated";
  167863. type XRImageTrackingScore = "untrackable" | "trackable";
  167864. interface XRTrackedImageInit {
  167865. image: ImageBitmap;
  167866. widthInMeters: number;
  167867. }
  167868. interface XRImageTrackingResult {
  167869. readonly imageSpace: XRSpace;
  167870. readonly index: number;
  167871. readonly trackingState: XRImageTrackingState;
  167872. readonly measuredWidthInMeters: number;
  167873. }
  167874. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  167875. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  167876. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  167877. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  167878. interface XRSceneObject {
  167879. type: XRSceneObjectType;
  167880. }
  167881. interface XRFieldOfView {
  167882. angleLeft: number;
  167883. angleRight: number;
  167884. angleUp: number;
  167885. angleDown: number;
  167886. }
  167887. interface XRFrustum {
  167888. position: DOMPointReadOnly;
  167889. orientation: DOMPointReadOnly;
  167890. fieldOfView: XRFieldOfView;
  167891. farDistance: number;
  167892. }
  167893. interface XRPlane {
  167894. parentSceneObject?: XRSceneObject;
  167895. }
  167896. interface XRMesh {
  167897. meshSpace: XRSpace;
  167898. positions: Float32Array;
  167899. indices: Uint32Array;
  167900. normals?: Float32Array;
  167901. lastChangedTime: number;
  167902. parentSceneObject?: XRSceneObject;
  167903. }
  167904. interface XRFrustumDetectionBoundary {
  167905. type: "frustum";
  167906. frustum: XRFrustum;
  167907. }
  167908. interface XRSphereDetectionBoundary {
  167909. type: "sphere";
  167910. radius: number;
  167911. }
  167912. interface XRBoxDetectionBoundary {
  167913. type: "box";
  167914. extent: DOMPointReadOnly;
  167915. }
  167916. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  167917. interface XRGeometryDetectorOptions {
  167918. detectionBoundary?: XRDetectionBoundary;
  167919. updateInterval?: number;
  167920. }
  167921. interface XRSession {
  167922. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  167923. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  167924. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  167925. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  167926. }
  167927. interface XRFrame {
  167928. featurePointCloud?: Array<number>;
  167929. }
  167930. type XRMeshSet = Set<XRMesh>;
  167931. interface XRWorldInformation {
  167932. detectedMeshes?: XRMeshSet;
  167933. }